Merge pull request #62 from fmms/master

More Checkstyle warnings
remotes/origin/stable5
Lukas Reschke 12 years ago
commit 73f85c3b81
  1. 2
      apps/files/ajax/scan.php
  2. 2
      apps/files/appinfo/app.php
  3. 2
      lib/appconfig.php
  4. 2
      lib/base.php
  5. 6
      lib/eventsource.php
  6. 78
      lib/filecache.php
  7. 2
      lib/filechunking.php
  8. 4
      lib/fileproxy.php
  9. 42
      lib/files.php
  10. 14
      lib/vobject.php

@ -21,7 +21,7 @@ if($force or !OC_FileCache::inCache('')) {
OC_Cache::clear('fileid/'); //make sure the old fileid's don't mess things up
}
OC_FileCache::scan($dir,$eventSource);
OC_FileCache::scan($dir, $eventSource);
OC_FileCache::clean();
OCP\DB::commit();
$eventSource->send('success', true);

@ -1,7 +1,7 @@
<?php
$l=OC_L10N::get('files');
OCP\App::registerAdmin('files','admin');
OCP\App::registerAdmin('files', 'admin');
OCP\App::addNavigationEntry( array( "id" => "files_index", "order" => 0, "href" => OCP\Util::linkTo( "files", "index.php" ), "icon" => OCP\Util::imagePath( "core", "places/home.svg" ), "name" => $l->t("Files") ));

@ -123,7 +123,7 @@ class OC_Appconfig{
*/
public static function setValue( $app, $key, $value ) {
// Does the key exist? yes: update. No: insert
if(! self::hasKey($app,$key)) {
if(! self::hasKey($app, $key)) {
$query = OC_DB::prepare( 'INSERT INTO `*PREFIX*appconfig` ( `appid`, `configkey`, `configvalue` ) VALUES( ?, ?, ? )' );
$query->execute( array( $app, $key, $value ));
}

@ -176,7 +176,7 @@ class OC{
OC::$SERVERROOT.'/lib'.PATH_SEPARATOR.
OC::$SERVERROOT.'/config'.PATH_SEPARATOR.
OC::$THIRDPARTYROOT.'/3rdparty'.PATH_SEPARATOR.
implode($paths,PATH_SEPARATOR).PATH_SEPARATOR.
implode($paths, PATH_SEPARATOR).PATH_SEPARATOR.
get_include_path().PATH_SEPARATOR.
OC::$SERVERROOT
);

@ -38,7 +38,7 @@ class OC_EventSource{
if($this->fallback) {
$this->fallBackId=$_GET['fallback_id'];
header("Content-Type: text/html");
echo str_repeat('<span></span>'.PHP_EOL,10); //dummy data to keep IE happy
echo str_repeat('<span></span>'.PHP_EOL, 10); //dummy data to keep IE happy
}else{
header("Content-Type: text/event-stream");
}
@ -78,6 +78,6 @@ class OC_EventSource{
* close the connection of the even source
*/
public function close() {
$this->send('__internal__','close');//server side closing can be an issue, let the client do it
$this->send('__internal__', 'close');//server side closing can be an issue, let the client do it
}
}
}

@ -43,14 +43,14 @@ class OC_FileCache{
* - versioned
*/
public static function get($path,$root=false) {
if(OC_FileCache_Update::hasUpdated($path,$root)) {
if(OC_FileCache_Update::hasUpdated($path, $root)) {
if($root===false) {//filesystem hooks are only valid for the default root
OC_Hook::emit('OC_Filesystem','post_write',array('path'=>$path));
OC_Hook::emit('OC_Filesystem', 'post_write', array('path'=>$path));
}else{
OC_FileCache_Update::update($path,$root);
OC_FileCache_Update::update($path, $root);
}
}
return OC_FileCache_Cached::get($path,$root);
return OC_FileCache_Cached::get($path, $root);
}
/**
@ -67,13 +67,13 @@ class OC_FileCache{
}
$fullpath=$root.$path;
$parent=self::getParentId($fullpath);
$id=self::getId($fullpath,'');
$id=self::getId($fullpath, '');
if(isset(OC_FileCache_Cached::$savedData[$fullpath])) {
$data=array_merge(OC_FileCache_Cached::$savedData[$fullpath],$data);
$data=array_merge(OC_FileCache_Cached::$savedData[$fullpath], $data);
unset(OC_FileCache_Cached::$savedData[$fullpath]);
}
if($id!=-1) {
self::update($id,$data);
self::update($id, $data);
return;
}
@ -104,7 +104,7 @@ class OC_FileCache{
$query=OC_DB::prepare('INSERT INTO `*PREFIX*fscache`(`parent`, `name`, `path`, `path_hash`, `size`, `mtime`, `ctime`, `mimetype`, `mimepart`,`user`,`writable`,`encrypted`,`versioned`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)');
$result=$query->execute(array($parent,basename($fullpath),$fullpath,md5($fullpath),$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable'],$data['encrypted'],$data['versioned']));
if(OC_DB::isError($result)) {
OC_Log::write('files','error while writing file('.$fullpath.') to cache',OC_Log::ERROR);
OC_Log::write('files', 'error while writing file('.$fullpath.') to cache', OC_Log::ERROR);
}
if($cache=OC_Cache::getUserCache(true)) {
@ -137,11 +137,11 @@ class OC_FileCache{
}
$arguments[]=$id;
$sql = 'UPDATE `*PREFIX*fscache` SET '.implode(' , ',$queryParts).' WHERE `id`=?';
$sql = 'UPDATE `*PREFIX*fscache` SET '.implode(' , ', $queryParts).' WHERE `id`=?';
$query=OC_DB::prepare($sql);
$result=$query->execute($arguments);
if(OC_DB::isError($result)) {
OC_Log::write('files','error while updating file('.$id.') in cache',OC_Log::ERROR);
OC_Log::write('files', 'error while updating file('.$id.') in cache', OC_Log::ERROR);
}
}
@ -166,7 +166,7 @@ class OC_FileCache{
$query->execute(array($newParent,basename($newPath),$newPath,md5($newPath),md5($oldPath)));
if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$oldPath)) {
$cache->set('fileid/'.$newPath,$cache->get('fileid/'.$oldPath));
$cache->set('fileid/'.$newPath, $cache->get('fileid/'.$oldPath));
$cache->remove('fileid/'.$oldPath);
}
@ -175,11 +175,11 @@ class OC_FileCache{
$updateQuery=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `path`=?, `path_hash`=? WHERE `path_hash`=?');
while($row= $query->execute(array($oldPath.'/%'))->fetchRow()) {
$old=$row['path'];
$new=$newPath.substr($old,$oldLength);
$new=$newPath.substr($old, $oldLength);
$updateQuery->execute(array($new,md5($new),md5($old)));
if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$old)) {
$cache->set('fileid/'.$new,$cache->get('fileid/'.$old));
$cache->set('fileid/'.$new, $cache->get('fileid/'.$old));
$cache->remove('fileid/'.$old);
}
}
@ -231,9 +231,9 @@ class OC_FileCache{
$names=array();
while($row=$result->fetchRow()) {
if(!$returnData) {
$names[]=substr($row['path'],$rootLen);
$names[]=substr($row['path'], $rootLen);
}else{
$row['path']=substr($row['path'],$rootLen);
$row['path']=substr($row['path'], $rootLen);
$names[]=$row;
}
}
@ -256,10 +256,10 @@ class OC_FileCache{
* - versioned
*/
public static function getFolderContent($path,$root=false,$mimetype_filter='') {
if(OC_FileCache_Update::hasUpdated($path,$root,true)) {
OC_FileCache_Update::updateFolder($path,$root);
if(OC_FileCache_Update::hasUpdated($path, $root, true)) {
OC_FileCache_Update::updateFolder($path, $root);
}
return OC_FileCache_Cached::getFolderContent($path,$root,$mimetype_filter);
return OC_FileCache_Cached::getFolderContent($path, $root, $mimetype_filter);
}
/**
@ -269,7 +269,7 @@ class OC_FileCache{
* @return bool
*/
public static function inCache($path,$root=false) {
return self::getId($path,$root)!=-1;
return self::getId($path, $root)!=-1;
}
/**
@ -291,7 +291,7 @@ class OC_FileCache{
$query=OC_DB::prepare('SELECT `id` FROM `*PREFIX*fscache` WHERE `path_hash`=?');
$result=$query->execute(array(md5($fullPath)));
if(OC_DB::isError($result)) {
OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR);
OC_Log::write('files', 'error while getting file id of '.$path, OC_Log::ERROR);
return -1;
}
@ -302,7 +302,7 @@ class OC_FileCache{
$id=-1;
}
if($cache=OC_Cache::getUserCache(true)) {
$cache->set('fileid/'.$fullPath,$id);
$cache->set('fileid/'.$fullPath, $id);
}
return $id;
@ -319,14 +319,14 @@ class OC_FileCache{
$user=OC_User::getUser();
}
$query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `id`=? AND `user`=?');
$result=$query->execute(array($id,$user));
$result=$query->execute(array($id, $user));
$row=$result->fetchRow();
$path=$row['path'];
$root='/'.$user.'/files';
if(substr($path,0,strlen($root))!=$root) {
if(substr($path, 0, strlen($root))!=$root) {
return false;
}
return substr($path,strlen($root));
return substr($path, strlen($root));
}
/**
@ -338,7 +338,7 @@ class OC_FileCache{
if($path=='/') {
return -1;
}else{
return self::getId(dirname($path),'');
return self::getId(dirname($path), '');
}
}
@ -350,7 +350,7 @@ class OC_FileCache{
*/
public static function increaseSize($path,$sizeDiff, $root=false) {
if($sizeDiff==0) return;
$id=self::getId($path,$root);
$id=self::getId($path, $root);
while($id!=-1) {//walk up the filetree increasing the size of all parent folders
$query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `size`=`size`+? WHERE `id`=?');
$query->execute(array($sizeDiff,$id));
@ -368,7 +368,7 @@ class OC_FileCache{
*/
public static function scan($path,$eventSource=false,&$count=0,$root=false) {
if($eventSource) {
$eventSource->send('scanning',array('file'=>$path,'count'=>$count));
$eventSource->send('scanning', array('file'=>$path, 'count'=>$count));
}
$lastSend=$count;
// NOTE: Ugly hack to prevent shared files from going into the cache (the source already exists somewhere in the cache)
@ -380,7 +380,7 @@ class OC_FileCache{
}else{
$view=new OC_FilesystemView($root);
}
self::scanFile($path,$root);
self::scanFile($path, $root);
$dh=$view->opendir($path.'/');
$totalSize=0;
if($dh) {
@ -388,13 +388,13 @@ class OC_FileCache{
if($filename != '.' and $filename != '..') {
$file=$path.'/'.$filename;
if($view->is_dir($file.'/')) {
self::scan($file,$eventSource,$count,$root);
self::scan($file, $eventSource, $count, $root);
}else{
$totalSize+=self::scanFile($file,$root);
$totalSize+=self::scanFile($file, $root);
$count++;
if($count>$lastSend+25 and $eventSource) {
$lastSend=$count;
$eventSource->send('scanning',array('file'=>$path,'count'=>$count));
$eventSource->send('scanning', array('file'=>$path, 'count'=>$count));
}
}
}
@ -436,7 +436,7 @@ class OC_FileCache{
if($path=='/') {
$path='';
}
self::put($path,$stat,$root);
self::put($path, $stat, $root);
return $stat['size'];
}
@ -462,14 +462,14 @@ class OC_FileCache{
$user=OC_User::getUser();
if(!$part2) {
$query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `mimepart`=? AND `user`=? AND `path` LIKE ?');
$result=$query->execute(array($part1,$user, $root));
$result=$query->execute(array($part1, $user, $root));
}else{
$query=OC_DB::prepare('SELECT `path` FROM `*PREFIX*fscache` WHERE `mimetype`=? AND `user`=? AND `path` LIKE ? ');
$result=$query->execute(array($part1.'/'.$part2,$user, $root));
$result=$query->execute(array($part1.'/'.$part2, $user, $root));
}
$names=array();
while($row=$result->fetchRow()) {
$names[]=substr($row['path'],$rootLen);
$names[]=substr($row['path'], $rootLen);
}
return $names;
}
@ -512,7 +512,7 @@ class OC_FileCache{
}
//watch for changes and try to keep the cache up to date
OC_Hook::connect('OC_Filesystem','post_write','OC_FileCache_Update','fileSystemWatcherWrite');
OC_Hook::connect('OC_Filesystem','post_delete','OC_FileCache_Update','fileSystemWatcherDelete');
OC_Hook::connect('OC_Filesystem','post_rename','OC_FileCache_Update','fileSystemWatcherRename');
OC_Hook::connect('OC_User','post_deleteUser','OC_FileCache_Update','deleteFromUser');
OC_Hook::connect('OC_Filesystem', 'post_write', 'OC_FileCache_Update', 'fileSystemWatcherWrite');
OC_Hook::connect('OC_Filesystem', 'post_delete', 'OC_FileCache_Update', 'fileSystemWatcherDelete');
OC_Hook::connect('OC_Filesystem', 'post_rename', 'OC_FileCache_Update', 'fileSystemWatcherRename');
OC_Hook::connect('OC_User', 'post_deleteUser', 'OC_FileCache_Update', 'deleteFromUser');

@ -59,7 +59,7 @@ class OC_FileChunking {
for($i=0; $i < $this->info['chunkcount']; $i++) {
$chunk = $cache->get($prefix.$i);
$cache->remove($prefix.$i);
$count += fwrite($f,$chunk);
$count += fwrite($f, $chunk);
}
return $count;
}

@ -52,7 +52,7 @@ class OC_FileProxy{
* this implements a dummy proxy for all operations
*/
public function __call($function,$arguments) {
if(substr($function,0,3)=='pre') {
if(substr($function, 0, 3)=='pre') {
return true;
}else{
return $arguments[1];
@ -70,7 +70,7 @@ class OC_FileProxy{
public static function getProxies($operation) {
$proxies=array();
foreach(self::$proxies as $proxy) {
if(method_exists($proxy,$operation)) {
if(method_exists($proxy, $operation)) {
$proxies[]=$proxy;
}
}

@ -136,12 +136,12 @@ class OC_Files {
* @param boolean $only_header ; boolean to only send header of the request
*/
public static function get($dir,$files, $only_header = false) {
if(strpos($files,';')) {
$files=explode(';',$files);
if(strpos($files, ';')) {
$files=explode(';', $files);
}
if(is_array($files)) {
self::validateZipDownload($dir,$files);
self::validateZipDownload($dir, $files);
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
$zip = new ZipArchive();
@ -154,15 +154,15 @@ class OC_Files {
if(OC_Filesystem::is_file($file)) {
$tmpFile=OC_Filesystem::toTmpFile($file);
self::$tmpFiles[]=$tmpFile;
$zip->addFile($tmpFile,basename($file));
$zip->addFile($tmpFile, basename($file));
}elseif(OC_Filesystem::is_dir($file)) {
self::zipAddDir($file,$zip);
self::zipAddDir($file, $zip);
}
}
$zip->close();
set_time_limit($executionTime);
}elseif(OC_Filesystem::is_dir($dir.'/'.$files)) {
self::validateZipDownload($dir,$files);
self::validateZipDownload($dir, $files);
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
$zip = new ZipArchive();
@ -171,7 +171,7 @@ class OC_Files {
exit("cannot open <$filename>\n");
}
$file=$dir.'/'.$files;
self::zipAddDir($file,$zip);
self::zipAddDir($file, $zip);
$zip->close();
set_time_limit($executionTime);
}else{
@ -193,7 +193,7 @@ class OC_Files {
}elseif($zip or !OC_Filesystem::file_exists($filename)) {
header("HTTP/1.0 404 Not Found");
$tmpl = new OC_Template( '', '404', 'guest' );
$tmpl->assign('file',$filename);
$tmpl->assign('file', $filename);
$tmpl->printPage();
}else{
header("HTTP/1.0 403 Forbidden");
@ -205,7 +205,7 @@ class OC_Files {
return ;
}
if($zip) {
$handle=fopen($filename,'r');
$handle=fopen($filename, 'r');
if ($handle) {
$chunkSize = 8*1024;// 1 MB chunks
while (!feof($handle)) {
@ -235,9 +235,9 @@ class OC_Files {
if(OC_Filesystem::is_file($file)) {
$tmpFile=OC_Filesystem::toTmpFile($file);
OC_Files::$tmpFiles[]=$tmpFile;
$zip->addFile($tmpFile,$internalDir.$filename);
$zip->addFile($tmpFile, $internalDir.$filename);
}elseif(OC_Filesystem::is_dir($file)) {
self::zipAddDir($file,$zip,$internalDir);
self::zipAddDir($file, $zip, $internalDir);
}
}
}
@ -253,7 +253,7 @@ class OC_Files {
if(OC_User::isLoggedIn() && ($sourceDir != '' || $source != 'Shared')) {
$targetFile=self::normalizePath($targetDir.'/'.$target);
$sourceFile=self::normalizePath($sourceDir.'/'.$source);
return OC_Filesystem::rename($sourceFile,$targetFile);
return OC_Filesystem::rename($sourceFile, $targetFile);
} else {
return false;
}
@ -271,7 +271,7 @@ class OC_Files {
if(OC_User::isLoggedIn()) {
$targetFile=$targetDir.'/'.$target;
$sourceFile=$sourceDir.'/'.$source;
return OC_Filesystem::copy($sourceFile,$targetFile);
return OC_Filesystem::copy($sourceFile, $targetFile);
}
}
@ -390,11 +390,11 @@ class OC_Files {
* @return string guessed mime type
*/
static function pull($source,$token,$dir,$file) {
$tmpfile=tempnam(get_temp_dir(),'remoteCloudFile');
$tmpfile=tempnam(get_temp_dir(), 'remoteCloudFile');
$fp=fopen($tmpfile,'w+');
$url=$source.="/files/pull.php?token=$token";
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
fclose($fp);
@ -402,7 +402,7 @@ class OC_Files {
$httpCode=$info['http_code'];
curl_close($ch);
if($httpCode==200 or $httpCode==0) {
OC_Filesystem::fromTmpFile($tmpfile,$dir.'/'.$file);
OC_Filesystem::fromTmpFile($tmpfile, $dir.'/'.$file);
return true;
}else{
return false;
@ -423,8 +423,8 @@ class OC_Files {
$size -=1;
} else {
$size=OC_Helper::humanFileSize($size);
$size=substr($size,0,-1);//strip the B
$size=str_replace(' ','',$size); //remove the space between the size and the postfix
$size=substr($size, 0, -1);//strip the B
$size=str_replace(' ', '', $size); //remove the space between the size and the postfix
}
//don't allow user to break his config -- broken or malicious size input
@ -459,7 +459,7 @@ class OC_Files {
if(is_writable(OC::$SERVERROOT.'/.htaccess')) {
file_put_contents(OC::$SERVERROOT.'/.htaccess', $htaccess);
return OC_Helper::computerFileSize($size);
} else { OC_Log::write('files','Can\'t write upload limit to '.OC::$SERVERROOT.'/.htaccess. Please check the file permissions',OC_Log::WARN); }
} else { OC_Log::write('files', 'Can\'t write upload limit to '.OC::$SERVERROOT.'/.htaccess. Please check the file permissions', OC_Log::WARN); }
return false;
}
@ -474,7 +474,7 @@ class OC_Files {
$old='';
while($old!=$path) {//replace any multiplicity of slashes with a single one
$old=$path;
$path=str_replace('//','/',$path);
$path=str_replace('//', '/', $path);
}
return $path;
}
@ -486,6 +486,6 @@ function fileCmp($a,$b) {
}elseif($a['type']!='dir' and $b['type']=='dir') {
return 1;
}else{
return strnatcasecmp($a['name'],$b['name']);
return strnatcasecmp($a['name'], $b['name']);
}
}

@ -62,7 +62,7 @@ class OC_VObject{
foreach($value as &$i ) {
$i = implode("\\\\;", explode(';', $i));
}
return implode(';',$value);
return implode(';', $value);
}
/**
@ -71,15 +71,15 @@ class OC_VObject{
* @return array
*/
public static function unescapeSemicolons($value) {
$array = explode(';',$value);
$array = explode(';', $value);
for($i=0;$i<count($array);$i++) {
if(substr($array[$i],-2,2)=="\\\\") {
if(substr($array[$i], -2, 2)=="\\\\") {
if(isset($array[$i+1])) {
$array[$i] = substr($array[$i],0,count($array[$i])-2).';'.$array[$i+1];
$array[$i] = substr($array[$i], 0, count($array[$i])-2).';'.$array[$i+1];
unset($array[$i+1]);
}
else{
$array[$i] = substr($array[$i],0,count($array[$i])-2).';';
$array[$i] = substr($array[$i], 0, count($array[$i])-2).';';
}
$i = $i - 1;
}
@ -127,8 +127,8 @@ class OC_VObject{
}
public function setUID() {
$uid = substr(md5(rand().time()),0,10);
$this->vobject->add('UID',$uid);
$uid = substr(md5(rand().time()), 0, 10);
$this->vobject->add('UID', $uid);
}
public function setString($name, $string) {

Loading…
Cancel
Save