= 0) { date_default_timezone_set(@date_default_timezone_get()); } // set env $XE_PATH = substr(dirname(__FILE__),0,strlen('common')*-1); $XE_WEB_PATH = substr($XE_PATH,strlen($_SERVER['DOCUMENT_ROOT'])); $cache_path = $XE_PATH . 'files/cache/optimized/'; $type = $_GET['t']; $list_file = $cache_path . $_GET['l']; // check if(!file_exists($list_file)) exit; $list = include($list_file); if(!is_array($list)) exit; function getRealPath($file){ global $XE_PATH; if($file{0}=='.' && $file{1} =='/') $file = $XE_PATH.substr($file, 2); return $file; } function getMtime($file){ $file = getRealPath($file); if(file_exists($file)) return filemtime($file); } function getMaxMtime($list){ $mtime = array(); foreach($list as $file) $mtime[] = getMtime($file); return max($mtime); } // max mtime $mtime = getMaxMtime($list); if($type == '.css'){ $content_type = 'text/css'; } else if($type == '.js') { $content_type = 'text/javascript'; } header("Content-Type: ".$content_type."; charset=UTF-8"); // return 304 if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $modifiedSince = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']); if ($modifiedSince && ($modifiedSince == $mtime)) { header('HTTP/1.1 304 Not Modified'); header("Connection: close"); exit; } } header("Cache-Control: private, max-age=2592000"); header("Pragma: cache"); header("Connection: close"); header("Last-Modified: " . substr(gmdate('r', $mtime), 0, -5). "GMT"); header("ETag: \"". md5(join(' ', $list)) .'-'. dechex($mtime)."\""); function printFileList($list){ for($i=0,$c=count($list);$i<$c;$i++){ $file = getRealPath($list[$i]); if(file_exists($file)){ $f = fopen($file,"r"); fpassthru($f); } } } if($type == '.css'){ function convertEncodingStr($str) { $charset_list = array( 'UTF-8', 'EUC-KR', 'CP949', 'ISO8859-1', 'EUC-JP', 'SHIFT_JIS', 'CP932', 'EUC-CN', 'HZ', 'GBK', 'GB18030', 'EUC-TW', 'BIG5', 'CP950', 'BIG5-HKSCS', 'ISO2022-CN', 'ISO2022-CN-EXT', 'ISO2022-JP', 'ISO2022-JP-2', 'ISO2022-JP-1', 'ISO8859-6', 'ISO8859-8', 'JOHAB', 'ISO2022-KR', 'CP1255', 'CP1256', 'CP862', 'ASCII', 'ISO8859-1', 'ISO8850-2', 'ISO8850-3', 'ISO8850-4', 'ISO8850-5', 'ISO8850-7', 'ISO8850-9', 'ISO8850-10', 'ISO8850-13', 'ISO8850-14', 'ISO8850-15', 'ISO8850-16', 'CP1250', 'CP1251', 'CP1252', 'CP1253', 'CP1254', 'CP1257', 'CP850', 'CP866', ); for($i=0;$i $cache_mtime){ makeCacheFileCSS($file, getRealPath($cache_file)); } $css[] = getRealPath($cache_file); } printFileList($css); }else{ printFileList($list); } ?>