diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-10-24 21:55:25 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-10-24 21:55:25 +0200 |
commit | 675a56c5ed798afae6bc9e56616f948a2c4496c2 (patch) | |
tree | 53f8b9688d4ace289d8b5438e22fa3d857e3aa5b /lib | |
parent | befdd6b63b1f64625bd26d50b18ebef5b8f82db4 (diff) | |
parent | 515e1b467e58337067ee3a4a8945f449d3c2ef3a (diff) | |
download | nextcloud-server-675a56c5ed798afae6bc9e56616f948a2c4496c2.tar.gz nextcloud-server-675a56c5ed798afae6bc9e56616f948a2c4496c2.zip |
Merge branch 'master' of github.com:owncloud/core into vcategories_db
Conflicts:
lib/vcategories.php
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MDB2/Driver/Function/sqlite3.php | 2 | ||||
-rwxr-xr-x | lib/app.php | 7 | ||||
-rw-r--r-- | lib/appconfig.php | 2 | ||||
-rw-r--r-- | lib/base.php | 2 | ||||
-rw-r--r-- | lib/connector/sabre/auth.php | 2 | ||||
-rw-r--r-- | lib/connector/sabre/locks.php | 2 | ||||
-rw-r--r-- | lib/eventsource.php | 6 | ||||
-rw-r--r-- | lib/filecache.php | 86 | ||||
-rw-r--r-- | lib/filechunking.php | 2 | ||||
-rw-r--r-- | lib/fileproxy.php | 4 | ||||
-rw-r--r-- | lib/fileproxy/quota.php | 54 | ||||
-rw-r--r-- | lib/files.php | 48 | ||||
-rw-r--r-- | lib/filestorage.php | 1 | ||||
-rw-r--r-- | lib/filestorage/common.php | 11 | ||||
-rw-r--r-- | lib/filestorage/local.php | 4 | ||||
-rw-r--r-- | lib/filesystem.php | 6 | ||||
-rw-r--r-- | lib/filesystemview.php | 5 | ||||
-rw-r--r-- | lib/helper.php | 24 | ||||
-rw-r--r-- | lib/installer.php | 6 | ||||
-rw-r--r-- | lib/l10n.php | 18 | ||||
-rw-r--r-- | lib/migrate.php | 6 | ||||
-rw-r--r-- | lib/ocsclient.php | 26 | ||||
-rw-r--r-- | lib/search/provider/file.php | 13 | ||||
-rw-r--r-- | lib/setup.php | 6 | ||||
-rw-r--r-- | lib/streamwrappers.php | 8 | ||||
-rw-r--r-- | lib/template.php | 4 | ||||
-rw-r--r-- | lib/templatelayout.php | 4 | ||||
-rw-r--r-- | lib/updater.php | 8 | ||||
-rw-r--r-- | lib/user.php | 10 | ||||
-rwxr-xr-x | lib/util.php | 14 | ||||
-rw-r--r-- | lib/vcategories.php | 2 | ||||
-rw-r--r-- | lib/vobject.php | 14 |
32 files changed, 217 insertions, 190 deletions
diff --git a/lib/MDB2/Driver/Function/sqlite3.php b/lib/MDB2/Driver/Function/sqlite3.php index 235a106e183..0bddde5bf3f 100644 --- a/lib/MDB2/Driver/Function/sqlite3.php +++ b/lib/MDB2/Driver/Function/sqlite3.php @@ -94,7 +94,7 @@ class MDB2_Driver_Function_sqlite3 extends MDB2_Driver_Function_Common if (!is_null($length)) { return "substr($value,$position,$length)"; } - return "substr($value,$position,length($value))"; + return "substr($value, $position, length($value))"; } // }}} diff --git a/lib/app.php b/lib/app.php index cb68ea3ddde..28757735e04 100755 --- a/lib/app.php +++ b/lib/app.php @@ -549,17 +549,14 @@ class OC_App{ foreach ( OC::$APPSROOTS as $apps_dir ) { if(! is_readable($apps_dir['path'])) { - OC_Log::write('core', 'unable to read app folder : ' .$apps_dir['path'] , OC_Log::WARN); + OC_Log::write('core', 'unable to read app folder : ' .$apps_dir['path'], OC_Log::WARN); continue; } $dh = opendir( $apps_dir['path'] ); while( $file = readdir( $dh ) ) { - if ( - $file[0] != '.' - and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php' ) - ) { + if ($file[0] != '.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')) { $apps[] = $file; diff --git a/lib/appconfig.php b/lib/appconfig.php index 6604e854d55..ed0e8f1d0bd 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -123,7 +123,7 @@ class OC_Appconfig{ */ public static function setValue( $app, $key, $value ) { // Does the key exist? yes: update. No: insert - if(! self::hasKey($app,$key)) { + if(! self::hasKey($app, $key)) { $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*appconfig` ( `appid`, `configkey`, `configvalue` ) VALUES( ?, ?, ? )' ); $query->execute( array( $app, $key, $value )); } diff --git a/lib/base.php b/lib/base.php index a1ad4f6dc0a..186ed53e980 100644 --- a/lib/base.php +++ b/lib/base.php @@ -176,7 +176,7 @@ class OC{ OC::$SERVERROOT.'/lib'.PATH_SEPARATOR. OC::$SERVERROOT.'/config'.PATH_SEPARATOR. OC::$THIRDPARTYROOT.'/3rdparty'.PATH_SEPARATOR. - implode($paths,PATH_SEPARATOR).PATH_SEPARATOR. + implode($paths, PATH_SEPARATOR).PATH_SEPARATOR. get_include_path().PATH_SEPARATOR. OC::$SERVERROOT ); diff --git a/lib/connector/sabre/auth.php b/lib/connector/sabre/auth.php index 0c34c7ea29f..db8f005745a 100644 --- a/lib/connector/sabre/auth.php +++ b/lib/connector/sabre/auth.php @@ -37,7 +37,7 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic { } else { OC_Util::setUpFS();//login hooks may need early access to the filesystem if(OC_User::login($username, $password)) { - OC_Util::setUpFS($username); + OC_Util::setUpFS(OC_User::getUser()); return true; } else{ diff --git a/lib/connector/sabre/locks.php b/lib/connector/sabre/locks.php index dbcc57558e0..8ebe324602c 100644 --- a/lib/connector/sabre/locks.php +++ b/lib/connector/sabre/locks.php @@ -109,7 +109,7 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract { $lockInfo->created = time(); $lockInfo->uri = $uri; - $locks = $this->getLocks($uri,false); + $locks = $this->getLocks($uri, false); $exists = false; foreach($locks as $lock) { if ($lock->token == $lockInfo->token) $exists = true; diff --git a/lib/eventsource.php b/lib/eventsource.php index 900b5b101e6..3bada131bdd 100644 --- a/lib/eventsource.php +++ b/lib/eventsource.php @@ -38,7 +38,7 @@ class OC_EventSource{ if($this->fallback) { $this->fallBackId=$_GET['fallback_id']; header("Content-Type: text/html"); - echo str_repeat('<span></span>'.PHP_EOL,10); //dummy data to keep IE happy + echo str_repeat('<span></span>'.PHP_EOL, 10); //dummy data to keep IE happy }else{ header("Content-Type: text/event-stream"); } @@ -78,6 +78,6 @@ class OC_EventSource{ * close the connection of the even source */ public function close() { - $this->send('__internal__','close');//server side closing can be an issue, let the client do it + $this->send('__internal__', 'close');//server side closing can be an issue, let the client do it } -}
\ No newline at end of file +} diff --git a/lib/filecache.php b/lib/filecache.php index 9e9ef606a9a..fee3b398251 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -43,14 +43,14 @@ class OC_FileCache{ * - versioned */ public static function get($path,$root=false) { - if(OC_FileCache_Update::hasUpdated($path,$root)) { + if(OC_FileCache_Update::hasUpdated($path, $root)) { if($root===false) {//filesystem hooks are only valid for the default root - OC_Hook::emit('OC_Filesystem','post_write',array('path'=>$path)); + OC_Hook::emit('OC_Filesystem', 'post_write', array('path'=>$path)); }else{ - OC_FileCache_Update::update($path,$root); + OC_FileCache_Update::update($path, $root); } } - return OC_FileCache_Cached::get($path,$root); + return OC_FileCache_Cached::get($path, $root); } /** @@ -65,15 +65,15 @@ class OC_FileCache{ if($root===false) { $root=OC_Filesystem::getRoot(); } - $fullpath=$root.$path; + $fullpath=OC_Filesystem::normalizePath($root.'/'.$path); $parent=self::getParentId($fullpath); - $id=self::getId($fullpath,''); + $id=self::getId($fullpath, ''); if(isset(OC_FileCache_Cached::$savedData[$fullpath])) { - $data=array_merge(OC_FileCache_Cached::$savedData[$fullpath],$data); + $data=array_merge(OC_FileCache_Cached::$savedData[$fullpath], $data); unset(OC_FileCache_Cached::$savedData[$fullpath]); } if($id!=-1) { - self::update($id,$data); + self::update($id, $data); return; } @@ -102,9 +102,9 @@ class OC_FileCache{ $data['versioned']=(int)$data['versioned']; $user=OC_User::getUser(); $query=OC_DB::prepare('INSERT INTO `*PREFIX*fscache`(`parent`, `name`, `path`, `path_hash`, `size`, `mtime`, `ctime`, `mimetype`, `mimepart`,`user`,`writable`,`encrypted`,`versioned`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)'); - $result=$query->execute(array($parent,basename($fullpath),$fullpath,md5($fullpath),$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable'],$data['encrypted'],$data['versioned'])); + $result=$query->execute(array($parent, basename($fullpath), $fullpath, md5($fullpath), $data['size'], $data['mtime'], $data['ctime'], $data['mimetype'], $mimePart, $user, $data['writable'], $data['encrypted'], $data['versioned'])); if(OC_DB::isError($result)) { - OC_Log::write('files','error while writing file('.$fullpath.') to cache',OC_Log::ERROR); + OC_Log::write('files', 'error while writing file('.$fullpath.') to cache', OC_Log::ERROR); } if($cache=OC_Cache::getUserCache(true)) { @@ -137,11 +137,11 @@ class OC_FileCache{ } $arguments[]=$id; - $sql = 'UPDATE `*PREFIX*fscache` SET '.implode(' , ',$queryParts).' WHERE `id`=?'; + $sql = 'UPDATE `*PREFIX*fscache` SET '.implode(' , ', $queryParts).' WHERE `id`=?'; $query=OC_DB::prepare($sql); $result=$query->execute($arguments); if(OC_DB::isError($result)) { - OC_Log::write('files','error while updating file('.$id.') in cache',OC_Log::ERROR); + OC_Log::write('files', 'error while updating file('.$id.') in cache', OC_Log::ERROR); } } @@ -163,10 +163,10 @@ class OC_FileCache{ $newPath=$root.$newPath; $newParent=self::getParentId($newPath); $query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `parent`=? ,`name`=?, `path`=?, `path_hash`=? WHERE `path_hash`=?'); - $query->execute(array($newParent,basename($newPath),$newPath,md5($newPath),md5($oldPath))); + $query->execute(array($newParent, basename($newPath), $newPath, md5($newPath), md5($oldPath))); if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$oldPath)) { - $cache->set('fileid/'.$newPath,$cache->get('fileid/'.$oldPath)); + $cache->set('fileid/'.$newPath, $cache->get('fileid/'.$oldPath)); $cache->remove('fileid/'.$oldPath); } @@ -175,11 +175,11 @@ class OC_FileCache{ $updateQuery=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `path`=?, `path_hash`=? WHERE `path_hash`=?'); while($row= $query->execute(array($oldPath.'/%'))->fetchRow()) { $old=$row['path']; - $new=$newPath.substr($old,$oldLength); - $updateQuery->execute(array($new,md5($new),md5($old))); + $new=$newPath.substr($old, $oldLength); + $updateQuery->execute(array($new, md5($new), md5($old))); if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$old)) { - $cache->set('fileid/'.$new,$cache->get('fileid/'.$old)); + $cache->set('fileid/'.$new, $cache->get('fileid/'.$old)); $cache->remove('fileid/'.$old); } } @@ -231,9 +231,9 @@ class OC_FileCache{ $names=array(); while($row=$result->fetchRow()) { if(!$returnData) { - $names[]=substr($row['path'],$rootLen); + $names[]=substr($row['path'], $rootLen); }else{ - $row['path']=substr($row['path'],$rootLen); + $row['path']=substr($row['path'], $rootLen); $names[]=$row; } } @@ -256,10 +256,10 @@ class OC_FileCache{ * - versioned */ public static function getFolderContent($path,$root=false,$mimetype_filter='') { - if(OC_FileCache_Update::hasUpdated($path,$root,true)) { - OC_FileCache_Update::updateFolder($path,$root); + if(OC_FileCache_Update::hasUpdated($path, $root, true)) { + OC_FileCache_Update::updateFolder($path, $root); } - return OC_FileCache_Cached::getFolderContent($path,$root,$mimetype_filter); + return OC_FileCache_Cached::getFolderContent($path, $root, $mimetype_filter); } /** @@ -269,7 +269,7 @@ class OC_FileCache{ * @return bool */ public static function inCache($path,$root=false) { - return self::getId($path,$root)!=-1; + return self::getId($path, $root)!=-1; } /** @@ -291,7 +291,7 @@ class OC_FileCache{ $query=OC_DB::prepare('SELECT `id` FROM `*PREFIX*fscache` WHERE `path_hash`=?'); $result=$query->execute(array(md5($fullPath))); if(OC_DB::isError($result)) { - OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR); + OC_Log::write('files', 'error while getting file id of '.$path, OC_Log::ERROR); return -1; } @@ -302,7 +302,7 @@ class OC_FileCache{ $id=-1; } if($cache=OC_Cache::getUserCache(true)) { - $cache->set('fileid/'.$fullPath,$id); + $cache->set('fileid/'.$fullPath, $id); } return $id; @@ -319,14 +319,14 @@ class OC_FileCache{ $user=OC_User::getUser(); } $query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `id`=? AND `user`=?'); - $result=$query->execute(array($id,$user)); + $result=$query->execute(array($id, $user)); $row=$result->fetchRow(); $path=$row['path']; $root='/'.$user.'/files'; - if(substr($path,0,strlen($root))!=$root) { + if(substr($path, 0, strlen($root))!=$root) { return false; } - return substr($path,strlen($root)); + return substr($path, strlen($root)); } /** @@ -338,7 +338,7 @@ class OC_FileCache{ if($path=='/') { return -1; }else{ - return self::getId(dirname($path),''); + return self::getId(dirname($path), ''); } } @@ -350,7 +350,7 @@ class OC_FileCache{ */ public static function increaseSize($path,$sizeDiff, $root=false) { if($sizeDiff==0) return; - $id=self::getId($path,$root); + $id=self::getId($path, $root); while($id!=-1) {//walk up the filetree increasing the size of all parent folders $query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `size`=`size`+? WHERE `id`=?'); $query->execute(array($sizeDiff,$id)); @@ -368,7 +368,7 @@ class OC_FileCache{ */ public static function scan($path,$eventSource=false,&$count=0,$root=false) { if($eventSource) { - $eventSource->send('scanning',array('file'=>$path,'count'=>$count)); + $eventSource->send('scanning', array('file'=>$path, 'count'=>$count)); } $lastSend=$count; // NOTE: Ugly hack to prevent shared files from going into the cache (the source already exists somewhere in the cache) @@ -380,7 +380,7 @@ class OC_FileCache{ }else{ $view=new OC_FilesystemView($root); } - self::scanFile($path,$root); + self::scanFile($path, $root); $dh=$view->opendir($path.'/'); $totalSize=0; if($dh) { @@ -388,13 +388,13 @@ class OC_FileCache{ if($filename != '.' and $filename != '..') { $file=$path.'/'.$filename; if($view->is_dir($file.'/')) { - self::scan($file,$eventSource,$count,$root); + self::scan($file, $eventSource, $count, $root); }else{ - $totalSize+=self::scanFile($file,$root); + $totalSize+=self::scanFile($file, $root); $count++; if($count>$lastSend+25 and $eventSource) { $lastSend=$count; - $eventSource->send('scanning',array('file'=>$path,'count'=>$count)); + $eventSource->send('scanning', array('file'=>$path, 'count'=>$count)); } } } @@ -436,7 +436,7 @@ class OC_FileCache{ if($path=='/') { $path=''; } - self::put($path,$stat,$root); + self::put($path, $stat, $root); return $stat['size']; } @@ -462,14 +462,14 @@ class OC_FileCache{ $user=OC_User::getUser(); if(!$part2) { $query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `mimepart`=? AND `user`=? AND `path` LIKE ?'); - $result=$query->execute(array($part1,$user, $root)); + $result=$query->execute(array($part1, $user, $root)); }else{ $query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `mimetype`=? AND `user`=? AND `path` LIKE ? '); - $result=$query->execute(array($part1.'/'.$part2,$user, $root)); + $result=$query->execute(array($part1.'/'.$part2, $user, $root)); } $names=array(); while($row=$result->fetchRow()) { - $names[]=substr($row['path'],$rootLen); + $names[]=substr($row['path'], $rootLen); } return $names; } @@ -512,7 +512,7 @@ class OC_FileCache{ } //watch for changes and try to keep the cache up to date -OC_Hook::connect('OC_Filesystem','post_write','OC_FileCache_Update','fileSystemWatcherWrite'); -OC_Hook::connect('OC_Filesystem','post_delete','OC_FileCache_Update','fileSystemWatcherDelete'); -OC_Hook::connect('OC_Filesystem','post_rename','OC_FileCache_Update','fileSystemWatcherRename'); -OC_Hook::connect('OC_User','post_deleteUser','OC_FileCache_Update','deleteFromUser'); +OC_Hook::connect('OC_Filesystem', 'post_write', 'OC_FileCache_Update', 'fileSystemWatcherWrite'); +OC_Hook::connect('OC_Filesystem', 'post_delete', 'OC_FileCache_Update', 'fileSystemWatcherDelete'); +OC_Hook::connect('OC_Filesystem', 'post_rename', 'OC_FileCache_Update', 'fileSystemWatcherRename'); +OC_Hook::connect('OC_User', 'post_deleteUser', 'OC_FileCache_Update', 'deleteFromUser'); diff --git a/lib/filechunking.php b/lib/filechunking.php index 5ab33c77ad7..55a4d730430 100644 --- a/lib/filechunking.php +++ b/lib/filechunking.php @@ -59,7 +59,7 @@ class OC_FileChunking { for($i=0; $i < $this->info['chunkcount']; $i++) { $chunk = $cache->get($prefix.$i); $cache->remove($prefix.$i); - $count += fwrite($f,$chunk); + $count += fwrite($f, $chunk); } return $count; } diff --git a/lib/fileproxy.php b/lib/fileproxy.php index 17380c656a3..3e7f1aa1c41 100644 --- a/lib/fileproxy.php +++ b/lib/fileproxy.php @@ -52,7 +52,7 @@ class OC_FileProxy{ * this implements a dummy proxy for all operations */ public function __call($function,$arguments) { - if(substr($function,0,3)=='pre') { + if(substr($function, 0, 3)=='pre') { return true; }else{ return $arguments[1]; @@ -70,7 +70,7 @@ class OC_FileProxy{ public static function getProxies($operation) { $proxies=array(); foreach(self::$proxies as $proxy) { - if(method_exists($proxy,$operation)) { + if(method_exists($proxy, $operation)) { $proxies[]=$proxy; } } diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php index 5a0dbdb6fe2..012be582a51 100644 --- a/lib/fileproxy/quota.php +++ b/lib/fileproxy/quota.php @@ -27,52 +27,58 @@ class OC_FileProxy_Quota extends OC_FileProxy{ static $rootView; - private $userQuota=-1; + private $userQuota=array(); /** - * get the quota for the current user + * get the quota for the user + * @param user * @return int */ - private function getQuota() { - if($this->userQuota!=-1) { - return $this->userQuota; + private function getQuota($user) { + if(in_array($user, $this->userQuota)) { + return $this->userQuota[$user]; } - $userQuota=OC_Preferences::getValue(OC_User::getUser(),'files','quota','default'); + $userQuota=OC_Preferences::getValue($user,'files','quota','default'); if($userQuota=='default') { $userQuota=OC_AppConfig::getValue('files','default_quota','none'); } if($userQuota=='none') { - $this->userQuota=0; + $this->userQuota[$user]=0; }else{ - $this->userQuota=OC_Helper::computerFileSize($userQuota); + $this->userQuota[$user]=OC_Helper::computerFileSize($userQuota); } - return $this->userQuota; + return $this->userQuota[$user]; } /** - * get the free space in the users home folder + * get the free space in the path's owner home folder + * @param path * @return int */ - private function getFreeSpace() { - $rootInfo=OC_FileCache_Cached::get(''); + private function getFreeSpace($path) { + $storage=OC_Filesystem::getStorage($path); + $owner=$storage->getOwner($path); + + $totalSpace=$this->getQuota($owner); + if($totalSpace==0) { + return 0; + } + + $rootInfo=OC_FileCache::get('', "/".$owner."/files"); // TODO Remove after merge of share_api - if (OC_FileCache::inCache('/Shared')) { - $sharedInfo=OC_FileCache_Cached::get('/Shared'); + if (OC_FileCache::inCache('/Shared', "/".$owner."/files")) { + $sharedInfo=OC_FileCache::get('/Shared', "/".$owner."/files"); } else { $sharedInfo = null; } $usedSpace=isset($rootInfo['size'])?$rootInfo['size']:0; $usedSpace=isset($sharedInfo['size'])?$usedSpace-$sharedInfo['size']:$usedSpace; - $totalSpace=$this->getQuota(); - if($totalSpace==0) { - return 0; - } return $totalSpace-$usedSpace; } - + public function postFree_space($path,$space) { - $free=$this->getFreeSpace(); + $free=$this->getFreeSpace($path); if($free==0) { return $space; } @@ -83,21 +89,21 @@ class OC_FileProxy_Quota extends OC_FileProxy{ if (is_resource($data)) { $data = '';//TODO: find a way to get the length of the stream without emptying it } - return (strlen($data)<$this->getFreeSpace() or $this->getFreeSpace()==0); + return (strlen($data)<$this->getFreeSpace($path) or $this->getFreeSpace($path)==0); } public function preCopy($path1,$path2) { if(!self::$rootView){ self::$rootView = new OC_FilesystemView(''); } - return (self::$rootView->filesize($path1)<$this->getFreeSpace() or $this->getFreeSpace()==0); + return (self::$rootView->filesize($path1)<$this->getFreeSpace($path2) or $this->getFreeSpace($path2)==0); } public function preFromTmpFile($tmpfile,$path) { - return (filesize($tmpfile)<$this->getFreeSpace() or $this->getFreeSpace()==0); + return (filesize($tmpfile)<$this->getFreeSpace($path) or $this->getFreeSpace($path)==0); } public function preFromUploadedFile($tmpfile,$path) { - return (filesize($tmpfile)<$this->getFreeSpace() or $this->getFreeSpace()==0); + return (filesize($tmpfile)<$this->getFreeSpace($path) or $this->getFreeSpace($path)==0); } } diff --git a/lib/files.php b/lib/files.php index 2b2b8b42dc4..b4d4de1c995 100644 --- a/lib/files.php +++ b/lib/files.php @@ -136,17 +136,17 @@ class OC_Files { * @param boolean $only_header ; boolean to only send header of the request */ public static function get($dir,$files, $only_header = false) { - if(strpos($files,';')) { - $files=explode(';',$files); + if(strpos($files, ';')) { + $files=explode(';', $files); } if(is_array($files)) { - self::validateZipDownload($dir,$files); + self::validateZipDownload($dir, $files); $executionTime = intval(ini_get('max_execution_time')); set_time_limit(0); $zip = new ZipArchive(); $filename = OC_Helper::tmpFile('.zip'); - if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) { + if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==true) { exit("cannot open <$filename>\n"); } foreach($files as $file) { @@ -154,24 +154,24 @@ class OC_Files { if(OC_Filesystem::is_file($file)) { $tmpFile=OC_Filesystem::toTmpFile($file); self::$tmpFiles[]=$tmpFile; - $zip->addFile($tmpFile,basename($file)); + $zip->addFile($tmpFile, basename($file)); }elseif(OC_Filesystem::is_dir($file)) { - self::zipAddDir($file,$zip); + self::zipAddDir($file, $zip); } } $zip->close(); set_time_limit($executionTime); }elseif(OC_Filesystem::is_dir($dir.'/'.$files)) { - self::validateZipDownload($dir,$files); + self::validateZipDownload($dir, $files); $executionTime = intval(ini_get('max_execution_time')); set_time_limit(0); $zip = new ZipArchive(); $filename = OC_Helper::tmpFile('.zip'); - if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) { + if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==true) { exit("cannot open <$filename>\n"); } $file=$dir.'/'.$files; - self::zipAddDir($file,$zip); + self::zipAddDir($file, $zip); $zip->close(); set_time_limit($executionTime); }else{ @@ -193,7 +193,7 @@ class OC_Files { }elseif($zip or !OC_Filesystem::file_exists($filename)) { header("HTTP/1.0 404 Not Found"); $tmpl = new OC_Template( '', '404', 'guest' ); - $tmpl->assign('file',$filename); + $tmpl->assign('file', $filename); $tmpl->printPage(); }else{ header("HTTP/1.0 403 Forbidden"); @@ -205,7 +205,7 @@ class OC_Files { return ; } if($zip) { - $handle=fopen($filename,'r'); + $handle=fopen($filename, 'r'); if ($handle) { $chunkSize = 8*1024;// 1 MB chunks while (!feof($handle)) { @@ -235,9 +235,9 @@ class OC_Files { if(OC_Filesystem::is_file($file)) { $tmpFile=OC_Filesystem::toTmpFile($file); OC_Files::$tmpFiles[]=$tmpFile; - $zip->addFile($tmpFile,$internalDir.$filename); + $zip->addFile($tmpFile, $internalDir.$filename); }elseif(OC_Filesystem::is_dir($file)) { - self::zipAddDir($file,$zip,$internalDir); + self::zipAddDir($file, $zip, $internalDir); } } } @@ -253,7 +253,7 @@ class OC_Files { if(OC_User::isLoggedIn() && ($sourceDir != '' || $source != 'Shared')) { $targetFile=self::normalizePath($targetDir.'/'.$target); $sourceFile=self::normalizePath($sourceDir.'/'.$source); - return OC_Filesystem::rename($sourceFile,$targetFile); + return OC_Filesystem::rename($sourceFile, $targetFile); } else { return false; } @@ -271,7 +271,7 @@ class OC_Files { if(OC_User::isLoggedIn()) { $targetFile=$targetDir.'/'.$target; $sourceFile=$sourceDir.'/'.$source; - return OC_Filesystem::copy($sourceFile,$targetFile); + return OC_Filesystem::copy($sourceFile, $targetFile); } } @@ -390,11 +390,11 @@ class OC_Files { * @return string guessed mime type */ static function pull($source,$token,$dir,$file) { - $tmpfile=tempnam(get_temp_dir(),'remoteCloudFile'); + $tmpfile=tempnam(get_temp_dir(), 'remoteCloudFile'); $fp=fopen($tmpfile,'w+'); $url=$source.="/files/pull.php?token=$token"; $ch=curl_init(); - curl_setopt($ch,CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FILE, $fp); curl_exec($ch); fclose($fp); @@ -402,7 +402,7 @@ class OC_Files { $httpCode=$info['http_code']; curl_close($ch); if($httpCode==200 or $httpCode==0) { - OC_Filesystem::fromTmpFile($tmpfile,$dir.'/'.$file); + OC_Filesystem::fromTmpFile($tmpfile, $dir.'/'.$file); return true; }else{ return false; @@ -423,8 +423,8 @@ class OC_Files { $size -=1; } else { $size=OC_Helper::humanFileSize($size); - $size=substr($size,0,-1);//strip the B - $size=str_replace(' ','',$size); //remove the space between the size and the postfix + $size=substr($size, 0, -1);//strip the B + $size=str_replace(' ', '', $size); //remove the space between the size and the postfix } //don't allow user to break his config -- broken or malicious size input @@ -447,7 +447,7 @@ class OC_Files { $setting = 'php_value '.$key.' '.$size; $hasReplaced = 0; $content = preg_replace($pattern, $setting, $htaccess, 1, $hasReplaced); - if($content !== NULL) { + if($content !== null) { $htaccess = $content; } if($hasReplaced == 0) { @@ -459,7 +459,7 @@ class OC_Files { if(is_writable(OC::$SERVERROOT.'/.htaccess')) { file_put_contents(OC::$SERVERROOT.'/.htaccess', $htaccess); return OC_Helper::computerFileSize($size); - } else { OC_Log::write('files','Can\'t write upload limit to '.OC::$SERVERROOT.'/.htaccess. Please check the file permissions',OC_Log::WARN); } + } else { OC_Log::write('files', 'Can\'t write upload limit to '.OC::$SERVERROOT.'/.htaccess. Please check the file permissions', OC_Log::WARN); } return false; } @@ -474,7 +474,7 @@ class OC_Files { $old=''; while($old!=$path) {//replace any multiplicity of slashes with a single one $old=$path; - $path=str_replace('//','/',$path); + $path=str_replace('//', '/', $path); } return $path; } @@ -486,6 +486,6 @@ function fileCmp($a,$b) { }elseif($a['type']!='dir' and $b['type']=='dir') { return 1; }else{ - return strnatcasecmp($a['name'],$b['name']); + return strnatcasecmp($a['name'], $b['name']); } } diff --git a/lib/filestorage.php b/lib/filestorage.php index 5bfd09253d5..146cecf4efa 100644 --- a/lib/filestorage.php +++ b/lib/filestorage.php @@ -63,4 +63,5 @@ abstract class OC_Filestorage{ * returning true for other changes in the folder is optional */ abstract public function hasUpdated($path,$time); + abstract public function getOwner($path); } diff --git a/lib/filestorage/common.php b/lib/filestorage/common.php index 351714437c5..f24a5704913 100644 --- a/lib/filestorage/common.php +++ b/lib/filestorage/common.php @@ -260,7 +260,7 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { if($dh) { while($item=readdir($dh)) { if ($item == '.' || $item == '..') continue; - if(strstr(strtolower($item),strtolower($query))!==false) { + if(strstr(strtolower($item), strtolower($query))!==false) { $files[]=$dir.'/'.$item; } if($this->is_dir($dir.'/'.$item)) { @@ -279,4 +279,13 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { public function hasUpdated($path,$time) { return $this->filemtime($path)>$time; } + + /** + * get the owner of a path + * @param $path The path to get the owner + * @return string uid or false + */ + public function getOwner($path) { + return OC_User::getUser(); + } } diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php index 80aa548047c..731ac4a3c72 100644 --- a/lib/filestorage/local.php +++ b/lib/filestorage/local.php @@ -103,7 +103,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ if(!$this->file_exists($path2)) { $this->mkdir($path2); } - $source=substr($path1,strrpos($path1,'/')+1); + $source=substr($path1, strrpos($path1,'/')+1); $path2.=$source; } return copy($this->datadir.$path1,$this->datadir.$path2); @@ -178,7 +178,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ $files=array(); foreach (scandir($this->datadir.$dir) as $item) { if ($item == '.' || $item == '..') continue; - if(strstr(strtolower($item),strtolower($query))!==false) { + if(strstr(strtolower($item), strtolower($query))!==false) { $files[]=$dir.'/'.$item; } if(is_dir($this->datadir.$dir.'/'.$item)) { diff --git a/lib/filesystem.php b/lib/filesystem.php index 00682573dd9..bc30dac7fa1 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -148,7 +148,7 @@ class OC_Filesystem{ * @return string */ static public function getMountPoint($path) { - OC_Hook::emit(self::CLASSNAME,'get_mountpoint',array('path'=>$path)); + OC_Hook::emit(self::CLASSNAME,'get_mountpoint', array('path'=>$path)); if(!$path) { $path='/'; } @@ -176,7 +176,7 @@ class OC_Filesystem{ */ static public function getInternalPath($path) { $mountPoint=self::getMountPoint($path); - $internalPath=substr($path,strlen($mountPoint)); + $internalPath=substr($path, strlen($mountPoint)); return $internalPath; } @@ -210,7 +210,7 @@ class OC_Filesystem{ static private function loadSystemMountPoints($user) { if(is_file(OC::$SERVERROOT.'/config/mount.php')) {
- $mountConfig=include(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);
diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 2950ced5f9e..872da992fab 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -251,6 +251,9 @@ class OC_FilesystemView { return $this->basicOperation('filemtime', $path); } public function touch($path, $mtime=null) { + if(!is_null($mtime) and !is_numeric($mtime)){ + $mtime = strtotime($mtime); + } return $this->basicOperation('touch', $path, array('write'), $mtime); } public function file_get_contents($path) { @@ -585,7 +588,7 @@ class OC_FilesystemView { $result = OC_FileProxy::runPostProxies($operation, $this->getAbsolutePath($path), $result); if(OC_Filesystem::$loaded and $this->fakeRoot==OC_Filesystem::getRoot()) { if($operation!='fopen') {//no post hooks for fopen, the file stream is still open - $this->runHooks($hooks,$path,true); + $this->runHooks($hooks,$path, true); } } return $result; diff --git a/lib/helper.php b/lib/helper.php index a52adc96958..b7166e9fb41 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -189,7 +189,7 @@ class OC_Helper { return OC::$WEBROOT."/core/img/filetypes/$mimetype.png"; } //try only the first part of the filetype - $mimetype=substr($mimetype,0,strpos($mimetype,'-')); + $mimetype=substr($mimetype,0, strpos($mimetype,'-')); if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.png" )) { return OC::$WEBROOT."/core/img/filetypes/$mimetype.png"; } @@ -274,18 +274,18 @@ class OC_Helper { if($file != '.' && $file != '..') { $fullpath = $path.'/'.$file; if(is_link($fullpath)) - return FALSE; + return false; elseif(!is_dir($fullpath) && !@chmod($fullpath, $filemode)) - return FALSE; + return false; elseif(!self::chmodr($fullpath, $filemode)) - return FALSE; + return false; } } closedir($dh); if(@chmod($path, $filemode)) - return TRUE; + return true; else - return FALSE; + return false; } /** @@ -350,8 +350,8 @@ class OC_Helper { if(strpos($path,'.')) { //try to guess the type by the file extension - if(!self::$mimetypes || self::$mimetypes != include('mimetypes.list.php')) { - self::$mimetypes=include('mimetypes.list.php'); + if(!self::$mimetypes || self::$mimetypes != include 'mimetypes.list.php') { + self::$mimetypes=include 'mimetypes.list.php'; } $extension=strtolower(strrchr(basename($path), ".")); $extension=substr($extension,1);//remove leading . @@ -363,7 +363,7 @@ class OC_Helper { if($mimeType=='application/octet-stream' and function_exists('finfo_open') and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)) { $info = @strtolower(finfo_file($finfo,$path)); if($info) { - $mimeType=substr($info,0,strpos($info,';')); + $mimeType=substr($info,0, strpos($info,';')); } finfo_close($finfo); } @@ -380,8 +380,8 @@ class OC_Helper { pclose($fp); //trim the character set from the end of the response - $mimeType=substr($reply,0,strrpos($reply,' ')); - $mimeType=substr($mimeType,0,strrpos($mimeType,"\n")); + $mimeType=substr($reply,0, strrpos($reply,' ')); + $mimeType=substr($mimeType,0, strrpos($mimeType,"\n")); //trim ; if (strpos($mimeType, ';') !== false) { @@ -495,7 +495,7 @@ class OC_Helper { } $count=0; while(!feof($source)) { - $count+=fwrite($target,fread($source,8192)); + $count+=fwrite($target, fread($source,8192)); } return $count; } diff --git a/lib/installer.php b/lib/installer.php index 9135c60fc05..83d082b804a 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -125,7 +125,7 @@ class OC_Installer{ } return false; } - $info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml',true); + $info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml', true); // check the code for not allowed calls if(!OC_Installer::checkCode($info['id'],$extractDir)) { OC_Log::write('core','App can\'t be installed because of not allowed code in the App',OC_Log::ERROR); @@ -187,7 +187,7 @@ class OC_Installer{ //run appinfo/install.php if((!isset($data['noinstall']) or $data['noinstall']==false) and file_exists($basedir.'/appinfo/install.php')) { - include($basedir.'/appinfo/install.php'); + include $basedir.'/appinfo/install.php'; } //set the installed version @@ -320,7 +320,7 @@ class OC_Installer{ //run appinfo/install.php if(is_file(OC_App::getAppPath($app)."/appinfo/install.php")) { - include(OC_App::getAppPath($app)."/appinfo/install.php"); + include OC_App::getAppPath($app)."/appinfo/install.php"; } $info=OC_App::getAppInfo($app); OC_Appconfig::setValue($app,'installed_version',OC_App::getAppVersion($app)); diff --git a/lib/l10n.php b/lib/l10n.php index ac57115da4e..f1a2523c307 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -58,9 +58,11 @@ class OC_L10N{ * Localization */ private $localizations = array( + 'jsdate' => 'dd.mm.yy', 'date' => '%d.%m.%Y', 'datetime' => '%d.%m.%Y %H:%M:%S', - 'time' => '%H:%M:%S'); + 'time' => '%H:%M:%S', + 'firstday' => 0); /** * get an L10N instance @@ -118,7 +120,7 @@ class OC_L10N{ OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/lib/l10n/') || OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/settings')) && file_exists($i18ndir.$lang.'.php')) { // Include the file, save the data from $CONFIG - include(strip_tags($i18ndir).strip_tags($lang).'.php'); + include strip_tags($i18ndir).strip_tags($lang).'.php'; if(isset($TRANSLATIONS) && is_array($TRANSLATIONS)) { $this->translations = $TRANSLATIONS; } @@ -126,7 +128,7 @@ class OC_L10N{ if(file_exists(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php')) { // Include the file, save the data from $CONFIG - include(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php'); + include OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php'; if(isset($LOCALIZATIONS) && is_array($LOCALIZATIONS)) { $this->localizations = array_merge($this->localizations, $LOCALIZATIONS); } @@ -221,8 +223,16 @@ class OC_L10N{ $locales[] = $locales[0].'_'.strtoupper($locales[0]); } setlocale(LC_TIME, $locales); - return strftime($this->localizations[$type], $data); + $format = $this->localizations[$type]; + // Check for Windows to find and replace the %e modifier correctly + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { + $format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format); + } + return strftime($format, $data); break; + case 'firstday': + case 'jsdate': + return $this->localizations[$type]; default: return false; } diff --git a/lib/migrate.php b/lib/migrate.php index 611a935ee5d..409d77a1a96 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -66,7 +66,7 @@ class OC_Migrate{ foreach($apps as $app) { $path = OC_App::getAppPath($app) . '/appinfo/migrate.php'; if( file_exists( $path ) ) { - include( $path ); + include $path; } } } @@ -347,7 +347,7 @@ class OC_Migrate{ OC_Log::write( 'migration', 'Zip not found', OC_Log::ERROR ); return false; } - if ( self::$zip->open( $path ) != TRUE ) { + if ( self::$zip->open( $path ) != true ) { OC_Log::write( 'migration', "Failed to open zip file", OC_Log::ERROR ); return false; } @@ -576,7 +576,7 @@ class OC_Migrate{ OC_Log::write('migration', 'createZip() called but $zip and/or $zippath have not been set', OC_Log::ERROR); return false; } - if ( self::$zip->open( self::$zippath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE ) !== TRUE ) { + if ( self::$zip->open( self::$zippath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE ) !== true ) { OC_Log::write('migration', 'Failed to create the zip with error: '.self::$zip->getStatusString(), OC_Log::ERROR); return false; } else { diff --git a/lib/ocsclient.php b/lib/ocsclient.php index 3c80f319662..32c2cfe6e48 100644 --- a/lib/ocsclient.php +++ b/lib/ocsclient.php @@ -76,12 +76,12 @@ class OC_OCSClient{ */ public static function getCategories() { if(OC_Config::getValue('appstoreenabled', true)==false) { - return NULL; + return null; } $url=OC_OCSClient::getAppStoreURL().'/content/categories'; $xml=OC_OCSClient::getOCSresponse($url); - if($xml==FALSE) { - return NULL; + if($xml==false) { + return null; } $data=simplexml_load_string($xml); @@ -122,8 +122,8 @@ class OC_OCSClient{ $apps=array(); $xml=OC_OCSClient::getOCSresponse($url); - if($xml==FALSE) { - return NULL; + if($xml==false) { + return null; } $data=simplexml_load_string($xml); @@ -156,14 +156,14 @@ class OC_OCSClient{ */ public static function getApplication($id) { if(OC_Config::getValue('appstoreenabled', true)==false) { - return NULL; + return null; } $url=OC_OCSClient::getAppStoreURL().'/content/data/'.urlencode($id); $xml=OC_OCSClient::getOCSresponse($url); - if($xml==FALSE) { + if($xml==false) { OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL); - return NULL; + return null; } $data=simplexml_load_string($xml); @@ -194,14 +194,14 @@ class OC_OCSClient{ */ public static function getApplicationDownload($id,$item) { if(OC_Config::getValue('appstoreenabled', true)==false) { - return NULL; + return null; } $url=OC_OCSClient::getAppStoreURL().'/content/download/'.urlencode($id).'/'.urlencode($item); $xml=OC_OCSClient::getOCSresponse($url); - if($xml==FALSE) { + if($xml==false) { OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL); - return NULL; + return null; } $data=simplexml_load_string($xml); @@ -237,9 +237,9 @@ class OC_OCSClient{ $kbe=array(); $xml=OC_OCSClient::getOCSresponse($url); - if($xml==FALSE) { + if($xml==false) { OC_Log::write('core','Unable to parse knowledgebase content',OC_Log::FATAL); - return NULL; + return null; } $data=simplexml_load_string($xml); diff --git a/lib/search/provider/file.php b/lib/search/provider/file.php index 24832296c59..0d4b332b792 100644 --- a/lib/search/provider/file.php +++ b/lib/search/provider/file.php @@ -2,8 +2,9 @@ class OC_Search_Provider_File extends OC_Search_Provider{ function search($query) { - $files=OC_FileCache::search($query,true); + $files=OC_FileCache::search($query, true); $results=array(); + $l=OC_L10N::get('lib'); foreach($files as $fileData) { $path = $fileData['path']; $mime = $fileData['mimetype']; @@ -13,7 +14,7 @@ class OC_Search_Provider_File extends OC_Search_Provider{ $skip = false; if($mime=='httpd/unix-directory') { $link = OC_Helper::linkTo( 'files', 'index.php', array('dir' => $path)); - $type = 'Files'; + $type = (string)$l->t('Files'); }else{ $link = OC_Helper::linkTo( 'files', 'download.php', array('file' => $path)); $mimeBase = $fileData['mimepart']; @@ -22,16 +23,16 @@ class OC_Search_Provider_File extends OC_Search_Provider{ $skip = true; break; case 'text': - $type = 'Text'; + $type = (string)$l->t('Text'); break; case 'image': - $type = 'Images'; + $type = (string)$l->t('Images'); break; default: if($mime=='application/xml') { - $type = 'Text'; + $type = (string)$l->t('Text'); }else{ - $type = 'Files'; + $type = (string)$l->t('Files'); } } } diff --git a/lib/setup.php b/lib/setup.php index 3c92e9c5599..62d31fd544f 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -92,7 +92,7 @@ class OC_Setup { //write the config file OC_Config::setValue('datadirectory', $datadir); OC_Config::setValue('dbtype', $dbtype); - OC_Config::setValue('version',implode('.',OC_Util::getVersion())); + OC_Config::setValue('version', implode('.',OC_Util::getVersion())); if($dbtype == 'mysql') { $dbuser = $options['dbuser']; $dbpass = $options['dbpass']; @@ -376,8 +376,8 @@ class OC_Setup { } if(count($error) == 0) { - OC_Appconfig::setValue('core', 'installedat',microtime(true)); - OC_Appconfig::setValue('core', 'lastupdatedat',microtime(true)); + OC_Appconfig::setValue('core', 'installedat', microtime(true)); + OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true)); OC_Group::createGroup('admin'); OC_Group::addToGroup($username, 'admin'); diff --git a/lib/streamwrappers.php b/lib/streamwrappers.php index 1e5b19a11f0..63b795f4c4d 100644 --- a/lib/streamwrappers.php +++ b/lib/streamwrappers.php @@ -6,7 +6,7 @@ class OC_FakeDirStream{ private $index; public function dir_opendir($path,$options) { - $this->name=substr($path,strlen('fakedir://')); + $this->name=substr($path, strlen('fakedir://')); $this->index=0; if(!isset(self::$dirs[$this->name])) { self::$dirs[$this->name]=array(); @@ -223,7 +223,7 @@ class OC_CloseStreamWrapper{ private $source; private static $open=array(); public function stream_open($path, $mode, $options, &$opened_path) { - $path=substr($path,strlen('close://')); + $path=substr($path, strlen('close://')); $this->path=$path; $this->source=fopen($path,$mode); if(is_resource($this->source)) { @@ -279,7 +279,7 @@ class OC_CloseStreamWrapper{ } public function url_stat($path) { - $path=substr($path,strlen('close://')); + $path=substr($path, strlen('close://')); if(file_exists($path)) { return stat($path); }else{ @@ -295,7 +295,7 @@ class OC_CloseStreamWrapper{ } public function unlink($path) { - $path=substr($path,strlen('close://')); + $path=substr($path, strlen('close://')); return unlink($path); } } diff --git a/lib/template.php b/lib/template.php index 1c529932a30..972d75807c7 100644 --- a/lib/template.php +++ b/lib/template.php @@ -405,7 +405,7 @@ class OC_Template{ // Execute the template ob_start(); - include( $this->template ); // <-- we have to use include because we pass $_! + include $this->template; // <-- we have to use include because we pass $_! $data = ob_get_contents(); @ob_end_clean(); @@ -430,7 +430,7 @@ class OC_Template{ // Include ob_start(); - include( $this->path.$file.'.php' ); + include $this->path.$file.'.php'; $data = ob_get_contents(); @ob_end_clean(); diff --git a/lib/templatelayout.php b/lib/templatelayout.php index 78893457f47..c3da172a7c1 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -12,7 +12,7 @@ class OC_TemplateLayout extends OC_Template { if( $renderas == 'user' ) { parent::__construct( 'core', 'layout.user' ); - if(in_array(OC_APP::getCurrentApp(),array('settings','admin','help'))!==false) { + if(in_array(OC_APP::getCurrentApp(), array('settings','admin','help'))!==false) { $this->assign('bodyid','body-settings', false); }else{ $this->assign('bodyid','body-user', false); @@ -38,7 +38,7 @@ class OC_TemplateLayout extends OC_Template { foreach(OC_App::getEnabledApps() as $app) { $apps_paths[$app] = OC_App::getAppWebPath($app); } - $this->assign( 'apps_paths', str_replace('\\/', '/',json_encode($apps_paths)),false ); // Ugly unescape slashes waiting for better solution + $this->assign( 'apps_paths', str_replace('\\/', '/', json_encode($apps_paths)), false ); // Ugly unescape slashes waiting for better solution if (OC_Config::getValue('installed', false) && !OC_AppConfig::getValue('core', 'remote_core.css', false)) { OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php'); diff --git a/lib/updater.php b/lib/updater.php index cb22da4f906..f55e55985d9 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -29,8 +29,8 @@ class OC_Updater{ * Check if a new version is available */ public static function check() { - OC_Appconfig::setValue('core', 'lastupdatedat',microtime(true)); - if(OC_Appconfig::getValue('core', 'installedat','')=='') OC_Appconfig::setValue('core', 'installedat',microtime(true)); + OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true)); + if(OC_Appconfig::getValue('core', 'installedat','')=='') OC_Appconfig::setValue('core', 'installedat', microtime(true)); $updaterurl='http://apps.owncloud.com/updater.php'; $version=OC_Util::getVersion(); @@ -52,7 +52,7 @@ class OC_Updater{ ) ); $xml=@file_get_contents($url, 0, $ctx); - if($xml==FALSE) { + if($xml==false) { return array(); } $data=@simplexml_load_string($xml); @@ -72,7 +72,7 @@ class OC_Updater{ if(OC_Config::getValue('updatechecker', true)==true) { $data=OC_Updater::check(); if(isset($data['version']) and $data['version']<>'') { - $txt='<span style="color:#AA0000; font-weight:bold;">'.$l->t('%s is available. Get <a href="%s">more information</a>',array($data['versionstring'], $data['web'])).'</span>'; + $txt='<span style="color:#AA0000; font-weight:bold;">'.$l->t('%s is available. Get <a href="%s">more information</a>', array($data['versionstring'], $data['web'])).'</span>'; }else{ $txt=$l->t('up to date'); } diff --git a/lib/user.php b/lib/user.php index 77bfe0de92a..064fcbad96f 100644 --- a/lib/user.php +++ b/lib/user.php @@ -120,11 +120,11 @@ class OC_User { * setup the configured backends in config.php */ public static function setupBackends() { - $backends=OC_Config::getValue('user_backends',array()); + $backends=OC_Config::getValue('user_backends', array()); foreach($backends as $i=>$config) { $class=$config['class']; $arguments=$config['arguments']; - if(class_exists($class) and array_search($i,self::$_setupedBackends)===false) { + if(class_exists($class) and array_search($i, self::$_setupedBackends)===false) { // make a reflection object $reflectionObj = new ReflectionClass($class); @@ -491,8 +491,8 @@ class OC_User { unset($_COOKIE["oc_username"]); unset($_COOKIE["oc_token"]); unset($_COOKIE["oc_remember_login"]); - setcookie("oc_username", NULL, -1); - setcookie("oc_token", NULL, -1); - setcookie("oc_remember_login", NULL, -1); + setcookie("oc_username", null, -1); + setcookie("oc_token", null, -1); + setcookie("oc_remember_login", null, -1); } } diff --git a/lib/util.php b/lib/util.php index c5f41be324b..907b4554037 100755 --- a/lib/util.php +++ b/lib/util.php @@ -34,7 +34,7 @@ class OC_Util { $CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); //first set up the local "root" storage if(!self::$rootMounted) { - OC_Filesystem::mount('OC_Filestorage_Local',array('datadir'=>$CONFIG_DATADIRECTORY),'/'); + OC_Filesystem::mount('OC_Filestorage_Local', array('datadir'=>$CONFIG_DATADIRECTORY),'/'); self::$rootMounted=true; } @@ -68,7 +68,7 @@ class OC_Util { $user_root = OC_User::getHome($user);
$userdirectory = $user_root . '/files'; if (is_file($user_root.'/mount.php')) {
- $mountConfig = include($user_root.'/mount.php');
+ $mountConfig = include $user_root.'/mount.php';
if (isset($mountConfig['user'][$user])) {
foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
OC_Filesystem::mount($options['class'], $options['options'], $mountPoint);
@@ -456,7 +456,7 @@ class OC_Util { * @return string */ public static function getInstanceId() { - $id=OC_Config::getValue('instanceid',null); + $id=OC_Config::getValue('instanceid', null); if(is_null($id)) { $id=uniqid(); OC_Config::setValue('instanceid',$id); @@ -611,14 +611,14 @@ class OC_Util { // Try to use openssl_random_pseudo_bytes if(function_exists('openssl_random_pseudo_bytes')) { $pseudo_byte = bin2hex(openssl_random_pseudo_bytes($length, $strong)); - if($strong == TRUE) { + if($strong == true) { return substr($pseudo_byte, 0, $length); // Truncate it to match the length } } // Try to use /dev/urandom $fp = @file_get_contents('/dev/urandom', false, null, 0, $length); - if ($fp !== FALSE) { + if ($fp !== false) { $string = substr(bin2hex($fp), 0, $length); return $string; } @@ -645,14 +645,14 @@ class OC_Util { // Check openssl_random_pseudo_bytes if(function_exists('openssl_random_pseudo_bytes')) { openssl_random_pseudo_bytes(1, $strong); - if($strong == TRUE) { + if($strong == true) { return true; } } // Check /dev/urandom $fp = @file_get_contents('/dev/urandom', false, null, 0, 1); - if ($fp !== FALSE) { + if ($fp !== false) { return true; } diff --git a/lib/vcategories.php b/lib/vcategories.php index 607a995cb33..ec243297a43 100644 --- a/lib/vcategories.php +++ b/lib/vcategories.php @@ -706,11 +706,11 @@ class OC_VCategories { if(!is_array($haystack)) { return false; } + return array_search( strtolower($needle), array_map('strtolower', $haystack) ); } - } diff --git a/lib/vobject.php b/lib/vobject.php index b5a04b4bf65..2ccf8eda685 100644 --- a/lib/vobject.php +++ b/lib/vobject.php @@ -62,7 +62,7 @@ class OC_VObject{ foreach($value as &$i ) { $i = implode("\\\\;", explode(';', $i)); } - return implode(';',$value); + return implode(';', $value); } /** @@ -71,15 +71,15 @@ class OC_VObject{ * @return array */ public static function unescapeSemicolons($value) { - $array = explode(';',$value); + $array = explode(';', $value); for($i=0;$i<count($array);$i++) { - if(substr($array[$i],-2,2)=="\\\\") { + if(substr($array[$i], -2, 2)=="\\\\") { if(isset($array[$i+1])) { - $array[$i] = substr($array[$i],0,count($array[$i])-2).';'.$array[$i+1]; + $array[$i] = substr($array[$i], 0, count($array[$i])-2).';'.$array[$i+1]; unset($array[$i+1]); } else{ - $array[$i] = substr($array[$i],0,count($array[$i])-2).';'; + $array[$i] = substr($array[$i], 0, count($array[$i])-2).';'; } $i = $i - 1; } @@ -127,8 +127,8 @@ class OC_VObject{ } public function setUID() { - $uid = substr(md5(rand().time()),0,10); - $this->vobject->add('UID',$uid); + $uid = substr(md5(rand().time()), 0, 10); + $this->vobject->add('UID', $uid); } public function setString($name, $string) { |