PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/application/admin/public_data/compact.php

http://f-engine.googlecode.com/
PHP | 56 lines | 33 code | 18 blank | 5 comment | 6 complexity | 7cc24c1ebb02d4493ed62fa584b59ef8 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, LGPL-2.1
  1. <?php
  2. /***
  3. * This script combines and compacts css and javascript files
  4. * to reduce the number of HTTP requests and speed up
  5. * web page load time
  6. */
  7. define('BASEPATH',realpath(dirname(__FILE__))."/../../");
  8. include(realpath(dirname(__FILE__))."/../config/config.php");
  9. $options = $config["compact"];
  10. if($options["compress"] and extension_loaded('zlib')) {
  11. ob_start('ob_gzhandler');
  12. }
  13. header ("content-type: text/css; charset: UTF-8");
  14. header ("cache-control: must-revalidate");
  15. $offset = 60 * 60 * $options["cachetime"];
  16. $expire = "expires: " . gmdate ("D, d M Y H:i:s", time() + $offset) . " GMT";
  17. header ($expire);
  18. if(isset($_GET["css"])) {
  19. $files = $_GET["css"];
  20. $prefix = "css/";
  21. } elseif(isset($_GET["js"])) {
  22. $files = $_GET["js"];
  23. $prefix = "js/";
  24. } else {
  25. return;
  26. }
  27. $files = explode(",",$files);
  28. foreach($files as $file) {
  29. $filename = realpath(dirname(__FILE__)."/".$prefix.$file);
  30. if(file_exists($filename) and strstr($filename, realpath(dirname(__FILE__)))) {
  31. include($filename);
  32. } else {
  33. echo "\n/* file not found: ".$filename." */\n";
  34. }
  35. }
  36. if($options["compress"] and extension_loaded('zlib')){
  37. ob_end_flush();
  38. }