From dfc8228fb47220e9fe107368da2ebd5da79e780a Mon Sep 17 00:00:00 2001 From: Felix Moeller Date: Sun, 28 Oct 2012 23:58:08 +0100 Subject: NoSpaceAfterComma --- apps/files_encryption/lib/crypt.php | 20 +++++++-------- apps/files_encryption/lib/cryptstream.php | 42 +++++++++++++++---------------- apps/files_external/lib/webdav.php | 38 ++++++++++++++-------------- 3 files changed, 50 insertions(+), 50 deletions(-) (limited to 'apps') diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php index d057c1ed194..28bf3c5c93e 100644 --- a/apps/files_encryption/lib/crypt.php +++ b/apps/files_encryption/lib/crypt.php @@ -40,7 +40,7 @@ class OC_Crypt { static private $bf = null; public static function loginListener($params) { - self::init($params['uid'],$params['password']); + self::init($params['uid'], $params['password']); } public static function init($login,$password) { @@ -51,7 +51,7 @@ class OC_Crypt { OC_FileProxy::$enabled=false; if(!$view->file_exists('/'.$login.'/encryption.key')) {// does key exist? - OC_Crypt::createkey($login,$password); + OC_Crypt::createkey($login, $password); } $key=$view->file_get_contents('/'.$login.'/encryption.key'); OC_FileProxy::$enabled=true; @@ -82,16 +82,16 @@ class OC_Crypt { 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); + $key=mt_rand(10000, 99999).mt_rand(10000, 99999).mt_rand(10000, 99999).mt_rand(10000, 99999); // encrypt the key with the passcode of the user - $enckey=OC_Crypt::encrypt($key,$passcode); + $enckey=OC_Crypt::encrypt($key, $passcode); // Write the file $proxyEnabled=OC_FileProxy::$enabled; OC_FileProxy::$enabled=false; $view=new OC_FilesystemView('/'.$username); - $view->file_put_contents('/encryption.key',$enckey); + $view->file_put_contents('/encryption.key', $enckey); OC_FileProxy::$enabled=$proxyEnabled; } @@ -195,8 +195,8 @@ class OC_Crypt { public static function blockEncrypt($data, $key='') { $result=''; while(strlen($data)) { - $result.=self::encrypt(substr($data,0,8192),$key); - $data=substr($data,8192); + $result.=self::encrypt(substr($data, 0, 8192),$key); + $data=substr($data, 8192); } return $result; } @@ -207,11 +207,11 @@ class OC_Crypt { public static function blockDecrypt($data, $key='',$maxLength=0) { $result=''; while(strlen($data)) { - $result.=self::decrypt(substr($data,0,8192),$key); - $data=substr($data,8192); + $result.=self::decrypt(substr($data, 0, 8192),$key); + $data=substr($data, 8192); } if($maxLength>0) { - return substr($result,0,$maxLength); + return substr($result, 0, $maxLength); }else{ return rtrim($result, "\0"); } diff --git a/apps/files_encryption/lib/cryptstream.php b/apps/files_encryption/lib/cryptstream.php index 95b58b8cce7..0dd2d4b7b1e 100644 --- a/apps/files_encryption/lib/cryptstream.php +++ b/apps/files_encryption/lib/cryptstream.php @@ -40,7 +40,7 @@ class OC_CryptStream{ if(!self::$rootView) { self::$rootView=new OC_FilesystemView(''); } - $path=str_replace('crypt://','',$path); + $path=str_replace('crypt://', '', $path); if(dirname($path)=='streams' and isset(self::$sourceStreams[basename($path)])) { $this->source=self::$sourceStreams[basename($path)]['stream']; $this->path=self::$sourceStreams[basename($path)]['path']; @@ -50,13 +50,13 @@ class OC_CryptStream{ if($mode=='w' or $mode=='w+' or $mode=='wb' or $mode=='wb+') { $this->size=0; }else{ - $this->size=self::$rootView->filesize($path,$mode); + $this->size=self::$rootView->filesize($path, $mode); } OC_FileProxy::$enabled=false;//disable fileproxies so we can open the source file - $this->source=self::$rootView->fopen($path,$mode); + $this->source=self::$rootView->fopen($path, $mode); OC_FileProxy::$enabled=true; if(!is_resource($this->source)) { - OCP\Util::writeLog('files_encryption','failed to open '.$path,OCP\Util::ERROR); + OCP\Util::writeLog('files_encryption', 'failed to open '.$path, OCP\Util::ERROR); } } if(is_resource($this->source)) { @@ -67,7 +67,7 @@ class OC_CryptStream{ public function stream_seek($offset, $whence=SEEK_SET) { $this->flush(); - fseek($this->source,$offset,$whence); + fseek($this->source, $offset, $whence); } public function stream_tell() { @@ -79,11 +79,11 @@ class OC_CryptStream{ //This makes this function a lot simpler but will breake everything the moment it's fixed $this->writeCache=''; if($count!=8192) { - OCP\Util::writeLog('files_encryption','php bug 21641 no longer holds, decryption will not work',OCP\Util::FATAL); + OCP\Util::writeLog('files_encryption', 'php bug 21641 no longer holds, decryption will not work', OCP\Util::FATAL); die(); } $pos=ftell($this->source); - $data=fread($this->source,8192); + $data=fread($this->source, 8192); if(strlen($data)) { $result=OC_Crypt::decrypt($data); }else{ @@ -91,7 +91,7 @@ class OC_CryptStream{ } $length=$this->size-$pos; if($length<8192) { - $result=substr($result,0,$length); + $result=substr($result, 0, $length); } return $result; } @@ -105,12 +105,12 @@ class OC_CryptStream{ } if($currentPos%8192!=0) { //make sure we always start on a block start - fseek($this->source,-($currentPos%8192),SEEK_CUR); + fseek($this->source, -($currentPos%8192), SEEK_CUR); $encryptedBlock=fread($this->source,8192); - fseek($this->source,-($currentPos%8192),SEEK_CUR); + fseek($this->source, -($currentPos%8192), SEEK_CUR); $block=OC_Crypt::decrypt($encryptedBlock); - $data=substr($block,0,$currentPos%8192).$data; - fseek($this->source,-($currentPos%8192),SEEK_CUR); + $data=substr($block, 0, $currentPos%8192).$data; + fseek($this->source, -($currentPos%8192), SEEK_CUR); } $currentPos=ftell($this->source); while($remainingLength=strlen($data)>0) { @@ -118,9 +118,9 @@ class OC_CryptStream{ $this->writeCache=$data; $data=''; }else{ - $encrypted=OC_Crypt::encrypt(substr($data,0,8192)); - fwrite($this->source,$encrypted); - $data=substr($data,8192); + $encrypted=OC_Crypt::encrypt(substr($data, 0, 8192)); + fwrite($this->source, $encrypted); + $data=substr($data, 8192); } } $this->size=max($this->size,$currentPos+$length); @@ -130,13 +130,13 @@ class OC_CryptStream{ public function stream_set_option($option,$arg1,$arg2) { switch($option) { case STREAM_OPTION_BLOCKING: - stream_set_blocking($this->source,$arg1); + 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); } } @@ -145,7 +145,7 @@ class OC_CryptStream{ } public function stream_lock($mode) { - flock($this->source,$mode); + flock($this->source, $mode); } public function stream_flush() { @@ -159,7 +159,7 @@ class OC_CryptStream{ private function flush() { if($this->writeCache) { $encrypted=OC_Crypt::encrypt($this->writeCache); - fwrite($this->source,$encrypted); + fwrite($this->source, $encrypted); $this->writeCache=''; } } @@ -167,7 +167,7 @@ class OC_CryptStream{ public function stream_close() { $this->flush(); if($this->meta['mode']!='r' and $this->meta['mode']!='rb') { - OC_FileCache::put($this->path, array('encrypted'=>true,'size'=>$this->size),''); + OC_FileCache::put($this->path, array('encrypted'=>true, 'size'=>$this->size), ''); } return fclose($this->source); } diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 74e468a2838..e29ec6cb8a2 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -22,8 +22,8 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ public function __construct($params) { $host = $params['host']; //remove leading http[s], will be generated in createBaseUri() - if (substr($host,0,8) == "https://") $host = substr($host, 8); - else if (substr($host,0,7) == "http://") $host = substr($host, 7); + if (substr($host, 0, 8) == "https://") $host = substr($host, 8); + else if (substr($host, 0, 7) == "http://") $host = substr($host, 7); $this->host=$host; $this->user=$params['user']; $this->password=$params['password']; @@ -32,7 +32,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ if(!$this->root || $this->root[0]!='/') { $this->root='/'.$this->root; } - if(substr($this->root,-1,1)!='/') { + if(substr($this->root, -1, 1)!='/') { $this->root.='/'; } @@ -65,18 +65,18 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ public function mkdir($path) { $path=$this->cleanPath($path); - return $this->simpleResponse('MKCOL',$path, null,201); + return $this->simpleResponse('MKCOL', $path, null, 201); } public function rmdir($path) { $path=$this->cleanPath($path); - return $this->simpleResponse('DELETE',$path, null,204); + return $this->simpleResponse('DELETE', $path, null, 204); } public function opendir($path) { $path=$this->cleanPath($path); try{ - $response=$this->client->propfind($path, array(),1); + $response=$this->client->propfind($path, array(), 1); $id=md5('webdav'.$this->root.$path); OC_FakeDirStream::$dirs[$id]=array(); $files=array_keys($response); @@ -123,7 +123,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ } public function unlink($path) { - return $this->simpleResponse('DELETE',$path, null,204); + return $this->simpleResponse('DELETE', $path, null, 204); } public function fopen($path,$mode) { @@ -137,7 +137,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ //straight up curl instead of sabredav here, sabredav put's the entire get result in memory $curl = curl_init(); $fp = fopen('php://temp', 'r+'); - curl_setopt($curl,CURLOPT_USERPWD,$this->user.':'.$this->password); + curl_setopt($curl, CURLOPT_USERPWD, $this->user.':'.$this->password); curl_setopt($curl, CURLOPT_URL, $this->createBaseUri().$path); curl_setopt($curl, CURLOPT_FILE, $fp); @@ -158,18 +158,18 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ 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); + $this->getFile($path, $tmpFile); } self::$tempFiles[$tmpFile]=$path; - return fopen('close://'.$tmpFile,$mode); + return fopen('close://'.$tmpFile, $mode); } } @@ -203,15 +203,15 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ } public function getFile($path,$target) { - $source=$this->fopen($path,'r'); - file_put_contents($target,$source); + $source=$this->fopen($path, 'r'); + file_put_contents($target, $source); } public function uploadFile($path,$target) { - $source=fopen($path,'r'); + $source=fopen($path, 'r'); $curl = curl_init(); - curl_setopt($curl,CURLOPT_USERPWD,$this->user.':'.$this->password); + curl_setopt($curl, CURLOPT_USERPWD, $this->user.':'.$this->password); curl_setopt($curl, CURLOPT_URL, $this->createBaseUri().$target); curl_setopt($curl, CURLOPT_BINARYTRANSFER, true); curl_setopt($curl, CURLOPT_INFILE, $source); // file pointer @@ -283,7 +283,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ private function cleanPath($path) { if(!$path || $path[0]=='/') { - return substr($path,1); + return substr($path, 1); }else{ return $path; } @@ -292,7 +292,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ private function simpleResponse($method,$path,$body,$expected) { $path=$this->cleanPath($path); try{ - $response=$this->client->request($method,$path,$body); + $response=$this->client->request($method, $path, $body); return $response['statusCode']==$expected; }catch(Exception $e) { return false; -- cgit v1.2.3