aboutsummaryrefslogtreecommitdiffstats
path: root/lib/files.php
diff options
context:
space:
mode:
authorValerio Ponte <valerio.ponte@gmail.com>2012-10-30 23:37:31 +0100
committerValerio Ponte <valerio.ponte@gmail.com>2012-11-14 20:10:20 +0100
commitde7e419610d3fde8a16367776279d76837a0ee62 (patch)
tree2b21989e8c7eb2a7d52781e8c68b78ab3a500eff /lib/files.php
parent8e190a5a97fd2be24370aa8d3f21b7641506ae92 (diff)
downloadnextcloud-server-de7e419610d3fde8a16367776279d76837a0ee62.tar.gz
nextcloud-server-de7e419610d3fde8a16367776279d76837a0ee62.zip
Fixed style according to owncloud styleguide
Diffstat (limited to 'lib/files.php')
-rw-r--r--lib/files.php50
1 files changed, 30 insertions, 20 deletions
diff --git a/lib/files.php b/lib/files.php
index 24e3b4bfaa7..912de5655b0 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -42,16 +42,20 @@ class OC_Files {
* - versioned
*/
public static function getFileInfo($path) {
+ $path = OC_Filesystem::normalizePath($path);
if (($path == '/Shared' || substr($path, 0, 8) == '/Shared/') && OC_App::isEnabled('files_sharing')) {
if ($path == '/Shared') {
list($info) = OCP\Share::getItemsSharedWith('file', OC_Share_Backend_File::FORMAT_FILE_APP_ROOT);
- }else{
- $info['size'] = OC_Filesystem::filesize($path);
- $info['mtime'] = OC_Filesystem::filemtime($path);
- $info['ctime'] = OC_Filesystem::filectime($path);
- $info['mimetype'] = OC_Filesystem::getMimeType($path);
- $info['encrypted'] = false;
- $info['versioned'] = false;
+ } else {
+ $info = array();
+ if (OC_Filesystem::file_exists($path)) {
+ $info['size'] = OC_Filesystem::filesize($path);
+ $info['mtime'] = OC_Filesystem::filemtime($path);
+ $info['ctime'] = OC_Filesystem::filectime($path);
+ $info['mimetype'] = OC_Filesystem::getMimeType($path);
+ $info['encrypted'] = false;
+ $info['versioned'] = false;
+ }
}
} else {
$info = OC_FileCache::get($path);
@@ -87,13 +91,13 @@ class OC_Files {
foreach ($files as &$file) {
$file['directory'] = $directory;
$file['type'] = ($file['mimetype'] == 'httpd/unix-directory') ? 'dir' : 'file';
- $permissions = OCP\Share::PERMISSION_READ;
+ $permissions = OCP\PERMISSION_READ;
// NOTE: Remove check when new encryption is merged
if (!$file['encrypted']) {
- $permissions |= OCP\Share::PERMISSION_SHARE;
+ $permissions |= OCP\PERMISSION_SHARE;
}
if ($file['type'] == 'dir' && $file['writable']) {
- $permissions |= OCP\Share::PERMISSION_CREATE;
+ $permissions |= OCP\PERMISSION_CREATE;
}
if ($file['writable']) {
$permissions |= OCP\PERMISSION_UPDATE | OCP\PERMISSION_DELETE;
@@ -138,8 +142,9 @@ class OC_Files {
public static function get($dir, $files, $only_header = false) {
$xsendfile = false;
if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) ||
- isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED']))
+ isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
$xsendfile = true;
+ }
if(strpos($files, ';')) {
$files=explode(';', $files);
}
@@ -149,11 +154,12 @@ class OC_Files {
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
$zip = new ZipArchive();
- if ($xsendfile)
+ if ($xsendfile) {
$filename = OC_Helper::tmpFileNoClean('.zip');
- else
+ }else{
$filename = OC_Helper::tmpFile('.zip');
- if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) {
+ }
+ if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==true) {
exit("cannot open <$filename>\n");
}
foreach($files as $file) {
@@ -173,11 +179,12 @@ class OC_Files {
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
$zip = new ZipArchive();
- if ($xsendfile)
+ if ($xsendfile) {
$filename = OC_Helper::tmpFileNoClean('.zip');
- else
+ }else{
$filename = OC_Helper::tmpFile('.zip');
- if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) {
+ }
+ if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==true) {
exit("cannot open <$filename>\n");
}
$file=$dir.'/'.$files;
@@ -201,8 +208,9 @@ class OC_Files {
}else{
header('Content-Type: '.OC_Filesystem::getMimeType($filename));
$storage = OC_Filesystem::getStorage($filename);
- if ($storage instanceof OC_Filestorage_Local)
+ if ($storage instanceof OC_Filestorage_Local) {
self::addSendfileHeader(OC_Filesystem::getLocalFile($filename));
+ }
}
}elseif($zip or !OC_Filesystem::file_exists($filename)) {
header("HTTP/1.0 404 Not Found");
@@ -227,8 +235,9 @@ class OC_Files {
flush();
}
}
- if (!$xsendfile)
+ if (!$xsendfile) {
unlink($filename);
+ }
}else{
OC_Filesystem::readfile($filename);
}
@@ -243,8 +252,9 @@ class OC_Files {
if (isset($_SERVER['MOD_X_SENDFILE_ENABLED'])) {
header("X-Sendfile: " . $filename);
}
- if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED']))
+ if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
header("X-Accel-Redirect: " . $filename);
+ }
}
public static function zipAddDir($dir, $zip, $internalDir='') {