summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-04-21 23:21:50 +0200
committerGeorg Ehrke <dev@georgswebsite.de>2012-04-21 23:21:50 +0200
commit0918fc7d9156f3846a19b673db5b01422a59c506 (patch)
tree131188252fd42c4f3c9673975adafa24783c632f /lib
parent77cefdedb86de65e69f470c8b6a1b03bb001966e (diff)
parent74e540271122222f650bbbfaeaac310b0e592674 (diff)
downloadnextcloud-server-0918fc7d9156f3846a19b673db5b01422a59c506.tar.gz
nextcloud-server-0918fc7d9156f3846a19b673db5b01422a59c506.zip
fix merge conflicts
Diffstat (limited to 'lib')
-rwxr-xr-xlib/app.php2
-rw-r--r--lib/filecache.php7
-rw-r--r--lib/group/backend.php2
-rwxr-xr-xlib/helper.php25
-rw-r--r--lib/log/owncloud.php12
-rw-r--r--lib/mail.php116
-rwxr-xr-xlib/ocsclient.php6
-rw-r--r--lib/util.php40
8 files changed, 183 insertions, 27 deletions
diff --git a/lib/app.php b/lib/app.php
index bd432109b23..9f7d23872f3 100755
--- a/lib/app.php
+++ b/lib/app.php
@@ -303,8 +303,6 @@ class OC_App{
$settings[] = array( "id" => "core_users", "order" => 2, "href" => OC_Helper::linkTo( "settings", "users.php" ), "name" => $l->t("Users"), "icon" => OC_Helper::imagePath( "settings", "users.svg" ));
// admin apps menu
$settings[] = array( "id" => "core_apps", "order" => 3, "href" => OC_Helper::linkTo( "settings", "apps.php" ).'?installed', "name" => $l->t("Apps"), "icon" => OC_Helper::imagePath( "settings", "apps.svg" ));
- // admin log menu
- $settings[] = array( "id" => "core_log", "order" => 4, "href" => OC_Helper::linkTo( "settings", "log.php" ), "name" => $l->t("Log"), "icon" => OC_Helper::imagePath( "settings", "log.svg" ));
$settings[]=array( "id" => "admin", "order" => 1000, "href" => OC_Helper::linkTo( "settings", "admin.php" ), "name" => $l->t("Admin"), "icon" => OC_Helper::imagePath( "settings", "admin.svg" ));
}
diff --git a/lib/filecache.php b/lib/filecache.php
index e62fb2189f4..19286ff746b 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -335,7 +335,12 @@ class OC_FileCache{
$query=OC_DB::prepare('SELECT path FROM *PREFIX*fscache WHERE id=? AND user=?');
$result=$query->execute(array($id,$user));
$row=$result->fetchRow();
- return $row['path'];
+ $path=$row['path'];
+ $root='/'.$user.'/files';
+ if(substr($path,0,strlen($root))!=$root){
+ return false;
+ }
+ return substr($path,strlen($root));
}
/**
diff --git a/lib/group/backend.php b/lib/group/backend.php
index d0bc970da73..af6c53c8035 100644
--- a/lib/group/backend.php
+++ b/lib/group/backend.php
@@ -89,7 +89,7 @@ abstract class OC_Group_Backend {
* @return bool
*/
public function groupExists($gid){
- if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_GROUPS)){
+ if(!$this->implementsActions(OC_GROUP_BACKEND_GET_GROUPS)){
return false;
}
return in_array($gid, $this->getGroups());
diff --git a/lib/helper.php b/lib/helper.php
index 412f0e6b764..beb10280d93 100755
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -354,6 +354,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.
@@ -502,6 +522,9 @@ class OC_Helper {
*/
public static function buildNotExistingFileName($path, $filename)
{
+ if($path==='/'){
+ $path='';
+ }
if ($pos = strrpos($filename, '.')) {
$name = substr($filename, 0, $pos);
$ext = substr($filename, $pos);
@@ -518,6 +541,6 @@ class OC_Helper {
$counter++;
}
- return $newname;
+ return $newpath;
}
}
diff --git a/lib/log/owncloud.php b/lib/log/owncloud.php
index 0ed30510134..881c67d2664 100644
--- a/lib/log/owncloud.php
+++ b/lib/log/owncloud.php
@@ -44,7 +44,7 @@ class OC_Log_Owncloud {
* @param int level
*/
public static function write($app, $message, $level) {
- $minLevel=OC_Config::getValue( "loglevel", 2 );
+ $minLevel=min(OC_Config::getValue( "loglevel", OC_Log::WARN ),OC_Log::ERROR);
if($level>=$minLevel){
$entry=array('app'=>$app, 'message'=>$message, 'level'=>$level,'time'=>time());
$fh=fopen(self::$logFile, 'a');
@@ -61,6 +61,7 @@ class OC_Log_Owncloud {
*/
public static function getEntries($limit=50, $offset=0){
self::init();
+ $minLevel=OC_Config::getValue( "loglevel", OC_Log::WARN );
$entries=array();
if(!file_exists(self::$logFile)) {
return array();
@@ -71,8 +72,13 @@ class OC_Log_Owncloud {
}
$end=max(count($contents)-$offset-1, 0);
$start=max($end-$limit,0);
- for($i=$end;$i>$start;$i--) {
- $entries[]=json_decode($contents[$i]);
+ $i=$end;
+ while(count($entries)<$limit){
+ $entry=json_decode($contents[$i]);
+ if($entry->level>=$minLevel){
+ $entries[]=$entry;
+ }
+ $i--;
}
return $entries;
}
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..aef51f38fb7 100755
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -162,6 +162,7 @@ class OC_OCSClient{
$app['preview3']=$tmp->smallpreviewpic3;
$app['changed']=strtotime($tmp->changed);
$app['description']=$tmp->description;
+ $app['detailpage']=$tmp->detailpage;
return $app;
}
@@ -199,7 +200,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 +209,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);
diff --git a/lib/util.php b/lib/util.php
index 2ea392ec31d..ec70fd91cb5 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -129,23 +129,23 @@ class OC_Util {
self::$headers[]=array('tag'=>$tag,'attributes'=>$attributes,'text'=>$text);
}
- /**
- * formats a timestamp in the "right" way
- *
- * @param int timestamp $timestamp
- * @param bool dateOnly option to ommit time from the result
- */
- public static function formatDate( $timestamp,$dateOnly=false){
- if(isset($_SESSION['timezone'])){//adjust to clients timezone if we know it
- $systemTimeZone = intval(date('O'));
- $systemTimeZone=(round($systemTimeZone/100,0)*60)+($systemTimeZone%100);
- $clientTimeZone=$_SESSION['timezone']*60;
- $offset=$clientTimeZone-$systemTimeZone;
- $timestamp=$timestamp+$offset*60;
- }
- $timeformat=$dateOnly?'F j, Y':'F j, Y, H:i';
- return date($timeformat,$timestamp);
- }
+ /**
+ * formats a timestamp in the "right" way
+ *
+ * @param int timestamp $timestamp
+ * @param bool dateOnly option to ommit time from the result
+ */
+ public static function formatDate( $timestamp,$dateOnly=false){
+ if(isset($_SESSION['timezone'])){//adjust to clients timezone if we know it
+ $systemTimeZone = intval(date('O'));
+ $systemTimeZone=(round($systemTimeZone/100,0)*60)+($systemTimeZone%100);
+ $clientTimeZone=$_SESSION['timezone']*60;
+ $offset=$clientTimeZone-$systemTimeZone;
+ $timestamp=$timestamp+$offset*60;
+ }
+ $timeformat=$dateOnly?'F j, Y':'F j, Y, H:i';
+ return date($timeformat,$timestamp);
+ }
/**
* Shows a pagenavi widget where you can jump to different pages.
@@ -237,6 +237,12 @@ class OC_Util {
if(!function_exists('ctype_digit')){
$errors[]=array('error'=>'PHP module ctype is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
}
+ if(!function_exists('json_encode')){
+ $errors[]=array('error'=>'PHP module JSON is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
+ }
+ if(!function_exists('imagepng')){
+ $errors[]=array('error'=>'PHP module GD is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.');
+ }
return $errors;
}