Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/files.php')
-rw-r--r--lib/files.php84
1 files changed, 42 insertions, 42 deletions
diff --git a/lib/files.php b/lib/files.php
index 00cbc63aba0..63dd96b9509 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -32,9 +32,9 @@ class OC_Files {
* get the content of a directory
* @param dir $directory path under datadirectory
*/
- public static function getDirectoryContent($directory, $mimetype_filter = ''){
+ public static function getDirectoryContent($directory, $mimetype_filter = '') {
$directory=OC_Filesystem::normalizePath($directory);
- if($directory=='/'){
+ if($directory=='/') {
$directory='';
}
$files = array();
@@ -87,12 +87,12 @@ class OC_Files {
* @param file $file ; seperated list of files to download
* @param boolean $only_header ; boolean to only send header of the request
*/
- public static function get($dir,$files, $only_header = false){
- if(strpos($files,';')){
+ public static function get($dir,$files, $only_header = false) {
+ if(strpos($files,';')) {
$files=explode(';',$files);
}
- if(is_array($files)){
+ if(is_array($files)) {
self::validateZipDownload($dir,$files);
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
@@ -101,19 +101,19 @@ class OC_Files {
if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) {
exit("cannot open <$filename>\n");
}
- foreach($files as $file){
+ foreach($files as $file) {
$file=$dir.'/'.$file;
- if(OC_Filesystem::is_file($file)){
+ if(OC_Filesystem::is_file($file)) {
$tmpFile=OC_Filesystem::toTmpFile($file);
self::$tmpFiles[]=$tmpFile;
$zip->addFile($tmpFile,basename($file));
- }elseif(OC_Filesystem::is_dir($file)){
+ }elseif(OC_Filesystem::is_dir($file)) {
self::zipAddDir($file,$zip);
}
}
$zip->close();
set_time_limit($executionTime);
- }elseif(OC_Filesystem::is_dir($dir.'/'.$files)){
+ }elseif(OC_Filesystem::is_dir($dir.'/'.$files)) {
self::validateZipDownload($dir,$files);
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
@@ -131,18 +131,18 @@ class OC_Files {
$filename=$dir.'/'.$files;
}
@ob_end_clean();
- if($zip or OC_Filesystem::is_readable($filename)){
+ if($zip or OC_Filesystem::is_readable($filename)) {
header('Content-Disposition: attachment; filename="'.basename($filename).'"');
header('Content-Transfer-Encoding: binary');
OC_Response::disableCaching();
- if($zip){
+ if($zip) {
ini_set('zlib.output_compression', 'off');
header('Content-Type: application/zip');
header('Content-Length: ' . filesize($filename));
}else{
header('Content-Type: '.OC_Filesystem::getMimeType($filename));
}
- }elseif($zip or !OC_Filesystem::file_exists($filename)){
+ }elseif($zip or !OC_Filesystem::file_exists($filename)) {
header("HTTP/1.0 404 Not Found");
$tmpl = new OC_Template( '', '404', 'guest' );
$tmpl->assign('file',$filename);
@@ -151,12 +151,12 @@ class OC_Files {
header("HTTP/1.0 403 Forbidden");
die('403 Forbidden');
}
- if($only_header){
+ if($only_header) {
if(!$zip)
header("Content-Length: ".OC_Filesystem::filesize($filename));
return ;
}
- if($zip){
+ if($zip) {
$handle=fopen($filename,'r');
if ($handle) {
$chunkSize = 8*1024;// 1 MB chunks
@@ -169,26 +169,26 @@ class OC_Files {
}else{
OC_Filesystem::readfile($filename);
}
- foreach(self::$tmpFiles as $tmpFile){
- if(file_exists($tmpFile) and is_file($tmpFile)){
+ foreach(self::$tmpFiles as $tmpFile) {
+ if(file_exists($tmpFile) and is_file($tmpFile)) {
unlink($tmpFile);
}
}
}
- public static function zipAddDir($dir,$zip,$internalDir=''){
+ public static function zipAddDir($dir,$zip,$internalDir='') {
$dirname=basename($dir);
$zip->addEmptyDir($internalDir.$dirname);
$internalDir.=$dirname.='/';
$files=OC_Files::getdirectorycontent($dir);
- foreach($files as $file){
+ foreach($files as $file) {
$filename=$file['name'];
$file=$dir.'/'.$filename;
- if(OC_Filesystem::is_file($file)){
+ if(OC_Filesystem::is_file($file)) {
$tmpFile=OC_Filesystem::toTmpFile($file);
OC_Files::$tmpFiles[]=$tmpFile;
$zip->addFile($tmpFile,$internalDir.$filename);
- }elseif(OC_Filesystem::is_dir($file)){
+ }elseif(OC_Filesystem::is_dir($file)) {
self::zipAddDir($file,$zip,$internalDir);
}
}
@@ -201,8 +201,8 @@ class OC_Files {
* @param dir $targetDir
* @param file $target
*/
- public static function move($sourceDir,$source,$targetDir,$target){
- if(OC_User::isLoggedIn() && ($sourceDir != '' || $source != 'Shared')){
+ public static function move($sourceDir,$source,$targetDir,$target) {
+ if(OC_User::isLoggedIn() && ($sourceDir != '' || $source != 'Shared')) {
$targetFile=self::normalizePath($targetDir.'/'.$target);
$sourceFile=self::normalizePath($sourceDir.'/'.$source);
return OC_Filesystem::rename($sourceFile,$targetFile);
@@ -219,8 +219,8 @@ class OC_Files {
* @param dir $targetDir
* @param file $target
*/
- public static function copy($sourceDir,$source,$targetDir,$target){
- if(OC_User::isLoggedIn()){
+ public static function copy($sourceDir,$source,$targetDir,$target) {
+ if(OC_User::isLoggedIn()) {
$targetFile=$targetDir.'/'.$target;
$sourceFile=$sourceDir.'/'.$source;
return OC_Filesystem::copy($sourceFile,$targetFile);
@@ -234,14 +234,14 @@ class OC_Files {
* @param file $name
* @param type $type
*/
- public static function newFile($dir,$name,$type){
- if(OC_User::isLoggedIn()){
+ public static function newFile($dir,$name,$type) {
+ if(OC_User::isLoggedIn()) {
$file=$dir.'/'.$name;
- if($type=='dir'){
+ if($type=='dir') {
return OC_Filesystem::mkdir($file);
- }elseif($type=='file'){
+ }elseif($type=='file') {
$fileHandle=OC_Filesystem::fopen($file, 'w');
- if($fileHandle){
+ if($fileHandle) {
fclose($fileHandle);
return true;
}else{
@@ -257,7 +257,7 @@ class OC_Files {
* @param dir $dir
* @param file $name
*/
- public static function delete($dir,$file){
+ public static function delete($dir,$file) {
if(OC_User::isLoggedIn() && ($dir!= '' || $file != 'Shared')) {
$file=$dir.'/'.$file;
return OC_Filesystem::unlink($file);
@@ -289,8 +289,8 @@ class OC_Files {
$zipLimit = OC_Config::getValue('maxZipInputSize', OC_Helper::computerFileSize('800 MB'));
if($zipLimit > 0) {
$totalsize = 0;
- if(is_array($files)){
- foreach($files as $file){
+ if(is_array($files)) {
+ foreach($files as $file) {
$totalsize += OC_Filesystem::filesize($dir.'/'.$file);
}
}else{
@@ -319,7 +319,7 @@ class OC_Files {
* @param string path
* @return string guessed mime type
*/
- static function getMimeType($path){
+ static function getMimeType($path) {
return OC_Filesystem::getMimeType($path);
}
@@ -329,7 +329,7 @@ class OC_Files {
* @param string path
* @return array
*/
- static function getTree($path){
+ static function getTree($path) {
return OC_Filesystem::getTree($path);
}
@@ -341,7 +341,7 @@ class OC_Files {
* @param string file
* @return string guessed mime type
*/
- static function pull($source,$token,$dir,$file){
+ static function pull($source,$token,$dir,$file) {
$tmpfile=tempnam(get_temp_dir(),'remoteCloudFile');
$fp=fopen($tmpfile,'w+');
$url=$source.="/files/pull.php?token=$token";
@@ -353,7 +353,7 @@ class OC_Files {
$info=curl_getinfo($ch);
$httpCode=$info['http_code'];
curl_close($ch);
- if($httpCode==200 or $httpCode==0){
+ if($httpCode==200 or $httpCode==0) {
OC_Filesystem::fromTmpFile($tmpfile,$dir.'/'.$file);
return true;
}else{
@@ -366,7 +366,7 @@ class OC_Files {
* @param int size filesisze in bytes
* @return false on failure, size on success
*/
- static function setUploadLimit($size){
+ static function setUploadLimit($size) {
//don't allow user to break his config -- upper boundary
if($size > PHP_INT_MAX) {
//max size is always 1 byte lower than computerFileSize returns
@@ -421,10 +421,10 @@ class OC_Files {
* @param string $path
* @return string
*/
- static public function normalizePath($path){
+ static public function normalizePath($path) {
$path='/'.$path;
$old='';
- while($old!=$path){//replace any multiplicity of slashes with a single one
+ while($old!=$path) {//replace any multiplicity of slashes with a single one
$old=$path;
$path=str_replace('//','/',$path);
}
@@ -432,10 +432,10 @@ class OC_Files {
}
}
-function fileCmp($a,$b){
- if($a['type']=='dir' and $b['type']!='dir'){
+function fileCmp($a,$b) {
+ if($a['type']=='dir' and $b['type']!='dir') {
return -1;
- }elseif($a['type']!='dir' and $b['type']=='dir'){
+ }elseif($a['type']!='dir' and $b['type']=='dir') {
return 1;
}else{
return strnatcasecmp($a['name'],$b['name']);