diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/app.php | 4 | ||||
-rw-r--r-- | lib/base.php | 3 | ||||
-rw-r--r-- | lib/filecache.php | 15 | ||||
-rw-r--r-- | lib/filesystem.php | 48 | ||||
-rw-r--r-- | lib/filesystemview.php | 19 | ||||
-rw-r--r-- | lib/public/util.php | 60 |
6 files changed, 141 insertions, 8 deletions
diff --git a/lib/app.php b/lib/app.php index 9f7d23872f3..29653775253 100755 --- a/lib/app.php +++ b/lib/app.php @@ -519,6 +519,10 @@ class OC_App{ public static function getStorage($appid){ if(OC_App::isEnabled($appid)){//sanity check if(OC_User::isLoggedIn()){ + $view = new OC_FilesystemView('/'.OC_User::getUser()); + if(!$view->file_exists($appid)) { + $view->mkdir($appid); + } return new OC_FilesystemView('/'.OC_User::getUser().'/'.$appid); }else{ OC_Log::write('core','Can\'t get app storage, app, user not logged in',OC_Log::ERROR); diff --git a/lib/base.php b/lib/base.php index f3dacdc0f76..5c42000b9e1 100644 --- a/lib/base.php +++ b/lib/base.php @@ -81,6 +81,9 @@ class OC{ elseif(strpos($className,'OC_')===0){ require_once strtolower(str_replace('_','/',substr($className,3)) . '.php'); } + elseif(strpos($className,'OCP\\')===0){ + require_once 'public/'.strtolower(str_replace('\\','/',substr($className,3)) . '.php'); + } elseif(strpos($className,'Sabre_')===0) { require_once str_replace('_','/',$className) . '.php'; } diff --git a/lib/filecache.php b/lib/filecache.php index 19286ff746b..28a9eb247a6 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -64,7 +64,7 @@ class OC_FileCache{ if(is_array($result)){ return $result; }else{ - OC_Log::write('get(): file not found in cache ('.$path.')','core',OC_Log::DEBUG); + OC_Log::write('files','get(): file not found in cache ('.$path.')',OC_Log::DEBUG); return false; } } @@ -257,7 +257,7 @@ class OC_FileCache{ if(is_array($result)){ return $result; }else{ - OC_Log::write('getFolderContent(): file not found in cache ('.$path.')','core',OC_Log::DEBUG); + OC_Log::write('files','getFolderContent(): file not found in cache ('.$path.')',OC_Log::DEBUG); return false; } } @@ -300,7 +300,7 @@ class OC_FileCache{ if(is_array($result)){ return $result['id']; }else{ - OC_Log::write('getFileId(): file not found in cache ('.$path.')','core',OC_Log::DEBUG); + OC_Log::write('files','getFileId(): file not found in cache ('.$path.')',OC_Log::DEBUG); return -1; } } @@ -414,8 +414,12 @@ class OC_FileCache{ } return $result; }else{ - OC_Log::write('get(): file not found in cache ('.$path.')','core',OC_Log::DEBUG); - return false; + OC_Log::write('files','getChached(): file not found in cache ('.$path.')',OC_Log::DEBUG); + if(isset(self::$savedData[$path])){ + return self::$savedData[$path]; + }else{ + return array(); + } } } @@ -553,6 +557,7 @@ class OC_FileCache{ $view=new OC_FilesystemView(($root=='/')?'':$root); } if(!$view->is_readable($path)) return; //cant read, nothing we can do + clearstatcache(); $stat=$view->stat($path); $mimetype=$view->getMimeType($path); $writable=$view->is_writable($path); diff --git a/lib/filesystem.php b/lib/filesystem.php index dc678fba74c..1b91eabc7c1 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -196,10 +196,58 @@ class OC_Filesystem{ return false; } self::$defaultInstance=new OC_FilesystemView($root); + + //load custom mount config + if(is_file(OC::$SERVERROOT.'/config/mount.php')){ + $mountConfig=include(OC::$SERVERROOT.'/config/mount.php'); + if(isset($mountConfig['global'])){ + foreach($mountConfig['global'] as $mountPoint=>$options){ + self::mount($options['class'],$options['options'],$mountPoint); + } + } + + if(isset($mountConfig['group'])){ + foreach($mountConfig['group'] as $group=>$mounts){ + if(OC_Group::inGroup(OC_User::getUser(),$group)){ + foreach($mounts as $mountPoint=>$options){ + $mountPoint=self::setUserVars($mountPoint); + foreach($options as &$option){ + $option=self::setUserVars($option); + } + self::mount($options['class'],$options['options'],$mountPoint); + } + } + } + } + + if(isset($mountConfig['user'])){ + foreach($mountConfig['user'] as $user=>$mounts){ + if($user==='all' or strtolower($user)===strtolower(OC_User::getUser())){ + foreach($mounts as $mountPoint=>$options){ + $mountPoint=self::setUserVars($mountPoint); + foreach($options as &$option){ + $option=self::setUserVars($option); + } + self::mount($options['class'],$options['options'],$mountPoint); + } + } + } + } + } + self::$loaded=true; } /** + * fill in the correct values for $user, and $password placeholders + * @param string intput + * @return string + */ + private static function setUserVars($input){ + return str_replace('$user',OC_User::getUser(),$input); + } + + /** * get the default filesystem view * @return OC_FilesystemView */ diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 95873bd87cf..ac5a0a3bff5 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -136,15 +136,16 @@ class OC_FilesystemView { return $this->basicOperation('filesize',$path); } public function readfile($path){ + @ob_end_clean(); $handle=$this->fopen($path,'r'); if ($handle) { - $chunkSize = 1024*1024;// 1 MB chunks + $chunkSize = 8*1024;// 1 MB chunks while (!feof($handle)) { echo fread($handle, $chunkSize); - @ob_flush(); flush(); } - return $this->filesize($path); + $size=$this->filesize($path); + return $size; } return false; } @@ -174,11 +175,23 @@ class OC_FilesystemView { } public function file_put_contents($path,$data){ if(is_resource($data)){//not having to deal with streams in file_put_contents makes life easier + $exists=$this->file_exists($path); + $run=true; + if(!$exists){ + OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, array( OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run)); + } + OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, array( OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run)); + if(!$run){ + return false; + } $target=$this->fopen($path,'w'); if($target){ $count=OC_Helper::streamCopy($data,$target); fclose($target); fclose($data); + if(!$exists){ + OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_create, array( OC_Filesystem::signal_param_path => $path)); + } OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, array( OC_Filesystem::signal_param_path => $path)); return $count>0; }else{ diff --git a/lib/public/util.php b/lib/public/util.php new file mode 100644 index 00000000000..3425ed9df3b --- /dev/null +++ b/lib/public/util.php @@ -0,0 +1,60 @@ +<?php +/** +* ownCloud +* +* @author Frank Karlitschek +* @copyright 2010 Frank Karlitschek karlitschek@kde.org +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +* +*/ + +/** + * Public interface of ownCloud for apps to use. + * Utility Class. + * + */ + +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes +namespace OCP; + +class Util { + + /** + * 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 sendmail($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='',$bcc='') { + + // call the internal mail class + OC_MAIL::send($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='',$bcc=''); + + } + + + +} + + + + +?> |