home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / libraries / ob.lib.php < prev    next >
Encoding:
PHP Script  |  2008-06-23  |  3.3 KB  |  108 lines

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