Rev Author Line No. Line
250 kaklik 1 <?php
2 /* $Id: ob.lib.php,v 2.2 2003/11/26 22:52:23 rabus Exp $ */
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 * @return integer the output buffer mode
22 */
23 function PMA_outBufferModeGet()
24 {
25 if (@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 (@ini_get('output_handler') == 'ob_gzhandler') {
38 $mode = 0;
39 }
40 if (@get_cfg_var('output_handler') == 'ob_gzhandler') {
41 $mode = 0;
42 }
43 // End patch
44  
45 // If output buffering is enabled in php.ini it's not possible to
46 // add the ob_gzhandler without a warning message from php 4.3.0.
47 // Being better safe than sorry, check for any existing output handler
48 // instead of just checking the 'output_buffering' setting.
49 //
50 if (@function_exists('ob_get_level')) {
51 if (ob_get_level() > 0) {
52 $mode = 0;
53 }
54 }
55  
56 // Zero (0) is no mode or in other words output buffering is OFF.
57 // Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
58 // Usefull if we ever decide to combine modes. Then a bitmask field of
59 // the sum of all modes will be the natural choice.
60  
61 header('X-ob_mode: ' . $mode);
62  
63 return $mode;
64 } // end of the 'PMA_outBufferModeGet()' function
65  
66  
67 /**
68 * This function will need to run at the top of all pages if output
69 * output buffering is turned on. It also needs to be passed $mode from
70 * the PMA_outBufferModeGet() function or it will be useless.
71 *
72 * @param integer the output buffer mode
73 *
74 * @return boolean whether output buffering is enabled or not
75 */
76 function PMA_outBufferPre($mode)
77 {
78 switch($mode)
79 {
80 case 1:
81 ob_start('ob_gzhandler');
82 $retval = TRUE;
83 break;
84  
85 case 0:
86 $retval = FALSE;
87 break;
88  
89 // loic1: php3 fix
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 * @param integer the output buffer mode
105 *
106 * @return boolean whether data has been send from the buffer or not
107 */
108 function PMA_outBufferPost($mode)
109 {
110 switch($mode)
111 {
112 case 1:
113 # This output buffer doesn't need a footer.
114 $retval = TRUE;
115 break;
116  
117 case 0:
118 $retval = FALSE;
119 break;
120  
121 // loic1: php3 fix
122 default:
123 $retval = FALSE;
124 break;
125 } // end switch
126  
127 return $retval;
128 } // end of the 'PMA_outBufferPost()' function
129  
130 ?>