summaryrefslogtreecommitdiffstats
path: root/files/open_file.php
diff options
context:
space:
mode:
Diffstat (limited to 'files/open_file.php')
-rwxr-xr-xfiles/open_file.php31
1 files changed, 5 insertions, 26 deletions
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