summaryrefslogtreecommitdiff
path: root/itjs.php
diff options
context:
space:
mode:
Diffstat (limited to 'itjs.php')
-rw-r--r--itjs.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/itjs.php b/itjs.php
new file mode 100644
index 0000000..204235a
--- /dev/null
+++ b/itjs.php
@@ -0,0 +1,57 @@
+<?php
+/*
+** $Id$
+**
+** itjs.php - Delivers /itjs/ files through AliasMatch in httpd.conf
+**
+** ITools - the Internet Tools Library
+**
+** Copyright (C) 1995-2003 by the ITools Authors.
+** This program is free software; you can redistribute it and/or
+** modify it under the terms of either the GNU General Public License
+** or the GNU Lesser General Public License, as published by the Free
+** Software Foundation. See http://www.gnu.org/licenses/ for details.
+*/
+
+require "itools/itools.lib";
+
+if (EDC('slowjs'))
+ sleep(20);
+
+$data = "";
+$files = itjs::filenames(basename($_SERVER['PHP_SELF']));
+
+foreach ($files as $file)
+ $data .= ereg('\.php|\.html$', $file) ? @include($file) : @file_get_contents($file);
+
+$checksum = strlen($data) . itjs::checksum($files);
+
+if (ereg('\.gif$', $file))
+ header("Content-Type: image/gif");
+else if (!ereg('\.html$', $file))
+{
+ if (!$_REQUEST['retry'])
+ ob_start('ob_gzhandler');
+
+ header("Content-Type: application/x-javascript; charset=iso-8859-1");
+}
+
+@header("Etag: $checksum");
+
+if ($checksum != $_SERVER['HTTP_IF_NONE_MATCH'])
+{
+ if ($_REQUEST['init'])
+ $data .= "window.it_boot_init();";
+
+ if ($_REQUEST['boot'])
+ {
+ $data = itjs::strip($data);
+ echo itjs::serialize(array('code' => $data, 'len' => strlen($data)));
+ }
+ else
+ echo itjs::strip($data);
+}
+else
+ header("HTTP/1.0 304 Not Modified");
+
+?>