[ Index ]
 

Code source de phpMyAdmin 2.10.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/libraries/ -> ob.lib.php (source)

   1  <?php
   2  /* $Id: ob.lib.php 9442 2006-09-22 11:58:39Z cybot_tm $ */
   3  // vim: expandtab sw=4 ts=4 sts=4:
   4  
   5  
   6  /**
   7   * Output buffer functions for phpMyAdmin
   8   *
   9   * Copyright 2001 Jeremy Brand <jeremy@nirvani.net>
  10   * http://www.jeremybrand.com/Jeremy/Brand/Jeremy_Brand.html
  11   *
  12   * Check for all the needed functions for output buffering
  13   * Make some wrappers for the top and bottoms of our files.
  14   */
  15  
  16  /**
  17   * This function be used eventually to support more modes.  It is needed
  18   * because both header and footer functions must know what each other is
  19   * doing.
  20   *
  21   * @uses    $GLOBALS['cfg']['OBGzip']
  22   * @uses    function_exists()
  23   * @uses    ini_get()
  24   * @uses    ob_get_level()
  25   * @uses    header()
  26   * @staticvar integer remember last calculated value
  27   * @return  integer  the output buffer mode
  28   */
  29  function PMA_outBufferModeGet()
  30  {
  31      static $mode = null;
  32  
  33      if (null !== $mode) {
  34          return $mode;
  35      }
  36  
  37      $mode = 0;
  38  
  39      if ($GLOBALS['cfg']['OBGzip'] && function_exists('ob_start')) {
  40          if (ini_get('output_handler') == 'ob_gzhandler') {
  41              // If a user sets the output_handler in php.ini to ob_gzhandler, then
  42              // any right frame file in phpMyAdmin will not be handled properly by
  43              // the browser. My fix was to check the ini file within the
  44              // PMA_outBufferModeGet() function.
  45              //
  46              // (Patch by Garth Gillespie, modified by Marc Delisle)
  47              $mode = 0;
  48          } elseif (function_exists('ob_get_level') && ob_get_level() > 0) {
  49              // If output buffering is enabled in php.ini it's not possible to
  50              // add the ob_gzhandler without a warning message from php 4.3.0.
  51              // Being better safe than sorry, check for any existing output handler
  52              // instead of just checking the 'output_buffering' setting.
  53              $mode = 0;
  54          } else {
  55              $mode = 1;
  56          }
  57      }
  58  
  59      // Zero (0) is no mode or in other words output buffering is OFF.
  60      // Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
  61      // Usefull if we ever decide to combine modes.  Then a bitmask field of
  62      // the sum of all modes will be the natural choice.
  63  
  64      header('X-ob_mode: ' . $mode);
  65  
  66      return $mode;
  67  } // end of the 'PMA_outBufferModeGet()' function
  68  
  69  
  70  /**
  71   * This function will need to run at the top of all pages if output
  72   * output buffering is turned on.  It also needs to be passed $mode from
  73   * the PMA_outBufferModeGet() function or it will be useless.
  74   *
  75   * @uses    PMA_outBufferModeGet()
  76   * @uses    ob_start()
  77   * @param   integer  $mode  DEPRECATED
  78   * @return  boolean  whether output buffering is enabled or not
  79   */
  80  function PMA_outBufferPre($mode = null)
  81  {
  82      switch(PMA_outBufferModeGet())
  83      {
  84          case 1:
  85              ob_start('ob_gzhandler');
  86              $retval = true;
  87              break;
  88  
  89          case 0:
  90          default:
  91              $retval = false;
  92              break;
  93      } // end switch
  94  
  95      return $retval;
  96  } // end of the 'PMA_outBufferPre()' function
  97  
  98  
  99  /**
 100   * This function will need to run at the bottom of all pages if output
 101   * buffering is turned on.  It also needs to be passed $mode from the
 102   * PMA_outBufferModeGet() function or it will be useless.
 103   *
 104   * @uses    PMA_outBufferModeGet()
 105   * @uses    ob_flush()
 106   * @uses    flush()
 107   * @param   integer  $mode  DEPRECATED
 108   * @return  boolean  whether data has been send from the buffer or not
 109   */
 110  function PMA_outBufferPost($mode = null)
 111  {
 112      switch(PMA_outBufferModeGet())
 113      {
 114          case 1:
 115              # This output buffer doesn't need a footer.
 116              ob_flush();
 117              $retval = true;
 118              break;
 119  
 120          case 0:
 121          default:
 122              flush();
 123              $retval = false;
 124              break;
 125      } // end switch
 126  
 127      return $retval;
 128  } // end of the 'PMA_outBufferPost()' function
 129  
 130  ?>


Généré le : Mon Nov 26 15:18:20 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics