Merge pull request #62 from fmms/master

More Checkstyle warnings
This commit is contained in:
Lukas Reschke 2012-10-23 08:07:01 -07:00
commit 73f85c3b81
10 changed files with 77 additions and 77 deletions

View File

@ -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_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(); OC_FileCache::clean();
OCP\DB::commit(); OCP\DB::commit();
$eventSource->send('success', true); $eventSource->send('success', true);

View File

@ -1,7 +1,7 @@
<?php <?php
$l=OC_L10N::get('files'); $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") )); 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") ));

View File

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

View File

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

View File

@ -38,7 +38,7 @@ class OC_EventSource{
if($this->fallback) { if($this->fallback) {
$this->fallBackId=$_GET['fallback_id']; $this->fallBackId=$_GET['fallback_id'];
header("Content-Type: text/html"); 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{ }else{
header("Content-Type: text/event-stream"); header("Content-Type: text/event-stream");
} }
@ -78,6 +78,6 @@ class OC_EventSource{
* close the connection of the even source * close the connection of the even source
*/ */
public function close() { public function close() {
$this->send('__internal__','close');//server side closing can be an issue, let the client do it $this->send('__internal__', 'close');//server side closing can be an issue, let the client do it
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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