[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/Web/Javascripts/js/debug/ -> clientscripts.php (source)

   1  <?php
   2  /**
   3   * This file compresses the javascript files using GZip
   4   *
   5   * Todo:
   6   *  - Add local file cache for the GZip:ed version.
   7   */
   8  
   9  $debugMode=(isset($_GET['mode']) && $_GET['mode']==='debug');
  10  
  11  // if debug mode, js is not cached; otherwise cached for 10 days.
  12  $expiresOffset = $debugMode ? -10000 : 3600 * 24 * 10; //no cache
  13  
  14  //allowed libraries
  15  $library = array('prado', 'effects', 'ajax', 'validator', 'logger', 'datepicker', 'rico', 'colorpicker');
  16  
  17  $param = isset($_GET['js']) ? $_GET['js'] : '';
  18  
  19  //check for proper matching parameters, otherwise exit;
  20  if(preg_match('/(\w)+(,\w+)*/', $param)) $js = explode(',', $param); else exit();
  21  foreach($js as $lib) if(!in_array($lib, $library)) exit();
  22  
  23  // Only gzip the contents if clients and server support it
  24  if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
  25      $encodings = explode(',', strtolower($_SERVER['HTTP_ACCEPT_ENCODING']));
  26  else
  27      $encodings = array();
  28  
  29  // Check for gzip header or northon internet securities
  30  if ((in_array('gzip', $encodings) || isset($_SERVER['---------------']))
  31          && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')
  32          && ini_get('output_handler') != 'ob_gzhandler')
  33      ob_start("ob_gzhandler");
  34  
  35  // Output rest of headers
  36  header('Content-type: text/javascript; charset: UTF-8');
  37  // header("Cache-Control: must-revalidate");
  38  header('Vary: Accept-Encoding'); // Handle proxies
  39  header('Expires: ' . @gmdate('D, d M Y H:i:s', @time() + $expiresOffset) . ' GMT');
  40  
  41  if ($debugMode)
  42  {
  43      foreach($js as $lib)
  44      {
  45          $file = realpath($lib.'.js');
  46          if(is_file($file))
  47              echo file_get_contents($file);
  48          else //log missings files to console logger
  49          {
  50              echo 'setTimeout(function(){ if(Logger) Logger.error("Missing file", "'.$lib.'.js"); }, 1000);';
  51              error_log("Unable to find asset file {$lib}.js");
  52          }
  53      }
  54  }
  55  else
  56  {
  57      foreach($js as $lib)
  58          echo file_get_contents($lib.'.js');
  59  }
  60  
  61  ?>


Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7