2014-11-19 19:47:21 +03:00
|
|
|
<?php
|
|
|
|
|
2014-11-19 21:11:08 +03:00
|
|
|
include "internals.php";
|
|
|
|
|
2015-10-04 10:38:41 +03:00
|
|
|
global $config;
|
|
|
|
|
2014-11-19 19:47:21 +03:00
|
|
|
function fault() {
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($_GET["file"]))
|
|
|
|
fault();
|
|
|
|
|
2014-11-19 21:11:08 +03:00
|
|
|
$name = $_GET["file"];
|
|
|
|
if (substr($name, 0, 4) == "auth")
|
2014-11-19 19:47:21 +03:00
|
|
|
fault();
|
2015-04-05 13:32:54 +03:00
|
|
|
if (!preg_match("/^[a-zA-Z0-9-. _]*$/i", $name))
|
2014-11-19 19:47:21 +03:00
|
|
|
fault();
|
|
|
|
|
2015-10-04 10:38:41 +03:00
|
|
|
$file = $config->data_folder.$name;
|
2014-11-19 19:47:21 +03:00
|
|
|
if (!file_exists($file)) {
|
|
|
|
if (!has_permissions())
|
|
|
|
fault();
|
|
|
|
|
2015-10-04 10:38:41 +03:00
|
|
|
$file = $$config->data_folder."auth-".$name;
|
2014-11-19 19:47:21 +03:00
|
|
|
if (!file_exists($file))
|
|
|
|
fault();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
|
|
|
|
strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == filemtime($file))
|
|
|
|
{
|
|
|
|
header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($file)).' GMT', true, 304);
|
|
|
|
} else {
|
|
|
|
header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($file)).' GMT', true, 200);
|
|
|
|
header('Content-Length: '.filesize($file));
|
|
|
|
echo file_get_contents($file);
|
|
|
|
}
|