scratch
/file.php |
@@ -90,6 +90,11 @@ |
); |
break; |
case 'GET': |
### Tell browser not to cache files. |
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
header("Cache-Control: post-check=0, pre-check=0", false); |
header("Pragma: no-cache"); |
|
### If no file has been specified for download then return. |
if (!isset($_GET['hash']) or empty($_GET['hash'])) { |
http_response_code(404); |
@@ -137,7 +142,7 @@ |
die('Internal server error.'); |
} |
|
### Hook for HTML files to display properly. |
### Hook for various file extensions. |
switch(strtoupper($fileExtension)) { |
case "HTML": |
case "HTM": |
@@ -144,6 +149,12 @@ |
header('Content-type: text/html'); |
break; |
break; |
case "URL": |
if(preg_match("/URL=([^\n]*)\n/", file_get_contents($userPath), $matches)) { |
header('Location: '.$matches[1]); |
return; |
} |
break; |
default: |
### Open MIME info database and send the content type. |
$finfo = finfo_open(FILEINFO_MIME_TYPE); |
@@ -156,10 +167,6 @@ |
break; |
} |
|
### Tell browser not to cache files. |
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); |
header("Cache-Control: post-check=0, pre-check=0", false); |
header("Pragma: no-cache"); |
### Send the file along with the inline content disposition. |
header('Content-length: '.(int)get_file_size($userPath)); |
header('Content-Disposition: inline; filename="' . basename($userPath) . '"'); |