summaryrefslogtreecommitdiff
path: root/itjs.php
blob: 3cd2f47f333d9f00951d45c6a951a367363fd42e (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
<?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 ($_REQUEST['boot'])
		$data = preg_replace('/([\xa0-\xff])/e', 'sprintf("\\u%04x", ord("\\1"))', $data) . "window.it_boot_init();";

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

?>