summaryrefslogtreecommitdiff
path: root/itjs.php
blob: 818f9b8b04f03aaf63dece17fb4944f6ed90ae5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?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['boot'] && !$_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 (!preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT']))
		header("Cache-Control: max-age=900");

	$data = itjs::strip($data);

	if ($_REQUEST['boot'])
	{
		$data .= "window.it_boot_init();\n";
		$data .= sprintf("/*sln:% 8d*/", strlen($data) + 16);
	}

	echo $data;
}
else
	header("HTTP/1.0 304 Not Modified");

?>