summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--itjs.class11
-rw-r--r--itjs.php31
2 files changed, 20 insertions, 22 deletions
diff --git a/itjs.class b/itjs.class
index e8284ce..d9db666 100644
--- a/itjs.class
+++ b/itjs.class
@@ -158,7 +158,7 @@ static function strip($code)
if (!it::is_devel())
$code = preg_replace(array(
'|\s//.*$|m',
- '|\s+/\*.*?\*/|s', # MUST require at least one space before "/*" (jquery.js) but MUST NOT require space before "*/" (searchmap.js)
+ '|\s+/\*.*?\*/|s', # MUST require at least one space before /* (jquery.js) but MUST NOT require space before */ (searchmap.js)
'|^\s+|m'
), array(), $code);
if (EDC('print'))
@@ -179,14 +179,9 @@ static function checksum($files = array())
$service_itjs = glob($GLOBALS['ULTRAHOME'] . "/itjs/*.{js,css,php}", GLOB_BRACE);
foreach (array_merge($files, $service_itjs, $itools_itjs, array("$itjs/itjs.php", "$itjs/itjs.class")) as $file)
- {
- if (!it::is_devel())
- $result += @filesize($file);
- else
- $result = md5($result . @file_get_contents($file));
- }
+ $allfiles .= $file;
- return $result;
+ return substr(md5($allfiles), 0, 8); # UTF8SAFE
}
}
diff --git a/itjs.php b/itjs.php
index 9f5cc78..65a78fe 100644
--- a/itjs.php
+++ b/itjs.php
@@ -26,6 +26,11 @@ require "itools/itools.lib";
if (EDC('slowjs'))
sleep(20);
+if ($_SERVER['HTTP_IF_NONE_MATCH'] && it::is_live() && !$_REQUEST['retry']) {
+ header("HTTP/1.0 304 Not Modified"); # client should always keep the component that fits the page it has
+ exit;
+}
+
$data = "";
$files = itjs::filenames(it::match('/itjs/([a-z0-9_,.-]*)', $_SERVER['PHP_SELF']));
@@ -64,23 +69,21 @@ else if (!it::match('\.html$', $file))
@header("Etag: $checksum");
-if ($checksum != $_SERVER['HTTP_IF_NONE_MATCH'] || $_REQUEST['retry'])
+if (!preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT']) && it::is_live() && !$_REQUEST['retry'])
{
- if (!preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT']) && it::is_live() && !$_REQUEST['retry'])
- header("Cache-Control: max-age=900");
-
- $data = itjs::strip($data);
+ header("Cache-Control: max-age=604800");
+ header("Expires: " . gmdate("D, d M Y H:i:s", time()+604800). " GMT");
+}
- if ($_REQUEST['boot'])
- {
- $data .= "window.it_boot_init();\n";
- if (!$_REQUEST['script'])
- $data = sprintf("/*sln:%d*/\n%s/*eln:%d*/", grapheme_strlen($data), strtr($data, array('%' => "%25", '.' => "%2e", 'e' => "%65", 'i' => "%69")), grapheme_strlen($data)); # Protect from Firewalls/Proxies altering Javascript source code
- }
+$data = itjs::strip($data);
- echo it_untaint($data);
+if ($_REQUEST['boot'])
+{
+ $data .= "window.it_boot_init();\n";
+ if (!$_REQUEST['script'])
+ $data = sprintf("/*sln:%d*/\n%s/*eln:%d*/", grapheme_strlen($data), strtr($data, array('%' => "%25", '.' => "%2e", 'e' => "%65", 'i' => "%69")), grapheme_strlen($data)); # Protect from Firewalls/Proxies altering Javascript source code
}
-else
- header("HTTP/1.0 304 Not Modified");
+
+echo it_untaint($data);
?>