diff options
author | Christian Schneider | 2016-01-29 15:28:34 +0100 |
---|---|---|
committer | Christian Schneider | 2016-01-29 15:28:34 +0100 |
commit | 55535adc55f85d76dc6da7e2225261b24e3d3a3a (patch) | |
tree | e78ca49193f4f85d6f53f47e60640306c698d595 /itjs.class | |
parent | b3e0bc32f74878216fe09c846d30f375e082ff9a (diff) | |
download | itools-55535adc55f85d76dc6da7e2225261b24e3d3a3a.tar.gz itools-55535adc55f85d76dc6da7e2225261b24e3d3a3a.tar.bz2 itools-55535adc55f85d76dc6da7e2225261b24e3d3a3a.zip |
Improved version of 0b595fb/80c5bcd which decides for each file individually if it has to be passed through php
Diffstat (limited to 'itjs.class')
-rw-r--r-- | itjs.class | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -146,7 +146,7 @@ static function filenames($filelist) /** * Return (php-interpreted by default) files that will be sent to client. Files must exist. */ -static function filecontents($filenames, $execphp = true) +static function filecontents($filenames) { foreach ($filenames as $filename) { @@ -155,9 +155,9 @@ static function filecontents($filenames, $execphp = true) { $origget = $_GET; list($filename, $paramstr) = explode("?", $filename); - if ($paramstr && $execphp) + if ($paramstr) parse_str($paramstr, $_GET); - $result .= it::replace(array('^1$' => ""), $execphp ? include($filename) : file_get_contents($filename), array('utf8' => false)); + $result .= it::replace(array('^1$' => ""), it::match('\.(js|css)$', $filename) ? include($filename) : file_get_contents($filename), array('utf8' => false)); $_GET = $origget; } $result .= ob_get_clean(); @@ -198,15 +198,12 @@ static function checksum($fnlist, $p = array()) foreach (is_array($fnlist) ? $fnlist : itjs::filenames($fnlist) as $filename) $filenames[] = !file_exists($filename) && file_exists($t = it::replace(array('^/www/[^/]*' => "/www/lib.search.ch"), $filename)) ? $t : $filename; - if (preg_grep('/jquery(build)\.js/', $filenames)) # jquery files may be included invisibly - $filenames = array_merge($filenames, array("/www/lib.search.ch/var/jquery-ui/dist/minified/core.min.js", "/www/lib.search.ch/var/jquery/dist/jquery.min.js")); - $key = "itjs_" . md5(join("", it::map('"$v" . @filemtime("$v")', $filenames))); if ($filenames && $p['short_expire'] && (time() - max(@array_map('filemtime', $filenames)) < 60)) return "-"; # trigger short expire, our file may not yet be up to date on other slaves else if ($filenames) - return it_cache::get($key) ?: it_cache::put($key, substr(md5(self::filecontents($filenames, false)), 0, 10), array('ttl' => 60)); + return it_cache::get($key) ?: it_cache::put($key, substr(md5(self::filecontents($filenames)), 0, 10), array('ttl' => 60)); } /** |