~ubuntu-branches/ubuntu/raring/webcalendar/raring

« back to all changes in this revision

Viewing changes to js_cacher.php

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2009-06-09 06:26:24 UTC
  • mfrom: (18.2.3 karmic)
  • Revision ID: james.westby@ubuntu.com-20090609062624-9n9xea2ftpipmg38
Tags: 1.2.0+dfsg-4
* debian/patches/06_send-reminder-paths.diff: Adjust patch to help
  translate.php to find the translation files under /etc/webcalendar.
  Thanks to Dale and Cheryl Schroeder for the help on debugging this
  (really, closes: #531312).
* debian/patches/16_no-blink-public-access-title.diff: New patch for
  avoiding the blinking title when changing the Public Access title in
  English-US.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
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 );
 
6
 
 
7
if ( empty ( $inc ) )
 
8
  $inc = $_GET['inc'];
 
9
 
 
10
if ( empty ( $inc ) && ! empty ( $_REQUEST['inc'] ) )
 
11
  $inc = $_REQUEST['inc'];
 
12
 
 
13
$arinc = explode ( '/', $inc );
 
14
 
 
15
if ( $arinc[0] != 'js' && $arinc[0] != 'htmlarea' )
 
16
  return false;
 
17
 
 
18
// Get list of files in the js directory.
 
19
$myDirectory = opendir ( 'includes/' . $arinc[0] );
 
20
while ( $fileName = readdir ( $myDirectory ) ) {
 
21
  $fileList[] = $fileName;
 
22
}
 
23
closedir ( $myDirectory );
 
24
 
 
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 );
 
29
 
 
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' );
 
34
} else {
 
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';
 
40
 
 
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';
 
46
 
 
47
  load_global_settings ();
 
48
  @session_start ();
 
49
  $login = ( empty ( $_SESSION['webcal_login'] )
 
50
    ? '__public__' : $_SESSION['webcal_login'] );
 
51
 
 
52
  load_user_preferences ();
 
53
 
 
54
  send_no_cache_header ();
 
55
}
 
56
 
 
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' );
 
61
 
 
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 );
 
66
 
 
67
?>