diff options
author | Robin <robin@Amaya.(none)> | 2010-05-07 22:50:59 +0200 |
---|---|---|
committer | Robin <robin@Amaya.(none)> | 2010-05-07 22:50:59 +0200 |
commit | 565410d8e266b4d0391b10d15339f700dcb1f789 (patch) | |
tree | 37259c99ba87e38954f7a06c6c09cf9703fd8b10 /files | |
parent | ede1c64eddeb3abdde5b67da03be906bfba1b4cc (diff) | |
download | nextcloud-server-565410d8e266b4d0391b10d15339f700dcb1f789.tar.gz nextcloud-server-565410d8e266b4d0391b10d15339f700dcb1f789.zip |
use an abstraction for file system functions to allow premisions and multiply storage backends
Diffstat (limited to 'files')
-rwxr-xr-x | files/get_files.php | 2 | ||||
-rwxr-xr-x | files/open_file.php | 31 |
2 files changed, 6 insertions, 27 deletions
diff --git a/files/get_files.php b/files/get_files.php index 21866dbf636..1481bb6f84b 100755 --- a/files/get_files.php +++ b/files/get_files.php @@ -42,7 +42,7 @@ function return_bytes($val) { header('Content-type: application/xml'); $dir=isset($_GET['dir'])?$_GET['dir']:''; -$files=OC_FILES::getdirectorycontent(realpath($CONFIG_DATADIRECTORY.'/'.$dir)); +$files=OC_FILES::getdirectorycontent($dir); $dirname=(isset($files[0]))?$files[0]['directory']:''; $dirname=substr($dirname,strrpos($dirname,'/')); $max_upload=min(return_bytes(ini_get('post_max_size')),return_bytes(ini_get('upload_max_filesize'))); diff --git a/files/open_file.php b/files/open_file.php index 933efa51e1e..e1b82dcd37b 100755 --- a/files/open_file.php +++ b/files/open_file.php @@ -24,40 +24,19 @@ require_once('../inc/lib_base.php'); -function get_mime_type($filename, $mimePath = '../etc') { - $fileext = substr(strrchr($filename, '.'), 1); - if (empty($fileext)) return (false); - $regex = "/^([\w\+\-\.\/]+)\s+(\w+\s)*($fileext\s)/i"; - $lines = file("$mimePath/mime.types"); - foreach($lines as $line) { - if (substr($line, 0, 1) == '#') continue; // skip comments - $line = rtrim($line) . " "; - if (!preg_match($regex, $line, $matches)) continue; // no match to the extension - return ($matches[1]); - } - return (false); // no match at all -} - $file=$_GET['file']; $dir=(isset($_GET['dir']))?$_GET['dir']:''; if(strstr($file,'..') or strstr($dir,'..')){ die(); } -$filename=$CONFIG_DATADIRECTORY.'/'.$dir.'/'.$file; -// $ftype='application/octet-stream'; -// $finfo=new finfo(FILEINFO_MIME); -// $fres=@$finfo->file($filename); -// if (is_string($fres) && !empty($fres)) { -// $ftype = $fres; -// } -$ftype=get_mime_type($filename); +$filename=$dir.'/'.$file; +$ftype=OC_FILESYSTEM::getMimeType($filename); ob_end_clean(); -// echo $ftype; -// die(); header('Content-Type: '.$ftype); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); -header('Content-Length: ' . filesize($filename)); -readfile($filename); +header('Content-Length: ' . OC_FILESYSTEM::filesize($filename)); + +OC_FILESYSTEM::readfile($filename); ?>
\ No newline at end of file |