Matthias Andreas Benkard | b382b10 | 2021-01-02 15:32:21 +0100 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | $pathinfo = pathinfo($_GET['file']); |
| 4 | $extension = strtolower($pathinfo['extension']); |
| 5 | |
| 6 | $filepath = '/tmp/' . $pathinfo['basename']; |
| 7 | $content = ''; |
| 8 | |
| 9 | if (file_exists($filepath)) { |
| 10 | $secondsToCache = 31536000; |
| 11 | $expires = gmdate('D, d M Y H:i:s', time() + $secondsToCache) . ' GMT'; |
| 12 | |
| 13 | if ($extension === 'js') { |
| 14 | header('Content-Type: application/javascript'); |
| 15 | } elseif ($extension === 'css') { |
| 16 | header('Content-Type: text/css'); |
| 17 | } else { |
| 18 | //currently just css and js should be supported! |
| 19 | exit(); |
| 20 | } |
| 21 | |
| 22 | header("Expires: $expires"); |
| 23 | header('Pragma: cache'); |
| 24 | header('Cache-Control: max-age=' . $secondsToCache); |
| 25 | $content = file_get_contents($filepath); |
| 26 | } |
| 27 | |
| 28 | echo $content; |