refactored output buffer functions
This commit is contained in:
@@ -5,6 +5,9 @@ phpMyAdmin - ChangeLog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2006-09-22 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||||
|
* libraries/ob.lib.php: refactored
|
||||||
|
|
||||||
2006-09-21 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
2006-09-21 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||||
* libraries/PMA_List.class.php: new PMA_List class
|
* libraries/PMA_List.class.php: new PMA_List class
|
||||||
* libraries/PMA_List_Database.class.php, left.php, libraries\common.lib.php:
|
* libraries/PMA_List_Database.class.php, left.php, libraries\common.lib.php:
|
||||||
|
@@ -18,38 +18,41 @@
|
|||||||
* because both header and footer functions must know what each other is
|
* because both header and footer functions must know what each other is
|
||||||
* doing.
|
* doing.
|
||||||
*
|
*
|
||||||
|
* @uses $GLOBALS['cfg']['OBGzip']
|
||||||
|
* @uses function_exists()
|
||||||
|
* @uses ini_get()
|
||||||
|
* @uses ob_get_level()
|
||||||
|
* @uses header()
|
||||||
|
* @staticvar integer remember last calculated value
|
||||||
* @return integer the output buffer mode
|
* @return integer the output buffer mode
|
||||||
*/
|
*/
|
||||||
function PMA_outBufferModeGet()
|
function PMA_outBufferModeGet()
|
||||||
{
|
{
|
||||||
if (@function_exists('ob_start')) {
|
static $mode = null;
|
||||||
$mode = 1;
|
|
||||||
} else {
|
if (null !== $mode) {
|
||||||
$mode = 0;
|
return $mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a user sets the output_handler in php.ini to ob_gzhandler, then
|
$mode = 0;
|
||||||
// any right frame file in phpMyAdmin will not be handled properly by
|
|
||||||
// the browser. My fix was to check the ini file within the
|
|
||||||
// PMA_outBufferModeGet() function.
|
|
||||||
//
|
|
||||||
// (Patch by Garth Gillespie, modified by Marc Delisle)
|
|
||||||
if (@ini_get('output_handler') == 'ob_gzhandler') {
|
|
||||||
$mode = 0;
|
|
||||||
}
|
|
||||||
if (@get_cfg_var('output_handler') == 'ob_gzhandler') {
|
|
||||||
$mode = 0;
|
|
||||||
}
|
|
||||||
// End patch
|
|
||||||
|
|
||||||
// If output buffering is enabled in php.ini it's not possible to
|
if ($GLOBALS['cfg']['OBGzip'] && function_exists('ob_start')) {
|
||||||
// add the ob_gzhandler without a warning message from php 4.3.0.
|
if (ini_get('output_handler') == 'ob_gzhandler') {
|
||||||
// Being better safe than sorry, check for any existing output handler
|
// If a user sets the output_handler in php.ini to ob_gzhandler, then
|
||||||
// instead of just checking the 'output_buffering' setting.
|
// any right frame file in phpMyAdmin will not be handled properly by
|
||||||
//
|
// the browser. My fix was to check the ini file within the
|
||||||
if (@function_exists('ob_get_level')) {
|
// PMA_outBufferModeGet() function.
|
||||||
if (ob_get_level() > 0) {
|
//
|
||||||
|
// (Patch by Garth Gillespie, modified by Marc Delisle)
|
||||||
$mode = 0;
|
$mode = 0;
|
||||||
|
} elseif (function_exists('ob_get_level') && ob_get_level() > 0) {
|
||||||
|
// If output buffering is enabled in php.ini it's not possible to
|
||||||
|
// add the ob_gzhandler without a warning message from php 4.3.0.
|
||||||
|
// Being better safe than sorry, check for any existing output handler
|
||||||
|
// instead of just checking the 'output_buffering' setting.
|
||||||
|
$mode = 0;
|
||||||
|
} else {
|
||||||
|
$mode = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,26 +72,23 @@ function PMA_outBufferModeGet()
|
|||||||
* output buffering is turned on. It also needs to be passed $mode from
|
* output buffering is turned on. It also needs to be passed $mode from
|
||||||
* the PMA_outBufferModeGet() function or it will be useless.
|
* the PMA_outBufferModeGet() function or it will be useless.
|
||||||
*
|
*
|
||||||
* @param integer the output buffer mode
|
* @uses PMA_outBufferModeGet()
|
||||||
*
|
* @uses ob_start()
|
||||||
|
* @param integer $mode DEPRECATED
|
||||||
* @return boolean whether output buffering is enabled or not
|
* @return boolean whether output buffering is enabled or not
|
||||||
*/
|
*/
|
||||||
function PMA_outBufferPre($mode)
|
function PMA_outBufferPre($mode = null)
|
||||||
{
|
{
|
||||||
switch($mode)
|
switch(PMA_outBufferModeGet())
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
ob_start('ob_gzhandler');
|
ob_start('ob_gzhandler');
|
||||||
$retval = TRUE;
|
$retval = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
$retval = FALSE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// loic1: php3 fix
|
|
||||||
default:
|
default:
|
||||||
$retval = FALSE;
|
$retval = false;
|
||||||
break;
|
break;
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|
||||||
@@ -101,26 +101,26 @@ function PMA_outBufferPre($mode)
|
|||||||
* buffering is turned on. It also needs to be passed $mode from the
|
* buffering is turned on. It also needs to be passed $mode from the
|
||||||
* PMA_outBufferModeGet() function or it will be useless.
|
* PMA_outBufferModeGet() function or it will be useless.
|
||||||
*
|
*
|
||||||
* @param integer the output buffer mode
|
* @uses PMA_outBufferModeGet()
|
||||||
*
|
* @uses ob_flush()
|
||||||
|
* @uses flush()
|
||||||
|
* @param integer $mode DEPRECATED
|
||||||
* @return boolean whether data has been send from the buffer or not
|
* @return boolean whether data has been send from the buffer or not
|
||||||
*/
|
*/
|
||||||
function PMA_outBufferPost($mode)
|
function PMA_outBufferPost($mode = null)
|
||||||
{
|
{
|
||||||
switch($mode)
|
switch(PMA_outBufferModeGet())
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
# This output buffer doesn't need a footer.
|
# This output buffer doesn't need a footer.
|
||||||
$retval = TRUE;
|
ob_flush();
|
||||||
|
$retval = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
$retval = FALSE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// loic1: php3 fix
|
|
||||||
default:
|
default:
|
||||||
$retval = FALSE;
|
flush();
|
||||||
|
$retval = false;
|
||||||
break;
|
break;
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user