Refresh .po files
[phpmyadmin/madhuracj.git] / libraries / ob.lib.php
blob14f3202315d3e4ea2e09bf07fced97d3983703a7
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Output buffer functions for phpMyAdmin
6 * Copyright 2001 Jeremy Brand <jeremy@nirvani.net>
7 * http://www.jeremybrand.com/Jeremy/Brand/Jeremy_Brand.html
9 * Check for all the needed functions for output buffering
10 * Make some wrappers for the top and bottoms of our files.
12 * @package phpMyAdmin
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.
20 * @staticvar integer remember last calculated value
21 * @return integer the output buffer mode
23 function PMA_outBufferModeGet()
25 static $mode = null;
27 if (null !== $mode) {
28 return $mode;
31 $mode = 0;
33 if ($GLOBALS['cfg']['OBGzip'] && function_exists('ob_start')) {
34 if (ini_get('output_handler') == 'ob_gzhandler') {
35 // If a user sets the output_handler in php.ini to ob_gzhandler, then
36 // any right frame file in phpMyAdmin will not be handled properly by
37 // the browser. My fix was to check the ini file within the
38 // PMA_outBufferModeGet() function.
39 $mode = 0;
40 } elseif (function_exists('ob_get_level') && ob_get_level() > 0) {
41 // If output buffering is enabled in php.ini it's not possible to
42 // add the ob_gzhandler without a warning message from php 4.3.0.
43 // Being better safe than sorry, check for any existing output handler
44 // instead of just checking the 'output_buffering' setting.
45 $mode = 0;
46 } else {
47 $mode = 1;
51 // Zero (0) is no mode or in other words output buffering is OFF.
52 // Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
53 // Usefull if we ever decide to combine modes. Then a bitmask field of
54 // the sum of all modes will be the natural choice.
56 return $mode;
57 } // end of the 'PMA_outBufferModeGet()' function
60 /**
61 * This function will need to run at the top of all pages if output
62 * output buffering is turned on. It also needs to be passed $mode from
63 * the PMA_outBufferModeGet() function or it will be useless.
66 function PMA_outBufferPre()
68 if ($mode = PMA_outBufferModeGet()) {
69 ob_start('ob_gzhandler');
72 header('X-ob_mode: ' . $mode);
74 register_shutdown_function('PMA_outBufferPost');
75 } // end of the 'PMA_outBufferPre()' function
78 /**
79 * This function will need to run at the bottom of all pages if output
80 * buffering is turned on. It also needs to be passed $mode from the
81 * PMA_outBufferModeGet() function or it will be useless.
84 function PMA_outBufferPost()
86 if (ob_get_status() && PMA_outBufferModeGet()) {
87 ob_flush();
89 /**
90 * previously we had here an "else flush()" but some PHP versions
91 * (at least PHP 5.2.11) have a bug (49816) that produces garbled
92 * data
94 } // end of the 'PMA_outBufferPost()' function