diff --git a/README b/README index e11ff7d10c..9b113c4f67 100644 --- a/README +++ b/README @@ -4,6 +4,7 @@ A personal cloud which runs on your own server. http://ownCloud.org Installation instructions: http://owncloud.org/support +Contribution Guidelines: http://owncloud.org/dev/contribute/ Source code: https://github.com/owncloud Mailing list: https://mail.kde.org/mailman/listinfo/owncloud @@ -16,4 +17,4 @@ Please submit translations via Transifex: https://www.transifex.com/projects/p/owncloud/ For more detailed information about translations: -http://owncloud.org/dev/translation/ \ No newline at end of file +http://owncloud.org/dev/translation/ diff --git a/apps/files/ajax/autocomplete.php b/apps/files/ajax/autocomplete.php index fae38368a8..b32ba7c3d5 100644 --- a/apps/files/ajax/autocomplete.php +++ b/apps/files/ajax/autocomplete.php @@ -44,7 +44,7 @@ if(OC_Filesystem::file_exists($base) and OC_Filesystem::is_dir($base)) { if(substr(strtolower($file), 0, $queryLen)==$query) { $item=$base.$file; if((!$dirOnly or OC_Filesystem::is_dir($item))) { - $files[]=(object)array('id'=>$item,'label'=>$item,'name'=>$item); + $files[]=(object)array('id'=>$item, 'label'=>$item, 'name'=>$item); } } } diff --git a/apps/files/ajax/move.php b/apps/files/ajax/move.php index 0541bb1606..5612716b7e 100644 --- a/apps/files/ajax/move.php +++ b/apps/files/ajax/move.php @@ -12,7 +12,7 @@ $file = stripslashes($_GET["file"]); $target = stripslashes(rawurldecode($_GET["target"])); -if(OC_Filesystem::file_exists($target . '/' . $file)){ +if(OC_Filesystem::file_exists($target . '/' . $file)) { OCP\JSON::error(array("data" => array( "message" => "Could not move $file - File with this name already exists" ))); exit; } diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index dc83057040..4ed0bbc5b0 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -38,7 +38,7 @@ $totalSize=0; foreach($files['size'] as $size) { $totalSize+=$size; } -if($totalSize>OC_Filesystem::free_space($dir)){ +if($totalSize>OC_Filesystem::free_space($dir)) { OCP\JSON::error(array("data" => array( "message" => "Not enough space available" ))); exit(); } @@ -51,7 +51,7 @@ if(strpos($dir, '..') === false) { if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { $meta = OC_FileCache::get($target); $id = OC_FileCache::getId($target); - $result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'], 'id'=>$id, 'name'=>basename($target)); + $result[]=array( "status" => "success", 'mime'=>$meta['mimetype'], 'size'=>$meta['size'], 'id'=>$id, 'name'=>basename($target)); } } OCP\JSON::encodedPrint($result); diff --git a/apps/files/appinfo/filesync.php b/apps/files/appinfo/filesync.php index dfafe3f956..0e368cb0f4 100644 --- a/apps/files/appinfo/filesync.php +++ b/apps/files/appinfo/filesync.php @@ -21,7 +21,7 @@ */ // load needed apps -$RUNTIME_APPTYPES=array('filesystem','authentication','logging'); +$RUNTIME_APPTYPES=array('filesystem', 'authentication', 'logging'); OC_App::loadApps($RUNTIME_APPTYPES); if(!OC_User::isLoggedIn()) { if(!isset($_SERVER['PHP_AUTH_USER'])) { @@ -36,7 +36,7 @@ if(!OC_User::isLoggedIn()) { } } -list($type,$file) = explode('/', substr($path_info, 1+strlen($service)+1), 2); +list($type, $file) = explode('/', substr($path_info, 1+strlen($service)+1), 2); if ($type != 'oc_chunked') { OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND); diff --git a/apps/files/appinfo/remote.php b/apps/files/appinfo/remote.php index f12430f24d..400a978fb1 100644 --- a/apps/files/appinfo/remote.php +++ b/apps/files/appinfo/remote.php @@ -23,7 +23,7 @@ * */ // load needed apps -$RUNTIME_APPTYPES=array('filesystem','authentication','logging'); +$RUNTIME_APPTYPES=array('filesystem', 'authentication', 'logging'); OC_App::loadApps($RUNTIME_APPTYPES); diff --git a/apps/files/appinfo/update.php b/apps/files/appinfo/update.php index bcbbc6035f..738864d7cf 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.6', '<')) { $query = OC_DB::prepare( "SELECT `propertyname`, `propertypath`, `userid` FROM `*PREFIX*properties`" ); $result = $query->execute(); - while( $row = $result->fetchRow()){ + while( $row = $result->fetchRow()) { if ( $row["propertyname"][0] != '{' ) { $query = OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertyname` = ? WHERE `userid` = ? AND `propertypath` = ?' ); $query->execute( array( '{DAV:}' + $row["propertyname"], $row["userid"], $row["propertypath"] )); @@ -39,7 +39,7 @@ foreach($filesToRemove as $file) { $success = OCP\Files::rmdirr($filepath); if($success === false) { //probably not sufficient privileges, give up and give a message. - OCP\Util::writeLog('files','Could not clean /files/ directory. Please remove everything except webdav.php from ' . OC::$SERVERROOT . '/files/', OCP\Util::ERROR); + OCP\Util::writeLog('files', 'Could not clean /files/ directory. Please remove everything except webdav.php from ' . OC::$SERVERROOT . '/files/', OCP\Util::ERROR); break; } } diff --git a/apps/files/index.php b/apps/files/index.php index 51fe6b0379..c46ec59d03 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -67,7 +67,7 @@ $breadcrumb = array(); $pathtohere = ''; foreach( explode( '/', $dir ) as $i ) { if( $i != '' ) { - $pathtohere .= '/'.str_replace('+','%20', urlencode($i)); + $pathtohere .= '/'.str_replace('+', '%20', urlencode($i)); $breadcrumb[] = array( 'dir' => $pathtohere, 'name' => $i ); } } diff --git a/apps/files/templates/admin.php b/apps/files/templates/admin.php index 5869ed2107..a60a1cebaf 100644 --- a/apps/files/templates/admin.php +++ b/apps/files/templates/admin.php @@ -1,4 +1,4 @@ - +
diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 7cdff024dd..e2640c1113 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -8,7 +8,7 @@
diff --git a/apps/files/templates/part.breadcrumb.php b/apps/files/templates/part.breadcrumb.php index 71b695f65f..ead9ab1ed7 100644 --- a/apps/files/templates/part.breadcrumb.php +++ b/apps/files/templates/part.breadcrumb.php @@ -1,6 +1,6 @@ -
svg" data-dir='' style='background-image:url("")'> +
svg" data-dir='' style='background-image:url("")'> ">
diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index aaf9c5f57e..4b5ac32567 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -14,10 +14,10 @@ $relative_modified_date = OCP\relative_modified_date($file['mtime']); $relative_date_color = round((time()-$file['mtime'])/60/60/24*14); // the older the file, the brighter the shade of grey; days*14 if($relative_date_color>200) $relative_date_color = 200; - $name = str_replace('+','%20', urlencode($file['name'])); - $name = str_replace('%2F','/', $name); - $directory = str_replace('+','%20', urlencode($file['directory'])); - $directory = str_replace('%2F','/', $directory); ?> + $name = str_replace('+', '%20', urlencode($file['name'])); + $name = str_replace('%2F', '/', $name); + $directory = str_replace('+', '%20', urlencode($file['directory'])); + $directory = str_replace('%2F', '/', $directory); ?> ' data-permissions=''> diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php index bb130a366b..3f76e910a5 100644 --- a/apps/files_encryption/appinfo/app.php +++ b/apps/files_encryption/appinfo/app.php @@ -6,9 +6,9 @@ OC::$CLASSPATH['OC_FileProxy_Encryption'] = 'apps/files_encryption/lib/proxy.php OC_FileProxy::register(new OC_FileProxy_Encryption()); -OCP\Util::connectHook('OC_User','post_login','OC_Crypt','loginListener'); +OCP\Util::connectHook('OC_User', 'post_login', 'OC_Crypt', 'loginListener'); -stream_wrapper_register('crypt','OC_CryptStream'); +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) OCP\User::logout(); diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php index d8e7e4d1dd..5ff3f57838 100644 --- a/apps/files_encryption/lib/crypt.php +++ b/apps/files_encryption/lib/crypt.php @@ -80,7 +80,7 @@ class OC_Crypt { } } - public static function createkey($username,$passcode) { + public static function createkey($username, $passcode) { // generate a random key $key=mt_rand(10000, 99999).mt_rand(10000, 99999).mt_rand(10000, 99999).mt_rand(10000, 99999); diff --git a/apps/files_encryption/lib/cryptstream.php b/apps/files_encryption/lib/cryptstream.php index 3170cff366..8b05560050 100644 --- a/apps/files_encryption/lib/cryptstream.php +++ b/apps/files_encryption/lib/cryptstream.php @@ -23,7 +23,7 @@ /** * transparently encrypted filestream * - * you can use it as wrapper around an existing stream by setting OC_CryptStream::$sourceStreams['foo']=array('path'=>$path,'stream'=>$stream) + * you can use it as wrapper around an existing stream by setting OC_CryptStream::$sourceStreams['foo']=array('path'=>$path, 'stream'=>$stream) * and then fopen('crypt://streams/foo'); */ @@ -123,11 +123,11 @@ class OC_CryptStream{ $data=substr($data, 8192); } } - $this->size=max($this->size,$currentPos+$length); + $this->size=max($this->size, $currentPos+$length); return $length; } - public function stream_set_option($option,$arg1,$arg2) { + public function stream_set_option($option, $arg1, $arg2) { switch($option) { case STREAM_OPTION_BLOCKING: stream_set_blocking($this->source, $arg1); diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index fed6acaf91..4a390013d2 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -36,7 +36,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ */ private static function shouldEncrypt($path) { if(is_null(self::$enableEncryption)) { - self::$enableEncryption=(OCP\Config::getAppValue('files_encryption','enable_encryption','true')=='true'); + self::$enableEncryption=(OCP\Config::getAppValue('files_encryption', 'enable_encryption', 'true')=='true'); } if(!self::$enableEncryption) { return false; @@ -59,7 +59,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ * @return bool */ private static function isEncrypted($path) { - $metadata=OC_FileCache_Cached::get($path,''); + $metadata=OC_FileCache_Cached::get($path, ''); return isset($metadata['encrypted']) and (bool)$metadata['encrypted']; } @@ -68,14 +68,14 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ if (!is_resource($data)) {//stream put contents should have been converter to fopen $size=strlen($data); $data=OC_Crypt::blockEncrypt($data); - OC_FileCache::put($path, array('encrypted'=>true,'size'=>$size),''); + OC_FileCache::put($path, array('encrypted'=>true,'size'=>$size), ''); } } } - public function postFile_get_contents($path,$data) { + public function postFile_get_contents($path, $data) { if(self::isEncrypted($path)) { - $cached=OC_FileCache_Cached::get($path,''); + $cached=OC_FileCache_Cached::get($path, ''); $data=OC_Crypt::blockDecrypt($data, '', $cached['size']); } return $data; @@ -92,7 +92,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ }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); + OCP\Util::writeLog('files_encryption', 'Decrypting '.$path.' before writing', OCP\Util::DEBUG); $tmp=fopen('php://temp'); OCP\Files::streamCopy($result, $tmp); fclose($result); @@ -106,14 +106,14 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ public function postGetMimeType($path, $mime) { if(self::isEncrypted($path)) { - $mime=OCP\Files::getMimeType('crypt://'.$path,'w'); + $mime=OCP\Files::getMimeType('crypt://'.$path, 'w'); } return $mime; } public function postStat($path, $data) { if(self::isEncrypted($path)) { - $cached=OC_FileCache_Cached::get($path,''); + $cached=OC_FileCache_Cached::get($path, ''); $data['size']=$cached['size']; } return $data; @@ -121,7 +121,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ public function postFileSize($path, $size) { if(self::isEncrypted($path)) { - $cached=OC_FileCache_Cached::get($path,''); + $cached=OC_FileCache_Cached::get($path, ''); return $cached['size']; }else{ return $size; diff --git a/apps/files_encryption/settings.php b/apps/files_encryption/settings.php index ab9324dee4..ae28b088cd 100644 --- a/apps/files_encryption/settings.php +++ b/apps/files_encryption/settings.php @@ -8,11 +8,11 @@ $tmpl = new OCP\Template( 'files_encryption', 'settings'); $blackList=explode(',', OCP\Config::getAppValue('files_encryption', 'type_blacklist', 'jpg,png,jpeg,avi,mpg,mpeg,mkv,mp3,oga,ogv,ogg')); -$enabled=(OCP\Config::getAppValue('files_encryption','enable_encryption','true')=='true'); +$enabled=(OCP\Config::getAppValue('files_encryption', 'enable_encryption', 'true')=='true'); $tmpl->assign('blacklist', $blackList); $tmpl->assign('encryption_enabled', $enabled); -OCP\Util::addscript('files_encryption','settings'); -OCP\Util::addscript('core','multiselect'); +OCP\Util::addscript('files_encryption', 'settings'); +OCP\Util::addscript('core', 'multiselect'); return $tmpl->fetchPage(); diff --git a/apps/files_encryption/tests/encryption.php b/apps/files_encryption/tests/encryption.php index b714b00b8f..0e119f55be 100644 --- a/apps/files_encryption/tests/encryption.php +++ b/apps/files_encryption/tests/encryption.php @@ -17,7 +17,7 @@ class Test_Encryption extends UnitTestCase { $this->assertNotEqual($encrypted, $source); $this->assertEqual($decrypted, $source); - $chunk=substr($source,0, 8192); + $chunk=substr($source, 0, 8192); $encrypted=OC_Crypt::encrypt($chunk, $key); $this->assertEqual(strlen($chunk), strlen($encrypted)); $decrypted=OC_Crypt::decrypt($encrypted, $key); @@ -30,14 +30,14 @@ class Test_Encryption extends UnitTestCase { $this->assertEqual($decrypted, $source); $tmpFileEncrypted=OCP\Files::tmpFile(); - OC_Crypt::encryptfile($file,$tmpFileEncrypted, $key); + OC_Crypt::encryptfile($file, $tmpFileEncrypted, $key); $encrypted=file_get_contents($tmpFileEncrypted); $decrypted=OC_Crypt::blockDecrypt($encrypted, $key); $this->assertNotEqual($encrypted, $source); $this->assertEqual($decrypted, $source); $tmpFileDecrypted=OCP\Files::tmpFile(); - OC_Crypt::decryptfile($tmpFileEncrypted,$tmpFileDecrypted, $key); + OC_Crypt::decryptfile($tmpFileEncrypted, $tmpFileDecrypted, $key); $decrypted=file_get_contents($tmpFileDecrypted); $this->assertEqual($decrypted, $source); diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php index 25427ff4b9..1c800bbc5f 100644 --- a/apps/files_encryption/tests/proxy.php +++ b/apps/files_encryption/tests/proxy.php @@ -13,8 +13,8 @@ class Test_CryptProxy extends UnitTestCase { public function setUp() { $user=OC_User::getUser(); - $this->oldConfig=OCP\Config::getAppValue('files_encryption','enable_encryption','true'); - OCP\Config::setAppValue('files_encryption','enable_encryption','true'); + $this->oldConfig=OCP\Config::getAppValue('files_encryption','enable_encryption', 'true'); + OCP\Config::setAppValue('files_encryption', 'enable_encryption', 'true'); $this->oldKey=isset($_SESSION['enckey'])?$_SESSION['enckey']:null; @@ -30,7 +30,7 @@ class Test_CryptProxy extends UnitTestCase { //set up temporary storage OC_Filesystem::clearMounts(); - OC_Filesystem::mount('OC_Filestorage_Temporary', array(),'/'); + OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/'); OC_Filesystem::init('/'.$user.'/files'); diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php index 2caebf912e..67b5e98ae6 100644 --- a/apps/files_encryption/tests/stream.php +++ b/apps/files_encryption/tests/stream.php @@ -10,23 +10,23 @@ class Test_CryptStream extends UnitTestCase { private $tmpFiles=array(); function testStream() { - $stream=$this->getStream('test1','w', strlen('foobar')); - fwrite($stream,'foobar'); + $stream=$this->getStream('test1', 'w', strlen('foobar')); + fwrite($stream, 'foobar'); fclose($stream); - $stream=$this->getStream('test1','r', strlen('foobar')); + $stream=$this->getStream('test1', 'r', strlen('foobar')); $data=fread($stream, 6); fclose($stream); $this->assertEqual('foobar', $data); $file=OC::$SERVERROOT.'/3rdparty/MDB2.php'; - $source=fopen($file,'r'); + $source=fopen($file, 'r'); $target=$this->getStream('test2', 'w', 0); OCP\Files::streamCopy($source, $target); fclose($target); fclose($source); - $stream=$this->getStream('test2','r', filesize($file)); + $stream=$this->getStream('test2', 'r', filesize($file)); $data=stream_get_contents($stream); $original=file_get_contents($file); $this->assertEqual(strlen($original), strlen($data)); @@ -51,7 +51,7 @@ class Test_CryptStream extends UnitTestCase { $file=$this->tmpFiles[$id]; } $stream=fopen($file, $mode); - OC_CryptStream::$sourceStreams[$id]=array('path'=>'dummy'.$id,'stream'=>$stream,'size'=>$size); + OC_CryptStream::$sourceStreams[$id]=array('path'=>'dummy'.$id, 'stream'=>$stream, 'size'=>$size); return fopen('crypt://streams/'.$id, $mode); } @@ -59,11 +59,11 @@ class Test_CryptStream extends UnitTestCase { $file=__DIR__.'/binary'; $source=file_get_contents($file); - $stream=$this->getStream('test','w', strlen($source)); + $stream=$this->getStream('test', 'w', strlen($source)); fwrite($stream, $source); fclose($stream); - $stream=$this->getStream('test','r', strlen($source)); + $stream=$this->getStream('test', 'r', strlen($source)); $data=stream_get_contents($stream); fclose($stream); $this->assertEqual(strlen($data), strlen($source)); @@ -72,11 +72,11 @@ class Test_CryptStream extends UnitTestCase { $file=__DIR__.'/zeros'; $source=file_get_contents($file); - $stream=$this->getStream('test2','w', strlen($source)); + $stream=$this->getStream('test2', 'w', strlen($source)); fwrite($stream, $source); fclose($stream); - $stream=$this->getStream('test2','r', strlen($source)); + $stream=$this->getStream('test2', 'r', strlen($source)); $data=stream_get_contents($stream); fclose($stream); $this->assertEqual(strlen($data), strlen($source)); diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php index 8a67b31b20..2fc2a3a1a3 100644 --- a/apps/files_external/lib/ftp.php +++ b/apps/files_external/lib/ftp.php @@ -53,7 +53,7 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{ case 'ab': //these are supported by the wrapper $context = stream_context_create(array('ftp' => array('overwrite' => true))); - return fopen($this->constructUrl($path),$mode, false, $context); + return fopen($this->constructUrl($path), $mode, false, $context); case 'r+': case 'w+': case 'wb+': @@ -63,13 +63,13 @@ class OC_FileStorage_FTP extends OC_FileStorage_StreamWrapper{ case 'c': case 'c+': //emulate these - if(strrpos($path,'.')!==false) { - $ext=substr($path, strrpos($path,'.')); + if(strrpos($path, '.')!==false) { + $ext=substr($path, strrpos($path, '.')); }else{ $ext=''; } $tmpFile=OCP\Files::tmpFile($ext); - OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); + OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack'); if($this->file_exists($path)) { $this->getFile($path, $tmpFile); } diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index 32d57ed3ce..e5de81280a 100644 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -394,8 +394,8 @@ class OC_Filestorage_Google extends OC_Filestorage_Common { case 'x+': case 'c': case 'c+': - if (strrpos($path,'.') !== false) { - $ext = substr($path, strrpos($path,'.')); + if (strrpos($path, '.') !== false) { + $ext = substr($path, strrpos($path, '.')); } else { $ext = ''; } diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index d763689434..802d80d8d1 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -24,7 +24,7 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ 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]!='/') { @@ -41,7 +41,7 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{ } public function constructUrl($path) { - if(substr($path,-1)=='/') { + if(substr($path, -1)=='/') { $path=substr($path, 0, -1); } return 'smb://'.$this->user.':'.$this->password.'@'.$this->host.$this->share.$this->root.$path; diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index 7961ecbe1b..b66a0f0ee1 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -60,8 +60,8 @@ abstract class OC_FileStorage_StreamWrapper extends OC_Filestorage_Common{ public function touch($path, $mtime=null) { if(is_null($mtime)) { - $fh=$this->fopen($path,'a'); - fwrite($fh,''); + $fh=$this->fopen($path, 'a'); + fwrite($fh, ''); fclose($fh); }else{ return false;//not supported diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index c04de45d40..2f0076706e 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -39,7 +39,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ * @return string */ private function getContainerName($path) { - $path=trim(trim($this->root,'/')."/".$path,'/.'); + $path=trim(trim($this->root, '/')."/".$path, '/.'); return str_replace('/', '\\', $path); } @@ -205,7 +205,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ unlink($tmpFile); return false; }else{ - $fh=fopen($tmpFile,'a'); + $fh=fopen($tmpFile, 'a'); fwrite($fh, $name."\n"); } }catch(Exception $e) { @@ -432,7 +432,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{ case 'c': case 'c+': $tmpFile=$this->getTmpFile($path); - OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); + OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack'); self::$tempFiles[$tmpFile]=$path; return fopen('close://'.$tmpFile, $mode); } diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 3d2ea7fa2a..02fe540d06 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -46,7 +46,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ if($caview = \OCP\Files::getStorage('files_external')) { $certPath=\OCP\Config::getSystemValue('datadirectory').$caview->getAbsolutePath("").'rootcerts.crt'; - if (file_exists($certPath)) { + if (file_exists($certPath)) { $this->client->addTrustedCertificates($certPath); } } @@ -252,7 +252,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ public function stat($path) { $path=$this->cleanPath($path); try{ - $response=$this->client->propfind($path, array('{DAV:}getlastmodified','{DAV:}getcontentlength')); + $response=$this->client->propfind($path, array('{DAV:}getlastmodified', '{DAV:}getcontentlength')); return array( 'mtime'=>strtotime($response['{DAV:}getlastmodified']), 'size'=>(int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0, @@ -266,7 +266,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ public function getMimeType($path) { $path=$this->cleanPath($path); try{ - $response=$this->client->propfind($path, array('{DAV:}getcontenttype','{DAV:}resourcetype')); + $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') { diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 105e94f114..295273d842 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -1,223 +1,223 @@ -execute(array($_GET['token']))->fetchOne(); - if(isset($filepath)) { - $info = OC_FileCache_Cached::get($filepath, ''); - if(strtolower($info['mimetype']) == 'httpd/unix-directory') { - $_GET['dir'] = $filepath; - } else { - $_GET['file'] = $filepath; - } - \OCP\Util::writeLog('files_sharing', 'You have files that are shared by link originating from ownCloud 4.0. Redistribute the new links, because backwards compatibility will be removed in ownCloud 5.', \OCP\Util::WARN); - } -} -// Enf of backward compatibility - -function getID($path) { - // use the share table from the db to find the item source if the file was reshared because shared files - //are not stored in the file cache. - if (substr(OC_Filesystem::getMountPoint($path), -7, 6) == "Shared") { - $path_parts = explode('/', $path, 5); - $user = $path_parts[1]; - $intPath = '/'.$path_parts[4]; - $query = \OC_DB::prepare('SELECT item_source FROM *PREFIX*share WHERE uid_owner = ? AND file_target = ? '); - $result = $query->execute(array($user, $intPath)); - $row = $result->fetchRow(); - $fileSource = $row['item_source']; - } else { - $fileSource = OC_Filecache::getId($path, ''); - } - - return $fileSource; -} - -if (isset($_GET['file']) || isset($_GET['dir'])) { - if (isset($_GET['dir'])) { - $type = 'folder'; - $path = $_GET['dir']; - if(strlen($path)>1 and substr($path, -1, 1)==='/') { - $path=substr($path, 0, -1); - } - $baseDir = $path; - $dir = $baseDir; - } else { - $type = 'file'; - $path = $_GET['file']; - if(strlen($path)>1 and substr($path, -1, 1)==='/') { - $path=substr($path, 0, -1); - } - } - $uidOwner = substr($path, 1, strpos($path, '/', 1) - 1); - if (OCP\User::userExists($uidOwner)) { - OC_Util::setupFS($uidOwner); - $fileSource = getId($path); - if ($fileSource != -1 && ($linkItem = OCP\Share::getItemSharedWithByLink($type, $fileSource, $uidOwner))) { - // TODO Fix in the getItems - if (!isset($linkItem['item_type']) || $linkItem['item_type'] != $type) { - header('HTTP/1.0 404 Not Found'); - $tmpl = new OCP\Template('', '404', 'guest'); - $tmpl->printPage(); - exit(); - } - if (isset($linkItem['share_with'])) { - // Check password - if (isset($_GET['file'])) { - $url = OCP\Util::linkToPublic('files').'&file='.$_GET['file']; - } else { - $url = OCP\Util::linkToPublic('files').'&dir='.$_GET['dir']; - } - if (isset($_POST['password'])) { - $password = $_POST['password']; - $storedHash = $linkItem['share_with']; - $forcePortable = (CRYPT_BLOWFISH != 1); - $hasher = new PasswordHash(8, $forcePortable); - if (!($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash))) { - $tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest'); - $tmpl->assign('URL', $url); - $tmpl->assign('error', true); - $tmpl->printPage(); - exit(); - } else { - // Save item id in session for future requests - $_SESSION['public_link_authenticated'] = $linkItem['id']; - } - // Check if item id is set in session - } else if (!isset($_SESSION['public_link_authenticated']) || $_SESSION['public_link_authenticated'] !== $linkItem['id']) { - // Prompt for password - $tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest'); - $tmpl->assign('URL', $url); - $tmpl->printPage(); - exit(); - } - } - $path = $linkItem['path']; - if (isset($_GET['path'])) { - $path .= $_GET['path']; - $dir .= $_GET['path']; - if (!OC_Filesystem::file_exists($path)) { - header('HTTP/1.0 404 Not Found'); - $tmpl = new OCP\Template('', '404', 'guest'); - $tmpl->printPage(); - exit(); - } - } - // Download the file - if (isset($_GET['download'])) { - if (isset($_GET['dir'])) { - if ( isset($_GET['files']) ) { // download selected files - OC_Files::get($path, $_GET['files'], $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); - } else if (isset($_GET['path']) && $_GET['path'] != '' ) { // download a file from a shared directory - OC_Files::get('', $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); - } else { // download the whole shared directory - OC_Files::get($path, '', $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); - } - } else { // download a single shared file - OC_Files::get("", $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); - } - - } else { - OCP\Util::addStyle('files_sharing', 'public'); - OCP\Util::addScript('files_sharing', 'public'); - OCP\Util::addScript('files', 'fileactions'); - $tmpl = new OCP\Template('files_sharing', 'public', 'base'); - $tmpl->assign('owner', $uidOwner); - // Show file list - if (OC_Filesystem::is_dir($path)) { - OCP\Util::addStyle('files', 'files'); - OCP\Util::addScript('files', 'files'); - OCP\Util::addScript('files', 'filelist'); - $files = array(); - $rootLength = strlen($baseDir) + 1; - foreach (OC_Files::getDirectoryContent($path) as $i) { - $i['date'] = OCP\Util::formatDate($i['mtime']); - if ($i['type'] == 'file') { - $fileinfo = pathinfo($i['name']); - $i['basename'] = $fileinfo['filename']; - $i['extension'] = isset($fileinfo['extension']) ? ('.'.$fileinfo['extension']) : ''; - } - $i['directory'] = '/'.substr('/'.$uidOwner.'/files'.$i['directory'], $rootLength); - if ($i['directory'] == '/') { - $i['directory'] = ''; - } - $i['permissions'] = OCP\Share::PERMISSION_READ; - $files[] = $i; - } - // Make breadcrumb - $breadcrumb = array(); - $pathtohere = ''; - $count = 1; - foreach (explode('/', $dir) as $i) { - if ($i != '') { - if ($i != $baseDir) { - $pathtohere .= '/'.$i; - } - if ( strlen($pathtohere) < strlen($_GET['dir'])) { - continue; - } - $breadcrumb[] = array('dir' => str_replace($_GET['dir'], "", $pathtohere, $count), 'name' => $i); - } - } - $list = new OCP\Template('files', 'part.list', ''); - $list->assign('files', $files, false); - $list->assign('publicListView', true); - $list->assign('baseURL', OCP\Util::linkToPublic('files').'&dir='.urlencode($_GET['dir']).'&path=', false); - $list->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path=', false); - $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '' ); - $breadcrumbNav->assign('breadcrumb', $breadcrumb, false); - $breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files').'&dir='.urlencode($_GET['dir']).'&path=', false); - $folder = new OCP\Template('files', 'index', ''); - $folder->assign('fileList', $list->fetchPage(), false); - $folder->assign('breadcrumb', $breadcrumbNav->fetchPage(), false); - $folder->assign('dir', basename($dir)); - $folder->assign('isCreatable', false); - $folder->assign('permissions', 0); - $folder->assign('files', $files); - $folder->assign('uploadMaxFilesize', 0); - $folder->assign('uploadMaxHumanFilesize', 0); - $folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); - $tmpl->assign('folder', $folder->fetchPage(), false); - $tmpl->assign('uidOwner', $uidOwner); - $tmpl->assign('dir', basename($dir)); - $tmpl->assign('filename', basename($path)); - $tmpl->assign('mimetype', OC_Filesystem::getMimeType($path)); - $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); - if (isset($_GET['path'])) { - $getPath = $_GET['path']; - } else { - $getPath = ''; - } - $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path='.urlencode($getPath), false); - } else { - // Show file preview if viewer is available - $tmpl->assign('uidOwner', $uidOwner); - $tmpl->assign('dir', dirname($path)); - $tmpl->assign('filename', basename($path)); - $tmpl->assign('mimetype', OC_Filesystem::getMimeType($path)); - if ($type == 'file') { - $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&file='.urlencode($_GET['file']).'&download', false); - } else { - if (isset($_GET['path'])) { - $getPath = $_GET['path']; - } else { - $getPath = ''; - } - $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path='.urlencode($getPath), false); - } - } - $tmpl->printPage(); - } - exit(); - } - } -} -header('HTTP/1.0 404 Not Found'); -$tmpl = new OCP\Template('', '404', 'guest'); -$tmpl->printPage(); +execute(array($_GET['token']))->fetchOne(); + if(isset($filepath)) { + $info = OC_FileCache_Cached::get($filepath, ''); + if(strtolower($info['mimetype']) == 'httpd/unix-directory') { + $_GET['dir'] = $filepath; + } else { + $_GET['file'] = $filepath; + } + \OCP\Util::writeLog('files_sharing', 'You have files that are shared by link originating from ownCloud 4.0. Redistribute the new links, because backwards compatibility will be removed in ownCloud 5.', \OCP\Util::WARN); + } +} +// Enf of backward compatibility + +function getID($path) { + // use the share table from the db to find the item source if the file was reshared because shared files + //are not stored in the file cache. + if (substr(OC_Filesystem::getMountPoint($path), -7, 6) == "Shared") { + $path_parts = explode('/', $path, 5); + $user = $path_parts[1]; + $intPath = '/'.$path_parts[4]; + $query = \OC_DB::prepare('SELECT item_source FROM *PREFIX*share WHERE uid_owner = ? AND file_target = ? '); + $result = $query->execute(array($user, $intPath)); + $row = $result->fetchRow(); + $fileSource = $row['item_source']; + } else { + $fileSource = OC_Filecache::getId($path, ''); + } + + return $fileSource; +} + +if (isset($_GET['file']) || isset($_GET['dir'])) { + if (isset($_GET['dir'])) { + $type = 'folder'; + $path = $_GET['dir']; + if(strlen($path)>1 and substr($path, -1, 1)==='/') { + $path=substr($path, 0, -1); + } + $baseDir = $path; + $dir = $baseDir; + } else { + $type = 'file'; + $path = $_GET['file']; + if(strlen($path)>1 and substr($path, -1, 1)==='/') { + $path=substr($path, 0, -1); + } + } + $uidOwner = substr($path, 1, strpos($path, '/', 1) - 1); + if (OCP\User::userExists($uidOwner)) { + OC_Util::setupFS($uidOwner); + $fileSource = getId($path); + if ($fileSource != -1 && ($linkItem = OCP\Share::getItemSharedWithByLink($type, $fileSource, $uidOwner))) { + // TODO Fix in the getItems + if (!isset($linkItem['item_type']) || $linkItem['item_type'] != $type) { + header('HTTP/1.0 404 Not Found'); + $tmpl = new OCP\Template('', '404', 'guest'); + $tmpl->printPage(); + exit(); + } + if (isset($linkItem['share_with'])) { + // Check password + if (isset($_GET['file'])) { + $url = OCP\Util::linkToPublic('files').'&file='.$_GET['file']; + } else { + $url = OCP\Util::linkToPublic('files').'&dir='.$_GET['dir']; + } + if (isset($_POST['password'])) { + $password = $_POST['password']; + $storedHash = $linkItem['share_with']; + $forcePortable = (CRYPT_BLOWFISH != 1); + $hasher = new PasswordHash(8, $forcePortable); + if (!($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash))) { + $tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest'); + $tmpl->assign('URL', $url); + $tmpl->assign('error', true); + $tmpl->printPage(); + exit(); + } else { + // Save item id in session for future requests + $_SESSION['public_link_authenticated'] = $linkItem['id']; + } + // Check if item id is set in session + } else if (!isset($_SESSION['public_link_authenticated']) || $_SESSION['public_link_authenticated'] !== $linkItem['id']) { + // Prompt for password + $tmpl = new OCP\Template('files_sharing', 'authenticate', 'guest'); + $tmpl->assign('URL', $url); + $tmpl->printPage(); + exit(); + } + } + $path = $linkItem['path']; + if (isset($_GET['path'])) { + $path .= $_GET['path']; + $dir .= $_GET['path']; + if (!OC_Filesystem::file_exists($path)) { + header('HTTP/1.0 404 Not Found'); + $tmpl = new OCP\Template('', '404', 'guest'); + $tmpl->printPage(); + exit(); + } + } + // Download the file + if (isset($_GET['download'])) { + if (isset($_GET['dir'])) { + if ( isset($_GET['files']) ) { // download selected files + OC_Files::get($path, $_GET['files'], $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); + } else if (isset($_GET['path']) && $_GET['path'] != '' ) { // download a file from a shared directory + OC_Files::get('', $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); + } else { // download the whole shared directory + OC_Files::get($path, '', $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); + } + } else { // download a single shared file + OC_Files::get("", $path, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false); + } + + } else { + OCP\Util::addStyle('files_sharing', 'public'); + OCP\Util::addScript('files_sharing', 'public'); + OCP\Util::addScript('files', 'fileactions'); + $tmpl = new OCP\Template('files_sharing', 'public', 'base'); + $tmpl->assign('owner', $uidOwner); + // Show file list + if (OC_Filesystem::is_dir($path)) { + OCP\Util::addStyle('files', 'files'); + OCP\Util::addScript('files', 'files'); + OCP\Util::addScript('files', 'filelist'); + $files = array(); + $rootLength = strlen($baseDir) + 1; + foreach (OC_Files::getDirectoryContent($path) as $i) { + $i['date'] = OCP\Util::formatDate($i['mtime']); + if ($i['type'] == 'file') { + $fileinfo = pathinfo($i['name']); + $i['basename'] = $fileinfo['filename']; + $i['extension'] = isset($fileinfo['extension']) ? ('.'.$fileinfo['extension']) : ''; + } + $i['directory'] = '/'.substr('/'.$uidOwner.'/files'.$i['directory'], $rootLength); + if ($i['directory'] == '/') { + $i['directory'] = ''; + } + $i['permissions'] = OCP\Share::PERMISSION_READ; + $files[] = $i; + } + // Make breadcrumb + $breadcrumb = array(); + $pathtohere = ''; + $count = 1; + foreach (explode('/', $dir) as $i) { + if ($i != '') { + if ($i != $baseDir) { + $pathtohere .= '/'.$i; + } + if ( strlen($pathtohere) < strlen($_GET['dir'])) { + continue; + } + $breadcrumb[] = array('dir' => str_replace($_GET['dir'], "", $pathtohere, $count), 'name' => $i); + } + } + $list = new OCP\Template('files', 'part.list', ''); + $list->assign('files', $files, false); + $list->assign('publicListView', true); + $list->assign('baseURL', OCP\Util::linkToPublic('files').'&dir='.urlencode($_GET['dir']).'&path=', false); + $list->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path=', false); + $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '' ); + $breadcrumbNav->assign('breadcrumb', $breadcrumb, false); + $breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files').'&dir='.urlencode($_GET['dir']).'&path=', false); + $folder = new OCP\Template('files', 'index', ''); + $folder->assign('fileList', $list->fetchPage(), false); + $folder->assign('breadcrumb', $breadcrumbNav->fetchPage(), false); + $folder->assign('dir', basename($dir)); + $folder->assign('isCreatable', false); + $folder->assign('permissions', 0); + $folder->assign('files', $files); + $folder->assign('uploadMaxFilesize', 0); + $folder->assign('uploadMaxHumanFilesize', 0); + $folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); + $tmpl->assign('folder', $folder->fetchPage(), false); + $tmpl->assign('uidOwner', $uidOwner); + $tmpl->assign('dir', basename($dir)); + $tmpl->assign('filename', basename($path)); + $tmpl->assign('mimetype', OC_Filesystem::getMimeType($path)); + $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); + if (isset($_GET['path'])) { + $getPath = $_GET['path']; + } else { + $getPath = ''; + } + $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path='.urlencode($getPath), false); + } else { + // Show file preview if viewer is available + $tmpl->assign('uidOwner', $uidOwner); + $tmpl->assign('dir', dirname($path)); + $tmpl->assign('filename', basename($path)); + $tmpl->assign('mimetype', OC_Filesystem::getMimeType($path)); + if ($type == 'file') { + $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&file='.urlencode($_GET['file']).'&download', false); + } else { + if (isset($_GET['path'])) { + $getPath = $_GET['path']; + } else { + $getPath = ''; + } + $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files').'&download&dir='.urlencode($_GET['dir']).'&path='.urlencode($getPath), false); + } + } + $tmpl->printPage(); + } + exit(); + } + } +} +header('HTTP/1.0 404 Not Found'); +$tmpl = new OCP\Template('', '404', 'guest'); +$tmpl->printPage(); diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php index 746f89a813..599d302e6e 100644 --- a/apps/files_versions/appinfo/app.php +++ b/apps/files_versions/appinfo/app.php @@ -5,7 +5,7 @@ OC::$CLASSPATH['OCA_Versions\Storage'] = 'apps/files_versions/lib/versions.php'; OC::$CLASSPATH['OCA_Versions\Hooks'] = 'apps/files_versions/lib/hooks.php'; OCP\App::registerAdmin('files_versions', 'settings'); -OCP\App::registerPersonal('files_versions','settings-personal'); +OCP\App::registerPersonal('files_versions', 'settings-personal'); OCP\Util::addscript('files_versions', 'versions'); diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php index 0ebb34f45e..deff735ced 100644 --- a/apps/files_versions/history.php +++ b/apps/files_versions/history.php @@ -22,7 +22,7 @@ */ OCP\User::checkLoggedIn( ); -OCP\Util::addStyle('files_versions','versions'); +OCP\Util::addStyle('files_versions', 'versions'); $tmpl = new OCP\Template( 'files_versions', 'history', 'user' ); if ( isset( $_GET['path'] ) ) { diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 8ee147d085..dc83ab12af 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -1,278 +1,278 @@ - - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -/** - * Versions - * - * A class to handle the versioning of files. - */ - -namespace OCA_Versions; - -class Storage { - - - // config.php configuration: - // - files_versions - // - files_versionsfolder - // - files_versionsblacklist - // - files_versionsmaxfilesize - // - files_versionsinterval - // - files_versionmaxversions - // - // todo: - // - finish porting to OC_FilesystemView to enable network transparency - // - add transparent compression. first test if it´s worth it. - - const DEFAULTENABLED=true; - const DEFAULTBLACKLIST='avi mp3 mpg mp4 ctmp'; - const DEFAULTMAXFILESIZE=1048576; // 10MB - const DEFAULTMININTERVAL=60; // 1 min - const DEFAULTMAXVERSIONS=50; - - private static function getUidAndFilename($filename) - { - if (\OCP\App::isEnabled('files_sharing') - && substr($filename, 0, 7) == '/Shared' - && $source = \OCP\Share::getItemSharedWith('file', - substr($filename, 7), - \OC_Share_Backend_File::FORMAT_SHARED_STORAGE)) { - $filename = $source['path']; - $pos = strpos($filename, '/files', 1); - $uid = substr($filename, 1, $pos - 1); - $filename = substr($filename, $pos + 6); - } else { - $uid = \OCP\User::getUser(); - } - return array($uid, $filename); - } - - /** - * store a new version of a file. - */ - public function store($filename) { - if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - list($uid, $filename) = self::getUidAndFilename($filename); - $files_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/files'); - $users_view = new \OC_FilesystemView('/'.\OCP\User::getUser()); - - //check if source file already exist as version to avoid recursions. - // todo does this check work? - if ($users_view->file_exists($filename)) { - return false; - } - - // check if filename is a directory - if($files_view->is_dir($filename)) { - return false; - } - - // check filetype blacklist - $blacklist=explode(' ', \OCP\Config::getSystemValue('files_versionsblacklist', Storage::DEFAULTBLACKLIST)); - foreach($blacklist as $bl) { - $parts=explode('.', $filename); - $ext=end($parts); - if(strtolower($ext)==$bl) { - return false; - } - } - // we should have a source file to work with - if (!$files_view->file_exists($filename)) { - return false; - } - - // check filesize - if($files_view->filesize($filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)) { - return false; - } - - - // check mininterval if the file is being modified by the owner (all shared files should be versioned despite mininterval) - if ($uid == \OCP\User::getUser()) { - $versions_fileview = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_versions'); - $versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename); - $versionsFolderName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath(''); - $matches=glob($versionsName.'.v*'); - sort($matches); - $parts=explode('.v', end($matches)); - if((end($parts)+Storage::DEFAULTMININTERVAL)>time()) { - return false; - } - } - - - // create all parent folders - $info=pathinfo($filename); - if(!file_exists($versionsFolderName.'/'.$info['dirname'])) { - mkdir($versionsFolderName.'/'.$info['dirname'],0750, true); - } - - // store a new version of a file - $users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.time()); - - // expire old revisions if necessary - Storage::expire($filename); - } - } - - - /** - * rollback to an old version of a file. - */ - public static function rollback($filename, $revision) { - - if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - list($uid, $filename) = self::getUidAndFilename($filename); - $users_view = new \OC_FilesystemView('/'.\OCP\User::getUser()); - - // rollback - if( @$users_view->copy('files_versions'.$filename.'.v'.$revision, 'files'.$filename) ) { - - return true; - - }else{ - - return false; - - } - - } - - } - - /** - * check if old versions of a file exist. - */ - public static function isversioned($filename) { - if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - list($uid, $filename) = self::getUidAndFilename($filename); - $versions_fileview = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_versions'); - - $versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename); - - // check for old versions - $matches=glob($versionsName.'.v*'); - if(count($matches)>0) { - return true; - }else{ - return false; - } - }else{ - return(false); - } - } - - - - /** - * @brief get a list of all available versions of a file in descending chronological order - * @param $filename file to find versions of, relative to the user files dir - * @param $count number of versions to return - * @returns array - */ - public static function getVersions( $filename, $count = 0 ) { - if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) { - list($uid, $filename) = self::getUidAndFilename($filename); - $versions_fileview = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_versions'); - - $versionsName = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename); - $versions = array(); - // fetch for old versions - $matches = glob( $versionsName.'.v*' ); - - sort( $matches ); - - $i = 0; - - $files_view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files'); - $local_file = $files_view->getLocalFile($filename); - foreach( $matches as $ma ) { - - $i++; - $versions[$i]['cur'] = 0; - $parts = explode( '.v', $ma ); - $versions[$i]['version'] = ( end( $parts ) ); - - // if file with modified date exists, flag it in array as currently enabled version - ( \md5_file( $ma ) == \md5_file( $local_file ) ? $versions[$i]['fileMatch'] = 1 : $versions[$i]['fileMatch'] = 0 ); - - } - - $versions = array_reverse( $versions ); - - foreach( $versions as $key => $value ) { - - // flag the first matched file in array (which will have latest modification date) as current version - if ( $value['fileMatch'] ) { - - $value['cur'] = 1; - break; - - } - - } - - $versions = array_reverse( $versions ); - - // only show the newest commits - if( $count != 0 and ( count( $versions )>$count ) ) { - - $versions = array_slice( $versions, count( $versions ) - $count ); - - } - - return( $versions ); - - - } else { - - // if versioning isn't enabled then return an empty array - return( array() ); - - } - - } - - /** - * @brief Erase a file's versions which exceed the set quota - */ - public static function expire($filename) { - if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - list($uid, $filename) = self::getUidAndFilename($filename); - $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions'); - - $versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename); - - // check for old versions - $matches = glob( $versionsName.'.v*' ); - - if( count( $matches ) > \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ) { - - $numberToDelete = count($matches) - \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ); - - // delete old versions of a file - $deleteItems = array_slice( $matches, 0, $numberToDelete ); - - foreach( $deleteItems as $de ) { - - unlink( $versionsName.'.v'.$de ); - - } - } - } - } - - /** - * @brief Erase all old versions of all user files - * @return true/false - */ - public function expireAll() { - $view = \OCP\Files::getStorage('files_versions'); - return $view->deleteAll('', true); - } + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +/** + * Versions + * + * A class to handle the versioning of files. + */ + +namespace OCA_Versions; + +class Storage { + + + // config.php configuration: + // - files_versions + // - files_versionsfolder + // - files_versionsblacklist + // - files_versionsmaxfilesize + // - files_versionsinterval + // - files_versionmaxversions + // + // todo: + // - finish porting to OC_FilesystemView to enable network transparency + // - add transparent compression. first test if it´s worth it. + + const DEFAULTENABLED=true; + const DEFAULTBLACKLIST='avi mp3 mpg mp4 ctmp'; + const DEFAULTMAXFILESIZE=1048576; // 10MB + const DEFAULTMININTERVAL=60; // 1 min + const DEFAULTMAXVERSIONS=50; + + private static function getUidAndFilename($filename) + { + if (\OCP\App::isEnabled('files_sharing') + && substr($filename, 0, 7) == '/Shared' + && $source = \OCP\Share::getItemSharedWith('file', + substr($filename, 7), + \OC_Share_Backend_File::FORMAT_SHARED_STORAGE)) { + $filename = $source['path']; + $pos = strpos($filename, '/files', 1); + $uid = substr($filename, 1, $pos - 1); + $filename = substr($filename, $pos + 6); + } else { + $uid = \OCP\User::getUser(); + } + return array($uid, $filename); + } + + /** + * store a new version of a file. + */ + public function store($filename) { + if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + list($uid, $filename) = self::getUidAndFilename($filename); + $files_view = new \OC_FilesystemView('/'.\OCP\User::getUser() .'/files'); + $users_view = new \OC_FilesystemView('/'.\OCP\User::getUser()); + + //check if source file already exist as version to avoid recursions. + // todo does this check work? + if ($users_view->file_exists($filename)) { + return false; + } + + // check if filename is a directory + if($files_view->is_dir($filename)) { + return false; + } + + // check filetype blacklist + $blacklist=explode(' ', \OCP\Config::getSystemValue('files_versionsblacklist', Storage::DEFAULTBLACKLIST)); + foreach($blacklist as $bl) { + $parts=explode('.', $filename); + $ext=end($parts); + if(strtolower($ext)==$bl) { + return false; + } + } + // we should have a source file to work with + if (!$files_view->file_exists($filename)) { + return false; + } + + // check filesize + if($files_view->filesize($filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)) { + return false; + } + + + // check mininterval if the file is being modified by the owner (all shared files should be versioned despite mininterval) + if ($uid == \OCP\User::getUser()) { + $versions_fileview = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_versions'); + $versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename); + $versionsFolderName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath(''); + $matches=glob($versionsName.'.v*'); + sort($matches); + $parts=explode('.v', end($matches)); + if((end($parts)+Storage::DEFAULTMININTERVAL)>time()) { + return false; + } + } + + + // create all parent folders + $info=pathinfo($filename); + if(!file_exists($versionsFolderName.'/'.$info['dirname'])) { + mkdir($versionsFolderName.'/'.$info['dirname'], 0750, true); + } + + // store a new version of a file + $users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.time()); + + // expire old revisions if necessary + Storage::expire($filename); + } + } + + + /** + * rollback to an old version of a file. + */ + public static function rollback($filename, $revision) { + + if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + list($uid, $filename) = self::getUidAndFilename($filename); + $users_view = new \OC_FilesystemView('/'.\OCP\User::getUser()); + + // rollback + if( @$users_view->copy('files_versions'.$filename.'.v'.$revision, 'files'.$filename) ) { + + return true; + + }else{ + + return false; + + } + + } + + } + + /** + * check if old versions of a file exist. + */ + public static function isversioned($filename) { + if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + list($uid, $filename) = self::getUidAndFilename($filename); + $versions_fileview = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_versions'); + + $versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename); + + // check for old versions + $matches=glob($versionsName.'.v*'); + if(count($matches)>0) { + return true; + }else{ + return false; + } + }else{ + return(false); + } + } + + + + /** + * @brief get a list of all available versions of a file in descending chronological order + * @param $filename file to find versions of, relative to the user files dir + * @param $count number of versions to return + * @returns array + */ + public static function getVersions( $filename, $count = 0 ) { + if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) { + list($uid, $filename) = self::getUidAndFilename($filename); + $versions_fileview = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_versions'); + + $versionsName = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename); + $versions = array(); + // fetch for old versions + $matches = glob( $versionsName.'.v*' ); + + sort( $matches ); + + $i = 0; + + $files_view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files'); + $local_file = $files_view->getLocalFile($filename); + foreach( $matches as $ma ) { + + $i++; + $versions[$i]['cur'] = 0; + $parts = explode( '.v', $ma ); + $versions[$i]['version'] = ( end( $parts ) ); + + // if file with modified date exists, flag it in array as currently enabled version + ( \md5_file( $ma ) == \md5_file( $local_file ) ? $versions[$i]['fileMatch'] = 1 : $versions[$i]['fileMatch'] = 0 ); + + } + + $versions = array_reverse( $versions ); + + foreach( $versions as $key => $value ) { + + // flag the first matched file in array (which will have latest modification date) as current version + if ( $value['fileMatch'] ) { + + $value['cur'] = 1; + break; + + } + + } + + $versions = array_reverse( $versions ); + + // only show the newest commits + if( $count != 0 and ( count( $versions )>$count ) ) { + + $versions = array_slice( $versions, count( $versions ) - $count ); + + } + + return( $versions ); + + + } else { + + // if versioning isn't enabled then return an empty array + return( array() ); + + } + + } + + /** + * @brief Erase a file's versions which exceed the set quota + */ + public static function expire($filename) { + if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + list($uid, $filename) = self::getUidAndFilename($filename); + $versions_fileview = new \OC_FilesystemView('/'.$uid.'/files_versions'); + + $versionsName=\OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath($filename); + + // check for old versions + $matches = glob( $versionsName.'.v*' ); + + if( count( $matches ) > \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ) { + + $numberToDelete = count($matches) - \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ); + + // delete old versions of a file + $deleteItems = array_slice( $matches, 0, $numberToDelete ); + + foreach( $deleteItems as $de ) { + + unlink( $versionsName.'.v'.$de ); + + } + } + } + } + + /** + * @brief Erase all old versions of all user files + * @return true/false + */ + public function expireAll() { + $view = \OCP\Files::getStorage('files_versions'); + return $view->deleteAll('', true); + } } diff --git a/apps/files_versions/settings-personal.php b/apps/files_versions/settings-personal.php index 4fb866bd99..6555bc99c3 100644 --- a/apps/files_versions/settings-personal.php +++ b/apps/files_versions/settings-personal.php @@ -2,6 +2,6 @@ $tmpl = new OCP\Template( 'files_versions', 'settings-personal'); -OCP\Util::addscript('files_versions','settings-personal'); +OCP\Util::addscript('files_versions', 'settings-personal'); return $tmpl->fetchPage(); diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index 6c6cc5679b..6343731008 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -124,7 +124,7 @@ class GROUP_LDAP extends lib\Access implements \OCP\GroupInterface { $this->connection->ldapGroupFilter, $this->connection->ldapGroupMemberAssocAttr.'='.$uid )); - $groups = $this->fetchListOfGroups($filter, array($this->connection->ldapGroupDisplayName,'dn')); + $groups = $this->fetchListOfGroups($filter, array($this->connection->ldapGroupDisplayName, 'dn')); $groups = array_unique($this->ownCloudGroupNames($groups), SORT_LOCALE_STRING); $this->connection->writeToCache($cacheKey, $groups); diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 74ff55355b..ef92bbad40 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -180,13 +180,13 @@ class Connection { * Caches the general LDAP configuration. */ private function readConfiguration($force = false) { - \OCP\Util::writeLog('user_ldap','Checking conf state: isConfigured? '.print_r($this->configured, true).' isForce? '.print_r($force, true).' configID? '.print_r($this->configID, true), \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Checking conf state: isConfigured? '.print_r($this->configured, true).' isForce? '.print_r($force, true).' configID? '.print_r($this->configID, true), \OCP\Util::DEBUG); if((!$this->configured || $force) && !is_null($this->configID)) { - \OCP\Util::writeLog('user_ldap','Reading the configuration', \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'Reading the configuration', \OCP\Util::DEBUG); $this->config['ldapHost'] = \OCP\Config::getAppValue($this->configID, 'ldap_host', ''); $this->config['ldapPort'] = \OCP\Config::getAppValue($this->configID, 'ldap_port', 389); - $this->config['ldapAgentName'] = \OCP\Config::getAppValue($this->configID, 'ldap_dn',''); - $this->config['ldapAgentPassword'] = base64_decode(\OCP\Config::getAppValue($this->configID, 'ldap_agent_password','')); + $this->config['ldapAgentName'] = \OCP\Config::getAppValue($this->configID, 'ldap_dn', ''); + $this->config['ldapAgentPassword'] = base64_decode(\OCP\Config::getAppValue($this->configID, 'ldap_agent_password', '')); $this->config['ldapBase'] = \OCP\Config::getAppValue($this->configID, 'ldap_base', ''); $this->config['ldapBaseUsers'] = \OCP\Config::getAppValue($this->configID, 'ldap_base_users', $this->config['ldapBase']); $this->config['ldapBaseGroups'] = \OCP\Config::getAppValue($this->configID, 'ldap_base_groups', $this->config['ldapBase']); @@ -194,8 +194,8 @@ class Connection { $this->config['ldapNoCase'] = \OCP\Config::getAppValue($this->configID, 'ldap_nocase', 0); $this->config['turnOffCertCheck'] = \OCP\Config::getAppValue($this->configID, 'ldap_turn_off_cert_check', 0); $this->config['ldapUserDisplayName'] = mb_strtolower(\OCP\Config::getAppValue($this->configID, 'ldap_display_name', 'uid'), 'UTF-8'); - $this->config['ldapUserFilter'] = \OCP\Config::getAppValue($this->configID, 'ldap_userlist_filter','objectClass=person'); - $this->config['ldapGroupFilter'] = \OCP\Config::getAppValue($this->configID, 'ldap_group_filter','(objectClass=posixGroup)'); + $this->config['ldapUserFilter'] = \OCP\Config::getAppValue($this->configID, 'ldap_userlist_filter', 'objectClass=person'); + $this->config['ldapGroupFilter'] = \OCP\Config::getAppValue($this->configID, 'ldap_group_filter', '(objectClass=posixGroup)'); $this->config['ldapLoginFilter'] = \OCP\Config::getAppValue($this->configID, 'ldap_login_filter', '(uid=%uid)'); $this->config['ldapGroupDisplayName'] = mb_strtolower(\OCP\Config::getAppValue($this->configID, 'ldap_group_display_name', 'uid'), 'UTF-8'); $this->config['ldapQuotaAttribute'] = \OCP\Config::getAppValue($this->configID, 'ldap_quota_attr', ''); @@ -263,7 +263,7 @@ class Connection { if(empty($this->config['ldapGroupFilter']) && empty($this->config['ldapGroupMemberAssocAttr'])) { \OCP\Util::writeLog('user_ldap', 'No group filter is specified, LDAP group feature will not be used.', \OCP\Util::INFO); } - if(!in_array($this->config['ldapUuidAttribute'], array('auto','entryuuid', 'nsuniqueid', 'objectguid')) && (!is_null($this->configID))) { + if(!in_array($this->config['ldapUuidAttribute'], array('auto', 'entryuuid', 'nsuniqueid', 'objectguid')) && (!is_null($this->configID))) { \OCP\Config::setAppValue($this->configID, 'ldap_uuid_attribute', 'auto'); \OCP\Util::writeLog('user_ldap', 'Illegal value for the UUID Attribute, reset to autodetect.', \OCP\Util::INFO); } diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php index f765151456..2ee936d29a 100644 --- a/apps/user_ldap/settings.php +++ b/apps/user_ldap/settings.php @@ -26,16 +26,12 @@ OCP\Util::addscript('user_ldap', 'settings'); OCP\Util::addstyle('user_ldap', 'settings'); if ($_POST) { + $clearCache = false; foreach($params as $param) { if(isset($_POST[$param])) { + $clearCache = true; if('ldap_agent_password' == $param) { OCP\Config::setAppValue('user_ldap', $param, base64_encode($_POST[$param])); - } elseif('ldap_cache_ttl' == $param) { - if(OCP\Config::getAppValue('user_ldap', $param,'') != $_POST[$param]) { - $ldap = new \OCA\user_ldap\lib\Connection('user_ldap'); - $ldap->clearCache(); - OCP\Config::setAppValue('user_ldap', $param, $_POST[$param]); - } } elseif('home_folder_naming_rule' == $param) { $value = empty($_POST[$param]) ? 'opt:username' : 'attr:'.$_POST[$param]; OCP\Config::setAppValue('user_ldap', $param, $value); @@ -54,12 +50,16 @@ if ($_POST) { OCP\Config::setAppValue('user_ldap', $param, 0); } } + if($clearCache) { + $ldap = new \OCA\user_ldap\lib\Connection('user_ldap'); + $ldap->clearCache(); + } } // fill template $tmpl = new OCP\Template( 'user_ldap', 'settings'); foreach($params as $param) { - $value = OCP\Config::getAppValue('user_ldap', $param,''); + $value = OCP\Config::getAppValue('user_ldap', $param, ''); $tmpl->assign($param, $value); } diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php index 3a653ad720..d10062c1d9 100644 --- a/apps/user_ldap/templates/settings.php +++ b/apps/user_ldap/templates/settings.php @@ -29,7 +29,7 @@

- t('Help');?> + t('Help');?>
diff --git a/apps/user_ldap/tests/group_ldap.php b/apps/user_ldap/tests/group_ldap.php index 2acb8c35a1..f99902d32f 100644 --- a/apps/user_ldap/tests/group_ldap.php +++ b/apps/user_ldap/tests/group_ldap.php @@ -32,8 +32,8 @@ class Test_Group_Ldap extends UnitTestCase { $this->assertIsA(OC_Group::getGroups(), gettype(array())); $this->assertIsA($group_ldap->getGroups(), gettype(array())); - $this->assertFalse(OC_Group::inGroup('john','dosers'), gettype(false)); - $this->assertFalse($group_ldap->inGroup('john','dosers'), gettype(false)); + $this->assertFalse(OC_Group::inGroup('john', 'dosers'), gettype(false)); + $this->assertFalse($group_ldap->inGroup('john', 'dosers'), gettype(false)); //TODO: check also for expected true result. This backend won't be able to do any modifications, maybe use a dummy for this. $this->assertIsA(OC_Group::getUserGroups('john doe'), gettype(array())); diff --git a/apps/user_webdavauth/appinfo/app.php b/apps/user_webdavauth/appinfo/app.php index 3ab323becc..c4c131b7ef 100755 --- a/apps/user_webdavauth/appinfo/app.php +++ b/apps/user_webdavauth/appinfo/app.php @@ -23,7 +23,7 @@ require_once 'apps/user_webdavauth/user_webdavauth.php'; -OC_APP::registerAdmin('user_webdavauth','settings'); +OC_APP::registerAdmin('user_webdavauth', 'settings'); OC_User::registerBackend("WEBDAVAUTH"); OC_User::useBackend( "WEBDAVAUTH" ); diff --git a/apps/user_webdavauth/settings.php b/apps/user_webdavauth/settings.php index 4f1ddbbefd..497a3385ca 100755 --- a/apps/user_webdavauth/settings.php +++ b/apps/user_webdavauth/settings.php @@ -21,7 +21,6 @@ * */ -print_r($_POST); if($_POST) { if(isset($_POST['webdav_url'])) { diff --git a/core/ajax/requesttoken.php b/core/ajax/requesttoken.php deleted file mode 100644 index 9d43a72285..0000000000 --- a/core/ajax/requesttoken.php +++ /dev/null @@ -1,40 +0,0 @@ - -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the license, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. -* If not, see . -* -*/ - -/** - * @file core/ajax/requesttoken.php - * @brief Ajax method to retrieve a fresh request protection token for ajax calls - * @return json: success/error state indicator including a fresh request token - * @author Christian Reiner - */ - -// don't load apps or filesystem for this task -$RUNTIME_NOAPPS = true; -$RUNTIME_NOSETUPFS = true; - -// Sanity checks -// using OCP\JSON::callCheck() below protects the token refreshing itself. -//OCP\JSON::callCheck ( ); -OCP\JSON::checkLoggedIn ( ); -// hand out a fresh token -OCP\JSON::success ( array ( 'token' => OCP\Util::callRegister() ) ); -?> diff --git a/core/js/eventsource.js b/core/js/eventsource.js index 45c63715a7..e3ad7e3a67 100644 --- a/core/js/eventsource.js +++ b/core/js/eventsource.js @@ -40,7 +40,7 @@ OC.EventSource=function(src,data){ dataStr+=name+'='+encodeURIComponent(data[name])+'&'; } } - dataStr+='requesttoken='+OC.Request.Token; + dataStr+='requesttoken='+OC.EventSource.requesttoken; if(!this.useFallBack && typeof EventSource !='undefined'){ this.source=new EventSource(src+'?'+dataStr); this.source.onmessage=function(e){ diff --git a/core/js/requesttoken.js b/core/js/requesttoken.js deleted file mode 100644 index 0d78cd7e93..0000000000 --- a/core/js/requesttoken.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * ownCloud - * - * @file core/js/requesttoken.js - * @brief Routine to refresh the Request protection request token periodically - * @author Christian Reiner (arkascha) - * @copyright 2011-2012 Christian Reiner - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE - * License as published by the Free Software Foundation; either - * version 3 of the license, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with this library. - * If not, see . - * - */ - -OC.Request = { - // the request token - Token: {}, - // the lifespan span (in secs) - Lifespan: {}, - // method to refresh the local request token periodically - Refresh: function(){ - // just a client side console log to preserve efficiency - console.log("refreshing request token (lifebeat)"); - var dfd=new $.Deferred(); - $.ajax({ - type: 'POST', - url: OC.filePath('core','ajax','requesttoken.php'), - cache: false, - data: { }, - dataType: 'json' - }).done(function(response){ - // store refreshed token inside this class - OC.Request.Token=response.token; - dfd.resolve(); - }).fail(dfd.reject); - return dfd; - } -} -// accept requesttoken and lifespan into the OC namespace -OC.Request.Token = oc_requesttoken; -OC.Request.Lifespan = oc_requestlifespan; -// refresh the request token periodically shortly before it becomes invalid on the server side -setInterval(OC.Request.Refresh,Math.floor(1000*OC.Request.Lifespan*0.93)), // 93% of lifespan value, close to when the token expires -// early bind token as additional ajax argument for every single request -$(document).bind('ajaxSend', function(elm, xhr, s){xhr.setRequestHeader('requesttoken', OC.Request.Token);}); diff --git a/core/routes.php b/core/routes.php index 3ac943f7c6..fc511d403d 100644 --- a/core/routes.php +++ b/core/routes.php @@ -13,9 +13,6 @@ $this->create('search_ajax_search', '/search/ajax/search.php') // AppConfig $this->create('core_ajax_appconfig', '/core/ajax/appconfig.php') ->actionInclude('core/ajax/appconfig.php'); -// RequestToken -$this->create('core_ajax_requesttoken', '/core/ajax/requesttoken.php') - ->actionInclude('core/ajax/requesttoken.php'); // Share $this->create('core_ajax_share', '/core/ajax/share.php') ->actionInclude('core/ajax/share.php'); diff --git a/core/templates/installation.php b/core/templates/installation.php index 5a3bd2cc9f..a7c4780d5d 100644 --- a/core/templates/installation.php +++ b/core/templates/installation.php @@ -73,7 +73,7 @@

MySQL t( 'will be used' ); ?>.

- /> + /> @@ -84,7 +84,7 @@ - /> + /> @@ -94,7 +94,7 @@ - /> + /> diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php index f78b6ff8bb..d8f8305877 100644 --- a/core/templates/layout.base.php +++ b/core/templates/layout.base.php @@ -11,7 +11,6 @@ var oc_webroot = ''; var oc_appswebroots = ; var oc_requesttoken = ''; - var oc_requestlifespan = ''; diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index e6468cdcfb..2eaa517b32 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -11,7 +11,6 @@ var oc_webroot = ''; var oc_appswebroots = ; var oc_requesttoken = ''; - var oc_requestlifespan = ''; var datepickerFormatDate = l('jsdate', 'jsdate')) ?>; var dayNames = t('Sunday'), (string)$l->t('Monday'), (string)$l->t('Tuesday'), (string)$l->t('Wednesday'), (string)$l->t('Thursday'), (string)$l->t('Friday'), (string)$l->t('Saturday'))) ?>; var monthNames = t('January'), (string)$l->t('February'), (string)$l->t('March'), (string)$l->t('April'), (string)$l->t('May'), (string)$l->t('June'), (string)$l->t('July'), (string)$l->t('August'), (string)$l->t('September'), (string)$l->t('October'), (string)$l->t('November'), (string)$l->t('December'))) ?>; diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index d876fbc98e..451a4685e8 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -12,7 +12,6 @@ var oc_appswebroots = ; var oc_current_user = ''; var oc_requesttoken = ''; - var oc_requestlifespan = ''; var datepickerFormatDate = l('jsdate', 'jsdate')) ?>; var dayNames = t('Sunday'), (string)$l->t('Monday'), (string)$l->t('Tuesday'), (string)$l->t('Wednesday'), (string)$l->t('Thursday'), (string)$l->t('Friday'), (string)$l->t('Saturday'))) ?>; var monthNames = t('January'), (string)$l->t('February'), (string)$l->t('March'), (string)$l->t('April'), (string)$l->t('May'), (string)$l->t('June'), (string)$l->t('July'), (string)$l->t('August'), (string)$l->t('September'), (string)$l->t('October'), (string)$l->t('November'), (string)$l->t('December'))) ?>; @@ -21,6 +20,13 @@ + \n" "Language-Team: LANGUAGE \n" @@ -29,7 +29,7 @@ msgstr "" msgid "This category already exists: " msgstr "" -#: js/js.js:243 templates/layout.user.php:53 templates/layout.user.php:54 +#: js/js.js:243 templates/layout.user.php:59 templates/layout.user.php:60 msgid "Settings" msgstr "" @@ -314,87 +314,87 @@ msgstr "" msgid "Finish setup" msgstr "" -#: templates/layout.guest.php:16 templates/layout.user.php:17 +#: templates/layout.guest.php:15 templates/layout.user.php:16 msgid "Sunday" msgstr "" -#: templates/layout.guest.php:16 templates/layout.user.php:17 +#: templates/layout.guest.php:15 templates/layout.user.php:16 msgid "Monday" msgstr "" -#: templates/layout.guest.php:16 templates/layout.user.php:17 +#: templates/layout.guest.php:15 templates/layout.user.php:16 msgid "Tuesday" msgstr "" -#: templates/layout.guest.php:16 templates/layout.user.php:17 +#: templates/layout.guest.php:15 templates/layout.user.php:16 msgid "Wednesday" msgstr "" -#: templates/layout.guest.php:16 templates/layout.user.php:17 +#: templates/layout.guest.php:15 templates/layout.user.php:16 msgid "Thursday" msgstr "" -#: templates/layout.guest.php:16 templates/layout.user.php:17 +#: templates/layout.guest.php:15 templates/layout.user.php:16 msgid "Friday" msgstr "" -#: templates/layout.guest.php:16 templates/layout.user.php:17 +#: templates/layout.guest.php:15 templates/layout.user.php:16 msgid "Saturday" msgstr "" -#: templates/layout.guest.php:17 templates/layout.user.php:18 +#: templates/layout.guest.php:16 templates/layout.user.php:17 msgid "January" msgstr "" -#: templates/layout.guest.php:17 templates/layout.user.php:18 +#: templates/layout.guest.php:16 templates/layout.user.php:17 msgid "February" msgstr "" -#: templates/layout.guest.php:17 templates/layout.user.php:18 +#: templates/layout.guest.php:16 templates/layout.user.php:17 msgid "March" msgstr "" -#: templates/layout.guest.php:17 templates/layout.user.php:18 +#: templates/layout.guest.php:16 templates/layout.user.php:17 msgid "April" msgstr "" -#: templates/layout.guest.php:17 templates/layout.user.php:18 +#: templates/layout.guest.php:16 templates/layout.user.php:17 msgid "May" msgstr "" -#: templates/layout.guest.php:17 templates/layout.user.php:18 +#: templates/layout.guest.php:16 templates/layout.user.php:17 msgid "June" msgstr "" -#: templates/layout.guest.php:17 templates/layout.user.php:18 +#: templates/layout.guest.php:16 templates/layout.user.php:17 msgid "July" msgstr "" -#: templates/layout.guest.php:17 templates/layout.user.php:18 +#: templates/layout.guest.php:16 templates/layout.user.php:17 msgid "August" msgstr "" -#: templates/layout.guest.php:17 templates/layout.user.php:18 +#: templates/layout.guest.php:16 templates/layout.user.php:17 msgid "September" msgstr "" -#: templates/layout.guest.php:17 templates/layout.user.php:18 +#: templates/layout.guest.php:16 templates/layout.user.php:17 msgid "October" msgstr "" -#: templates/layout.guest.php:17 templates/layout.user.php:18 +#: templates/layout.guest.php:16 templates/layout.user.php:17 msgid "November" msgstr "" -#: templates/layout.guest.php:17 templates/layout.user.php:18 +#: templates/layout.guest.php:16 templates/layout.user.php:17 msgid "December" msgstr "" -#: templates/layout.guest.php:42 +#: templates/layout.guest.php:41 msgid "web services under your control" msgstr "" -#: templates/layout.user.php:38 +#: templates/layout.user.php:44 msgid "Log out" msgstr "" diff --git a/l10n/templates/files.pot b/l10n/templates/files.pot index 06fc0ce46d..5db9a1a6ac 100644 --- a/l10n/templates/files.pot +++ b/l10n/templates/files.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-11-04 00:00+0100\n" +"POT-Creation-Date: 2012-11-05 00:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/templates/files_encryption.pot b/l10n/templates/files_encryption.pot index 729f944b65..b94a4e4031 100644 --- a/l10n/templates/files_encryption.pot +++ b/l10n/templates/files_encryption.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-11-04 00:00+0100\n" +"POT-Creation-Date: 2012-11-05 00:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/templates/files_external.pot b/l10n/templates/files_external.pot index 51f405e0f1..24de4f4f70 100644 --- a/l10n/templates/files_external.pot +++ b/l10n/templates/files_external.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-11-04 00:00+0100\n" +"POT-Creation-Date: 2012-11-05 00:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/templates/files_sharing.pot b/l10n/templates/files_sharing.pot index d53c61547c..f2f865ee03 100644 --- a/l10n/templates/files_sharing.pot +++ b/l10n/templates/files_sharing.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-11-04 00:00+0100\n" +"POT-Creation-Date: 2012-11-05 00:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/templates/files_versions.pot b/l10n/templates/files_versions.pot index 5c037f680c..217c2ff250 100644 --- a/l10n/templates/files_versions.pot +++ b/l10n/templates/files_versions.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-11-04 00:00+0100\n" +"POT-Creation-Date: 2012-11-05 00:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/templates/lib.pot b/l10n/templates/lib.pot index fd91ee28f2..615a609eaf 100644 --- a/l10n/templates/lib.pot +++ b/l10n/templates/lib.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-11-04 00:01+0100\n" +"POT-Creation-Date: 2012-11-05 00:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/templates/settings.pot b/l10n/templates/settings.pot index a7fbc613ee..3a2f324131 100644 --- a/l10n/templates/settings.pot +++ b/l10n/templates/settings.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-11-04 00:01+0100\n" +"POT-Creation-Date: 2012-11-05 00:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/templates/user_ldap.pot b/l10n/templates/user_ldap.pot index 1e74d70915..638b83aa48 100644 --- a/l10n/templates/user_ldap.pot +++ b/l10n/templates/user_ldap.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-11-04 00:00+0100\n" +"POT-Creation-Date: 2012-11-05 00:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/lib/MDB2/Driver/Reverse/sqlite3.php b/lib/MDB2/Driver/Reverse/sqlite3.php index 36626478ce..9703780954 100644 --- a/lib/MDB2/Driver/Reverse/sqlite3.php +++ b/lib/MDB2/Driver/Reverse/sqlite3.php @@ -476,7 +476,7 @@ class MDB2_Driver_Reverse_sqlite3 extends MDB2_Driver_Reverse_Common $definition['unique'] = true; $count = count($column_names); for ($i=0; $i<$count; ++$i) { - $column_name = strtok($column_names[$i]," "); + $column_name = strtok($column_names[$i], " "); $collation = strtok(" "); $definition['fields'][$column_name] = array( 'position' => $i+1 diff --git a/lib/MDB2/Driver/sqlite3.php b/lib/MDB2/Driver/sqlite3.php index c9e7170ac6..fa4c91c126 100644 --- a/lib/MDB2/Driver/sqlite3.php +++ b/lib/MDB2/Driver/sqlite3.php @@ -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(); @@ -397,8 +397,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common } if ($this->fix_assoc_fields_names || - $this->options['portability'] & MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES) - { + $this->options['portability'] & MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES) { $this->connection->exec("PRAGMA short_column_names = 1"); $this->fix_assoc_fields_names = true; } diff --git a/lib/app.php b/lib/app.php index f82961ca3a..79c1d83314 100755 --- a/lib/app.php +++ b/lib/app.php @@ -185,7 +185,7 @@ class OC_App{ }else{ $download=OC_OCSClient::getApplicationDownload($app, 1); if(isset($download['downloadlink']) and $download['downloadlink']!='') { - $app=OC_Installer::installApp(array('source'=>'http','href'=>$download['downloadlink'])); + $app=OC_Installer::installApp(array('source'=>'http', 'href'=>$download['downloadlink'])); } } } diff --git a/lib/archive/tar.php b/lib/archive/tar.php index 6e0629a0e1..0fa633c603 100644 --- a/lib/archive/tar.php +++ b/lib/archive/tar.php @@ -23,7 +23,7 @@ class OC_Archive_TAR extends OC_Archive{ private $path; function __construct($source) { - $types=array(null,'gz','bz'); + $types=array(null, 'gz', 'bz'); $this->path=$source; $this->tar=new Archive_Tar($source, $types[self::getTarType($source)]); } @@ -130,8 +130,7 @@ class OC_Archive_TAR extends OC_Archive{ if( $file == $header['filename'] or $file.'/' == $header['filename'] or '/'.$file.'/' == $header['filename'] - or '/'.$file == $header['filename']) - { + or '/'.$file == $header['filename']) { return $header; } } @@ -309,7 +308,7 @@ class OC_Archive_TAR extends OC_Archive{ if($mode=='r' or $mode=='rb') { return fopen($tmpFile, $mode); }else{ - OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); + OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack'); self::$tempFiles[$tmpFile]=$path; return fopen('close://'.$tmpFile, $mode); } @@ -334,7 +333,7 @@ class OC_Archive_TAR extends OC_Archive{ $this->tar->_close(); $this->tar=null; } - $types=array(null,'gz','bz'); + $types=array(null, 'gz', 'bz'); $this->tar=new Archive_Tar($this->path, $types[self::getTarType($this->path)]); } } diff --git a/lib/archive/zip.php b/lib/archive/zip.php index 5a6fc578be..1c967baa08 100644 --- a/lib/archive/zip.php +++ b/lib/archive/zip.php @@ -171,7 +171,7 @@ class OC_Archive_ZIP extends OC_Archive{ $ext=''; } $tmpFile=OCP\Files::tmpFile($ext); - OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack'); + OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this, 'writeBack'); if($this->fileExists($path)) { $this->extractFile($path, $tmpFile); } diff --git a/lib/backgroundjob.php b/lib/backgroundjob.php index 6415f5b84a..28b5ce3af2 100644 --- a/lib/backgroundjob.php +++ b/lib/backgroundjob.php @@ -40,11 +40,11 @@ class OC_BackgroundJob{ * @param $type execution type * @return boolean * - * This method sets the execution type of the background jobs. Possible types + * This method sets the execution type of the background jobs. Possible types * are "none", "ajax", "webcron", "cron" */ public static function setExecutionType( $type ) { - if( !in_array( $type, array('none', 'ajax', 'webcron', 'cron'))){ + if( !in_array( $type, array('none', 'ajax', 'webcron', 'cron'))) { return false; } return OC_Appconfig::setValue( 'core', 'backgroundjobs_mode', $type ); diff --git a/lib/base.php b/lib/base.php index 5c3d3fb80c..d4eeac82da 100644 --- a/lib/base.php +++ b/lib/base.php @@ -239,7 +239,7 @@ class OC{ } if(file_exists(OC::$SERVERROOT."/config/config.php") and !is_writable(OC::$SERVERROOT."/config/config.php")) { $tmpl = new OC_Template( '', 'error', 'guest' ); - $tmpl->assign('errors', array(1=>array('error'=>"Can't write into config directory 'config'",'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud"))); + $tmpl->assign('errors', array(1=>array('error'=>"Can't write into config directory 'config'", 'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud"))); $tmpl->printPage(); exit; } @@ -264,8 +264,6 @@ class OC{ OC_Util::addScript( "jquery-tipsy" ); OC_Util::addScript( "oc-dialogs" ); OC_Util::addScript( "js" ); - // request protection token MUST be defined after the jquery library but before any $('document').ready() - OC_Util::addScript( "requesttoken" ); OC_Util::addScript( "eventsource" ); OC_Util::addScript( "config" ); //OC_Util::addScript( "multiselect" ); @@ -322,7 +320,7 @@ class OC{ public static function init() { // register autoloader - spl_autoload_register(array('OC','autoload')); + spl_autoload_register(array('OC', 'autoload')); setlocale(LC_ALL, 'en_US.UTF-8'); // set some stuff @@ -440,7 +438,7 @@ class OC{ OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted'); //make sure temporary files are cleaned up - register_shutdown_function(array('OC_Helper','cleanTmp')); + register_shutdown_function(array('OC_Helper', 'cleanTmp')); //parse the given parameters self::$REQUESTEDAPP = (isset($_GET['app']) && trim($_GET['app']) != '' && !is_null($_GET['app'])?str_replace(array('\0', '/', '\\', '..'), '', strip_tags($_GET['app'])):OC_Config::getValue('defaultapp', 'files')); @@ -526,8 +524,7 @@ class OC{ } $file_ext = substr($param['file'], -3); if ($file_ext != 'php' - || !self::loadAppScriptFile($param)) - { + || !self::loadAppScriptFile($param)) { header('HTTP/1.0 404 Not Found'); } } @@ -597,8 +594,7 @@ class OC{ if(!isset($_COOKIE["oc_remember_login"]) || !isset($_COOKIE["oc_token"]) || !isset($_COOKIE["oc_username"]) - || !$_COOKIE["oc_remember_login"]) - { + || !$_COOKIE["oc_remember_login"]) { return false; } OC_App::loadApps(array('authentication')); @@ -623,9 +619,9 @@ class OC{ OC_Util::redirectToDefaultPage(); // doesn't return } - // if you reach this point you have changed your password + // if you reach this point you have changed your password // or you are an attacker - // we can not delete tokens here because users may reach + // we can not delete tokens here because users may reach // this point multiple times after a password change OC_Log::write('core', 'Authentication cookie rejected for user '.$_COOKIE['oc_username'], OC_Log::WARN); } @@ -669,7 +665,7 @@ class OC{ } OC_App::loadApps(array('authentication')); if (OC_User::login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"])) { - //OC_Log::write('core',"Logged in with HTTP Authentication",OC_Log::DEBUG); + //OC_Log::write('core',"Logged in with HTTP Authentication", OC_Log::DEBUG); OC_User::unsetMagicInCookie(); $_REQUEST['redirect_url'] = (isset($_SERVER['REQUEST_URI'])?$_SERVER['REQUEST_URI']:''); OC_Util::redirectToDefaultPage(); diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php index ed02840195..8d963a1cf8 100644 --- a/lib/connector/sabre/file.php +++ b/lib/connector/sabre/file.php @@ -57,7 +57,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D */ public function get() { - return OC_Filesystem::fopen($this->path,'rb'); + return OC_Filesystem::fopen($this->path, 'rb'); } diff --git a/lib/connector/sabre/locks.php b/lib/connector/sabre/locks.php index 55a8d5eaa6..a72d003bc7 100644 --- a/lib/connector/sabre/locks.php +++ b/lib/connector/sabre/locks.php @@ -102,7 +102,7 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract { * @param Sabre_DAV_Locks_LockInfo $lockInfo * @return bool */ - public function lock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) { + public function lock($uri, Sabre_DAV_Locks_LockInfo $lockInfo) { // We're making the lock timeout 5 minutes $lockInfo->timeout = 300; @@ -134,7 +134,7 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract { * @param Sabre_DAV_Locks_LockInfo $lockInfo * @return bool */ - public function unlock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) { + public function unlock($uri, Sabre_DAV_Locks_LockInfo $lockInfo) { $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*locks` WHERE `userid` = ? AND `uri` = ? AND `token` = ?' ); $result = $query->execute( array(OC_User::getUser(), $uri, $lockInfo->token)); diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index 291b87257f..5fc106b85e 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -85,7 +85,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr $this->path = $newPath; $query = OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertypath` = ? WHERE `userid` = ? AND `propertypath` = ?' ); - $query->execute( array( $newPath,OC_User::getUser(), $oldPath )); + $query->execute( array( $newPath, OC_User::getUser(), $oldPath )); } @@ -159,7 +159,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr $query->execute( array( OC_User::getUser(), $this->path, $propertyName, $propertyValue )); } else { $query = OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertyvalue` = ? WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?' ); - $query->execute( array( $propertyValue,OC_User::getUser(), $this->path, $propertyName )); + $query->execute( array( $propertyValue, OC_User::getUser(), $this->path, $propertyName )); } } } diff --git a/lib/connector/sabre/quotaplugin.php b/lib/connector/sabre/quotaplugin.php index 5b8ef94171..a56a65ad86 100644 --- a/lib/connector/sabre/quotaplugin.php +++ b/lib/connector/sabre/quotaplugin.php @@ -2,7 +2,7 @@ /** * This plugin check user quota and deny creating files when they exceeds the quota. - * + * * @copyright Copyright (C) 2012 entreCables S.L. All rights reserved. * @author Sergio Cambra * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License @@ -10,9 +10,9 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin { /** - * Reference to main server object - * - * @var Sabre_DAV_Server + * Reference to main server object + * + * @var Sabre_DAV_Server */ private $server; @@ -23,8 +23,8 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin { * addPlugin is called. * * This method should set up the requires event subscriptions. - * - * @param Sabre_DAV_Server $server + * + * @param Sabre_DAV_Server $server * @return void */ public function initialize(Sabre_DAV_Server $server) { @@ -37,10 +37,10 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin { /** * This method is called before any HTTP method and forces users to be authenticated - * + * * @param string $method * @throws Sabre_DAV_Exception - * @return bool + * @return bool */ public function checkQuota($uri, $data = null) { $expected = $this->server->httpRequest->getHeader('X-Expected-Entity-Length'); diff --git a/lib/db.php b/lib/db.php index e48eece1e5..48e0ec82da 100644 --- a/lib/db.php +++ b/lib/db.php @@ -324,7 +324,7 @@ class OC_DB { if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"
'; $entry .= 'Offending command was: '.htmlentities($query).'
'; - OC_Log::write('core', $entry,OC_Log::FATAL); + OC_Log::write('core', $entry, OC_Log::FATAL); error_log('DB error: '.$entry); die( $entry ); } @@ -334,7 +334,7 @@ class OC_DB { }catch(PDOException $e) { $entry = 'DB Error: "'.$e->getMessage().'"
'; $entry .= 'Offending command was: '.htmlentities($query).'
'; - OC_Log::write('core', $entry,OC_Log::FATAL); + OC_Log::write('core', $entry, OC_Log::FATAL); error_log('DB error: '.$entry); die( $entry ); } diff --git a/lib/filecache.php b/lib/filecache.php index d5f90d3023..6263e03fc6 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -61,7 +61,7 @@ class OC_FileCache{ * * $data is an assiciative array in the same format as returned by get */ - public static function put($path,$data, $root=false) { + public static function put($path, $data, $root=false) { if($root===false) { $root=OC_Filesystem::getRoot(); } @@ -120,7 +120,7 @@ class OC_FileCache{ private static function update($id, $data) { $arguments=array(); $queryParts=array(); - foreach(array('size','mtime','ctime','mimetype','encrypted','versioned','writable') as $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) { @@ -227,7 +227,7 @@ class OC_FileCache{ $where = '`name` LIKE ? AND `user`=?'; } $query=OC_DB::prepare('SELECT '.$select.' FROM `*PREFIX*fscache` WHERE '.$where); - $result=$query->execute(array("%$search%",OC_User::getUser())); + $result=$query->execute(array("%$search%", OC_User::getUser())); $names=array(); while($row=$result->fetchRow()) { if(!$returnData) { @@ -366,7 +366,7 @@ class OC_FileCache{ * @param int count (optional) * @param string root (optional) */ - public static function scan($path,$eventSource=false,&$count=0, $root=false) { + public static function scan($path, $eventSource=false,&$count=0, $root=false) { if($eventSource) { $eventSource->send('scanning', array('file'=>$path, 'count'=>$count)); } @@ -402,7 +402,7 @@ class OC_FileCache{ } OC_FileCache_Update::cleanFolder($path, $root); - self::increaseSize($path,$totalSize, $root); + self::increaseSize($path, $totalSize, $root); } /** @@ -448,7 +448,7 @@ class OC_FileCache{ * @return array of file paths * * $part1 and $part2 together form the complete mimetype. - * e.g. searchByMime('text','plain') + * e.g. searchByMime('text', 'plain') * * seccond mimetype part can be ommited * e.g. searchByMime('audio') @@ -500,7 +500,7 @@ class OC_FileCache{ * trigger an update for the cache by setting the mtimes to 0 * @param string $user (optional) */ - public static function triggerUpdate($user=''){ + public static function triggerUpdate($user='') { if($user) { $query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `mtime`=0 WHERE `user`=? AND `mimetype`="httpd/unix-directory"'); $query->execute(array($user)); diff --git a/lib/filecache/update.php b/lib/filecache/update.php index ecfa892744..bc403113e7 100644 --- a/lib/filecache/update.php +++ b/lib/filecache/update.php @@ -85,7 +85,7 @@ class OC_FileCache_Update{ $file=$path.'/'.$filename; $isDir=$view->is_dir($file); if(self::hasUpdated($file, $root, $isDir)) { - if($isDir){ + if($isDir) { self::updateFolder($file, $root); }elseif($root===false) {//filesystem hooks are only valid for the default root OC_Hook::emit('OC_Filesystem', 'post_write', array('path'=>$file)); @@ -165,7 +165,7 @@ class OC_FileCache_Update{ $mtime=$view->filemtime($path.'/'); $ctime=$view->filectime($path.'/'); $writable=$view->is_writable($path.'/'); - OC_FileCache::put($path, array('size'=>$size,'mtime'=>$mtime,'ctime'=>$ctime,'mimetype'=>$mimetype,'writable'=>$writable)); + OC_FileCache::put($path, array('size'=>$size,'mtime'=>$mtime,'ctime'=>$ctime,'mimetype'=>$mimetype, 'writable'=>$writable)); }else{ $count=0; OC_FileCache::scan($path, null, $count, $root); @@ -174,7 +174,7 @@ class OC_FileCache_Update{ }else{ $size=OC_FileCache::scanFile($path, $root); } - if($path !== '' and $path !== '/'){ + if($path !== '' and $path !== '/') { OC_FileCache::increaseSize(dirname($path), $size-$cachedSize, $root); } } @@ -200,7 +200,7 @@ class OC_FileCache_Update{ * @param string newPath * @param string root (optional) */ - public static function rename($oldPath,$newPath, $root=false) { + public static function rename($oldPath, $newPath, $root=false) { if(!OC_FileCache::inCache($oldPath, $root)) { return; } diff --git a/lib/fileproxy.php b/lib/fileproxy.php index 1ca799fb74..2f81bde64a 100644 --- a/lib/fileproxy.php +++ b/lib/fileproxy.php @@ -97,7 +97,7 @@ class OC_FileProxy{ return true; } - public static function runPostProxies($operation,$path, $result) { + public static function runPostProxies($operation, $path, $result) { if(!self::$enabled) { return $result; } diff --git a/lib/fileproxy/fileoperations.php b/lib/fileproxy/fileoperations.php index 23fb63fcfb..516629adae 100644 --- a/lib/fileproxy/fileoperations.php +++ b/lib/fileproxy/fileoperations.php @@ -28,7 +28,7 @@ class OC_FileProxy_FileOperations extends OC_FileProxy{ static $rootView; public function premkdir($path) { - if(!self::$rootView){ + if(!self::$rootView) { self::$rootView = new OC_FilesystemView(''); } return !self::$rootView->file_exists($path); diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php index 54bda5d864..46bc8dc16d 100644 --- a/lib/fileproxy/quota.php +++ b/lib/fileproxy/quota.php @@ -38,9 +38,9 @@ class OC_FileProxy_Quota extends OC_FileProxy{ if(in_array($user, $this->userQuota)) { return $this->userQuota[$user]; } - $userQuota=OC_Preferences::getValue($user,'files','quota','default'); + $userQuota=OC_Preferences::getValue($user, 'files', 'quota', 'default'); if($userQuota=='default') { - $userQuota=OC_AppConfig::getValue('files','default_quota','none'); + $userQuota=OC_AppConfig::getValue('files', 'default_quota', 'none'); } if($userQuota=='none') { $this->userQuota[$user]=0; @@ -93,7 +93,7 @@ class OC_FileProxy_Quota extends OC_FileProxy{ } public function preCopy($path1, $path2) { - if(!self::$rootView){ + if(!self::$rootView) { self::$rootView = new OC_FilesystemView(''); } return (self::$rootView->filesize($path1)<$this->getFreeSpace($path2) or $this->getFreeSpace($path2)==0); diff --git a/lib/files.php b/lib/files.php index 13bb127e86..5a14083c28 100644 --- a/lib/files.php +++ b/lib/files.php @@ -391,7 +391,7 @@ class OC_Files { */ static function pull($source, $token, $dir, $file) { $tmpfile=tempnam(get_temp_dir(), 'remoteCloudFile'); - $fp=fopen($tmpfile,'w+'); + $fp=fopen($tmpfile, 'w+'); $url=$source.="/files/pull.php?token=$token"; $ch=curl_init(); curl_setopt($ch, CURLOPT_URL, $url); diff --git a/lib/filestorage.php b/lib/filestorage.php index 7b3a15dd8c..dd65f4421b 100644 --- a/lib/filestorage.php +++ b/lib/filestorage.php @@ -48,7 +48,7 @@ abstract class OC_Filestorage{ abstract public function copy($path1, $path2); abstract public function fopen($path, $mode); abstract public function getMimeType($path); - abstract public function hash($type,$path, $raw = false); + abstract public function hash($type, $path, $raw = false); abstract public function free_space($path); abstract public function search($query); abstract public function touch($path, $mtime=null); diff --git a/lib/filestorage/common.php b/lib/filestorage/common.php index 3c06570d89..b97eb79d8d 100644 --- a/lib/filestorage/common.php +++ b/lib/filestorage/common.php @@ -204,7 +204,7 @@ 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); @@ -264,7 +264,7 @@ abstract class OC_Filestorage_Common extends OC_Filestorage { $files[]=$dir.'/'.$item; } if($this->is_dir($dir.'/'.$item)) { - $files=array_merge($files,$this->searchInDir($query, $dir.'/'.$item)); + $files=array_merge($files, $this->searchInDir($query, $dir.'/'.$item)); } } } diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php index 89e994120c..6fe45acf8c 100644 --- a/lib/filestorage/local.php +++ b/lib/filestorage/local.php @@ -6,7 +6,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ protected $datadir; public function __construct($arguments) { $this->datadir=$arguments['datadir']; - if(substr($this->datadir,-1)!=='/') { + if(substr($this->datadir, -1)!=='/') { $this->datadir.='/'; } } @@ -20,7 +20,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ return opendir($this->datadir.$path); } public function is_dir($path) { - if(substr($path,-1)=='/') { + if(substr($path, -1)=='/') { $path=substr($path, 0, -1); } return is_dir($this->datadir.$path); @@ -86,11 +86,11 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ } public function rename($path1, $path2) { if (!$this->isUpdatable($path1)) { - OC_Log::write('core','unable to rename, file is not writable : '.$path1,OC_Log::ERROR); + OC_Log::write('core', 'unable to rename, file is not writable : '.$path1, OC_Log::ERROR); return false; } if(! $this->file_exists($path1)) { - OC_Log::write('core','unable to rename, file does not exists : '.$path1,OC_Log::ERROR); + OC_Log::write('core', 'unable to rename, file does not exists : '.$path1, OC_Log::ERROR); return false; } @@ -103,7 +103,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ if(!$this->file_exists($path2)) { $this->mkdir($path2); } - $source=substr($path1, strrpos($path1,'/')+1); + $source=substr($path1, strrpos($path1, '/')+1); $path2.=$source; } return copy($this->datadir.$path1, $this->datadir.$path2); @@ -156,8 +156,8 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ return $return; } - public function hash($path,$type, $raw=false) { - return hash_file($type,$this->datadir.$path, $raw); + public function hash($path, $type, $raw=false) { + return hash_file($type, $this->datadir.$path, $raw); } public function free_space($path) { @@ -182,7 +182,7 @@ class OC_Filestorage_Local extends OC_Filestorage_Common{ $files[]=$dir.'/'.$item; } if(is_dir($this->datadir.$dir.'/'.$item)) { - $files=array_merge($files,$this->searchInDir($query, $dir.'/'.$item)); + $files=array_merge($files, $this->searchInDir($query, $dir.'/'.$item)); } } return $files; diff --git a/lib/filesystem.php b/lib/filesystem.php index 852290e62a..4635f8b4f3 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -35,10 +35,10 @@ * post_create(path) * delete(path, &run) * post_delete(path) - * rename(oldpath,newpath, &run) - * post_rename(oldpath,newpath) - * copy(oldpath,newpath, &run) (if the newpath doesn't exists yes, copy, create and write will be emited in that order) - * post_rename(oldpath,newpath) + * rename(oldpath, newpath, &run) + * post_rename(oldpath, newpath) + * copy(oldpath, newpath, &run) (if the newpath doesn't exists yes, copy, create and write will be emited in that order) + * post_rename(oldpath, newpath) * * the &run parameter can be set to false to prevent the operation from occuring */ @@ -209,48 +209,48 @@ class OC_Filesystem{ } static private function loadSystemMountPoints($user) { - if(is_file(OC::$SERVERROOT.'/config/mount.php')) { - $mountConfig=include OC::$SERVERROOT.'/config/mount.php'; - if(isset($mountConfig['global'])) { - foreach($mountConfig['global'] as $mountPoint=>$options) { - self::mount($options['class'], $options['options'], $mountPoint); - } - } - - if(isset($mountConfig['group'])) { - foreach($mountConfig['group'] as $group=>$mounts) { - if(OC_Group::inGroup($user, $group)) { - foreach($mounts as $mountPoint=>$options) { - $mountPoint=self::setUserVars($mountPoint, $user); - foreach($options as &$option) { - $option=self::setUserVars($option, $user); - } - self::mount($options['class'], $options['options'], $mountPoint); - } - } - } - } - - if(isset($mountConfig['user'])) { - foreach($mountConfig['user'] as $user=>$mounts) { - if($user==='all' or strtolower($user)===strtolower($user)) { - foreach($mounts as $mountPoint=>$options) { - $mountPoint=self::setUserVars($mountPoint, $user); - foreach($options as &$option) { - $option=self::setUserVars($option, $user); - } - self::mount($options['class'], $options['options'], $mountPoint); - } - } - } - } - - $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 - OC_FileCache::triggerUpdate(); - OC_Appconfig::setValue('files', 'mountconfigmtime', $mtime); - } + if(is_file(OC::$SERVERROOT.'/config/mount.php')) { + $mountConfig=include OC::$SERVERROOT.'/config/mount.php'; + if(isset($mountConfig['global'])) { + foreach($mountConfig['global'] as $mountPoint=>$options) { + self::mount($options['class'], $options['options'], $mountPoint); + } + } + + if(isset($mountConfig['group'])) { + foreach($mountConfig['group'] as $group=>$mounts) { + if(OC_Group::inGroup($user, $group)) { + foreach($mounts as $mountPoint=>$options) { + $mountPoint=self::setUserVars($mountPoint, $user); + foreach($options as &$option) { + $option=self::setUserVars($option, $user); + } + self::mount($options['class'], $options['options'], $mountPoint); + } + } + } + } + + if(isset($mountConfig['user'])) { + foreach($mountConfig['user'] as $user=>$mounts) { + if($user==='all' or strtolower($user)===strtolower($user)) { + foreach($mounts as $mountPoint=>$options) { + $mountPoint=self::setUserVars($mountPoint, $user); + foreach($options as &$option) { + $option=self::setUserVars($option, $user); + } + self::mount($options['class'], $options['options'], $mountPoint); + } + } + } + } + + $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 + OC_FileCache::triggerUpdate(); + OC_Appconfig::setValue('files', 'mountconfigmtime', $mtime); + } } } @@ -312,7 +312,7 @@ class OC_Filesystem{ return false; } }else{ - OC_Log::write('core','storage backend '.$class.' not found',OC_Log::ERROR); + OC_Log::write('core', 'storage backend '.$class.' not found', OC_Log::ERROR); return false; } } @@ -356,7 +356,7 @@ class OC_Filesystem{ if(substr($mountpoint, -1)!=='/') { $mountpoint=$mountpoint.'/'; } - self::$mounts[$mountpoint]=array('class'=>$class,'arguments'=>$arguments); + self::$mounts[$mountpoint]=array('class'=>$class, 'arguments'=>$arguments); } /** @@ -403,7 +403,7 @@ class OC_Filesystem{ if(strstr($path, '/../') || strrchr($path, '/') === '/..' ) { return false; } - if(self::isFileBlacklisted($path)){ + if(self::isFileBlacklisted($path)) { return false; } return true; @@ -425,7 +425,7 @@ class OC_Filesystem{ } } - static public function isFileBlacklisted($path){ + static public function isFileBlacklisted($path) { $blacklist = array('.htaccess'); $filename = strtolower(basename($path)); return in_array($filename, $blacklist); @@ -590,7 +590,7 @@ class OC_Filesystem{ $path=substr($path, 0, -1); } //remove duplicate slashes - while(strpos($path,'//')!==false) { + while(strpos($path, '//')!==false) { $path=str_replace('//', '/', $path); } //normalize unicode if possible diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 9a38601acf..936e1feb41 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -251,7 +251,7 @@ class OC_FilesystemView { return $this->basicOperation('filemtime', $path); } public function touch($path, $mtime=null) { - if(!is_null($mtime) and !is_numeric($mtime)){ + if(!is_null($mtime) and !is_numeric($mtime)) { $mtime = strtotime($mtime); } return $this->basicOperation('touch', $path, array('write'), $mtime); @@ -266,7 +266,7 @@ class OC_FilesystemView { $path = $this->getRelativePath($absolutePath); $exists = $this->file_exists($path); $run = true; - if( $this->fakeRoot==OC_Filesystem::getRoot() ){ + if( $this->fakeRoot==OC_Filesystem::getRoot() ) { if(!$exists) { OC_Hook::emit( OC_Filesystem::CLASSNAME, @@ -294,7 +294,7 @@ class OC_FilesystemView { $count=OC_Helper::streamCopy($data, $target); fclose($target); fclose($data); - if( $this->fakeRoot==OC_Filesystem::getRoot() ){ + if( $this->fakeRoot==OC_Filesystem::getRoot() ) { if(!$exists) { OC_Hook::emit( OC_Filesystem::CLASSNAME, @@ -337,7 +337,7 @@ class OC_FilesystemView { return false; } $run=true; - if( $this->fakeRoot==OC_Filesystem::getRoot() ){ + if( $this->fakeRoot==OC_Filesystem::getRoot() ) { OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename, array( @@ -362,7 +362,7 @@ class OC_FilesystemView { $storage1->unlink($this->getInternalPath($path1.$postFix1)); $result = $count>0; } - if( $this->fakeRoot==OC_Filesystem::getRoot() ){ + if( $this->fakeRoot==OC_Filesystem::getRoot() ) { OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_rename, @@ -389,7 +389,7 @@ class OC_FilesystemView { return false; } $run=true; - if( $this->fakeRoot==OC_Filesystem::getRoot() ){ + if( $this->fakeRoot==OC_Filesystem::getRoot() ) { OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_copy, @@ -433,7 +433,7 @@ class OC_FilesystemView { $target = $this->fopen($path2.$postFix2, 'w'); $result = OC_Helper::streamCopy($source, $target); } - if( $this->fakeRoot==OC_Filesystem::getRoot() ){ + if( $this->fakeRoot==OC_Filesystem::getRoot() ) { OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_copy, @@ -489,7 +489,7 @@ class OC_FilesystemView { $hooks[]='write'; break; default: - OC_Log::write('core', 'invalid mode ('.$mode.') for '.$path,OC_Log::ERROR); + OC_Log::write('core', 'invalid mode ('.$mode.') for '.$path, OC_Log::ERROR); } return $this->basicOperation('fopen', $path, $hooks, $mode); diff --git a/lib/helper.php b/lib/helper.php index 27e312eeb2..ed459dab62 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -475,16 +475,16 @@ class OC_Helper { $dirs = explode(PATH_SEPARATOR, $path); // WARNING : We have to check if open_basedir is enabled : $obd = ini_get('open_basedir'); - if($obd != "none"){ + if($obd != "none") { $obd_values = explode(PATH_SEPARATOR, $obd); - if(count($obd_values) > 0 and $obd_values[0]){ + if(count($obd_values) > 0 and $obd_values[0]) { // open_basedir is in effect ! // We need to check if the program is in one of these dirs : $dirs = $obd_values; } } - foreach($dirs as $dir){ - foreach($exts as $ext){ + foreach($dirs as $dir) { + foreach($exts as $ext) { if($check_fn("$dir/$name".$ext)) return true; } diff --git a/lib/image.php b/lib/image.php index 38acf00d9f..41cd908169 100644 --- a/lib/image.php +++ b/lib/image.php @@ -271,7 +271,7 @@ class OC_Image { return -1; } if(is_null($this->filepath) || !is_readable($this->filepath)) { - OC_Log::write('core','OC_Image->fixOrientation() No readable file path set.', OC_Log::DEBUG); + OC_Log::write('core', 'OC_Image->fixOrientation() No readable file path set.', OC_Log::DEBUG); return -1; } $exif = @exif_read_data($this->filepath, 'IFD0'); diff --git a/lib/installer.php b/lib/installer.php index 0c776d47d5..7dc8b0cef8 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -57,7 +57,7 @@ class OC_Installer{ */ public static function installApp( $data = array()) { if(!isset($data['source'])) { - OC_Log::write('core','No source specified when installing app',OC_Log::ERROR); + OC_Log::write('core', 'No source specified when installing app', OC_Log::ERROR); return false; } @@ -65,13 +65,13 @@ class OC_Installer{ if($data['source']=='http') { $path=OC_Helper::tmpFile(); if(!isset($data['href'])) { - OC_Log::write('core','No href specified when installing app from http',OC_Log::ERROR); + 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'])) { - OC_Log::write('core','No path specified when installing app from local file',OC_Log::ERROR); + OC_Log::write('core', 'No path specified when installing app from local file', OC_Log::ERROR); return false; } $path=$data['path']; @@ -86,7 +86,7 @@ class OC_Installer{ rename($path, $path.'.tgz'); $path.='.tgz'; }else{ - OC_Log::write('core','Archives of type '.$mime.' are not supported',OC_Log::ERROR); + OC_Log::write('core', 'Archives of type '.$mime.' are not supported', OC_Log::ERROR); return false; } @@ -248,7 +248,7 @@ class OC_Installer{ * -# including appinfo/upgrade.php * -# setting the installed version * - * upgrade.php can determine the current installed version of the app using "OC_Appconfig::getValue($appid,'installed_version')" + * upgrade.php can determine the current installed version of the app using "OC_Appconfig::getValue($appid, 'installed_version')" */ public static function upgradeApp( $data = array()) { // TODO: write function diff --git a/lib/json.php b/lib/json.php index be37f94ca6..204430411c 100644 --- a/lib/json.php +++ b/lib/json.php @@ -72,7 +72,7 @@ class OC_JSON{ public static function checkSubAdminUser() { self::checkLoggedIn(); self::verifyUser(); - 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(); diff --git a/lib/l10n.php b/lib/l10n.php index 996ace2f57..f172710e5d 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -167,7 +167,7 @@ class OC_L10N{ * */ public function tA($textArray) { - OC_Log::write('core', 'DEPRECATED: the method tA is deprecated and will be removed soon.',OC_Log::WARN); + 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) { $result[$key] = (string)$this->t($text); diff --git a/lib/log.php b/lib/log.php index 3fc1e3976a..e9cededa5c 100644 --- a/lib/log.php +++ b/lib/log.php @@ -41,23 +41,23 @@ class OC_Log { } //Fatal errors handler - public static function onShutdown(){ + public static function onShutdown() { $error = error_get_last(); if($error) { //ob_end_clean(); self::write('PHP', $error['message'] . ' at ' . $error['file'] . '#' . $error['line'], self::FATAL); } else { - return true; + return true; } } // Uncaught exception handler - public static function onException($exception){ + public static function onException($exception) { self::write('PHP', $exception->getMessage() . ' at ' . $exception->getFile() . '#' . $exception->getLine(), self::FATAL); } //Recoverable errors handler - public static function onError($number, $message, $file, $line){ + public static function onError($number, $message, $file, $line) { if (error_reporting() === 0) { return; } diff --git a/lib/log/owncloud.php b/lib/log/owncloud.php index d4644163ad..ec43208d83 100644 --- a/lib/log/owncloud.php +++ b/lib/log/owncloud.php @@ -44,9 +44,9 @@ class OC_Log_Owncloud { * @param int level */ public static function write($app, $message, $level) { - $minLevel=min(OC_Config::getValue( "loglevel", OC_Log::WARN ),OC_Log::ERROR); + $minLevel=min(OC_Config::getValue( "loglevel", OC_Log::WARN ), OC_Log::ERROR); if($level>=$minLevel) { - $entry=array('app'=>$app, 'message'=>$message, 'level'=>$level,'time'=>time()); + $entry=array('app'=>$app, 'message'=>$message, 'level'=>$level, 'time'=>time()); $fh=fopen(self::$logFile, 'a'); fwrite($fh, json_encode($entry)."\n"); fclose($fh); diff --git a/lib/mail.php b/lib/mail.php index a77ac58569..c78fcce88d 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -27,7 +27,7 @@ class OC_Mail { * @param string $fromname * @param bool $html */ - public static function send($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='',$bcc='') { + public static function send($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='', $bcc='') { $SMTPMODE = OC_Config::getValue( 'mail_smtpmode', 'sendmail' ); $SMTPHOST = OC_Config::getValue( 'mail_smtphost', '127.0.0.1' ); diff --git a/lib/migrate.php b/lib/migrate.php index 409d77a1a9..96f5a0001f 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -91,7 +91,7 @@ class OC_Migrate{ if( self::$exporttype == 'user' ) { // Check user exists self::$uid = is_null($uid) ? OC_User::getUser() : $uid; - if(!OC_User::userExists(self::$uid)){ + if(!OC_User::userExists(self::$uid)) { return json_encode( array( 'success' => false) ); } } @@ -611,11 +611,11 @@ class OC_Migrate{ if( file_exists( $db ) ) { // Connect to the db if(!self::connectDB( $db )) { - OC_Log::write('migration','Failed to connect to migration.db',OC_Log::ERROR); + OC_Log::write('migration', 'Failed to connect to migration.db', OC_Log::ERROR); return false; } } else { - OC_Log::write('migration','Migration.db not found at: '.$db, OC_Log::FATAL ); + OC_Log::write('migration', 'Migration.db not found at: '.$db, OC_Log::FATAL ); return false; } diff --git a/lib/migration/content.php b/lib/migration/content.php index ca102b03d8..00df62f0c7 100644 --- a/lib/migration/content.php +++ b/lib/migration/content.php @@ -53,7 +53,7 @@ class OC_Migration_Content{ if( !is_null( $this->db ) ) { // Get db path $db = $this->db->getDatabase(); - if(!in_array($db, $this->tmpfiles)){ + if(!in_array($db, $this->tmpfiles)) { $this->tmpfiles[] = $db; } } @@ -205,7 +205,7 @@ class OC_Migration_Content{ } closedir($dirhandle); } else { - OC_Log::write('admin_export',"Was not able to open directory: " . $dir,OC_Log::ERROR); + OC_Log::write('admin_export', "Was not able to open directory: " . $dir, OC_Log::ERROR); return false; } return true; diff --git a/lib/ocsclient.php b/lib/ocsclient.php index 2a36cbc123..b6b5ad8f0a 100644 --- a/lib/ocsclient.php +++ b/lib/ocsclient.php @@ -162,7 +162,7 @@ class OC_OCSClient{ $xml=OC_OCSClient::getOCSresponse($url); if($xml==false) { - OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL); + OC_Log::write('core', 'Unable to parse OCS content', OC_Log::FATAL); return null; } $data=simplexml_load_string($xml); @@ -200,7 +200,7 @@ class OC_OCSClient{ $xml=OC_OCSClient::getOCSresponse($url); if($xml==false) { - OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL); + OC_Log::write('core', 'Unable to parse OCS content', OC_Log::FATAL); return null; } $data=simplexml_load_string($xml); @@ -238,7 +238,7 @@ class OC_OCSClient{ $xml=OC_OCSClient::getOCSresponse($url); if($xml==false) { - OC_Log::write('core','Unable to parse knowledgebase content',OC_Log::FATAL); + OC_Log::write('core', 'Unable to parse knowledgebase content', OC_Log::FATAL); return null; } $data=simplexml_load_string($xml); diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php index 24a17836f7..601046fe69 100644 --- a/lib/public/backgroundjob.php +++ b/lib/public/backgroundjob.php @@ -62,7 +62,7 @@ class BackgroundJob { * @param $type execution type * @return boolean * - * This method sets the execution type of the background jobs. Possible types + * This method sets the execution type of the background jobs. Possible types * are "none", "ajax", "webcron", "cron" */ public static function setExecutionType( $type ) { diff --git a/lib/public/share.php b/lib/public/share.php index da1c061639..071304ec24 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -28,7 +28,7 @@ namespace OCP; /** * This class provides the ability for apps to share their content between users. * Apps must create a backend class that implements OCP\Share_Backend and register it with this class. -* +* * It provides the following hooks: * - post_shared */ diff --git a/lib/public/util.php b/lib/public/util.php index 6ce79715b6..7b5b1abbde 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -61,7 +61,7 @@ class Util { */ public static function sendMail( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html=0, $altbody='', $ccaddress='', $ccname='', $bcc='') { // call the internal mail class - \OC_MAIL::send( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html=0, $altbody='', $ccaddress='', $ccname='', $bcc=''); + \OC_MAIL::send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = ''); } /** diff --git a/lib/request.php b/lib/request.php index 87262d9862..287d20d1a5 100644 --- a/lib/request.php +++ b/lib/request.php @@ -63,7 +63,7 @@ class OC_Request { $path_info = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])); // following is taken from Sabre_DAV_URLUtil::decodePathSegment $path_info = rawurldecode($path_info); - $encoding = mb_detect_encoding($path_info, array('UTF-8','ISO-8859-1')); + $encoding = mb_detect_encoding($path_info, array('UTF-8', 'ISO-8859-1')); switch($encoding) { @@ -98,7 +98,7 @@ class OC_Request { $HTTP_ACCEPT_ENCODING = $_SERVER["HTTP_ACCEPT_ENCODING"]; if( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false ) return 'x-gzip'; - else if( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false ) + else if( strpos($HTTP_ACCEPT_ENCODING, 'gzip') !== false ) return 'gzip'; return false; } diff --git a/lib/route.php b/lib/route.php index d5233d7986..5901717c09 100644 --- a/lib/route.php +++ b/lib/route.php @@ -108,7 +108,7 @@ class OC_Route extends Route { public function actionInclude($file) { $function = create_function('$param', 'unset($param["_route"]);' - .'$_GET=array_merge($_GET,$param);' + .'$_GET=array_merge($_GET, $param);' .'unset($param);' .'require_once "'.$file.'";'); $this->action($function); diff --git a/lib/router.php b/lib/router.php index 7bbc546d75..8cb8fd4f33 100644 --- a/lib/router.php +++ b/lib/router.php @@ -34,7 +34,7 @@ class OC_Router { public function getRoutingFiles() { if (!isset($this->routing_files)) { $this->routing_files = array(); - foreach(OC_APP::getEnabledApps() as $app){ + foreach(OC_APP::getEnabledApps() as $app) { $file = OC_App::getAppPath($app).'/appinfo/routes.php'; if(file_exists($file)) { $this->routing_files[$app] = $file; diff --git a/lib/search.php b/lib/search.php index 2629c5e2fb..3c3378ad13 100644 --- a/lib/search.php +++ b/lib/search.php @@ -41,7 +41,7 @@ class OC_Search{ * @param string $provider class name of a OC_Search_Provider */ public static function registerProvider($class, $options=array()) { - self::$registeredProviders[]=array('class'=>$class,'options'=>$options); + self::$registeredProviders[]=array('class'=>$class, 'options'=>$options); } /** diff --git a/lib/setup.php b/lib/setup.php index d0620f814a..726b3352d5 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -70,7 +70,7 @@ class OC_Setup { if(empty($options['dbname'])) { $error[] = "$dbprettyname enter the database name."; } - if(substr_count($options['dbname'], '.') >= 1){ + if(substr_count($options['dbname'], '.') >= 1) { $error[] = "$dbprettyname you may not use dots in the database name"; } if($dbtype != 'oci' && empty($options['dbhost'])) { @@ -95,7 +95,7 @@ class OC_Setup { //write the config file OC_Config::setValue('datadirectory', $datadir); OC_Config::setValue('dbtype', $dbtype); - OC_Config::setValue('version', implode('.',OC_Util::getVersion())); + OC_Config::setValue('version', implode('.', OC_Util::getVersion())); if($dbtype == 'mysql') { $dbuser = $options['dbuser']; $dbpass = $options['dbpass']; diff --git a/lib/streamwrappers.php b/lib/streamwrappers.php index b5ea0a2b2e..981c280f0d 100644 --- a/lib/streamwrappers.php +++ b/lib/streamwrappers.php @@ -234,7 +234,7 @@ class OC_CloseStreamWrapper{ } public function stream_seek($offset, $whence=SEEK_SET) { - fseek($this->source,$offset, $whence); + fseek($this->source, $offset, $whence); } public function stream_tell() { @@ -249,16 +249,16 @@ class OC_CloseStreamWrapper{ return fwrite($this->source, $data); } - public function stream_set_option($option,$arg1, $arg2) { + public function stream_set_option($option, $arg1, $arg2) { switch($option) { case STREAM_OPTION_BLOCKING: stream_set_blocking($this->source, $arg1); break; case STREAM_OPTION_READ_TIMEOUT: - stream_set_timeout($this->source,$arg1, $arg2); + stream_set_timeout($this->source, $arg1, $arg2); break; case STREAM_OPTION_WRITE_BUFFER: - stream_set_write_buffer($this->source,$arg1, $arg2); + stream_set_write_buffer($this->source, $arg1, $arg2); } } diff --git a/lib/template.php b/lib/template.php index ed2481afba..3d3589abd1 100644 --- a/lib/template.php +++ b/lib/template.php @@ -25,7 +25,7 @@ * Prints an XSS escaped string * @param string $string the string which will be escaped and printed */ -function p($string){ +function p($string) { print(OC_Util::sanitizeHTML($string)); } @@ -33,7 +33,7 @@ function p($string){ * Prints an unescaped string * @param string $string the string which will be printed as it is */ -function print_unescaped($string){ +function print_unescaped($string) { print($string); } @@ -172,7 +172,6 @@ class OC_Template{ $this->application = $app; $this->vars = array(); $this->vars['requesttoken'] = OC_Util::callRegister(); - $this->vars['requestlifespan'] = OC_Util::$callLifespan; $parts = explode('/', $app); // fix translation when app is something like core/lostpassword $this->l10n = OC_L10N::get($parts[0]); @@ -196,11 +195,11 @@ class OC_Template{ public static function detectFormfactor() { // please add more useragent strings for other devices if(isset($_SERVER['HTTP_USER_AGENT'])) { - if(stripos($_SERVER['HTTP_USER_AGENT'],'ipad')>0) { + 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'; @@ -357,7 +356,7 @@ class OC_Template{ * @param string $text the text content for the element */ public function addHeader( $tag, $attributes, $text='') { - $this->headers[]=array('tag'=>$tag,'attributes'=>$attributes,'text'=>$text); + $this->headers[]=array('tag'=>$tag,'attributes'=>$attributes, 'text'=>$text); } /** @@ -391,7 +390,6 @@ class OC_Template{ $page = new OC_TemplateLayout($this->renderas); if($this->renderas == 'user') { $page->assign('requesttoken', $this->vars['requesttoken']); - $page->assign('requestlifespan', $this->vars['requestlifespan']); } // Add custom headers diff --git a/lib/templatelayout.php b/lib/templatelayout.php index c3da172a7c..1a0570a270 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -12,10 +12,10 @@ class OC_TemplateLayout extends OC_Template { if( $renderas == 'user' ) { parent::__construct( 'core', 'layout.user' ); - if(in_array(OC_APP::getCurrentApp(), array('settings','admin','help'))!==false) { - $this->assign('bodyid','body-settings', false); + if(in_array(OC_APP::getCurrentApp(), array('settings','admin', 'help'))!==false) { + $this->assign('bodyid', 'body-settings', false); }else{ - $this->assign('bodyid','body-user', false); + $this->assign('bodyid', 'body-user', false); } // Add navigation entry diff --git a/lib/updater.php b/lib/updater.php index 7d5ec4ffe9..11081eded6 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -30,7 +30,7 @@ class OC_Updater{ */ public static function check() { OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true)); - if(OC_Appconfig::getValue('core', 'installedat','')=='') OC_Appconfig::setValue('core', 'installedat', microtime(true)); + if(OC_Appconfig::getValue('core', 'installedat', '')=='') OC_Appconfig::setValue('core', 'installedat', microtime(true)); $updaterurl='http://apps.owncloud.com/updater.php'; $version=OC_Util::getVersion(); diff --git a/lib/user.php b/lib/user.php index 126f2aa3da..801ab7f608 100644 --- a/lib/user.php +++ b/lib/user.php @@ -133,7 +133,7 @@ class OC_User { self::useBackend($backend); $_setupedBackends[]=$i; }else{ - OC_Log::write('core','User backend '.$class.' not found.',OC_Log::ERROR); + OC_Log::write('core', 'User backend '.$class.' not found.', OC_Log::ERROR); } } } diff --git a/lib/user/database.php b/lib/user/database.php index f39c19829e..f33e338e2e 100644 --- a/lib/user/database.php +++ b/lib/user/database.php @@ -155,7 +155,7 @@ class OC_User_Database extends OC_User_Backend { * Get a list of all users. */ public function getUsers($search = '', $limit = null, $offset = null) { - $query = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users` WHERE LOWER(`uid`) LIKE LOWER(?)',$limit, $offset); + $query = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users` WHERE LOWER(`uid`) LIKE LOWER(?)', $limit, $offset); $result = $query->execute(array($search.'%')); $users = array(); while ($row = $result->fetchRow()) { diff --git a/lib/user/http.php b/lib/user/http.php index ea055b6982..944ede73a0 100644 --- a/lib/user/http.php +++ b/lib/user/http.php @@ -50,7 +50,7 @@ class OC_User_HTTP extends OC_User_Backend { * @return boolean */ private function matchUrl($url) { - return ! is_null(parse_url($url,PHP_URL_USER)); + return ! is_null(parse_url($url, PHP_URL_USER)); } /** diff --git a/lib/util.php b/lib/util.php index a9bc5c061c..40b44bf9d6 100755 --- a/lib/util.php +++ b/lib/util.php @@ -95,7 +95,7 @@ class OC_Util { */ public static function getVersion() { // hint: We only can count up. So the internal version number of ownCloud 4.5 will be 4.90.0. This is not visible to the user - return array(4,91, 00); + return array(4, 91, 00); } /** @@ -157,7 +157,7 @@ class OC_Util { * @param string $text the text content for the element */ public static function addHeader( $tag, $attributes, $text='') { - self::$headers[]=array('tag'=>$tag,'attributes'=>$attributes,'text'=>$text); + self::$headers[]=array('tag'=>$tag,'attributes'=>$attributes, 'text'=>$text); } /** @@ -186,7 +186,7 @@ class OC_Util { * @param string $url * @return OC_Template */ - public static function getPageNavi($pagecount,$page, $url) { + public static function getPageNavi($pagecount, $page, $url) { $pagelinkcount=8; if ($pagecount>1) { @@ -217,7 +217,7 @@ class OC_Util { $web_server_restart= false; //check for database drivers 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.
','hint'=>'');//TODO: sane hint + $errors[]=array('error'=>'No database drivers (sqlite, mysql, or postgresql) installed.
', 'hint'=>'');//TODO: sane hint $web_server_restart= true; } @@ -226,13 +226,13 @@ class OC_Util { // Check if config folder is writable. if(!is_writable(OC::$SERVERROOT."/config/") or !is_readable(OC::$SERVERROOT."/config/")) { - $errors[]=array('error'=>"Can't write into config directory 'config'",'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud"); + $errors[]=array('error'=>"Can't write into config directory 'config'", 'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud"); } // Check if there is a writable install folder. if(OC_Config::getValue('appstoreenabled', true)) { if( OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath()) || !is_readable(OC_App::getInstallPath()) ) { - $errors[]=array('error'=>"Can't write into apps directory",'hint'=>"You can usually fix this by giving the webserver user write access to the apps directory + $errors[]=array('error'=>"Can't write into apps directory", 'hint'=>"You can usually fix this by giving the webserver user write access to the apps directory in owncloud or disabling the appstore in the config file."); } } @@ -269,57 +269,57 @@ class OC_Util { 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' "); + $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) or !is_readable($CONFIG_DATADIRECTORY)) { - $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') not writable by ownCloud
','hint'=>$permissionsHint); + $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') not writable by ownCloud
', 'hint'=>$permissionsHint); } // check if all required php modules are present if(!class_exists('ZipArchive')) { - $errors[]=array('error'=>'PHP module zip not installed.
','hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module zip not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('mb_detect_encoding')) { - $errors[]=array('error'=>'PHP module mb multibyte not installed.
','hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module mb multibyte not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('ctype_digit')) { - $errors[]=array('error'=>'PHP module ctype is not installed.
','hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module ctype is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('json_encode')) { - $errors[]=array('error'=>'PHP module JSON is not installed.
','hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module JSON is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('imagepng')) { - $errors[]=array('error'=>'PHP module GD is not installed.
','hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module GD is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('gzencode')) { - $errors[]=array('error'=>'PHP module zlib is not installed.
','hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module zlib is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('iconv')) { - $errors[]=array('error'=>'PHP module iconv is not installed.
','hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module iconv is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('simplexml_load_string')) { - $errors[]=array('error'=>'PHP module SimpleXML is not installed.
','hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module SimpleXML is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(floatval(phpversion())<5.3) { - $errors[]=array('error'=>'PHP 5.3 is required.
','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.'); + $errors[]=array('error'=>'PHP 5.3 is required.
', '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.'); $web_server_restart= false; } if(!defined('PDO::ATTR_DRIVER_NAME')) { - $errors[]=array('error'=>'PHP PDO module is not installed.
','hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP PDO module is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if($web_server_restart) { - $errors[]=array('error'=>'PHP modules have been installed, but they are still listed as missing?
','hint'=>'Please ask your server administrator to restart the web server.'); + $errors[]=array('error'=>'PHP modules have been installed, but they are still listed as missing?
', 'hint'=>'Please ask your server administrator to restart the web server.'); } return $errors; @@ -472,17 +472,6 @@ class OC_Util { return $id; } - /** - * @brief Static lifespan (in seconds) when a request token expires. - * @see OC_Util::callRegister() - * @see OC_Util::isCallRegistered() - * @description - * Also required for the client side to compute the piont in time when to - * request a fresh token. The client will do so when nearly 97% of the - * timespan coded here has expired. - */ - public static $callLifespan = 3600; // 3600 secs = 1 hour - /** * @brief Register an get/post call. Important to prevent CSRF attacks. * @todo Write howto: CSRF protection guide @@ -491,30 +480,24 @@ class OC_Util { * Creates a 'request token' (random) and stores it inside the session. * Ever subsequent (ajax) request must use such a valid token to succeed, * otherwise the request will be denied as a protection against CSRF. - * The tokens expire after a fixed lifespan. - * @see OC_Util::$callLifespan * @see OC_Util::isCallRegistered() */ public static function callRegister() { // Check if a token exists - if(!isset($_SESSION['requesttoken']) || time() >$_SESSION['requesttoken']['time']) { + if(!isset($_SESSION['requesttoken'])) { // No valid token found, generate a new one. - $requestTokenArray = array( - "requesttoken" => self::generate_random_bytes(20), - "time" => time()+self::$callLifespan, - ); - $_SESSION['requesttoken']=$requestTokenArray; + $requestToken = self::generate_random_bytes(20); + $_SESSION['requesttoken']=$requestToken; } else { // Valid token already exists, send it - $requestTokenArray = $_SESSION['requesttoken']; + $requestToken = $_SESSION['requesttoken']; } - return($requestTokenArray['requesttoken']); + return($requestToken); } /** * @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. - * @see OC_Util::$callLifespan * @see OC_Util::callRegister() */ public static function isCallRegistered() { @@ -530,7 +513,7 @@ class OC_Util { } // Check if the token is valid - if(!isset($_SESSION['requesttoken']) || time() > $_SESSION['requesttoken']["time"]) { + if($token !== $_SESSION['requesttoken']) { // Not valid return false; } else { @@ -576,7 +559,7 @@ class OC_Util { // creating a test file $testfile = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ).'/'.$filename; - if(file_exists($testfile)){// already running this test, possible recursive call + if(file_exists($testfile)) {// already running this test, possible recursive call return false; } diff --git a/lib/vcategories.php b/lib/vcategories.php index 7032afd5fd..bae9e3d039 100644 --- a/lib/vcategories.php +++ b/lib/vcategories.php @@ -661,6 +661,7 @@ class OC_VCategories { if(!is_array($names)) { $names = array($names); } + OC_Log::write('core', __METHOD__ . ', before: ' . print_r($this->categories, true), OC_Log::DEBUG); foreach($names as $name) { @@ -724,6 +725,7 @@ class OC_VCategories { unset($categories[$this->array_searchi($name, $categories)]); } } + $object->setString('CATEGORIES', implode(',', $categories)); if($vobject !== $object) { $vobject[$componentname] = $object; diff --git a/ocs/providers.php b/ocs/providers.php index 4c68ded914..43c9dc2aa4 100644 --- a/ocs/providers.php +++ b/ocs/providers.php @@ -3,22 +3,22 @@ /** * ownCloud * -* @author Frank Karlitschek -* @copyright 2012 Frank Karlitschek frank@owncloud.org -* +* @author Frank Karlitschek +* @copyright 2012 Frank Karlitschek frank@owncloud.org +* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either +* License as published by the Free Software Foundation; either * version 3 of the License, or any later version. -* +* * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public +* +* You should have received a copy of the GNU Affero General Public * License along with this library. If not, see . -* +* */ require_once '../lib/base.php'; diff --git a/ocs/v1.php b/ocs/v1.php index b12ea5ef18..1652b0bedb 100644 --- a/ocs/v1.php +++ b/ocs/v1.php @@ -3,22 +3,22 @@ /** * ownCloud * -* @author Frank Karlitschek -* @copyright 2012 Frank Karlitschek frank@owncloud.org -* +* @author Frank Karlitschek +* @copyright 2012 Frank Karlitschek frank@owncloud.org +* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either +* License as published by the Free Software Foundation; either * version 3 of the License, or any later version. -* +* * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public +* +* You should have received a copy of the GNU Affero General Public * License along with this library. If not, see . -* +* */ require_once '../lib/base.php'; diff --git a/settings/admin.php b/settings/admin.php index 7ce0ee0d6f..c704704ed3 100755 --- a/settings/admin.php +++ b/settings/admin.php @@ -25,7 +25,7 @@ function compareEntries($a, $b) { } usort($entries, 'compareEntries'); -$tmpl->assign('loglevel',OC_Config::getValue( "loglevel", 2 )); +$tmpl->assign('loglevel', OC_Config::getValue( "loglevel", 2 )); $tmpl->assign('entries', $entries); $tmpl->assign('entriesremain', $entriesremain); $tmpl->assign('htaccessworking', $htaccessworking); diff --git a/settings/ajax/changepassword.php b/settings/ajax/changepassword.php index a0fe5947b6..b2db261151 100644 --- a/settings/ajax/changepassword.php +++ b/settings/ajax/changepassword.php @@ -16,8 +16,7 @@ if(OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) { $userstatus = 'subadmin'; } if(OC_User::getUser() === $username) { - if (OC_User::checkPassword($username, $oldPassword)) - { + if (OC_User::checkPassword($username, $oldPassword)) { $userstatus = 'user'; } else { if (!OC_Util::isUserVerified()) { diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php index c87ff422f6..16b48c8a9c 100644 --- a/settings/ajax/createuser.php +++ b/settings/ajax/createuser.php @@ -43,9 +43,9 @@ try { } OC_Group::addToGroup( $username, $i ); } - OC_JSON::success(array("data" => - array( - "username" => $username, + OC_JSON::success(array("data" => + array( + "username" => $username, "groups" => implode( ", ", OC_Group::getUserGroups( $username ))))); } catch (Exception $exception) { OC_JSON::error(array("data" => array( "message" => $exception->getMessage()))); diff --git a/settings/ajax/getlog.php b/settings/ajax/getlog.php index 273b02e382..043124fa17 100644 --- a/settings/ajax/getlog.php +++ b/settings/ajax/getlog.php @@ -12,5 +12,5 @@ $offset=(isset($_GET['offset']))?$_GET['offset']:0; $entries=OC_Log_Owncloud::getEntries($count, $offset); OC_JSON::success(array( - "data" => OC_Util::sanitizeHTML($entries), + "data" => OC_Util::sanitizeHTML($entries), "remain"=>(count(OC_Log_Owncloud::getEntries(1, $offset + $offset)) != 0) ? true : false)); diff --git a/settings/ajax/setquota.php b/settings/ajax/setquota.php index 4b32585b30..845f8ea408 100644 --- a/settings/ajax/setquota.php +++ b/settings/ajax/setquota.php @@ -36,5 +36,5 @@ if($username) { } OC_Appconfig::setValue('files', 'default_quota', $quota); } -OC_JSON::success(array("data" => array( "username" => $username ,'quota' => $quota))); +OC_JSON::success(array("data" => array( "username" => $username , 'quota' => $quota))); diff --git a/settings/ajax/userlist.php b/settings/ajax/userlist.php index 61b1a388fc..eaeade60a3 100644 --- a/settings/ajax/userlist.php +++ b/settings/ajax/userlist.php @@ -32,9 +32,9 @@ if (OC_Group::inGroup(OC_User::getUser(), 'admin')) { $batch = OC_User::getUsers('', 10, $offset); foreach ($batch as $user) { $users[] = array( - 'name' => $user, - 'groups' => join(', ', OC_Group::getUserGroups($user)), - 'subadmin' => join(', ', OC_SubAdmin::getSubAdminsGroups($user)), + 'name' => $user, + 'groups' => join(', ', OC_Group::getUserGroups($user)), + 'subadmin' => join(', ', OC_SubAdmin::getSubAdminsGroups($user)), 'quota' => OC_Preferences::getValue($user, 'files', 'quota', 'default')); } } else { @@ -42,8 +42,8 @@ if (OC_Group::inGroup(OC_User::getUser(), 'admin')) { $batch = OC_Group::usersInGroups($groups, '', 10, $offset); foreach ($batch as $user) { $users[] = array( - 'name' => $user, - 'groups' => join(', ', OC_Group::getUserGroups($user)), + 'name' => $user, + 'groups' => join(', ', OC_Group::getUserGroups($user)), 'quota' => OC_Preferences::getValue($user, 'files', 'quota', 'default')); } } diff --git a/settings/apps.php b/settings/apps.php index 8134b44143..155291333f 100644 --- a/settings/apps.php +++ b/settings/apps.php @@ -95,11 +95,11 @@ if ( $remoteApps ) { foreach ( $remoteApps AS $key => $remote ) { - if ( + if ( $app['name'] == $remote['name'] - // To set duplicate detection to use OCS ID instead of string name, - // enable this code, remove the line of code above, - // and add [ID] to info.xml of each 3rd party app: + // To set duplicate detection to use OCS ID instead of string name, + // enable this code, remove the line of code above, + // and add [ID] to info.xml of each 3rd party app: // OR $app['ocs_id'] == $remote['ocs_id'] ) { diff --git a/settings/languageCodes.php b/settings/languageCodes.php index 221aa13cf6..7165580085 100644 --- a/settings/languageCodes.php +++ b/settings/languageCodes.php @@ -3,7 +3,7 @@ * This file is licensed under the Affero General Public License version 3 or later. * See the COPYING-README file. */ - + return array( 'bg_BG'=>'български език', 'ca'=>'Català', diff --git a/settings/personal.php b/settings/personal.php index f28ab2ae75..47dbcc53eb 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -40,11 +40,11 @@ $languages=array(); 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__')); + $languages[]=array('code'=>$lang, 'name'=>$l->t('__language_name__')); }elseif(isset($languageNames[$lang])) { - $languages[]=array('code'=>$lang,'name'=>$languageNames[$lang]); + $languages[]=array('code'=>$lang, 'name'=>$languageNames[$lang]); }else{//fallback to language code - $languages[]=array('code'=>$lang,'name'=>$lang); + $languages[]=array('code'=>$lang, 'name'=>$lang); } } diff --git a/settings/templates/admin.php b/settings/templates/admin.php index 35f34489fe..300d6093d6 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -3,7 +3,7 @@ * This file is licensed under the Affero General Public License version 3 or later. * See the COPYING-README file. */ -$levels=array('Debug','Info','Warning','Error','Fatal'); +$levels=array('Debug','Info','Warning','Error', 'Fatal'); ?> printPage(); } ?> diff --git a/settings/templates/users.php b/settings/templates/users.php index eef9b29135..de7e50da8f 100644 --- a/settings/templates/users.php +++ b/settings/templates/users.php @@ -142,7 +142,7 @@ var isadmin = ; - + diff --git a/settings/users.php b/settings/users.php index 6eaae47453..93a259f1cd 100644 --- a/settings/users.php +++ b/settings/users.php @@ -31,7 +31,7 @@ if($isadmin) { foreach($accessibleusers as $i) { $users[] = array( - "name" => $i, + "name" => $i, "groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($i)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/), 'quota'=>OC_Preferences::getValue($i, 'files', 'quota', 'default'), 'subadmin'=>implode(', ', OC_SubAdmin::getSubAdminsGroups($i))); @@ -42,7 +42,7 @@ foreach( $accessiblegroups as $i ) { $groups[] = array( "name" => $i ); } $quotaPreset=OC_Appconfig::getValue('files', 'quota_preset', 'default,none,1 GB, 5 GB, 10 GB'); -$quotaPreset=explode(',',$quotaPreset); +$quotaPreset=explode(',', $quotaPreset); foreach($quotaPreset as &$preset) { $preset=trim($preset); } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f8364b71ef..4080a974be 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,25 +2,25 @@ require_once __DIR__.'/../lib/base.php'; -if(!class_exists('PHPUnit_Framework_TestCase')){ +if(!class_exists('PHPUnit_Framework_TestCase')) { require_once('PHPUnit/Autoload.php'); } //SimpleTest compatibility abstract class UnitTestCase extends PHPUnit_Framework_TestCase{ - function assertEqual($expected, $actual, $string=''){ + function assertEqual($expected, $actual, $string='') { $this->assertEquals($expected, $actual, $string); } - function assertNotEqual($expected, $actual, $string=''){ + function assertNotEqual($expected, $actual, $string='') { $this->assertNotEquals($expected, $actual, $string); } - static function assertTrue($actual, $string=''){ + static function assertTrue($actual, $string='') { parent::assertTrue((bool)$actual, $string); } - static function assertFalse($actual, $string=''){ + static function assertFalse($actual, $string='') { parent::assertFalse((bool)$actual, $string); } } diff --git a/tests/lib/archive.php b/tests/lib/archive.php index 408dc2bbae..cd2ca6630a 100644 --- a/tests/lib/archive.php +++ b/tests/lib/archive.php @@ -26,16 +26,16 @@ abstract class Test_Archive extends UnitTestCase { 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'); + $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) { $this->assertContains($file, $allFiles, 'cant find '. $file . ' in archive'); - $this->assertTrue($this->instance->fileExists($file),'file '.$file.' does not exist in archive'); + $this->assertTrue($this->instance->fileExists($file), 'file '.$file.' does not exist in archive'); } $this->assertFalse($this->instance->fileExists('non/existing/file')); $rootContent=$this->instance->getFolder(''); - $expected=array('lorem.txt','logo-wide.png','dir/'); + $expected=array('lorem.txt','logo-wide.png', 'dir/'); $this->assertEqual(3, count($rootContent)); foreach($expected as $file) { $this->assertContains($file, $rootContent, 'cant find '. $file . ' in archive'); @@ -71,14 +71,14 @@ abstract class Test_Archive extends UnitTestCase { $this->assertFalse($this->instance->fileExists('lorem.txt/')); $this->assertEqual(file_get_contents($textFile), $this->instance->getFile('lorem.txt')); - $this->instance->addFile('lorem.txt','foobar'); + $this->instance->addFile('lorem.txt', 'foobar'); $this->assertEqual('foobar', $this->instance->getFile('lorem.txt')); } public function testReadStream() { $dir=OC::$SERVERROOT.'/tests/data'; $this->instance=$this->getExisting(); - $fh=$this->instance->getStream('lorem.txt','r'); + $fh=$this->instance->getStream('lorem.txt', 'r'); $this->assertTrue($fh); $content=fread($fh, $this->instance->filesize('lorem.txt')); fclose($fh); @@ -87,8 +87,8 @@ abstract class Test_Archive extends UnitTestCase { public function testWriteStream() { $dir=OC::$SERVERROOT.'/tests/data'; $this->instance=$this->getNew(); - $fh=$this->instance->getStream('lorem.txt','w'); - $source=fopen($dir.'/lorem.txt','r'); + $fh=$this->instance->getStream('lorem.txt', 'w'); + $source=fopen($dir.'/lorem.txt', 'r'); OCP\Files::streamCopy($source, $fh); fclose($source); fclose($fh); @@ -123,7 +123,7 @@ abstract class Test_Archive extends UnitTestCase { $this->instance=$this->getNew(); $this->instance->addFile('lorem.txt', $textFile); $this->assertFalse($this->instance->fileExists('target.txt')); - $this->instance->rename('lorem.txt','target.txt'); + $this->instance->rename('lorem.txt', 'target.txt'); $this->assertTrue($this->instance->fileExists('target.txt')); $this->assertFalse($this->instance->fileExists('lorem.txt')); $this->assertEqual(file_get_contents($textFile), $this->instance->getFile('target.txt')); diff --git a/tests/lib/cache.php b/tests/lib/cache.php index 7f3eb3ee6f..1a1287ff13 100644 --- a/tests/lib/cache.php +++ b/tests/lib/cache.php @@ -13,7 +13,7 @@ abstract class Test_Cache extends UnitTestCase { protected $instance; public function tearDown() { - if($this->instance){ + if($this->instance) { $this->instance->clear(); } } @@ -26,22 +26,22 @@ abstract class Test_Cache extends UnitTestCase { $this->instance->set('value1', $value); $this->assertTrue($this->instance->hasKey('value1')); $received=$this->instance->get('value1'); - $this->assertEqual($value, $received,'Value recieved from cache not equal to the original'); + $this->assertEqual($value, $received, 'Value recieved from cache not equal to the original'); $value='ipsum lorum'; $this->instance->set('value1', $value); $received=$this->instance->get('value1'); - $this->assertEqual($value, $received,'Value not overwritten by second set'); + $this->assertEqual($value, $received, 'Value not overwritten by second set'); $value2='foobar'; $this->instance->set('value2', $value2); $received2=$this->instance->get('value2'); $this->assertTrue($this->instance->hasKey('value1')); $this->assertTrue($this->instance->hasKey('value2')); - $this->assertEqual($value, $received,'Value changed while setting other variable'); - $this->assertEqual($value2, $received2,'Second value not equal to original'); + $this->assertEqual($value, $received, 'Value changed while setting other variable'); + $this->assertEqual($value2, $received2, 'Second value not equal to original'); $this->assertFalse($this->instance->hasKey('not_set')); - $this->assertNull($this->instance->get('not_set'),'Unset value not equal to null'); + $this->assertNull($this->instance->get('not_set'), 'Unset value not equal to null'); $this->assertTrue($this->instance->remove('value1')); $this->assertFalse($this->instance->hasKey('value1')); diff --git a/tests/lib/cache/apc.php b/tests/lib/cache/apc.php index f68b97bcbd..bb5eb483db 100644 --- a/tests/lib/cache/apc.php +++ b/tests/lib/cache/apc.php @@ -22,11 +22,11 @@ class Test_Cache_APC extends Test_Cache { public function setUp() { - if(!extension_loaded('apc')){ + if(!extension_loaded('apc')) { $this->markTestSkipped('The apc extension is not available.'); return; } - if(!ini_get('apc.enable_cli') && OC::$CLI){ + if(!ini_get('apc.enable_cli') && OC::$CLI) { $this->markTestSkipped('apc not available in CLI.'); return; } diff --git a/tests/lib/cache/file.php b/tests/lib/cache/file.php index 47b18e5b9f..d64627198e 100644 --- a/tests/lib/cache/file.php +++ b/tests/lib/cache/file.php @@ -39,7 +39,7 @@ class Test_Cache_File extends Test_Cache { //set up temporary storage OC_Filesystem::clearMounts(); - OC_Filesystem::mount('OC_Filestorage_Temporary', array(),'/'); + OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/'); OC_User::clearBackends(); OC_User::useBackend(new OC_User_Dummy()); diff --git a/tests/lib/cache/xcache.php b/tests/lib/cache/xcache.php index c081036a31..43bed2db03 100644 --- a/tests/lib/cache/xcache.php +++ b/tests/lib/cache/xcache.php @@ -22,7 +22,7 @@ class Test_Cache_XCache extends Test_Cache { public function setUp() { - if(!function_exists('xcache_get')){ + if(!function_exists('xcache_get')) { $this->markTestSkipped('The xcache extension is not available.'); return; } diff --git a/tests/lib/group.php b/tests/lib/group.php index 9ad397b94a..7b9ca3414b 100644 --- a/tests/lib/group.php +++ b/tests/lib/group.php @@ -50,15 +50,15 @@ class Test_Group extends UnitTestCase { $this->assertFalse(OC_Group::addToGroup($user1, $group1)); - $this->assertEqual(array($user1),OC_Group::usersInGroup($group1)); - $this->assertEqual(array(),OC_Group::usersInGroup($group2)); + $this->assertEqual(array($user1), OC_Group::usersInGroup($group1)); + $this->assertEqual(array(), OC_Group::usersInGroup($group2)); - $this->assertEqual(array($group1),OC_Group::getUserGroups($user1)); - $this->assertEqual(array(),OC_Group::getUserGroups($user2)); + $this->assertEqual(array($group1), OC_Group::getUserGroups($user1)); + $this->assertEqual(array(), OC_Group::getUserGroups($user2)); OC_Group::deleteGroup($group1); - $this->assertEqual(array(),OC_Group::getUserGroups($user1)); - $this->assertEqual(array(),OC_Group::usersInGroup($group1)); + $this->assertEqual(array(), OC_Group::getUserGroups($user1)); + $this->assertEqual(array(), OC_Group::usersInGroup($group1)); $this->assertFalse(OC_Group::inGroup($user1, $group1)); } @@ -76,13 +76,13 @@ class Test_Group extends UnitTestCase { $this->assertEqual(array($group1), $backend1->getGroups()); $this->assertEqual(array(), $backend2->getGroups()); - $this->assertEqual(array($group1),OC_Group::getGroups()); + $this->assertEqual(array($group1), OC_Group::getGroups()); $this->assertTrue(OC_Group::groupExists($group1)); $this->assertFalse(OC_Group::groupExists($group2)); $backend1->createGroup($group2); - $this->assertEqual(array($group1, $group2),OC_Group::getGroups()); + $this->assertEqual(array($group1, $group2), OC_Group::getGroups()); $this->assertTrue(OC_Group::groupExists($group1)); $this->assertTrue(OC_Group::groupExists($group2)); @@ -101,14 +101,14 @@ class Test_Group extends UnitTestCase { $this->assertFalse(OC_Group::addToGroup($user1, $group1)); - $this->assertEqual(array($user1),OC_Group::usersInGroup($group1)); + $this->assertEqual(array($user1), OC_Group::usersInGroup($group1)); - $this->assertEqual(array($group1),OC_Group::getUserGroups($user1)); - $this->assertEqual(array(),OC_Group::getUserGroups($user2)); + $this->assertEqual(array($group1), OC_Group::getUserGroups($user1)); + $this->assertEqual(array(), OC_Group::getUserGroups($user2)); OC_Group::deleteGroup($group1); - $this->assertEqual(array(),OC_Group::getUserGroups($user1)); - $this->assertEqual(array(),OC_Group::usersInGroup($group1)); + $this->assertEqual(array(), OC_Group::getUserGroups($user1)); + $this->assertEqual(array(), OC_Group::usersInGroup($group1)); $this->assertFalse(OC_Group::inGroup($user1, $group1)); } } diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index 3cad3a2868..2cb6f7417d 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -181,7 +181,7 @@ class Test_Share extends UnitTestCase { $this->assertEquals($message, $exception->getMessage()); } - // Owner grants share and update permission + // Owner grants share and update permission OC_User::setUserId($this->user1); $this->assertTrue(OCP\Share::setPermissions('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_UPDATE | OCP\Share::PERMISSION_SHARE)); @@ -375,7 +375,7 @@ class Test_Share extends UnitTestCase { $this->assertTrue(in_array('test.txt', $to_test)); $this->assertTrue(in_array('test1.txt', $to_test)); - // Valid reshare + // Valid reshare $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_USER, $this->user4, OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_SHARE)); OC_User::setUserId($this->user4); $this->assertEquals(array('test1.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET)); diff --git a/tests/lib/streamwrappers.php b/tests/lib/streamwrappers.php index f864a9e361..89b2785fca 100644 --- a/tests/lib/streamwrappers.php +++ b/tests/lib/streamwrappers.php @@ -22,7 +22,7 @@ class Test_StreamWrappers extends UnitTestCase { public function testFakeDir() { - $items=array('foo','bar'); + $items=array('foo', 'bar'); OC_FakeDirStream::$dirs['test']=$items; $dh=opendir('fakedir://test'); $result=array(); @@ -60,9 +60,9 @@ class Test_StreamWrappers extends UnitTestCase { //test callback $tmpFile=OC_Helper::TmpFile('.txt'); $file='close://'.$tmpFile; - OC_CloseStreamWrapper::$callBacks[$tmpFile]=array('Test_StreamWrappers','closeCallBack'); - $fh=fopen($file,'w'); - fwrite($fh,'asd'); + OC_CloseStreamWrapper::$callBacks[$tmpFile]=array('Test_StreamWrappers', 'closeCallBack'); + $fh=fopen($file, 'w'); + fwrite($fh, 'asd'); try{ fclose($fh); $this->fail('Expected exception'); diff --git a/tests/lib/template.php b/tests/lib/template.php index dadfdba5e0..32ae4aca59 100644 --- a/tests/lib/template.php +++ b/tests/lib/template.php @@ -24,7 +24,7 @@ require_once("lib/template.php"); class Test_TemplateFunctions extends UnitTestCase { - public function testP(){ + public function testP() { // FIXME: do we need more testcases? $htmlString = ""; ob_start(); @@ -35,7 +35,7 @@ class Test_TemplateFunctions extends UnitTestCase { $this->assertEqual("<script>alert('xss');</script>", $result); } - public function testPNormalString(){ + public function testPNormalString() { $normalString = "This is a good string!"; ob_start(); p($normalString); @@ -46,7 +46,7 @@ class Test_TemplateFunctions extends UnitTestCase { } - public function testPrintUnescaped(){ + public function testPrintUnescaped() { $htmlString = ""; ob_start(); @@ -57,7 +57,7 @@ class Test_TemplateFunctions extends UnitTestCase { $this->assertEqual($htmlString, $result); } - public function testPrintUnescapedNormalString(){ + public function testPrintUnescapedNormalString() { $normalString = "This is a good string!"; ob_start(); print_unescaped($normalString); diff --git a/tests/lib/user/backend.php b/tests/lib/user/backend.php index eb3aa91b68..0b744770ea 100644 --- a/tests/lib/user/backend.php +++ b/tests/lib/user/backend.php @@ -23,10 +23,10 @@ /** * Abstract class to provide the basis of backend-specific unit test classes. * - * All subclasses MUST assign a backend property in setUp() which implements + * All subclasses MUST assign a backend property in setUp() which implements * user operations (add, remove, etc.). Test methods in this class will then be * run on each separate subclass and backend therein. - * + * * For an example see /tests/lib/user/dummy.php */ @@ -51,12 +51,12 @@ abstract class Test_User_Backend extends UnitTestCase { $name1=$this->getUser(); $name2=$this->getUser(); - $this->backend->createUser($name1,''); + $this->backend->createUser($name1, ''); $count=count($this->backend->getUsers())-$startCount; $this->assertEqual(1, $count); $this->assertTrue((array_search($name1, $this->backend->getUsers())!==false)); $this->assertFalse((array_search($name2, $this->backend->getUsers())!==false)); - $this->backend->createUser($name2,''); + $this->backend->createUser($name2, ''); $count=count($this->backend->getUsers())-$startCount; $this->assertEqual(2, $count); $this->assertTrue((array_search($name1, $this->backend->getUsers())!==false)); @@ -76,24 +76,24 @@ abstract class Test_User_Backend extends UnitTestCase { $this->assertFalse($this->backend->userExists($name1)); $this->assertFalse($this->backend->userExists($name2)); - $this->backend->createUser($name1,'pass1'); - $this->backend->createUser($name2,'pass2'); + $this->backend->createUser($name1, 'pass1'); + $this->backend->createUser($name2, 'pass2'); $this->assertTrue($this->backend->userExists($name1)); $this->assertTrue($this->backend->userExists($name2)); - $this->assertTrue($this->backend->checkPassword($name1,'pass1')); - $this->assertTrue($this->backend->checkPassword($name2,'pass2')); + $this->assertTrue($this->backend->checkPassword($name1, 'pass1')); + $this->assertTrue($this->backend->checkPassword($name2, 'pass2')); - $this->assertFalse($this->backend->checkPassword($name1,'pass2')); - $this->assertFalse($this->backend->checkPassword($name2,'pass1')); + $this->assertFalse($this->backend->checkPassword($name1, 'pass2')); + $this->assertFalse($this->backend->checkPassword($name2, 'pass1')); - $this->assertFalse($this->backend->checkPassword($name1,'dummy')); - $this->assertFalse($this->backend->checkPassword($name2,'foobar')); + $this->assertFalse($this->backend->checkPassword($name1, 'dummy')); + $this->assertFalse($this->backend->checkPassword($name2, 'foobar')); - $this->backend->setPassword($name1,'newpass1'); - $this->assertFalse($this->backend->checkPassword($name1,'pass1')); - $this->assertTrue($this->backend->checkPassword($name1,'newpass1')); - $this->assertFalse($this->backend->checkPassword($name2,'newpass1')); + $this->backend->setPassword($name1, 'newpass1'); + $this->assertFalse($this->backend->checkPassword($name1, 'pass1')); + $this->assertTrue($this->backend->checkPassword($name1, 'newpass1')); + $this->assertFalse($this->backend->checkPassword($name2, 'newpass1')); } } diff --git a/tests/lib/util.php b/tests/lib/util.php index a8e5b81026..27635cb805 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -10,7 +10,7 @@ class Test_Util extends UnitTestCase { // Constructor function Test_Util() { - date_default_timezone_set("UTC"); + date_default_timezone_set("UTC"); } function testFormatDate() { @@ -36,10 +36,10 @@ class Test_Util extends UnitTestCase { $goodString = "This is an harmless string."; $result = OC_Util::sanitizeHTML($goodString); $this->assertEquals("This is an harmless string.", $result); - } + } function testGenerate_random_bytes() { $result = strlen(OC_Util::generate_random_bytes(59)); $this->assertEquals(59, $result); - } + } } \ No newline at end of file diff --git a/tests/preseed-config.php b/tests/preseed-config.php index 7eadccbe76..9791e713da 100644 --- a/tests/preseed-config.php +++ b/tests/preseed-config.php @@ -1,15 +1,15 @@ false, - 'apps_paths' => + 'apps_paths' => array ( - 0 => + 0 => array ( 'path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => false, ), - 1 => + 1 => array ( 'path' => OC::$SERVERROOT.'/apps2', 'url' => '/apps2',