blob: 96d41c1a04057f11e35149d8bbe778b714a6d53b [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001<?php
2
3$pathinfo = pathinfo($_GET['file']);
4$extension = strtolower($pathinfo['extension']);
5
6$filepath = '/tmp/' . $pathinfo['basename'];
7$content = '';
8
9if (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
28echo $content;