diff options
author | Urban Müller | 2013-10-18 13:29:35 +0000 |
---|---|---|
committer | Urban Müller | 2013-10-18 13:29:35 +0000 |
commit | 38ad0880d982d4c449a4f2cf26e91fa6af86b149 (patch) | |
tree | 01f5bf84ef4eb8502fbc2fc309db58206765b490 /itjs.class | |
parent | 6583f6132f88a32ba4aa8a40533f664201e175a4 (diff) | |
download | itools-38ad0880d982d4c449a4f2cf26e91fa6af86b149.tar.gz itools-38ad0880d982d4c449a4f2cf26e91fa6af86b149.tar.bz2 itools-38ad0880d982d4c449a4f2cf26e91fa6af86b149.zip |
cleaner solution: execute php but ignore reset headers when computing checksum
Diffstat (limited to 'itjs.class')
-rw-r--r-- | itjs.class | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -151,13 +151,13 @@ static function filenames($filelist) /** * Return (interpreted) files that will be sent to client */ -static function filecontents($filenames, $execphp = true) +static function filecontents($filenames) { foreach ($filenames as $filename) { ob_start(); # Needs to capture inside loop to guarantee file order if (!(it::match('W3C_CSS_Validator', $_SERVER['HTTP_USER_AGENT']) && it::match('jquery-ui\.css', $filename))) - $result .= it::replace(array('^1$' => ""), $execphp ? @include($filename) : file_get_contents($filename), array('utf8' => false)); + $result .= it::replace(array('^1$' => ""), @include($filename), array('utf8' => false)); $result .= ob_get_clean(); } @@ -191,8 +191,16 @@ static function strip($code) static function checksum($fnlist) { $key = "itjs_" . md5(join("", it::map('"$v" . filemtime("$v")', is_array($fnlist) ? $fnlist : itjs::filenames($fnlist)))); + if (!($result = it_cache::get($key))) + { + $origheaders = headers_list(); + $result = it_cache::put($key, substr(md5(itjs::filecontents(is_array($fnlist) ? $fnlist : itjs::filenames($fnlist), false)), 0, 8)); + header_remove(); + foreach ($origheaders as $origheader) + header($origheader); # included filecontents might have modified Content-Type + } - return it_cache::get($key) ?: it_cache::put($key, substr(md5(self::filecontents(is_array($fnlist) ? $fnlist : itjs::filenames($fnlist), false)), 0, 8)); + return $result; } } |