2
/* $Id: js_cacher.php,v 1.15.2.1 2007/09/17 02:39:21 cknudsen Exp $ */
3
// If the javascript doesn't need any input from php,
4
// then we can cache it and not run init.php.
5
define ( '_ISVALID', true );
10
if ( empty ( $inc ) && ! empty ( $_REQUEST['inc'] ) )
11
$inc = $_REQUEST['inc'];
13
$arinc = explode ( '/', $inc );
15
if ( $arinc[0] != 'js' && $arinc[0] != 'htmlarea' )
18
// Get list of files in the js directory.
19
$myDirectory = opendir ( 'includes/' . $arinc[0] );
20
while ( $fileName = readdir ( $myDirectory ) ) {
21
$fileList[] = $fileName;
23
closedir ( $myDirectory );
25
header ( 'Content-type: text/javascript' );
26
if ( ( ! empty ( $arinc[2] ) && stristr ( $arinc[2], 'true' ) ) ) {
27
$cookie = ( isset ( $_COOKIE['webcalendar_csscache'] )
28
? $_COOKIE['webcalendar_csscache'] : 0 );
30
header ( 'Last-Modified: ' . date ( 'r', mktime ( 0, 0, 0 ) + $cookie ) );
31
header ( 'Expires: ' . date ( 'D, j M Y H:i:s', time () + 86400 ) . ' UTC' );
32
header ( 'Cache-Control: Public' );
33
header ( 'Pragma: Public' );
35
include 'includes/translate.php';
36
include 'includes/config.php';
37
include 'includes/dbi4php.php';
38
include 'includes/formvars.php';
39
include 'includes/functions.php';
41
do_config ( 'includes/settings.php' );
42
include 'includes/' . $user_inc;
43
include_once 'includes/access.php';
44
include_once 'includes/validate.php';
45
include_once 'includes/gradient.php';
47
load_global_settings ();
49
$login = ( empty ( $_SESSION['webcal_login'] )
50
? '__public__' : $_SESSION['webcal_login'] );
52
load_user_preferences ();
54
send_no_cache_header ();
57
// We don't want to compress for IE6 because of 'object expected' errors.
58
if ( ini_get ( 'zlib.output_compression' ) != 1 && !
59
stristr ( $_SERVER['HTTP_USER_AGENT'], 'MSIE 6' ) )
60
ob_start ( 'ob_gzhandler' );
62
// We only allow includes if they exist in our includes/js directory, or HTMLarea
63
$newinc = 'includes/' . $arinc[0] . '/' . $arinc[1];
64
if ( is_file ( $newinc ) && in_array ( $arinc[1], $fileList ) )
65
include_once ( $newinc );