home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / phptriad / phptriad2-2-1.exe / htdocs / phpmyadmin / libraries / ob.lib.php < prev    next >
PHP Script  |  2002-01-06  |  4KB  |  125 lines

  1. <?php
  2. /* $Id: ob.lib.php,v 1.3 2001/11/23 01:04:57 loic1 Exp $ */
  3.  
  4.  
  5. if (!defined('PMA_OB_LIB_INCLUDED')) {
  6.     define('PMA_OB_LIB_INCLUDED', 1);
  7.  
  8.     # Output buffer functions for phpMyAdmin
  9.     #
  10.     # Copyright 2001 Jeremy Brand <jeremy@nirvani.net>
  11.     # http://www.jeremybrand.com/Jeremy/Brand/Jeremy_Brand.html
  12.     #
  13.     # Check for all the needed functions for output buffering
  14.     # Make some wrappers for the top and bottoms of our files.
  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.      * @return  integer  the output buffer mode
  22.      */
  23.     function PMA_outBufferModeGet()
  24.     {
  25.         if (PMA_PHP_INT_VERSION >= 40000 && @function_exists('ob_start')) {
  26.             $mode = 1;
  27.         } else {
  28.             $mode = 0;
  29.         }
  30.  
  31.         // If a user sets the output_handler in php.ini to ob_gzhandler, then
  32.         // any right frame file in phpMyAdmin will not be handled properly by
  33.         // the browser. My fix was to check the ini file within the
  34.         // PMA_outBufferModeGet() function.
  35.         //
  36.         // (Patch by Garth Gillespie, modified by Marc Delisle)
  37.         if (PMA_PHP_INT_VERSION >= 40000 && @ini_get('output_handler')) {
  38.             if (@ini_get('output_handler') == 'ob_gzhandler') {
  39.                 $mode = 0;
  40.             }
  41.         } else if (PMA_PHP_INT_VERSION >= 40000) {
  42.             if (@get_cfg_var('output_handler') == 'ob_gzhandler') {
  43.                 $mode = 0;
  44.             }
  45.         }
  46.         // End patch
  47.  
  48.         // Zero (0) is no mode or in other words output buffering is OFF.
  49.         // Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
  50.         // Usefull if we ever decide to combine modes.  Then a bitmask field of
  51.         // the sum of all modes will be the natural choice.
  52.  
  53.         header('X-ob_mode: ' . $mode);
  54.  
  55.         return $mode;
  56.     } // end of the 'PMA_outBufferModeGet()' function
  57.  
  58.  
  59.     /**
  60.      * This function will need to run at the top of all pages if output
  61.      * output buffering is turned on.  It also needs to be passed $mode from
  62.      * the PMA_outBufferModeGet() function or it will be useless.
  63.      *
  64.      * @param   integer  the output buffer mode
  65.      *
  66.      * @return  boolean  whether output buffering is enabled or not
  67.      */
  68.     function PMA_outBufferPre($mode)
  69.     {
  70.         switch($mode)
  71.         {
  72.             case 1:
  73.                 ob_start('ob_gzhandler');
  74.                 $retval = TRUE;
  75.                 break;
  76.  
  77.             case 0:
  78.                 $retval = FALSE;
  79.                 break;
  80.  
  81.             // loic1: php3 fix
  82.             default:
  83.                 $retval = FALSE;
  84.                 break;
  85.         } // end switch
  86.  
  87.         return $retval;
  88.     } // end of the 'PMA_outBufferPre()' function
  89.  
  90.  
  91.     /**
  92.      * This function will need to run at the bottom of all pages if output
  93.      * buffering is turned on.  It also needs to be passed $mode from the
  94.      * PMA_outBufferModeGet() function or it will be useless.
  95.      *
  96.      * @param   integer  the output buffer mode
  97.      *
  98.      * @return  boolean  whether data has been send from the buffer or not
  99.      */     
  100.     function PMA_outBufferPost($mode)
  101.     {
  102.         switch($mode)
  103.         {
  104.             case 1:
  105.                 # This output buffer doesn't need a footer.
  106.                 $retval = TRUE;
  107.                 break;
  108.  
  109.             case 0:
  110.                 $retval = FALSE;
  111.                 break;
  112.  
  113.             // loic1: php3 fix
  114.             default:
  115.                 $retval = FALSE;
  116.                 break;
  117.         } // end switch
  118.  
  119.         return $retval;
  120.     } // end of the 'PMA_outBufferPost()' function
  121.  
  122. } // $__PMA_OB_LIB__
  123.  
  124. ?>
  125.