summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-04-20 22:41:39 +0200
committerGeorg Ehrke <dev@georgswebsite.de>2012-04-20 22:41:39 +0200
commit711aa229b882d3fc5e2fa8c22e6db2ec05642984 (patch)
tree5098a6dacf65a3d557977ff39b52ac527a0eb777 /lib
parent12ef2f5054ebae12853f51d067993b825e4b4286 (diff)
parent0f5864d864f63a7142064d142661c46644b2d0db (diff)
downloadnextcloud-server-711aa229b882d3fc5e2fa8c22e6db2ec05642984.tar.gz
nextcloud-server-711aa229b882d3fc5e2fa8c22e6db2ec05642984.zip
Merge branch 'master' into movable_apps
Diffstat (limited to 'lib')
-rwxr-xr-xlib/helper.php20
-rw-r--r--lib/mail.php116
-rwxr-xr-xlib/ocsclient.php5
3 files changed, 139 insertions, 2 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 77b56051419..34f8faad4a5 100755
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -358,6 +358,26 @@ class OC_Helper {
}
/**
+ * get the mimetype form a data string
+ * @param string data
+ * @return string
+ */
+ static function getStringMimeType($data){
+ if(function_exists('finfo_open') and function_exists('finfo_file')){
+ $finfo=finfo_open(FILEINFO_MIME);
+ return finfo_buffer($finfo, $data);
+ }else{
+ $tmpFile=OC_Helper::tmpFile();
+ $fh=fopen($tmpFile,'wb');
+ fwrite($fh,$data,8024);
+ fclose($fh);
+ $mime=self::getMimeType($tmpFile);
+ unset($tmpFile);
+ return $mime;
+ }
+ }
+
+ /**
* @brief Checks $_REQUEST contains a var for the $s key. If so, returns the html-escaped value of this var; otherwise returns the default value provided by $d.
* @param $s name of the var to escape, if set.
* @param $d default value.
diff --git a/lib/mail.php b/lib/mail.php
new file mode 100644
index 00000000000..0045f8de6da
--- /dev/null
+++ b/lib/mail.php
@@ -0,0 +1,116 @@
+<?php
+/**
+ * Copyright (c) 2012 Frank Karlitschek <frank@owncloud.org>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+/**
+ * OC_Mail
+ *
+ * A class to handle mail sending.
+ */
+
+require_once('class.phpmailer.php');
+
+class OC_Mail {
+
+ /**
+ * send an email
+ *
+ * @param string $toaddress
+ * @param string $toname
+ * @param string $subject
+ * @param string $mailtext
+ * @param string $fromaddress
+ * @param string $fromname
+ * @param bool $html
+ */
+ public static function send($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='',$bcc='') {
+
+ $SMTPMODE = OC_Config::getValue( 'mail_smtpmode', 'sendmail' );
+ $SMTPHOST = OC_Config::getValue( 'mail_smtphost', '127.0.0.1' );
+ $SMTPAUTH = OC_Config::getValue( 'mail_smtpauth', 'false' );
+ $SMTPUSERNAME = OC_Config::getValue( 'mail_smtpname', '' );
+ $SMTPPASSWORD = OC_Config::getValue( 'mail_smtppassword', '' );
+
+
+ $mailo = new PHPMailer();
+ if($SMTPMODE=='sendmail') {
+ $mailo->IsSendmail();
+ }elseif($SMTPMODE=='smtp'){
+ $mailo->IsSMTP();
+ }elseif($SMTPMODE=='qmail'){
+ $mailo->IsQmail();
+ }else{
+ $mailo->IsMail();
+ }
+
+
+ $mailo->Host = $SMTPHOST;
+ $mailo->SMTPAuth = $SMTPAUTH;
+ $mailo->Username = $SMTPUSERNAME;
+ $mailo->Password = $SMTPPASSWORD;
+
+ $mailo->From =$fromaddress;
+ $mailo->FromName = $fromname;;
+ $a=explode(' ',$toaddress);
+ foreach($a as $ad) {
+ $mailo->AddAddress($ad,$toname);
+ }
+
+ if($ccaddress<>'') $mailo->AddCC($ccaddress,$ccname);
+ if($bcc<>'') $mailo->AddBCC($bcc);
+
+ $mailo->AddReplyTo($fromaddress, $fromname);
+
+ $mailo->WordWrap = 50;
+ if($html==1) $mailo->IsHTML(true); else $mailo->IsHTML(false);
+
+ $mailo->Subject = $subject;
+ if($altbody=='') {
+ $mailo->Body = $mailtext.OC_MAIL::getfooter();
+ $mailo->AltBody = '';
+ }else{
+ $mailo->Body = $mailtext;
+ $mailo->AltBody = $altbody;
+ }
+ $mailo->CharSet = 'UTF-8';
+
+ $mailo->Send();
+ unset($mailo);
+
+ OC_Log::write('Mail from '.$fromname.' ('.$fromaddress.')'.' to: '.$toname.'('.$toaddress.')'.' subject: '.$subject,'mail',OC_Log::DEBUG);
+
+ }
+
+
+
+ /**
+ * sending a mail based on a template
+ *
+ * @param texttemplate $texttemplate
+ * @param htmltemplate $htmltemplate
+ * @param data $data
+ * @param To $toaddress
+ * @param ToName $toname
+ * @param Subject $subject
+ * @param From $fromaddress
+ * @param FromName $fromname
+ * @param ccaddress $ccaddress
+ * @param ccname $ccname
+ * @param bcc $bcc
+ */
+ public static function getfooter() {
+
+ $txt="\n--\n";
+ $txt.="ownCloud\n";
+ $txt.="Your Cloud, Your Data, Your Way!\n";
+ return($txt);
+
+ }
+
+
+
+}
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index d830a4f3e7e..9ad9ef21c66 100755
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -199,7 +199,7 @@ class OC_OCSClient{
*
* This function returns a list of all the knowledgebase entries from the OCS server
*/
- public static function getKnownledgebaseEntries($page,$pagesize){
+ public static function getKnownledgebaseEntries($page,$pagesize,$search=''){
if(OC_Config::getValue('knowledgebaseenabled', true)==false){
$kbe=array();
$kbe['totalitems']=0;
@@ -208,7 +208,8 @@ class OC_OCSClient{
$p= (int) $page;
$s= (int) $pagesize;
- $url=OC_OCSClient::getKBURL().'/knowledgebase/data?type=150&page='.$p.'&pagesize='.$s;
+ if($search<>'') $searchcmd='&search='.urlencode($search); else $searchcmd='';
+ $url=OC_OCSClient::getKBURL().'/knowledgebase/data?type=150&page='.$p.'&pagesize='.$s.$searchcmd;
$kbe=array();
$xml=@file_get_contents($url);