WebCalendar PHP Cross Reference Groupware Applications

Source: /js_cacher.php - 71 lines - 2350 bytes - Summary - Text - Print

   1  <?php
   2  /* $Id: js_cacher.php,v 1.15.2.3 2010/08/16 18:33:11 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    // Kludge - we don't have access to the db from this script (for performance
  31    // reasons... so just use EST for the timezone.
  32    if ( function_exists ( "date_default_timezone_set" ) )
  33      date_default_timezone_set ( "America/New_York");
  34    header ( 'Last-Modified: ' . date ( 'r', mktime ( 0, 0, 0 ) + $cookie ) );
  35    header ( 'Expires: ' . date ( 'D, j M Y H:i:s', time () + 86400 ) . ' UTC' );
  36    header ( 'Cache-Control: Public' );
  37    header ( 'Pragma: Public' );
  38  } else {
  39    include  'includes/translate.php';
  40    include  'includes/config.php';
  41    include  'includes/dbi4php.php';
  42    include  'includes/formvars.php';
  43    include  'includes/functions.php';
  44  
  45    do_config ( 'includes/settings.php' );
  46    include 'includes/' . $user_inc;
  47    include_once  'includes/access.php';
  48    include_once  'includes/validate.php';
  49    include_once  'includes/gradient.php';
  50  
  51    load_global_settings ();
  52    @session_start ();
  53    $login = ( empty ( $_SESSION['webcal_login'] )
  54      ? '__public__' : $_SESSION['webcal_login'] );
  55  
  56    load_user_preferences ();
  57  
  58    send_no_cache_header ();
  59  }
  60  
  61  // We don't want to compress for IE6 because of 'object expected' errors.
  62  if ( ini_get ( 'zlib.output_compression' ) != 1 && !
  63      stristr ( $_SERVER['HTTP_USER_AGENT'], 'MSIE 6' ) )
  64    ob_start ( 'ob_gzhandler' );
  65  
  66  // We only allow includes if they exist in our includes/js directory, or HTMLarea
  67  $newinc = 'includes/' . $arinc[0] . '/' . $arinc[1];
  68  if ( is_file ( $newinc ) && in_array ( $arinc[1], $fileList ) )
  69    include_once ( $newinc );
  70  
  71  ?>

title

Description

title

Description

title

Description

title

title

Body