resource.php 736 B

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