2019-10-21 03:25:58 +08:00
|
|
|
<?php
|
|
|
|
|
2022-03-21 05:05:28 +08:00
|
|
|
if (!isset($_GET['file']) ) {
|
|
|
|
http_response_code(404);
|
|
|
|
exit;
|
|
|
|
}
|
2019-10-21 03:25:58 +08:00
|
|
|
$pathinfo = pathinfo($_GET['file']);
|
2022-03-21 05:05:28 +08:00
|
|
|
|
|
|
|
if (!array_key_exists('extension', $pathinfo)) {
|
|
|
|
http_response_code(404);
|
|
|
|
exit;
|
|
|
|
}
|
2019-10-21 03:25:58 +08:00
|
|
|
$extension = strtolower($pathinfo['extension']);
|
|
|
|
|
|
|
|
$filepath = '/tmp/' . $pathinfo['basename'];
|
|
|
|
$content = '';
|
|
|
|
|
|
|
|
if (file_exists($filepath)) {
|
|
|
|
$secondsToCache = 31536000;
|
|
|
|
$expires = gmdate('D, d M Y H:i:s', time() + $secondsToCache) . ' GMT';
|
|
|
|
|
|
|
|
if ($extension === 'js') {
|
|
|
|
header('Content-Type: application/javascript');
|
|
|
|
} elseif ($extension === 'css') {
|
|
|
|
header('Content-Type: text/css');
|
|
|
|
} else {
|
|
|
|
//currently just css and js should be supported!
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
header("Expires: $expires");
|
|
|
|
header('Pragma: cache');
|
|
|
|
header('Cache-Control: max-age=' . $secondsToCache);
|
|
|
|
$content = file_get_contents($filepath);
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $content;
|