arewefastyet/website/data.php

39 строки
831 B
PHP
Исходник Обычный вид История

<?php
2014-11-19 21:11:08 +03:00
include "internals.php";
2015-10-04 10:38:41 +03:00
global $config;
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")
fault();
if (!preg_match("/^[a-zA-Z0-9-. _]*$/i", $name))
fault();
2015-10-04 10:38:41 +03:00
$file = $config->data_folder.$name;
if (!file_exists($file)) {
if (!has_permissions())
fault();
2015-10-04 10:38:41 +03:00
$file = $$config->data_folder."auth-".$name;
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);
}