EPESI BIM • Business Information Manager • Cloud CRM/ERP http://epe.si/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

79 lines
2.3 KiB

  1. <?php
  2. /**
  3. * @author Paul Bukowski <pbukowski@telaxus.com>
  4. * @copyright Copyright &copy; 2006, Telaxus LLC
  5. * @license MIT
  6. * @version 1.0
  7. * @package epesi-base
  8. *
  9. * This script will serve a single js/css file in this directory. Here we place
  10. * the front-end-controller logic in user code, then use the "Files" controller
  11. * to minify the file. Alternately, we could have created a custom controller
  12. * with the same logic and passed it to Minify::handleRequest().
  13. */
  14. /**
  15. * The Files controller only "knows" HTML, CSS, and JS files. Other files
  16. * would only be trim()ed and sent as plain/text.
  17. */
  18. $serveExtensions = array('css', 'js');
  19. set_time_limit(0);
  20. // serve
  21. if (isset($_GET['f'])) {
  22. $filename = $_GET['f']; // remove any naughty bits
  23. $filenamePattern = '/[^\'"\\/\\\\]+\\.(?:'
  24. .implode('|', $serveExtensions).')$/';
  25. if(is_string($filename))
  26. $arr = explode(',',$filename);
  27. elseif(is_array($filename))
  28. $arr = array_values($filename);
  29. if(isset($arr)) {
  30. $arr2 = array();
  31. $this_file_dir_pattern = '/'.preg_quote(dirname(__FILE__),'/').'/i';
  32. foreach($arr as $k=>$v) {
  33. if (preg_match($filenamePattern, $v) &&
  34. file_exists($v) && preg_match($this_file_dir_pattern,realpath($v)))
  35. $arr2[] = $v;
  36. }
  37. ini_set('include_path','libs/minify'.PATH_SEPARATOR.'.'.PATH_SEPARATOR.'libs'.PATH_SEPARATOR.ini_get('include_path'));
  38. require 'Minify.php';
  39. define('_VALID_ACCESS',1);
  40. require_once('include/data_dir.php');
  41. require_once('include/config.php');
  42. $cache_dir = DATA_DIR.'/cache/minify';
  43. if(!file_exists($cache_dir))
  44. mkdir($cache_dir,0777,true);
  45. Minify::setCache($cache_dir);
  46. $opts = array( 'files' => $arr2,
  47. 'maxAge' => 86400 * 365,
  48. 'rewriteCssUris'=>false
  49. );
  50. if (!MINIFY_ENCODE) {
  51. $opts['encodeOutput'] = false;
  52. $opts['encodeMethod'] = '';
  53. }
  54. if (!MINIFY_SOURCES) {
  55. $opts['minifiers'] = array(
  56. Minify::TYPE_CSS => '',
  57. Minify::TYPE_HTML => '',
  58. Minify::TYPE_JS => ''
  59. );
  60. }
  61. // The Files controller can serve an array of files, but here we just
  62. // need one.
  63. Minify::serve('Files', $opts);
  64. exit();
  65. }
  66. }
  67. header("HTTP/1.0 404 Not Found");
  68. echo "HTTP/1.0 404 Not Found";
  69. ?>