diff options
author | Thomas Mueller <thomas.mueller@tmit.eu> | 2012-09-07 15:22:01 +0200 |
---|---|---|
committer | Thomas Mueller <thomas.mueller@tmit.eu> | 2012-09-07 15:22:01 +0200 |
commit | 3829460ab8cbb6de65c53583a20fd04cbe7927dd (patch) | |
tree | 4dc24845a5eb31b17510a621e14c15b51f16bf7b | |
parent | 785aa751bb5f9a4bcdd677b96207550482e17d3c (diff) | |
download | nextcloud-server-3829460ab8cbb6de65c53583a20fd04cbe7927dd.tar.gz nextcloud-server-3829460ab8cbb6de65c53583a20fd04cbe7927dd.zip |
adding space between) and {
168 files changed, 1834 insertions, 1834 deletions
diff --git a/apps/files/admin.php b/apps/files/admin.php index b49c0f61a0c..a8f2deffc92 100644 --- a/apps/files/admin.php +++ b/apps/files/admin.php @@ -33,7 +33,7 @@ $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize') $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $maxUploadFilesize = OCP\Util::humanFileSize(min($upload_max_filesize, $post_max_size)); if($_POST) { - if(isset($_POST['maxUploadSize'])){ + if(isset($_POST['maxUploadSize'])) { if(($setMaxSize = OC_Files::setUploadLimit(OCP\Util::computerFileSize($_POST['maxUploadSize']))) !== false) { $maxUploadFilesize = OCP\Util::humanFileSize($setMaxSize); } diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index 2254526231e..568fe754c02 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -17,7 +17,7 @@ $data = array(); if($doBreadcrumb) { $breadcrumb = array(); $pathtohere = "/"; - foreach( explode( "/", $dir ) as $i ){ + foreach( explode( "/", $dir ) as $i ) { if( $i != "" ) { $pathtohere .= "$i/"; $breadcrumb[] = array( "dir" => $pathtohere, "name" => $i ); @@ -32,7 +32,7 @@ if($doBreadcrumb) { // make filelist $files = array(); -foreach( OC_Files::getdirectorycontent( $dir ) as $i ){ +foreach( OC_Files::getdirectorycontent( $dir ) as $i ) { $i["date"] = OCP\Util::formatDate($i["mtime"] ); $files[] = $i; } diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 813a6c67b5c..7709becc6a8 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -35,7 +35,7 @@ $dir = $_POST['dir']; $error=''; $totalSize=0; -foreach($files['size'] as $size){ +foreach($files['size'] as $size) { $totalSize+=$size; } if($totalSize>OC_Filesystem::free_space('/')) { @@ -46,7 +46,7 @@ if($totalSize>OC_Filesystem::free_space('/')) { $result=array(); if(strpos($dir, '..') === false) { $fileCount=count($files['name']); - for($i=0;$i<$fileCount;$i++){ + for($i=0;$i<$fileCount;$i++) { $target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]); if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { $meta=OC_FileCache_Cached::get($target); diff --git a/apps/files/appinfo/filesync.php b/apps/files/appinfo/filesync.php index 707ee2435c0..c1fe444cec7 100644 --- a/apps/files/appinfo/filesync.php +++ b/apps/files/appinfo/filesync.php @@ -23,14 +23,14 @@ // only need filesystem apps $RUNTIME_APPTYPES=array('filesystem','authentication'); OC_App::loadApps($RUNTIME_APPTYPES); -if(!OC_User::isLoggedIn()){ - if(!isset($_SERVER['PHP_AUTH_USER'])){ +if(!OC_User::isLoggedIn()) { + if(!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="ownCloud Server"'); header('HTTP/1.0 401 Unauthorized'); echo 'Valid credentials must be supplied'; exit(); } else { - if(!OC_User::login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"])){ + if(!OC_User::login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"])) { exit(); } } diff --git a/apps/files/appinfo/update.php b/apps/files/appinfo/update.php index 32ac89f0061..35008e345b9 100644 --- a/apps/files/appinfo/update.php +++ b/apps/files/appinfo/update.php @@ -5,7 +5,7 @@ $installedVersion=OCP\Config::getAppValue('files', 'installed_version'); if (version_compare($installedVersion, '1.1.4', '<')) { $query = OC_DB::prepare( "SELECT `propertyname`, `propertypath`, `userid` FROM `*PREFIX*properties`" ); $result = $query->execute(); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $query = OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertyname` = ? WHERE `userid` = ? AND `propertypath` = ?' ); $query->execute( array( preg_replace("/^{.*}/", "", $row["propertyname"]),$row["userid"], $row["propertypath"] )); } diff --git a/apps/files/download.php b/apps/files/download.php index 44a328e25db..ff6aefbbe0f 100644 --- a/apps/files/download.php +++ b/apps/files/download.php @@ -29,7 +29,7 @@ OCP\User::checkLoggedIn(); $filename = $_GET["file"]; -if(!OC_Filesystem::file_exists($filename)){ +if(!OC_Filesystem::file_exists($filename)) { header("HTTP/1.0 404 Not Found"); $tmpl = new OCP\Template( '', '404', 'guest' ); $tmpl->assign('file',$filename); diff --git a/apps/files/index.php b/apps/files/index.php index ba785f7d6bc..493087d26f1 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -31,7 +31,7 @@ OCP\Util::addscript( 'files', 'jquery.fileupload' ); OCP\Util::addscript( 'files', 'files' ); OCP\Util::addscript( 'files', 'filelist' ); OCP\Util::addscript( 'files', 'fileactions' ); -if(!isset($_SESSION['timezone'])){ +if(!isset($_SESSION['timezone'])) { OCP\Util::addscript( 'files', 'timezone' ); } OCP\App::setActiveNavigationEntry( 'files_index' ); @@ -44,9 +44,9 @@ if(!OC_Filesystem::is_dir($dir.'/')) { } $files = array(); -foreach( OC_Files::getdirectorycontent( $dir ) as $i ){ +foreach( OC_Files::getdirectorycontent( $dir ) as $i ) { $i['date'] = OCP\Util::formatDate($i['mtime'] ); - if($i['type']=='file'){ + if($i['type']=='file') { $fileinfo=pathinfo($i['name']); $i['basename']=$fileinfo['filename']; if (!empty($fileinfo['extension'])) { @@ -56,7 +56,7 @@ foreach( OC_Files::getdirectorycontent( $dir ) as $i ){ $i['extension']=''; } } - if($i['directory']=='/'){ + if($i['directory']=='/') { $i['directory']=''; } $files[] = $i; @@ -65,8 +65,8 @@ foreach( OC_Files::getdirectorycontent( $dir ) as $i ){ // Make breadcrumb $breadcrumb = array(); $pathtohere = ''; -foreach( explode( '/', $dir ) as $i ){ - if( $i != '' ){ +foreach( explode( '/', $dir ) as $i ) { + if( $i != '' ) { $pathtohere .= '/'.str_replace('+','%20', urlencode($i)); $breadcrumb[] = array( 'dir' => $pathtohere, 'name' => $i ); } diff --git a/apps/files/settings.php b/apps/files/settings.php index b02c3738c6e..52ec9fd0fe3 100644 --- a/apps/files/settings.php +++ b/apps/files/settings.php @@ -36,7 +36,7 @@ OCP\Util::addscript( "files", "files" ); $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; $files = array(); -foreach( OC_Files::getdirectorycontent( $dir ) as $i ){ +foreach( OC_Files::getdirectorycontent( $dir ) as $i ) { $i["date"] = date( $CONFIG_DATEFORMAT, $i["mtime"] ); $files[] = $i; } @@ -44,8 +44,8 @@ foreach( OC_Files::getdirectorycontent( $dir ) as $i ){ // Make breadcrumb $breadcrumb = array(); $pathtohere = "/"; -foreach( explode( "/", $dir ) as $i ){ - if( $i != "" ){ +foreach( explode( "/", $dir ) as $i ) { + if( $i != "" ) { $pathtohere .= "$i/"; $breadcrumb[] = array( "dir" => $pathtohere, "name" => $i ); } diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php index 679d0b95edc..bb130a366be 100644 --- a/apps/files_encryption/appinfo/app.php +++ b/apps/files_encryption/appinfo/app.php @@ -10,7 +10,7 @@ OCP\Util::connectHook('OC_User','post_login','OC_Crypt','loginListener'); stream_wrapper_register('crypt','OC_CryptStream'); -if(!isset($_SESSION['enckey']) and OCP\User::isLoggedIn()){//force the user to re-loggin if the encryption key isn't unlocked (happens when a user is logged in before the encryption app is enabled) +if(!isset($_SESSION['enckey']) and OCP\User::isLoggedIn()) {//force the user to re-loggin if the encryption key isn't unlocked (happens when a user is logged in before the encryption app is enabled) OCP\User::logout(); header("Location: ".OC::$WEBROOT.'/'); exit(); diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php index ebc09e78961..38d8edf28c3 100644 --- a/apps/files_encryption/lib/crypt.php +++ b/apps/files_encryption/lib/crypt.php @@ -39,18 +39,18 @@ require_once 'Crypt_Blowfish/Blowfish.php'; class OC_Crypt { static private $bf = null; - public static function loginListener($params){ + public static function loginListener($params) { self::init($params['uid'],$params['password']); } public static function init($login,$password) { $view=new OC_FilesystemView('/'); - if(!$view->file_exists('/'.$login)){ + if(!$view->file_exists('/'.$login)) { $view->mkdir('/'.$login); } OC_FileProxy::$enabled=false; - if(!$view->file_exists('/'.$login.'/encryption.key')){// does key exist? + if(!$view->file_exists('/'.$login.'/encryption.key')) {// does key exist? OC_Crypt::createkey($login,$password); } $key=$view->file_get_contents('/'.$login.'/encryption.key'); @@ -66,14 +66,14 @@ class OC_Crypt { * * if the key is left out, the default handeler will be used */ - public static function getBlowfish($key=''){ - if($key){ + public static function getBlowfish($key='') { + if($key) { return new Crypt_Blowfish($key); }else{ - if(!isset($_SESSION['enckey'])){ + if(!isset($_SESSION['enckey'])) { return false; } - if(!self::$bf){ + if(!self::$bf) { self::$bf=new Crypt_Blowfish($_SESSION['enckey']); } return self::$bf; @@ -96,7 +96,7 @@ class OC_Crypt { } public static function changekeypasscode($oldPassword, $newPassword) { - if(OCP\User::isLoggedIn()){ + if(OCP\User::isLoggedIn()) { $username=OCP\USER::getUser(); $view=new OC_FilesystemView('/'.$username); @@ -179,7 +179,7 @@ class OC_Crypt { while (!feof($handleread)) { $content = fread($handleread, 8192); $enccontent=OC_CRYPT::decrypt( $content, $key); - if(feof($handleread)){ + if(feof($handleread)) { $enccontent=rtrim($enccontent, "\0"); } fwrite($handlewrite, $enccontent); @@ -192,9 +192,9 @@ class OC_Crypt { /** * encrypt data in 8192b sized blocks */ - public static function blockEncrypt($data, $key=''){ + public static function blockEncrypt($data, $key='') { $result=''; - while(strlen($data)){ + while(strlen($data)) { $result.=self::encrypt(substr($data,0,8192),$key); $data=substr($data,8192); } @@ -204,13 +204,13 @@ class OC_Crypt { /** * decrypt data in 8192b sized blocks */ - public static function blockDecrypt($data, $key='',$maxLength=0){ + public static function blockDecrypt($data, $key='',$maxLength=0) { $result=''; - while(strlen($data)){ + while(strlen($data)) { $result.=self::decrypt(substr($data,0,8192),$key); $data=substr($data,8192); } - if($maxLength>0){ + if($maxLength>0) { return substr($result,0,$maxLength); }else{ return rtrim($result, "\0"); diff --git a/apps/files_encryption/lib/cryptstream.php b/apps/files_encryption/lib/cryptstream.php index 75ad62659d7..721a1b955df 100644 --- a/apps/files_encryption/lib/cryptstream.php +++ b/apps/files_encryption/lib/cryptstream.php @@ -36,18 +36,18 @@ class OC_CryptStream{ private $size; private static $rootView; - public function stream_open($path, $mode, $options, &$opened_path){ - if(!self::$rootView){ + public function stream_open($path, $mode, $options, &$opened_path) { + if(!self::$rootView) { self::$rootView=new OC_FilesystemView(''); } $path=str_replace('crypt://','',$path); - if(dirname($path)=='streams' and isset(self::$sourceStreams[basename($path)])){ + if(dirname($path)=='streams' and isset(self::$sourceStreams[basename($path)])) { $this->source=self::$sourceStreams[basename($path)]['stream']; $this->path=self::$sourceStreams[basename($path)]['path']; $this->size=self::$sourceStreams[basename($path)]['size']; }else{ $this->path=$path; - if($mode=='w' or $mode=='w+' or $mode=='wb' or $mode=='wb+'){ + if($mode=='w' or $mode=='w+' or $mode=='wb' or $mode=='wb+') { $this->size=0; }else{ $this->size=self::$rootView->filesize($path,$mode); @@ -55,55 +55,55 @@ class OC_CryptStream{ OC_FileProxy::$enabled=false;//disable fileproxies so we can open the source file $this->source=self::$rootView->fopen($path,$mode); OC_FileProxy::$enabled=true; - if(!is_resource($this->source)){ + if(!is_resource($this->source)) { OCP\Util::writeLog('files_encryption','failed to open '.$path,OCP\Util::ERROR); } } - if(is_resource($this->source)){ + if(is_resource($this->source)) { $this->meta=stream_get_meta_data($this->source); } return is_resource($this->source); } - public function stream_seek($offset, $whence=SEEK_SET){ + public function stream_seek($offset, $whence=SEEK_SET) { $this->flush(); fseek($this->source,$offset,$whence); } - public function stream_tell(){ + public function stream_tell() { return ftell($this->source); } - public function stream_read($count){ + public function stream_read($count) { //$count will always be 8192 https://bugs.php.net/bug.php?id=21641 //This makes this function a lot simpler but will breake everything the moment it's fixed $this->writeCache=''; - if($count!=8192){ + if($count!=8192) { OCP\Util::writeLog('files_encryption','php bug 21641 no longer holds, decryption will not work',OCP\Util::FATAL); die(); } $pos=ftell($this->source); $data=fread($this->source,8192); - if(strlen($data)){ + if(strlen($data)) { $result=OC_Crypt::decrypt($data); }else{ $result=''; } $length=$this->size-$pos; - if($length<8192){ + if($length<8192) { $result=substr($result,0,$length); } return $result; } - public function stream_write($data){ + public function stream_write($data) { $length=strlen($data); $currentPos=ftell($this->source); - if($this->writeCache){ + if($this->writeCache) { $data=$this->writeCache.$data; $this->writeCache=''; } - if($currentPos%8192!=0){ + if($currentPos%8192!=0) { //make sure we always start on a block start fseek($this->source,-($currentPos%8192),SEEK_CUR); $encryptedBlock=fread($this->source,8192); @@ -113,8 +113,8 @@ class OC_CryptStream{ fseek($this->source,-($currentPos%8192),SEEK_CUR); } $currentPos=ftell($this->source); - while($remainingLength=strlen($data)>0){ - if($remainingLength<8192){ + while($remainingLength=strlen($data)>0) { + if($remainingLength<8192) { $this->writeCache=$data; $data=''; }else{ @@ -127,8 +127,8 @@ class OC_CryptStream{ return $length; } - public function stream_set_option($option,$arg1,$arg2){ - switch($option){ + public function stream_set_option($option,$arg1,$arg2) { + switch($option) { case STREAM_OPTION_BLOCKING: stream_set_blocking($this->source,$arg1); break; @@ -140,33 +140,33 @@ class OC_CryptStream{ } } - public function stream_stat(){ + public function stream_stat() { return fstat($this->source); } - public function stream_lock($mode){ + public function stream_lock($mode) { flock($this->source,$mode); } - public function stream_flush(){ + public function stream_flush() { return fflush($this->source); } - public function stream_eof(){ + public function stream_eof() { return feof($this->source); } - private function flush(){ - if($this->writeCache){ + private function flush() { + if($this->writeCache) { $encrypted=OC_Crypt::encrypt($this->writeCache); fwrite($this->source,$encrypted); $this->writeCache=''; } } - public function stream_close(){ + public function stream_close() { $this->flush(); - if($this->meta['mode']!='r' and $this->meta['mode']!='rb'){ + if($this->meta['mode']!='r' and $this->meta['mode']!='rb') { OC_FileCache::put($this->path,array('encrypted'=>true,'size'=>$this->size),''); } return fclose($this->source); diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 247924b2aaf..f61cd1e3773 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -34,21 +34,21 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ * @param string $path * @return bool */ - private static function shouldEncrypt($path){ - if(is_null(self::$enableEncryption)){ + private static function shouldEncrypt($path) { + if(is_null(self::$enableEncryption)) { self::$enableEncryption=(OCP\Config::getAppValue('files_encryption','enable_encryption','true')=='true'); } - if(!self::$enableEncryption){ + if(!self::$enableEncryption) { return false; } - if(is_null(self::$blackList)){ + if(is_null(self::$blackList)) { self::$blackList=explode(',',OCP\Config::getAppValue('files_encryption','type_blacklist','jpg,png,jpeg,avi,mpg,mpeg,mkv,mp3,oga,ogv,ogg')); } - if(self::isEncrypted($path)){ + if(self::isEncrypted($path)) { return true; } $extension=substr($path,strrpos($path,'.')+1); - if(array_search($extension,self::$blackList)===false){ + if(array_search($extension,self::$blackList)===false) { return true; } } @@ -58,13 +58,13 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ * @param string $path * @return bool */ - private static function isEncrypted($path){ + private static function isEncrypted($path) { $metadata=OC_FileCache_Cached::get($path,''); return isset($metadata['encrypted']) and (bool)$metadata['encrypted']; } - public function preFile_put_contents($path,&$data){ - if(self::shouldEncrypt($path)){ + public function preFile_put_contents($path,&$data) { + if(self::shouldEncrypt($path)) { if (!is_resource($data)) {//stream put contents should have been converter to fopen $size=strlen($data); $data=OC_Crypt::blockEncrypt($data); @@ -73,24 +73,24 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ } } - public function postFile_get_contents($path,$data){ - if(self::isEncrypted($path)){ + public function postFile_get_contents($path,$data) { + if(self::isEncrypted($path)) { $cached=OC_FileCache_Cached::get($path,''); $data=OC_Crypt::blockDecrypt($data,'',$cached['size']); } return $data; } - public function postFopen($path,&$result){ - if(!$result){ + public function postFopen($path,&$result) { + if(!$result) { return $result; } $meta=stream_get_meta_data($result); - if(self::isEncrypted($path)){ + if(self::isEncrypted($path)) { fclose($result); $result=fopen('crypt://'.$path,$meta['mode']); - }elseif(self::shouldEncrypt($path) and $meta['mode']!='r' and $meta['mode']!='rb'){ - if(OC_Filesystem::file_exists($path) and OC_Filesystem::filesize($path)>0){ + }elseif(self::shouldEncrypt($path) and $meta['mode']!='r' and $meta['mode']!='rb') { + if(OC_Filesystem::file_exists($path) and OC_Filesystem::filesize($path)>0) { //first encrypt the target file so we don't end up with a half encrypted file OCP\Util::writeLog('files_encryption','Decrypting '.$path.' before writing',OCP\Util::DEBUG); $tmp=fopen('php://temp'); @@ -104,23 +104,23 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ return $result; } - public function postGetMimeType($path,$mime){ - if(self::isEncrypted($path)){ + public function postGetMimeType($path,$mime) { + if(self::isEncrypted($path)) { $mime=OCP\Files::getMimeType('crypt://'.$path,'w'); } return $mime; } - public function postStat($path,$data){ - if(self::isEncrypted($path)){ + public function postStat($path,$data) { + if(self::isEncrypted($path)) { $cached=OC_FileCache_Cached::get($path,''); $data['size']=$cached['size']; } return $data; } - public function postFileSize($path,$size){ - if(self::isEncrypted($path)){ + public function postFileSize($path,$size) { + if(self::isEncrypted($path)) { $cached=OC_FileCache_Cached::get($path,''); return $cached['size']; }else{ diff --git a/apps/files_encryption/templates/settings.php b/apps/files_encryption/templates/settings.php index 79780d694cf..55e8cf1542c 100644 --- a/apps/files_encryption/templates/settings.php +++ b/apps/files_encryption/templates/settings.php @@ -7,6 +7,6 @@ <option selected="selected" value="<?php echo $type;?>"><?php echo $type;?></option> <?php endforeach;?> </select> - <input type='checkbox' id='enable_encryption' <?php if($_['encryption_enabled']){echo 'checked="checked"';} ?>></input><label for='enable_encryption'><?php echo $l->t('Enable Encryption')?></label> + <input type='checkbox' id='enable_encryption' <?php if($_['encryption_enabled']) {echo 'checked="checked"';} ?>></input><label for='enable_encryption'><?php echo $l->t('Enable Encryption')?></label> </fieldset> </form> diff --git a/apps/files_encryption/tests/encryption.php b/apps/files_encryption/tests/encryption.php index f70411ed63c..89397f6ef2c 100644 --- a/apps/files_encryption/tests/encryption.php +++ b/apps/files_encryption/tests/encryption.php @@ -7,7 +7,7 @@ */ class Test_Encryption extends UnitTestCase { - function testEncryption(){ + function testEncryption() { $key=uniqid(); $file=OC::$SERVERROOT.'/3rdparty/MDB2.php'; $source=file_get_contents($file); //nice large text file @@ -54,7 +54,7 @@ class Test_Encryption extends UnitTestCase { } - function testBinary(){ + function testBinary() { $key=uniqid(); $file=__DIR__.'/binary'; diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php index c4952d13d39..042011a6c87 100644 --- a/apps/files_encryption/tests/proxy.php +++ b/apps/files_encryption/tests/proxy.php @@ -10,7 +10,7 @@ class Test_CryptProxy extends UnitTestCase { private $oldConfig; private $oldKey; - public function setUp(){ + public function setUp() { $user=OC_User::getUser(); $this->oldConfig=OCP\Config::getAppValue('files_encryption','enable_encryption','true'); @@ -40,14 +40,14 @@ class Test_CryptProxy extends UnitTestCase { $rootView->mkdir('/'.$user.'/files'); } - public function tearDown(){ + public function tearDown() { OCP\Config::setAppValue('files_encryption','enable_encryption',$this->oldConfig); - if(!is_null($this->oldKey)){ + if(!is_null($this->oldKey)) { $_SESSION['enckey']=$this->oldKey; } } - public function testSimple(){ + public function testSimple() { $file=OC::$SERVERROOT.'/3rdparty/MDB2.php'; $original=file_get_contents($file); @@ -64,7 +64,7 @@ class Test_CryptProxy extends UnitTestCase { } - public function testView(){ + public function testView() { $file=OC::$SERVERROOT.'/3rdparty/MDB2.php'; $original=file_get_contents($file); @@ -86,7 +86,7 @@ class Test_CryptProxy extends UnitTestCase { $this->assertEqual($original,$fromFile); } - public function testBinary(){ + public function testBinary() { $file=__DIR__.'/binary'; $original=file_get_contents($file); diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php index 517d497344e..39b13620782 100644 --- a/apps/files_encryption/tests/stream.php +++ b/apps/files_encryption/tests/stream.php @@ -9,7 +9,7 @@ class Test_CryptStream extends UnitTestCase { private $tmpFiles=array(); - function testStream(){ + function testStream() { $stream=$this->getStream('test1','w',strlen('foobar')); fwrite($stream,'foobar'); fclose($stream); @@ -40,11 +40,11 @@ class Test_CryptStream extends UnitTestCase { * @param int size * @return resource */ - function getStream($id,$mode,$size){ - if($id===''){ + function getStream($id,$mode,$size) { + if($id==='') { $id=uniqid(); } - if(!isset($this->tmpFiles[$id])){ + if(!isset($this->tmpFiles[$id])) { $file=OCP\Files::tmpFile(); $this->tmpFiles[$id]=$file; }else{ @@ -55,7 +55,7 @@ class Test_CryptStream extends UnitTestCase { return fopen('crypt://streams/'.$id,$mode); } - function testBinary(){ + function testBinary() { $file=__DIR__.'/binary'; $source=file_get_contents($file); diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php index 818273f6c2d..261141455cc 100644 --- a/apps/files_external/lib/ftp.php +++ b/apps/files_external/lib/ftp.php @@ -15,13 +15,13 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{ private static $tempFiles=array(); - public function __construct($params){ + public function __construct($params) { $this->host=$params['host']; $this->user=$params['user']; $this->password=$params['password']; $this->secure=isset($params['secure'])?(bool)$params['secure']:false; $this->root=isset($params['root'])?$params['root']:'/'; - if(!$this->root || $this->root[0]!='/'){ + if(!$this->root || $this->root[0]!='/') { $this->root='/'.$this->root; } //create the root folder if necesary @@ -35,16 +35,16 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{ * @param string path * @return string */ - public function constructUrl($path){ + public function constructUrl($path) { $url='ftp'; - if($this->secure){ + if($this->secure) { $url.='s'; } $url.='://'.$this->user.':'.$this->password.'@'.$this->host.$this->root.$path; return $url; } - public function fopen($path,$mode){ - switch($mode){ + public function fopen($path,$mode) { + switch($mode) { case 'r': case 'rb': case 'w': @@ -63,14 +63,14 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{ case 'c': case 'c+': //emulate these - if(strrpos($path,'.')!==false){ + if(strrpos($path,'.')!==false) { $ext=substr($path,strrpos($path,'.')); }else{ $ext=''; } $tmpFile=OCP\Files::tmpFile($ext); OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); - if($this->file_exists($path)){ + if($this->file_exists($path)) { $this->getFile($path,$tmpFile); } self::$tempFiles[$tmpFile]=$path; @@ -78,8 +78,8 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{ } } - public function writeBack($tmpFile){ - if(isset(self::$tempFiles[$tmpFile])){ + public function writeBack($tmpFile) { + if(isset(self::$tempFiles[$tmpFile])) { $this->uploadFile($tmpFile,self::$tempFiles[$tmpFile]); unlink($tmpFile); } diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index 91c0f16c1f6..e5ba7a17743 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -15,40 +15,40 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ private $root; private $share; - public function __construct($params){ + public function __construct($params) { $this->host=$params['host']; $this->user=$params['user']; $this->password=$params['password']; $this->share=$params['share']; $this->root=isset($params['root'])?$params['root']:'/'; - if(!$this->root || $this->root[0]!='/'){ + if(!$this->root || $this->root[0]!='/') { $this->root='/'.$this->root; } - if(substr($this->root,-1,1)!='/'){ + if(substr($this->root,-1,1)!='/') { $this->root.='/'; } - if(!$this->share || $this->share[0]!='/'){ + if(!$this->share || $this->share[0]!='/') { $this->share='/'.$this->share; } - if(substr($this->share,-1,1)=='/'){ + if(substr($this->share,-1,1)=='/') { $this->share=substr($this->share,0,-1); } //create the root folder if necesary - if(!$this->is_dir('')){ + if(!$this->is_dir('')) { $this->mkdir(''); } } - public function constructUrl($path){ - if(substr($path,-1)=='/'){ + public function constructUrl($path) { + if(substr($path,-1)=='/') { $path=substr($path,0,-1); } return 'smb://'.$this->user.':'.$this->password.'@'.$this->host.$this->share.$this->root.$path; } - public function stat($path){ - if(!$path and $this->root=='/'){//mtime doesn't work for shares + public function stat($path) { + if(!$path and $this->root=='/') {//mtime doesn't work for shares $mtime=$this->shareMTime(); $stat=stat($this->constructUrl($path)); $stat['mtime']=$mtime; @@ -58,7 +58,7 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ } } - public function filetype($path){ + public function filetype($path) { return (bool)@$this->opendir($path);//using opendir causes the same amount of requests and caches the content of the folder in one go } @@ -67,8 +67,8 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ * @param int $time * @return bool */ - public function hasUpdated($path,$time){ - if(!$path and $this->root=='/'){ + public function hasUpdated($path,$time) { + if(!$path and $this->root=='/') { //mtime doesn't work for shares, but giving the nature of the backend, doing a full update is still just fast enough return true; }else{ @@ -80,13 +80,13 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ /** * get the best guess for the modification time of the share */ - private function shareMTime(){ + private function shareMTime() { $dh=$this->opendir(''); $lastCtime=0; - while($file=readdir($dh)){ - if($file!='.' and $file!='..'){ + while($file=readdir($dh)) { + if($file!='.' and $file!='..') { $ctime=$this->filemtime($file); - if($ctime>$lastCtime){ + if($ctime>$lastCtime) { $lastCtime=$ctime; } } diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index 467c5a5b845..7263ef23253 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -10,12 +10,12 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{ abstract public function constructUrl($path); - public function mkdir($path){ + public function mkdir($path) { return mkdir($this->constructUrl($path)); } - public function rmdir($path){ - if($this->file_exists($path)){ + public function rmdir($path) { + if($this->file_exists($path)) { $succes=rmdir($this->constructUrl($path)); clearstatcache(); return $succes; @@ -24,42 +24,42 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{ } } - public function opendir($path){ + public function opendir($path) { return opendir($this->constructUrl($path)); } - public function filetype($path){ + public function filetype($path) { return filetype($this->constructUrl($path)); } - public function isReadable($path){ + public function isReadable($path) { return true;//not properly supported } - public function isUpdatable($path){ + public function isUpdatable($path) { return true;//not properly supported } - public function file_exists($path){ + public function file_exists($path) { return file_exists($this->constructUrl($path)); } - public function unlink($path){ + public function unlink($path) { $succes=unlink($this->constructUrl($path)); clearstatcache(); return $succes; } - public function fopen($path,$mode){ + public function fopen($path,$mode) { return fopen($this->constructUrl($path),$mode); } - public function free_space($path){ + public function free_space($path) { return 0; } - public function touch($path,$mtime=null){ - if(is_null($mtime)){ + public function touch($path,$mtime=null) { + if(is_null($mtime)) { $fh=$this->fopen($path,'a'); fwrite($fh,''); fclose($fh); @@ -68,19 +68,19 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{ } } - public function getFile($path,$target){ + public function getFile($path,$target) { return copy($this->constructUrl($path),$target); } - public function uploadFile($path,$target){ + public function uploadFile($path,$target) { return copy($path,$this->constructUrl($target)); } - public function rename($path1,$path2){ + public function rename($path1,$path2) { return rename($this->constructUrl($path1),$this->constructUrl($path2)); } - public function stat($path){ + public function stat($path) { return stat($this->constructUrl($path)); } diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index 9a4b5c6dd2b..c29d28b44c1 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -38,7 +38,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @param string path * @return string */ - private function getContainerName($path){ + private function getContainerName($path) { $path=trim($this->root.$path,'/'); return str_replace('/','\\',$path); } @@ -48,18 +48,18 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @param string path * @return CF_Container */ - private function getContainer($path){ - if($path=='' or $path=='/'){ + private function getContainer($path) { + if($path=='' or $path=='/') { return $this->rootContainer; } - if(isset($this->containers[$path])){ + if(isset($this->containers[$path])) { return $this->containers[$path]; } try{ $container=$this->conn->get_container($this->getContainerName($path)); $this->containers[$path]=$container; return $container; - }catch(NoSuchContainerException $e){ + }catch(NoSuchContainerException $e) { return null; } } @@ -69,15 +69,15 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @param string path * @return CF_Container */ - private function createContainer($path){ - if($path=='' or $path=='/'){ + private function createContainer($path) { + if($path=='' or $path=='/') { return $this->conn->create_container($this->getContainerName($path)); } $parent=dirname($path); - if($parent=='' or $parent=='/'){ + if($parent=='' or $parent=='/') { $parentContainer=$this->rootContainer; }else{ - if(!$this->containerExists($parent)){ + if(!$this->containerExists($parent)) { $parentContainer=$this->createContainer($parent); }else{ $parentContainer=$this->getContainer($parent); @@ -92,19 +92,19 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @param string path * @return CF_Object */ - private function getObject($path){ - if(isset($this->objects[$path])){ + private function getObject($path) { + if(isset($this->objects[$path])) { return $this->objects[$path]; } $container=$this->getContainer(dirname($path)); - if(is_null($container)){ + if(is_null($container)) { return null; }else{ try{ $obj=$container->get_object(basename($path)); $this->objects[$path]=$obj; return $obj; - }catch(NoSuchObjectException $e){ + }catch(NoSuchObjectException $e) { return null; } } @@ -115,12 +115,12 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @param CF_Container * @return array */ - private function getObjects($container){ - if(is_null($container)){ + private function getObjects($container) { + if(is_null($container)) { return array(); }else{ $files=$container->get_objects(); - foreach($files as &$file){ + foreach($files as &$file) { $file=$file->name; } return $files; @@ -132,9 +132,9 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @param string path * @return CF_Object */ - private function createObject($path){ + private function createObject($path) { $container=$this->getContainer(dirname($path)); - if(!is_null($container)){ + if(!is_null($container)) { $container=$this->createContainer($path); } return $container->create_object(basename($path)); @@ -145,7 +145,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @param string * @return bool */ - private function objectExists($path){ + private function objectExists($path) { return !is_null($this->getObject($path)); } @@ -154,7 +154,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @param string path * @return bool */ - private function containerExists($path){ + private function containerExists($path) { return !is_null($this->getContainer($path)); } @@ -163,18 +163,18 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @param CF_Container container * @return array */ - private function getSubContainers($container){ + private function getSubContainers($container) { $tmpFile=OCP\Files::tmpFile(); $obj=$this->getSubContainerFile($container); try{ $obj->save_to_filename($tmpFile); - }catch(Exception $e){ + }catch(Exception $e) { return array(); } $obj->save_to_filename($tmpFile); $containers=file($tmpFile); unlink($tmpFile); - foreach($containers as &$sub){ + foreach($containers as &$sub) { $sub=trim($sub); } return $containers; @@ -186,8 +186,8 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @param string name * @return bool */ - private function addSubContainer($container,$name){ - if(!$name){ + private function addSubContainer($container,$name) { + if(!$name) { return false; } $tmpFile=OCP\Files::tmpFile(); @@ -195,17 +195,17 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ try{ $obj->save_to_filename($tmpFile); $containers=file($tmpFile); - foreach($containers as &$sub){ + foreach($containers as &$sub) { $sub=trim($sub); } - if(array_search($name,$containers)!==false){ + if(array_search($name,$containers)!==false) { unlink($tmpFile); return false; }else{ $fh=fopen($tmpFile,'a'); fwrite($fh,$name."\n"); } - }catch(Exception $e){ + }catch(Exception $e) { $containers=array(); file_put_contents($tmpFile,$name."\n"); } @@ -221,8 +221,8 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @param string name * @return bool */ - private function removeSubContainer($container,$name){ - if(!$name){ + private function removeSubContainer($container,$name) { + if(!$name) { return false; } $tmpFile=OCP\Files::tmpFile(); @@ -230,14 +230,14 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ try{ $obj->save_to_filename($tmpFile); $containers=file($tmpFile); - }catch(Exception $e){ + }catch(Exception $e) { return false; } - foreach($containers as &$sub){ + foreach($containers as &$sub) { $sub=trim($sub); } $i=array_search($name,$containers); - if($i===false){ + if($i===false) { unlink($tmpFile); return false; }else{ @@ -255,21 +255,21 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @param CF_Container container * @return CF_Object */ - private function getSubContainerFile($container){ + private function getSubContainerFile($container) { try{ return $container->get_object(self::SUBCONTAINER_FILE); - }catch(NoSuchObjectException $e){ + }catch(NoSuchObjectException $e) { return $container->create_object(self::SUBCONTAINER_FILE); } } - public function __construct($params){ + public function __construct($params) { $this->token=$params['token']; $this->host=$params['host']; $this->user=$params['user']; $this->root=isset($params['root'])?$params['root']:'/'; $this->secure=isset($params['secure'])?(bool)$params['secure']:true; - if(!$this->root || $this->root[0]!='/'){ + if(!$this->root || $this->root[0]!='/') { $this->root='/'.$this->root; } $this->auth = new CF_Authentication($this->user, $this->token, null, $this->host); @@ -277,7 +277,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ $this->conn = new CF_Connection($this->auth); - if(!$this->containerExists($this->root)){ + if(!$this->containerExists($this->root)) { $this->rootContainer=$this->createContainer('/'); }else{ $this->rootContainer=$this->getContainer('/'); @@ -285,8 +285,8 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ } - public function mkdir($path){ - if($this->containerExists($path)){ + public function mkdir($path) { + if($this->containerExists($path)) { return false; }else{ $this->createContainer($path); @@ -294,12 +294,12 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ } } - public function rmdir($path){ - if(!$this->containerExists($path)){ + public function rmdir($path) { + if(!$this->containerExists($path)) { return false; }else{ $this->emptyContainer($path); - if($path!='' and $path!='/'){ + if($path!='' and $path!='/') { $parentContainer=$this->getContainer(dirname($path)); $this->removeSubContainer($parentContainer,basename($path)); } @@ -310,14 +310,14 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ } } - private function emptyContainer($path){ + private function emptyContainer($path) { $container=$this->getContainer($path); - if(is_null($container)){ + if(is_null($container)) { return; } $subContainers=$this->getSubContainers($container); - foreach($subContainers as $sub){ - if($sub){ + foreach($subContainers as $sub) { + if($sub) { $this->emptyContainer($path.'/'.$sub); $this->conn->delete_container($this->getContainerName($path.'/'.$sub)); unset($this->containers[$path.'/'.$sub]); @@ -325,17 +325,17 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ } $objects=$this->getObjects($container); - foreach($objects as $object){ + foreach($objects as $object) { $container->delete_object($object); unset($this->objects[$path.'/'.$object]); } } - public function opendir($path){ + public function opendir($path) { $container=$this->getContainer($path); $files=$this->getObjects($container); $i=array_search(self::SUBCONTAINER_FILE,$files); - if($i!==false){ + if($i!==false) { unset($files[$i]); } $subContainers=$this->getSubContainers($container); @@ -345,43 +345,43 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ return opendir('fakedir://'.$id); } - public function filetype($path){ - if($this->containerExists($path)){ + public function filetype($path) { + if($this->containerExists($path)) { return 'dir'; }else{ return 'file'; } } - public function isReadable($path){ + public function isReadable($path) { return true; } - public function isUpdatable($path){ + public function isUpdatable($path) { return true; } - public function file_exists($path){ - if($this->is_dir($path)){ + public function file_exists($path) { + if($this->is_dir($path)) { return true; }else{ return $this->objectExists($path); } } - public function file_get_contents($path){ + public function file_get_contents($path) { $obj=$this->getObject($path); - if(is_null($obj)){ + if(is_null($obj)) { return false; } return $obj->read(); } - public function file_put_contents($path,$content){ + public function file_put_contents($path,$content) { $obj=$this->getObject($path); - if(is_null($obj)){ + if(is_null($obj)) { $container=$this->getContainer(dirname($path)); - if(is_null($container)){ + if(is_null($container)) { return false; } $obj=$container->create_object(basename($path)); @@ -390,8 +390,8 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ return $obj->write($content); } - public function unlink($path){ - if($this->objectExists($path)){ + public function unlink($path) { + if($this->objectExists($path)) { $container=$this->getContainer(dirname($path)); $container->delete_object(basename($path)); unset($this->objects[$path]); @@ -400,12 +400,12 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ } } - public function fopen($path,$mode){ + public function fopen($path,$mode) { $obj=$this->getObject($path); - if(is_null($obj)){ + if(is_null($obj)) { return false; } - switch($mode){ + switch($mode) { case 'r': case 'rb': $fp = fopen('php://temp', 'r+'); @@ -432,23 +432,23 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ } } - public function writeBack($tmpFile){ - if(isset(self::$tempFiles[$tmpFile])){ + public function writeBack($tmpFile) { + if(isset(self::$tempFiles[$tmpFile])) { $this->fromTmpFile($tmpFile,self::$tempFiles[$tmpFile]); unlink($tmpFile); } } - public function free_space($path){ + public function free_space($path) { return 0; } - public function touch($path,$mtime=null){ + public function touch($path,$mtime=null) { $obj=$this->getObject($path); - if(is_null($obj)){ + if(is_null($obj)) { return false; } - if(is_null($mtime)){ + if(is_null($mtime)) { $mtime=time(); } @@ -457,36 +457,36 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ $obj->sync_metadata(); } - public function rename($path1,$path2){ + public function rename($path1,$path2) { $sourceContainer=$this->getContainer(dirname($path1)); $targetContainer=$this->getContainer(dirname($path2)); $result=$sourceContainer->move_object_to(basename($path1),$targetContainer,basename($path2)); unset($this->objects[$path1]); - if($result){ + if($result) { $targetObj=$this->getObject($path2); $this->resetMTime($targetObj); } return $result; } - public function copy($path1,$path2){ + public function copy($path1,$path2) { $sourceContainer=$this->getContainer(dirname($path1)); $targetContainer=$this->getContainer(dirname($path2)); $result=$sourceContainer->copy_object_to(basename($path1),$targetContainer,basename($path2)); - if($result){ + if($result) { $targetObj=$this->getObject($path2); $this->resetMTime($targetObj); } return $result; } - public function stat($path){ + public function stat($path) { $obj=$this->getObject($path); - if(is_null($obj)){ + if(is_null($obj)) { return false; } - if(isset($obj->metadata['Mtime']) and $obj->metadata['Mtime']>-1){ + if(isset($obj->metadata['Mtime']) and $obj->metadata['Mtime']>-1) { $mtime=$obj->metadata['Mtime']; }else{ $mtime=strtotime($obj->last_modified); @@ -498,9 +498,9 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ ); } - private function getTmpFile($path){ + private function getTmpFile($path) { $obj=$this->getObject($path); - if(!is_null($obj)){ + if(!is_null($obj)) { $tmpFile=OCP\Files::tmpFile(); $obj->save_to_filename($tmpFile); return $tmpFile; @@ -509,9 +509,9 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ } } - private function fromTmpFile($tmpFile,$path){ + private function fromTmpFile($tmpFile,$path) { $obj=$this->getObject($path); - if(is_null($obj)){ + if(is_null($obj)) { $obj=$this->createObject($path); } $obj->load_from_filename($tmpFile); @@ -522,8 +522,8 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * remove custom mtime metadata * @param CF_Object obj */ - private function resetMTime($obj){ - if(isset($obj->metadata['Mtime'])){ + private function resetMTime($obj) { + if(isset($obj->metadata['Mtime'])) { $obj->metadata['Mtime']=-1; $obj->sync_metadata(); } diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 1b9c3e3333b..3c18b227fa6 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -19,7 +19,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ private static $tempFiles=array(); - public function __construct($params){ + public function __construct($params) { $host = $params['host']; //remove leading http[s], will be generated in createBaseUri() if (substr($host,0,8) == "https://") $host = substr($host, 8); @@ -29,10 +29,10 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ $this->password=$params['password']; $this->secure=(isset($params['secure']) && $params['secure'] == 'true')?true:false; $this->root=isset($params['root'])?$params['root']:'/'; - if(!$this->root || $this->root[0]!='/'){ + if(!$this->root || $this->root[0]!='/') { $this->root='/'.$this->root; } - if(substr($this->root,-1,1)!='/'){ + if(substr($this->root,-1,1)!='/') { $this->root.='/'; } @@ -54,26 +54,26 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ $this->mkdir(''); } - private function createBaseUri(){ + private function createBaseUri() { $baseUri='http'; - if($this->secure){ + if($this->secure) { $baseUri.='s'; } $baseUri.='://'.$this->host.$this->root; return $baseUri; } - public function mkdir($path){ + public function mkdir($path) { $path=$this->cleanPath($path); return $this->simpleResponse('MKCOL',$path,null,201); } - public function rmdir($path){ + public function rmdir($path) { $path=$this->cleanPath($path); return $this->simpleResponse('DELETE',$path,null,204); } - public function opendir($path){ + public function opendir($path) { $path=$this->cleanPath($path); try{ $response=$this->client->propfind($path, array(),1); @@ -81,54 +81,54 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ OC_FakeDirStream::$dirs[$id]=array(); $files=array_keys($response); array_shift($files);//the first entry is the current directory - foreach($files as $file){ + foreach($files as $file) { $file = urldecode(basename($file)); OC_FakeDirStream::$dirs[$id][]=$file; } return opendir('fakedir://'.$id); - }catch(Exception $e){ + }catch(Exception $e) { return false; } } - public function filetype($path){ + public function filetype($path) { $path=$this->cleanPath($path); try{ $response=$this->client->propfind($path, array('{DAV:}resourcetype')); $responseType=$response["{DAV:}resourcetype"]->resourceType; return (count($responseType)>0 and $responseType[0]=="{DAV:}collection")?'dir':'file'; - }catch(Exception $e){ + }catch(Exception $e) { error_log($e->getMessage()); \OCP\Util::writeLog("webdav client", \OCP\Util::sanitizeHTML($e->getMessage()), \OCP\Util::ERROR); return false; } } - public function isReadable($path){ + public function isReadable($path) { return true;//not properly supported } - public function isUpdatable($path){ + public function isUpdatable($path) { return true;//not properly supported } - public function file_exists($path){ + public function file_exists($path) { $path=$this->cleanPath($path); try{ $this->client->propfind($path, array('{DAV:}resourcetype')); return true;//no 404 exception - }catch(Exception $e){ + }catch(Exception $e) { return false; } } - public function unlink($path){ + public function unlink($path) { return $this->simpleResponse('DELETE',$path,null,204); } - public function fopen($path,$mode){ + public function fopen($path,$mode) { $path=$this->cleanPath($path); - switch($mode){ + switch($mode) { case 'r': case 'rb': //straight up curl instead of sabredav here, sabredav put's the entire get result in memory @@ -155,14 +155,14 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ case 'c': case 'c+': //emulate these - if(strrpos($path,'.')!==false){ + if(strrpos($path,'.')!==false) { $ext=substr($path,strrpos($path,'.')); }else{ $ext=''; } $tmpFile=OCP\Files::tmpFile($ext); OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); - if($this->file_exists($path)){ + if($this->file_exists($path)) { $this->getFile($path,$tmpFile); } self::$tempFiles[$tmpFile]=$path; @@ -170,41 +170,41 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ } } - public function writeBack($tmpFile){ - if(isset(self::$tempFiles[$tmpFile])){ + public function writeBack($tmpFile) { + if(isset(self::$tempFiles[$tmpFile])) { $this->uploadFile($tmpFile,self::$tempFiles[$tmpFile]); unlink($tmpFile); } } - public function free_space($path){ + public function free_space($path) { $path=$this->cleanPath($path); try{ $response=$this->client->propfind($path, array('{DAV:}quota-available-bytes')); - if(isset($response['{DAV:}quota-available-bytes'])){ + if(isset($response['{DAV:}quota-available-bytes'])) { return (int)$response['{DAV:}quota-available-bytes']; }else{ return 0; } - }catch(Exception $e){ + }catch(Exception $e) { return 0; } } - public function touch($path,$mtime=null){ - if(is_null($mtime)){ + public function touch($path,$mtime=null) { + if(is_null($mtime)) { $mtime=time(); } $path=$this->cleanPath($path); $this->client->proppatch($path, array('{DAV:}lastmodified' => $mtime)); } - public function getFile($path,$target){ + public function getFile($path,$target) { $source=$this->fopen($path,'r'); file_put_contents($target,$source); } - public function uploadFile($path,$target){ + public function uploadFile($path,$target) { $source=fopen($path,'r'); $curl = curl_init(); @@ -218,13 +218,13 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ curl_close ($curl); } - public function rename($path1,$path2){ + public function rename($path1,$path2) { $path1=$this->cleanPath($path1); $path2=$this->root.$this->cleanPath($path2); try{ $response=$this->client->request('MOVE',$path1,null,array('Destination'=>$path2)); return true; - }catch(Exception $e){ + }catch(Exception $e) { echo $e; echo 'fail'; var_dump($response); @@ -232,13 +232,13 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ } } - public function copy($path1,$path2){ + public function copy($path1,$path2) { $path1=$this->cleanPath($path1); $path2=$this->root.$this->cleanPath($path2); try{ $response=$this->client->request('COPY',$path1,null,array('Destination'=>$path2)); return true; - }catch(Exception $e){ + }catch(Exception $e) { echo $e; echo 'fail'; var_dump($response); @@ -246,7 +246,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ } } - public function stat($path){ + public function stat($path) { $path=$this->cleanPath($path); try{ $response=$this->client->propfind($path, array('{DAV:}getlastmodified','{DAV:}getcontentlength')); @@ -255,43 +255,43 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ 'size'=>(int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0, 'ctime'=>-1, ); - }catch(Exception $e){ + }catch(Exception $e) { return array(); } } - public function getMimeType($path){ + public function getMimeType($path) { $path=$this->cleanPath($path); try{ $response=$this->client->propfind($path, array('{DAV:}getcontenttype','{DAV:}resourcetype')); $responseType=$response["{DAV:}resourcetype"]->resourceType; $type=(count($responseType)>0 and $responseType[0]=="{DAV:}collection")?'dir':'file'; - if($type=='dir'){ + if($type=='dir') { return 'httpd/unix-directory'; - }elseif(isset($response['{DAV:}getcontenttype'])){ + }elseif(isset($response['{DAV:}getcontenttype'])) { return $response['{DAV:}getcontenttype']; }else{ return false; } - }catch(Exception $e){ + }catch(Exception $e) { return false; } } - private function cleanPath($path){ - if(!$path || $path[0]=='/'){ + private function cleanPath($path) { + if(!$path || $path[0]=='/') { return substr($path,1); }else{ return $path; } } - private function simpleResponse($method,$path,$body,$expected){ + private function simpleResponse($method,$path,$body,$expected) { $path=$this->cleanPath($path); try{ $response=$this->client->request($method,$path,$body); return $response['statusCode']==$expected; - }catch(Exception $e){ + }catch(Exception $e) { return false; } } diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/ftp.php index 3548880e834..12f3ec3908d 100644 --- a/apps/files_external/tests/ftp.php +++ b/apps/files_external/tests/ftp.php @@ -7,21 +7,21 @@ */ $config=include('apps/files_external/tests/config.php'); -if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']){ +if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']) { abstract class Test_Filestorage_FTP extends Test_FileStorage{} return; }else{ class Test_Filestorage_FTP extends Test_FileStorage { private $config; - public function setUp(){ + public function setUp() { $id=uniqid(); $this->config=include('apps/files_external/tests/config.php'); $this->config['ftp']['root'].='/'.$id;//make sure we have an new empty folder to work in $this->instance=new OC_Filestorage_FTP($this->config['ftp']); } - public function tearDown(){ + public function tearDown() { OCP\Files::rmdirr($this->instance->constructUrl('')); } } diff --git a/apps/files_external/tests/google.php b/apps/files_external/tests/google.php index b0bd9cbbeaf..d2a6358ade4 100644 --- a/apps/files_external/tests/google.php +++ b/apps/files_external/tests/google.php @@ -21,7 +21,7 @@ */ $config=include('apps/files_external/tests/config.php'); -if(!is_array($config) or !isset($config['google']) or !$config['google']['run']){ +if(!is_array($config) or !isset($config['google']) or !$config['google']['run']) { abstract class Test_Filestorage_Google extends Test_FileStorage{} return; }else{ @@ -29,14 +29,14 @@ if(!is_array($config) or !isset($config['google']) or !$config['google']['run']) private $config; - public function setUp(){ + public function setUp() { $id=uniqid(); $this->config=include('apps/files_external/tests/config.php'); $this->config['google']['root'].='/'.$id;//make sure we have an new empty folder to work in $this->instance=new OC_Filestorage_Google($this->config['google']); } - public function tearDown(){ + public function tearDown() { $this->instance->rmdir('/'); } } diff --git a/apps/files_external/tests/smb.php b/apps/files_external/tests/smb.php index 001ef842276..7de4fddbb34 100644 --- a/apps/files_external/tests/smb.php +++ b/apps/files_external/tests/smb.php @@ -8,21 +8,21 @@ $config=include('apps/files_external/tests/config.php'); -if(!is_array($config) or !isset($config['smb']) or !$config['smb']['run']){ +if(!is_array($config) or !isset($config['smb']) or !$config['smb']['run']) { abstract class Test_Filestorage_SMB extends Test_FileStorage{} return; }else{ class Test_Filestorage_SMB extends Test_FileStorage { private $config; - public function setUp(){ + public function setUp() { $id=uniqid(); $this->config=include('apps/files_external/tests/config.php'); $this->config['smb']['root'].=$id;//make sure we have an new empty folder to work in $this->instance=new OC_Filestorage_SMB($this->config['smb']); } - public function tearDown(){ + public function tearDown() { OCP\Files::rmdirr($this->instance->constructUrl('')); } } diff --git a/apps/files_external/tests/swift.php b/apps/files_external/tests/swift.php index bfe7b77aac5..a6f5eace1c8 100644 --- a/apps/files_external/tests/swift.php +++ b/apps/files_external/tests/swift.php @@ -7,14 +7,14 @@ */ $config=include('apps/files_external/tests/config.php'); -if(!is_array($config) or !isset($config['swift']) or !$config['swift']['run']){ +if(!is_array($config) or !isset($config['swift']) or !$config['swift']['run']) { abstract class Test_Filestorage_SWIFT extends Test_FileStorage{} return; }else{ class Test_Filestorage_SWIFT extends Test_FileStorage { private $config; - public function setUp(){ + public function setUp() { $id=uniqid(); $this->config=include('apps/files_external/tests/config.php'); $this->config['swift']['root'].='/'.$id;//make sure we have an new empty folder to work in @@ -22,7 +22,7 @@ if(!is_array($config) or !isset($config['swift']) or !$config['swift']['run']){ } - public function tearDown(){ + public function tearDown() { $this->instance->rmdir(''); } diff --git a/apps/files_external/tests/webdav.php b/apps/files_external/tests/webdav.php index 49c44124f3c..74d980aa3f1 100644 --- a/apps/files_external/tests/webdav.php +++ b/apps/files_external/tests/webdav.php @@ -7,21 +7,21 @@ */ $config=include('apps/files_external/tests/config.php'); -if(!is_array($config) or !isset($config['webdav']) or !$config['webdav']['run']){ +if(!is_array($config) or !isset($config['webdav']) or !$config['webdav']['run']) { abstract class Test_Filestorage_DAV extends Test_FileStorage{} return; }else{ class Test_Filestorage_DAV extends Test_FileStorage { private $config; - public function setUp(){ + public function setUp() { $id=uniqid(); $this->config=include('apps/files_external/tests/config.php'); $this->config['webdav']['root'].='/'.$id;//make sure we have an new empty folder to work in $this->instance=new OC_Filestorage_DAV($this->config['webdav']); } - public function tearDown(){ + public function tearDown() { $this->instance->rmdir('/'); } } diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 4530ce87777..6dba76955a0 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -443,7 +443,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { * @param int $time * @return bool */ - public function hasUpdated($path,$time){ + public function hasUpdated($path,$time) { //TODO return false; } diff --git a/apps/files_versions/ajax/expireAll.php b/apps/files_versions/ajax/expireAll.php index f76da3da986..5c95885ffbd 100644 --- a/apps/files_versions/ajax/expireAll.php +++ b/apps/files_versions/ajax/expireAll.php @@ -31,7 +31,7 @@ OCP\JSON::callCheck(); $versions = new OCA_Versions\Storage(); -if( $versions->expireAll() ){ +if( $versions->expireAll() ) { OCP\JSON::success(); die(); diff --git a/apps/files_versions/ajax/rollbackVersion.php b/apps/files_versions/ajax/rollbackVersion.php index 24d71a914a4..f1b02eb4b92 100644 --- a/apps/files_versions/ajax/rollbackVersion.php +++ b/apps/files_versions/ajax/rollbackVersion.php @@ -9,7 +9,7 @@ $file = $_GET['file']; $revision=(int)$_GET['revision']; if( OCA_Versions\Storage::isversioned( $file ) ) { - if(OCA_Versions\Storage::rollback( $file, $revision )){ + if(OCA_Versions\Storage::rollback( $file, $revision )) { OCP\JSON::success(array("data" => array( "revision" => $revision, "file" => $file ))); }else{ OCP\JSON::error(array("data" => array( "message" => "Could not revert:" . $file ))); diff --git a/apps/files_versions/lib/hooks.php b/apps/files_versions/lib/hooks.php index 330f10afb59..9ec0b01a7f9 100644 --- a/apps/files_versions/lib/hooks.php +++ b/apps/files_versions/lib/hooks.php @@ -44,7 +44,7 @@ class Hooks { $abs_path = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('').$rel_path.'.v'; if(Storage::isversioned($rel_path)) { $versions = Storage::getVersions($rel_path); - foreach ($versions as $v){ + foreach ($versions as $v) { unlink($abs_path . $v['version']); } } @@ -66,7 +66,7 @@ class Hooks { $info=pathinfo($abs_newpath); if(!file_exists($info['dirname'])) mkdir($info['dirname'],0700,true); $versions = Storage::getVersions($rel_oldpath); - foreach ($versions as $v){ + foreach ($versions as $v) { rename($abs_oldpath.$v['version'], $abs_newpath.$v['version']); } } diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 4ea1a07b942..dedd83fc25a 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -82,7 +82,7 @@ class Storage { } // check if filename is a directory - if($files_view->is_dir($filename)){ + if($files_view->is_dir($filename)) { return false; } @@ -97,7 +97,7 @@ class Storage { } // check filesize - if($files_view->filesize($filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)){ + if($files_view->filesize($filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)) { return false; } @@ -107,7 +107,7 @@ class Storage { $matches=glob($versionsFolderName.'/'.$filename.'.v*'); sort($matches); $parts=explode('.v',end($matches)); - if((end($parts)+Storage::DEFAULTMININTERVAL)>time()){ + if((end($parts)+Storage::DEFAULTMININTERVAL)>time()) { return false; } } @@ -175,7 +175,7 @@ class Storage { // check for old versions $matches=glob($versionsFolderName.$filename.'.v*'); - if(count($matches)>0){ + if(count($matches)>0) { return true; }else{ return false; diff --git a/apps/user_ldap/appinfo/install.php b/apps/user_ldap/appinfo/install.php index 9efc3bb24d2..378957ec409 100644 --- a/apps/user_ldap/appinfo/install.php +++ b/apps/user_ldap/appinfo/install.php @@ -1,6 +1,6 @@ <?php $state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'doSet'); -if($state == 'doSet'){ +if($state == 'doSet') { OCP\Config::setSystemValue('ldapIgnoreNamingRules', false); } diff --git a/apps/user_ldap/appinfo/update.php b/apps/user_ldap/appinfo/update.php index da36211b665..f23285a0dc6 100644 --- a/apps/user_ldap/appinfo/update.php +++ b/apps/user_ldap/appinfo/update.php @@ -18,7 +18,7 @@ if(!is_null($pw)) { //detect if we can switch on naming guidelines. We won't do it on conflicts. //it's a bit spaghetti, but hey. $state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'unset'); -if($state == 'unset'){ +if($state == 'unset') { OCP\Config::setSystemValue('ldapIgnoreNamingRules', false); } diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index aac3ed78917..5ec259f6c47 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -231,7 +231,7 @@ class GROUP_LDAP extends lib\Access implements \OCP\GroupInterface { * @param string $gid * @return bool */ - public function groupExists($gid){ + public function groupExists($gid) { if($this->connection->isCached('groupExists'.$gid)) { return $this->connection->getFromCache('groupExists'.$gid); } diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php index 23018890eac..f765151456a 100644 --- a/apps/user_ldap/settings.php +++ b/apps/user_ldap/settings.php @@ -26,8 +26,8 @@ OCP\Util::addscript('user_ldap', 'settings'); OCP\Util::addstyle('user_ldap', 'settings'); if ($_POST) { - foreach($params as $param){ - if(isset($_POST[$param])){ + foreach($params as $param) { + if(isset($_POST[$param])) { if('ldap_agent_password' == $param) { OCP\Config::setAppValue('user_ldap', $param, base64_encode($_POST[$param])); } elseif('ldap_cache_ttl' == $param) { @@ -58,7 +58,7 @@ if ($_POST) { // fill template $tmpl = new OCP\Template( 'user_ldap', 'settings'); -foreach($params as $param){ +foreach($params as $param) { $value = OCP\Config::getAppValue('user_ldap', $param,''); $tmpl->assign($param, $value); } diff --git a/apps/user_ldap/tests/group_ldap.php b/apps/user_ldap/tests/group_ldap.php index ac66a608b76..b953127d86e 100644 --- a/apps/user_ldap/tests/group_ldap.php +++ b/apps/user_ldap/tests/group_ldap.php @@ -21,11 +21,11 @@ */ class Test_Group_Ldap extends UnitTestCase { - function setUp(){ + function setUp() { OC_Group::clearBackends(); } - function testSingleBackend(){ + function testSingleBackend() { OC_Group::useBackend(new OCA\user_ldap\GROUP_LDAP()); $group_ldap = new OCA\user_ldap\GROUP_LDAP(); diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index d297374600a..bacdb8b9ae1 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -65,7 +65,7 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface { * * Check if the password is correct without logging in the user */ - public function checkPassword($uid, $password){ + public function checkPassword($uid, $password) { //find out dn of the user name $filter = \OCP\Util::mb_str_replace('%uid', $uid, $this->connection->ldapLoginFilter, 'UTF-8'); $ldap_users = $this->fetchListOfUsers($filter, 'dn'); @@ -82,7 +82,7 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface { //do we have a username for him/her? $ocname = $this->dn2username($dn); - if($ocname){ + if($ocname) { //update some settings, if necessary $this->updateQuota($dn); $this->updateEmail($dn); @@ -100,7 +100,7 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface { * * Get a list of all users. */ - public function getUsers($search = '', $limit = 10, $offset = 0){ + public function getUsers($search = '', $limit = 10, $offset = 0) { $ldap_users = $this->connection->getFromCache('getUsers'); if(is_null($ldap_users)) { $ldap_users = $this->fetchListOfUsers($this->connection->ldapUserFilter, array($this->connection->ldapUserDisplayName, 'dn')); @@ -126,7 +126,7 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface { * @param string $uid the username * @return boolean */ - public function userExists($uid){ + public function userExists($uid) { if($this->connection->isCached('userExists'.$uid)) { return $this->connection->getFromCache('userExists'.$uid); } @@ -187,7 +187,7 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface { * @param string $uid the username * @return boolean */ - public function getHome($uid){ + public function getHome($uid) { if($this->userExists($uid)) { $homedir = \OCP\Config::getUserValue($uid, 'user_ldap', 'homedir', false); if(!$homedir) { diff --git a/apps/user_webdavauth/settings.php b/apps/user_webdavauth/settings.php index 1b80b1bba34..4f1ddbbefda 100755 --- a/apps/user_webdavauth/settings.php +++ b/apps/user_webdavauth/settings.php @@ -22,9 +22,9 @@ */ print_r($_POST); -if($_POST){ +if($_POST) { - if(isset($_POST['webdav_url'])){ + if(isset($_POST['webdav_url'])) { OC_CONFIG::setValue('user_webdavauth_url', strip_tags($_POST['webdav_url'])); } } diff --git a/apps/user_webdavauth/user_webdavauth.php b/apps/user_webdavauth/user_webdavauth.php index 571aca2f70f..c36d37c1fa2 100755 --- a/apps/user_webdavauth/user_webdavauth.php +++ b/apps/user_webdavauth/user_webdavauth.php @@ -50,7 +50,7 @@ class OC_USER_WEBDAVAUTH extends OC_User_Backend { $url= 'http://'.urlencode($uid).':'.urlencode($password).'@'.$this->webdavauth_url; $headers = get_headers($url); - if($headers==false){ + if($headers==false) { OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to connect to WebDAV Url: "'.$this->webdavauth_url.'" ' ,3); return false; @@ -68,14 +68,14 @@ class OC_USER_WEBDAVAUTH extends OC_User_Backend { /* * we don´t know if a user exists without the password. so we have to return false all the time */ - public function userExists( $uid ){ + public function userExists( $uid ) { return false; } /* * we don´t know the users so all we can do it return an empty array here */ - public function getUsers(){ + public function getUsers() { $returnArray = array(); return $returnArray; diff --git a/core/ajax/appconfig.php b/core/ajax/appconfig.php index 3ad9e2326c3..1b43afa74fb 100644 --- a/core/ajax/appconfig.php +++ b/core/ajax/appconfig.php @@ -11,7 +11,7 @@ OCP\JSON::callCheck(); $action=isset($_POST['action'])?$_POST['action']:$_GET['action']; $result=false; -switch($action){ +switch($action) { case 'getValue': $result=OC_Appconfig::getValue($_GET['app'], $_GET['key'], $_GET['defaultValue']); break; diff --git a/core/minimizer.php b/core/minimizer.php index 0abbca75027..4da9037c413 100644 --- a/core/minimizer.php +++ b/core/minimizer.php @@ -3,12 +3,12 @@ session_write_close(); OC_App::loadApps(); -if ($service == 'core.css'){ +if ($service == 'core.css') { $minimizer = new OC_Minimizer_CSS(); $files = OC_TemplateLayout::findStylesheetFiles(OC_Util::$core_styles); $minimizer->output($files, $service); } -else if ($service == 'core.js'){ +else if ($service == 'core.js') { $minimizer = new OC_Minimizer_JS(); $files = OC_TemplateLayout::findJavascriptFiles(OC_Util::$core_scripts); $minimizer->output($files, $service); diff --git a/core/templates/403.php b/core/templates/403.php index cdfef08ac76..fbf0e64fdb6 100644 --- a/core/templates/403.php +++ b/core/templates/403.php @@ -1,5 +1,5 @@ <?php -if(!isset($_)){//also provide standalone error page +if(!isset($_)) {//also provide standalone error page require_once '../../lib/base.php'; $tmpl = new OC_Template( '', '403', 'guest' ); diff --git a/core/templates/404.php b/core/templates/404.php index 13a81010343..c111fd70fa9 100644 --- a/core/templates/404.php +++ b/core/templates/404.php @@ -1,5 +1,5 @@ <?php -if(!isset($_)){//also provide standalone error page +if(!isset($_)) {//also provide standalone error page require_once '../../lib/base.php'; $tmpl = new OC_Template( '', '404', 'guest' ); diff --git a/core/templates/exception.php b/core/templates/exception.php index 7f58ce252cf..4b951fca51b 100644 --- a/core/templates/exception.php +++ b/core/templates/exception.php @@ -4,7 +4,7 @@ <summary class="error">We're sorry, but something went terribly wrong.<br></summary> <p class="exception"> <?php - if($_['showsysinfo'] == true){ + if($_['showsysinfo'] == true) { echo 'If you would like to support ownCloud\'s developers and report this error in our <a href="http://bugs.owncloud.org">Bugtracker</a>, please copy the following informations into the description. <br><br><textarea readonly>'; echo 'Message: ' . $_['message'] . "\n"; echo 'Error Code: ' . $_['code'] . "\n"; diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 4cdbfd16e52..9a5a056eb2b 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -24,7 +24,7 @@ <?php foreach($_['headers'] as $header): ?> <?php echo '<'.$header['tag'].' '; - foreach($header['attributes'] as $name=>$value){ + foreach($header['attributes'] as $name=>$value) { echo "$name='$value' "; }; echo '/>'; diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index a2560b755fa..89b8027fc0f 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -24,7 +24,7 @@ <?php foreach($_['headers'] as $header): ?> <?php echo '<'.$header['tag'].' '; - foreach($header['attributes'] as $name=>$value){ + foreach($header['attributes'] as $name=>$value) { echo "$name='$value' "; }; echo '/>'; @@ -33,7 +33,7 @@ <script type="text/javascript"> requesttoken = '<?php echo $_['requesttoken']; ?>'; OC.EventSource.requesttoken=requesttoken; - $(document).bind('ajaxSend', function(elm, xhr, s){ + $(document).bind('ajaxSend', function(elm, xhr, s) { xhr.setRequestHeader('requesttoken', requesttoken); }); </script> @@ -44,7 +44,7 @@ <a href="<?php echo link_to('', 'index.php'); ?>" title="" id="owncloud"><img class="svg" src="<?php echo image_path('', 'logo-wide.svg'); ?>" alt="ownCloud" /></a> <a class="header-right header-action" id="logout" href="<?php echo link_to('', 'index.php'); ?>?logout=true"><img class="svg" alt="<?php echo $l->t('Log out');?>" title="<?php echo $l->t('Log out');?>" src="<?php echo image_path('', 'actions/logout.svg'); ?>" /></a> <form class="searchbox header-right" action="#" method="post"> - <input id="searchbox" class="svg" type="search" name="query" value="<?php if(isset($_POST['query'])){echo OC_Util::sanitizeHTML($_POST['query']);};?>" autocomplete="off" x-webkit-speech /> + <input id="searchbox" class="svg" type="search" name="query" value="<?php if(isset($_POST['query'])) {echo OC_Util::sanitizeHTML($_POST['query']);};?>" autocomplete="off" x-webkit-speech /> </form> </div></header> @@ -77,7 +77,7 @@ if( OC::$CLI ) { OC_BackgroundJob_Worker::doAllSteps(); } else{ - if( $appmode == 'cron' ){ + if( $appmode == 'cron' ) { OC_JSON::error( array( 'data' => array( 'message' => 'Backgroundjobs are using system cron!'))); } else{ diff --git a/lib/MDB2/Driver/Datatype/sqlite3.php b/lib/MDB2/Driver/Datatype/sqlite3.php index 673706e518c..ca4c1cbceb8 100644 --- a/lib/MDB2/Driver/Datatype/sqlite3.php +++ b/lib/MDB2/Driver/Datatype/sqlite3.php @@ -191,7 +191,7 @@ class MDB2_Driver_Datatype_sqlite3 extends MDB2_Driver_Datatype_Common $notnull = empty($field['notnull']) ? '' : ' NOT NULL'; $unsigned = empty($field['unsigned']) ? '' : ' UNSIGNED'; $name = $db->quoteIdentifier($name, true); - if($autoinc){ + if($autoinc) { return $name.' '.$this->getTypeDeclaration($field).$autoinc; }else{ return $name.' '.$this->getTypeDeclaration($field).$unsigned.$default.$notnull.$autoinc; diff --git a/lib/MDB2/Driver/Manager/sqlite3.php b/lib/MDB2/Driver/Manager/sqlite3.php index 0101f8ee2ab..921153c17dd 100644 --- a/lib/MDB2/Driver/Manager/sqlite3.php +++ b/lib/MDB2/Driver/Manager/sqlite3.php @@ -531,7 +531,7 @@ class MDB2_Driver_Manager_sqlite3 extends MDB2_Driver_Manager_Common return MDB2_OK; } - if (empty($changes['remove']) and empty($changes['rename']) and empty($changes['change']) ){//if only rename or add changes are required, we can use ALTER TABLE + if (empty($changes['remove']) and empty($changes['rename']) and empty($changes['change']) ) {//if only rename or add changes are required, we can use ALTER TABLE $query = ''; if (!empty($changes['name'])) { $change_name = $db->quoteIdentifier($changes['name'], true); diff --git a/lib/MDB2/Driver/sqlite3.php b/lib/MDB2/Driver/sqlite3.php index 6bfccadad9a..9757e4faf94 100644 --- a/lib/MDB2/Driver/sqlite3.php +++ b/lib/MDB2/Driver/sqlite3.php @@ -150,7 +150,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common */ public function escape($text, $escape_wildcards = false) { - if($this->connection){ + if($this->connection) { return $this->connection->escapeString($text); }else{ return str_replace("'","''",$text);//TODO; more @@ -324,7 +324,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common **/ function connect() { - if($this->connection instanceof SQLite3){ + if($this->connection instanceof SQLite3) { return MDB2_OK; } $datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); @@ -351,7 +351,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common } if ($database_file !== ':memory:') { - if(!strpos($database_file,'.db')){ + if(!strpos($database_file,'.db')) { $database_file="$datadir/$database_file.db"; } if (!file_exists($database_file)) { @@ -387,7 +387,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common $php_errormsg = ''; $this->connection = new SQLite3($database_file); - if(is_callable(array($this->connection,'busyTimeout'))){//busy timout is only available in php>=5.3 + if(is_callable(array($this->connection,'busyTimeout'))) {//busy timout is only available in php>=5.3 $this->connection->busyTimeout(100); } $this->_lasterror = $this->connection->lastErrorMsg(); @@ -1055,7 +1055,7 @@ class MDB2_BufferedResult_sqlite3 extends MDB2_Result_sqlite3 function seek($rownum = 0) { $this->result->reset(); - for($i=0;$i<$rownum;$i++){ + for($i=0;$i<$rownum;$i++) { $this->result->fetchArray(); } $this->rownum = $rownum - 1; @@ -1093,7 +1093,7 @@ class MDB2_BufferedResult_sqlite3 extends MDB2_Result_sqlite3 { $rows = 0; $this->result->reset(); - while($this->result->fetchArray()){ + while($this->result->fetchArray()) { $rows++; } $this->result->reset(); @@ -1113,8 +1113,8 @@ class MDB2_Statement_sqlite3 extends MDB2_Statement_Common // }}} // {{{ function bindValue($parameter, &$value, $type = null) - private function getParamType($type){ - switch(strtolower($type)){ + private function getParamType($type) { + switch(strtolower($type)) { case 'text': return SQLITE3_TEXT; case 'boolean': @@ -1139,8 +1139,8 @@ class MDB2_Statement_sqlite3 extends MDB2_Statement_Common * * @access public */ - function bindValue($parameter, $value, $type = null){ - if($type){ + function bindValue($parameter, $value, $type = null) { + if($type) { $type=$this->getParamType($type); $this->statement->bindValue($parameter,$value,$type); }else{ @@ -1162,8 +1162,8 @@ class MDB2_Statement_sqlite3 extends MDB2_Statement_Common * * @access public */ - function bindParam($parameter, &$value, $type = null){ - if($type){ + function bindParam($parameter, &$value, $type = null) { + if($type) { $type=$this->getParamType($type); $this->statement->bindParam($parameter,$value,$type); }else{ @@ -1193,7 +1193,7 @@ class MDB2_Statement_sqlite3 extends MDB2_Statement_Common * a MDB2 error on failure * @access private */ - function _execute($result_class = true, $result_wrap_class = false){ + function _execute($result_class = true, $result_wrap_class = false) { if (is_null($this->statement)) { $result =& parent::_execute($result_class, $result_wrap_class); return $result; @@ -1313,7 +1313,7 @@ class MDB2_Statement_sqlite3 extends MDB2_Statement_Common } $values = (array)$values; if (!empty($values)) { - if(count($this->types)){ + if(count($this->types)) { $types=$this->types; }else{ $types=null; diff --git a/lib/app.php b/lib/app.php index e772704b7d2..f5c328afe7c 100755 --- a/lib/app.php +++ b/lib/app.php @@ -48,12 +48,12 @@ class OC_App{ * * if $types is set, only apps of those types will be loaded */ - public static function loadApps($types=null){ + public static function loadApps($types=null) { // Load the enabled apps here $apps = self::getEnabledApps(); // prevent app.php from printing output ob_start(); - foreach( $apps as $app ){ + foreach( $apps as $app ) { if((is_null($types) or self::isType($app, $types)) && !in_array($app, self::$loadedApps)) { self::loadApp($app); self::$loadedApps[] = $app; @@ -94,12 +94,12 @@ class OC_App{ * @param string $app * @param string/array $types */ - public static function isType($app,$types){ + public static function isType($app,$types) { if(is_string($types)) { $types=array($types); } $appTypes=self::getAppTypes($app); - foreach($types as $type){ + foreach($types as $type) { if(array_search($type, $appTypes)!==false) { return true; } @@ -112,7 +112,7 @@ class OC_App{ * @param string $app * @return array */ - private static function getAppTypes($app){ + private static function getAppTypes($app) { //load the cache if(count(self::$appTypes)==0) { self::$appTypes=OC_Appconfig::getValues(false, 'types'); @@ -128,7 +128,7 @@ class OC_App{ /** * read app types from info.xml and cache them in the database */ - public static function setAppTypes($app){ + public static function setAppTypes($app) { $appData=self::getAppInfo($app); if(isset($appData['types'])) { @@ -143,13 +143,13 @@ class OC_App{ /** * get all enabled apps */ - public static function getEnabledApps(){ + public static function getEnabledApps() { if(!OC_Config::getValue('installed', false)) return array(); $apps=array('files'); $query = OC_DB::prepare( 'SELECT `appid` FROM `*PREFIX*appconfig` WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'' ); $result=$query->execute(); - while($row=$result->fetchRow()){ + while($row=$result->fetchRow()) { if(array_search($row['appid'], $apps)===false) { $apps[]=$row['appid']; } @@ -164,7 +164,7 @@ class OC_App{ * * This function checks whether or not an app is enabled. */ - public static function isEnabled( $app ){ + public static function isEnabled( $app ) { if( 'files'==$app or 'yes' == OC_Appconfig::getValue( $app, 'enabled' )) { return true; } @@ -179,7 +179,7 @@ class OC_App{ * * This function set an app as enabled in appconfig. */ - public static function enable( $app ){ + public static function enable( $app ) { if(!OC_Installer::isInstalled($app)) { // check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string if(!is_numeric($app)) { @@ -215,7 +215,7 @@ class OC_App{ * * This function set an app as disabled in appconfig. */ - public static function disable( $app ){ + public static function disable( $app ) { // check if app is a shiped app or not. if not delete OC_Appconfig::setValue( $app, 'enabled', 'no' ); } @@ -237,7 +237,7 @@ class OC_App{ * - order: integer, that influences the position of your application in * the navigation. Lower values come first. */ - public static function addNavigationEntry( $data ){ + public static function addNavigationEntry( $data ) { $data['active']=false; if(!isset($data['icon'])) { $data['icon']=''; @@ -255,7 +255,7 @@ class OC_App{ * property from all other entries. The templates can use this for * highlighting the current position of the user. */ - public static function setActiveNavigationEntry( $id ){ + public static function setActiveNavigationEntry( $id ) { self::$activeapp = $id; return true; } @@ -267,7 +267,7 @@ class OC_App{ * This function returns the id of the active navigation entry (set by * setActiveNavigationEntry */ - public static function getActiveNavigationEntry(){ + public static function getActiveNavigationEntry() { return self::$activeapp; } @@ -278,7 +278,7 @@ class OC_App{ * This function returns an array containing all settings pages added. The * entries are sorted by the key 'order' ascending. */ - public static function getSettingsNavigation(){ + public static function getSettingsNavigation() { $l=OC_L10N::get('lib'); $settings = array(); @@ -320,8 +320,8 @@ class OC_App{ } /// This is private as well. It simply works, so don't ask for more details - private static function proceedNavigation( $list ){ - foreach( $list as &$naventry ){ + private static function proceedNavigation( $list ) { + foreach( $list as &$naventry ) { $naventry['subnavigation'] = array(); if( $naventry['id'] == self::$activeapp ) { $naventry['active'] = true; @@ -331,7 +331,7 @@ class OC_App{ } } unset( $naventry ); - usort( $list, create_function( '$a, $b', 'if( $a["order"] == $b["order"] ){return 0;}elseif( $a["order"] < $b["order"] ){return -1;}else{return 1;}' )); + usort( $list, create_function( '$a, $b', 'if( $a["order"] == $b["order"] ) {return 0;}elseif( $a["order"] < $b["order"] ) {return -1;}else{return 1;}' )); return $list; } @@ -388,7 +388,7 @@ class OC_App{ /** * get the last version of the app, either from appinfo/version or from appinfo/info.xml */ - public static function getAppVersion($appid){ + public static function getAppVersion($appid) { $file= self::getAppPath($appid).'/appinfo/version'; $version=@file_get_contents($file); if($version) { @@ -405,7 +405,7 @@ class OC_App{ * @param boolean path (optional) * @returns array */ - public static function getAppInfo($appid,$path=false){ + public static function getAppInfo($appid,$path=false) { if($path) { $file=$appid; }else{ @@ -423,18 +423,18 @@ class OC_App{ $data['info']=array(); $data['remote']=array(); $data['public']=array(); - foreach($xml->children() as $child){ + foreach($xml->children() as $child) { if($child->getName()=='remote') { - foreach($child->children() as $remote){ + foreach($child->children() as $remote) { $data['remote'][$remote->getName()]=(string)$remote; } }elseif($child->getName()=='public') { - foreach($child->children() as $public){ + foreach($child->children() as $public) { $data['public'][$public->getName()]=(string)$public; } }elseif($child->getName()=='types') { $data['types']=array(); - foreach($child->children() as $type){ + foreach($child->children() as $type) { $data['types'][]=$type->getName(); } }elseif($child->getName()=='description') { @@ -459,7 +459,7 @@ class OC_App{ * - children: array that is empty if the key 'active' is false or * contains the subentries if the key 'active' is true */ - public static function getNavigation(){ + public static function getNavigation() { $navigation = self::proceedNavigation( self::$navigation ); return $navigation; } @@ -468,7 +468,7 @@ class OC_App{ * get the id of loaded app * @return string */ - public static function getCurrentApp(){ + public static function getCurrentApp() { $script=substr($_SERVER["SCRIPT_NAME"], strlen(OC::$WEBROOT)+1); $topFolder=substr($script, 0, strpos($script, '/')); if($topFolder=='apps') { @@ -483,9 +483,9 @@ class OC_App{ /** * get the forms for either settings, admin or personal */ - public static function getForms($type){ + public static function getForms($type) { $forms=array(); - switch($type){ + switch($type) { case 'settings': $source=self::$settingsForms; break; @@ -496,7 +496,7 @@ class OC_App{ $source=self::$personalForms; break; } - foreach($source as $form){ + foreach($source as $form) { $forms[]=include $form; } return $forms; @@ -505,32 +505,32 @@ class OC_App{ /** * register a settings form to be shown */ - public static function registerSettings($app,$page){ + public static function registerSettings($app,$page) { self::$settingsForms[]= $app.'/'.$page.'.php'; } /** * register an admin form to be shown */ - public static function registerAdmin($app,$page){ + public static function registerAdmin($app,$page) { self::$adminForms[]= $app.'/'.$page.'.php'; } /** * register a personal form to be shown */ - public static function registerPersonal($app,$page){ + public static function registerPersonal($app,$page) { self::$personalForms[]= $app.'/'.$page.'.php'; } /** * get a list of all apps in the apps folder */ - public static function getAllApps(){ + public static function getAllApps() { $apps=array(); foreach(OC::$APPSROOTS as $apps_dir) { $dh=opendir($apps_dir['path']); - while($file=readdir($dh)){ + while($file=readdir($dh)) { if($file[0]!='.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')) { $apps[]=$file; } @@ -565,7 +565,7 @@ class OC_App{ * This is important if you upgrade ownCloud and have non ported 3rd * party apps installed. */ - public static function checkAppsRequirements($apps = array()){ + public static function checkAppsRequirements($apps = array()) { if (empty($apps)) { $apps = OC_App::getEnabledApps(); } @@ -583,7 +583,7 @@ class OC_App{ /** * get the installed version of all apps */ - public static function getAppVersions(){ + public static function getAppVersions() { static $versions; if (isset($versions)) { // simple cache, needs to be fixed return $versions; // when function is used besides in checkUpgrade @@ -591,7 +591,7 @@ class OC_App{ $versions=array(); $query = OC_DB::prepare( 'SELECT `appid`, `configvalue` FROM `*PREFIX*appconfig` WHERE `configkey` = \'installed_version\'' ); $result = $query->execute(); - while($row = $result->fetchRow()){ + while($row = $result->fetchRow()) { $versions[$row['appid']]=$row['configvalue']; } return $versions; @@ -601,7 +601,7 @@ class OC_App{ * update the database for the app and call the update script * @param string appid */ - public static function updateApp($appid){ + public static function updateApp($appid) { if(file_exists(self::getAppPath($appid).'/appinfo/database.xml')) { OC_DB::updateDbFromStructure(self::getAppPath($appid).'/appinfo/database.xml'); } @@ -615,10 +615,10 @@ class OC_App{ //set remote/public handelers $appData=self::getAppInfo($appid); - foreach($appData['remote'] as $name=>$path){ + foreach($appData['remote'] as $name=>$path) { OCP\CONFIG::setAppValue('core', 'remote_'.$name, $appid.'/'.$path); } - foreach($appData['public'] as $name=>$path){ + foreach($appData['public'] as $name=>$path) { OCP\CONFIG::setAppValue('core', 'public_'.$name, $appid.'/'.$path); } @@ -629,7 +629,7 @@ class OC_App{ * @param string appid * @return OC_FilesystemView */ - public static function getStorage($appid){ + public static function getStorage($appid) { if(OC_App::isEnabled($appid)) {//sanity check if(OC_User::isLoggedIn()) { $view = new OC_FilesystemView('/'.OC_User::getUser()); diff --git a/lib/appconfig.php b/lib/appconfig.php index 0e608b540bd..7f58b878504 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -45,13 +45,13 @@ class OC_Appconfig{ * This function returns a list of all apps that have at least one * entry in the appconfig table. */ - public static function getApps(){ + public static function getApps() { // No magic in here! $query = OC_DB::prepare( 'SELECT DISTINCT `appid` FROM `*PREFIX*appconfig`' ); $result = $query->execute(); $apps = array(); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $apps[] = $row["appid"]; } @@ -66,13 +66,13 @@ class OC_Appconfig{ * This function gets all keys of an app. Please note that the values are * not returned. */ - public static function getKeys( $app ){ + public static function getKeys( $app ) { // No magic in here as well $query = OC_DB::prepare( 'SELECT `configkey` FROM `*PREFIX*appconfig` WHERE `appid` = ?' ); $result = $query->execute( array( $app )); $keys = array(); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $keys[] = $row["configkey"]; } @@ -89,12 +89,12 @@ class OC_Appconfig{ * This function gets a value from the appconfig table. If the key does * not exist the default value will be returnes */ - public static function getValue( $app, $key, $default = null ){ + public static function getValue( $app, $key, $default = null ) { // At least some magic in here :-) $query = OC_DB::prepare( 'SELECT `configvalue` FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?' ); $result = $query->execute( array( $app, $key )); $row = $result->fetchRow(); - if($row){ + if($row) { return $row["configvalue"]; }else{ return $default; @@ -107,7 +107,7 @@ class OC_Appconfig{ * @param string $key * @return bool */ - public static function hasKey($app,$key){ + public static function hasKey($app,$key) { $exists = self::getKeys( $app ); return in_array( $key, $exists ); } @@ -121,9 +121,9 @@ class OC_Appconfig{ * * Sets a value. If the key did not exist before it will be created. */ - public static function setValue( $app, $key, $value ){ + 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 )); } @@ -141,7 +141,7 @@ class OC_Appconfig{ * * Deletes a key. */ - public static function deleteKey( $app, $key ){ + public static function deleteKey( $app, $key ) { // Boring! $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?' ); $query->execute( array( $app, $key )); @@ -156,7 +156,7 @@ class OC_Appconfig{ * * Removes all keys in appconfig belonging to the app. */ - public static function deleteApp( $app ){ + public static function deleteApp( $app ) { // Nothing special $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*appconfig` WHERE `appid` = ?' ); $query->execute( array( $app )); @@ -170,14 +170,14 @@ class OC_Appconfig{ * @param key * @return array */ - public static function getValues($app,$key){ - if($app!==false and $key!==false){ + public static function getValues($app,$key) { + if($app!==false and $key!==false) { return false; } $fields='`configvalue`'; $where='WHERE'; $params=array(); - if($app!==false){ + if($app!==false) { $fields.=', `configkey`'; $where.=' `appid` = ?'; $params[]=$app; @@ -192,7 +192,7 @@ class OC_Appconfig{ $query=OC_DB::prepare($queryString); $result=$query->execute($params); $values=array(); - while($row=$result->fetchRow()){ + while($row=$result->fetchRow()) { $values[$row[$key]]=$row['configvalue']; } return $values; diff --git a/lib/archive.php b/lib/archive.php index 5ac4edbfd1e..b4459c2b6ce 100644 --- a/lib/archive.php +++ b/lib/archive.php @@ -12,15 +12,15 @@ abstract class OC_Archive{ * @param string path * @return OC_Archive */ - public static function open($path){ + public static function open($path) { $ext=substr($path,strrpos($path,'.')); - switch($ext){ + switch($ext) { case '.zip': return new OC_Archive_ZIP($path); case '.gz': case '.bz': case '.bz2': - if(strpos($path,'.tar.')){ + if(strpos($path,'.tar.')) { return new OC_Archive_TAR($path); } break; @@ -118,14 +118,14 @@ abstract class OC_Archive{ * @param string source * @return bool */ - function addRecursive($path,$source){ - if($dh=opendir($source)){ + function addRecursive($path,$source) { + if($dh=opendir($source)) { $this->addFolder($path); - while($file=readdir($dh)){ - if($file=='.' or $file=='..'){ + while($file=readdir($dh)) { + if($file=='.' or $file=='..') { continue; } - if(is_dir($source.'/'.$file)){ + if(is_dir($source.'/'.$file)) { $this->addRecursive($path.'/'.$file,$source.'/'.$file); }else{ $this->addFile($path.'/'.$file,$source.'/'.$file); diff --git a/lib/archive/tar.php b/lib/archive/tar.php index 095362d0cd6..ebd581fc162 100644 --- a/lib/archive/tar.php +++ b/lib/archive/tar.php @@ -21,7 +21,7 @@ class OC_Archive_TAR extends OC_Archive{ private $tar=null; private $path; - function __construct($source){ + function __construct($source) { $types=array(null,'gz','bz'); $this->path=$source; $this->tar=new Archive_Tar($source,$types[self::getTarType($source)]); @@ -32,10 +32,10 @@ class OC_Archive_TAR extends OC_Archive{ * @param string file * @return str */ - static public function getTarType($file){ - if(strpos($file,'.')){ + static public function getTarType($file) { + if(strpos($file,'.')) { $extension=substr($file,strrpos($file,'.')); - switch($extension){ + switch($extension) { case 'gz': case 'tgz': return self::GZIP; @@ -55,19 +55,19 @@ class OC_Archive_TAR extends OC_Archive{ * @param string path * @return bool */ - function addFolder($path){ + function addFolder($path) { $tmpBase=OC_Helper::tmpFolder(); - if(substr($path,-1,1)!='/'){ + if(substr($path,-1,1)!='/') { $path.='/'; } - if($this->fileExists($path)){ + if($this->fileExists($path)) { return false; } $parts=explode('/',$path); $folder=$tmpBase; - foreach($parts as $part){ + foreach($parts as $part) { $folder.='/'.$part; - if(!is_dir($folder)){ + if(!is_dir($folder)) { mkdir($folder); } } @@ -82,11 +82,11 @@ class OC_Archive_TAR extends OC_Archive{ * @param string source either a local file or string data * @return bool */ - function addFile($path,$source=''){ - if($this->fileExists($path)){ + function addFile($path,$source='') { + if($this->fileExists($path)) { $this->remove($path); } - if($source and $source[0]=='/' and file_exists($source)){ + if($source and $source[0]=='/' and file_exists($source)) { $header=array(); $dummy=''; $this->tar->_openAppend(); @@ -104,7 +104,7 @@ class OC_Archive_TAR extends OC_Archive{ * @param string dest * @return bool */ - function rename($source,$dest){ + function rename($source,$dest) { //no proper way to delete, rename entire archive, rename file and remake archive $tmp=OCP\Files::tmpFolder(); $this->tar->extract($tmp); @@ -118,10 +118,10 @@ class OC_Archive_TAR extends OC_Archive{ return true; } - private function getHeader($file){ + private function getHeader($file) { $headers=$this->tar->listContent(); - foreach($headers as $header){ - if($file==$header['filename'] or $file.'/'==$header['filename'] or '/'.$file.'/'==$header['filename'] or '/'.$file==$header['filename']){ + foreach($headers as $header) { + if($file==$header['filename'] or $file.'/'==$header['filename'] or '/'.$file.'/'==$header['filename'] or '/'.$file==$header['filename']) { return $header; } } @@ -133,7 +133,7 @@ class OC_Archive_TAR extends OC_Archive{ * @param string path * @return int */ - function filesize($path){ + function filesize($path) { $stat=$this->getHeader($path); return $stat['size']; } @@ -142,7 +142,7 @@ class OC_Archive_TAR extends OC_Archive{ * @param string path * @return int */ - function mtime($path){ + function mtime($path) { $stat=$this->getHeader($path); return $stat['mtime']; } @@ -152,20 +152,20 @@ class OC_Archive_TAR extends OC_Archive{ * @param path * @return array */ - function getFolder($path){ + function getFolder($path) { $files=$this->getFiles(); $folderContent=array(); $pathLength=strlen($path); - foreach($files as $file){ - if($file[0]=='/'){ + foreach($files as $file) { + if($file[0]=='/') { $file=substr($file,1); } - if(substr($file,0,$pathLength)==$path and $file!=$path){ + if(substr($file,0,$pathLength)==$path and $file!=$path) { $result=substr($file,$pathLength); - if($pos=strpos($result,'/')){ + if($pos=strpos($result,'/')) { $result=substr($result,0,$pos+1); } - if(array_search($result,$folderContent)===false){ + if(array_search($result,$folderContent)===false) { $folderContent[]=$result; } } @@ -176,13 +176,13 @@ class OC_Archive_TAR extends OC_Archive{ *get all files in the archive * @return array */ - function getFiles(){ - if($this->fileList){ + function getFiles() { + if($this->fileList) { return $this->fileList; } $headers=$this->tar->listContent(); $files=array(); - foreach($headers as $header){ + foreach($headers as $header) { $files[]=$header['filename']; } $this->fileList=$files; @@ -193,7 +193,7 @@ class OC_Archive_TAR extends OC_Archive{ * @param string path * @return string */ - function getFile($path){ + function getFile($path) { return $this->tar->extractInString($path); } /** @@ -202,17 +202,17 @@ class OC_Archive_TAR extends OC_Archive{ * @param string dest * @return bool */ - function extractFile($path,$dest){ + function extractFile($path,$dest) { $tmp=OCP\Files::tmpFolder(); - if(!$this->fileExists($path)){ + if(!$this->fileExists($path)) { return false; } - if($this->fileExists('/'.$path)){ + if($this->fileExists('/'.$path)) { $success=$this->tar->extractList(array('/'.$path),$tmp); }else{ $success=$this->tar->extractList(array($path),$tmp); } - if($success){ + if($success) { rename($tmp.$path,$dest); } OCP\Files::rmdirr($tmp); @@ -224,7 +224,7 @@ class OC_Archive_TAR extends OC_Archive{ * @param string dest * @return bool */ - function extract($dest){ + function extract($dest) { return $this->tar->extract($dest); } /** @@ -232,23 +232,23 @@ class OC_Archive_TAR extends OC_Archive{ * @param string path * @return bool */ - function fileExists($path){ + function fileExists($path) { $files=$this->getFiles(); - if((array_search($path,$files)!==false) or (array_search($path.'/',$files)!==false)){ + if((array_search($path,$files)!==false) or (array_search($path.'/',$files)!==false)) { return true; }else{ $folderPath=$path; - if(substr($folderPath,-1,1)!='/'){ + if(substr($folderPath,-1,1)!='/') { $folderPath.='/'; } $pathLength=strlen($folderPath); - foreach($files as $file){ - if(strlen($file)>$pathLength and substr($file,0,$pathLength)==$folderPath){ + foreach($files as $file) { + if(strlen($file)>$pathLength and substr($file,0,$pathLength)==$folderPath) { return true; } } } - if($path[0]!='/'){//not all programs agree on the use of a leading / + if($path[0]!='/') {//not all programs agree on the use of a leading / return $this->fileExists('/'.$path); }else{ return false; @@ -260,8 +260,8 @@ class OC_Archive_TAR extends OC_Archive{ * @param string path * @return bool */ - function remove($path){ - if(!$this->fileExists($path)){ + function remove($path) { + if(!$this->fileExists($path)) { return false; } $this->fileList=false; @@ -281,19 +281,19 @@ class OC_Archive_TAR extends OC_Archive{ * @param string mode * @return resource */ - function getStream($path,$mode){ - if(strrpos($path,'.')!==false){ + function getStream($path,$mode) { + if(strrpos($path,'.')!==false) { $ext=substr($path,strrpos($path,'.')); }else{ $ext=''; } $tmpFile=OCP\Files::tmpFile($ext); - if($this->fileExists($path)){ + if($this->fileExists($path)) { $this->extractFile($path,$tmpFile); - }elseif($mode=='r' or $mode=='rb'){ + }elseif($mode=='r' or $mode=='rb') { return false; } - if($mode=='r' or $mode=='rb'){ + if($mode=='r' or $mode=='rb') { return fopen($tmpFile,$mode); }else{ OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); @@ -306,8 +306,8 @@ class OC_Archive_TAR extends OC_Archive{ /** * write back temporary files */ - function writeBack($tmpFile){ - if(isset(self::$tempFiles[$tmpFile])){ + function writeBack($tmpFile) { + if(isset(self::$tempFiles[$tmpFile])) { $this->addFile(self::$tempFiles[$tmpFile],$tmpFile); unlink($tmpFile); } @@ -316,8 +316,8 @@ class OC_Archive_TAR extends OC_Archive{ /** * reopen the archive to ensure everything is written */ - private function reopen(){ - if($this->tar){ + private function reopen() { + if($this->tar) { $this->tar->_close(); $this->tar=null; } diff --git a/lib/archive/zip.php b/lib/archive/zip.php index 396b1f6c054..45992ee3d89 100644 --- a/lib/archive/zip.php +++ b/lib/archive/zip.php @@ -13,10 +13,10 @@ class OC_Archive_ZIP extends OC_Archive{ private $zip=null; private $path; - function __construct($source){ + function __construct($source) { $this->path=$source; $this->zip=new ZipArchive(); - if($this->zip->open($source,ZipArchive::CREATE)){ + if($this->zip->open($source,ZipArchive::CREATE)) { }else{ OCP\Util::writeLog('files_archive','Error while opening archive '.$source,OCP\Util::WARN); } @@ -26,7 +26,7 @@ class OC_Archive_ZIP extends OC_Archive{ * @param string path * @return bool */ - function addFolder($path){ + function addFolder($path) { return $this->zip->addEmptyDir($path); } /** @@ -35,13 +35,13 @@ class OC_Archive_ZIP extends OC_Archive{ * @param string source either a local file or string data * @return bool */ - function addFile($path,$source=''){ - if($source and $source[0]=='/' and file_exists($source)){ + function addFile($path,$source='') { + if($source and $source[0]=='/' and file_exists($source)) { $result=$this->zip->addFile($source,$path); }else{ $result=$this->zip->addFromString($path,$source); } - if($result){ + if($result) { $this->zip->close();//close and reopen to save the zip $this->zip->open($this->path); } @@ -53,7 +53,7 @@ class OC_Archive_ZIP extends OC_Archive{ * @param string dest * @return bool */ - function rename($source,$dest){ + function rename($source,$dest) { $source=$this->stripPath($source); $dest=$this->stripPath($dest); $this->zip->renameName($source,$dest); @@ -63,7 +63,7 @@ class OC_Archive_ZIP extends OC_Archive{ * @param string path * @return int */ - function filesize($path){ + function filesize($path) { $stat=$this->zip->statName($path); return $stat['size']; } @@ -72,7 +72,7 @@ class OC_Archive_ZIP extends OC_Archive{ * @param string path * @return int */ - function mtime($path){ + function mtime($path) { return filemtime($this->path); } /** @@ -80,13 +80,13 @@ class OC_Archive_ZIP extends OC_Archive{ * @param path * @return array */ - function getFolder($path){ + function getFolder($path) { $files=$this->getFiles(); $folderContent=array(); $pathLength=strlen($path); - foreach($files as $file){ - if(substr($file,0,$pathLength)==$path and $file!=$path){ - if(strrpos(substr($file,0,-1),'/')<=$pathLength){ + foreach($files as $file) { + if(substr($file,0,$pathLength)==$path and $file!=$path) { + if(strrpos(substr($file,0,-1),'/')<=$pathLength) { $folderContent[]=substr($file,$pathLength); } } @@ -97,10 +97,10 @@ class OC_Archive_ZIP extends OC_Archive{ *get all files in the archive * @return array */ - function getFiles(){ + function getFiles() { $fileCount=$this->zip->numFiles; $files=array(); - for($i=0;$i<$fileCount;$i++){ + for($i=0;$i<$fileCount;$i++) { $files[]=$this->zip->getNameIndex($i); } return $files; @@ -110,7 +110,7 @@ class OC_Archive_ZIP extends OC_Archive{ * @param string path * @return string */ - function getFile($path){ + function getFile($path) { return $this->zip->getFromName($path); } /** @@ -119,7 +119,7 @@ class OC_Archive_ZIP extends OC_Archive{ * @param string dest * @return bool */ - function extractFile($path,$dest){ + function extractFile($path,$dest) { $fp = $this->zip->getStream($path); file_put_contents($dest,$fp); } @@ -129,7 +129,7 @@ class OC_Archive_ZIP extends OC_Archive{ * @param string dest * @return bool */ - function extract($dest){ + function extract($dest) { return $this->zip->extractTo($dest); } /** @@ -137,7 +137,7 @@ class OC_Archive_ZIP extends OC_Archive{ * @param string path * @return bool */ - function fileExists($path){ + function fileExists($path) { return ($this->zip->locateName($path)!==false) or ($this->zip->locateName($path.'/')!==false); } /** @@ -145,8 +145,8 @@ class OC_Archive_ZIP extends OC_Archive{ * @param string path * @return bool */ - function remove($path){ - if($this->fileExists($path.'/')){ + function remove($path) { + if($this->fileExists($path.'/')) { return $this->zip->deleteName($path.'/'); }else{ return $this->zip->deleteName($path); @@ -158,18 +158,18 @@ class OC_Archive_ZIP extends OC_Archive{ * @param string mode * @return resource */ - function getStream($path,$mode){ - if($mode=='r' or $mode=='rb'){ + function getStream($path,$mode) { + if($mode=='r' or $mode=='rb') { return $this->zip->getStream($path); }else{//since we cant directly get a writable stream, make a temp copy of the file and put it back in the archive when the stream is closed - if(strrpos($path,'.')!==false){ + if(strrpos($path,'.')!==false) { $ext=substr($path,strrpos($path,'.')); }else{ $ext=''; } $tmpFile=OCP\Files::tmpFile($ext); OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); - if($this->fileExists($path)){ + if($this->fileExists($path)) { $this->extractFile($path,$tmpFile); } self::$tempFiles[$tmpFile]=$path; @@ -181,15 +181,15 @@ class OC_Archive_ZIP extends OC_Archive{ /** * write back temporary files */ - function writeBack($tmpFile){ - if(isset(self::$tempFiles[$tmpFile])){ + function writeBack($tmpFile) { + if(isset(self::$tempFiles[$tmpFile])) { $this->addFile(self::$tempFiles[$tmpFile],$tmpFile); unlink($tmpFile); } } - private function stripPath($path){ - if(!$path || $path[0]=='/'){ + private function stripPath($path) { + if(!$path || $path[0]=='/') { return substr($path,1); }else{ return $path; diff --git a/lib/backgroundjob/queuedtask.php b/lib/backgroundjob/queuedtask.php index a7ec3efbf33..8264e1a0ae6 100644 --- a/lib/backgroundjob/queuedtask.php +++ b/lib/backgroundjob/queuedtask.php @@ -29,7 +29,7 @@ class OC_BackgroundJob_QueuedTask{ * @param $id ID of the task * @return associative array */ - public static function find( $id ){ + public static function find( $id ) { $stmt = OC_DB::prepare( 'SELECT * FROM `*PREFIX*queuedtasks` WHERE `id` = ?' ); $result = $stmt->execute(array($id)); return $result->fetchRow(); @@ -39,14 +39,14 @@ class OC_BackgroundJob_QueuedTask{ * @brief Gets all queued tasks * @return array with associative arrays */ - public static function all(){ + public static function all() { // Array for objects $return = array(); // Get Data $stmt = OC_DB::prepare( 'SELECT * FROM `*PREFIX*queuedtasks`' ); $result = $stmt->execute(array()); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $return[] = $row; } @@ -58,14 +58,14 @@ class OC_BackgroundJob_QueuedTask{ * @param $app app name * @return array with associative arrays */ - public static function whereAppIs( $app ){ + public static function whereAppIs( $app ) { // Array for objects $return = array(); // Get Data $stmt = OC_DB::prepare( 'SELECT * FROM `*PREFIX*queuedtasks` WHERE `app` = ?' ); $result = $stmt->execute(array($app)); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $return[] = $row; } @@ -81,7 +81,7 @@ class OC_BackgroundJob_QueuedTask{ * @param $parameters all useful data as text * @return id of task */ - public static function add( $app, $klass, $method, $parameters ){ + public static function add( $app, $klass, $method, $parameters ) { $stmt = OC_DB::prepare( 'INSERT INTO `*PREFIX*queuedtasks` (`app`, `klass`, `method`, `parameters`) VALUES(?,?,?,?)' ); $result = $stmt->execute(array($app, $klass, $method, $parameters )); @@ -95,7 +95,7 @@ class OC_BackgroundJob_QueuedTask{ * * Deletes a report */ - public static function delete( $id ){ + public static function delete( $id ) { $stmt = OC_DB::prepare( 'DELETE FROM `*PREFIX*queuedtasks` WHERE `id` = ?' ); $result = $stmt->execute(array($id)); diff --git a/lib/backgroundjob/regulartask.php b/lib/backgroundjob/regulartask.php index 53bd4eb5e9b..9976872ee13 100644 --- a/lib/backgroundjob/regulartask.php +++ b/lib/backgroundjob/regulartask.php @@ -32,7 +32,7 @@ class OC_BackgroundJob_RegularTask{ * @param $method method name * @return true */ - static public function register( $klass, $method ){ + static public function register( $klass, $method ) { // Create the data structure self::$registered["$klass-$method"] = array( $klass, $method ); @@ -46,7 +46,7 @@ class OC_BackgroundJob_RegularTask{ * * key is string "$klass-$method", value is array( $klass, $method ) */ - static public function all(){ + static public function all() { return self::$registered; } } diff --git a/lib/backgroundjob/worker.php b/lib/backgroundjob/worker.php index 8684e0df117..e966ac9647c 100644 --- a/lib/backgroundjob/worker.php +++ b/lib/backgroundjob/worker.php @@ -34,14 +34,14 @@ class OC_BackgroundJob_Worker{ * This method should be called by cli scripts that do not let the user * wait. */ - public static function doAllSteps(){ + public static function doAllSteps() { // Do our regular work $lasttask = OC_Appconfig::getValue( 'core', 'backgroundjobs_task', '' ); $regular_tasks = OC_BackgroundJob_RegularTask::all(); ksort( $regular_tasks ); - foreach( $regular_tasks as $key => $value ){ - if( strcmp( $key, $lasttask ) > 0 ){ + foreach( $regular_tasks as $key => $value ) { + if( strcmp( $key, $lasttask ) > 0 ) { // Set "restart here" config value OC_Appconfig::setValue( 'core', 'backgroundjobs_task', $key ); call_user_func( $value ); @@ -52,7 +52,7 @@ class OC_BackgroundJob_Worker{ // Do our queued tasks $queued_tasks = OC_BackgroundJob_QueuedTask::all(); - foreach( $queued_tasks as $task ){ + foreach( $queued_tasks as $task ) { OC_BackgroundJob_QueuedTask::delete( $task['id'] ); call_user_func( array( $task['klass'], $task['method'] ), $task['parameters'] ); } @@ -68,10 +68,10 @@ class OC_BackgroundJob_Worker{ * with the next step. This method should be used by webcron and ajax * services. */ - public static function doNextStep(){ + public static function doNextStep() { $laststep = OC_Appconfig::getValue( 'core', 'backgroundjobs_step', 'regular_tasks' ); - if( $laststep == 'regular_tasks' ){ + if( $laststep == 'regular_tasks' ) { // get last app $lasttask = OC_Appconfig::getValue( 'core', 'backgroundjobs_task', '' ); @@ -81,8 +81,8 @@ class OC_BackgroundJob_Worker{ $done = false; // search for next background job - foreach( $regular_tasks as $key => $value ){ - if( strcmp( $key, $lasttask ) > 0 ){ + foreach( $regular_tasks as $key => $value ) { + if( strcmp( $key, $lasttask ) > 0 ) { OC_Appconfig::setValue( 'core', 'backgroundjobs_task', $key ); $done = true; call_user_func( $value ); @@ -90,14 +90,14 @@ class OC_BackgroundJob_Worker{ } } - if( $done == false ){ + if( $done == false ) { // Next time load queued tasks OC_Appconfig::setValue( 'core', 'backgroundjobs_step', 'queued_tasks' ); } } else{ $tasks = OC_BackgroundJob_QueuedTask::all(); - if( count( $tasks )){ + if( count( $tasks )) { $task = $tasks[0]; // delete job before we execute it. This prevents endless loops // of failing jobs. diff --git a/lib/base.php b/lib/base.php index a145fd1cf23..1c6cc70b0e8 100644 --- a/lib/base.php +++ b/lib/base.php @@ -70,7 +70,7 @@ class OC{ /** * SPL autoload */ - public static function autoload($className){ + public static function autoload($className) { if(array_key_exists($className, OC::$CLASSPATH)) { /** @TODO: Remove this when necessary Remove "apps/" from inclusion path for smooth migration to mutli app dir @@ -102,7 +102,7 @@ class OC{ return false; } - public static function initPaths(){ + public static function initPaths() { // calculate the root directories OC::$SERVERROOT=str_replace("\\", '/', substr(__FILE__, 0, -13)); OC::$SUBURI= str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT))); @@ -260,7 +260,7 @@ class OC{ session_start(); } - public static function init(){ + public static function init() { // register autoloader spl_autoload_register(array('OC','autoload')); setlocale(LC_ALL, 'en_US.UTF-8'); @@ -556,7 +556,7 @@ class OC{ protected static function tryBasicAuthLogin() { if (!isset($_SERVER["PHP_AUTH_USER"]) - || !isset($_SERVER["PHP_AUTH_PW"])){ + || !isset($_SERVER["PHP_AUTH_PW"])) { return false; } OC_App::loadApps(array('authentication')); diff --git a/lib/cache/apc.php b/lib/cache/apc.php index c192fe2f196..6dda0a0ff8c 100644 --- a/lib/cache/apc.php +++ b/lib/cache/apc.php @@ -43,7 +43,7 @@ class OC_Cache_APC { return apc_delete($this->getNamespace().$key); } - public function clear($prefix=''){ + public function clear($prefix='') { $ns = $this->getNamespace().$prefix; $cache = apc_cache_info('user'); foreach($cache['cache_list'] as $entry) { diff --git a/lib/cache/broker.php b/lib/cache/broker.php index c2aceabaf53..a161dbfa3bb 100644 --- a/lib/cache/broker.php +++ b/lib/cache/broker.php @@ -46,7 +46,7 @@ class OC_Cache_Broker { return $this->slow_cache->remove($key); } - public function clear($prefix=''){ + public function clear($prefix='') { $this->fast_cache->clear($prefix); $this->slow_cache->clear($prefix); } diff --git a/lib/cache/file.php b/lib/cache/file.php index b9073dee09a..a4f83f76c94 100644 --- a/lib/cache/file.php +++ b/lib/cache/file.php @@ -13,7 +13,7 @@ class OC_Cache_File{ if (isset($this->storage)) { return $this->storage; } - if(OC_User::isLoggedIn()){ + if(OC_User::isLoggedIn()) { $subdir = 'cache'; $view = new OC_FilesystemView('/'.OC_User::getUser()); if(!$view->file_exists($subdir)) { @@ -61,18 +61,18 @@ class OC_Cache_File{ public function remove($key) { $storage = $this->getStorage(); - if(!$storage){ + if(!$storage) { return false; } return $storage->unlink($key); } - public function clear($prefix=''){ + public function clear($prefix='') { $storage = $this->getStorage(); - if($storage and $storage->is_dir('/')){ + if($storage and $storage->is_dir('/')) { $dh=$storage->opendir('/'); - while($file=readdir($dh)){ - if($file!='.' and $file!='..' and ($prefix==='' || strpos($file, $prefix) === 0)){ + while($file=readdir($dh)) { + if($file!='.' and $file!='..' and ($prefix==='' || strpos($file, $prefix) === 0)) { $storage->unlink('/'.$file); } } diff --git a/lib/cache/fileglobal.php b/lib/cache/fileglobal.php index e551ad472a2..6d01964e185 100644 --- a/lib/cache/fileglobal.php +++ b/lib/cache/fileglobal.php @@ -57,20 +57,20 @@ class OC_Cache_FileGlobal{ public function remove($key) { $cache_dir = self::getCacheDir(); - if(!$cache_dir){ + if(!$cache_dir) { return false; } $key = $this->fixKey($key); return unlink($cache_dir.$key); } - public function clear($prefix=''){ + public function clear($prefix='') { $cache_dir = self::getCacheDir(); $prefix = $this->fixKey($prefix); - if($cache_dir and is_dir($cache_dir)){ + if($cache_dir and is_dir($cache_dir)) { $dh=opendir($cache_dir); - while($file=readdir($dh)){ - if($file!='.' and $file!='..' and ($prefix==='' || strpos($file, $prefix) === 0)){ + while($file=readdir($dh)) { + if($file!='.' and $file!='..' and ($prefix==='' || strpos($file, $prefix) === 0)) { unlink($cache_dir.$file); } } diff --git a/lib/cache/xcache.php b/lib/cache/xcache.php index 951f9b47545..0739e4a2fa2 100644 --- a/lib/cache/xcache.php +++ b/lib/cache/xcache.php @@ -28,7 +28,7 @@ class OC_Cache_XCache { } public function set($key, $value, $ttl=0) { - if($ttl>0){ + if($ttl>0) { return xcache_set($this->getNamespace().$key,$value,$ttl); }else{ return xcache_set($this->getNamespace().$key,$value); @@ -43,7 +43,7 @@ class OC_Cache_XCache { return xcache_unset($this->getNamespace().$key); } - public function clear($prefix=''){ + public function clear($prefix='') { xcache_unset_by_prefix($this->getNamespace().$prefix); return true; } diff --git a/lib/config.php b/lib/config.php index 390469beacf..032d401264c 100644 --- a/lib/config.php +++ b/lib/config.php @@ -52,7 +52,7 @@ class OC_Config{ * This function returns all keys saved in config.php. Please note that it * does not return the values. */ - public static function getKeys(){ + public static function getKeys() { self::readData(); return array_keys( self::$cache ); @@ -67,7 +67,7 @@ class OC_Config{ * This function gets the value from config.php. If it does not exist, * $default will be returned. */ - public static function getValue( $key, $default = null ){ + public static function getValue( $key, $default = null ) { self::readData(); if( array_key_exists( $key, self::$cache )) { @@ -86,7 +86,7 @@ class OC_Config{ * This function sets the value and writes the config.php. If the file can * not be written, false will be returned. */ - public static function setValue( $key, $value ){ + public static function setValue( $key, $value ) { self::readData(); // Add change @@ -105,7 +105,7 @@ class OC_Config{ * This function removes a key from the config.php. If owncloud has no * write access to config.php, the function will return false. */ - public static function deleteKey( $key ){ + public static function deleteKey( $key ) { self::readData(); if( array_key_exists( $key, self::$cache )) { @@ -125,7 +125,7 @@ class OC_Config{ * * Reads the config file and saves it to the cache */ - private static function readData(){ + private static function readData() { if( self::$init ) { return true; } @@ -153,7 +153,7 @@ class OC_Config{ * Saves the config to the config file. * */ - public static function writeData(){ + public static function writeData() { // Create a php file ... $content = "<?php\n\$CONFIG = "; $content .= var_export(self::$cache, true); diff --git a/lib/connector/sabre/auth.php b/lib/connector/sabre/auth.php index 8197571e949..34fc5fee50c 100644 --- a/lib/connector/sabre/auth.php +++ b/lib/connector/sabre/auth.php @@ -30,13 +30,13 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic { * * @return bool */ - protected function validateUserPass($username, $password){ + protected function validateUserPass($username, $password) { if (OC_User::isLoggedIn()) { OC_Util::setupFS($username); return true; } else { OC_Util::setUpFS();//login hooks may need early access to the filesystem - if(OC_User::login($username,$password)){ + if(OC_User::login($username,$password)) { OC_Util::setUpFS($username); return true; } diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index a7502446152..8fff77ac749 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -119,7 +119,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa $paths[] = $this->path.'/'.$info['name']; } $properties = array_fill_keys($paths, array()); - if(count($paths)>0){ + if(count($paths)>0) { $placeholders = join(',', array_fill(0, count($paths), '?')); $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ?' . ' AND `propertypath` IN ('.$placeholders.')' ); array_unshift($paths, OC_User::getUser()); // prepend userid diff --git a/lib/connector/sabre/locks.php b/lib/connector/sabre/locks.php index a01653d960a..dbcc57558e0 100644 --- a/lib/connector/sabre/locks.php +++ b/lib/connector/sabre/locks.php @@ -77,7 +77,7 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract { $result = $stmt->execute( $params ); $lockList = array(); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $lockInfo = new Sabre_DAV_Locks_LockInfo(); $lockInfo->owner = $row['owner']; diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index afcabe7bef6..2916575e2d5 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -145,7 +145,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr $propertyName = preg_replace("/^{.*}/", "", $propertyName); // remove leading namespace from property name // If it was null, we need to delete the property if (is_null($propertyValue)) { - if(array_key_exists( $propertyName, $existing )){ + if(array_key_exists( $propertyName, $existing )) { $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?' ); $query->execute( array( OC_User::getUser(), $this->path, $propertyName )); } @@ -154,7 +154,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr if( strcmp( $propertyName, "lastmodified") === 0) { $this->touch($propertyValue); } else { - if(!array_key_exists( $propertyName, $existing )){ + if(!array_key_exists( $propertyName, $existing )) { $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*properties` (`userid`,`propertypath`,`propertyname`,`propertyvalue`) VALUES(?,?,?,?)' ); $query->execute( array( OC_User::getUser(), $this->path, $propertyName,$propertyValue )); } else { @@ -186,13 +186,13 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr $result = $query->execute( array( OC_User::getUser(), $this->path )); $this->property_cache = array(); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $this->property_cache[$row['propertyname']] = $row['propertyvalue']; } } // if the array was empty, we need to return everything - if(count($properties) == 0){ + if(count($properties) == 0) { return $this->property_cache; } diff --git a/lib/connector/sabre/principal.php b/lib/connector/sabre/principal.php index d1456f7c642..cfc72eda9f9 100644 --- a/lib/connector/sabre/principal.php +++ b/lib/connector/sabre/principal.php @@ -115,6 +115,6 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend { public function setGroupMemberSet($principal, array $members) { throw new Sabre_DAV_Exception('Setting members of the group is not supported yet'); } - function updatePrincipal($path, $mutations){return 0;} - function searchPrincipals($prefixPath, array $searchProperties){return 0;} + function updatePrincipal($path, $mutations) {return 0;} + function searchPrincipals($prefixPath, array $searchProperties) {return 0;} } diff --git a/lib/db.php b/lib/db.php index bd3afe2b06e..ee69e5f8299 100644 --- a/lib/db.php +++ b/lib/db.php @@ -41,7 +41,7 @@ class OC_DB { * check which backend we should use * @return BACKEND_MDB2 or BACKEND_PDO */ - private static function getDBBackend(){ + private static function getDBBackend() { //check if we can use PDO, else use MDB2 (installation always needs to be done my mdb2) if(class_exists('PDO') && OC_Config::getValue('installed', false)) { $type = OC_Config::getValue( "dbtype", "sqlite" ); @@ -63,7 +63,7 @@ class OC_DB { * * Connects to the database as specified in config.php */ - public static function connect($backend=null){ + public static function connect($backend=null) { if(self::$connection) { return; } @@ -84,7 +84,7 @@ class OC_DB { /** * connect to the database using pdo */ - public static function connectPDO(){ + public static function connectPDO() { if(self::$connection) { if(self::$backend==self::BACKEND_MDB2) { self::disconnect(); @@ -149,7 +149,7 @@ class OC_DB { } try{ self::$PDO=new PDO($dsn, $user, $pass, $opts); - }catch(PDOException $e){ + }catch(PDOException $e) { echo( '<b>can not connect to database, using '.$type.'. ('.$e->getMessage().')</center>'); die(); } @@ -194,7 +194,7 @@ class OC_DB { 'quote_identifier' => true ); // Add the dsn according to the database type - switch($type){ + switch($type) { case 'sqlite': case 'sqlite3': $dsn = array( @@ -262,7 +262,7 @@ class OC_DB { * * SQL query via MDB2 prepare(), needs to be execute()'d! */ - static public function prepare( $query , $limit=null, $offset=null ){ + static public function prepare( $query , $limit=null, $offset=null ) { if (!is_null($limit) && $limit != -1) { if (self::$backend == self::BACKEND_MDB2) { @@ -305,7 +305,7 @@ class OC_DB { }else{ try{ $result=self::$connection->prepare($query); - }catch(PDOException $e){ + }catch(PDOException $e) { $entry = 'DB Error: "'.$e->getMessage().'"<br />'; $entry .= 'Offending command was: '.$query.'<br />'; OC_Log::write('core', $entry,OC_Log::FATAL); @@ -327,7 +327,7 @@ class OC_DB { * Call this method right after the insert command or other functions may * cause trouble! */ - public static function insertid($table=null){ + public static function insertid($table=null) { self::connect(); if($table !== null) { $prefix = OC_Config::getValue( "dbtableprefix", "oc_" ); @@ -343,7 +343,7 @@ class OC_DB { * * This is good bye, good bye, yeah! */ - public static function disconnect(){ + public static function disconnect() { // Cut connection if required if(self::$connection) { if(self::$backend==self::BACKEND_MDB2) { @@ -364,7 +364,7 @@ class OC_DB { * * TODO: write more documentation */ - public static function getDbStructure( $file ,$mode=MDB2_SCHEMA_DUMP_STRUCTURE){ + public static function getDbStructure( $file ,$mode=MDB2_SCHEMA_DUMP_STRUCTURE) { self::connectScheme(); // write the scheme @@ -386,7 +386,7 @@ class OC_DB { * * TODO: write more documentation */ - public static function createDbFromStructure( $file ){ + public static function createDbFromStructure( $file ) { $CONFIG_DBNAME = OC_Config::getValue( "dbname", "owncloud" ); $CONFIG_DBTABLEPREFIX = OC_Config::getValue( "dbtableprefix", "oc_" ); $CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" ); @@ -445,7 +445,7 @@ class OC_DB { * @brief update the database scheme * @param $file file to read structure from */ - public static function updateDbFromStructure($file){ + public static function updateDbFromStructure($file) { $CONFIG_DBTABLEPREFIX = OC_Config::getValue( "dbtableprefix", "oc_" ); $CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" ); @@ -471,7 +471,7 @@ class OC_DB { * http://www.postgresql.org/docs/8.1/static/functions-datetime.html * http://www.sqlite.org/lang_createtable.html * http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm - if( $CONFIG_DBTYPE == 'pgsql' ){ //mysql support it too but sqlite doesn't + if( $CONFIG_DBTYPE == 'pgsql' ) { //mysql support it too but sqlite doesn't $content = str_replace( '<default>0000-00-00 00:00:00</default>', '<default>CURRENT_TIMESTAMP</default>', $content ); } */ @@ -496,7 +496,7 @@ class OC_DB { * * Connects to a MDB2 database scheme */ - private static function connectScheme(){ + private static function connectScheme() { // We need a mdb2 database connection self::connectMDB2(); self::$MDB2->loadModule('Manager'); @@ -519,7 +519,7 @@ class OC_DB { * This function replaces *PREFIX* with the value of $CONFIG_DBTABLEPREFIX * and replaces the ` woth ' or " according to the database driver. */ - private static function processQuery( $query ){ + private static function processQuery( $query ) { self::connect(); // We need Database type and table prefix if(is_null(self::$type)) { @@ -554,7 +554,7 @@ class OC_DB { * @brief drop a table * @param string $tableNamme the table to drop */ - public static function dropTable($tableName){ + public static function dropTable($tableName) { self::connectMDB2(); self::$MDB2->loadModule('Manager'); self::$MDB2->dropTable($tableName); @@ -564,7 +564,7 @@ class OC_DB { * remove all tables defined in a database structure xml file * @param string $file the xml file describing the tables */ - public static function removeDBStructure($file){ + public static function removeDBStructure($file) { $CONFIG_DBNAME = OC_Config::getValue( "dbname", "owncloud" ); $CONFIG_DBTABLEPREFIX = OC_Config::getValue( "dbtableprefix", "oc_" ); self::connectScheme(); @@ -584,7 +584,7 @@ class OC_DB { // Delete our temporary file unlink( $file2 ); $tables=array_keys($definition['tables']); - foreach($tables as $table){ + foreach($tables as $table) { self::dropTable($table); } } @@ -593,13 +593,13 @@ class OC_DB { * @brief replaces the owncloud tables with a new set * @param $file string path to the MDB2 xml db export file */ - public static function replaceDB( $file ){ + public static function replaceDB( $file ) { $apps = OC_App::getAllApps(); self::beginTransaction(); // Delete the old tables self::removeDBStructure( OC::$SERVERROOT . '/db_structure.xml' ); - foreach($apps as $app){ + foreach($apps as $app) { $path = OC_App::getAppPath($app).'/appinfo/database.xml'; if(file_exists($path)) { self::removeDBStructure( $path ); @@ -614,7 +614,7 @@ class OC_DB { /** * Start a transaction */ - public static function beginTransaction(){ + public static function beginTransaction() { self::connect(); if (self::$backend==self::BACKEND_MDB2 && !self::$connection->supports('transactions')) { return false; @@ -640,10 +640,10 @@ class OC_DB { * @param mixed $result * @return bool */ - public static function isError($result){ + public static function isError($result) { if(!$result) { return true; - }elseif(self::$backend==self::BACKEND_MDB2 and PEAR::isError($result)){ + }elseif(self::$backend==self::BACKEND_MDB2 and PEAR::isError($result)) { return true; }else{ return false; @@ -658,16 +658,16 @@ class PDOStatementWrapper{ private $statement=null; private $lastArguments=array(); - public function __construct($statement){ + public function __construct($statement) { $this->statement=$statement; } /** * make execute return the result instead of a bool */ - public function execute($input=array()){ + public function execute($input=array()) { $this->lastArguments=$input; - if(count($input)>0){ + if(count($input)>0) { $result=$this->statement->execute($input); }else{ $result=$this->statement->execute(); @@ -682,7 +682,7 @@ class PDOStatementWrapper{ /** * provide numRows */ - public function numRows(){ + public function numRows() { $regex = '/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i'; if (preg_match($regex, $this->statement->queryString, $output) > 0) { $query = OC_DB::prepare("SELECT COUNT(*) FROM {$output[1]}", PDO::FETCH_NUM); @@ -695,14 +695,14 @@ class PDOStatementWrapper{ /** * provide an alias for fetch */ - public function fetchRow(){ + public function fetchRow() { return $this->statement->fetch(); } /** * pass all other function directly to the PDOStatement */ - public function __call($name,$arguments){ + public function __call($name,$arguments) { return call_user_func_array(array($this->statement,$name), $arguments); } @@ -711,7 +711,7 @@ class PDOStatementWrapper{ * fetch single column from the next row * @param int $colnum the column number to fetch */ - public function fetchOne($colnum = 0){ + public function fetchOne($colnum = 0) { return $this->statement->fetchColumn($colnum); } } diff --git a/lib/eventsource.php b/lib/eventsource.php index 45a20806b6e..900b5b101e6 100644 --- a/lib/eventsource.php +++ b/lib/eventsource.php @@ -31,18 +31,18 @@ class OC_EventSource{ private $fallback; private $fallBackId=0; - public function __construct(){ + public function __construct() { @ob_end_clean(); header('Cache-Control: no-cache'); $this->fallback=isset($_GET['fallback']) and $_GET['fallback']=='true'; - if($this->fallback){ + 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 }else{ header("Content-Type: text/event-stream"); } - if( !OC_Util::isCallRegistered()){ + if( !OC_Util::isCallRegistered()) { exit(); } flush(); @@ -56,16 +56,16 @@ class OC_EventSource{ * * if only one paramater is given, a typeless message will be send with that paramater as data */ - public function send($type,$data=null){ - if(is_null($data)){ + public function send($type,$data=null) { + if(is_null($data)) { $data=$type; $type=null; } - if($this->fallback){ + if($this->fallback) { $response='<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack('.$this->fallBackId.',"'.$type.'",'.json_encode($data).')</script>'.PHP_EOL; echo $response; }else{ - if($type){ + if($type) { echo 'event: '.$type.PHP_EOL; } echo 'data: '.json_encode($data).PHP_EOL; @@ -77,7 +77,7 @@ class OC_EventSource{ /** * close the connection of the even source */ - public function close(){ + public function close() { $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 de38ad99e8e..adcf97753ed 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -42,9 +42,9 @@ class OC_FileCache{ * - encrypted * - versioned */ - public static function get($path,$root=false){ - if(OC_FileCache_Update::hasUpdated($path,$root)){ - if($root===false){//filesystem hooks are only valid for the default root + public static function get($path,$root=false) { + 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)); }else{ OC_FileCache_Update::update($path,$root); @@ -61,18 +61,18 @@ class OC_FileCache{ * * $data is an assiciative array in the same format as returned by get */ - public static function put($path,$data,$root=false){ - if($root===false){ + public static function put($path,$data,$root=false) { + if($root===false) { $root=OC_Filesystem::getRoot(); } $fullpath=$root.$path; $parent=self::getParentId($fullpath); $id=self::getId($fullpath,''); - if(isset(OC_FileCache_Cached::$savedData[$fullpath])){ + if(isset(OC_FileCache_Cached::$savedData[$fullpath])) { $data=array_merge(OC_FileCache_Cached::$savedData[$fullpath],$data); unset(OC_FileCache_Cached::$savedData[$fullpath]); } - if($id!=-1){ + if($id!=-1) { self::update($id,$data); return; } @@ -84,14 +84,14 @@ class OC_FileCache{ $parent = self::getParentId($fullpath); } - if(!isset($data['size']) or !isset($data['mtime'])){//save incomplete data for the next time we write it + if(!isset($data['size']) or !isset($data['mtime'])) {//save incomplete data for the next time we write it OC_FileCache_Cached::$savedData[$fullpath]=$data; return; } - if(!isset($data['encrypted'])){ + if(!isset($data['encrypted'])) { $data['encrypted']=false; } - if(!isset($data['versioned'])){ + if(!isset($data['versioned'])) { $data['versioned']=false; } $mimePart=dirname($data['mimetype']); @@ -103,11 +103,11 @@ class OC_FileCache{ $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'])); - if(OC_DB::isError($result)){ + if(OC_DB::isError($result)) { OC_Log::write('files','error while writing file('.$fullpath.') to cache',OC_Log::ERROR); } - if($cache=OC_Cache::getUserCache(true)){ + if($cache=OC_Cache::getUserCache(true)) { $cache->remove('fileid/'.$fullpath);//ensure we don't have -1 cached } } @@ -117,13 +117,13 @@ class OC_FileCache{ * @param int $id * @param array $data */ - private static function update($id,$data){ + private static function update($id,$data) { $arguments=array(); $queryParts=array(); - foreach(array('size','mtime','ctime','mimetype','encrypted','versioned','writable') as $attribute){ - if(isset($data[$attribute])){ + foreach(array('size','mtime','ctime','mimetype','encrypted','versioned','writable') as $attribute) { + if(isset($data[$attribute])) { //Convert to int it args are false - if($data[$attribute] === false){ + if($data[$attribute] === false) { $arguments[] = 0; }else{ $arguments[] = $data[$attribute]; @@ -131,7 +131,7 @@ class OC_FileCache{ $queryParts[]='`'.$attribute.'`=?'; } } - if(isset($data['mimetype'])){ + if(isset($data['mimetype'])) { $arguments[]=dirname($data['mimetype']); $queryParts[]='`mimepart`=?'; } @@ -140,7 +140,7 @@ class OC_FileCache{ $sql = 'UPDATE `*PREFIX*fscache` SET '.implode(' , ',$queryParts).' WHERE `id`=?'; $query=OC_DB::prepare($sql); $result=$query->execute($arguments); - if(OC_DB::isError($result)){ + if(OC_DB::isError($result)) { OC_Log::write('files','error while updating file('.$id.') in cache',OC_Log::ERROR); } } @@ -151,8 +151,8 @@ class OC_FileCache{ * @param string newPath * @param string root (optional) */ - public static function move($oldPath,$newPath,$root=false){ - if($root===false){ + public static function move($oldPath,$newPath,$root=false) { + if($root===false) { $root=OC_Filesystem::getRoot(); } // If replacing an existing file, delete the file @@ -165,7 +165,7 @@ class OC_FileCache{ $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))); - if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$oldPath)){ + if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$oldPath)) { $cache->set('fileid/'.$newPath,$cache->get('fileid/'.$oldPath)); $cache->remove('fileid/'.$oldPath); } @@ -173,12 +173,12 @@ class OC_FileCache{ $query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `path` LIKE ?'); $oldLength=strlen($oldPath); $updateQuery=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `path`=?, `path_hash`=? WHERE `path_hash`=?'); - while($row= $query->execute(array($oldPath.'/%'))->fetchRow()){ + while($row= $query->execute(array($oldPath.'/%'))->fetchRow()) { $old=$row['path']; $new=$newPath.substr($old,$oldLength); $updateQuery->execute(array($new,md5($new),md5($old))); - if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$old)){ + if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$old)) { $cache->set('fileid/'.$new,$cache->get('fileid/'.$old)); $cache->remove('fileid/'.$old); } @@ -190,8 +190,8 @@ class OC_FileCache{ * @param string path * @param string root (optional) */ - public static function delete($path,$root=false){ - if($root===false){ + public static function delete($path,$root=false) { + if($root===false) { $root=OC_Filesystem::getRoot(); } $query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache` WHERE `path_hash`=?'); @@ -211,20 +211,20 @@ class OC_FileCache{ * @param string root (optional) * @return array of filepaths */ - public static function search($search,$returnData=false,$root=false){ - if($root===false){ + public static function search($search,$returnData=false,$root=false) { + if($root===false) { $root=OC_Filesystem::getRoot(); } $rootLen=strlen($root); - if(!$returnData){ + if(!$returnData) { $query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `name` LIKE ? AND `user`=?'); }else{ $query=OC_DB::prepare('SELECT * FROM `*PREFIX*fscache` WHERE `name` LIKE ? AND `user`=?'); } $result=$query->execute(array("%$search%",OC_User::getUser())); $names=array(); - while($row=$result->fetchRow()){ - if(!$returnData){ + while($row=$result->fetchRow()) { + if(!$returnData) { $names[]=substr($row['path'],$rootLen); }else{ $row['path']=substr($row['path'],$rootLen); @@ -249,8 +249,8 @@ class OC_FileCache{ * - encrypted * - versioned */ - public static function getFolderContent($path,$root=false,$mimetype_filter=''){ - if(OC_FileCache_Update::hasUpdated($path,$root,true)){ + public static function getFolderContent($path,$root=false,$mimetype_filter='') { + if(OC_FileCache_Update::hasUpdated($path,$root,true)) { OC_FileCache_Update::updateFolder($path,$root); } return OC_FileCache_Cached::getFolderContent($path,$root,$mimetype_filter); @@ -262,7 +262,7 @@ class OC_FileCache{ * @param string root (optional) * @return bool */ - public static function inCache($path,$root=false){ + public static function inCache($path,$root=false) { return self::getId($path,$root)!=-1; } @@ -272,30 +272,30 @@ class OC_FileCache{ * @param string root (optional) * @return int */ - public static function getId($path,$root=false){ - if($root===false){ + public static function getId($path,$root=false) { + if($root===false) { $root=OC_Filesystem::getRoot(); } $fullPath=$root.$path; - if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$fullPath)){ + if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$fullPath)) { return $cache->get('fileid/'.$fullPath); } $query=OC_DB::prepare('SELECT `id` FROM `*PREFIX*fscache` WHERE `path_hash`=?'); $result=$query->execute(array(md5($fullPath))); - if(OC_DB::isError($result)){ + if(OC_DB::isError($result)) { OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR); return -1; } $result=$result->fetchRow(); - if(is_array($result)){ + if(is_array($result)) { $id=$result['id']; }else{ $id=-1; } - if($cache=OC_Cache::getUserCache(true)){ + if($cache=OC_Cache::getUserCache(true)) { $cache->set('fileid/'.$fullPath,$id); } @@ -308,8 +308,8 @@ class OC_FileCache{ * @param string user (optional) * @return string */ - public static function getPath($id,$user=''){ - if(!$user){ + public static function getPath($id,$user='') { + if(!$user) { $user=OC_User::getUser(); } $query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `id`=? AND `user`=?'); @@ -317,7 +317,7 @@ class OC_FileCache{ $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)); @@ -328,8 +328,8 @@ class OC_FileCache{ * @param string $path * @return int */ - private static function getParentId($path){ - if($path=='/'){ + private static function getParentId($path) { + if($path=='/') { return -1; }else{ return self::getId(dirname($path),''); @@ -342,10 +342,10 @@ class OC_FileCache{ * @param int $sizeDiff * @param string root (optinal) */ - public static function increaseSize($path,$sizeDiff, $root=false){ + public static function increaseSize($path,$sizeDiff, $root=false) { if($sizeDiff==0) return; $id=self::getId($path,$root); - while($id!=-1){//walk up the filetree increasing the size of all parent folders + 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)); $id=self::getParentId($path); @@ -360,8 +360,8 @@ class OC_FileCache{ * @param int count (optional) * @param string root (optional) */ - public static function scan($path,$eventSource=false,&$count=0,$root=false){ - if($eventSource){ + public static function scan($path,$eventSource=false,&$count=0,$root=false) { + if($eventSource) { $eventSource->send('scanning',array('file'=>$path,'count'=>$count)); } $lastSend=$count; @@ -369,7 +369,7 @@ class OC_FileCache{ if (substr($path, 0, 7) == '/Shared') { return; } - if($root===false){ + if($root===false) { $view=OC_Filesystem::getView(); }else{ $view=new OC_FilesystemView($root); @@ -377,16 +377,16 @@ class OC_FileCache{ self::scanFile($path,$root); $dh=$view->opendir($path.'/'); $totalSize=0; - if($dh){ + if($dh) { while (($filename = readdir($dh)) !== false) { - if($filename != '.' and $filename != '..'){ + if($filename != '.' and $filename != '..') { $file=$path.'/'.$filename; - if($view->is_dir($file.'/')){ + if($view->is_dir($file.'/')) { self::scan($file,$eventSource,$count,$root); }else{ $totalSize+=self::scanFile($file,$root); $count++; - if($count>$lastSend+25 and $eventSource){ + if($count>$lastSend+25 and $eventSource) { $lastSend=$count; $eventSource->send('scanning',array('file'=>$path,'count'=>$count)); } @@ -405,12 +405,12 @@ class OC_FileCache{ * @param string root (optional) * @return int size of the scanned file */ - public static function scanFile($path,$root=false){ + public static function scanFile($path,$root=false) { // NOTE: Ugly hack to prevent shared files from going into the cache (the source already exists somewhere in the cache) if (substr($path, 0, 7) == '/Shared') { return; } - if($root===false){ + if($root===false) { $view=OC_Filesystem::getView(); }else{ $view=new OC_FilesystemView($root); @@ -419,14 +419,14 @@ class OC_FileCache{ clearstatcache(); $mimetype=$view->getMimeType($path); $stat=$view->stat($path); - if($mimetype=='httpd/unix-directory'){ + if($mimetype=='httpd/unix-directory') { $writable=$view->is_writable($path.'/'); }else{ $writable=$view->is_writable($path); } $stat['mimetype']=$mimetype; $stat['writable']=$writable; - if($path=='/'){ + if($path=='/') { $path=''; } self::put($path,$stat,$root); @@ -446,14 +446,14 @@ class OC_FileCache{ * seccond mimetype part can be ommited * e.g. searchByMime('audio') */ - public static function searchByMime($part1,$part2=null,$root=false){ - if($root===false){ + public static function searchByMime($part1,$part2=null,$root=false) { + if($root===false) { $root=OC_Filesystem::getRoot(); } $rootLen=strlen($root); $root .= '%'; $user=OC_User::getUser(); - if(!$part2){ + 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)); }else{ @@ -461,7 +461,7 @@ class OC_FileCache{ $result=$query->execute(array($part1.'/'.$part2,$user, $root)); } $names=array(); - while($row=$result->fetchRow()){ + while($row=$result->fetchRow()) { $names[]=substr($row['path'],$rootLen); } return $names; @@ -470,7 +470,7 @@ class OC_FileCache{ /** * clean old pre-path_hash entries */ - public static function clean(){ + public static function clean() { $query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache` WHERE LENGTH(`path_hash`)<30'); $query->execute(); } @@ -479,8 +479,8 @@ class OC_FileCache{ * clear filecache entries * @param string user (optonal) */ - public static function clear($user=''){ - if($user){ + public static function clear($user='') { + if($user) { $query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache` WHERE user=?'); $query->execute(array($user)); }else{ diff --git a/lib/filecache/cached.php b/lib/filecache/cached.php index 505f1a5e2a0..261bd2f572b 100644 --- a/lib/filecache/cached.php +++ b/lib/filecache/cached.php @@ -13,20 +13,20 @@ class OC_FileCache_Cached{ public static $savedData=array(); - public static function get($path,$root=false){ - if($root===false){ + public static function get($path,$root=false) { + if($root===false) { $root=OC_Filesystem::getRoot(); } $path=$root.$path; $query=OC_DB::prepare('SELECT `path`,`ctime`,`mtime`,`mimetype`,`size`,`encrypted`,`versioned`,`writable` FROM `*PREFIX*fscache` WHERE `path_hash`=?'); $result=$query->execute(array(md5($path)))->fetchRow(); - if(is_array($result)){ - if(isset(self::$savedData[$path])){ + if(is_array($result)) { + if(isset(self::$savedData[$path])) { $result=array_merge($result,self::$savedData[$path]); } return $result; }else{ - if(isset(self::$savedData[$path])){ + if(isset(self::$savedData[$path])) { return self::$savedData[$path]; }else{ return array(); @@ -50,17 +50,17 @@ class OC_FileCache_Cached{ * - encrypted * - versioned */ - public static function getFolderContent($path,$root=false,$mimetype_filter=''){ - if($root===false){ + public static function getFolderContent($path,$root=false,$mimetype_filter='') { + if($root===false) { $root=OC_Filesystem::getRoot(); } $parent=OC_FileCache::getId($path,$root); - if($parent==-1){ + if($parent==-1) { return array(); } $query=OC_DB::prepare('SELECT `id`,`path`,`name`,`ctime`,`mtime`,`mimetype`,`size`,`encrypted`,`versioned`,`writable` FROM `*PREFIX*fscache` WHERE `parent`=? AND (`mimetype` LIKE ? OR `mimetype` = ?)'); $result=$query->execute(array($parent, $mimetype_filter.'%', 'httpd/unix-directory'))->fetchAll(); - if(is_array($result)){ + if(is_array($result)) { return $result; }else{ OC_Log::write('files','getFolderContent(): file not found in cache ('.$path.')',OC_Log::DEBUG); diff --git a/lib/filecache/update.php b/lib/filecache/update.php index 7b5f18fe5c1..3d10f5ea7b6 100644 --- a/lib/filecache/update.php +++ b/lib/filecache/update.php @@ -18,25 +18,25 @@ class OC_FileCache_Update{ * @param boolean folder * @return bool */ - public static function hasUpdated($path,$root=false,$folder=false){ - if($root===false){ + public static function hasUpdated($path,$root=false,$folder=false) { + if($root===false) { $view=OC_Filesystem::getView(); }else{ $view=new OC_FilesystemView($root); } - if(!$view->file_exists($path)){ + if(!$view->file_exists($path)) { return false; } $cachedData=OC_FileCache_Cached::get($path,$root); - if(isset($cachedData['mtime'])){ + if(isset($cachedData['mtime'])) { $cachedMTime=$cachedData['mtime']; - if($folder){ + if($folder) { return $view->hasUpdated($path.'/',$cachedMTime); }else{ return $view->hasUpdated($path,$cachedMTime); } }else{//file not in cache, so it has to be updated - if(($path=='/' or $path=='') and $root===false){//dont auto update the home folder, it will be scanned + if(($path=='/' or $path=='') and $root===false) {//dont auto update the home folder, it will be scanned return false; } return true; @@ -46,19 +46,19 @@ class OC_FileCache_Update{ /** * delete non existing files from the cache */ - public static function cleanFolder($path,$root=false){ - if($root===false){ + public static function cleanFolder($path,$root=false) { + if($root===false) { $view=OC_Filesystem::getView(); }else{ $view=new OC_FilesystemView($root); } $cachedContent=OC_FileCache_Cached::getFolderContent($path,$root); - foreach($cachedContent as $fileData){ + foreach($cachedContent as $fileData) { $path=$fileData['path']; $file=$view->getRelativePath($path); - if(!$view->file_exists($file)){ - if($root===false){//filesystem hooks are only valid for the default root + if(!$view->file_exists($file)) { + if($root===false) {//filesystem hooks are only valid for the default root OC_Hook::emit('OC_Filesystem','post_delete',array('path'=>$file)); }else{ self::delete($file,$root); @@ -72,19 +72,19 @@ class OC_FileCache_Update{ * @param string path * @param string root (optional) */ - public static function updateFolder($path,$root=false){ - if($root===false){ + public static function updateFolder($path,$root=false) { + if($root===false) { $view=OC_Filesystem::getView(); }else{ $view=new OC_FilesystemView($root); } $dh=$view->opendir($path.'/'); - if($dh){//check for changed/new files + if($dh) {//check for changed/new files while (($filename = readdir($dh)) !== false) { - if($filename != '.' and $filename != '..'){ + if($filename != '.' and $filename != '..') { $file=$path.'/'.$filename; - if(self::hasUpdated($file,$root)){ - if($root===false){//filesystem hooks are only valid for the default root + if(self::hasUpdated($file,$root)) { + if($root===false) {//filesystem hooks are only valid for the default root OC_Hook::emit('OC_Filesystem','post_write',array('path'=>$file)); }else{ self::update($file,$root); @@ -97,7 +97,7 @@ class OC_FileCache_Update{ self::cleanFolder($path,$root); //update the folder last, so we can calculate the size correctly - if($root===false){//filesystem hooks are only valid for the default root + if($root===false) {//filesystem hooks are only valid for the default root OC_Hook::emit('OC_Filesystem','post_write',array('path'=>$path)); }else{ self::update($path,$root); @@ -109,7 +109,7 @@ class OC_FileCache_Update{ * @param array $params * @param string root (optional) */ - public static function fileSystemWatcherWrite($params){ + public static function fileSystemWatcherWrite($params) { $path=$params['path']; self::update($path); } @@ -119,7 +119,7 @@ class OC_FileCache_Update{ * @param array $params * @param string root (optional) */ - public static function fileSystemWatcherDelete($params){ + public static function fileSystemWatcherDelete($params) { $path=$params['path']; self::delete($path); } @@ -129,7 +129,7 @@ class OC_FileCache_Update{ * @param array $params * @param string root (optional) */ - public static function fileSystemWatcherRename($params){ + public static function fileSystemWatcherRename($params) { $oldPath=$params['oldpath']; $newPath=$params['newpath']; self::rename($oldPath,$newPath); @@ -140,8 +140,8 @@ class OC_FileCache_Update{ * @param string path * @param string root (optional) */ - public static function update($path,$root=false){ - if($root===false){ + public static function update($path,$root=false) { + if($root===false) { $view=OC_Filesystem::getView(); }else{ $view=new OC_FilesystemView($root); @@ -153,10 +153,10 @@ class OC_FileCache_Update{ $cached=OC_FileCache_Cached::get($path,$root); $cachedSize=isset($cached['size'])?$cached['size']:0; - if($view->is_dir($path.'/')){ - if(OC_FileCache::inCache($path,$root)){ + if($view->is_dir($path.'/')) { + if(OC_FileCache::inCache($path,$root)) { $cachedContent=OC_FileCache_Cached::getFolderContent($path,$root); - foreach($cachedContent as $file){ + foreach($cachedContent as $file) { $size+=$file['size']; } $mtime=$view->filemtime($path.'/'); @@ -179,9 +179,9 @@ class OC_FileCache_Update{ * @param string path * @param string root (optional) */ - public static function delete($path,$root=false){ + public static function delete($path,$root=false) { $cached=OC_FileCache_Cached::get($path,$root); - if(!isset($cached['size'])){ + if(!isset($cached['size'])) { return; } $size=$cached['size']; @@ -195,11 +195,11 @@ class OC_FileCache_Update{ * @param string newPath * @param string root (optional) */ - public static function rename($oldPath,$newPath,$root=false){ - if(!OC_FileCache::inCache($oldPath,$root)){ + public static function rename($oldPath,$newPath,$root=false) { + if(!OC_FileCache::inCache($oldPath,$root)) { return; } - if($root===false){ + if($root===false) { $view=OC_Filesystem::getView(); }else{ $view=new OC_FilesystemView($root); diff --git a/lib/fileproxy.php b/lib/fileproxy.php index a1c79874bf7..17380c656a3 100644 --- a/lib/fileproxy.php +++ b/lib/fileproxy.php @@ -51,8 +51,8 @@ class OC_FileProxy{ * * this implements a dummy proxy for all operations */ - public function __call($function,$arguments){ - if(substr($function,0,3)=='pre'){ + public function __call($function,$arguments) { + if(substr($function,0,3)=='pre') { return true; }else{ return $arguments[1]; @@ -63,33 +63,33 @@ class OC_FileProxy{ * register a proxy to be used * @param OC_FileProxy $proxy */ - public static function register($proxy){ + public static function register($proxy) { self::$proxies[]=$proxy; } - public static function getProxies($operation){ + public static function getProxies($operation) { $proxies=array(); - foreach(self::$proxies as $proxy){ - if(method_exists($proxy,$operation)){ + foreach(self::$proxies as $proxy) { + if(method_exists($proxy,$operation)) { $proxies[]=$proxy; } } return $proxies; } - public static function runPreProxies($operation,&$filepath,&$filepath2=null){ - if(!self::$enabled){ + public static function runPreProxies($operation,&$filepath,&$filepath2=null) { + if(!self::$enabled) { return true; } $operation='pre'.$operation; $proxies=self::getProxies($operation); - foreach($proxies as $proxy){ - if(!is_null($filepath2)){ - if($proxy->$operation($filepath,$filepath2)===false){ + foreach($proxies as $proxy) { + if(!is_null($filepath2)) { + if($proxy->$operation($filepath,$filepath2)===false) { return false; } }else{ - if($proxy->$operation($filepath)===false){ + if($proxy->$operation($filepath)===false) { return false; } } @@ -97,19 +97,19 @@ class OC_FileProxy{ return true; } - public static function runPostProxies($operation,$path,$result){ - if(!self::$enabled){ + public static function runPostProxies($operation,$path,$result) { + if(!self::$enabled) { return $result; } $operation='post'.$operation; $proxies=self::getProxies($operation); - foreach($proxies as $proxy){ + foreach($proxies as $proxy) { $result=$proxy->$operation($path,$result); } return $result; } - public static function clearProxies(){ + public static function clearProxies() { self::$proxies=array(); } } diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php index 4c6261fc514..adbff3d301a 100644 --- a/lib/fileproxy/quota.php +++ b/lib/fileproxy/quota.php @@ -32,15 +32,15 @@ class OC_FileProxy_Quota extends OC_FileProxy{ * get the quota for the current user * @return int */ - private function getQuota(){ - if($this->userQuota!=-1){ + private function getQuota() { + if($this->userQuota!=-1) { return $this->userQuota; } $userQuota=OC_Preferences::getValue(OC_User::getUser(),'files','quota','default'); - if($userQuota=='default'){ + if($userQuota=='default') { $userQuota=OC_AppConfig::getValue('files','default_quota','none'); } - if($userQuota=='none'){ + if($userQuota=='none') { $this->userQuota=0; }else{ $this->userQuota=OC_Helper::computerFileSize($userQuota); @@ -53,7 +53,7 @@ class OC_FileProxy_Quota extends OC_FileProxy{ * get the free space in the users home folder * @return int */ - private function getFreeSpace(){ + private function getFreeSpace() { $rootInfo=OC_FileCache_Cached::get(''); // TODO Remove after merge of share_api if (OC_FileCache::inCache('/Shared')) { @@ -64,36 +64,36 @@ class OC_FileProxy_Quota extends OC_FileProxy{ $usedSpace=isset($rootInfo['size'])?$rootInfo['size']:0; $usedSpace=isset($sharedInfo['size'])?$usedSpace-$sharedInfo['size']:$usedSpace; $totalSpace=$this->getQuota(); - if($totalSpace==0){ + if($totalSpace==0) { return 0; } return $totalSpace-$usedSpace; } - public function postFree_space($path,$space){ + public function postFree_space($path,$space) { $free=$this->getFreeSpace(); - if($free==0){ + if($free==0) { return $space; } return min($free,$space); } - public function preFile_put_contents($path,$data){ + public function preFile_put_contents($path,$data) { 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); } - public function preCopy($path1,$path2){ + public function preCopy($path1,$path2) { return (OC_Filesystem::filesize($path1)<$this->getFreeSpace() or $this->getFreeSpace()==0); } - public function preFromTmpFile($tmpfile,$path){ + public function preFromTmpFile($tmpfile,$path) { return (filesize($tmpfile)<$this->getFreeSpace() or $this->getFreeSpace()==0); } - public function preFromUploadedFile($tmpfile,$path){ + public function preFromUploadedFile($tmpfile,$path) { return (filesize($tmpfile)<$this->getFreeSpace() or $this->getFreeSpace()==0); } }
\ No newline at end of file diff --git a/lib/files.php b/lib/files.php index 00cbc63aba0..63dd96b9509 100644 --- a/lib/files.php +++ b/lib/files.php @@ -32,9 +32,9 @@ class OC_Files { * get the content of a directory * @param dir $directory path under datadirectory */ - public static function getDirectoryContent($directory, $mimetype_filter = ''){ + public static function getDirectoryContent($directory, $mimetype_filter = '') { $directory=OC_Filesystem::normalizePath($directory); - if($directory=='/'){ + if($directory=='/') { $directory=''; } $files = array(); @@ -87,12 +87,12 @@ class OC_Files { * @param file $file ; seperated list of files to download * @param boolean $only_header ; boolean to only send header of the request */ - public static function get($dir,$files, $only_header = false){ - if(strpos($files,';')){ + public static function get($dir,$files, $only_header = false) { + if(strpos($files,';')) { $files=explode(';',$files); } - if(is_array($files)){ + if(is_array($files)) { self::validateZipDownload($dir,$files); $executionTime = intval(ini_get('max_execution_time')); set_time_limit(0); @@ -101,19 +101,19 @@ class OC_Files { if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) { exit("cannot open <$filename>\n"); } - foreach($files as $file){ + foreach($files as $file) { $file=$dir.'/'.$file; - if(OC_Filesystem::is_file($file)){ + if(OC_Filesystem::is_file($file)) { $tmpFile=OC_Filesystem::toTmpFile($file); self::$tmpFiles[]=$tmpFile; $zip->addFile($tmpFile,basename($file)); - }elseif(OC_Filesystem::is_dir($file)){ + }elseif(OC_Filesystem::is_dir($file)) { self::zipAddDir($file,$zip); } } $zip->close(); set_time_limit($executionTime); - }elseif(OC_Filesystem::is_dir($dir.'/'.$files)){ + }elseif(OC_Filesystem::is_dir($dir.'/'.$files)) { self::validateZipDownload($dir,$files); $executionTime = intval(ini_get('max_execution_time')); set_time_limit(0); @@ -131,18 +131,18 @@ class OC_Files { $filename=$dir.'/'.$files; } @ob_end_clean(); - if($zip or OC_Filesystem::is_readable($filename)){ + if($zip or OC_Filesystem::is_readable($filename)) { header('Content-Disposition: attachment; filename="'.basename($filename).'"'); header('Content-Transfer-Encoding: binary'); OC_Response::disableCaching(); - if($zip){ + if($zip) { ini_set('zlib.output_compression', 'off'); header('Content-Type: application/zip'); header('Content-Length: ' . filesize($filename)); }else{ header('Content-Type: '.OC_Filesystem::getMimeType($filename)); } - }elseif($zip or !OC_Filesystem::file_exists($filename)){ + }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); @@ -151,12 +151,12 @@ class OC_Files { header("HTTP/1.0 403 Forbidden"); die('403 Forbidden'); } - if($only_header){ + if($only_header) { if(!$zip) header("Content-Length: ".OC_Filesystem::filesize($filename)); return ; } - if($zip){ + if($zip) { $handle=fopen($filename,'r'); if ($handle) { $chunkSize = 8*1024;// 1 MB chunks @@ -169,26 +169,26 @@ class OC_Files { }else{ OC_Filesystem::readfile($filename); } - foreach(self::$tmpFiles as $tmpFile){ - if(file_exists($tmpFile) and is_file($tmpFile)){ + foreach(self::$tmpFiles as $tmpFile) { + if(file_exists($tmpFile) and is_file($tmpFile)) { unlink($tmpFile); } } } - public static function zipAddDir($dir,$zip,$internalDir=''){ + public static function zipAddDir($dir,$zip,$internalDir='') { $dirname=basename($dir); $zip->addEmptyDir($internalDir.$dirname); $internalDir.=$dirname.='/'; $files=OC_Files::getdirectorycontent($dir); - foreach($files as $file){ + foreach($files as $file) { $filename=$file['name']; $file=$dir.'/'.$filename; - if(OC_Filesystem::is_file($file)){ + if(OC_Filesystem::is_file($file)) { $tmpFile=OC_Filesystem::toTmpFile($file); OC_Files::$tmpFiles[]=$tmpFile; $zip->addFile($tmpFile,$internalDir.$filename); - }elseif(OC_Filesystem::is_dir($file)){ + }elseif(OC_Filesystem::is_dir($file)) { self::zipAddDir($file,$zip,$internalDir); } } @@ -201,8 +201,8 @@ class OC_Files { * @param dir $targetDir * @param file $target */ - public static function move($sourceDir,$source,$targetDir,$target){ - if(OC_User::isLoggedIn() && ($sourceDir != '' || $source != 'Shared')){ + public static function move($sourceDir,$source,$targetDir,$target) { + if(OC_User::isLoggedIn() && ($sourceDir != '' || $source != 'Shared')) { $targetFile=self::normalizePath($targetDir.'/'.$target); $sourceFile=self::normalizePath($sourceDir.'/'.$source); return OC_Filesystem::rename($sourceFile,$targetFile); @@ -219,8 +219,8 @@ class OC_Files { * @param dir $targetDir * @param file $target */ - public static function copy($sourceDir,$source,$targetDir,$target){ - if(OC_User::isLoggedIn()){ + public static function copy($sourceDir,$source,$targetDir,$target) { + if(OC_User::isLoggedIn()) { $targetFile=$targetDir.'/'.$target; $sourceFile=$sourceDir.'/'.$source; return OC_Filesystem::copy($sourceFile,$targetFile); @@ -234,14 +234,14 @@ class OC_Files { * @param file $name * @param type $type */ - public static function newFile($dir,$name,$type){ - if(OC_User::isLoggedIn()){ + public static function newFile($dir,$name,$type) { + if(OC_User::isLoggedIn()) { $file=$dir.'/'.$name; - if($type=='dir'){ + if($type=='dir') { return OC_Filesystem::mkdir($file); - }elseif($type=='file'){ + }elseif($type=='file') { $fileHandle=OC_Filesystem::fopen($file, 'w'); - if($fileHandle){ + if($fileHandle) { fclose($fileHandle); return true; }else{ @@ -257,7 +257,7 @@ class OC_Files { * @param dir $dir * @param file $name */ - public static function delete($dir,$file){ + public static function delete($dir,$file) { if(OC_User::isLoggedIn() && ($dir!= '' || $file != 'Shared')) { $file=$dir.'/'.$file; return OC_Filesystem::unlink($file); @@ -289,8 +289,8 @@ class OC_Files { $zipLimit = OC_Config::getValue('maxZipInputSize', OC_Helper::computerFileSize('800 MB')); if($zipLimit > 0) { $totalsize = 0; - if(is_array($files)){ - foreach($files as $file){ + if(is_array($files)) { + foreach($files as $file) { $totalsize += OC_Filesystem::filesize($dir.'/'.$file); } }else{ @@ -319,7 +319,7 @@ class OC_Files { * @param string path * @return string guessed mime type */ - static function getMimeType($path){ + static function getMimeType($path) { return OC_Filesystem::getMimeType($path); } @@ -329,7 +329,7 @@ class OC_Files { * @param string path * @return array */ - static function getTree($path){ + static function getTree($path) { return OC_Filesystem::getTree($path); } @@ -341,7 +341,7 @@ class OC_Files { * @param string file * @return string guessed mime type */ - static function pull($source,$token,$dir,$file){ + static function pull($source,$token,$dir,$file) { $tmpfile=tempnam(get_temp_dir(),'remoteCloudFile'); $fp=fopen($tmpfile,'w+'); $url=$source.="/files/pull.php?token=$token"; @@ -353,7 +353,7 @@ class OC_Files { $info=curl_getinfo($ch); $httpCode=$info['http_code']; curl_close($ch); - if($httpCode==200 or $httpCode==0){ + if($httpCode==200 or $httpCode==0) { OC_Filesystem::fromTmpFile($tmpfile,$dir.'/'.$file); return true; }else{ @@ -366,7 +366,7 @@ class OC_Files { * @param int size filesisze in bytes * @return false on failure, size on success */ - static function setUploadLimit($size){ + static function setUploadLimit($size) { //don't allow user to break his config -- upper boundary if($size > PHP_INT_MAX) { //max size is always 1 byte lower than computerFileSize returns @@ -421,10 +421,10 @@ class OC_Files { * @param string $path * @return string */ - static public function normalizePath($path){ + static public function normalizePath($path) { $path='/'.$path; $old=''; - while($old!=$path){//replace any multiplicity of slashes with a single one + while($old!=$path) {//replace any multiplicity of slashes with a single one $old=$path; $path=str_replace('//','/',$path); } @@ -432,10 +432,10 @@ class OC_Files { } } -function fileCmp($a,$b){ - if($a['type']=='dir' and $b['type']!='dir'){ +function fileCmp($a,$b) { + if($a['type']=='dir' and $b['type']!='dir') { return -1; - }elseif($a['type']!='dir' and $b['type']=='dir'){ + }elseif($a['type']!='dir' and $b['type']=='dir') { return 1; }else{ return strnatcasecmp($a['name'],$b['name']); diff --git a/lib/filestorage/common.php b/lib/filestorage/common.php index e2828e56170..351714437c5 100644 --- a/lib/filestorage/common.php +++ b/lib/filestorage/common.php @@ -34,20 +34,20 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { - public function __construct($parameters){} + public function __construct($parameters) {} // abstract public function mkdir($path); // abstract public function rmdir($path); // abstract public function opendir($path); - public function is_dir($path){ + public function is_dir($path) { return $this->filetype($path)=='dir'; } - public function is_file($path){ + public function is_file($path) { return $this->filetype($path)=='file'; } // abstract public function stat($path); // abstract public function filetype($path); public function filesize($path) { - if($this->is_dir($path)){ + if($this->is_dir($path)) { return 0;//by definition }else{ $stat = $this->stat($path); @@ -80,11 +80,11 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { } public function file_get_contents($path) { $handle = $this->fopen($path, "r"); - if(!$handle){ + if(!$handle) { return false; } $size=$this->filesize($path); - if($size==0){ + if($size==0) { return ''; } return fread($handle, $size); @@ -94,8 +94,8 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { return fwrite($handle, $data); } // abstract public function unlink($path); - public function rename($path1,$path2){ - if($this->copy($path1,$path2)){ + public function rename($path1,$path2) { + if($this->copy($path1,$path2)) { return $this->unlink($path1); }else{ return false; @@ -181,19 +181,19 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { } } - public function getMimeType($path){ - if(!$this->file_exists($path)){ + public function getMimeType($path) { + if(!$this->file_exists($path)) { return false; } - if($this->is_dir($path)){ + if($this->is_dir($path)) { return 'httpd/unix-directory'; } $source=$this->fopen($path,'r'); - if(!$source){ + if(!$source) { return false; } $head=fread($source,8192);//8kb should suffice to determine a mimetype - if($pos=strrpos($path,'.')){ + if($pos=strrpos($path,'.')) { $extension=substr($path,$pos); }else{ $extension=''; @@ -204,25 +204,25 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { unlink($tmpFile); return $mime; } - public function hash($type,$path,$raw = false){ + public function hash($type,$path,$raw = false) { $tmpFile=$this->getLocalFile(); $hash=hash($type,$tmpFile,$raw); unlink($tmpFile); return $hash; } // abstract public function free_space($path); - public function search($query){ + public function search($query) { return $this->searchInDir($query); } - public function getLocalFile($path){ + public function getLocalFile($path) { return $this->toTmpFile($path); } - private function toTmpFile($path){//no longer in the storage api, still usefull here + private function toTmpFile($path) {//no longer in the storage api, still usefull here $source=$this->fopen($path,'r'); - if(!$source){ + if(!$source) { return false; } - if($pos=strrpos($path,'.')){ + if($pos=strrpos($path,'.')) { $extension=substr($path,$pos); }else{ $extension=''; @@ -232,16 +232,16 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { OC_Helper::streamCopy($source,$target); return $tmpFile; } - public function getLocalFolder($path){ + public function getLocalFolder($path) { $baseDir=OC_Helper::tmpFolder(); $this->addLocalFolder($path,$baseDir); return $baseDir; } - private function addLocalFolder($path,$target){ - if($dh=$this->opendir($path)){ - while($file=readdir($dh)){ - if($file!=='.' and $file!=='..'){ - if($this->is_dir($path.'/'.$file)){ + private function addLocalFolder($path,$target) { + if($dh=$this->opendir($path)) { + while($file=readdir($dh)) { + if($file!=='.' and $file!=='..') { + if($this->is_dir($path.'/'.$file)) { mkdir($target.'/'.$file); $this->addLocalFolder($path.'/'.$file,$target.'/'.$file); }else{ @@ -254,16 +254,16 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { } // abstract public function touch($path, $mtime=null); - protected function searchInDir($query,$dir=''){ + protected function searchInDir($query,$dir='') { $files=array(); $dh=$this->opendir($dir); - if($dh){ - while($item=readdir($dh)){ + 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)){ + if($this->is_dir($dir.'/'.$item)) { $files=array_merge($files,$this->searchInDir($query,$dir.'/'.$item)); } } @@ -276,7 +276,7 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { * @param int $time * @return bool */ - public function hasUpdated($path,$time){ + public function hasUpdated($path,$time) { return $this->filemtime($path)>$time; } } diff --git a/lib/filestorage/commontest.php b/lib/filestorage/commontest.php index 4d06e4fa321..b88bb232c36 100644 --- a/lib/filestorage/commontest.php +++ b/lib/filestorage/commontest.php @@ -32,44 +32,44 @@ class OC_Filestorage_CommonTest extends OC_Filestorage_Common{ */ private $storage; - public function __construct($params){ + public function __construct($params) { $this->storage=new OC_Filestorage_Local($params); } - public function mkdir($path){ + public function mkdir($path) { return $this->storage->mkdir($path); } - public function rmdir($path){ + public function rmdir($path) { return $this->storage->rmdir($path); } - public function opendir($path){ + public function opendir($path) { return $this->storage->opendir($path); } - public function stat($path){ + public function stat($path) { return $this->storage->stat($path); } - public function filetype($path){ + public function filetype($path) { return $this->storage->filetype($path); } - public function isReadable($path){ + public function isReadable($path) { return $this->storage->isReadable($path); } - public function isUpdatable($path){ + public function isUpdatable($path) { return $this->storage->isUpdatable($path); } - public function file_exists($path){ + public function file_exists($path) { return $this->storage->file_exists($path); } - public function unlink($path){ + public function unlink($path) { return $this->storage->unlink($path); } - public function fopen($path,$mode){ + public function fopen($path,$mode) { return $this->storage->fopen($path,$mode); } - public function free_space($path){ + public function free_space($path) { return $this->storage->free_space($path); } - public function touch($path, $mtime=null){ + public function touch($path, $mtime=null) { return $this->storage->touch($path,$mtime); } }
\ No newline at end of file diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php index b19205f45b1..e26d3d3ef91 100644 --- a/lib/filestorage/local.php +++ b/lib/filestorage/local.php @@ -4,67 +4,67 @@ */ class OC_Filestorage_Local extends OC_Filestorage_Common{ protected $datadir; - public function __construct($arguments){ + public function __construct($arguments) { $this->datadir=$arguments['datadir']; - if(substr($this->datadir,-1)!=='/'){ + if(substr($this->datadir,-1)!=='/') { $this->datadir.='/'; } } - public function mkdir($path){ + public function mkdir($path) { return @mkdir($this->datadir.$path); } - public function rmdir($path){ + public function rmdir($path) { return @rmdir($this->datadir.$path); } - public function opendir($path){ + public function opendir($path) { return opendir($this->datadir.$path); } - public function is_dir($path){ - if(substr($path,-1)=='/'){ + public function is_dir($path) { + if(substr($path,-1)=='/') { $path=substr($path,0,-1); } return is_dir($this->datadir.$path); } - public function is_file($path){ + public function is_file($path) { return is_file($this->datadir.$path); } - public function stat($path){ + public function stat($path) { return stat($this->datadir.$path); } - public function filetype($path){ + public function filetype($path) { $filetype=filetype($this->datadir.$path); - if($filetype=='link'){ + if($filetype=='link') { $filetype=filetype(realpath($this->datadir.$path)); } return $filetype; } - public function filesize($path){ - if($this->is_dir($path)){ + public function filesize($path) { + if($this->is_dir($path)) { return 0; }else{ return filesize($this->datadir.$path); } } - public function isReadable($path){ + public function isReadable($path) { return is_readable($this->datadir.$path); } - public function isUpdatable($path){ + public function isUpdatable($path) { return is_writable($this->datadir.$path); } - public function file_exists($path){ + public function file_exists($path) { return file_exists($this->datadir.$path); } - public function filectime($path){ + public function filectime($path) { return filectime($this->datadir.$path); } - public function filemtime($path){ + public function filemtime($path) { return filemtime($this->datadir.$path); } - public function touch($path, $mtime=null){ + public function touch($path, $mtime=null) { // sets the modification time of the file to the given value. // If mtime is nil the current time is set. // note that the access time of the file always changes to the current time. - if(!is_null($mtime)){ + if(!is_null($mtime)) { $result=touch( $this->datadir.$path, $mtime ); }else{ $result=touch( $this->datadir.$path); @@ -75,32 +75,32 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ return $result; } - public function file_get_contents($path){ + public function file_get_contents($path) { return file_get_contents($this->datadir.$path); } - public function file_put_contents($path,$data){ + public function file_put_contents($path,$data) { return file_put_contents($this->datadir.$path,$data); } - public function unlink($path){ + public function unlink($path) { return $this->delTree($path); } - public function rename($path1,$path2){ + public function rename($path1,$path2) { if (!$this->isUpdatable($path1)) { OC_Log::write('core','unable to rename, file is not writable : '.$path1,OC_Log::ERROR); return false; } - if(! $this->file_exists($path1)){ + if(! $this->file_exists($path1)) { OC_Log::write('core','unable to rename, file does not exists : '.$path1,OC_Log::ERROR); return false; } - if($return=rename($this->datadir.$path1,$this->datadir.$path2)){ + if($return=rename($this->datadir.$path1,$this->datadir.$path2)) { } return $return; } - public function copy($path1,$path2){ - if($this->is_dir($path2)){ - if(!$this->file_exists($path2)){ + public function copy($path1,$path2) { + if($this->is_dir($path2)) { + if(!$this->file_exists($path2)) { $this->mkdir($path2); } $source=substr($path1,strrpos($path1,'/')+1); @@ -108,9 +108,9 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ } return copy($this->datadir.$path1,$this->datadir.$path2); } - public function fopen($path,$mode){ - if($return=fopen($this->datadir.$path,$mode)){ - switch($mode){ + public function fopen($path,$mode) { + if($return=fopen($this->datadir.$path,$mode)) { + switch($mode) { case 'r': break; case 'r+': @@ -127,8 +127,8 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ return $return; } - public function getMimeType($path){ - if($this->isReadable($path)){ + public function getMimeType($path) { + if($this->isReadable($path)) { return OC_Helper::getMimeType($this->datadir.$path); }else{ return false; @@ -142,46 +142,46 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ if (!is_dir($dir) || is_link($dir)) return unlink($dir); foreach (scandir($dir) as $item) { if ($item == '.' || $item == '..') continue; - if(is_file($dir.'/'.$item)){ - if(unlink($dir.'/'.$item)){ + if(is_file($dir.'/'.$item)) { + if(unlink($dir.'/'.$item)) { } - }elseif(is_dir($dir.'/'.$item)){ - if (!$this->delTree($dirRelative. "/" . $item)){ + }elseif(is_dir($dir.'/'.$item)) { + if (!$this->delTree($dirRelative. "/" . $item)) { return false; }; } } - if($return=rmdir($dir)){ + if($return=rmdir($dir)) { } return $return; } - public function hash($path,$type,$raw=false){ + public function hash($path,$type,$raw=false) { return hash_file($type,$this->datadir.$path,$raw); } - public function free_space($path){ + public function free_space($path) { return disk_free_space($this->datadir.$path); } - public function search($query){ + public function search($query) { return $this->searchInDir($query); } - public function getLocalFile($path){ + public function getLocalFile($path) { return $this->datadir.$path; } - public function getLocalFolder($path){ + public function getLocalFolder($path) { return $this->datadir.$path; } - protected function searchInDir($query,$dir=''){ + protected function searchInDir($query,$dir='') { $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)){ + if(is_dir($this->datadir.$dir.'/'.$item)) { $files=array_merge($files,$this->searchInDir($query,$dir.'/'.$item)); } } @@ -193,7 +193,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ * @param int $time * @return bool */ - public function hasUpdated($path,$time){ + public function hasUpdated($path,$time) { return $this->filemtime($path)>$time; } } diff --git a/lib/filestorage/temporary.php b/lib/filestorage/temporary.php index 8f2373c8e95..876ba045a63 100644 --- a/lib/filestorage/temporary.php +++ b/lib/filestorage/temporary.php @@ -3,15 +3,15 @@ * local storage backnd in temporary folder for testing purpores */ class OC_Filestorage_Temporary extends OC_Filestorage_Local{ - public function __construct($arguments){ + public function __construct($arguments) { $this->datadir=OC_Helper::tmpFolder(); } - public function cleanUp(){ + public function cleanUp() { OC_Helper::rmdirr($this->datadir); } - public function __destruct(){ + public function __destruct() { $this->cleanUp(); } } diff --git a/lib/filesystem.php b/lib/filesystem.php index 01467b54c8d..92eb4fa4778 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -146,22 +146,22 @@ class OC_Filesystem{ * @param string path * @return string */ - static public function getMountPoint($path){ + static public function getMountPoint($path) { OC_Hook::emit(self::CLASSNAME,'get_mountpoint',array('path'=>$path)); - if(!$path){ + if(!$path) { $path='/'; } - if($path[0]!=='/'){ + if($path[0]!=='/') { $path='/'.$path; } $path=str_replace('//', '/',$path); $foundMountPoint=''; $mountPoints=array_keys(OC_Filesystem::$mounts); - foreach($mountPoints as $mountpoint){ - if($mountpoint==$path){ + foreach($mountPoints as $mountpoint) { + if($mountpoint==$path) { return $mountpoint; } - if(strpos($path,$mountpoint)===0 and strlen($mountpoint)>strlen($foundMountPoint)){ + if(strpos($path,$mountpoint)===0 and strlen($mountpoint)>strlen($foundMountPoint)) { $foundMountPoint=$mountpoint; } } @@ -173,7 +173,7 @@ class OC_Filesystem{ * @param string path * @return bool */ - static public function getInternalPath($path){ + static public function getInternalPath($path) { $mountPoint=self::getMountPoint($path); $internalPath=substr($path,strlen($mountPoint)); return $internalPath; @@ -183,10 +183,10 @@ class OC_Filesystem{ * @param string path * @return OC_Filestorage */ - static public function getStorage($path){ + static public function getStorage($path) { $mountpoint=self::getMountPoint($path); - if($mountpoint){ - if(!isset(OC_Filesystem::$storages[$mountpoint])){ + if($mountpoint) { + if(!isset(OC_Filesystem::$storages[$mountpoint])) { $mount=OC_Filesystem::$mounts[$mountpoint]; OC_Filesystem::$storages[$mountpoint]=OC_Filesystem::createStorage($mount['class'],$mount['arguments']); } @@ -194,27 +194,27 @@ class OC_Filesystem{ } } - static public function init($root){ - if(self::$defaultInstance){ + static public function init($root) { + if(self::$defaultInstance) { return false; } self::$defaultInstance=new OC_FilesystemView($root); //load custom mount config - if(is_file(OC::$SERVERROOT.'/config/mount.php')){ + 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){ + 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){ + 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){ + foreach($options as &$option) { $option=self::setUserVars($option); } self::mount($options['class'],$options['options'],$mountPoint); @@ -223,12 +223,12 @@ class OC_Filesystem{ } } - 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){ + 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){ + foreach($options as &$option) { $option=self::setUserVars($option); } self::mount($options['class'],$options['options'],$mountPoint); @@ -239,7 +239,7 @@ class OC_Filesystem{ $mtime=filemtime(OC::$SERVERROOT.'/config/mount.php'); $previousMTime=OC_Appconfig::getValue('files','mountconfigmtime',0); - if($mtime>$previousMTime){//mount config has changed, filecache needs to be updated + if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated OC_FileCache::clear(); OC_Appconfig::setValue('files','mountconfigmtime',$mtime); } @@ -253,7 +253,7 @@ class OC_Filesystem{ * @param string intput * @return string */ - private static function setUserVars($input){ + private static function setUserVars($input) { return str_replace('$user',OC_User::getUser(),$input); } @@ -261,14 +261,14 @@ class OC_Filesystem{ * get the default filesystem view * @return OC_FilesystemView */ - static public function getView(){ + static public function getView() { return self::$defaultInstance; } /** * tear down the filesystem, removing all storage providers */ - static public function tearDown(){ + static public function tearDown() { self::$storages=array(); } @@ -278,8 +278,8 @@ class OC_Filesystem{ * @param array arguments * @return OC_Filestorage */ - static private function createStorage($class,$arguments){ - if(class_exists($class)){ + static private function createStorage($class,$arguments) { + if(class_exists($class)) { try { return new $class($arguments); } catch (Exception $exception) { @@ -297,7 +297,7 @@ class OC_Filesystem{ * @param string fakeRoot * @return bool */ - static public function chroot($fakeRoot){ + static public function chroot($fakeRoot) { return self::$defaultInstance->chroot($fakeRoot); } @@ -307,14 +307,14 @@ class OC_Filesystem{ * * Returns path like /admin/files */ - static public function getRoot(){ + static public function getRoot() { return self::$defaultInstance->getRoot(); } /** * clear all mounts and storage backends */ - public static function clearMounts(){ + public static function clearMounts() { self::$mounts=array(); self::$storages=array(); } @@ -324,11 +324,11 @@ class OC_Filesystem{ * @param OC_Filestorage storage * @param string mountpoint */ - static public function mount($class,$arguments,$mountpoint){ - if($mountpoint[0]!='/'){ + static public function mount($class,$arguments,$mountpoint) { + if($mountpoint[0]!='/') { $mountpoint='/'.$mountpoint; } - if(substr($mountpoint,-1)!=='/'){ + if(substr($mountpoint,-1)!=='/') { $mountpoint=$mountpoint.'/'; } self::$mounts[$mountpoint]=array('class'=>$class,'arguments'=>$arguments); @@ -340,14 +340,14 @@ class OC_Filesystem{ * @param string path * @return string */ - static public function getLocalFile($path){ + static public function getLocalFile($path) { return self::$defaultInstance->getLocalFile($path); } /** * @param string path * @return string */ - static public function getLocalFolder($path){ + static public function getLocalFolder($path) { return self::$defaultInstance->getLocalFolder($path); } @@ -370,11 +370,11 @@ class OC_Filesystem{ * @param string path * @return bool */ - static public function isValidPath($path){ - if(!$path || $path[0]!=='/'){ + static public function isValidPath($path) { + if(!$path || $path[0]!=='/') { $path='/'.$path; } - if(strstr($path,'/../') || strrchr($path, '/') === '/..' ){ + if(strstr($path,'/../') || strrchr($path, '/') === '/..' ) { return false; } return true; @@ -385,7 +385,7 @@ class OC_Filesystem{ * Listens to write and rename hooks * @param array $data from hook */ - static public function isBlacklisted($data){ + static public function isBlacklisted($data) { $blacklist = array('.htaccess'); if (isset($data['path'])) { $path = $data['path']; @@ -403,46 +403,46 @@ class OC_Filesystem{ /** * following functions are equivilent to their php buildin equivilents for arguments/return values. */ - static public function mkdir($path){ + static public function mkdir($path) { return self::$defaultInstance->mkdir($path); } - static public function rmdir($path){ + static public function rmdir($path) { return self::$defaultInstance->rmdir($path); } - static public function opendir($path){ + static public function opendir($path) { return self::$defaultInstance->opendir($path); } - static public function readdir($path){ + static public function readdir($path) { return self::$defaultInstance->readdir($path); } - static public function is_dir($path){ + static public function is_dir($path) { return self::$defaultInstance->is_dir($path); } - static public function is_file($path){ + static public function is_file($path) { return self::$defaultInstance->is_file($path); } - static public function stat($path){ + static public function stat($path) { return self::$defaultInstance->stat($path); } - static public function filetype($path){ + static public function filetype($path) { return self::$defaultInstance->filetype($path); } - static public function filesize($path){ + static public function filesize($path) { return self::$defaultInstance->filesize($path); } - static public function readfile($path){ + static public function readfile($path) { return self::$defaultInstance->readfile($path); } /** * @deprecated Replaced by isReadable() as part of CRUDS */ - static public function is_readable($path){ + static public function is_readable($path) { return self::$defaultInstance->is_readable($path); } /** * @deprecated Replaced by isCreatable(), isUpdatable(), isDeletable() as part of CRUDS */ - static public function is_writable($path){ + static public function is_writable($path) { return self::$defaultInstance->is_writable($path); } static public function isCreatable($path) { @@ -460,55 +460,55 @@ class OC_Filesystem{ static public function isSharable($path) { return self::$defaultInstance->isSharable($path); } - static public function file_exists($path){ + static public function file_exists($path) { return self::$defaultInstance->file_exists($path); } - static public function filectime($path){ + static public function filectime($path) { return self::$defaultInstance->filectime($path); } - static public function filemtime($path){ + static public function filemtime($path) { return self::$defaultInstance->filemtime($path); } - static public function touch($path, $mtime=null){ + static public function touch($path, $mtime=null) { return self::$defaultInstance->touch($path, $mtime); } - static public function file_get_contents($path){ + static public function file_get_contents($path) { return self::$defaultInstance->file_get_contents($path); } - static public function file_put_contents($path,$data){ + static public function file_put_contents($path,$data) { return self::$defaultInstance->file_put_contents($path,$data); } - static public function unlink($path){ + static public function unlink($path) { return self::$defaultInstance->unlink($path); } - static public function rename($path1,$path2){ + static public function rename($path1,$path2) { return self::$defaultInstance->rename($path1,$path2); } - static public function copy($path1,$path2){ + static public function copy($path1,$path2) { return self::$defaultInstance->copy($path1,$path2); } - static public function fopen($path,$mode){ + static public function fopen($path,$mode) { return self::$defaultInstance->fopen($path,$mode); } - static public function toTmpFile($path){ + static public function toTmpFile($path) { return self::$defaultInstance->toTmpFile($path); } - static public function fromTmpFile($tmpFile,$path){ + static public function fromTmpFile($tmpFile,$path) { return self::$defaultInstance->fromTmpFile($tmpFile,$path); } - static public function getMimeType($path){ + static public function getMimeType($path) { return self::$defaultInstance->getMimeType($path); } - static public function hash($type,$path, $raw = false){ + static public function hash($type,$path, $raw = false) { return self::$defaultInstance->hash($type,$path, $raw); } - static public function free_space($path='/'){ + static public function free_space($path='/') { return self::$defaultInstance->free_space($path); } - static public function search($query){ + static public function search($query) { return OC_FileCache::search($query); } @@ -517,7 +517,7 @@ class OC_Filesystem{ * @param int $time * @return bool */ - static public function hasUpdated($path,$time){ + static public function hasUpdated($path,$time) { return self::$defaultInstance->hasUpdated($path,$time); } @@ -536,26 +536,26 @@ class OC_Filesystem{ * @param bool $stripTrailingSlash * @return string */ - public static function normalizePath($path,$stripTrailingSlash=true){ - if($path==''){ + public static function normalizePath($path,$stripTrailingSlash=true) { + if($path=='') { return '/'; } //no windows style slashes $path=str_replace('\\','/',$path); //add leading slash - if($path[0]!=='/'){ + if($path[0]!=='/') { $path='/'.$path; } //remove trainling slash - if($stripTrailingSlash and strlen($path)>1 and substr($path,-1,1)==='/'){ + if($stripTrailingSlash and strlen($path)>1 and substr($path,-1,1)==='/') { $path=substr($path,0,-1); } //remove duplicate slashes - while(strpos($path,'//')!==false){ + while(strpos($path,'//')!==false) { $path=str_replace('//','/',$path); } //normalize unicode if possible - if(class_exists('Normalizer')){ + if(class_exists('Normalizer')) { $path=Normalizer::normalize($path); } return $path; diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 461a0262560..743f9403011 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -48,10 +48,10 @@ class OC_FilesystemView { } public function getAbsolutePath($path) { - if(!$path){ + if(!$path) { $path='/'; } - if($path[0]!=='/'){ + if($path[0]!=='/') { $path='/'.$path; } return $this->fakeRoot.$path; @@ -63,7 +63,7 @@ class OC_FilesystemView { * @return bool */ public function chroot($fakeRoot) { - if(!$fakeRoot==''){ + if(!$fakeRoot=='') { if($fakeRoot[0]!=='/') { $fakeRoot='/'.$fakeRoot; } @@ -104,7 +104,7 @@ class OC_FilesystemView { return null; }else{ $path=substr($path, strlen($this->fakeRoot)); - if(strlen($path)===0){ + if(strlen($path)===0) { return '/'; }else{ return $path; @@ -177,13 +177,13 @@ class OC_FilesystemView { return $fsLocal->readdir( $handle ); } public function is_dir($path) { - if($path=='/'){ + if($path=='/') { return true; } return $this->basicOperation('is_dir', $path); } public function is_file($path) { - if($path=='/'){ + if($path=='/') { return false; } return $this->basicOperation('is_file', $path); @@ -214,13 +214,13 @@ class OC_FilesystemView { /** * @deprecated Replaced by isReadable() as part of CRUDS */ - public function is_readable($path){ + public function is_readable($path) { return $this->basicOperation('isReadable',$path); } /** * @deprecated Replaced by isCreatable(), isUpdatable(), isDeletable() as part of CRUDS */ - public function is_writable($path){ + public function is_writable($path) { return $this->basicOperation('isUpdatable',$path); } public function isCreatable($path) { @@ -239,7 +239,7 @@ class OC_FilesystemView { return $this->basicOperation('isSharable', $path); } public function file_exists($path) { - if($path=='/'){ + if($path=='/') { return true; } return $this->basicOperation('file_exists', $path); @@ -411,7 +411,7 @@ class OC_FilesystemView { if($run) { $mp1=$this->getMountPoint($path1.$postFix1); $mp2=$this->getMountPoint($path2.$postFix2); - if($mp1 == $mp2){ + if($mp1 == $mp2) { if($storage = $this->getStorage($path1.$postFix1)) { $result=$storage->copy($this->getInternalPath($path1.$postFix1), $this->getInternalPath($path2.$postFix2)); } @@ -579,7 +579,7 @@ class OC_FilesystemView { return null; } - private function runHooks($hooks,$path,$post=false){ + private function runHooks($hooks,$path,$post=false) { $prefix=($post)?'post_':''; $run=true; if(OC_Filesystem::$loaded and $this->fakeRoot==OC_Filesystem::getRoot()) { diff --git a/lib/geo.php b/lib/geo.php index 964605b1c1c..4eb785da355 100644 --- a/lib/geo.php +++ b/lib/geo.php @@ -12,11 +12,11 @@ class OC_Geo{ * @param (string) $longitude - Longitude * @return (string) $timezone - closest timezone */ - public static function timezone($latitude, $longitude){ + public static function timezone($latitude, $longitude) { $alltimezones = DateTimeZone::listIdentifiers(); $variances = array(); //calculate for all timezones the system know - foreach($alltimezones as $timezone){ + foreach($alltimezones as $timezone) { $datetimezoneobj = new DateTimeZone($timezone); $locationinformations = $datetimezoneobj->getLocation(); $latitudeoftimezone = $locationinformations['latitude']; diff --git a/lib/group.php b/lib/group.php index dd70a94eb0d..b56a4ad456c 100644 --- a/lib/group.php +++ b/lib/group.php @@ -42,8 +42,8 @@ class OC_Group { * @param string $backend The backend to use for user managment * @returns true/false */ - public static function useBackend( $backend ){ - if($backend instanceof OC_Group_Interface){ + public static function useBackend( $backend ) { + if($backend instanceof OC_Group_Interface) { self::$_usedBackends[]=$backend; } } @@ -51,7 +51,7 @@ class OC_Group { /** * remove all used backends */ - public static function clearBackends(){ + public static function clearBackends() { self::$_usedBackends=array(); } @@ -65,27 +65,27 @@ class OC_Group { * * Allowed characters in the username are: "a-z", "A-Z", "0-9" and "_.@-" */ - public static function createGroup( $gid ){ + public static function createGroup( $gid ) { // Check the name for bad characters // Allowed are: "a-z", "A-Z", "0-9" and "_.@-" - if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $gid )){ + if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $gid )) { return false; } // No empty group names! - if( !$gid ){ + if( !$gid ) { return false; } // No duplicate group names - if( in_array( $gid, self::getGroups())){ + if( in_array( $gid, self::getGroups())) { return false; } $run = true; OC_Hook::emit( "OC_Group", "pre_createGroup", array( "run" => &$run, "gid" => $gid )); - if($run){ + if($run) { //create the group in the first backend that supports creating groups - foreach(self::$_usedBackends as $backend){ + foreach(self::$_usedBackends as $backend) { if(!$backend->implementsActions(OC_GROUP_BACKEND_CREATE_GROUP)) continue; @@ -106,18 +106,18 @@ class OC_Group { * * Deletes a group and removes it from the group_user-table */ - public static function deleteGroup( $gid ){ + public static function deleteGroup( $gid ) { // Prevent users from deleting group admin - if( $gid == "admin" ){ + if( $gid == "admin" ) { return false; } $run = true; OC_Hook::emit( "OC_Group", "pre_deleteGroup", array( "run" => &$run, "gid" => $gid )); - if($run){ + if($run) { //delete the group from all backends - foreach(self::$_usedBackends as $backend){ + foreach(self::$_usedBackends as $backend) { if(!$backend->implementsActions(OC_GROUP_BACKEND_DELETE_GROUP)) continue; @@ -139,9 +139,9 @@ class OC_Group { * * Checks whether the user is member of a group or not. */ - public static function inGroup( $uid, $gid ){ - foreach(self::$_usedBackends as $backend){ - if($backend->inGroup($uid,$gid)){ + public static function inGroup( $uid, $gid ) { + foreach(self::$_usedBackends as $backend) { + if($backend->inGroup($uid,$gid)) { return true; } } @@ -156,9 +156,9 @@ class OC_Group { * * Adds a user to a group. */ - public static function addToGroup( $uid, $gid ){ + public static function addToGroup( $uid, $gid ) { // Does the group exist? - if( !OC_Group::groupExists($gid)){ + if( !OC_Group::groupExists($gid)) { return false; } @@ -166,19 +166,19 @@ class OC_Group { $run = true; OC_Hook::emit( "OC_Group", "pre_addToGroup", array( "run" => &$run, "uid" => $uid, "gid" => $gid )); - if($run){ + if($run) { $succes=false; //add the user to the all backends that have the group - foreach(self::$_usedBackends as $backend){ + foreach(self::$_usedBackends as $backend) { if(!$backend->implementsActions(OC_GROUP_BACKEND_ADD_TO_GROUP)) continue; - if($backend->groupExists($gid)){ + if($backend->groupExists($gid)) { $succes|=$backend->addToGroup($uid, $gid); } } - if($succes){ + if($succes) { OC_Hook::emit( "OC_User", "post_addToGroup", array( "uid" => $uid, "gid" => $gid )); } return $succes; @@ -195,13 +195,13 @@ class OC_Group { * * removes the user from a group. */ - public static function removeFromGroup( $uid, $gid ){ + public static function removeFromGroup( $uid, $gid ) { $run = true; OC_Hook::emit( "OC_Group", "pre_removeFromGroup", array( "run" => &$run, "uid" => $uid, "gid" => $gid )); - if($run){ + if($run) { //remove the user from the all backends that have the group - foreach(self::$_usedBackends as $backend){ + foreach(self::$_usedBackends as $backend) { if(!$backend->implementsActions(OC_GROUP_BACKEND_REMOVE_FROM_GOUP)) continue; @@ -222,9 +222,9 @@ class OC_Group { * This function fetches all groups a user belongs to. It does not check * if the user exists at all. */ - public static function getUserGroups( $uid ){ + public static function getUserGroups( $uid ) { $groups=array(); - foreach(self::$_usedBackends as $backend){ + foreach(self::$_usedBackends as $backend) { $groups=array_merge($backend->getUserGroups($uid),$groups); } asort($groups); @@ -251,9 +251,9 @@ class OC_Group { * @param string $gid * @return bool */ - public static function groupExists($gid){ - foreach(self::$_usedBackends as $backend){ - if ($backend->groupExists($gid)){ + public static function groupExists($gid) { + foreach(self::$_usedBackends as $backend) { + if ($backend->groupExists($gid)) { return true; } } @@ -266,7 +266,7 @@ class OC_Group { */ public static function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { $users=array(); - foreach(self::$_usedBackends as $backend){ + foreach(self::$_usedBackends as $backend) { $users = array_merge($backend->usersInGroup($gid, $search, $limit, $offset), $users); } return $users; diff --git a/lib/group/backend.php b/lib/group/backend.php index 5969986c652..1ba34c940cf 100644 --- a/lib/group/backend.php +++ b/lib/group/backend.php @@ -52,9 +52,9 @@ abstract class OC_Group_Backend implements OC_Group_Interface { * Returns the supported actions as int to be * compared with OC_USER_BACKEND_CREATE_USER etc. */ - public function getSupportedActions(){ + public function getSupportedActions() { $actions = 0; - foreach($this->possibleActions AS $action => $methodName){ + foreach($this->possibleActions AS $action => $methodName) { if(method_exists($this, $methodName)) { $actions |= $action; } @@ -71,7 +71,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface { * Returns the supported actions as int to be * compared with OC_GROUP_BACKEND_CREATE_GROUP etc. */ - public function implementsActions($actions){ + public function implementsActions($actions) { return (bool)($this->getSupportedActions() & $actions); } @@ -83,7 +83,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface { * * Checks whether the user is member of a group or not. */ - public function inGroup($uid, $gid){ + public function inGroup($uid, $gid) { return in_array($gid, $this->getUserGroups($uid)); } @@ -95,7 +95,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface { * This function fetches all groups a user belongs to. It does not check * if the user exists at all. */ - public function getUserGroups($uid){ + public function getUserGroups($uid) { return array(); } @@ -115,7 +115,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface { * @param string $gid * @return bool */ - public function groupExists($gid){ + public function groupExists($gid) { return in_array($gid, $this->getGroups($gid, 1)); } diff --git a/lib/group/database.php b/lib/group/database.php index 52608b2db73..f3012563acf 100644 --- a/lib/group/database.php +++ b/lib/group/database.php @@ -50,12 +50,12 @@ class OC_Group_Database extends OC_Group_Backend { * Trys to create a new group. If the group name already exists, false will * be returned. */ - public function createGroup( $gid ){ + public function createGroup( $gid ) { // Check for existence $stmt = OC_DB::prepare( "SELECT `gid` FROM `*PREFIX*groups` WHERE `gid` = ?" ); $result = $stmt->execute( array( $gid )); - if( $result->fetchRow() ){ + if( $result->fetchRow() ) { // Can not add an existing group return false; } @@ -75,7 +75,7 @@ class OC_Group_Database extends OC_Group_Backend { * * Deletes a group and removes it from the group_user-table */ - public function deleteGroup( $gid ){ + public function deleteGroup( $gid ) { // Delete the group $stmt = OC_DB::prepare( "DELETE FROM `*PREFIX*groups` WHERE `gid` = ?" ); $result = $stmt->execute( array( $gid )); @@ -95,7 +95,7 @@ class OC_Group_Database extends OC_Group_Backend { * * Checks whether the user is member of a group or not. */ - public function inGroup( $uid, $gid ){ + public function inGroup( $uid, $gid ) { // check $stmt = OC_DB::prepare( "SELECT `uid` FROM `*PREFIX*group_user` WHERE `gid` = ? AND `uid` = ?" ); $result = $stmt->execute( array( $gid, $uid )); @@ -111,9 +111,9 @@ class OC_Group_Database extends OC_Group_Backend { * * Adds a user to a group. */ - public function addToGroup( $uid, $gid ){ + public function addToGroup( $uid, $gid ) { // No duplicate entries! - if( !$this->inGroup( $uid, $gid )){ + if( !$this->inGroup( $uid, $gid )) { $stmt = OC_DB::prepare( "INSERT INTO `*PREFIX*group_user` ( `uid`, `gid` ) VALUES( ?, ? )" ); $stmt->execute( array( $uid, $gid )); return true; @@ -130,7 +130,7 @@ class OC_Group_Database extends OC_Group_Backend { * * removes the user from a group. */ - public function removeFromGroup( $uid, $gid ){ + public function removeFromGroup( $uid, $gid ) { $stmt = OC_DB::prepare( "DELETE FROM `*PREFIX*group_user` WHERE `uid` = ? AND `gid` = ?" ); $stmt->execute( array( $uid, $gid )); @@ -145,13 +145,13 @@ class OC_Group_Database extends OC_Group_Backend { * This function fetches all groups a user belongs to. It does not check * if the user exists at all. */ - public function getUserGroups( $uid ){ + public function getUserGroups( $uid ) { // No magic! $stmt = OC_DB::prepare( "SELECT `gid` FROM `*PREFIX*group_user` WHERE `uid` = ?" ); $result = $stmt->execute( array( $uid )); $groups = array(); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $groups[] = $row["gid"]; } diff --git a/lib/group/dummy.php b/lib/group/dummy.php index 51eca28f3f4..8116dcbd675 100644 --- a/lib/group/dummy.php +++ b/lib/group/dummy.php @@ -34,8 +34,8 @@ class OC_Group_Dummy extends OC_Group_Backend { * Trys to create a new group. If the group name already exists, false will * be returned. */ - public function createGroup($gid){ - if(!isset($this->groups[$gid])){ + public function createGroup($gid) { + if(!isset($this->groups[$gid])) { $this->groups[$gid]=array(); return true; }else{ @@ -50,8 +50,8 @@ class OC_Group_Dummy extends OC_Group_Backend { * * Deletes a group and removes it from the group_user-table */ - public function deleteGroup($gid){ - if(isset($this->groups[$gid])){ + public function deleteGroup($gid) { + if(isset($this->groups[$gid])) { unset($this->groups[$gid]); return true; }else{ @@ -67,8 +67,8 @@ class OC_Group_Dummy extends OC_Group_Backend { * * Checks whether the user is member of a group or not. */ - public function inGroup($uid, $gid){ - if(isset($this->groups[$gid])){ + public function inGroup($uid, $gid) { + if(isset($this->groups[$gid])) { return (array_search($uid,$this->groups[$gid])!==false); }else{ return false; @@ -83,9 +83,9 @@ class OC_Group_Dummy extends OC_Group_Backend { * * Adds a user to a group. */ - public function addToGroup($uid, $gid){ - if(isset($this->groups[$gid])){ - if(array_search($uid,$this->groups[$gid])===false){ + public function addToGroup($uid, $gid) { + if(isset($this->groups[$gid])) { + if(array_search($uid,$this->groups[$gid])===false) { $this->groups[$gid][]=$uid; return true; }else{ @@ -104,9 +104,9 @@ class OC_Group_Dummy extends OC_Group_Backend { * * removes the user from a group. */ - public function removeFromGroup($uid,$gid){ - if(isset($this->groups[$gid])){ - if(($index=array_search($uid,$this->groups[$gid]))!==false){ + public function removeFromGroup($uid,$gid) { + if(isset($this->groups[$gid])) { + if(($index=array_search($uid,$this->groups[$gid]))!==false) { unset($this->groups[$gid][$index]); }else{ return false; @@ -124,11 +124,11 @@ class OC_Group_Dummy extends OC_Group_Backend { * This function fetches all groups a user belongs to. It does not check * if the user exists at all. */ - public function getUserGroups($uid){ + public function getUserGroups($uid) { $groups=array(); $allGroups=array_keys($this->groups); - foreach($allGroups as $group){ - if($this->inGroup($uid,$group)){ + foreach($allGroups as $group) { + if($this->inGroup($uid,$group)) { $groups[]=$group; } } @@ -150,7 +150,7 @@ class OC_Group_Dummy extends OC_Group_Backend { * @returns array with user ids */ public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { - if(isset($this->groups[$gid])){ + if(isset($this->groups[$gid])) { return $this->groups[$gid]; }else{ return array(); diff --git a/lib/helper.php b/lib/helper.php index ea43304da5f..70b2f78862b 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -37,12 +37,12 @@ class OC_Helper { * * Returns a url to the given app and file. */ - public static function linkTo( $app, $file, $args = array() ){ - if( $app != '' ){ + public static function linkTo( $app, $file, $args = array() ) { + if( $app != '' ) { $app_path = OC_App::getAppPath($app); // Check if the app is in the app folder - if( $app_path && file_exists( $app_path.'/'.$file )){ - if(substr($file, -3) == 'php' || substr($file, -3) == 'css'){ + if( $app_path && file_exists( $app_path.'/'.$file )) { + if(substr($file, -3) == 'php' || substr($file, -3) == 'css') { $urlLinkTo = OC::$WEBROOT . '/?app=' . $app; $urlLinkTo .= ($file!='index.php')?'&getfile=' . urlencode($file):''; }else{ @@ -54,7 +54,7 @@ class OC_Helper { } } else{ - if( file_exists( OC::$SERVERROOT . '/core/'. $file )){ + if( file_exists( OC::$SERVERROOT . '/core/'. $file )) { $urlLinkTo = OC::$WEBROOT . '/core/'.$file; } else{ @@ -125,22 +125,22 @@ class OC_Helper { * * Returns the path to the image. */ - public static function imagePath( $app, $image ){ + public static function imagePath( $app, $image ) { // Read the selected theme from the config file $theme=OC_Config::getValue( "theme" ); // Check if the app is in the app folder - if( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/img/$image" )){ + if( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/img/$image" )) { return OC::$WEBROOT."/themes/$theme/apps/$app/img/$image"; - }elseif( file_exists(OC_App::getAppPath($app)."/img/$image" )){ + }elseif( file_exists(OC_App::getAppPath($app)."/img/$image" )) { return OC_App::getAppWebPath($app)."/img/$image"; - }elseif( !empty( $app ) and file_exists( OC::$SERVERROOT."/themes/$theme/$app/img/$image" )){ + }elseif( !empty( $app ) and file_exists( OC::$SERVERROOT."/themes/$theme/$app/img/$image" )) { return OC::$WEBROOT."/themes/$theme/$app/img/$image"; - }elseif( !empty( $app ) and file_exists( OC::$SERVERROOT."/$app/img/$image" )){ + }elseif( !empty( $app ) and file_exists( OC::$SERVERROOT."/$app/img/$image" )) { return OC::$WEBROOT."/$app/img/$image"; - }elseif( file_exists( OC::$SERVERROOT."/themes/$theme/core/img/$image" )){ + }elseif( file_exists( OC::$SERVERROOT."/themes/$theme/core/img/$image" )) { return OC::$WEBROOT."/themes/$theme/core/img/$image"; - }elseif( file_exists( OC::$SERVERROOT."/core/img/$image" )){ + }elseif( file_exists( OC::$SERVERROOT."/core/img/$image" )) { return OC::$WEBROOT."/core/img/$image"; }else{ echo('image not found: image:'.$image.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); @@ -155,26 +155,26 @@ class OC_Helper { * * Returns the path to the image of this file type. */ - public static function mimetypeIcon( $mimetype ){ + public static function mimetypeIcon( $mimetype ) { $alias=array('application/xml'=>'code/xml'); - if(isset($alias[$mimetype])){ + if(isset($alias[$mimetype])) { $mimetype=$alias[$mimetype]; } // Replace slash with a minus $mimetype = str_replace( "/", "-", $mimetype ); // Is it a dir? - if( $mimetype == "dir" ){ + if( $mimetype == "dir" ) { return OC::$WEBROOT."/core/img/filetypes/folder.png"; } // Icon exists? - if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.png" )){ + if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.png" )) { return OC::$WEBROOT."/core/img/filetypes/$mimetype.png"; } //try only the first part of the filetype $mimetype=substr($mimetype,0,strpos($mimetype,'-')); - if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.png" )){ + if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.png" )) { return OC::$WEBROOT."/core/img/filetypes/$mimetype.png"; } else{ @@ -189,16 +189,16 @@ class OC_Helper { * * Makes 2048 to 2 kB. */ - public static function humanFileSize( $bytes ){ - if( $bytes < 1024 ){ + public static function humanFileSize( $bytes ) { + if( $bytes < 1024 ) { return "$bytes B"; } $bytes = round( $bytes / 1024, 1 ); - if( $bytes < 1024 ){ + if( $bytes < 1024 ) { return "$bytes kB"; } $bytes = round( $bytes / 1024, 1 ); - if( $bytes < 1024 ){ + if( $bytes < 1024 ) { return "$bytes MB"; } @@ -216,7 +216,7 @@ class OC_Helper { * * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418 */ - public static function computerFileSize( $str ){ + public static function computerFileSize( $str ) { $bytes = 0; $str=strtolower($str); @@ -280,17 +280,17 @@ class OC_Helper { * */ static function copyr($src, $dest) { - if(is_dir($src)){ - if(!is_dir($dest)){ + if(is_dir($src)) { + if(!is_dir($dest)) { mkdir($dest); } $files = scandir($src); - foreach ($files as $file){ - if ($file != "." && $file != ".."){ + foreach ($files as $file) { + if ($file != "." && $file != "..") { self::copyr("$src/$file", "$dest/$file"); } } - }elseif(file_exists($src)){ + }elseif(file_exists($src)) { copy($src, $dest); } } @@ -303,13 +303,13 @@ class OC_Helper { static function rmdirr($dir) { if(is_dir($dir)) { $files=scandir($dir); - foreach($files as $file){ - if ($file != "." && $file != ".."){ + foreach($files as $file) { + if ($file != "." && $file != "..") { self::rmdirr("$dir/$file"); } } rmdir($dir); - }elseif(file_exists($dir)){ + }elseif(file_exists($dir)) { unlink($dir); } if(file_exists($dir)) { @@ -323,7 +323,7 @@ class OC_Helper { * @return string * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead */ - static function getMimeType($path){ + static function getMimeType($path) { $isWrapped=(strpos($path,'://')!==false) and (substr($path,0,7)=='file://'); if (@is_dir($path)) { @@ -331,9 +331,9 @@ class OC_Helper { return "httpd/unix-directory"; } - if(strpos($path,'.')){ + if(strpos($path,'.')) { //try to guess the type by the file extension - if(!self::$mimetypes || 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), ".")); @@ -343,9 +343,9 @@ class OC_Helper { $mimeType='application/octet-stream'; } - if($mimeType=='application/octet-stream' and function_exists('finfo_open') and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)){ + 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){ + if($info) { $mimeType=substr($info,0,strpos($info,';')); } finfo_close($finfo); @@ -379,8 +379,8 @@ class OC_Helper { * @param string data * @return string */ - static function getStringMimeType($data){ - if(function_exists('finfo_open') and function_exists('finfo_file')){ + 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{ @@ -429,7 +429,7 @@ class OC_Helper { * @param string optional search path, defaults to $PATH * @return bool true if executable program found in path */ - public static function canExecute($name, $path = false){ + public static function canExecute($name, $path = false) { // path defaults to PATH from environment if not set if ($path === false) { $path = getenv("PATH"); @@ -473,12 +473,12 @@ class OC_Helper { * @param resource target * @return int the number of bytes copied */ - public static function streamCopy($source,$target){ - if(!$source or !$target){ + public static function streamCopy($source,$target) { + if(!$source or !$target) { return false; } $count=0; - while(!feof($source)){ + while(!feof($source)) { $count+=fwrite($target,fread($source,8192)); } return $count; @@ -491,7 +491,7 @@ class OC_Helper { * * temporary files are automatically cleaned up after the script is finished */ - public static function tmpFile($postfix=''){ + public static function tmpFile($postfix='') { $file=get_temp_dir().'/'.md5(time().rand()).$postfix; $fh=fopen($file,'w'); fclose($fh); @@ -505,7 +505,7 @@ class OC_Helper { * * temporary files are automatically cleaned up after the script is finished */ - public static function tmpFolder(){ + public static function tmpFolder() { $path=get_temp_dir().'/'.md5(time().rand()); mkdir($path); self::$tmpFiles[]=$path; @@ -515,9 +515,9 @@ class OC_Helper { /** * remove all files created by self::tmpFile */ - public static function cleanTmp(){ + public static function cleanTmp() { $leftoversFile=get_temp_dir().'/oc-not-deleted'; - if(file_exists($leftoversFile)){ + if(file_exists($leftoversFile)) { $leftovers=file($leftoversFile); foreach($leftovers as $file) { self::rmdirr($file); @@ -525,8 +525,8 @@ class OC_Helper { unlink($leftoversFile); } - foreach(self::$tmpFiles as $file){ - if(file_exists($file)){ + foreach(self::$tmpFiles as $file) { + if(file_exists($file)) { if(!self::rmdirr($file)) { file_put_contents($leftoversFile, $file."\n", FILE_APPEND); } @@ -541,8 +541,8 @@ class OC_Helper { * @param $filename * @return string */ - public static function buildNotExistingFileName($path, $filename){ - if($path==='/'){ + public static function buildNotExistingFileName($path, $filename) { + if($path==='/') { $path=''; } if ($pos = strrpos($filename, '.')) { @@ -571,21 +571,21 @@ class OC_Helper { * @param $parent * @return bool */ - public static function issubdirectory($sub, $parent){ - if($sub == null || $sub == '' || $parent == null || $parent == ''){ + public static function issubdirectory($sub, $parent) { + if($sub == null || $sub == '' || $parent == null || $parent == '') { return false; } $realpath_sub = realpath($sub); $realpath_parent = realpath($parent); - if(($realpath_sub == false && substr_count($realpath_sub, './') != 0) || ($realpath_parent == false && substr_count($realpath_parent, './') != 0)){ //it checks for both ./ and ../ + if(($realpath_sub == false && substr_count($realpath_sub, './') != 0) || ($realpath_parent == false && substr_count($realpath_parent, './') != 0)) { //it checks for both ./ and ../ return false; } - if($realpath_sub && $realpath_sub != '' && $realpath_parent && $realpath_parent != ''){ - if(substr($realpath_sub, 0, strlen($realpath_parent)) == $realpath_parent){ + if($realpath_sub && $realpath_sub != '' && $realpath_parent && $realpath_parent != '') { + if(substr($realpath_sub, 0, strlen($realpath_parent)) == $realpath_parent) { return true; } }else{ - if(substr($sub, 0, strlen($parent)) == $parent){ + if(substr($sub, 0, strlen($parent)) == $parent) { return true; } } @@ -610,7 +610,7 @@ class OC_Helper { * based on http://www.php.net/manual/en/function.array-change-key-case.php#107715 * */ - public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8'){ + public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') { $case = ($case != MB_CASE_UPPER) ? MB_CASE_LOWER : MB_CASE_UPPER; $ret = array(); foreach ($input as $k => $v) { diff --git a/lib/hook.php b/lib/hook.php index ee390d6cd5a..1bf80f604f6 100644 --- a/lib/hook.php +++ b/lib/hook.php @@ -19,12 +19,12 @@ class OC_Hook{ * * TODO: write example */ - static public function connect( $signalclass, $signalname, $slotclass, $slotname ){ + static public function connect( $signalclass, $signalname, $slotclass, $slotname ) { // Create the data structure - if( !array_key_exists( $signalclass, self::$registered )){ + if( !array_key_exists( $signalclass, self::$registered )) { self::$registered[$signalclass] = array(); } - if( !array_key_exists( $signalname, self::$registered[$signalclass] )){ + if( !array_key_exists( $signalname, self::$registered[$signalclass] )) { self::$registered[$signalclass][$signalname] = array(); } @@ -48,17 +48,17 @@ class OC_Hook{ * * TODO: write example */ - static public function emit( $signalclass, $signalname, $params = array()){ + static public function emit( $signalclass, $signalname, $params = array()) { // Return false if there are no slots - if( !array_key_exists( $signalclass, self::$registered )){ + if( !array_key_exists( $signalclass, self::$registered )) { return false; } - if( !array_key_exists( $signalname, self::$registered[$signalclass] )){ + if( !array_key_exists( $signalname, self::$registered[$signalclass] )) { return false; } // Call all slots - foreach( self::$registered[$signalclass][$signalname] as $i ){ + foreach( self::$registered[$signalclass][$signalname] as $i ) { call_user_func( array( $i["class"], $i["name"] ), $params ); } @@ -71,9 +71,9 @@ class OC_Hook{ * @param string signalclass * @param string signalname */ - static public function clear($signalclass='', $signalname=''){ - if($signalclass){ - if($signalname){ + static public function clear($signalclass='', $signalname='') { + if($signalclass) { + if($signalname) { self::$registered[$signalclass][$signalname]=array(); }else{ self::$registered[$signalclass]=array(); diff --git a/lib/image.php b/lib/image.php index e87cf9e16d9..f4b3c2cc071 100644 --- a/lib/image.php +++ b/lib/image.php @@ -262,7 +262,7 @@ class OC_Image { * @returns The orientation or -1 if no EXIF data is available. */ public function getOrientation() { - if(!is_callable('exif_read_data')){ + if(!is_callable('exif_read_data')) { OC_Log::write('core','OC_Image->fixOrientation() Exif module not enabled.', OC_Log::DEBUG); return -1; } @@ -612,7 +612,7 @@ class OC_Image { $y = ($height_orig/2) - ($height/2); $x = 0; } - if($size>0){ + if($size>0) { $targetWidth=$size; $targetHeight=$size; }else{ @@ -666,14 +666,14 @@ class OC_Image { return true; } - public function destroy(){ - if($this->valid()){ + public function destroy() { + if($this->valid()) { imagedestroy($this->resource); } $this->resource=null; } - public function __destruct(){ + public function __destruct() { $this->destroy(); } } diff --git a/lib/installer.php b/lib/installer.php index b8a3226aa0b..9135c60fc05 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -55,22 +55,22 @@ class OC_Installer{ * It is the task of oc_app_install to create the tables and do whatever is * needed to get the app working. */ - public static function installApp( $data = array()){ - if(!isset($data['source'])){ + public static function installApp( $data = array()) { + if(!isset($data['source'])) { OC_Log::write('core','No source specified when installing app',OC_Log::ERROR); return false; } //download the file if necesary - if($data['source']=='http'){ + if($data['source']=='http') { $path=OC_Helper::tmpFile(); - if(!isset($data['href'])){ + if(!isset($data['href'])) { OC_Log::write('core','No href specified when installing app from http',OC_Log::ERROR); return false; } copy($data['href'],$path); }else{ - if(!isset($data['path'])){ + if(!isset($data['path'])) { OC_Log::write('core','No path specified when installing app from local file',OC_Log::ERROR); return false; } @@ -79,10 +79,10 @@ class OC_Installer{ //detect the archive type $mime=OC_Helper::getMimeType($path); - if($mime=='application/zip'){ + if($mime=='application/zip') { rename($path,$path.'.zip'); $path.='.zip'; - }elseif($mime=='application/x-gzip'){ + }elseif($mime=='application/x-gzip') { rename($path,$path.'.tgz'); $path.='.tgz'; }else{ @@ -94,40 +94,40 @@ class OC_Installer{ $extractDir=OC_Helper::tmpFolder(); OC_Helper::rmdirr($extractDir); mkdir($extractDir); - if($archive=OC_Archive::open($path)){ + if($archive=OC_Archive::open($path)) { $archive->extract($extractDir); } else { OC_Log::write('core','Failed to open archive when installing app',OC_Log::ERROR); OC_Helper::rmdirr($extractDir); - if($data['source']=='http'){ + if($data['source']=='http') { unlink($path); } return false; } //load the info.xml file of the app - if(!is_file($extractDir.'/appinfo/info.xml')){ + if(!is_file($extractDir.'/appinfo/info.xml')) { //try to find it in a subdir $dh=opendir($extractDir); - while($folder=readdir($dh)){ - if($folder[0]!='.' and is_dir($extractDir.'/'.$folder)){ - if(is_file($extractDir.'/'.$folder.'/appinfo/info.xml')){ + while($folder=readdir($dh)) { + if($folder[0]!='.' and is_dir($extractDir.'/'.$folder)) { + if(is_file($extractDir.'/'.$folder.'/appinfo/info.xml')) { $extractDir.='/'.$folder; } } } } - if(!is_file($extractDir.'/appinfo/info.xml')){ + if(!is_file($extractDir.'/appinfo/info.xml')) { OC_Log::write('core','App does not provide an info.xml file',OC_Log::ERROR); OC_Helper::rmdirr($extractDir); - if($data['source']=='http'){ + if($data['source']=='http') { unlink($path); } return false; } $info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml',true); // check the code for not allowed calls - if(!OC_Installer::checkCode($info['id'],$extractDir)){ + 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); OC_Helper::rmdirr($extractDir); return false; @@ -135,17 +135,17 @@ class OC_Installer{ // check if the app is compatible with this version of ownCloud $version=OC_Util::getVersion(); - if(!isset($info['require']) or ($version[0]>$info['require'])){ + if(!isset($info['require']) or ($version[0]>$info['require'])) { OC_Log::write('core','App can\'t be installed because it is not compatible with this version of ownCloud',OC_Log::ERROR); OC_Helper::rmdirr($extractDir); return false; } //check if an app with the same id is already installed - if(self::isInstalled( $info['id'] )){ + if(self::isInstalled( $info['id'] )) { OC_Log::write('core','App already installed',OC_Log::WARN); OC_Helper::rmdirr($extractDir); - if($data['source']=='http'){ + if($data['source']=='http') { unlink($path); } return false; @@ -153,24 +153,24 @@ class OC_Installer{ $basedir=OC_App::getInstallPath().'/'.$info['id']; //check if the destination directory already exists - if(is_dir($basedir)){ + if(is_dir($basedir)) { OC_Log::write('core','App directory already exists',OC_Log::WARN); OC_Helper::rmdirr($extractDir); - if($data['source']=='http'){ + if($data['source']=='http') { unlink($path); } return false; } - if(isset($data['pretent']) and $data['pretent']==true){ + if(isset($data['pretent']) and $data['pretent']==true) { return false; } //copy the app to the correct place - if(@!mkdir($basedir)){ + if(@!mkdir($basedir)) { OC_Log::write('core','Can\'t create app folder. Please fix permissions. ('.$basedir.')',OC_Log::ERROR); OC_Helper::rmdirr($extractDir); - if($data['source']=='http'){ + if($data['source']=='http') { unlink($path); } return false; @@ -181,12 +181,12 @@ class OC_Installer{ OC_Helper::rmdirr($extractDir); //install the database - if(is_file($basedir.'/appinfo/database.xml')){ + if(is_file($basedir.'/appinfo/database.xml')) { OC_DB::createDbFromStructure($basedir.'/appinfo/database.xml'); } //run appinfo/install.php - if((!isset($data['noinstall']) or $data['noinstall']==false) and file_exists($basedir.'/appinfo/install.php')){ + if((!isset($data['noinstall']) or $data['noinstall']==false) and file_exists($basedir.'/appinfo/install.php')) { include($basedir.'/appinfo/install.php'); } @@ -195,10 +195,10 @@ class OC_Installer{ OC_Appconfig::setValue($info['id'],'enabled','no'); //set remote/public handelers - foreach($info['remote'] as $name=>$path){ + foreach($info['remote'] as $name=>$path) { OCP\CONFIG::setAppValue('core', 'remote_'.$name, $info['id'].'/'.$path); } - foreach($info['public'] as $name=>$path){ + foreach($info['public'] as $name=>$path) { OCP\CONFIG::setAppValue('core', 'public_'.$name, $info['id'].'/'.$path); } @@ -214,9 +214,9 @@ class OC_Installer{ * * Checks whether or not an app is installed, i.e. registered in apps table. */ - public static function isInstalled( $app ){ + public static function isInstalled( $app ) { - if( null == OC_Appconfig::getValue( $app, "installed_version" )){ + if( null == OC_Appconfig::getValue( $app, "installed_version" )) { return false; } @@ -250,7 +250,7 @@ class OC_Installer{ * * upgrade.php can determine the current installed version of the app using "OC_Appconfig::getValue($appid,'installed_version')" */ - public static function upgradeApp( $data = array()){ + public static function upgradeApp( $data = array()) { // TODO: write function return true; } @@ -275,7 +275,7 @@ class OC_Installer{ * The function will not delete preferences, tables and the configuration, * this has to be done by the function oc_app_uninstall(). */ - public static function removeApp( $name, $options = array()){ + public static function removeApp( $name, $options = array()) { // TODO: write function return true; } @@ -285,16 +285,16 @@ class OC_Installer{ * * This function installs all apps found in the 'apps' directory that should be enabled by default; */ - public static function installShippedApps(){ + public static function installShippedApps() { foreach(OC::$APPSROOTS as $app_dir) { - if($dir = opendir( $app_dir['path'] )){ - while( false !== ( $filename = readdir( $dir ))){ - if( substr( $filename, 0, 1 ) != '.' and is_dir($app_dir['path']."/$filename") ){ - if( file_exists( $app_dir['path']."/$filename/appinfo/app.php" )){ - if(!OC_Installer::isInstalled($filename)){ + if($dir = opendir( $app_dir['path'] )) { + while( false !== ( $filename = readdir( $dir ))) { + if( substr( $filename, 0, 1 ) != '.' and is_dir($app_dir['path']."/$filename") ) { + if( file_exists( $app_dir['path']."/$filename/appinfo/app.php" )) { + if(!OC_Installer::isInstalled($filename)) { $info=OC_App::getAppInfo($filename); $enabled = isset($info['default_enable']); - if( $enabled ){ + if( $enabled ) { OC_Installer::installShippedApp($filename); OC_Appconfig::setValue($filename,'enabled','yes'); } @@ -312,24 +312,24 @@ class OC_Installer{ * @param string $app id of the app to install * @returns array see OC_App::getAppInfo */ - public static function installShippedApp($app){ + public static function installShippedApp($app) { //install the database - if(is_file(OC_App::getAppPath($app)."/appinfo/database.xml")){ + if(is_file(OC_App::getAppPath($app)."/appinfo/database.xml")) { OC_DB::createDbFromStructure(OC_App::getAppPath($app)."/appinfo/database.xml"); } //run appinfo/install.php - if(is_file(OC_App::getAppPath($app)."/appinfo/install.php")){ + if(is_file(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)); //set remote/public handelers - foreach($info['remote'] as $name=>$path){ + foreach($info['remote'] as $name=>$path) { OCP\CONFIG::setAppValue('core', 'remote_'.$name, $app.'/'.$path); } - foreach($info['public'] as $name=>$path){ + foreach($info['public'] as $name=>$path) { OCP\CONFIG::setAppValue('core', 'public_'.$name, $app.'/'.$path); } @@ -344,7 +344,7 @@ class OC_Installer{ * @param string $folder the folder of the app to check * @returns true for app is o.k. and false for app is not o.k. */ - public static function checkCode($appname,$folder){ + public static function checkCode($appname,$folder) { $blacklist=array( 'exec(', @@ -355,7 +355,7 @@ class OC_Installer{ ); // is the code checker enabled? - if(OC_Config::getValue('appcodechecker', false)){ + if(OC_Config::getValue('appcodechecker', false)) { // check if grep is installed $grep = exec('which grep'); diff --git a/lib/json.php b/lib/json.php index 12442cc83d7..518c3c87c49 100644 --- a/lib/json.php +++ b/lib/json.php @@ -11,8 +11,8 @@ class OC_JSON{ /** * set Content-Type header to jsonrequest */ - public static function setContentTypeHeader($type='application/json'){ - if (!self::$send_content_type_header){ + public static function setContentTypeHeader($type='application/json') { + if (!self::$send_content_type_header) { // We send json data header( 'Content-Type: '.$type ); self::$send_content_type_header = true; @@ -22,8 +22,8 @@ class OC_JSON{ /** * Check if the app is enabled, send json error msg if not */ - public static function checkAppEnabled($app){ - if( !OC_App::isEnabled($app)){ + public static function checkAppEnabled($app) { + if( !OC_App::isEnabled($app)) { $l = OC_L10N::get('lib'); self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled') ))); exit(); @@ -33,8 +33,8 @@ class OC_JSON{ /** * Check if the user is logged in, send json error msg if not */ - public static function checkLoggedIn(){ - if( !OC_User::isLoggedIn()){ + public static function checkLoggedIn() { + if( !OC_User::isLoggedIn()) { $l = OC_L10N::get('lib'); self::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); @@ -45,8 +45,8 @@ class OC_JSON{ * @brief Check an ajax get/post call if the request token is valid. * @return json Error msg if not valid. */ - public static function callCheck(){ - if( !OC_Util::isCallRegistered()){ + public static function callCheck() { + if( !OC_Util::isCallRegistered()) { $l = OC_L10N::get('lib'); self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.') ))); exit(); @@ -56,9 +56,9 @@ class OC_JSON{ /** * Check if the user is a admin, send json error msg if not */ - public static function checkAdminUser(){ + public static function checkAdminUser() { self::checkLoggedIn(); - if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )){ + if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )) { $l = OC_L10N::get('lib'); self::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); @@ -68,9 +68,9 @@ class OC_JSON{ /** * Check if the user is a subadmin, send json error msg if not */ - public static function checkSubAdminUser(){ + public static function checkSubAdminUser() { self::checkLoggedIn(); - if(!OC_Group::inGroup(OC_User::getUser(),'admin') && !OC_SubAdmin::isSubAdmin(OC_User::getUser())){ + if(!OC_Group::inGroup(OC_User::getUser(),'admin') && !OC_SubAdmin::isSubAdmin(OC_User::getUser())) { $l = OC_L10N::get('lib'); self::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); @@ -80,7 +80,7 @@ class OC_JSON{ /** * Send json error msg */ - public static function error($data = array()){ + public static function error($data = array()) { $data['status'] = 'error'; self::encodedPrint($data); } @@ -88,7 +88,7 @@ class OC_JSON{ /** * Send json success msg */ - public static function success($data = array()){ + public static function success($data = array()) { $data['status'] = 'success'; self::encodedPrint($data); } @@ -96,7 +96,7 @@ class OC_JSON{ /** * Convert OC_L10N_String to string, for use in json encodings */ - protected static function to_string(&$value){ + protected static function to_string(&$value) { if ($value instanceof OC_L10N_String) { $value = (string)$value; } @@ -105,10 +105,10 @@ class OC_JSON{ /** * Encode and print $data in json format */ - public static function encodedPrint($data,$setContentType=true){ + public static function encodedPrint($data,$setContentType=true) { // Disable mimesniffing, don't move this to setContentTypeHeader! header( 'X-Content-Type-Options: nosniff' ); - if($setContentType){ + if($setContentType) { self::setContentTypeHeader(); } array_walk_recursive($data, array('OC_JSON', 'to_string')); diff --git a/lib/l10n.php b/lib/l10n.php index f8274126136..90877cbd747 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -66,9 +66,9 @@ class OC_L10N{ * get an L10N instance * @return OC_L10N */ - public static function get($app,$lang=null){ - if(is_null($lang)){ - if(!isset(self::$instances[$app])){ + public static function get($app,$lang=null) { + if(is_null($lang)) { + if(!isset(self::$instances[$app])) { self::$instances[$app]=new OC_L10N($app); } return self::$instances[$app]; @@ -86,12 +86,12 @@ class OC_L10N{ * If language is not set, the constructor tries to find the right * language. */ - public function __construct($app, $lang = null){ + public function __construct($app, $lang = null) { $this->app = $app; $this->lang = $lang; } - protected function init(){ + protected function init() { if ($this->app === true) { return; } @@ -104,7 +104,7 @@ class OC_L10N{ } // Use cache if possible - if(array_key_exists($app.'::'.$lang, self::$cache)){ + if(array_key_exists($app.'::'.$lang, self::$cache)) { $this->translations = self::$cache[$app.'::'.$lang]['t']; $this->localizations = self::$cache[$app.'::'.$lang]['l']; @@ -119,15 +119,15 @@ class OC_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'); - if(isset($TRANSLATIONS) && is_array($TRANSLATIONS)){ + if(isset($TRANSLATIONS) && is_array($TRANSLATIONS)) { $this->translations = $TRANSLATIONS; } } - if(file_exists(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php')){ + 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'); - if(isset($LOCALIZATIONS) && is_array($LOCALIZATIONS)){ + if(isset($LOCALIZATIONS) && is_array($LOCALIZATIONS)) { $this->localizations = array_merge($this->localizations, $LOCALIZATIONS); } } @@ -146,7 +146,7 @@ class OC_L10N{ * Returns the translation. If no translation is found, $text will be * returned. */ - public function t($text, $parameters = array()){ + public function t($text, $parameters = array()) { return new OC_L10N_String($this, $text, $parameters); } @@ -164,10 +164,10 @@ class OC_L10N{ * * */ - public function tA($textArray){ + public function tA($textArray) { OC_Log::write('core', 'DEPRECATED: the method tA is deprecated and will be removed soon.',OC_Log::WARN); $result = array(); - foreach($textArray as $key => $text){ + foreach($textArray as $key => $text) { $result[$key] = (string)$this->t($text); } return $result; @@ -179,7 +179,7 @@ class OC_L10N{ * * Returns an associative array with all translations */ - public function getTranslations(){ + public function getTranslations() { $this->init(); return $this->translations; } @@ -206,9 +206,9 @@ class OC_L10N{ * - l10n-field: time * - params: timestamp (int/string) */ - public function l($type, $data){ + public function l($type, $data) { $this->init(); - switch($type){ + switch($type) { // If you add something don't forget to add it to $localizations // at the top of the page case 'date': @@ -233,7 +233,7 @@ class OC_L10N{ * This function is useful to avoid loading thousands of files if only one * simple string is needed, for example in appinfo.php */ - public static function selectLanguage($text){ + public static function selectLanguage($text) { $lang = self::findLanguage(array_keys($text)); return $text[$lang]; } @@ -249,37 +249,37 @@ class OC_L10N{ * * If nothing works it returns 'en' */ - public static function findLanguage($app = null){ - if(!is_array($app) && self::$language != ''){ + public static function findLanguage($app = null) { + if(!is_array($app) && self::$language != '') { return self::$language; } - if(OC_User::getUser() && OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang')){ + if(OC_User::getUser() && OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang')) { $lang = OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang'); self::$language = $lang; - if(is_array($app)){ + if(is_array($app)) { $available = $app; $lang_exists = array_search($lang, $available) !== false; } else { $lang_exists = self::languageExists($app, $lang); } - if($lang_exists){ + if($lang_exists) { return $lang; } } - if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){ + if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $accepted_languages = preg_split('/,\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE']); - if(is_array($app)){ + if(is_array($app)) { $available = $app; } else{ $available = self::findAvailableLanguages($app); } - foreach($accepted_languages as $i){ + foreach($accepted_languages as $i) { $temp = explode(';', $i); - if(array_search($temp[0], $available) !== false){ + if(array_search($temp[0], $available) !== false) { return $temp[0]; } } @@ -294,12 +294,12 @@ class OC_L10N{ * @param $app App that needs to be translated * @returns directory */ - protected static function findI18nDir($app){ + protected static function findI18nDir($app) { // find the i18n dir $i18ndir = OC::$SERVERROOT.'/core/l10n/'; - if($app != ''){ + if($app != '') { // Check if the app is in the app folder - if(file_exists(OC_App::getAppPath($app).'/l10n/')){ + if(file_exists(OC_App::getAppPath($app).'/l10n/')) { $i18ndir = OC_App::getAppPath($app).'/l10n/'; } else{ @@ -314,13 +314,13 @@ class OC_L10N{ * @param $app App that needs to be translated * @returns array an array of available languages */ - public static function findAvailableLanguages($app=null){ + public static function findAvailableLanguages($app=null) { $available=array('en');//english is always available $dir = self::findI18nDir($app); - if(is_dir($dir)){ + if(is_dir($dir)) { $files=scandir($dir); - foreach($files as $file){ - if(substr($file, -4, 4) == '.php'){ + foreach($files as $file) { + if(substr($file, -4, 4) == '.php') { $i = substr($file, 0, -4); $available[] = $i; } @@ -329,12 +329,12 @@ class OC_L10N{ return $available; } - public static function languageExists($app, $lang){ - if ($lang == 'en'){//english is always available + public static function languageExists($app, $lang) { + if ($lang == 'en') {//english is always available return true; } $dir = self::findI18nDir($app); - if(is_dir($dir)){ + if(is_dir($dir)) { return file_exists($dir.'/'.$lang.'.php'); } return false; diff --git a/lib/l10n/string.php b/lib/l10n/string.php index 4769790a16d..8eef10071e6 100644 --- a/lib/l10n/string.php +++ b/lib/l10n/string.php @@ -8,16 +8,16 @@ class OC_L10N_String{ protected $l10n; - public function __construct($l10n, $text, $parameters){ + public function __construct($l10n, $text, $parameters) { $this->l10n = $l10n; $this->text = $text; $this->parameters = $parameters; } - public function __toString(){ + public function __toString() { $translations = $this->l10n->getTranslations(); - if(array_key_exists($this->text, $translations)){ + if(array_key_exists($this->text, $translations)) { return vsprintf($translations[$this->text], $this->parameters); } return vsprintf($this->text, $this->parameters); diff --git a/lib/log/owncloud.php b/lib/log/owncloud.php index 9eb21832c55..d4644163ad5 100644 --- a/lib/log/owncloud.php +++ b/lib/log/owncloud.php @@ -45,7 +45,7 @@ class OC_Log_Owncloud { */ public static function write($app, $message, $level) { $minLevel=min(OC_Config::getValue( "loglevel", OC_Log::WARN ),OC_Log::ERROR); - if($level>=$minLevel){ + if($level>=$minLevel) { $entry=array('app'=>$app, 'message'=>$message, 'level'=>$level,'time'=>time()); $fh=fopen(self::$logFile, 'a'); fwrite($fh, json_encode($entry)."\n"); @@ -59,7 +59,7 @@ class OC_Log_Owncloud { * @param int offset * @return array */ - public static function getEntries($limit=50, $offset=0){ + public static function getEntries($limit=50, $offset=0) { self::init(); $minLevel=OC_Config::getValue( "loglevel", OC_Log::WARN ); $entries = array(); diff --git a/lib/mail.php b/lib/mail.php index 15e91158e1c..8d30fff9f28 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -39,9 +39,9 @@ class OC_Mail { $mailo = new PHPMailer(true); if($SMTPMODE=='sendmail') { $mailo->IsSendmail(); - }elseif($SMTPMODE=='smtp'){ + }elseif($SMTPMODE=='smtp') { $mailo->IsSMTP(); - }elseif($SMTPMODE=='qmail'){ + }elseif($SMTPMODE=='qmail') { $mailo->IsQmail(); }else{ $mailo->IsMail(); diff --git a/lib/migrate.php b/lib/migrate.php index b3ef00cbf6d..823b3574f16 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -52,20 +52,20 @@ class OC_Migrate{ * register a new migration provider * @param OC_Migrate_Provider $provider */ - public static function registerProvider($provider){ + public static function registerProvider($provider) { self::$providers[]=$provider; } /** * @brief finds and loads the providers */ - static private function findProviders(){ + static private function findProviders() { // Find the providers $apps = OC_App::getAllApps(); - foreach($apps as $app){ + foreach($apps as $app) { $path = OC_App::getAppPath($app) . '/appinfo/migrate.php'; - if( file_exists( $path ) ){ + if( file_exists( $path ) ) { include( $path ); } } @@ -78,21 +78,21 @@ class OC_Migrate{ * @param otional $path string path to zip output folder * @return false on error, path to zip on success */ - public static function export( $uid=null, $type='user', $path=null ){ + public static function export( $uid=null, $type='user', $path=null ) { $datadir = OC_Config::getValue( 'datadirectory' ); // Validate export type $types = array( 'user', 'instance', 'system', 'userfiles' ); - if( !in_array( $type, $types ) ){ + if( !in_array( $type, $types ) ) { OC_Log::write( 'migration', 'Invalid export type', OC_Log::ERROR ); return json_encode( array( array( 'success' => false ) ) ); } self::$exporttype = $type; // Userid? - if( self::$exporttype == 'user' ){ + if( self::$exporttype == 'user' ) { // Check user exists - if( !is_null($uid) ){ + if( !is_null($uid) ) { $db = new OC_User_Database; - if( !$db->userExists( $uid ) ){ + if( !$db->userExists( $uid ) ) { OC_Log::write('migration', 'User: '.$uid.' is not in the database and so cannot be exported.', OC_Log::ERROR); return json_encode( array( 'success' => false ) ); } @@ -102,18 +102,18 @@ class OC_Migrate{ } } // Calculate zipname - if( self::$exporttype == 'user' ){ + if( self::$exporttype == 'user' ) { $zipname = 'oc_export_' . self::$uid . '_' . date("y-m-d_H-i-s") . '.zip'; } else { $zipname = 'oc_export_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '.zip'; } // Calculate path - if( self::$exporttype == 'user' ){ + if( self::$exporttype == 'user' ) { self::$zippath = $datadir . '/' . self::$uid . '/' . $zipname; } else { - if( !is_null( $path ) ){ + if( !is_null( $path ) ) { // Validate custom path - if( !file_exists( $path ) || !is_writeable( $path ) ){ + if( !file_exists( $path ) || !is_writeable( $path ) ) { OC_Log::write( 'migration', 'Path supplied is invalid.', OC_Log::ERROR ); return json_encode( array( 'success' => false ) ); } @@ -124,17 +124,17 @@ class OC_Migrate{ } } // Create the zip object - if( !self::createZip() ){ + if( !self::createZip() ) { return json_encode( array( 'success' => false ) ); } // Do the export self::findProviders(); $exportdata = array(); - switch( self::$exporttype ){ + switch( self::$exporttype ) { case 'user': // Connect to the db self::$dbpath = $datadir . '/' . self::$uid . '/migration.db'; - if( !self::connectDB() ){ + if( !self::connectDB() ) { return json_encode( array( 'success' => false ) ); } self::$content = new OC_Migration_Content( self::$zip, self::$MDB2 ); @@ -158,14 +158,14 @@ class OC_Migrate{ // Add the export to the zip self::$content->addFromString( $dbexport, "dbexport.xml" ); // Add user data - foreach(OC_User::getUsers() as $user){ + foreach(OC_User::getUsers() as $user) { self::$content->addDir(OC_User::getHome($user), true, "/userdata/" ); } break; case 'userfiles': self::$content = new OC_Migration_Content( self::$zip ); // Creates a zip with all of the users files - foreach(OC_User::getUsers() as $user){ + foreach(OC_User::getUsers() as $user) { self::$content->addDir(OC_User::getHome($user), true, "/" ); } break; @@ -178,12 +178,12 @@ class OC_Migrate{ } break; } - if( !$info = self::getExportInfo( $exportdata ) ){ + if( !$info = self::getExportInfo( $exportdata ) ) { return json_encode( array( 'success' => false ) ); } // Add the export info json to the export zip self::$content->addFromString( $info, 'export_info.json' ); - if( !self::$content->finish() ){ + if( !self::$content->finish() ) { return json_encode( array( 'success' => false ) ); } return json_encode( array( 'success' => true, 'data' => self::$zippath ) ); @@ -195,22 +195,22 @@ class OC_Migrate{ * @param optional $type type of import (user or instance) * @param optional $uid userid of new user */ - public static function import( $path, $type='user', $uid=null ){ + public static function import( $path, $type='user', $uid=null ) { $datadir = OC_Config::getValue( 'datadirectory' ); // Extract the zip - if( !$extractpath = self::extractZip( $path ) ){ + if( !$extractpath = self::extractZip( $path ) ) { return json_encode( array( 'success' => false ) ); } // Get export_info.json $scan = scandir( $extractpath ); // Check for export_info.json - if( !in_array( 'export_info.json', $scan ) ){ + if( !in_array( 'export_info.json', $scan ) ) { OC_Log::write( 'migration', 'Invalid import file, export_info.json note found', OC_Log::ERROR ); return json_encode( array( 'success' => false ) ); } $json = json_decode( file_get_contents( $extractpath . 'export_info.json' ) ); - if( $json->exporttype != $type ){ + if( $json->exporttype != $type ) { OC_Log::write( 'migration', 'Invalid import file', OC_Log::ERROR ); return json_encode( array( 'success' => false ) ); } @@ -219,13 +219,13 @@ class OC_Migrate{ $currentuser = OC_User::getUser(); // Have we got a user if type is user - if( self::$exporttype == 'user' ){ + if( self::$exporttype == 'user' ) { self::$uid = !is_null($uid) ? $uid : $currentuser; } // We need to be an admin if we are not importing our own data - if(($type == 'user' && self::$uid != $currentuser) || $type != 'user' ){ - if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )){ + if(($type == 'user' && self::$uid != $currentuser) || $type != 'user' ) { + if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )) { // Naughty. OC_Log::write( 'migration', 'Import not permitted.', OC_Log::ERROR ); return json_encode( array( 'success' => false ) ); @@ -233,23 +233,23 @@ class OC_Migrate{ } // Handle export types - switch( self::$exporttype ){ + switch( self::$exporttype ) { case 'user': // Check user availability - if( !OC_User::userExists( self::$uid ) ){ + if( !OC_User::userExists( self::$uid ) ) { OC_Log::write( 'migration', 'User doesn\'t exist', OC_Log::ERROR ); return json_encode( array( 'success' => false ) ); } // Copy data - if( !self::copy_r( $extractpath . $json->exporteduser, $datadir . '/' . self::$uid ) ){ + if( !self::copy_r( $extractpath . $json->exporteduser, $datadir . '/' . self::$uid ) ) { return json_encode( array( 'success' => false ) ); } // Import user app data - if( !$appsimported = self::importAppData( $extractpath . $json->exporteduser . '/migration.db', $json, self::$uid ) ){ + if( !$appsimported = self::importAppData( $extractpath . $json->exporteduser . '/migration.db', $json, self::$uid ) ) { return json_encode( array( 'success' => false ) ); } // All done! - if( !self::unlink_r( $extractpath ) ){ + if( !self::unlink_r( $extractpath ) ) { OC_Log::write( 'migration', 'Failed to delete the extracted zip', OC_Log::ERROR ); } return json_encode( array( 'success' => true, 'data' => $appsimported ) ); @@ -262,19 +262,19 @@ class OC_Migrate{ // Delete current data folder. OC_Log::write( 'migration', "Deleting current data dir", OC_Log::INFO ); - if( !self::unlink_r( $datadir, false ) ){ + if( !self::unlink_r( $datadir, false ) ) { OC_Log::write( 'migration', 'Failed to delete the current data dir', OC_Log::ERROR ); return json_encode( array( 'success' => false ) ); } // Copy over data - if( !self::copy_r( $extractpath . 'userdata', $datadir ) ){ + if( !self::copy_r( $extractpath . 'userdata', $datadir ) ) { OC_Log::write( 'migration', 'Failed to copy over data directory', OC_Log::ERROR ); return json_encode( array( 'success' => false ) ); } // Import the db - if( !OC_DB::replaceDB( $extractpath . 'dbexport.xml' ) ){ + if( !OC_DB::replaceDB( $extractpath . 'dbexport.xml' ) ) { return json_encode( array( 'success' => false ) ); } // Done @@ -291,15 +291,15 @@ class OC_Migrate{ * $param optional $deleteRootToo bool delete the root directory * @return bool */ - private static function unlink_r( $dir, $deleteRootToo=true ){ - if( !$dh = @opendir( $dir ) ){ + private static function unlink_r( $dir, $deleteRootToo=true ) { + if( !$dh = @opendir( $dir ) ) { return false; } - while (false !== ($obj = readdir($dh))){ + while (false !== ($obj = readdir($dh))) { if($obj == '.' || $obj == '..') { continue; } - if (!@unlink($dir . '/' . $obj)){ + if (!@unlink($dir . '/' . $obj)) { self::unlink_r($dir.'/'.$obj, true); } } @@ -316,16 +316,16 @@ class OC_Migrate{ * @param $dest string path to destination * @return bool */ - private static function copy_r( $path, $dest ){ - if( is_dir($path) ){ + private static function copy_r( $path, $dest ) { + if( is_dir($path) ) { @mkdir( $dest ); $objects = scandir( $path ); - if( sizeof( $objects ) > 0 ){ - foreach( $objects as $file ){ + if( sizeof( $objects ) > 0 ) { + foreach( $objects as $file ) { if( $file == "." || $file == ".." || $file == ".htaccess") continue; // go on - if( is_dir( $path . '/' . $file ) ){ + if( is_dir( $path . '/' . $file ) ) { self::copy_r( $path .'/' . $file, $dest . '/' . $file ); } else { copy( $path . '/' . $file, $dest . '/' . $file ); @@ -334,7 +334,7 @@ class OC_Migrate{ } return true; } - elseif( is_file( $path ) ){ + elseif( is_file( $path ) ) { return copy( $path, $dest ); } else { return false; @@ -346,10 +346,10 @@ class OC_Migrate{ * @param $path string path to the zip * @return string path to extract location (with a trailing slash) or false on failure */ - static private function extractZip( $path ){ + static private function extractZip( $path ) { self::$zip = new ZipArchive; // Validate path - if( !file_exists( $path ) ){ + if( !file_exists( $path ) ) { OC_Log::write( 'migration', 'Zip not found', OC_Log::ERROR ); return false; } @@ -358,7 +358,7 @@ class OC_Migrate{ return false; } $to = get_temp_dir() . '/oc_import_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '/'; - if( !self::$zip->extractTo( $to ) ){ + if( !self::$zip->extractTo( $to ) ) { return false; } self::$zip->close(); @@ -369,13 +369,13 @@ class OC_Migrate{ * @brief connects to a MDB2 database scheme * @returns bool */ - static private function connectScheme(){ + static private function connectScheme() { // We need a mdb2 database connection self::$MDB2->loadModule( 'Manager' ); self::$MDB2->loadModule( 'Reverse' ); // Connect if this did not happen before - if( !self::$schema ){ + if( !self::$schema ) { require_once 'MDB2/Schema.php'; self::$schema=MDB2_Schema::factory( self::$MDB2 ); } @@ -387,23 +387,23 @@ class OC_Migrate{ * @brief creates a migration.db in the users data dir with their app data in * @return bool whether operation was successfull */ - private static function exportAppData( ){ + private static function exportAppData( ) { $success = true; $return = array(); // Foreach provider - foreach( self::$providers as $provider ){ + foreach( self::$providers as $provider ) { // Check if the app is enabled - if( OC_App::isEnabled( $provider->getID() ) ){ + if( OC_App::isEnabled( $provider->getID() ) ) { $success = true; // Does this app use the database? - if( file_exists( OC_App::getAppPath($provider->getID()).'/appinfo/database.xml' ) ){ + if( file_exists( OC_App::getAppPath($provider->getID()).'/appinfo/database.xml' ) ) { // Create some app tables $tables = self::createAppTables( $provider->getID() ); - if( is_array( $tables ) ){ + if( is_array( $tables ) ) { // Save the table names - foreach($tables as $table){ + foreach($tables as $table) { $return['apps'][$provider->getID()]['tables'][] = $table; } } else { @@ -413,7 +413,7 @@ class OC_Migrate{ } // Run the export function? - if( $success ){ + if( $success ) { // Set the provider properties $provider->setData( self::$uid, self::$content ); $return['apps'][$provider->getID()]['success'] = $provider->export(); @@ -438,7 +438,7 @@ class OC_Migrate{ * @param optional $array array of data to include in the returned json * @return bool */ - static private function getExportInfo( $array=array() ){ + static private function getExportInfo( $array=array() ) { $info = array( 'ocversion' => OC_Util::getVersion(), 'exporttime' => time(), @@ -447,7 +447,7 @@ class OC_Migrate{ 'exporteduser' => self::$uid ); - if( !is_array( $array ) ){ + if( !is_array( $array ) ) { OC_Log::write( 'migration', 'Supplied $array was not an array in getExportInfo()', OC_Log::ERROR ); } // Merge in other data @@ -462,23 +462,23 @@ class OC_Migrate{ * @param $db optional path to migration.db, defaults to user data dir * @return bool whether the operation was successful */ - static private function connectDB( $path=null ){ + static private function connectDB( $path=null ) { // Has the dbpath been set? self::$dbpath = !is_null( $path ) ? $path : self::$dbpath; - if( !self::$dbpath ){ + if( !self::$dbpath ) { OC_Log::write( 'migration', 'connectDB() was called without dbpath being set', OC_Log::ERROR ); return false; } // Already connected - if(!self::$MDB2){ + if(!self::$MDB2) { require_once 'MDB2.php'; $datadir = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); // DB type - if( class_exists( 'SQLite3' ) ){ + if( class_exists( 'SQLite3' ) ) { $dbtype = 'sqlite3'; - } else if( is_callable( 'sqlite_open' ) ){ + } else if( is_callable( 'sqlite_open' ) ) { $dbtype = 'sqlite'; } else { OC_Log::write( 'migration', 'SQLite not found', OC_Log::ERROR ); @@ -502,7 +502,7 @@ class OC_Migrate{ // Try to establish connection self::$MDB2 = MDB2::factory( $dsn, $options ); // Die if we could not connect - if( PEAR::isError( self::$MDB2 ) ){ + if( PEAR::isError( self::$MDB2 ) ) { die( self::$MDB2->getMessage() ); OC_Log::write( 'migration', 'Failed to create/connect to migration.db', OC_Log::FATAL ); OC_Log::write( 'migration', self::$MDB2->getUserInfo(), OC_Log::FATAL ); @@ -521,9 +521,9 @@ class OC_Migrate{ * @param $appid string id of the app * @return bool whether the operation was successful */ - static private function createAppTables( $appid ){ + static private function createAppTables( $appid ) { - if( !self::connectScheme() ){ + if( !self::connectScheme() ) { return false; } @@ -538,7 +538,7 @@ class OC_Migrate{ $content = str_replace( '*dbprefix*', '', $content ); $xml = new SimpleXMLElement($content); - foreach($xml->table as $table){ + foreach($xml->table as $table) { $tables[] = (string)$table->name; } @@ -550,7 +550,7 @@ class OC_Migrate{ unlink( $file2 ); // Die in case something went wrong - if( $definition instanceof MDB2_Schema_Error ){ + if( $definition instanceof MDB2_Schema_Error ) { OC_Log::write( 'migration', 'Failed to parse database.xml for: '.$appid, OC_Log::FATAL ); OC_Log::write( 'migration', $definition->getMessage().': '.$definition->getUserInfo(), OC_Log::FATAL ); return false; @@ -561,7 +561,7 @@ class OC_Migrate{ $ret = self::$schema->createDatabase( $definition ); // Die in case something went wrong - if( $ret instanceof MDB2_Error ){ + if( $ret instanceof MDB2_Error ) { OC_Log::write( 'migration', 'Failed to create tables for: '.$appid, OC_Log::FATAL ); OC_Log::write( 'migration', $ret->getMessage().': '.$ret->getUserInfo(), OC_Log::FATAL ); return false; @@ -575,10 +575,10 @@ class OC_Migrate{ * @param $path string path to zip destination * @return bool */ - static private function createZip(){ + static private function createZip() { self::$zip = new ZipArchive; // Check if properties are set - if( !self::$zippath ){ + if( !self::$zippath ) { OC_Log::write('migration', 'createZip() called but $zip and/or $zippath have not been set', OC_Log::ERROR); return false; } @@ -594,11 +594,11 @@ class OC_Migrate{ * @brief returns an array of apps that support migration * @return array */ - static public function getApps(){ + static public function getApps() { $allapps = OC_App::getAllApps(); - foreach($allapps as $app){ + foreach($allapps as $app) { $path = self::getAppPath($app) . '/lib/migrate.php'; - if( file_exists( $path ) ){ + if( file_exists( $path ) ) { $supportsmigration[] = $app; } } @@ -612,11 +612,11 @@ class OC_Migrate{ * @param $uid optional uid to use * @return array of apps with import statuses, or false on failure. */ - public static function importAppData( $db, $info, $uid=null ){ + public static function importAppData( $db, $info, $uid=null ) { // Check if the db exists - if( file_exists( $db ) ){ + if( file_exists( $db ) ) { // Connect to the db - if(!self::connectDB( $db )){ + if(!self::connectDB( $db )) { OC_Log::write('migration','Failed to connect to migration.db',OC_Log::ERROR); return false; } @@ -634,25 +634,25 @@ class OC_Migrate{ 'newuid' => self::$uid ); - foreach( self::$providers as $provider){ + foreach( self::$providers as $provider) { // Is the app in the export? $id = $provider->getID(); - if( isset( $info->apps->$id ) ){ + if( isset( $info->apps->$id ) ) { // Is the app installed - if( !OC_App::isEnabled( $id ) ){ + if( !OC_App::isEnabled( $id ) ) { OC_Log::write( 'migration', 'App: ' . $id . ' is not installed, can\'t import data.', OC_Log::INFO ); $appsstatus[$id] = 'notsupported'; } else { // Did it succeed on export? - if( $info->apps->$id->success ){ + if( $info->apps->$id->success ) { // Give the provider the content object - if( !self::connectDB( $db ) ){ + if( !self::connectDB( $db ) ) { return false; } $content = new OC_Migration_Content( self::$zip, self::$MDB2 ); $provider->setData( self::$uid, $content, $info ); // Then do the import - if( !$appsstatus[$id] = $provider->import( $info->apps->$id, $importinfo ) ){ + if( !$appsstatus[$id] = $provider->import( $info->apps->$id, $importinfo ) ) { // Failed to import app OC_Log::write( 'migration', 'Failed to import app data for user: ' . self::$uid . ' for app: ' . $id, OC_Log::ERROR ); } @@ -674,17 +674,17 @@ class OC_Migrate{ * @param $hash string hash of the user to be created * @return bool result of user creation */ - public static function createUser( $uid, $hash ){ + public static function createUser( $uid, $hash ) { // Check if userid exists - if(OC_User::userExists( $uid )){ + if(OC_User::userExists( $uid )) { return false; } // Create the user $query = OC_DB::prepare( "INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )" ); $result = $query->execute( array( $uid, $hash)); - if( !$result ){ + if( !$result ) { OC_Log::write('migration', 'Failed to create the new user "'.$uid.""); } return $result ? true : false; diff --git a/lib/migration/content.php b/lib/migration/content.php index e04ac224f79..64b8168cd98 100644 --- a/lib/migration/content.php +++ b/lib/migration/content.php @@ -38,12 +38,12 @@ class OC_Migration_Content{ * @param optional $db a MDB2 database object (required for exporttype user) * @return bool */ - public function __construct( $zip, $db=null ){ + public function __construct( $zip, $db=null ) { $this->zip = $zip; $this->db = $db; - if( !is_null( $db ) ){ + if( !is_null( $db ) ) { // Get db path $db = $this->db->getDatabase(); $this->tmpfiles[] = $db; @@ -53,7 +53,7 @@ class OC_Migration_Content{ // @brief prepares the db // @param $query the sql query to prepare - public function prepare( $query ){ + public function prepare( $query ) { // Optimize the query $query = $this->processQuery( $query ); @@ -78,7 +78,7 @@ class OC_Migration_Content{ * @param $query the query to process * @return string of processed query */ - private function processQuery( $query ){ + private function processQuery( $query ) { $query = str_replace( '`', '\'', $query ); $query = str_replace( 'NOW()', 'datetime(\'now\')', $query ); $query = str_replace( 'now()', 'datetime(\'now\')', $query ); @@ -92,22 +92,22 @@ class OC_Migration_Content{ * @param $options array of options. * @return bool */ - public function copyRows( $options ){ - if( !array_key_exists( 'table', $options ) ){ + public function copyRows( $options ) { + if( !array_key_exists( 'table', $options ) ) { return false; } $return = array(); // Need to include 'where' in the query? - if( array_key_exists( 'matchval', $options ) && array_key_exists( 'matchcol', $options ) ){ + if( array_key_exists( 'matchval', $options ) && array_key_exists( 'matchcol', $options ) ) { // If only one matchval, create an array - if(!is_array($options['matchval'])){ + if(!is_array($options['matchval'])) { $options['matchval'] = array( $options['matchval'] ); } - foreach( $options['matchval'] as $matchval ){ + foreach( $options['matchval'] as $matchval ) { // Run the query for this match value (where x = y value) $sql = 'SELECT * FROM `*PREFIX*' . $options['table'] . '` WHERE `' . $options['matchcol'] . '` LIKE ?'; $query = OC_DB::prepare( $sql ); @@ -135,12 +135,12 @@ class OC_Migration_Content{ * @param $options array of copyRows options * @return void */ - private function insertData( $data, $options ){ + private function insertData( $data, $options ) { $return = array(); // Foreach row of data to insert - while( $row = $data->fetchRow() ){ + while( $row = $data->fetchRow() ) { // Now save all this to the migration.db - foreach($row as $field=>$value){ + foreach($row as $field=>$value) { $fields[] = $field; $values[] = $value; } @@ -153,14 +153,14 @@ class OC_Migration_Content{ $sql .= $valuessql . " )"; // Make the query $query = $this->prepare( $sql ); - if( !$query ){ + if( !$query ) { OC_Log::write( 'migration', 'Invalid sql produced: '.$sql, OC_Log::FATAL ); return false; exit(); } else { $query->execute( $values ); // Do we need to return some values? - if( array_key_exists( 'idcol', $options ) ){ + if( array_key_exists( 'idcol', $options ) ) { // Yes we do $return[] = $row[$options['idcol']]; } else { @@ -185,7 +185,7 @@ class OC_Migration_Content{ $dirname = basename($dir); $this->zip->addEmptyDir($internaldir . $dirname); $internaldir.=$dirname.='/'; - if( !file_exists( $dir ) ){ + if( !file_exists( $dir ) ) { return false; } if ($dirhandle = opendir($dir)) { @@ -214,11 +214,11 @@ class OC_Migration_Content{ * @param $path the relative path inside of the zip to save the file to * @return bool */ - public function addFromString( $data, $path ){ + public function addFromString( $data, $path ) { // Create a temp file $file = tempnam( get_temp_dir(). '/', 'oc_export_tmp_' ); $this->tmpfiles[] = $file; - if( !file_put_contents( $file, $data ) ){ + if( !file_put_contents( $file, $data ) ) { OC_Log::write( 'migation', 'Failed to save data to a temporary file', OC_Log::ERROR ); return false; } @@ -231,8 +231,8 @@ class OC_Migration_Content{ * @brief closes the zip, removes temp files * @return bool */ - public function finish(){ - if( !$this->zip->close() ){ + public function finish() { + if( !$this->zip->close() ) { OC_Log::write( 'migration', 'Failed to write the zip file with error: '.$this->zip->getStatusString(), OC_Log::ERROR ); return false; } @@ -243,9 +243,9 @@ class OC_Migration_Content{ /** * @brief cleans up after the zip */ - private function cleanup(){ + private function cleanup() { // Delete tmp files - foreach($this->tmpfiles as $i){ + foreach($this->tmpfiles as $i) { unlink( $i ); } } diff --git a/lib/migration/provider.php b/lib/migration/provider.php index 259b1fe7ae6..234ab3351f3 100644 --- a/lib/migration/provider.php +++ b/lib/migration/provider.php @@ -10,7 +10,7 @@ abstract class OC_Migration_Provider{ protected $olduid=false; protected $appinfo=false; - public function __construct( $appid ){ + public function __construct( $appid ) { // Set the id $this->id = $appid; OC_Migrate::registerProvider( $this ); @@ -32,11 +32,11 @@ abstract class OC_Migration_Provider{ * @brief sets the OC_Migration_Content object to $this->content * @param $content a OC_Migration_Content object */ - public function setData( $uid, $content, $info=null ){ + public function setData( $uid, $content, $info=null ) { $this->content = $content; $this->uid = $uid; $id = $this->id; - if( !is_null( $info ) ){ + if( !is_null( $info ) ) { $this->olduid = $info->exporteduser; $this->appinfo = $info->apps->$id; } @@ -46,7 +46,7 @@ abstract class OC_Migration_Provider{ * @brief returns the appid of the provider * @return string */ - public function getID(){ + public function getID() { return $this->id; } } diff --git a/lib/minimizer.php b/lib/minimizer.php index ff5f9304d9c..d50ab0d2397 100644 --- a/lib/minimizer.php +++ b/lib/minimizer.php @@ -22,7 +22,7 @@ abstract class OC_Minimizer { $gzout = false; $cache = OC_Cache::getGlobalCache(); - if (!OC_Request::isNoCache() && (!defined('DEBUG') || !DEBUG)){ + if (!OC_Request::isNoCache() && (!defined('DEBUG') || !DEBUG)) { OC_Response::setETagHeader($etag); $gzout = $cache->get($cache_key.'.gz'); } diff --git a/lib/minimizer/css.php b/lib/minimizer/css.php index 41886087199..8d130572e2b 100644 --- a/lib/minimizer/css.php +++ b/lib/minimizer/css.php @@ -30,7 +30,7 @@ class OC_Minimizer_CSS extends OC_Minimizer $remote .= dirname($file_info[2]); $css_out .= CSSMin::remap($css, dirname($file), $remote, true); } - if (!defined('DEBUG') || !DEBUG){ + if (!defined('DEBUG') || !DEBUG) { $css_out = CSSMin::minify($css_out); } return $css_out; diff --git a/lib/minimizer/js.php b/lib/minimizer/js.php index 97d54c8fb97..bd2d836deb0 100644 --- a/lib/minimizer/js.php +++ b/lib/minimizer/js.php @@ -13,7 +13,7 @@ class OC_Minimizer_JS extends OC_Minimizer $js_out .= '/* ' . $file . ' */' . "\n"; $js_out .= file_get_contents($file); } - if (!defined('DEBUG') || !DEBUG){ + if (!defined('DEBUG') || !DEBUG) { $js_out = JavaScriptMinifier::minify($js_out); } return $js_out; diff --git a/lib/ocs.php b/lib/ocs.php index ad01e5c42fa..3a9be4cf09d 100644 --- a/lib/ocs.php +++ b/lib/ocs.php @@ -102,79 +102,79 @@ class OC_OCS { // eventhandler // CONFIG // apiconfig - GET - CONFIG - if(($method=='get') and ($ex[$paracount-3] == 'v1.php') and ($ex[$paracount-2] == 'config')){ + if(($method=='get') and ($ex[$paracount-3] == 'v1.php') and ($ex[$paracount-2] == 'config')) { OC_OCS::apiconfig($format); // PERSON // personcheck - POST - PERSON/CHECK - }elseif(($method=='post') and ($ex[$paracount-4] == 'v1.php') and ($ex[$paracount-3]=='person') and ($ex[$paracount-2] == 'check')){ + }elseif(($method=='post') and ($ex[$paracount-4] == 'v1.php') and ($ex[$paracount-3]=='person') and ($ex[$paracount-2] == 'check')) { $login = self::readData($method, 'login', 'text'); $passwd = self::readData($method, 'password', 'text'); OC_OCS::personcheck($format,$login,$passwd); // ACTIVITY // activityget - GET ACTIVITY page,pagesize als urlparameter - }elseif(($method=='get') and ($ex[$paracount-3] == 'v1.php') and ($ex[$paracount-2] == 'activity')){ + }elseif(($method=='get') and ($ex[$paracount-3] == 'v1.php') and ($ex[$paracount-2] == 'activity')) { $page = self::readData($method, 'page', 'int', 0); $pagesize = self::readData($method, 'pagesize','int', 10); if($pagesize<1 or $pagesize>100) $pagesize=10; OC_OCS::activityget($format,$page,$pagesize); // activityput - POST ACTIVITY - }elseif(($method=='post') and ($ex[$paracount-3] == 'v1.php') and ($ex[$paracount-2] == 'activity')){ + }elseif(($method=='post') and ($ex[$paracount-3] == 'v1.php') and ($ex[$paracount-2] == 'activity')) { $message = self::readData($method, 'message', 'text'); OC_OCS::activityput($format,$message); // PRIVATEDATA // get - GET DATA - }elseif(($method=='get') and ($ex[$paracount-4] == 'v1.php') and ($ex[$paracount-2] == 'getattribute')){ + }elseif(($method=='get') and ($ex[$paracount-4] == 'v1.php') and ($ex[$paracount-2] == 'getattribute')) { OC_OCS::privateDataGet($format); - }elseif(($method=='get') and ($ex[$paracount-5] == 'v1.php') and ($ex[$paracount-3] == 'getattribute')){ + }elseif(($method=='get') and ($ex[$paracount-5] == 'v1.php') and ($ex[$paracount-3] == 'getattribute')) { $app=$ex[$paracount-2]; OC_OCS::privateDataGet($format, $app); - }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-4] == 'getattribute')){ + }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-4] == 'getattribute')) { $key=$ex[$paracount-2]; $app=$ex[$paracount-3]; OC_OCS::privateDataGet($format, $app,$key); // set - POST DATA - }elseif(($method=='post') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-4] == 'setattribute')){ + }elseif(($method=='post') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-4] == 'setattribute')) { $key=$ex[$paracount-2]; $app=$ex[$paracount-3]; $value = self::readData($method, 'value', 'text'); OC_OCS::privatedataset($format, $app, $key, $value); // delete - POST DATA - }elseif(($method=='post') and ($ex[$paracount-6] =='v1.php') and ($ex[$paracount-4] == 'deleteattribute')){ + }elseif(($method=='post') and ($ex[$paracount-6] =='v1.php') and ($ex[$paracount-4] == 'deleteattribute')) { $key=$ex[$paracount-2]; $app=$ex[$paracount-3]; OC_OCS::privatedatadelete($format, $app, $key); // CLOUD // systemWebApps - }elseif(($method=='get') and ($ex[$paracount-5] == 'v1.php') and ($ex[$paracount-4]=='cloud') and ($ex[$paracount-3] == 'system') and ($ex[$paracount-2] == 'webapps')){ + }elseif(($method=='get') and ($ex[$paracount-5] == 'v1.php') and ($ex[$paracount-4]=='cloud') and ($ex[$paracount-3] == 'system') and ($ex[$paracount-2] == 'webapps')) { OC_OCS::systemwebapps($format); // quotaget - }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'quota')){ + }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'quota')) { $user=$ex[$paracount-3]; OC_OCS::quotaget($format,$user); // quotaset - }elseif(($method=='post') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'quota')){ + }elseif(($method=='post') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'quota')) { $user=$ex[$paracount-3]; $quota = self::readData('post', 'quota', 'int'); OC_OCS::quotaset($format,$user,$quota); // keygetpublic - }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'publickey')){ + }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'publickey')) { $user=$ex[$paracount-3]; OC_OCS::publicKeyGet($format,$user); // keygetprivate - }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'privatekey')){ + }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'privatekey')) { $user=$ex[$paracount-3]; OC_OCS::privateKeyGet($format,$user); @@ -229,7 +229,7 @@ class OC_OCS { if(isset($_SERVER['PHP_AUTH_PW'])) $authpw=$_SERVER['PHP_AUTH_PW']; else $authpw=''; if(empty($authuser)) { - if($forceuser){ + if($forceuser) { header('WWW-Authenticate: Basic realm="your valid user account or api key"'); header('HTTP/1.0 401 Unauthorized'); exit; @@ -237,8 +237,8 @@ class OC_OCS { $identifieduser=''; } }else{ - if(!OC_User::login($authuser,$authpw)){ - if($forceuser){ + if(!OC_User::login($authuser,$authpw)) { + if($forceuser) { header('WWW-Authenticate: Basic realm="your valid user account or api key"'); header('HTTP/1.0 401 Unauthorized'); exit; @@ -310,7 +310,7 @@ class OC_OCS { xmlwriter_write_attribute($writer,'details',$tagattribute); } foreach($entry as $key=>$value) { - if(is_array($value)){ + if(is_array($value)) { foreach($value as $k=>$v) { xmlwriter_write_element($writer,$k,$v); } @@ -330,7 +330,7 @@ class OC_OCS { xmlwriter_write_attribute($writer,'details',$tagattribute); } foreach($entry as $key=>$value) { - if(is_array($value)){ + if(is_array($value)) { xmlwriter_start_element($writer,$entrykey); foreach($value as $k=>$v) { xmlwriter_write_element($writer,$k,$v); @@ -363,7 +363,7 @@ class OC_OCS { if (is_numeric($key)) { $key = $node; } - if (is_array($value)){ + if (is_array($value)) { xmlwriter_start_element($writer,$key); OC_OCS::toxml($writer,$value,$node); xmlwriter_end_element($writer); @@ -402,8 +402,8 @@ class OC_OCS { * @return string xml/json */ private static function personCheck($format,$login,$passwd) { - if($login<>''){ - if(OC_User::login($login,$passwd)){ + if($login<>'') { + if(OC_User::login($login,$passwd)) { $xml['person']['personid']=$login; echo(OC_OCS::generatexml($format,'ok',100,'',$xml,'person','check',2)); }else{ @@ -480,7 +480,7 @@ class OC_OCS { */ private static function privateDataSet($format, $app, $key, $value) { $user=OC_OCS::checkpassword(); - if(OC_OCS::setData($user,$app,$key,$value)){ + if(OC_OCS::setData($user,$app,$key,$value)) { echo(OC_OCS::generatexml($format,'ok',100,'')); } } @@ -493,11 +493,11 @@ class OC_OCS { * @return string xml/json */ private static function privateDataDelete($format, $app, $key) { - if($key=="" or $app==""){ + if($key=="" or $app=="") { return; //key and app are NOT optional here } $user=OC_OCS::checkpassword(); - if(OC_OCS::deleteData($user,$app,$key)){ + if(OC_OCS::deleteData($user,$app,$key)) { echo(OC_OCS::generatexml($format,'ok',100,'')); } } @@ -511,21 +511,21 @@ class OC_OCS { * @return array */ public static function getData($user,$app="",$key="") { - if($app){ + if($app) { $apps=array($app); }else{ $apps=OC_Preferences::getApps($user); } - if($key){ + if($key) { $keys=array($key); }else{ - foreach($apps as $app){ + foreach($apps as $app) { $keys=OC_Preferences::getKeys($user,$app); } } $result=array(); - foreach($apps as $app){ - foreach($keys as $key){ + foreach($apps as $app) { + foreach($keys as $key) { $value=OC_Preferences::getValue($user,$app,$key); $result[]=array('app'=>$app,'key'=>$key,'value'=>$value); } @@ -592,7 +592,7 @@ class OC_OCS { $login=OC_OCS::checkpassword(); if(OC_Group::inGroup($login, 'admin') or ($login==$user)) { - if(OC_User::userExists($user)){ + if(OC_User::userExists($user)) { // calculate the disc space $user_dir = '/'.$user.'/files'; OC_Filesystem::init($user_dir); @@ -653,7 +653,7 @@ class OC_OCS { private static function publicKeyGet($format,$user) { $login=OC_OCS::checkpassword(); - if(OC_User::userExists($user)){ + if(OC_User::userExists($user)) { // calculate the disc space $txt='this is the public key of '.$user; echo($txt); @@ -672,7 +672,7 @@ class OC_OCS { $login=OC_OCS::checkpassword(); if(OC_Group::inGroup($login, 'admin') or ($login==$user)) { - if(OC_User::userExists($user)){ + if(OC_User::userExists($user)) { // calculate the disc space $txt='this is the private key of '.$user; echo($txt); diff --git a/lib/ocsclient.php b/lib/ocsclient.php index dde2545858d..8596ea0b3c7 100644 --- a/lib/ocsclient.php +++ b/lib/ocsclient.php @@ -34,7 +34,7 @@ class OC_OCSClient{ * * This function returns the url of the OCS AppStore server. It´s possible to set it in the config file or it will fallback to the default */ - private static function getAppStoreURL(){ + private static function getAppStoreURL() { $url = OC_Config::getValue('appstoreurl', 'http://api.apps.owncloud.com/v1'); return($url); } @@ -44,7 +44,7 @@ class OC_OCSClient{ * @returns string of the KB server * This function returns the url of the OCS knowledge base server. It´s possible to set it in the config file or it will fallback to the default */ - private static function getKBURL(){ + private static function getKBURL() { $url = OC_Config::getValue('knowledgebaseurl', 'http://api.apps.owncloud.com/v1'); return($url); } @@ -56,14 +56,14 @@ class OC_OCSClient{ * * This function returns a list of all the application categories on the OCS server */ - public static function getCategories(){ - if(OC_Config::getValue('appstoreenabled', true)==false){ + public static function getCategories() { + if(OC_Config::getValue('appstoreenabled', true)==false) { return NULL; } $url=OC_OCSClient::getAppStoreURL().'/content/categories'; $xml=@file_get_contents($url); - if($xml==FALSE){ + if($xml==FALSE) { return NULL; } $data=simplexml_load_string($xml); @@ -88,8 +88,8 @@ class OC_OCSClient{ * * This function returns a list of all the applications on the OCS server */ - public static function getApplications($categories,$page,$filter){ - if(OC_Config::getValue('appstoreenabled', true)==false){ + public static function getApplications($categories,$page,$filter) { + if(OC_Config::getValue('appstoreenabled', true)==false) { return(array()); } @@ -104,7 +104,7 @@ class OC_OCSClient{ $url=OC_OCSClient::getAppStoreURL().'/content/data?categories='.urlencode($categoriesstring).'&sortmode=new&page='.urlencode($page).'&pagesize=100'.$filterurl.$version; $apps=array(); $xml=@file_get_contents($url); - if($xml==FALSE){ + if($xml==FALSE) { return NULL; } $data=simplexml_load_string($xml); @@ -135,14 +135,14 @@ class OC_OCSClient{ * * This function returns an applications from the OCS server */ - public static function getApplication($id){ - if(OC_Config::getValue('appstoreenabled', true)==false){ + public static function getApplication($id) { + if(OC_Config::getValue('appstoreenabled', true)==false) { return NULL; } $url=OC_OCSClient::getAppStoreURL().'/content/data/'.urlencode($id); $xml=@file_get_contents($url); - if($xml==FALSE){ + if($xml==FALSE) { OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL); return NULL; } @@ -172,14 +172,14 @@ class OC_OCSClient{ * * This function returns an download url for an applications from the OCS server */ - public static function getApplicationDownload($id,$item){ - if(OC_Config::getValue('appstoreenabled', true)==false){ + public static function getApplicationDownload($id,$item) { + if(OC_Config::getValue('appstoreenabled', true)==false) { return NULL; } $url=OC_OCSClient::getAppStoreURL().'/content/download/'.urlencode($id).'/'.urlencode($item); $xml=@file_get_contents($url); - if($xml==FALSE){ + if($xml==FALSE) { OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL); return NULL; } @@ -202,8 +202,8 @@ class OC_OCSClient{ * * This function returns a list of all the knowledgebase entries from the OCS server */ - public static function getKnownledgebaseEntries($page,$pagesize,$search=''){ - if(OC_Config::getValue('knowledgebaseenabled', true)==false){ + public static function getKnownledgebaseEntries($page,$pagesize,$search='') { + if(OC_Config::getValue('knowledgebaseenabled', true)==false) { $kbe=array(); $kbe['totalitems']=0; return $kbe; @@ -216,7 +216,7 @@ class OC_OCSClient{ $kbe=array(); $xml=@file_get_contents($url); - if($xml==FALSE){ + if($xml==FALSE) { OC_Log::write('core','Unable to parse knowledgebase content',OC_Log::FATAL); return NULL; } diff --git a/lib/preferences.php b/lib/preferences.php index de5747fcccc..3d61887785c 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -45,13 +45,13 @@ class OC_Preferences{ * This function returns a list of all users that have at least one entry * in the preferences table. */ - public static function getUsers(){ + public static function getUsers() { // No need for more comments $query = OC_DB::prepare( 'SELECT DISTINCT( `userid` ) FROM `*PREFIX*preferences`' ); $result = $query->execute(); $users = array(); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $users[] = $row["userid"]; } @@ -66,13 +66,13 @@ class OC_Preferences{ * This function returns a list of all apps of the user that have at least * one entry in the preferences table. */ - public static function getApps( $user ){ + public static function getApps( $user ) { // No need for more comments $query = OC_DB::prepare( 'SELECT DISTINCT( `appid` ) FROM `*PREFIX*preferences` WHERE `userid` = ?' ); $result = $query->execute( array( $user )); $apps = array(); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $apps[] = $row["appid"]; } @@ -88,13 +88,13 @@ class OC_Preferences{ * This function gets all keys of an app of an user. Please note that the * values are not returned. */ - public static function getKeys( $user, $app ){ + public static function getKeys( $user, $app ) { // No need for more comments $query = OC_DB::prepare( 'SELECT `configkey` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?' ); $result = $query->execute( array( $user, $app )); $keys = array(); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { $keys[] = $row["configkey"]; } @@ -112,13 +112,13 @@ class OC_Preferences{ * This function gets a value from the prefernces table. If the key does * not exist the default value will be returnes */ - public static function getValue( $user, $app, $key, $default = null ){ + public static function getValue( $user, $app, $key, $default = null ) { // Try to fetch the value, return default if not exists. $query = OC_DB::prepare( 'SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' ); $result = $query->execute( array( $user, $app, $key )); $row = $result->fetchRow(); - if($row){ + if($row) { return $row["configvalue"]; }else{ return $default; @@ -136,13 +136,13 @@ class OC_Preferences{ * Adds a value to the preferences. If the key did not exist before, it * will be added automagically. */ - public static function setValue( $user, $app, $key, $value ){ + public static function setValue( $user, $app, $key, $value ) { // Check if the key does exist $query = OC_DB::prepare( 'SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' ); $values=$query->execute(array($user,$app,$key))->fetchAll(); $exists=(count($values)>0); - if( !$exists ){ + if( !$exists ) { $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*preferences` ( `userid`, `appid`, `configkey`, `configvalue` ) VALUES( ?, ?, ?, ? )' ); $query->execute( array( $user, $app, $key, $value )); } @@ -162,7 +162,7 @@ class OC_Preferences{ * * Deletes a key. */ - public static function deleteKey( $user, $app, $key ){ + public static function deleteKey( $user, $app, $key ) { // No need for more comments $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' ); $result = $query->execute( array( $user, $app, $key )); @@ -178,7 +178,7 @@ class OC_Preferences{ * * Removes all keys in appconfig belonging to the app and the user. */ - public static function deleteApp( $user, $app ){ + public static function deleteApp( $user, $app ) { // No need for more comments $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?' ); $result = $query->execute( array( $user, $app )); @@ -193,7 +193,7 @@ class OC_Preferences{ * * Removes all keys in appconfig belonging to the user. */ - public static function deleteUser( $user ){ + public static function deleteUser( $user ) { // No need for more comments $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ?' ); $result = $query->execute( array( $user )); @@ -208,7 +208,7 @@ class OC_Preferences{ * * Removes all keys in preferences belonging to the app. */ - public static function deleteAppFromAllUsers( $app ){ + public static function deleteAppFromAllUsers( $app ) { // No need for more comments $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `appid` = ?' ); $result = $query->execute( array( $app )); diff --git a/lib/public/app.php b/lib/public/app.php index be38bbff98a..eb824f043e9 100644 --- a/lib/public/app.php +++ b/lib/public/app.php @@ -45,7 +45,7 @@ class App { * It'll remain in our public API for compatibility reasons * */ - public static function register( $data ){ + public static function register( $data ) { return true; // don't do anything } @@ -66,7 +66,7 @@ class App { * - order: integer, that influences the position of your application in * the navigation. Lower values come first. */ - public static function addNavigationEntry( $data ){ + public static function addNavigationEntry( $data ) { return \OC_App::addNavigationEntry( $data ); } @@ -80,7 +80,7 @@ class App { * property from all other entries. The templates can use this for * highlighting the current position of the user. */ - public static function setActiveNavigationEntry( $id ){ + public static function setActiveNavigationEntry( $id ) { return \OC_App::setActiveNavigationEntry( $id ); } @@ -90,7 +90,7 @@ class App { * @param $app string appid * @param $page string page to be included */ - public static function registerPersonal( $app, $page ){ + public static function registerPersonal( $app, $page ) { return \OC_App::registerPersonal( $app, $page ); } @@ -100,7 +100,7 @@ class App { * @param $app string appid * @param $page string page to be included */ - public static function registerAdmin( $app, $page ){ + public static function registerAdmin( $app, $page ) { return \OC_App::registerAdmin( $app, $page ); } @@ -111,7 +111,7 @@ class App { * @param boolean path (optional) * @returns array */ - public static function getAppInfo( $app, $path=false ){ + public static function getAppInfo( $app, $path=false ) { return \OC_App::getAppInfo( $app, $path); } @@ -124,7 +124,7 @@ class App { * * This function checks whether or not an app is enabled. */ - public static function isEnabled( $app ){ + public static function isEnabled( $app ) { return \OC_App::isEnabled( $app ); } @@ -134,7 +134,7 @@ class App { * @param $app app * @returns true/false */ - public static function checkAppEnabled( $app ){ + public static function checkAppEnabled( $app ) { return \OC_Util::checkAppEnabled( $app ); } @@ -144,7 +144,7 @@ class App { * @param $app app * @returns true/false */ - public static function getAppVersion( $app ){ + public static function getAppVersion( $app ) { return \OC_App::getAppVersion( $app ); } diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php index 2962346dbc9..aba7d2b7620 100644 --- a/lib/public/backgroundjob.php +++ b/lib/public/backgroundjob.php @@ -52,7 +52,7 @@ class BackgroundJob { * @param $method method name * @return true */ - public static function addRegularTask( $klass, $method ){ + public static function addRegularTask( $klass, $method ) { return \OC_BackgroundJob_RegularTask::register( $klass, $method ); } @@ -62,7 +62,7 @@ class BackgroundJob { * * key is string "$klass-$method", value is array( $klass, $method ) */ - static public function allRegularTasks(){ + static public function allRegularTasks() { return \OC_BackgroundJob_RegularTask::all(); } @@ -71,7 +71,7 @@ class BackgroundJob { * @param $id ID of the task * @return associative array */ - public static function findQueuedTask( $id ){ + public static function findQueuedTask( $id ) { return \OC_BackgroundJob_QueuedTask::find( $id ); } @@ -79,7 +79,7 @@ class BackgroundJob { * @brief Gets all queued tasks * @return array with associative arrays */ - public static function allQueuedTasks(){ + public static function allQueuedTasks() { return \OC_BackgroundJob_QueuedTask::all(); } @@ -88,7 +88,7 @@ class BackgroundJob { * @param $app app name * @return array with associative arrays */ - public static function queuedTaskWhereAppIs( $app ){ + public static function queuedTaskWhereAppIs( $app ) { return \OC_BackgroundJob_QueuedTask::whereAppIs( $app ); } @@ -100,7 +100,7 @@ class BackgroundJob { * @param $parameters all useful data as text * @return id of task */ - public static function addQueuedTask( $app, $klass, $method, $parameters ){ + public static function addQueuedTask( $app, $klass, $method, $parameters ) { return \OC_BackgroundJob_QueuedTask::add( $app, $klass, $method, $parameters ); } @@ -111,7 +111,7 @@ class BackgroundJob { * * Deletes a report */ - public static function deleteQueuedTask( $id ){ + public static function deleteQueuedTask( $id ) { return \OC_BackgroundJob_QueuedTask::delete( $id ); } } diff --git a/lib/public/config.php b/lib/public/config.php index f3120b9aaa2..fa9658e7288 100644 --- a/lib/public/config.php +++ b/lib/public/config.php @@ -49,7 +49,7 @@ class Config { * This function gets the value from config.php. If it does not exist, * $default will be returned. */ - public static function getSystemValue( $key, $default = null ){ + public static function getSystemValue( $key, $default = null ) { return(\OC_Config::getValue( $key, $default )); } @@ -63,7 +63,7 @@ class Config { * This function sets the value and writes the config.php. If the file can * not be written, false will be returned. */ - public static function setSystemValue( $key, $value ){ + public static function setSystemValue( $key, $value ) { return(\OC_Config::setValue( $key, $value )); } @@ -78,7 +78,7 @@ class Config { * This function gets a value from the appconfig table. If the key does * not exist the default value will be returnes */ - public static function getAppValue( $app, $key, $default = null ){ + public static function getAppValue( $app, $key, $default = null ) { return(\OC_Appconfig::getValue( $app, $key, $default )); } @@ -92,7 +92,7 @@ class Config { * * Sets a value. If the key did not exist before it will be created. */ - public static function setAppValue( $app, $key, $value ){ + public static function setAppValue( $app, $key, $value ) { return(\OC_Appconfig::setValue( $app, $key, $value )); } @@ -108,7 +108,7 @@ class Config { * This function gets a value from the prefernces table. If the key does * not exist the default value will be returnes */ - public static function getUserValue( $user, $app, $key, $default = null ){ + public static function getUserValue( $user, $app, $key, $default = null ) { return(\OC_Preferences::getValue( $user, $app, $key, $default )); } @@ -124,7 +124,7 @@ class Config { * Adds a value to the preferences. If the key did not exist before, it * will be added automagically. */ - public static function setUserValue( $user, $app, $key, $value ){ + public static function setUserValue( $user, $app, $key, $value ) { return(\OC_Preferences::setValue( $user, $app, $key, $value )); } diff --git a/lib/public/db.php b/lib/public/db.php index e1da62e2d27..5ac356bb475 100644 --- a/lib/public/db.php +++ b/lib/public/db.php @@ -43,7 +43,7 @@ class DB { * * SQL query via MDB2 prepare(), needs to be execute()'d! */ - static public function prepare( $query, $limit=null, $offset=null ){ + static public function prepare( $query, $limit=null, $offset=null ) { return(\OC_DB::prepare($query,$limit,$offset)); } @@ -58,7 +58,7 @@ class DB { * Call this method right after the insert command or other functions may * cause trouble! */ - public static function insertid($table=null){ + public static function insertid($table=null) { return(\OC_DB::insertid($table)); } @@ -66,7 +66,7 @@ class DB { /** * @brief Start a transaction */ - public static function beginTransaction(){ + public static function beginTransaction() { return(\OC_DB::beginTransaction()); } @@ -74,7 +74,7 @@ class DB { /** * @brief Commit the database changes done during a transaction that is in progress */ - public static function commit(){ + public static function commit() { return(\OC_DB::commit()); } @@ -84,7 +84,7 @@ class DB { * @param mixed $result * @return bool */ - public static function isError($result){ + public static function isError($result) { return(\OC_DB::isError($result)); } diff --git a/lib/public/files.php b/lib/public/files.php index be5952d362a..2f4f459bd91 100644 --- a/lib/public/files.php +++ b/lib/public/files.php @@ -52,7 +52,7 @@ class Files { * @return string * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead */ - static function getMimeType( $path ){ + static function getMimeType( $path ) { return(\OC_Helper::getMimeType( $path )); } @@ -63,7 +63,7 @@ class Files { * @param resource target * @return int the number of bytes copied */ - public static function streamCopy( $source, $target ){ + public static function streamCopy( $source, $target ) { return(\OC_Helper::streamCopy( $source, $target )); } @@ -75,7 +75,7 @@ class Files { * * temporary files are automatically cleaned up after the script is finished */ - public static function tmpFile( $postfix='' ){ + public static function tmpFile( $postfix='' ) { return(\OC_Helper::tmpFile( $postfix )); } @@ -86,7 +86,7 @@ class Files { * * temporary files are automatically cleaned up after the script is finished */ - public static function tmpFolder(){ + public static function tmpFolder() { return(\OC_Helper::tmpFolder()); } @@ -98,7 +98,7 @@ class Files { * @param $filename * @return string */ - public static function buildNotExistingFileName( $path, $filename ){ + public static function buildNotExistingFileName( $path, $filename ) { return(\OC_Helper::buildNotExistingFileName( $path, $filename )); } @@ -107,7 +107,7 @@ class Files { * @param $app app * @return OC_FilesystemView */ - public static function getStorage( $app ){ + public static function getStorage( $app ) { return \OC_App::getStorage( $app ); } diff --git a/lib/public/json.php b/lib/public/json.php index c37b42c3f74..93be920c6d7 100644 --- a/lib/public/json.php +++ b/lib/public/json.php @@ -41,7 +41,7 @@ class JSON { * @param string $setContentType the optional content type * @return string json formatted string. */ - public static function encodedPrint( $data, $setContentType=true ){ + public static function encodedPrint( $data, $setContentType=true ) { return(\OC_JSON::encodedPrint( $data, $setContentType )); } @@ -60,7 +60,7 @@ class JSON { * * @return string json formatted error string if not authenticated. */ - public static function checkLoggedIn(){ + public static function checkLoggedIn() { return(\OC_JSON::checkLoggedIn()); } @@ -84,7 +84,7 @@ class JSON { * * @return string json formatted error string if not valid. */ - public static function callCheck(){ + public static function callCheck() { return(\OC_JSON::callCheck()); } @@ -97,7 +97,7 @@ class JSON { * @param array $data The data to use * @return string json formatted string. */ - public static function success( $data = array() ){ + public static function success( $data = array() ) { return(\OC_JSON::success( $data )); } @@ -119,7 +119,7 @@ class JSON { * @param array $data The data to use * @return string json formatted error string. */ - public static function error( $data = array() ){ + public static function error( $data = array() ) { return(\OC_JSON::error( $data )); } @@ -128,7 +128,7 @@ class JSON { * @param array $type The contwnt type header * @return string json formatted string. */ - public static function setContentTypeHeader( $type='application/json' ){ + public static function setContentTypeHeader( $type='application/json' ) { return(\OC_JSON::setContentTypeHeader( $type )); } @@ -148,7 +148,7 @@ class JSON { * @param string $app The app to check * @return string json formatted string if not enabled. */ - public static function checkAppEnabled( $app ){ + public static function checkAppEnabled( $app ) { return(\OC_JSON::checkAppEnabled( $app )); } @@ -167,7 +167,7 @@ class JSON { * * @return string json formatted string if not admin user. */ - public static function checkAdminUser(){ + public static function checkAdminUser() { return(\OC_JSON::checkAdminUser()); } diff --git a/lib/public/template.php b/lib/public/template.php index 11c740d13ac..4cda3650866 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -39,7 +39,7 @@ namespace OCP; * * For further information have a look at OC_Helper::imagePath */ -function image_path( $app, $image ){ +function image_path( $app, $image ) { return(\image_path( $app, $image )); } @@ -50,7 +50,7 @@ function image_path( $app, $image ){ * @param $mimetype mimetype * @returns link to the image */ -function mimetype_icon( $mimetype ){ +function mimetype_icon( $mimetype ) { return(\mimetype_icon( $mimetype )); } @@ -61,7 +61,7 @@ function mimetype_icon( $mimetype ){ * @param $bytes size in bytes * @returns size as string */ -function human_file_size( $bytes ){ +function human_file_size( $bytes ) { return(\human_file_size( $bytes )); } diff --git a/lib/public/user.php b/lib/public/user.php index 327e2a77355..b530321f21d 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -40,7 +40,7 @@ class User { * @brief get the user id of the user currently logged in. * @return string uid or false */ - public static function getUser(){ + public static function getUser() { return \OC_USER::getUser(); } @@ -62,7 +62,7 @@ class User { * * Checks if the user is logged in */ - public static function isLoggedIn(){ + public static function isLoggedIn() { return \OC_USER::isLoggedIn(); } @@ -72,7 +72,7 @@ class User { * @param string $uid the username * @return boolean */ - public static function userExists( $uid ){ + public static function userExists( $uid ) { return \OC_USER::userExists( $uid ); } @@ -83,7 +83,7 @@ class User { * * Logout, destroys session */ - public static function logout(){ + public static function logout() { return \OC_USER::logout(); } @@ -96,7 +96,7 @@ class User { * * Check if the password is correct without logging in the user */ - public static function checkPassword( $uid, $password ){ + public static function checkPassword( $uid, $password ) { return \OC_USER::checkPassword( $uid, $password ); } @@ -104,7 +104,7 @@ class User { /** * Check if the user is a admin, redirects to home if not */ - public static function checkAdminUser(){ + public static function checkAdminUser() { \OC_Util::checkAdminUser(); } @@ -113,7 +113,7 @@ class User { * Check if the user is logged in, redirects to home if not. With * redirect URL parameter to the request URI. */ - public static function checkLoggedIn(){ + public static function checkLoggedIn() { \OC_Util::checkLoggedIn(); } diff --git a/lib/public/util.php b/lib/public/util.php index cc05e6d535f..ed23521b040 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -48,7 +48,7 @@ class Util { * @brief get the current installed version of ownCloud * @return array */ - public static function getVersion(){ + public static function getVersion() { return(\OC_Util::getVersion()); } @@ -85,7 +85,7 @@ class Util { * @brief add a css file * @param url $url */ - public static function addStyle( $application, $file = null ){ + public static function addStyle( $application, $file = null ) { \OC_Util::addStyle( $application, $file ); } @@ -95,7 +95,7 @@ class Util { * @param appid $application * @param filename $file */ - public static function addScript( $application, $file = null ){ + public static function addScript( $application, $file = null ) { \OC_Util::addScript( $application, $file ); } @@ -105,7 +105,7 @@ class Util { * @param array $attributes array of attributes for the element * @param string $text the text content for the element */ - public static function addHeader( $tag, $attributes, $text=''){ + public static function addHeader( $tag, $attributes, $text='') { \OC_Util::addHeader( $tag, $attributes, $text ); } @@ -114,7 +114,7 @@ class Util { * @param int timestamp $timestamp * @param bool dateOnly option to ommit time from the result */ - public static function formatDate( $timestamp,$dateOnly=false){ + public static function formatDate( $timestamp,$dateOnly=false) { return(\OC_Util::formatDate( $timestamp,$dateOnly )); } @@ -166,7 +166,7 @@ class Util { * * Returns a url to the given app and file. */ - public static function linkTo( $app, $file, $args = array() ){ + public static function linkTo( $app, $file, $args = array() ) { return(\OC_Helper::linkTo( $app, $file, $args )); } @@ -199,7 +199,7 @@ class Util { * * Returns the path to the image. */ - public static function imagePath( $app, $image ){ + public static function imagePath( $app, $image ) { return(\OC_Helper::imagePath( $app, $image )); } @@ -211,7 +211,7 @@ class Util { * * Makes 2048 to 2 kB. */ - public static function humanFileSize( $bytes ){ + public static function humanFileSize( $bytes ) { return(\OC_Helper::humanFileSize( $bytes )); } @@ -224,7 +224,7 @@ class Util { * * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418 */ - public static function computerFileSize( $str ){ + public static function computerFileSize( $str ) { return(\OC_Helper::computerFileSize( $str )); } @@ -240,7 +240,7 @@ class Util { * * TODO: write example */ - static public function connectHook( $signalclass, $signalname, $slotclass, $slotname ){ + static public function connectHook( $signalclass, $signalname, $slotclass, $slotname ) { return(\OC_Hook::connect( $signalclass, $signalname, $slotclass, $slotname )); } @@ -256,7 +256,7 @@ class Util { * * TODO: write example */ - static public function emitHook( $signalclass, $signalname, $params = array()){ + static public function emitHook( $signalclass, $signalname, $params = array()) { return(\OC_Hook::emit( $signalclass, $signalname, $params )); } @@ -265,7 +265,7 @@ class Util { * Register an get/post call. This is important to prevent CSRF attacks * TODO: write example */ - public static function callRegister(){ + public static function callRegister() { return(\OC_Util::callRegister()); } @@ -274,7 +274,7 @@ class Util { * Check an ajax get/post call if the request token is valid. exit if not. * Todo: Write howto */ - public static function callCheck(){ + public static function callCheck() { return(\OC_Util::callCheck()); } @@ -286,7 +286,7 @@ class Util { * @param string or array of strings * @return array with sanitized strings or a single sinitized string, depends on the input parameter. */ - public static function sanitizeHTML( $value ){ + public static function sanitizeHTML( $value ) { return(\OC_Util::sanitizeHTML($value)); } @@ -300,7 +300,7 @@ class Util { * * */ - public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8'){ + public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') { return(\OC_Helper::mb_array_change_key_case($input, $case, $encoding)); } diff --git a/lib/request.php b/lib/request.php index 10f6e91bac8..87262d98625 100644 --- a/lib/request.php +++ b/lib/request.php @@ -15,7 +15,7 @@ class OC_Request { * reverse proxies */ public static function serverHost() { - if(OC::$CLI){ + if(OC::$CLI) { return 'localhost'; } if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { @@ -57,7 +57,7 @@ class OC_Request { * @returns string Path info or false when not found */ public static function getPathInfo() { - if (array_key_exists('PATH_INFO', $_SERVER)){ + if (array_key_exists('PATH_INFO', $_SERVER)) { $path_info = $_SERVER['PATH_INFO']; }else{ $path_info = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])); diff --git a/lib/search.php b/lib/search.php index 9dfd0cf69ef..0b6ad050024 100644 --- a/lib/search.php +++ b/lib/search.php @@ -31,7 +31,7 @@ class OC_Search{ /** * remove all registered search providers */ - public static function clearProviders(){ + public static function clearProviders() { self::$providers=array(); self::$registeredProviders=array(); } @@ -40,7 +40,7 @@ class OC_Search{ * register a new search provider to be used * @param string $provider class name of a OC_Search_Provider */ - public static function registerProvider($class,$options=array()){ + public static function registerProvider($class,$options=array()) { self::$registeredProviders[]=array('class'=>$class,'options'=>$options); } @@ -49,10 +49,10 @@ class OC_Search{ * @param string query * @return array An array of OC_Search_Result's */ - public static function search($query){ + public static function search($query) { self::initProviders(); $results=array(); - foreach(self::$providers as $provider){ + foreach(self::$providers as $provider) { $results=array_merge($results, $provider->search($query)); } return $results; @@ -61,11 +61,11 @@ class OC_Search{ /** * create instances of all the registered search providers */ - private static function initProviders(){ - if(count(self::$providers)>0){ + private static function initProviders() { + if(count(self::$providers)>0) { return; } - foreach(self::$registeredProviders as $provider){ + foreach(self::$registeredProviders as $provider) { $class=$provider['class']; $options=$provider['options']; self::$providers[]=new $class($options); diff --git a/lib/search/provider.php b/lib/search/provider.php index b83c5aa61b6..b617b9c5d94 100644 --- a/lib/search/provider.php +++ b/lib/search/provider.php @@ -5,7 +5,7 @@ abstract class OC_Search_Provider { private $options; - public function __construct($options){ + public function __construct($options) { $this->options=$options; } diff --git a/lib/search/provider/file.php b/lib/search/provider/file.php index 12a535876fe..50e16457672 100644 --- a/lib/search/provider/file.php +++ b/lib/search/provider/file.php @@ -1,17 +1,17 @@ <?php class OC_Search_Provider_File extends OC_Search_Provider{ - function search($query){ + function search($query) { $files=OC_FileCache::search($query,true); $results=array(); - foreach($files as $fileData){ + foreach($files as $fileData) { $file=$fileData['path']; $mime=$fileData['mimetype']; - if($mime=='httpd/unix-directory'){ + if($mime=='httpd/unix-directory') { $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'index.php', array('dir' => $file)),'Files'); }else{ $mimeBase=$fileData['mimepart']; - switch($mimeBase){ + switch($mimeBase) { case 'audio': break; case 'text': @@ -21,7 +21,7 @@ class OC_Search_Provider_File extends OC_Search_Provider{ $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Images'); break; default: - if($mime=='application/xml'){ + if($mime=='application/xml') { $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Text'); }else{ $results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php', array('dir' => $file) ),'Files'); diff --git a/lib/search/result.php b/lib/search/result.php index cd78a5cf253..63b5cfabce6 100644 --- a/lib/search/result.php +++ b/lib/search/result.php @@ -15,7 +15,7 @@ class OC_Search_Result{ * @param string $link link for the result * @param string $type the type of result as human readable string ('File', 'Music', etc) */ - public function __construct($name,$text,$link,$type){ + public function __construct($name,$text,$link,$type) { $this->name=$name; $this->text=$text; $this->link=$link; diff --git a/lib/setup.php b/lib/setup.php index 271fe55fd70..f27254a42a4 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -74,7 +74,7 @@ class OC_Setup { $datadir = htmlspecialchars_decode($options['directory']); //use sqlite3 when available, otherise sqlite2 will be used. - if($dbtype=='sqlite' and class_exists('SQLite3')){ + if($dbtype=='sqlite' and class_exists('SQLite3')) { $dbtype='sqlite3'; } @@ -114,7 +114,7 @@ class OC_Setup { //add prefix to the mysql user name to prevent collisions $dbusername=substr('oc_'.$username,0,16); - if($dbusername!=$oldUser){ + if($dbusername!=$oldUser) { //hash the password so we don't need to store the admin config in the config file $dbpassword=md5(time().$password); @@ -128,7 +128,7 @@ class OC_Setup { self::createDatabase($dbname, $dbusername, $connection); } else { - if($dbuser!=$oldUser){ + if($dbuser!=$oldUser) { OC_Config::setValue('dbuser', $dbuser); OC_Config::setValue('dbpassword', $dbpass); } @@ -140,7 +140,7 @@ class OC_Setup { //fill the database if needed $query="select count(*) from information_schema.tables where table_schema='$dbname' AND table_name = '{$dbtableprefix}users';"; $result = mysql_query($query,$connection); - if($result){ + if($result) { $row=mysql_fetch_row($result); } if(!$result or $row[0]==0) { @@ -345,7 +345,7 @@ class OC_Setup { } else { //delete the old sqlite database first, might cause infinte loops otherwise - if(file_exists("$datadir/owncloud.db")){ + if(file_exists("$datadir/owncloud.db")) { unlink("$datadir/owncloud.db"); } //in case of sqlite, we can always fill the database diff --git a/lib/streamwrappers.php b/lib/streamwrappers.php index f502c6170bd..1e5b19a11f0 100644 --- a/lib/streamwrappers.php +++ b/lib/streamwrappers.php @@ -5,17 +5,17 @@ class OC_FakeDirStream{ private $name; private $index; - public function dir_opendir($path,$options){ + public function dir_opendir($path,$options) { $this->name=substr($path,strlen('fakedir://')); $this->index=0; - if(!isset(self::$dirs[$this->name])){ + if(!isset(self::$dirs[$this->name])) { self::$dirs[$this->name]=array(); } return true; } - public function dir_readdir(){ - if($this->index>=count(self::$dirs[$this->name])){ + public function dir_readdir() { + if($this->index>=count(self::$dirs[$this->name])) { return false; } $filename=self::$dirs[$this->name][$this->index]; @@ -222,35 +222,35 @@ class OC_CloseStreamWrapper{ private $path=''; private $source; private static $open=array(); - public function stream_open($path, $mode, $options, &$opened_path){ + public function stream_open($path, $mode, $options, &$opened_path) { $path=substr($path,strlen('close://')); $this->path=$path; $this->source=fopen($path,$mode); - if(is_resource($this->source)){ + if(is_resource($this->source)) { $this->meta=stream_get_meta_data($this->source); } self::$open[]=$path; return is_resource($this->source); } - public function stream_seek($offset, $whence=SEEK_SET){ + public function stream_seek($offset, $whence=SEEK_SET) { fseek($this->source,$offset,$whence); } - public function stream_tell(){ + public function stream_tell() { return ftell($this->source); } - public function stream_read($count){ + public function stream_read($count) { return fread($this->source,$count); } - public function stream_write($data){ + public function stream_write($data) { return fwrite($this->source,$data); } - public function stream_set_option($option,$arg1,$arg2){ - switch($option){ + public function stream_set_option($option,$arg1,$arg2) { + switch($option) { case STREAM_OPTION_BLOCKING: stream_set_blocking($this->source,$arg1); break; @@ -262,39 +262,39 @@ class OC_CloseStreamWrapper{ } } - public function stream_stat(){ + public function stream_stat() { return fstat($this->source); } - public function stream_lock($mode){ + public function stream_lock($mode) { flock($this->source,$mode); } - public function stream_flush(){ + public function stream_flush() { return fflush($this->source); } - public function stream_eof(){ + public function stream_eof() { return feof($this->source); } public function url_stat($path) { $path=substr($path,strlen('close://')); - if(file_exists($path)){ + if(file_exists($path)) { return stat($path); }else{ return false; } } - public function stream_close(){ + public function stream_close() { fclose($this->source); - if(isset(self::$callBacks[$this->path])){ + if(isset(self::$callBacks[$this->path])) { call_user_func(self::$callBacks[$this->path],$this->path); } } - public function unlink($path){ + public function unlink($path) { $path=substr($path,strlen('close://')); return unlink($path); } diff --git a/lib/subadmin.php b/lib/subadmin.php index 4752492df30..363e4a97cad 100644 --- a/lib/subadmin.php +++ b/lib/subadmin.php @@ -36,7 +36,7 @@ class OC_SubAdmin{ * @param $gid gid of the group * @return boolean */ - public static function createSubAdmin($uid, $gid){ + public static function createSubAdmin($uid, $gid) { $stmt = OC_DB::prepare('INSERT INTO `*PREFIX*group_admin` (`gid`,`uid`) VALUES(?,?)'); $result = $stmt->execute(array($gid, $uid)); OC_Hook::emit( "OC_SubAdmin", "post_createSubAdmin", array( "gid" => $gid )); @@ -49,7 +49,7 @@ class OC_SubAdmin{ * @param $gid gid of the group * @return boolean */ - public static function deleteSubAdmin($uid, $gid){ + public static function deleteSubAdmin($uid, $gid) { $stmt = OC_DB::prepare('DELETE FROM `*PREFIX*group_admin` WHERE `gid` = ? AND `uid` = ?'); $result = $stmt->execute(array($gid, $uid)); OC_Hook::emit( "OC_SubAdmin", "post_deleteSubAdmin", array( "gid" => $gid )); @@ -61,11 +61,11 @@ class OC_SubAdmin{ * @param $uid uid of the SubAdmin * @return array */ - public static function getSubAdminsGroups($uid){ + public static function getSubAdminsGroups($uid) { $stmt = OC_DB::prepare('SELECT `gid` FROM `*PREFIX*group_admin` WHERE `uid` = ?'); $result = $stmt->execute(array($uid)); $gids = array(); - while($row = $result->fetchRow()){ + while($row = $result->fetchRow()) { $gids[] = $row['gid']; } return $gids; @@ -76,11 +76,11 @@ class OC_SubAdmin{ * @param $gid gid of the group * @return array */ - public static function getGroupsSubAdmins($gid){ + public static function getGroupsSubAdmins($gid) { $stmt = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*group_admin` WHERE `gid` = ?'); $result = $stmt->execute(array($gid)); $uids = array(); - while($row = $result->fetchRow()){ + while($row = $result->fetchRow()) { $uids[] = $row['uid']; } return $uids; @@ -90,11 +90,11 @@ class OC_SubAdmin{ * @brief get all SubAdmins * @return array */ - public static function getAllSubAdmins(){ + public static function getAllSubAdmins() { $stmt = OC_DB::prepare('SELECT * FROM `*PREFIX*group_admin`'); $result = $stmt->execute(); $subadmins = array(); - while($row = $result->fetchRow()){ + while($row = $result->fetchRow()) { $subadmins[] = $row; } return $subadmins; @@ -106,11 +106,11 @@ class OC_SubAdmin{ * @param $gid gid of the group * @return bool */ - public static function isSubAdminofGroup($uid, $gid){ + public static function isSubAdminofGroup($uid, $gid) { $stmt = OC_DB::prepare('SELECT COUNT(*) AS `count` FROM `*PREFIX*group_admin` WHERE `uid` = ? AND `gid` = ?'); $result = $stmt->execute(array($uid, $gid)); $result = $result->fetchRow(); - if($result['count'] >= 1){ + if($result['count'] >= 1) { return true; } return false; @@ -121,11 +121,11 @@ class OC_SubAdmin{ * @param $uid uid of the subadmin * @return bool */ - public static function isSubAdmin($uid){ + public static function isSubAdmin($uid) { $stmt = OC_DB::prepare('SELECT COUNT(*) AS `count` FROM `*PREFIX*group_admin` WHERE `uid` = ?'); $result = $stmt->execute(array($uid)); $result = $result->fetchRow(); - if($result['count'] > 0){ + if($result['count'] > 0) { return true; } return false; @@ -137,16 +137,16 @@ class OC_SubAdmin{ * @param $user uid of the user * @return bool */ - public static function isUserAccessible($subadmin, $user){ - if(!self::isSubAdmin($subadmin)){ + public static function isUserAccessible($subadmin, $user) { + if(!self::isSubAdmin($subadmin)) { return false; } - if(OC_Group::inGroup($user, 'admin')){ + if(OC_Group::inGroup($user, 'admin')) { return false; } $accessiblegroups = self::getSubAdminsGroups($subadmin); - foreach($accessiblegroups as $accessiblegroup){ - if(OC_Group::inGroup($user, $accessiblegroup)){ + foreach($accessiblegroups as $accessiblegroup) { + if(OC_Group::inGroup($user, $accessiblegroup)) { return true; } } @@ -156,7 +156,7 @@ class OC_SubAdmin{ /* * @brief alias for self::isSubAdminofGroup() */ - public static function isGroupAccessible($subadmin, $group){ + public static function isGroupAccessible($subadmin, $group) { return self::isSubAdminofGroup($subadmin, $group); } @@ -165,7 +165,7 @@ class OC_SubAdmin{ * @param $parameters * @return boolean */ - public static function post_deleteUser($parameters){ + public static function post_deleteUser($parameters) { $stmt = OC_DB::prepare('DELETE FROM `*PREFIX*group_admin` WHERE `uid` = ?'); $result = $stmt->execute(array($parameters['uid'])); return true; @@ -176,7 +176,7 @@ class OC_SubAdmin{ * @param $parameters * @return boolean */ - public static function post_deleteGroup($parameters){ + public static function post_deleteGroup($parameters) { $stmt = OC_DB::prepare('DELETE FROM `*PREFIX*group_admin` WHERE `gid` = ?'); $result = $stmt->execute(array($parameters['gid'])); return true; diff --git a/lib/template.php b/lib/template.php index 2359bd50c46..8c872a2059b 100644 --- a/lib/template.php +++ b/lib/template.php @@ -30,7 +30,7 @@ * * For further information have a look at OC_Helper::linkTo */ -function link_to( $app, $file, $args = array() ){ +function link_to( $app, $file, $args = array() ) { return OC_Helper::linkTo( $app, $file, $args ); } @@ -42,7 +42,7 @@ function link_to( $app, $file, $args = array() ){ * * For further information have a look at OC_Helper::imagePath */ -function image_path( $app, $image ){ +function image_path( $app, $image ) { return OC_Helper::imagePath( $app, $image ); } @@ -53,7 +53,7 @@ function image_path( $app, $image ){ * * For further information have a look at OC_Helper::mimetypeIcon */ -function mimetype_icon( $mimetype ){ +function mimetype_icon( $mimetype ) { return OC_Helper::mimetypeIcon( $mimetype ); } @@ -64,7 +64,7 @@ function mimetype_icon( $mimetype ){ * * For further information have a look at OC_Helper::humanFileSize */ -function human_file_size( $bytes ){ +function human_file_size( $bytes ) { return OC_Helper::humanFileSize( $bytes ); } @@ -99,25 +99,25 @@ function relative_modified_date($timestamp) { } function html_select_options($options, $selected, $params=array()) { - if (!is_array($selected)){ + if (!is_array($selected)) { $selected=array($selected); } - if (isset($params['combine']) && $params['combine']){ + if (isset($params['combine']) && $params['combine']) { $options = array_combine($options, $options); } $value_name = $label_name = false; - if (isset($params['value'])){ + if (isset($params['value'])) { $value_name = $params['value']; } - if (isset($params['label'])){ + if (isset($params['label'])) { $label_name = $params['label']; } $html = ''; - foreach($options as $value => $label){ - if ($value_name && is_array($label)){ + foreach($options as $value => $label) { + if ($value_name && is_array($label)) { $value = $label[$value_name]; } - if ($label_name && is_array($label)){ + if ($label_name && is_array($label)) { $label = $label[$label_name]; } $select = in_array($value, $selected) ? ' selected="selected"' : ''; @@ -150,7 +150,7 @@ class OC_Template{ * according layout. For now, renderas can be set to "guest", "user" or * "admin". */ - public function __construct( $app, $name, $renderas = "" ){ + public function __construct( $app, $name, $renderas = "" ) { // Set the private data $this->renderas = $renderas; $this->application = $app; @@ -175,14 +175,14 @@ class OC_Template{ * sidebar, just the application. Useful to use just a specific * app on the desktop in a standalone window. */ - public static function detectFormfactor(){ + public static function detectFormfactor() { // please add more useragent strings for other devices - if(isset($_SERVER['HTTP_USER_AGENT'])){ + if(isset($_SERVER['HTTP_USER_AGENT'])) { if(stripos($_SERVER['HTTP_USER_AGENT'],'ipad')>0) { $mode='tablet'; - }elseif(stripos($_SERVER['HTTP_USER_AGENT'],'iphone')>0){ + }elseif(stripos($_SERVER['HTTP_USER_AGENT'],'iphone')>0) { $mode='mobile'; - }elseif((stripos($_SERVER['HTTP_USER_AGENT'],'N9')>0) and (stripos($_SERVER['HTTP_USER_AGENT'],'nokia')>0)){ + }elseif((stripos($_SERVER['HTTP_USER_AGENT'],'N9')>0) and (stripos($_SERVER['HTTP_USER_AGENT'],'nokia')>0)) { $mode='mobile'; }else{ $mode='default'; @@ -201,11 +201,11 @@ class OC_Template{ // if the formfactor is not yet autodetected do the // autodetection now. For possible formfactors check the // detectFormfactor documentation - if(!isset($_SESSION['formfactor'])){ + if(!isset($_SESSION['formfactor'])) { $_SESSION['formfactor'] = self::detectFormfactor(); } // allow manual override via GET parameter - if(isset($_GET['formfactor'])){ + if(isset($_GET['formfactor'])) { $_SESSION['formfactor']=$_GET['formfactor']; } $formfactor=$_SESSION['formfactor']; @@ -240,9 +240,9 @@ class OC_Template{ $app = $this->application; // Check if it is a app template or not. - if( $app != "" ){ + if( $app != "" ) { // Check if the app is in the app folder or in the root - if( file_exists(OC_App::getAppPath($app)."/templates/" )){ + if( file_exists(OC_App::getAppPath($app)."/templates/" )) { // Check if the template is overwritten by the selected theme if ($this->checkPathForTemplate(OC::$SERVERROOT."/themes/$theme/apps/$app/templates/", $name, $fext)) { }elseif ($this->checkPathForTemplate(OC_App::getAppPath($app)."/templates/", $name, $fext)) { @@ -282,9 +282,9 @@ class OC_Template{ { if ($name =='') return false; $template = null; - if( is_file( $path.$name.$fext.'.php' )){ + if( is_file( $path.$name.$fext.'.php' )) { $template = $path.$name.$fext.'.php'; - }elseif( is_file( $path.$name.'.php' )){ + }elseif( is_file( $path.$name.'.php' )) { $template = $path.$name.'.php'; } if ($template) { @@ -307,7 +307,7 @@ class OC_Template{ * * If the key existed before, it will be overwritten */ - public function assign( $key, $value, $sanitizeHTML=true ){ + public function assign( $key, $value, $sanitizeHTML=true ) { if($sanitizeHTML == true) $value=OC_Util::sanitizeHTML($value); $this->vars[$key] = $value; return true; @@ -323,8 +323,8 @@ class OC_Template{ * exists, the value will be appended. It can be accessed via * $_[$key][$position] in the template. */ - public function append( $key, $value ){ - if( array_key_exists( $key, $this->vars )){ + public function append( $key, $value ) { + if( array_key_exists( $key, $this->vars )) { $this->vars[$key][] = $value; } else{ @@ -338,7 +338,7 @@ class OC_Template{ * @param array $attributes array of attrobutes for the element * @param string $text the text content for the element */ - public function addHeader( $tag, $attributes, $text=''){ + public function addHeader( $tag, $attributes, $text='') { $this->headers[]=array('tag'=>$tag,'attributes'=>$attributes,'text'=>$text); } @@ -348,9 +348,9 @@ class OC_Template{ * * This function proceeds the template and prints its output. */ - public function printPage(){ + public function printPage() { $data = $this->fetchPage(); - if( $data === false ){ + if( $data === false ) { return false; } else{ @@ -366,10 +366,10 @@ class OC_Template{ * This function proceeds the template. If $this->renderas is set, it * will produce a full page. */ - public function fetchPage(){ + public function fetchPage() { $data = $this->_fetch(); - if( $this->renderas ){ + if( $this->renderas ) { $page = new OC_TemplateLayout($this->renderas); if($this->renderas == 'user') { $page->assign('requesttoken', $this->vars['requesttoken']); @@ -377,7 +377,7 @@ class OC_Template{ // Add custom headers $page->assign('headers',$this->headers, false); - foreach(OC_Util::$headers as $header){ + foreach(OC_Util::$headers as $header) { $page->append('headers',$header); } @@ -395,7 +395,7 @@ class OC_Template{ * * Includes the template file, fetches its output */ - private function _fetch(){ + private function _fetch() { // Register the variables $_ = $this->vars; $l = $this->l10n; @@ -417,12 +417,12 @@ class OC_Template{ * Includes another template. use <?php echo $this->inc('template'); ?> to * do this. */ - public function inc( $file, $additionalparams = null ){ + public function inc( $file, $additionalparams = null ) { // $_ erstellen $_ = $this->vars; $l = $this->l10n; - if( !is_null($additionalparams)){ + if( !is_null($additionalparams)) { $_ = array_merge( $additionalparams, $this->vars ); } @@ -443,9 +443,9 @@ class OC_Template{ * @param $parameters Parameters for the template * @returns true/false */ - public static function printUserPage( $application, $name, $parameters = array() ){ + public static function printUserPage( $application, $name, $parameters = array() ) { $content = new OC_Template( $application, $name, "user" ); - foreach( $parameters as $key => $value ){ + foreach( $parameters as $key => $value ) { $content->assign( $key, $value, false ); } print $content->printPage(); @@ -458,9 +458,9 @@ class OC_Template{ * @param $parameters Parameters for the template * @returns true/false */ - public static function printAdminPage( $application, $name, $parameters = array() ){ + public static function printAdminPage( $application, $name, $parameters = array() ) { $content = new OC_Template( $application, $name, "admin" ); - foreach( $parameters as $key => $value ){ + foreach( $parameters as $key => $value ) { $content->assign( $key, $value, false ); } return $content->printPage(); @@ -473,9 +473,9 @@ class OC_Template{ * @param $parameters Parameters for the template * @returns true/false */ - public static function printGuestPage( $application, $name, $parameters = array() ){ + public static function printGuestPage( $application, $name, $parameters = array() ) { $content = new OC_Template( $application, $name, "guest" ); - foreach( $parameters as $key => $value ){ + foreach( $parameters as $key => $value ) { $content->assign( $key, $value, false ); } return $content->printPage(); diff --git a/lib/templatelayout.php b/lib/templatelayout.php index 18fd23aac95..ad013edad8c 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -7,13 +7,13 @@ */ class OC_TemplateLayout extends OC_Template { - public function __construct( $renderas ){ + public function __construct( $renderas ) { // Decide which page we show - if( $renderas == 'user' ){ + if( $renderas == 'user' ) { parent::__construct( 'core', 'layout.user' ); $this->assign('searchurl',OC_Helper::linkTo( 'search', 'index.php' ), false); - if(array_search(OC_APP::getCurrentApp(),array('settings','admin','help'))!==false){ + if(array_search(OC_APP::getCurrentApp(),array('settings','admin','help'))!==false) { $this->assign('bodyid','body-settings', false); }else{ $this->assign('bodyid','body-user', false); @@ -36,7 +36,7 @@ class OC_TemplateLayout extends OC_Template { } $apps_paths = array(); - foreach(OC_App::getEnabledApps() as $app){ + 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 @@ -96,7 +96,7 @@ class OC_TemplateLayout extends OC_Template { return false; } - static public function findStylesheetFiles($styles){ + static public function findStylesheetFiles($styles) { // Read the selected theme from the config file $theme=OC_Config::getValue( 'theme' ); @@ -104,7 +104,7 @@ class OC_TemplateLayout extends OC_Template { $fext = self::getFormFactorExtension(); $files = array(); - foreach($styles as $style){ + foreach($styles as $style) { // is it in 3rdparty? if(self::appendIfExist($files, OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $style.'.css')) { @@ -132,7 +132,7 @@ class OC_TemplateLayout extends OC_Template { } // Add the theme css files. you can override the default values here if(!empty($theme)) { - foreach($styles as $style){ + foreach($styles as $style) { if(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style$fext.css" )) { }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style.css" )) { @@ -147,7 +147,7 @@ class OC_TemplateLayout extends OC_Template { return $files; } - static public function findJavascriptFiles($scripts){ + static public function findJavascriptFiles($scripts) { // Read the selected theme from the config file $theme=OC_Config::getValue( 'theme' ); @@ -155,7 +155,7 @@ class OC_TemplateLayout extends OC_Template { $fext = self::getFormFactorExtension(); $files = array(); - foreach($scripts as $script){ + foreach($scripts as $script) { // Is it in 3rd party? if(self::appendIfExist($files, OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $script.'.js')) { diff --git a/lib/updater.php b/lib/updater.php index 1b1a4eab970..ad42f2bf605 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -28,7 +28,7 @@ class OC_Updater{ /** * Check if a new version is available */ - public static function check(){ + public static function check() { OC_Appconfig::setValue('core', 'lastupdatedat',microtime(true)); if(OC_Appconfig::getValue('core', 'installedat','')=='') OC_Appconfig::setValue('core', 'installedat',microtime(true)); @@ -43,7 +43,7 @@ class OC_Updater{ //fetch xml data from updater $url=$updaterurl.'?version='.$versionstring; $xml=@file_get_contents($url); - if($xml==FALSE){ + if($xml==FALSE) { return array(); } $data=@simplexml_load_string($xml); @@ -57,10 +57,10 @@ class OC_Updater{ return $tmp; } - public static function ShowUpdatingHint(){ + public static function ShowUpdatingHint() { $l = OC_L10N::get('lib'); - if(OC_Config::getValue('updatechecker', true)==true){ + 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>'; @@ -77,7 +77,7 @@ class OC_Updater{ /** * do ownCloud update */ - public static function doUpdate(){ + public static function doUpdate() { //update ownCloud core diff --git a/lib/user.php b/lib/user.php index 236478e9e5c..89dab9f9647 100644 --- a/lib/user.php +++ b/lib/user.php @@ -52,7 +52,7 @@ class OC_User { * * Makes a list of backends that can be used by other modules */ - public static function registerBackend( $backend ){ + public static function registerBackend( $backend ) { self::$_backends[] = $backend; return true; } @@ -63,7 +63,7 @@ class OC_User { * * Returns the names of all backends. */ - public static function getBackends(){ + public static function getBackends() { return self::$_backends; } @@ -73,7 +73,7 @@ class OC_User { * * Returns the names of all used backends. */ - public static function getUsedBackends(){ + public static function getUsedBackends() { return array_keys(self::$_usedBackends); } @@ -84,17 +84,17 @@ class OC_User { * * Set the User Authentication Module */ - public static function useBackend( $backend = 'database' ){ - if($backend instanceof OC_User_Interface){ + public static function useBackend( $backend = 'database' ) { + if($backend instanceof OC_User_Interface) { self::$_usedBackends[get_class($backend)]=$backend; }else{ // You'll never know what happens - if( null === $backend OR !is_string( $backend )){ + if( null === $backend OR !is_string( $backend )) { $backend = 'database'; } // Load backend - switch( $backend ){ + switch( $backend ) { case 'database': case 'mysql': case 'sqlite': @@ -112,19 +112,19 @@ class OC_User { /** * remove all used backends */ - public static function clearBackends(){ + public static function clearBackends() { self::$_usedBackends=array(); } /** * setup the configured backends in config.php */ - public static function setupBackends(){ + public static function setupBackends() { $backends=OC_Config::getValue('user_backends',array()); - foreach($backends as $i=>$config){ + 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); @@ -149,23 +149,23 @@ class OC_User { * * Allowed characters in the username are: "a-z", "A-Z", "0-9" and "_.@-" */ - public static function createUser( $uid, $password ){ + public static function createUser( $uid, $password ) { // Check the name for bad characters // Allowed are: "a-z", "A-Z", "0-9" and "_.@-" - if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $uid )){ + if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $uid )) { throw new Exception('Only the following characters are allowed in a username: "a-z", "A-Z", "0-9", and "_.@-"'); } // No empty username - if(trim($uid) == ''){ + if(trim($uid) == '') { throw new Exception('A valid username must be provided'); } // No empty password - if(trim($password) == ''){ + if(trim($password) == '') { throw new Exception('A valid password must be provided'); } // Check if user already exists - if( self::userExists($uid) ){ + if( self::userExists($uid) ) { throw new Exception('The username is already being used'); } @@ -173,9 +173,9 @@ class OC_User { $run = true; OC_Hook::emit( "OC_User", "pre_createUser", array( "run" => &$run, "uid" => $uid, "password" => $password )); - if( $run ){ + if( $run ) { //create the user in the first backend that supports creating users - foreach(self::$_usedBackends as $backend){ + foreach(self::$_usedBackends as $backend) { if(!$backend->implementsActions(OC_USER_BACKEND_CREATE_USER)) continue; @@ -195,17 +195,17 @@ class OC_User { * * Deletes a user */ - public static function deleteUser( $uid ){ + public static function deleteUser( $uid ) { $run = true; OC_Hook::emit( "OC_User", "pre_deleteUser", array( "run" => &$run, "uid" => $uid )); - if( $run ){ + if( $run ) { //delete the user from all backends - foreach(self::$_usedBackends as $backend){ + foreach(self::$_usedBackends as $backend) { $backend->deleteUser($uid); } // We have to delete the user from all groups - foreach( OC_Group::getUserGroups( $uid ) as $i ){ + foreach( OC_Group::getUserGroups( $uid ) as $i ) { OC_Group::removeFromGroup( $uid, $i ); } // Delete the user's keys in preferences @@ -227,14 +227,14 @@ class OC_User { * * Log in a user and regenerate a new session - if the password is ok */ - public static function login( $uid, $password ){ + public static function login( $uid, $password ) { $run = true; OC_Hook::emit( "OC_User", "pre_login", array( "run" => &$run, "uid" => $uid )); - if( $run ){ + if( $run ) { $uid = self::checkPassword( $uid, $password ); $enabled = self::isEnabled($uid); - if($uid && $enabled){ + if($uid && $enabled) { session_regenerate_id(true); self::setUserId($uid); OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid, 'password'=>$password )); @@ -260,7 +260,7 @@ class OC_User { * * Logout, destroys session */ - public static function logout(){ + public static function logout() { OC_Hook::emit( "OC_User", "logout", array()); session_unset(); session_destroy(); @@ -274,11 +274,11 @@ class OC_User { * * Checks if the user is logged in */ - public static function isLoggedIn(){ + public static function isLoggedIn() { if( isset($_SESSION['user_id']) AND $_SESSION['user_id']) { OC_App::loadApps(array('authentication')); self::setupBackends(); - if (self::userExists($_SESSION['user_id']) ){ + if (self::userExists($_SESSION['user_id']) ) { return true; } } @@ -289,8 +289,8 @@ class OC_User { * @brief get the user id of the user currently logged in. * @return string uid or false */ - public static function getUser(){ - if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] ){ + public static function getUser() { + if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] ) { return $_SESSION['user_id']; } else{ @@ -304,7 +304,7 @@ class OC_User { * * generates a password */ - public static function generatePassword(){ + public static function generatePassword() { return uniqId(); } @@ -316,15 +316,15 @@ class OC_User { * * Change the password of a user */ - public static function setPassword( $uid, $password ){ + public static function setPassword( $uid, $password ) { $run = true; OC_Hook::emit( "OC_User", "pre_setPassword", array( "run" => &$run, "uid" => $uid, "password" => $password )); - if( $run ){ + if( $run ) { $success = false; - foreach(self::$_usedBackends as $backend){ - if($backend->implementsActions(OC_USER_BACKEND_SET_PASSWORD)){ - if($backend->userExists($uid)){ + foreach(self::$_usedBackends as $backend) { + if($backend->implementsActions(OC_USER_BACKEND_SET_PASSWORD)) { + if($backend->userExists($uid)) { $success |= $backend->setPassword($uid,$password); } } @@ -346,11 +346,11 @@ class OC_User { * Check if the password is correct without logging in the user * returns the user id or false */ - public static function checkPassword( $uid, $password ){ - foreach(self::$_usedBackends as $backend){ - if($backend->implementsActions(OC_USER_BACKEND_CHECK_PASSWORD)){ + public static function checkPassword( $uid, $password ) { + foreach(self::$_usedBackends as $backend) { + if($backend->implementsActions(OC_USER_BACKEND_CHECK_PASSWORD)) { $result=$backend->checkPassword( $uid, $password ); - if($result){ + if($result) { return $result; } } @@ -366,11 +366,11 @@ class OC_User { * Check if the password is correct without logging in the user * returns the user id or false */ - public static function getHome($uid){ - foreach(self::$_usedBackends as $backend){ - if($backend->implementsActions(OC_USER_BACKEND_GET_HOME)){ + public static function getHome($uid) { + foreach(self::$_usedBackends as $backend) { + if($backend->implementsActions(OC_USER_BACKEND_GET_HOME)) { $result=$backend->getHome($uid); - if($result){ + if($result) { return $result; } } @@ -401,10 +401,10 @@ class OC_User { * @param string $uid the username * @return boolean */ - public static function userExists($uid){ - foreach(self::$_usedBackends as $backend){ + public static function userExists($uid) { + foreach(self::$_usedBackends as $backend) { $result=$backend->userExists($uid); - if($result===true){ + if($result===true) { return true; } } @@ -415,7 +415,7 @@ class OC_User { * disables a user * @param string $userid the user to disable */ - public static function disableUser($userid){ + public static function disableUser($userid) { $query = "INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, `configkey`, `configvalue`) VALUES(?, ?, ?, ?)"; $query = OC_DB::prepare($query); $query->execute(array($userid, 'core', 'enabled', 'false')); @@ -425,7 +425,7 @@ class OC_User { * enable a user * @param string $userid */ - public static function enableUser($userid){ + public static function enableUser($userid) { $query = "DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?"; $query = OC_DB::prepare($query); $query->execute(array($userid, 'core', 'enabled', 'false')); @@ -436,7 +436,7 @@ class OC_User { * @param string $userid * @return bool */ - public static function isEnabled($userid){ + public static function isEnabled($userid) { $query = "SELECT `userid` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?"; $query = OC_DB::prepare($query); $results = $query->execute(array($userid, 'core', 'enabled', 'false')); @@ -447,7 +447,7 @@ class OC_User { * @brief Set cookie value to use in next page load * @param string $username username to be set */ - public static function setMagicInCookie($username, $token){ + public static function setMagicInCookie($username, $token) { $secure_cookie = OC_Config::getValue("forcessl", false); setcookie("oc_username", $username, time()+60*60*24*15, '', '', $secure_cookie); setcookie("oc_token", $token, time()+60*60*24*15, '', '', $secure_cookie); @@ -457,7 +457,7 @@ class OC_User { /** * @brief Remove cookie for "remember username" */ - public static function unsetMagicInCookie(){ + public static function unsetMagicInCookie() { unset($_COOKIE["oc_username"]); unset($_COOKIE["oc_token"]); unset($_COOKIE["oc_remember_login"]); diff --git a/lib/user/backend.php b/lib/user/backend.php index 0ef7ccd0468..2a95db93690 100644 --- a/lib/user/backend.php +++ b/lib/user/backend.php @@ -59,9 +59,9 @@ abstract class OC_User_Backend implements OC_User_Interface { * Returns the supported actions as int to be * compared with OC_USER_BACKEND_CREATE_USER etc. */ - public function getSupportedActions(){ + public function getSupportedActions() { $actions = 0; - foreach($this->possibleActions AS $action => $methodName){ + foreach($this->possibleActions AS $action => $methodName) { if(method_exists($this, $methodName)) { $actions |= $action; } @@ -78,7 +78,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * Returns the supported actions as int to be * compared with OC_USER_BACKEND_CREATE_USER etc. */ - public function implementsActions($actions){ + public function implementsActions($actions) { return (bool)($this->getSupportedActions() & $actions); } @@ -89,7 +89,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * * Deletes a user */ - public function deleteUser( $uid ){ + public function deleteUser( $uid ) { return false; } @@ -108,7 +108,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * @param string $uid the username * @return boolean */ - public function userExists($uid){ + public function userExists($uid) { return false; } @@ -117,7 +117,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * @param string $uid the username * @return boolean */ - public function getHome($uid){ + public function getHome($uid) { return false; } } diff --git a/lib/user/database.php b/lib/user/database.php index 52f3b35fa5c..76b44a2f6ca 100644 --- a/lib/user/database.php +++ b/lib/user/database.php @@ -44,8 +44,8 @@ class OC_User_Database extends OC_User_Backend { */ static private $hasher=null; - private function getHasher(){ - if(!self::$hasher){ + private function getHasher() { + if(!self::$hasher) { //we don't want to use DES based crypt(), since it doesn't return a has with a recognisable prefix $forcePortable=(CRYPT_BLOWFISH!=1); self::$hasher=new PasswordHash(8,$forcePortable); @@ -63,8 +63,8 @@ class OC_User_Database extends OC_User_Backend { * Creates a new user. Basic checking of username is done in OC_User * itself, not in its subclasses. */ - public function createUser( $uid, $password ){ - if( $this->userExists($uid) ){ + public function createUser( $uid, $password ) { + if( $this->userExists($uid) ) { return false; }else{ $hasher=$this->getHasher(); @@ -83,7 +83,7 @@ class OC_User_Database extends OC_User_Backend { * * Deletes a user */ - public function deleteUser( $uid ){ + public function deleteUser( $uid ) { // Delete user-group-relation $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*users` WHERE uid = ?' ); $query->execute( array( $uid )); @@ -98,8 +98,8 @@ class OC_User_Database extends OC_User_Backend { * * Change the password of a user */ - public function setPassword( $uid, $password ){ - if( $this->userExists($uid) ){ + public function setPassword( $uid, $password ) { + if( $this->userExists($uid) ) { $hasher=$this->getHasher(); $hash = $hasher->HashPassword($password.OC_Config::getValue('passwordsalt', '')); $query = OC_DB::prepare( 'UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?' ); @@ -120,22 +120,22 @@ class OC_User_Database extends OC_User_Backend { * Check if the password is correct without logging in the user * returns the user id or false */ - public function checkPassword( $uid, $password ){ + public function checkPassword( $uid, $password ) { $query = OC_DB::prepare( 'SELECT `uid`, `password` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)' ); $result = $query->execute( array( $uid)); $row=$result->fetchRow(); - if($row){ + if($row) { $storedHash=$row['password']; - if ($storedHash[0]=='$'){//the new phpass based hashing + if ($storedHash[0]=='$') {//the new phpass based hashing $hasher=$this->getHasher(); - if($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash)){ + if($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash)) { return $row['uid']; }else{ return false; } }else{//old sha1 based hashing - if(sha1($password)==$storedHash){ + if(sha1($password)==$storedHash) { //upgrade to new hashing $this->setPassword($row['uid'],$password); return $row['uid']; @@ -169,7 +169,7 @@ class OC_User_Database extends OC_User_Backend { * @param string $uid the username * @return boolean */ - public function userExists($uid){ + public function userExists($uid) { $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)' ); $result = $query->execute( array( $uid )); @@ -181,8 +181,8 @@ class OC_User_Database extends OC_User_Backend { * @param string $uid the username * @return boolean */ - public function getHome($uid){ - if($this->userExists($uid)){ + public function getHome($uid) { + if($this->userExists($uid)) { return OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ) . '/' . $uid; }else{ return false; diff --git a/lib/user/dummy.php b/lib/user/dummy.php index 15a67b7e1ed..4dbbc02b888 100644 --- a/lib/user/dummy.php +++ b/lib/user/dummy.php @@ -35,8 +35,8 @@ class OC_User_Dummy extends OC_User_Backend { * Creates a new user. Basic checking of username is done in OC_User * itself, not in its subclasses. */ - public function createUser($uid, $password){ - if(isset($this->users[$uid])){ + public function createUser($uid, $password) { + if(isset($this->users[$uid])) { return false; }else{ $this->users[$uid]=$password; @@ -51,8 +51,8 @@ class OC_User_Dummy extends OC_User_Backend { * * Deletes a user */ - public function deleteUser( $uid ){ - if(isset($this->users[$uid])){ + public function deleteUser( $uid ) { + if(isset($this->users[$uid])) { unset($this->users[$uid]); return true; }else{ @@ -68,8 +68,8 @@ class OC_User_Dummy extends OC_User_Backend { * * Change the password of a user */ - public function setPassword($uid, $password){ - if(isset($this->users[$uid])){ + public function setPassword($uid, $password) { + if(isset($this->users[$uid])) { $this->users[$uid]=$password; return true; }else{ @@ -86,8 +86,8 @@ class OC_User_Dummy extends OC_User_Backend { * Check if the password is correct without logging in the user * returns the user id or false */ - public function checkPassword($uid, $password){ - if(isset($this->users[$uid])){ + public function checkPassword($uid, $password) { + if(isset($this->users[$uid])) { return ($this->users[$uid]==$password); }else{ return false; @@ -109,7 +109,7 @@ class OC_User_Dummy extends OC_User_Backend { * @param string $uid the username * @return boolean */ - public function userExists($uid){ + public function userExists($uid) { return isset($this->users[$uid]); } } diff --git a/lib/user/http.php b/lib/user/http.php index 5149678e4ed..2668341408d 100644 --- a/lib/user/http.php +++ b/lib/user/http.php @@ -30,14 +30,14 @@ class OC_User_HTTP extends OC_User_Backend { * @param string path * @return array */ - private function parseUrl($url){ + private function parseUrl($url) { $parts=parse_url($url); $url=$parts['scheme'].'://'.$parts['host']; - if(isset($parts['port'])){ + if(isset($parts['port'])) { $url.=':'.$parts['port']; } $url.=$parts['path']; - if(isset($parts['query'])){ + if(isset($parts['query'])) { $url.='?'.$parts['query']; } return array($parts['user'],$url); @@ -49,7 +49,7 @@ class OC_User_HTTP extends OC_User_Backend { * @param string url * @return boolean */ - private function matchUrl($url){ + private function matchUrl($url) { return ! is_null(parse_url($url,PHP_URL_USER)); } @@ -62,8 +62,8 @@ class OC_User_HTTP extends OC_User_Backend { * Check if the password is correct without logging in the user * returns the user id or false */ - public function checkPassword($uid, $password){ - if(!$this->matchUrl($uid)){ + public function checkPassword($uid, $password) { + if(!$this->matchUrl($uid)) { return false; } list($user,$url)=$this->parseUrl($uid); @@ -87,7 +87,7 @@ class OC_User_HTTP extends OC_User_Backend { * @param string $uid the username * @return boolean */ - public function userExists($uid){ + public function userExists($uid) { return $this->matchUrl($uid); } @@ -96,8 +96,8 @@ class OC_User_HTTP extends OC_User_Backend { * @param string $uid the username * @return boolean */ - public function getHome($uid){ - if($this->userExists($uid)){ + public function getHome($uid) { + if($this->userExists($uid)) { return OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ) . '/' . $uid; }else{ return false; diff --git a/lib/util.php b/lib/util.php index b742e27b55d..5046550d6a2 100755 --- a/lib/util.php +++ b/lib/util.php @@ -14,13 +14,13 @@ class OC_Util { public static $core_scripts=array(); // Can be set up - public static function setupFS( $user = '' ){// configure the initial filesystem based on the configuration - if(self::$fsSetup){//setting up the filesystem twice can only lead to trouble + public static function setupFS( $user = '' ) {// configure the initial filesystem based on the configuration + if(self::$fsSetup) {//setting up the filesystem twice can only lead to trouble return false; } // If we are not forced to load a specific user we load the one that is logged in - if( $user == "" && OC_User::isLoggedIn()){ + if( $user == "" && OC_User::isLoggedIn()) { $user = OC_User::getUser(); } @@ -33,16 +33,16 @@ class OC_Util { $CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); //first set up the local "root" storage - if(!self::$rootMounted){ + if(!self::$rootMounted) { OC_Filesystem::mount('OC_Filestorage_Local',array('datadir'=>$CONFIG_DATADIRECTORY),'/'); self::$rootMounted=true; } - if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem + if( $user != "" ) { //if we aren't logged in, there is no use to set up the filesystem $user_dir = '/'.$user.'/files'; $user_root = OC_User::getHome($user); $userdirectory = $user_root . '/files'; - if( !is_dir( $userdirectory )){ + if( !is_dir( $userdirectory )) { mkdir( $userdirectory, 0755, true ); } //jail the user into his "home" directory @@ -61,7 +61,7 @@ class OC_Util { $mtime=filemtime($user_root.'/mount.php'); $previousMTime=OC_Preferences::getValue($user,'files','mountconfigmtime',0); - if($mtime>$previousMTime){//mount config has changed, filecache needs to be updated + if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated OC_FileCache::clear($user); OC_Preferences::setValue($user,'files','mountconfigmtime',$mtime); } @@ -70,7 +70,7 @@ class OC_Util { } } - public static function tearDownFS(){ + public static function tearDownFS() { OC_Filesystem::tearDown(); self::$fsSetup=false; } @@ -79,7 +79,7 @@ class OC_Util { * get the current installed version of ownCloud * @return array */ - public static function getVersion(){ + public static function getVersion() { // hint: We only can count up. So the internal version number of ownCloud 4.5 will be 4,9,0. This is not visible to the user return array(4,83,6); } @@ -88,7 +88,7 @@ class OC_Util { * get the current installed version string of ownCloud * @return string */ - public static function getVersionString(){ + public static function getVersionString() { return '4.5 beta 2'; } @@ -96,7 +96,7 @@ class OC_Util { * get the current installed edition of ownCloud. There is the community edition that just returns an empty string and the enterprise edition that returns "Enterprise". * @return string */ - public static function getEditionString(){ + public static function getEditionString() { return ''; } @@ -106,12 +106,12 @@ class OC_Util { * @param appid $application * @param filename $file */ - public static function addScript( $application, $file = null ){ - if( is_null( $file )){ + public static function addScript( $application, $file = null ) { + if( is_null( $file )) { $file = $application; $application = ""; } - if( !empty( $application )){ + if( !empty( $application )) { self::$scripts[] = "$application/js/$file"; }else{ self::$scripts[] = "js/$file"; @@ -124,12 +124,12 @@ class OC_Util { * @param appid $application * @param filename $file */ - public static function addStyle( $application, $file = null ){ - if( is_null( $file )){ + public static function addStyle( $application, $file = null ) { + if( is_null( $file )) { $file = $application; $application = ""; } - if( !empty( $application )){ + if( !empty( $application )) { self::$styles[] = "$application/css/$file"; }else{ self::$styles[] = "css/$file"; @@ -142,7 +142,7 @@ class OC_Util { * @param array $attributes array of attributes for the element * @param string $text the text content for the element */ - public static function addHeader( $tag, $attributes, $text=''){ + public static function addHeader( $tag, $attributes, $text='') { self::$headers[]=array('tag'=>$tag,'attributes'=>$attributes,'text'=>$text); } @@ -152,8 +152,8 @@ class OC_Util { * @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 + 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; @@ -197,11 +197,11 @@ class OC_Util { * check if the current server configuration is suitable for ownCloud * @return array arrays with error messages and hints */ - public static function checkServer(){ + public static function checkServer() { $errors=array(); //check for database drivers - if(!(is_callable('sqlite_open') or class_exists('SQLite3')) and !is_callable('mysql_connect') and !is_callable('pg_connect')){ + if(!(is_callable('sqlite_open') or class_exists('SQLite3')) and !is_callable('mysql_connect') and !is_callable('pg_connect')) { $errors[]=array('error'=>'No database drivers (sqlite, mysql, or postgresql) installed.<br/>','hint'=>'');//TODO: sane hint } @@ -223,25 +223,25 @@ class OC_Util { $CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); //check for correct file permissions - if(!stristr(PHP_OS, 'WIN')){ + if(!stristr(PHP_OS, 'WIN')) { $permissionsModHint="Please change the permissions to 0770 so that the directory cannot be listed by other users."; $prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY)),-3); - if(substr($prems,-1)!='0'){ + if(substr($prems,-1)!='0') { OC_Helper::chmodr($CONFIG_DATADIRECTORY,0770); clearstatcache(); $prems=substr(decoct(@fileperms($CONFIG_DATADIRECTORY)),-3); - if(substr($prems,2,1)!='0'){ + if(substr($prems,2,1)!='0') { $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') is readable for other users<br/>','hint'=>$permissionsModHint); } } - if( OC_Config::getValue( "enablebackup", false )){ + if( OC_Config::getValue( "enablebackup", false )) { $CONFIG_BACKUPDIRECTORY = OC_Config::getValue( "backupdirectory", OC::$SERVERROOT."/backup" ); $prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)),-3); - if(substr($prems,-1)!='0'){ + if(substr($prems,-1)!='0') { OC_Helper::chmodr($CONFIG_BACKUPDIRECTORY,0770); clearstatcache(); $prems=substr(decoct(@fileperms($CONFIG_BACKUPDIRECTORY)),-3); - if(substr($prems,2,1)!='0'){ + if(substr($prems,2,1)!='0') { $errors[]=array('error'=>'Data directory ('.$CONFIG_BACKUPDIRECTORY.') is readable for other users<br/>','hint'=>$permissionsModHint); } } @@ -250,39 +250,39 @@ class OC_Util { //TODO: permissions checks for windows hosts } // Create root dir. - if(!is_dir($CONFIG_DATADIRECTORY)){ + if(!is_dir($CONFIG_DATADIRECTORY)) { $success=@mkdir($CONFIG_DATADIRECTORY); if(!$success) { $errors[]=array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY.")",'hint'=>"You can usually fix this by giving the webserver write access to the ownCloud directory '".OC::$SERVERROOT."' (in a terminal, use the command 'chown -R www-data:www-data /path/to/your/owncloud/install/data' "); } - } else if(!is_writable($CONFIG_DATADIRECTORY)){ + } else if(!is_writable($CONFIG_DATADIRECTORY)) { $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') not writable by ownCloud<br/>','hint'=>$permissionsHint); } // check if all required php modules are present - if(!class_exists('ZipArchive')){ + if(!class_exists('ZipArchive')) { $errors[]=array('error'=>'PHP module zip not installed.<br/>','hint'=>'Please ask your server administrator to install the module.'); } - if(!function_exists('mb_detect_encoding')){ + if(!function_exists('mb_detect_encoding')) { $errors[]=array('error'=>'PHP module mb multibyte not installed.<br/>','hint'=>'Please ask your server administrator to install the module.'); } - if(!function_exists('ctype_digit')){ + 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')){ + 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')){ + if(!function_exists('imagepng')) { $errors[]=array('error'=>'PHP module GD is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.'); } - if(!function_exists('gzencode')){ + if(!function_exists('gzencode')) { $errors[]=array('error'=>'PHP module zlib is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.'); } - if(floatval(phpversion())<5.3){ + if(floatval(phpversion())<5.3) { $errors[]=array('error'=>'PHP 5.3 is required.<br/>','hint'=>'Please ask your server administrator to update PHP to version 5.3 or higher. PHP 5.2 is no longer supported by ownCloud and the PHP community.'); } - if(!defined('PDO::ATTR_DRIVER_NAME')){ + if(!defined('PDO::ATTR_DRIVER_NAME')) { $errors[]=array('error'=>'PHP PDO module is not installed.<br/>','hint'=>'Please ask your server administrator to install the module.'); } @@ -316,8 +316,8 @@ class OC_Util { /** * Check if the app is enabled, redirects to home if not */ - public static function checkAppEnabled($app){ - if( !OC_App::isEnabled($app)){ + public static function checkAppEnabled($app) { + if( !OC_App::isEnabled($app)) { header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' )); exit(); } @@ -327,9 +327,9 @@ class OC_Util { * Check if the user is logged in, redirects to home if not. With * redirect URL parameter to the request URI. */ - public static function checkLoggedIn(){ + public static function checkLoggedIn() { // Check if we are a user - if( !OC_User::isLoggedIn()){ + if( !OC_User::isLoggedIn()) { header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php', array('redirect_url' => urlencode($_SERVER["REQUEST_URI"])))); exit(); } @@ -338,10 +338,10 @@ class OC_Util { /** * Check if the user is a admin, redirects to home if not */ - public static function checkAdminUser(){ + public static function checkAdminUser() { // Check if we are a user self::checkLoggedIn(); - if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )){ + if( !OC_Group::inGroup( OC_User::getUser(), 'admin' )) { header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' )); exit(); } @@ -351,13 +351,13 @@ class OC_Util { * Check if the user is a subadmin, redirects to home if not * @return array $groups where the current user is subadmin */ - public static function checkSubAdminUser(){ + public static function checkSubAdminUser() { // Check if we are a user self::checkLoggedIn(); - if(OC_Group::inGroup(OC_User::getUser(),'admin')){ + if(OC_Group::inGroup(OC_User::getUser(),'admin')) { return true; } - if(!OC_SubAdmin::isSubAdmin(OC_User::getUser())){ + if(!OC_SubAdmin::isSubAdmin(OC_User::getUser())) { header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php' )); exit(); } @@ -367,7 +367,7 @@ class OC_Util { /** * Redirect to the user default page */ - public static function redirectToDefaultPage(){ + public static function redirectToDefaultPage() { if(isset($_REQUEST['redirect_url']) && (substr($_REQUEST['redirect_url'], 0, strlen(OC::$WEBROOT)) == OC::$WEBROOT || $_REQUEST['redirect_url'][0] == '/')) { $location = $_REQUEST['redirect_url']; } @@ -392,9 +392,9 @@ class OC_Util { * get an id unqiue for this instance * @return string */ - public static function getInstanceId(){ + public static function getInstanceId() { $id=OC_Config::getValue('instanceid',null); - if(is_null($id)){ + if(is_null($id)) { $id=uniqid(); OC_Config::setValue('instanceid',$id); } @@ -406,7 +406,7 @@ class OC_Util { * Todo: Write howto * @return $token Generated token. */ - public static function callRegister(){ + public static function callRegister() { //mamimum time before token exires $maxtime=(60*60); // 1 hour @@ -422,7 +422,7 @@ class OC_Util { foreach($_SESSION as $key=>$value) { // search all tokens in the session if(substr($key,0,12)=='requesttoken') { - if($value+$maxtime<time()){ + if($value+$maxtime<time()) { // remove outdated tokens unset($_SESSION[$key]); } @@ -438,14 +438,14 @@ class OC_Util { * @brief Check an ajax get/post call if the request token is valid. * @return boolean False if request token is not set or is invalid. */ - public static function isCallRegistered(){ + public static function isCallRegistered() { //mamimum time before token exires $maxtime=(60*60); // 1 hour if(isset($_GET['requesttoken'])) { $token=$_GET['requesttoken']; - }elseif(isset($_POST['requesttoken'])){ + }elseif(isset($_POST['requesttoken'])) { $token=$_POST['requesttoken']; - }elseif(isset($_SERVER['HTTP_REQUESTTOKEN'])){ + }elseif(isset($_SERVER['HTTP_REQUESTTOKEN'])) { $token=$_SERVER['HTTP_REQUESTTOKEN']; }else{ //no token found. @@ -453,7 +453,7 @@ class OC_Util { } if(isset($_SESSION['requesttoken-'.$token])) { $timestamp=$_SESSION['requesttoken-'.$token]; - if($timestamp+$maxtime<time()){ + if($timestamp+$maxtime<time()) { return false; }else{ //token valid @@ -468,7 +468,7 @@ class OC_Util { * @brief Check an ajax get/post call if the request token is valid. exit if not. * Todo: Write howto */ - public static function callCheck(){ + public static function callCheck() { if(!OC_Util::isCallRegistered()) { exit; } @@ -483,7 +483,7 @@ class OC_Util { * @param string or array of strings * @return array with sanitized strings or a single sanitized string, depends on the input parameter. */ - public static function sanitizeHTML( &$value ){ + public static function sanitizeHTML( &$value ) { if (is_array($value) || is_object($value)) array_walk_recursive($value,'OC_Util::sanitizeHTML'); else $value = htmlentities($value, ENT_QUOTES, 'UTF-8'); //Specify encoding for PHP<5.4 return $value; diff --git a/lib/vcategories.php b/lib/vcategories.php index 05dfe18db6f..f5123adeeb6 100644 --- a/lib/vcategories.php +++ b/lib/vcategories.php @@ -125,7 +125,7 @@ class OC_VCategories { * $result = $stmt->execute(); * $objects = array(); * if(!is_null($result)) { - * while( $row = $result->fetchRow()){ + * while( $row = $result->fetchRow()) { * $objects[] = $row['carddata']; * } * } @@ -183,7 +183,7 @@ class OC_VCategories { if(!is_null($objects)) { foreach($objects as $key=>&$value) { $vobject = OC_VObject::parse($value[1]); - if(!is_null($vobject)){ + if(!is_null($vobject)) { $categories = $vobject->getAsArray('CATEGORIES'); //OC_Log::write('core','OC_VCategories::delete, before: '.$key.': '.print_r($categories, true), OC_Log::DEBUG); foreach($names as $name) { diff --git a/lib/vobject.php b/lib/vobject.php index ec80e1d605a..b5a04b4bf65 100644 --- a/lib/vobject.php +++ b/lib/vobject.php @@ -30,7 +30,7 @@ class OC_VObject{ /** * @returns Sabre_VObject_Component */ - public function getVObject(){ + public function getVObject() { return $this->vobject; } @@ -39,11 +39,11 @@ class OC_VObject{ * @param string VObject as string * @returns Sabre_VObject or null */ - public static function parse($data){ + public static function parse($data) { try { Sabre_VObject_Property::$classMap['LAST-MODIFIED'] = 'Sabre_VObject_Property_DateTime'; $vobject = Sabre_VObject_Reader::read($data); - if ($vobject instanceof Sabre_VObject_Component){ + if ($vobject instanceof Sabre_VObject_Component) { $vobject = new OC_VObject($vobject); } return $vobject; @@ -58,8 +58,8 @@ class OC_VObject{ * @param string $value * @return string */ - public static function escapeSemicolons($value){ - foreach($value as &$i ){ + public static function escapeSemicolons($value) { + foreach($value as &$i ) { $i = implode("\\\\;", explode(';', $i)); } return implode(';',$value); @@ -70,11 +70,11 @@ class OC_VObject{ * @param string $value * @return array */ - public static function unescapeSemicolons($value){ + public static function unescapeSemicolons($value) { $array = explode(';',$value); - for($i=0;$i<count($array);$i++){ - if(substr($array[$i],-2,2)=="\\\\"){ - if(isset($array[$i+1])){ + for($i=0;$i<count($array);$i++) { + if(substr($array[$i],-2,2)=="\\\\") { + if(isset($array[$i+1])) { $array[$i] = substr($array[$i],0,count($array[$i])-2).';'.$array[$i+1]; unset($array[$i+1]); } @@ -91,16 +91,16 @@ class OC_VObject{ * Constuctor * @param Sabre_VObject_Component or string */ - public function __construct($vobject_or_name){ - if (is_object($vobject_or_name)){ + public function __construct($vobject_or_name) { + if (is_object($vobject_or_name)) { $this->vobject = $vobject_or_name; } else { $this->vobject = new Sabre_VObject_Component($vobject_or_name); } } - public function add($item, $itemValue = null){ - if ($item instanceof OC_VObject){ + public function add($item, $itemValue = null) { + if ($item instanceof OC_VObject) { $item = $item->getVObject(); } $this->vobject->add($item, $itemValue); @@ -113,12 +113,12 @@ class OC_VObject{ * @param object $parameters of property * @returns Sabre_VObject_Property newly created */ - public function addProperty($name, $value, $parameters=array()){ - if(is_array($value)){ + public function addProperty($name, $value, $parameters=array()) { + if(is_array($value)) { $value = OC_VObject::escapeSemicolons($value); } $property = new Sabre_VObject_Property( $name, $value ); - foreach($parameters as $name => $value){ + foreach($parameters as $name => $value) { $property->parameters[] = new Sabre_VObject_Parameter($name, $value); } @@ -126,13 +126,13 @@ class OC_VObject{ return $property; } - public function setUID(){ + public function setUID() { $uid = substr(md5(rand().time()),0,10); $this->vobject->add('UID',$uid); } - public function setString($name, $string){ - if ($string != ''){ + public function setString($name, $string) { + if ($string != '') { $string = strtr($string, array("\r\n"=>"\n")); $this->vobject->__set($name, $string); }else{ @@ -150,11 +150,11 @@ class OC_VObject{ * @param int $dateType * @return void */ - public function setDateTime($name, $datetime, $dateType=Sabre_VObject_Property_DateTime::LOCALTZ){ - if ($datetime == 'now'){ + public function setDateTime($name, $datetime, $dateType=Sabre_VObject_Property_DateTime::LOCALTZ) { + if ($datetime == 'now') { $datetime = new DateTime(); } - if ($datetime instanceof DateTime){ + if ($datetime instanceof DateTime) { $datetime_element = new Sabre_VObject_Property_DateTime($name); $datetime_element->setDateTime($datetime, $dateType); $this->vobject->__set($name, $datetime_element); @@ -163,45 +163,45 @@ class OC_VObject{ } } - public function getAsString($name){ + public function getAsString($name) { return $this->vobject->__isset($name) ? $this->vobject->__get($name)->value : ''; } - public function getAsArray($name){ + public function getAsArray($name) { $values = array(); - if ($this->vobject->__isset($name)){ + if ($this->vobject->__isset($name)) { $values = explode(',', $this->getAsString($name)); $values = array_map('trim', $values); } return $values; } - public function &__get($name){ - if ($name == 'children'){ + public function &__get($name) { + if ($name == 'children') { return $this->vobject->children; } $return = $this->vobject->__get($name); - if ($return instanceof Sabre_VObject_Component){ + if ($return instanceof Sabre_VObject_Component) { $return = new OC_VObject($return); } return $return; } - public function __set($name, $value){ + public function __set($name, $value) { return $this->vobject->__set($name, $value); } - public function __unset($name){ + public function __unset($name) { return $this->vobject->__unset($name); } - public function __isset($name){ + public function __isset($name) { return $this->vobject->__isset($name); } - public function __call($function,$arguments){ + public function __call($function,$arguments) { return call_user_func_array(array($this->vobject, $function), $arguments); } } diff --git a/search/ajax/search.php b/search/ajax/search.php index b524993d24f..41ee9ad5aba 100644 --- a/search/ajax/search.php +++ b/search/ajax/search.php @@ -29,7 +29,7 @@ require_once '../../lib/base.php'; OC_JSON::checkLoggedIn(); $query=(isset($_GET['query']))?$_GET['query']:''; -if($query){ +if($query) { $result=OC_Search::search($query); OC_JSON::encodedPrint($result); }else{ diff --git a/search/index.php b/search/index.php index 958065dc406..9c515ff3dd3 100644 --- a/search/index.php +++ b/search/index.php @@ -39,7 +39,7 @@ if($query) { } $resultTypes=array(); -foreach($results as $result){ +foreach($results as $result) { if(!isset($resultTypes[$result->type])) { $resultTypes[$result->type]=array(); } diff --git a/settings/admin.php b/settings/admin.php index 351c8a3fff1..a36f2190386 100755 --- a/settings/admin.php +++ b/settings/admin.php @@ -20,7 +20,7 @@ $htaccessworking=OC_Util::ishtaccessworking(); $entries=OC_Log_Owncloud::getEntries(3); $entriesremain=(count(OC_Log_Owncloud::getEntries(4)) > 3)?true:false; -function compareEntries($a,$b){ +function compareEntries($a,$b) { return $b->time - $a->time; } usort($entries, 'compareEntries'); @@ -35,7 +35,7 @@ $tmpl->assign('allowLinks', OC_Appconfig::getValue('core', 'shareapi_allow_links $tmpl->assign('allowResharing', OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes')); $tmpl->assign('sharePolicy', OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global')); $tmpl->assign('forms',array()); -foreach($forms as $form){ +foreach($forms as $form) { $tmpl->append('forms',$form); } $tmpl->printPage(); diff --git a/settings/ajax/apps/ocs.php b/settings/ajax/apps/ocs.php index 1f3e3b3dfea..71cb046fc8d 100644 --- a/settings/ajax/apps/ocs.php +++ b/settings/ajax/apps/ocs.php @@ -32,10 +32,10 @@ if(is_array($catagoryNames)) { $page=0; $filter='approved'; $externalApps=OC_OCSClient::getApplications($categories, $page, $filter); - foreach($externalApps as $app){ + foreach($externalApps as $app) { // show only external apps that aren't enabled yet $local=false; - foreach($enabledApps as $a){ + foreach($enabledApps as $a) { if($a == $app['name']) { $local=true; } diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php index 22320b870e8..bdf7e4983ac 100644 --- a/settings/ajax/createuser.php +++ b/settings/ajax/createuser.php @@ -21,7 +21,7 @@ if($isadmin) { }else{ if(isset( $_POST["groups"] )) { $groups = array(); - foreach($_POST["groups"] as $group){ + foreach($_POST["groups"] as $group) { if(OC_SubAdmin::isGroupAccessible(OC_User::getUser(), $group)) { $groups[] = $group; } @@ -45,7 +45,7 @@ if( in_array( $username, OC_User::getUsers())) { // Return Success story try { OC_User::createUser($username, $password); - foreach( $groups as $i ){ + foreach( $groups as $i ) { if(!OC_Group::groupExists($i)) { OC_Group::createGroup($i); } diff --git a/settings/ajax/togglesubadmins.php b/settings/ajax/togglesubadmins.php index 82bb6ac45f3..5f7126dca34 100644 --- a/settings/ajax/togglesubadmins.php +++ b/settings/ajax/togglesubadmins.php @@ -10,7 +10,7 @@ $username = $_POST["username"]; $group = OC_Util::sanitizeHTML($_POST["group"]); // Toggle group -if(OC_SubAdmin::isSubAdminofGroup($username, $group)){ +if(OC_SubAdmin::isSubAdminofGroup($username, $group)) { OC_SubAdmin::deleteSubAdmin($username, $group); }else{ OC_SubAdmin::createSubAdmin($username, $group); diff --git a/settings/apps.php b/settings/apps.php index 686972c3343..e613814fe94 100644 --- a/settings/apps.php +++ b/settings/apps.php @@ -57,7 +57,7 @@ foreach($registeredApps as $app) { } } -function app_sort($a, $b){ +function app_sort($a, $b) { if ($a['active'] != $b['active']) { return $b['active'] - $a['active']; } diff --git a/settings/personal.php b/settings/personal.php index 2fa8cd4f5e3..4f92985c797 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -41,11 +41,11 @@ array_unshift($languageCodes, $lang); $languageNames=include 'languageCodes.php'; $languages=array(); -foreach($languageCodes as $lang){ +foreach($languageCodes as $lang) { $l=OC_L10N::get('settings', $lang); if(substr($l->t('__language_name__'), 0, 1)!='_') {//first check if the language name is in the translation file $languages[]=array('code'=>$lang,'name'=>$l->t('__language_name__')); - }elseif(isset($languageNames[$lang])){ + }elseif(isset($languageNames[$lang])) { $languages[]=array('code'=>$lang,'name'=>$languageNames[$lang]); }else{//fallback to language code $languages[]=array('code'=>$lang,'name'=>$lang); @@ -62,7 +62,7 @@ $tmpl->assign('languages', $languages); $forms=OC_App::getForms('personal'); $tmpl->assign('forms', array()); -foreach($forms as $form){ +foreach($forms as $form) { $tmpl->append('forms', $form); } $tmpl->printPage(); diff --git a/settings/settings.php b/settings/settings.php index ae41fecaf9f..24099ef5742 100644 --- a/settings/settings.php +++ b/settings/settings.php @@ -14,7 +14,7 @@ OC_App::setActiveNavigationEntry( 'settings' ); $tmpl = new OC_Template( 'settings', 'settings', 'user'); $forms=OC_App::getForms('settings'); $tmpl->assign('forms', array()); -foreach($forms as $form){ +foreach($forms as $form) { $tmpl->append('forms', $form); } $tmpl->printPage(); diff --git a/settings/templates/admin.php b/settings/templates/admin.php index 22e13571d0b..5fa9e26c9c7 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -23,17 +23,17 @@ if(!$_['htaccessworking']) { ?> -<?php foreach($_['forms'] as $form){ +<?php foreach($_['forms'] as $form) { echo $form; };?> <fieldset class="personalblock" id="backgroundjobs"> <legend><strong><?php echo $l->t('Cron');?></strong></legend> - <input type="radio" name="mode" value="ajax" id="backgroundjobs_ajax" <?php if( $_['backgroundjobs_mode'] == "ajax" ){ echo 'checked="checked"'; } ?>> + <input type="radio" name="mode" value="ajax" id="backgroundjobs_ajax" <?php if( $_['backgroundjobs_mode'] == "ajax" ) { echo 'checked="checked"'; } ?>> <label for="backgroundjobs_ajax" title="<?php echo $l->t("execute one task with each page loaded"); ?>">AJAX</label><br /> - <input type="radio" name="mode" value="webcron" id="backgroundjobs_webcron" <?php if( $_['backgroundjobs_mode'] == "webcron" ){ echo 'checked="checked"'; } ?>> + <input type="radio" name="mode" value="webcron" id="backgroundjobs_webcron" <?php if( $_['backgroundjobs_mode'] == "webcron" ) { echo 'checked="checked"'; } ?>> <label for="backgroundjobs_webcron" title="<?php echo $l->t("cron.php is registered at a webcron service"); ?>">Webcron</label><br /> - <input type="radio" name="mode" value="cron" id="backgroundjobs_cron" <?php if( $_['backgroundjobs_mode'] == "cron" ){ echo 'checked="checked"'; } ?>> + <input type="radio" name="mode" value="cron" id="backgroundjobs_cron" <?php if( $_['backgroundjobs_mode'] == "cron" ) { echo 'checked="checked"'; } ?>> <label for="backgroundjobs_cron" title="<?php echo $l->t("use systems cron service"); ?>">Cron</label><br /> </fieldset> diff --git a/settings/templates/personal.php b/settings/templates/personal.php index ee40120d724..4503f3d50b4 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -51,7 +51,7 @@ <em><?php echo $l->t('use this address to connect to your ownCloud in your file manager');?></em> </p> -<?php foreach($_['forms'] as $form){ +<?php foreach($_['forms'] as $form) { echo $form; };?> diff --git a/settings/templates/settings.php b/settings/templates/settings.php index 98acd541e36..12368a1cdb6 100644 --- a/settings/templates/settings.php +++ b/settings/templates/settings.php @@ -4,6 +4,6 @@ * See the COPYING-README file. */?> -<?php foreach($_['forms'] as $form){ +<?php foreach($_['forms'] as $form) { echo $form; };?>
\ No newline at end of file diff --git a/settings/users.php b/settings/users.php index f176977ade1..e76505cc78d 100644 --- a/settings/users.php +++ b/settings/users.php @@ -29,7 +29,7 @@ if($isadmin) { $subadmins = false; } -foreach($accessibleusers as $i){ +foreach($accessibleusers as $i) { $users[] = array( "name" => $i, "groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($i)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/), @@ -37,13 +37,13 @@ foreach($accessibleusers as $i){ 'subadmin'=>implode(', ', OC_SubAdmin::getSubAdminsGroups($i))); } -foreach( $accessiblegroups as $i ){ +foreach( $accessiblegroups as $i ) { // Do some more work here soon $groups[] = array( "name" => $i ); } $quotaPreset=OC_Appconfig::getValue('files', 'quota_preset', 'default,none,1 GB, 5 GB, 10 GB'); $quotaPreset=explode(',',$quotaPreset); -foreach($quotaPreset as &$preset){ +foreach($quotaPreset as &$preset) { $preset=trim($preset); } diff --git a/tests/index.php b/tests/index.php index 032689970fa..82a61c281fd 100644 --- a/tests/index.php +++ b/tests/index.php @@ -31,14 +31,14 @@ require_once 'simpletest/default_reporter.php'; $testSuiteName="ownCloud Unit Test Suite"; // prepare the reporter -if(OC::$CLI){ +if(OC::$CLI) { $reporter=new TextReporter; $test=isset($_SERVER['argv'][1])?$_SERVER['argv'][1]:false; - if($test=='xml'){ + if($test=='xml') { $reporter= new XmlReporter; $test=false; - if(isset($_SERVER['argv'][2])){ + if(isset($_SERVER['argv'][2])) { $testSuiteName=$testSuiteName." (".$_SERVER['argv'][2].")"; } } @@ -60,30 +60,30 @@ loadTests(dirname(__FILE__), $testSuite, $test, 'lib'); // $apps=OC_App::getEnabledApps(); -foreach($apps as $app){ +foreach($apps as $app) { $testDir=OC_App::getAppPath($app).'/tests'; - if(is_dir($testDir)){ + if(is_dir($testDir)) { loadTests($testDir, $testSuite, $test, $app); } } // run the suite -if($testSuite->getSize()>0){ +if($testSuite->getSize()>0) { $testSuite->run($reporter); } // helper below -function loadTests($dir,$testSuite, $test, $app){ +function loadTests($dir,$testSuite, $test, $app) { $root=($app=='lib')?OC::$SERVERROOT.'/tests/lib/':OC_App::getAppPath($app).'/tests/'; - if($dh=opendir($dir)){ - while($name=readdir($dh)){ - if($name[0]!='.'){//no hidden files, '.' or '..' + if($dh=opendir($dir)) { + while($name=readdir($dh)) { + if($name[0]!='.') {//no hidden files, '.' or '..' $file=$dir.'/'.$name; - if(is_dir($file)){ + if(is_dir($file)) { loadTests($file, $testSuite, $test, $app); - }elseif(substr($file,-4)=='.php' and $file!=__FILE__){ + }elseif(substr($file,-4)=='.php' and $file!=__FILE__) { $name=$app.'/'.getTestName($file,$root); - if($test===false or $test==$name or substr($name,0,strlen($test))==$test){ + if($test===false or $test==$name or substr($name,0,strlen($test))==$test) { $extractor = new SimpleFileLoader(); $loadedSuite=$extractor->load($file); if ($loadedSuite->getSize() > 0) @@ -95,7 +95,7 @@ function loadTests($dir,$testSuite, $test, $app){ } } -function getTestName($file,$root){ +function getTestName($file,$root) { // //TODO: get better test names $file=substr($file,strlen($root)); return substr($file,0,-4);//strip .php diff --git a/tests/lib/archive.php b/tests/lib/archive.php index 1711be58e01..565c314cb8c 100644 --- a/tests/lib/archive.php +++ b/tests/lib/archive.php @@ -23,12 +23,12 @@ abstract class Test_Archive extends UnitTestCase { */ abstract protected function getNew(); - public function testGetFiles(){ + public function testGetFiles() { $this->instance=$this->getExisting(); $allFiles=$this->instance->getFiles(); $expected=array('lorem.txt','logo-wide.png','dir/','dir/lorem.txt'); $this->assertEqual(4,count($allFiles),'only found '.count($allFiles).' out of 4 expected files'); - foreach($expected as $file){ + foreach($expected as $file) { $this->assertNotIdentical(false,array_search($file,$allFiles),'cant find '.$file.' in archive'); $this->assertTrue($this->instance->fileExists($file),'file '.$file.' does not exist in archive'); } @@ -37,19 +37,19 @@ abstract class Test_Archive extends UnitTestCase { $rootContent=$this->instance->getFolder(''); $expected=array('lorem.txt','logo-wide.png','dir/'); $this->assertEqual(3,count($rootContent)); - foreach($expected as $file){ + foreach($expected as $file) { $this->assertNotIdentical(false,array_search($file,$rootContent),'cant find '.$file.' in archive'); } $dirContent=$this->instance->getFolder('dir/'); $expected=array('lorem.txt'); $this->assertEqual(1,count($dirContent)); - foreach($expected as $file){ + foreach($expected as $file) { $this->assertNotIdentical(false,array_search($file,$dirContent),'cant find '.$file.' in archive'); } } - public function testContent(){ + public function testContent() { $this->instance=$this->getExisting(); $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; $textFile=$dir.'/lorem.txt'; @@ -60,7 +60,7 @@ abstract class Test_Archive extends UnitTestCase { $this->assertEqual(file_get_contents($textFile),file_get_contents($tmpFile)); } - public function testWrite(){ + public function testWrite() { $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; $textFile=$dir.'/lorem.txt'; $this->instance=$this->getNew(); @@ -75,7 +75,7 @@ abstract class Test_Archive extends UnitTestCase { $this->assertEqual('foobar',$this->instance->getFile('lorem.txt')); } - public function testReadStream(){ + public function testReadStream() { $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; $this->instance=$this->getExisting(); $fh=$this->instance->getStream('lorem.txt','r'); @@ -84,7 +84,7 @@ abstract class Test_Archive extends UnitTestCase { fclose($fh); $this->assertEqual(file_get_contents($dir.'/lorem.txt'),$content); } - public function testWriteStream(){ + public function testWriteStream() { $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; $this->instance=$this->getNew(); $fh=$this->instance->getStream('lorem.txt','w'); @@ -95,7 +95,7 @@ abstract class Test_Archive extends UnitTestCase { $this->assertTrue($this->instance->fileExists('lorem.txt')); $this->assertEqual(file_get_contents($dir.'/lorem.txt'),$this->instance->getFile('lorem.txt')); } - public function testFolder(){ + public function testFolder() { $this->instance=$this->getNew(); $this->assertFalse($this->instance->fileExists('/test')); $this->assertFalse($this->instance->fileExists('/test/')); @@ -106,7 +106,7 @@ abstract class Test_Archive extends UnitTestCase { $this->assertFalse($this->instance->fileExists('/test')); $this->assertFalse($this->instance->fileExists('/test/')); } - public function testExtract(){ + public function testExtract() { $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; $this->instance=$this->getExisting(); $tmpDir=OCP\Files::tmpFolder(); @@ -117,7 +117,7 @@ abstract class Test_Archive extends UnitTestCase { $this->assertEqual(file_get_contents($dir.'/lorem.txt'),file_get_contents($tmpDir.'lorem.txt')); OCP\Files::rmdirr($tmpDir); } - public function testMoveRemove(){ + public function testMoveRemove() { $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; $textFile=$dir.'/lorem.txt'; $this->instance=$this->getNew(); @@ -130,7 +130,7 @@ abstract class Test_Archive extends UnitTestCase { $this->instance->remove('target.txt'); $this->assertFalse($this->instance->fileExists('target.txt')); } - public function testRecursive(){ + public function testRecursive() { $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; $this->instance=$this->getNew(); $this->instance->addRecursive('/dir',$dir); diff --git a/tests/lib/archive/tar.php b/tests/lib/archive/tar.php index 22481f1a54a..2595b7cb195 100644 --- a/tests/lib/archive/tar.php +++ b/tests/lib/archive/tar.php @@ -8,14 +8,14 @@ require_once 'archive.php'; -if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')){ +if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')) { class Test_Archive_TAR extends Test_Archive{ - protected function getExisting(){ + protected function getExisting() { $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; return new OC_Archive_TAR($dir.'/data.tar.gz'); } - protected function getNew(){ + protected function getNew() { return new OC_Archive_TAR(OCP\Files::tmpFile('.tar.gz')); } } diff --git a/tests/lib/archive/zip.php b/tests/lib/archive/zip.php index b61d8aeac2c..a7682e34180 100644 --- a/tests/lib/archive/zip.php +++ b/tests/lib/archive/zip.php @@ -8,14 +8,14 @@ require_once 'archive.php'; -if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')){ +if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')) { class Test_Archive_ZIP extends Test_Archive{ - protected function getExisting(){ + protected function getExisting() { $dir=OC::$SERVERROOT.'/apps/files_archive/tests/data'; return new OC_Archive_ZIP($dir.'/data.zip'); } - protected function getNew(){ + protected function getNew() { return new OC_Archive_ZIP(OCP\Files::tmpFile('.zip')); } } diff --git a/tests/lib/cache.php b/tests/lib/cache.php index 511999be956..9ada0accc21 100644 --- a/tests/lib/cache.php +++ b/tests/lib/cache.php @@ -12,11 +12,11 @@ abstract class Test_Cache extends UnitTestCase { */ protected $instance; - public function tearDown(){ + public function tearDown() { $this->instance->clear(); } - function testSimple(){ + function testSimple() { $this->assertNull($this->instance->get('value1')); $this->assertFalse($this->instance->hasKey('value1')); @@ -45,7 +45,7 @@ abstract class Test_Cache extends UnitTestCase { $this->assertFalse($this->instance->hasKey('value1')); } - function testClear(){ + function testClear() { $value='ipsum lorum'; $this->instance->set('1_value1',$value); $this->instance->set('1_value2',$value); @@ -65,7 +65,7 @@ abstract class Test_Cache extends UnitTestCase { $this->assertFalse($this->instance->hasKey('3_value1')); } - function testTTL(){ + function testTTL() { $value='foobar'; $this->instance->set('value1',$value,1); $value2='foobar'; diff --git a/tests/lib/cache/apc.php b/tests/lib/cache/apc.php index ab8eb188664..34ea968cd54 100644 --- a/tests/lib/cache/apc.php +++ b/tests/lib/cache/apc.php @@ -25,11 +25,11 @@ class Test_Cache_APC extends Test_Cache { $this->skipUnless(function_exists('apc_store')); } - public function setUp(){ + public function setUp() { $this->instance=new OC_Cache_APC(); } - function testTTL(){ + function testTTL() { // ttl doesn't work correctly in the same request // see https://bugs.php.net/bug.php?id=58084 } diff --git a/tests/lib/cache/file.php b/tests/lib/cache/file.php index 28778efb68c..00be005d08d 100644 --- a/tests/lib/cache/file.php +++ b/tests/lib/cache/file.php @@ -27,13 +27,13 @@ class Test_Cache_File extends Test_Cache { //$this->skipUnless(OC_User::isLoggedIn()); } - public function setUp(){ + public function setUp() { //clear all proxies and hooks so we can do clean testing OC_FileProxy::clearProxies(); OC_Hook::clear('OC_Filesystem'); //enable only the encryption hook if needed - if(OC_App::isEnabled('files_encryption')){ + if(OC_App::isEnabled('files_encryption')) { OC_FileProxy::register(new OC_FileProxy_Encryption()); } @@ -57,7 +57,7 @@ class Test_Cache_File extends Test_Cache { $this->instance=new OC_Cache_File(); } - public function tearDown(){ + public function tearDown() { OC_User::setUserId($this->user); } } diff --git a/tests/lib/cache/xcache.php b/tests/lib/cache/xcache.php index cc2077076ce..85cc2d8b3c6 100644 --- a/tests/lib/cache/xcache.php +++ b/tests/lib/cache/xcache.php @@ -25,11 +25,11 @@ class Test_Cache_XCache extends Test_Cache { $this->skipUnless(function_exists('xcache_get')); } - public function setUp(){ + public function setUp() { $this->instance=new OC_Cache_XCache(); } - function testTTL(){ + function testTTL() { // ttl doesn't work correctly in the same request } } diff --git a/tests/lib/filestorage.php b/tests/lib/filestorage.php index 0a8715600d5..3f7bb7b62dc 100644 --- a/tests/lib/filestorage.php +++ b/tests/lib/filestorage.php @@ -29,7 +29,7 @@ abstract class Test_FileStorage extends UnitTestCase { /** * the root folder of the storage should always exist, be readable and be recognized as a directory */ - public function testRoot(){ + public function testRoot() { $this->assertTrue($this->instance->file_exists('/'),'Root folder does not exist'); $this->assertTrue($this->instance->isReadable('/'),'Root folder is not readable'); $this->assertTrue($this->instance->is_dir('/'),'Root folder is not a directory'); @@ -40,7 +40,7 @@ abstract class Test_FileStorage extends UnitTestCase { $this->assertTrue($this->instance->isUpdatable('/'),'Root folder is not writable'); } - public function testDirectories(){ + public function testDirectories() { $this->assertFalse($this->instance->file_exists('/folder')); $this->assertTrue($this->instance->mkdir('/folder')); @@ -55,8 +55,8 @@ abstract class Test_FileStorage extends UnitTestCase { $dh=$this->instance->opendir('/'); $content=array(); - while($file=readdir($dh)){ - if($file!='.' and $file!='..'){ + while($file=readdir($dh)) { + if($file!='.' and $file!='..') { $content[]=$file; } } @@ -71,8 +71,8 @@ abstract class Test_FileStorage extends UnitTestCase { $dh=$this->instance->opendir('/'); $content=array(); - while($file=readdir($dh)){ - if($file!='.' and $file!='..'){ + while($file=readdir($dh)) { + if($file!='.' and $file!='..') { $content[]=$file; } } @@ -82,7 +82,7 @@ abstract class Test_FileStorage extends UnitTestCase { /** * test the various uses of file_get_contents and file_put_contents */ - public function testGetPutContents(){ + public function testGetPutContents() { $sourceFile=OC::$SERVERROOT.'/tests/data/lorem.txt'; $sourceText=file_get_contents($sourceFile); @@ -99,7 +99,7 @@ abstract class Test_FileStorage extends UnitTestCase { /** * test various known mimetypes */ - public function testMimeType(){ + public function testMimeType() { $this->assertEqual('httpd/unix-directory',$this->instance->getMimeType('/')); $this->assertEqual(false,$this->instance->getMimeType('/non/existing/file')); @@ -116,7 +116,7 @@ abstract class Test_FileStorage extends UnitTestCase { $this->assertEqual('image/svg+xml',$this->instance->getMimeType('/logo-wide.svg')); } - public function testCopyAndMove(){ + public function testCopyAndMove() { $textFile=OC::$SERVERROOT.'/tests/data/lorem.txt'; $this->instance->file_put_contents('/source.txt',file_get_contents($textFile)); $this->instance->copy('/source.txt','/target.txt'); @@ -129,7 +129,7 @@ abstract class Test_FileStorage extends UnitTestCase { $this->assertEqual(file_get_contents($textFile),$this->instance->file_get_contents('/target.txt')); } - public function testLocal(){ + public function testLocal() { $textFile=OC::$SERVERROOT.'/tests/data/lorem.txt'; $this->instance->file_put_contents('/lorem.txt',file_get_contents($textFile)); $localFile=$this->instance->getLocalFile('/lorem.txt'); @@ -150,7 +150,7 @@ abstract class Test_FileStorage extends UnitTestCase { $this->assertEqual(file_get_contents($localFolder.'/recursive/file.txt'),'foo'); } - public function testStat(){ + public function testStat() { $textFile=OC::$SERVERROOT.'/tests/data/lorem.txt'; $ctimeStart=time(); $this->instance->file_put_contents('/lorem.txt',file_get_contents($textFile)); @@ -158,7 +158,7 @@ abstract class Test_FileStorage extends UnitTestCase { $ctimeEnd=time(); $cTime=$this->instance->filectime('/lorem.txt'); $mTime=$this->instance->filemtime('/lorem.txt'); - if($cTime!=-1){//not everything can support ctime + if($cTime!=-1) {//not everything can support ctime $this->assertTrue(($ctimeStart-1)<=$cTime); $this->assertTrue($cTime<=($ctimeEnd+1)); } @@ -187,7 +187,7 @@ abstract class Test_FileStorage extends UnitTestCase { $this->assertTrue($this->instance->hasUpdated('/lorem.txt',$mtimeStart-1)); - if($this->instance->touch('/lorem.txt',100)!==false){ + if($this->instance->touch('/lorem.txt',100)!==false) { $mTime=$this->instance->filemtime('/lorem.txt'); $this->assertEqual($mTime,100); } @@ -207,7 +207,7 @@ abstract class Test_FileStorage extends UnitTestCase { $this->assertTrue($this->instance->hasUpdated('/',$mtimeStart-1)); } - public function testSearch(){ + public function testSearch() { $textFile=OC::$SERVERROOT.'/tests/data/lorem.txt'; $this->instance->file_put_contents('/lorem.txt',file_get_contents($textFile,'r')); $pngFile=OC::$SERVERROOT.'/tests/data/logo-wide.png'; diff --git a/tests/lib/filestorage/commontest.php b/tests/lib/filestorage/commontest.php index ab5375ec2b0..89e83589e5d 100644 --- a/tests/lib/filestorage/commontest.php +++ b/tests/lib/filestorage/commontest.php @@ -25,15 +25,15 @@ class Test_Filestorage_CommonTest extends Test_FileStorage { * @var string tmpDir */ private $tmpDir; - public function setUp(){ + public function setUp() { $this->tmpDir=get_temp_dir().'/filestoragecommon'; - if(!file_exists($this->tmpDir)){ + if(!file_exists($this->tmpDir)) { mkdir($this->tmpDir); } $this->instance=new OC_Filestorage_CommonTest(array('datadir'=>$this->tmpDir)); } - public function tearDown(){ + public function tearDown() { OC_Helper::rmdirr($this->tmpDir); } } diff --git a/tests/lib/filestorage/local.php b/tests/lib/filestorage/local.php index 692f05f9fca..f68fb69b97f 100644 --- a/tests/lib/filestorage/local.php +++ b/tests/lib/filestorage/local.php @@ -25,12 +25,12 @@ class Test_Filestorage_Local extends Test_FileStorage { * @var string tmpDir */ private $tmpDir; - public function setUp(){ + public function setUp() { $this->tmpDir=OC_Helper::tmpFolder(); $this->instance=new OC_Filestorage_Local(array('datadir'=>$this->tmpDir)); } - public function tearDown(){ + public function tearDown() { OC_Helper::rmdirr($this->tmpDir); } } diff --git a/tests/lib/filesystem.php b/tests/lib/filesystem.php index 72af0835788..1cfa35e305d 100644 --- a/tests/lib/filesystem.php +++ b/tests/lib/filesystem.php @@ -29,23 +29,23 @@ class Test_Filesystem extends UnitTestCase{ /** * @return array */ - private function getStorageData(){ + private function getStorageData() { $dir=OC_Helper::tmpFolder(); $this->tmpDirs[]=$dir; return array('datadir'=>$dir); } - public function tearDown(){ - foreach($this->tmpDirs as $dir){ + public function tearDown() { + foreach($this->tmpDirs as $dir) { OC_Helper::rmdirr($dir); } } - public function setUp(){ + public function setUp() { OC_Filesystem::clearMounts(); } - public function testMount(){ + public function testMount() { OC_Filesystem::mount('OC_Filestorage_Local',self::getStorageData(),'/'); $this->assertEqual('/',OC_Filesystem::getMountPoint('/')); $this->assertEqual('/',OC_Filesystem::getMountPoint('/some/folder')); @@ -60,14 +60,14 @@ class Test_Filesystem extends UnitTestCase{ $this->assertEqual('folder',OC_Filesystem::getInternalPath('/some/folder')); } - public function testNormalize(){ + public function testNormalize() { $this->assertEqual('/path',OC_Filesystem::normalizePath('/path/')); $this->assertEqual('/path/',OC_Filesystem::normalizePath('/path/',false)); $this->assertEqual('/path',OC_Filesystem::normalizePath('path')); $this->assertEqual('/path',OC_Filesystem::normalizePath('\path')); $this->assertEqual('/foo/bar',OC_Filesystem::normalizePath('/foo//bar/')); $this->assertEqual('/foo/bar',OC_Filesystem::normalizePath('/foo////bar')); - if(class_exists('Normalizer')){ + if(class_exists('Normalizer')) { $this->assertEqual("/foo/bar\xC3\xBC",OC_Filesystem::normalizePath("/foo/baru\xCC\x88")); } } diff --git a/tests/lib/group.php b/tests/lib/group.php index 922613211bc..0bea9a00886 100644 --- a/tests/lib/group.php +++ b/tests/lib/group.php @@ -21,11 +21,11 @@ */ class Test_Group extends UnitTestCase { - function setUp(){ + function setUp() { OC_Group::clearBackends(); } - function testSingleBackend(){ + function testSingleBackend() { OC_Group::useBackend(new OC_Group_Dummy()); $group1=uniqid(); @@ -62,7 +62,7 @@ class Test_Group extends UnitTestCase { $this->assertFalse(OC_Group::inGroup($user1,$group1)); } - function testMultiBackend(){ + function testMultiBackend() { $backend1=new OC_Group_Dummy(); $backend2=new OC_Group_Dummy(); OC_Group::useBackend($backend1); diff --git a/tests/lib/group/backend.php b/tests/lib/group/backend.php index 9405e90aabf..61e008b6ca5 100644 --- a/tests/lib/group/backend.php +++ b/tests/lib/group/backend.php @@ -31,7 +31,7 @@ abstract class Test_Group_Backend extends UnitTestCase { * test cases can override this in order to clean up created groups * @return array */ - public function getGroupName(){ + public function getGroupName() { return uniqid('test_'); } @@ -40,11 +40,11 @@ abstract class Test_Group_Backend extends UnitTestCase { * test cases can override this in order to clean up created user * @return array */ - public function getUserName(){ + public function getUserName() { return uniqid('test_'); } - public function testAddRemove(){ + public function testAddRemove() { //get the number of groups we start with, in case there are exising groups $startCount=count($this->backend->getGroups()); @@ -68,7 +68,7 @@ abstract class Test_Group_Backend extends UnitTestCase { $this->assertFalse((array_search($name2,$this->backend->getGroups())!==false)); } - public function testUser(){ + public function testUser() { $group1=$this->getGroupName(); $group2=$this->getGroupName(); $this->backend->createGroup($group1); diff --git a/tests/lib/group/database.php b/tests/lib/group/database.php index fb51bc8d8d9..5278c26f4df 100644 --- a/tests/lib/group/database.php +++ b/tests/lib/group/database.php @@ -28,7 +28,7 @@ class Test_Group_Database extends Test_Group_Backend { * test cases can override this in order to clean up created groups * @return array */ - public function getGroupName(){ + public function getGroupName() { $name=uniqid('test_'); $this->groups[]=$name; return $name; @@ -39,16 +39,16 @@ class Test_Group_Database extends Test_Group_Backend { * test cases can override this in order to clean up created user * @return array */ - public function getUserName(){ + public function getUserName() { return uniqid('test_'); } - public function setUp(){ + public function setUp() { $this->backend=new OC_Group_Database(); } - public function tearDown(){ - foreach($this->groups as $group){ + public function tearDown() { + foreach($this->groups as $group) { $this->backend->deleteGroup($group); } } diff --git a/tests/lib/group/dummy.php b/tests/lib/group/dummy.php index d0b475d3ec5..287d6f1a977 100644 --- a/tests/lib/group/dummy.php +++ b/tests/lib/group/dummy.php @@ -21,7 +21,7 @@ */ class Test_Group_Dummy extends Test_Group_Backend { - public function setUp(){ + public function setUp() { $this->backend=new OC_Group_Dummy(); } } diff --git a/tests/lib/streamwrappers.php b/tests/lib/streamwrappers.php index 17a92c6658c..5d6fe8da826 100644 --- a/tests/lib/streamwrappers.php +++ b/tests/lib/streamwrappers.php @@ -21,19 +21,19 @@ */ class Test_StreamWrappers extends UnitTestCase { - public function testFakeDir(){ + public function testFakeDir() { $items=array('foo','bar'); OC_FakeDirStream::$dirs['test']=$items; $dh=opendir('fakedir://test'); $result=array(); - while($file=readdir($dh)){ + while($file=readdir($dh)) { $result[]=$file; $this->assertNotIdentical(false,array_search($file,$items)); } $this->assertEqual(count($items),count($result)); } - public function testStaticStream(){ + public function testStaticStream() { $sourceFile=OC::$SERVERROOT.'/tests/data/lorem.txt'; $staticFile='static://test'; $this->assertFalse(file_exists($staticFile)); @@ -45,7 +45,7 @@ class Test_StreamWrappers extends UnitTestCase { $this->assertFalse(file_exists($staticFile)); } - public function testCloseStream(){ + public function testCloseStream() { //ensure all basic stream stuff works $sourceFile=OC::$SERVERROOT.'/tests/data/lorem.txt'; $tmpFile=OC_Helper::TmpFile('.txt'); @@ -66,13 +66,13 @@ class Test_StreamWrappers extends UnitTestCase { try{ fclose($fh); $this->fail('Expected exception'); - }catch(Exception $e){ + }catch(Exception $e) { $path=$e->getMessage(); $this->assertEqual($path,$tmpFile); } } - public static function closeCallBack($path){ + public static function closeCallBack($path) { throw new Exception($path); } }
\ No newline at end of file diff --git a/tests/lib/user/backend.php b/tests/lib/user/backend.php index 984249e84eb..c69c1bad512 100644 --- a/tests/lib/user/backend.php +++ b/tests/lib/user/backend.php @@ -41,11 +41,11 @@ abstract class Test_User_Backend extends UnitTestCase { * test cases can override this in order to clean up created user * @return array */ - public function getUser(){ + public function getUser() { return uniqid('test_'); } - public function testAddRemove(){ + public function testAddRemove() { //get the number of groups we start with, in case there are exising groups $startCount=count($this->backend->getUsers()); @@ -69,7 +69,7 @@ abstract class Test_User_Backend extends UnitTestCase { $this->assertFalse((array_search($name2,$this->backend->getUsers())!==false)); } - public function testLogin(){ + public function testLogin() { $name1=$this->getUser(); $name2=$this->getUser(); diff --git a/tests/lib/user/database.php b/tests/lib/user/database.php index f484ffa78f7..fe7d87c44de 100644 --- a/tests/lib/user/database.php +++ b/tests/lib/user/database.php @@ -26,18 +26,18 @@ class Test_User_Database extends Test_User_Backend { * test cases can override this in order to clean up created user * @return array */ - public function getUser(){ + public function getUser() { $user=uniqid('test_'); $this->users[]=$user; return $user; } - public function setUp(){ + public function setUp() { $this->backend=new OC_User_Dummy(); } - public function tearDown(){ - foreach($this->users as $user){ + public function tearDown() { + foreach($this->users as $user) { $this->backend->deleteUser($user); } } diff --git a/tests/lib/user/dummy.php b/tests/lib/user/dummy.php index 062f55ba079..e417fd97603 100644 --- a/tests/lib/user/dummy.php +++ b/tests/lib/user/dummy.php @@ -21,7 +21,7 @@ */ class Test_User_Dummy extends Test_User_Backend { - public function setUp(){ + public function setUp() { $this->backend=new OC_User_Dummy(); } } |