. ** ** itjs.php - Delivers /itjs/ files through AliasMatch in httpd.conf */ require "itools/itools.lib"; if (EDC('slow' . it::match('\.(\w+)$', $_SERVER['PHP_SELF']))) sleep(10); $crc = $_REQUEST['c'] ?: $_REQUEST['s']; if (false && $crc != "-" && !$_SERVER['HTTP_CACHE_CONTROL'] && $_SERVER['HTTP_IF_NONE_MATCH'] && !it::is_devel() && !$_REQUEST['retry']) { header("HTTP/1.0 304 Not Modified"); # client should always keep the component that fits the page it has exit; } if (!$GLOBALS['ULTRAHOME']) exit; # useless here. cannot write tempfiles $files = itjs::filenames($_GET['files'] ?: it::match('/itjs/([-a-z0-9_,.]*)', $_SERVER['PHP_SELF'])); $data = itjs::filecontents($files); $file = end($files); if (it::match('\.gif$', $file)) { header("Content-Type: image/gif"); } else if (it::match('\.css', $_SERVER['PHP_SELF'])) { header("Content-Type: text/css"); $data .= "\n#it_boot_dom { display:none }\n"; # Append magic style for it_boot if (!it::match('^devel', $GLOBALS['ULTRASERVERTYPE'])) $data = it::replace(array('[ \t]*([{};])[ \t]*' => '$1', '/\*.*?\*/' => ""), $data); if (it::match('W3C_CSS_Validator', $_SERVER['HTTP_USER_AGENT']) || EDC('w3c')) $data = it::replace(array( '@-.*' => "", 'background[^;}]*(gradient|rgba)[^;}]*;?' => "", '(filter:\s*(progid|none)|text-overflow:|zoom:|-webkit-|display:-moz-|-moz-|-o-|cursor:|border-radius:|behavior:|\w+:expression)[^;}]*;?' => "", 'pointer-events:[^;}]*' => "", 'html\.ie6.*' => "", ':valid:' => ":", # hack for iOS datetime '([^/])\*(\w)' => '$1$2'), $data ); } else if (it::match('\.htc$', $file)) { header("Content-Type: text/x-component"); } else if (!it::match('\.html$', $file)) { $data = "window.trace+='i';\n$data\nwindow.trace+='I';\n"; $data .= "\nwindow.it_gotjs = (window.it_gotjs ? window.it_gotjs : '') + '." . it::match('\w+', basename($file)) . "';\n"; $charset = ini_get('default_charset') ?: 'iso-8859-1'; header("Content-Type: application/x-javascript; charset=$charset"); } @header("Etag: alwaysvalid"); # we have checksums in the url. client should always keep the version he downloaded along with the html if (it::is_live() && !$_REQUEST['retry']) { $keeptime = $crc == "-" ? 0 : ($crc ? 900 : 900); # long expire if checksum present DISABLED header("Cache-Control: max-age=$keeptime, private"); # proxies should not cache since contents of same url can differ between browsers header("Expires: " . gmdate("D, d M Y H:i:s", time() + $keeptime). " GMT"); } $data = itjs::strip($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 } echo it_untaint($data); ?>