arewefastyet/website/data.php

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

<?php
2017-05-22 18:47:32 +03:00
include "lib/internals.php";
2014-11-19 21:11:08 +03:00
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();
2016-03-01 17:47:43 +03:00
if (!preg_match("/^[a-zA-Z0-9-. _]*$/i", $name)) {
if (!preg_match("/^treeherder-logs\/[a-zA-Z0-9-. _]*$/i", $name))
fault();
}
2015-10-04 10:38:41 +03:00
$file = $config->data_folder.$name;
2017-03-07 13:56:13 +03:00
if (has_permissions()) {
$authfile = $config->data_folder."auth-".$name;
if (file_exists($authfile))
$file = $authfile;
}
2017-03-07 13:56:13 +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);
}