Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 435 lines (374 sloc) 12.613 kB
9f6ee3e Everyone seemed to prefer lower case API filenames and I had a few sp…
Julian Fitzell authored
1 <?php
4d63b48 @siebrand Mantis -> MantisBT in file headers, comments, and elsewhere.
siebrand authored
2 # MantisBT - a php based bugtracking system
72da4a7 @grangeway PHPDOC changes
grangeway authored
3
4d63b48 @siebrand Mantis -> MantisBT in file headers, comments, and elsewhere.
siebrand authored
4 # MantisBT is free software: you can redistribute it and/or modify
2669909 @giallu Merge back to HEAD the changes between tags:
giallu authored
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
8 #
4d63b48 @siebrand Mantis -> MantisBT in file headers, comments, and elsewhere.
siebrand authored
9 # MantisBT is distributed in the hope that it will be useful,
2669909 @giallu Merge back to HEAD the changes between tags:
giallu authored
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
4d63b48 @siebrand Mantis -> MantisBT in file headers, comments, and elsewhere.
siebrand authored
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
3f4914c @siebrand Consistency updates
siebrand authored
16
17 /**
18 * @package CoreAPI
19 * @subpackage ErrorAPI
72da4a7 @grangeway PHPDOC changes
grangeway authored
20 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
4d63b48 @siebrand Mantis -> MantisBT in file headers, comments, and elsewhere.
siebrand authored
21 * @copyright Copyright (C) 2002 - 2009 MantisBT Team - mantisbt-dev@lists.sourceforge.net
72da4a7 @grangeway PHPDOC changes
grangeway authored
22 * @link http://www.mantisbt.org
3f4914c @siebrand Consistency updates
siebrand authored
23 */
24
25 # Error API
26 # set up error_handler() as the new default error handling function
27 set_error_handler( 'error_handler' );
28
29 # ########################################
30 # SECURITY NOTE: these globals are initialized here to prevent them
31 # being spoofed if register_globals is turned on
32 #
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
33 $g_error_parameters = array();
3f4914c @siebrand Consistency updates
siebrand authored
34 $g_error_handled = false;
35 $g_error_proceed_url = null;
36
7a111a5 @grangeway PHPDoc updates
grangeway authored
37 /**
38 * Default error handler
39 *
40 * This handler will not receive E_ERROR, E_PARSE, E_CORE_*, or E_COMPILE_*
41 * errors.
42 *
43 * E_USER_* are triggered by us and will contain an error constant in $p_error
44 * The others, being system errors, will come with a string in $p_error
45 *
46 * @access private
47 * @param int p_type contains the level of the error raised, as an integer.
48 * @param string p_error contains the error message, as a string.
49 * @param string p_file contains the filename that the error was raised in, as a string.
50 * @param int p_line contains the line number the error was raised at, as an integer.
51 * @param array p_context to the active symbol table at the point the error occurred (optional)
52 * @uses lang_api.php
53 * @uses config_api.php
54 * @uses compress_api.php
55 * @uses database_api.php (optional)
56 * @uses html_api.php (optional)
57 */
3f4914c @siebrand Consistency updates
siebrand authored
58 function error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) {
59 global $g_error_parameters, $g_error_handled, $g_error_proceed_url;
60 global $g_lang_overrides;
61 global $g_error_send_page_header;
62
63 # check if errors were disabled with @ somewhere in this call chain
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
64 if( 0 == error_reporting() ) {
3f4914c @siebrand Consistency updates
siebrand authored
65 return;
66 }
67
68 $t_lang_pushed = false;
9f6ee3e Everyone seemed to prefer lower case API filenames and I had a few sp…
Julian Fitzell authored
69
3f4914c @siebrand Consistency updates
siebrand authored
70 $t_db_connected = false;
71 if( function_exists( 'db_is_connected' ) ) {
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
72 if( db_is_connected() ) {
3f4914c @siebrand Consistency updates
siebrand authored
73 $t_db_connected = true;
b241ef7 * core/error_api.php
Julian Fitzell authored
74 }
3f4914c @siebrand Consistency updates
siebrand authored
75 }
76 $t_html_api = false;
77 if( function_exists( 'html_end' ) ) {
78 $t_html_api = true;
79 }
b241ef7 * core/error_api.php
Julian Fitzell authored
80
3f4914c @siebrand Consistency updates
siebrand authored
81 # flush any language overrides to return to user's natural default
82 if( $t_db_connected ) {
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
83 lang_push( lang_get_default() );
3f4914c @siebrand Consistency updates
siebrand authored
84 $t_lang_pushed = true;
85 }
86
87 $t_short_file = basename( $p_file );
88 $t_method_array = config_get_global( 'display_errors' );
89 if( isset( $t_method_array[$p_type] ) ) {
90 $t_method = $t_method_array[$p_type];
a8f55d5 @grangeway Inconsistent if-else block format.
grangeway authored
91 } else {
3f4914c @siebrand Consistency updates
siebrand authored
92 if( isset( $t_method_array[E_ALL] ) ) {
93 $t_method = $t_method_array[E_ALL];
a8f55d5 @grangeway Inconsistent if-else block format.
grangeway authored
94 } else {
3f4914c @siebrand Consistency updates
siebrand authored
95 $t_method = 'none';
80a3c35 @grangeway Tidy error_api as someone touched core.php :(
grangeway authored
96 }
3f4914c @siebrand Consistency updates
siebrand authored
97 }
936ca79 @vboctor Fixed 4855: Account Update page shows header twice when there is an e…
vboctor authored
98
3f4914c @siebrand Consistency updates
siebrand authored
99 # build an appropriate error string
100 switch( $p_type ) {
101 case E_WARNING:
102 $t_error_type = 'SYSTEM WARNING';
103 $t_error_description = $p_error;
104 break;
105 case E_NOTICE:
106 $t_error_type = 'SYSTEM NOTICE';
107 $t_error_description = $p_error;
108 break;
109 case E_USER_ERROR:
110 $t_error_type = "APPLICATION ERROR #$p_error";
111 $t_error_description = error_string( $p_error );
112 break;
113 case E_USER_WARNING:
114 $t_error_type = "APPLICATION WARNING #$p_error";
115 $t_error_description = error_string( $p_error );
116 break;
117 case E_USER_NOTICE:
118
119 # used for debugging
120 $t_error_type = 'DEBUG';
121 $t_error_description = $p_error;
122 break;
123 default:
124
125 # shouldn't happen, just display the error just in case
126 $t_error_type = '';
127 $t_error_description = $p_error;
128 }
129
130 $t_error_description = nl2br( $t_error_description );
131
132 switch( $t_method ) {
133 case 'halt':
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
134 $t_oblen = ob_get_length();
135 if( error_handled() && $t_oblen > 0 ) {
136 $t_old_contents = ob_get_contents();
5780543 @grangeway rewrite error_api some more
grangeway authored
137 }
9f6ee3e Everyone seemed to prefer lower case API filenames and I had a few sp…
Julian Fitzell authored
138
3f4914c @siebrand Consistency updates
siebrand authored
139 # We need to ensure compression is off - otherwise the compression headers are output.
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
140 compress_disable();
3f4914c @siebrand Consistency updates
siebrand authored
141
142 # then clean the buffer, leaving output buffering on.
143 if( $t_oblen > 0 ) {
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
144 ob_clean();
3f4914c @siebrand Consistency updates
siebrand authored
145 }
9f6ee3e Everyone seemed to prefer lower case API filenames and I had a few sp…
Julian Fitzell authored
146
3f4914c @siebrand Consistency updates
siebrand authored
147 # don't send the page header information if it has already been sent
148 if( $g_error_send_page_header || $g_error_send_page_header == null ) {
149 if( $t_html_api ) {
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
150 html_page_top1();
3f4914c @siebrand Consistency updates
siebrand authored
151 if( $p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true ) {
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
152 html_page_top2();
a8f55d5 @grangeway Inconsistent if-else block format.
grangeway authored
153 } else {
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
154 html_page_top2a();
3f4914c @siebrand Consistency updates
siebrand authored
155 }
a8f55d5 @grangeway Inconsistent if-else block format.
grangeway authored
156 } else {
3f4914c @siebrand Consistency updates
siebrand authored
157 echo '<html><head><title>', $t_error_type, '</title></head><body>';
9c69e4d @grangeway Fix: Error handler when called with a DB_QUERY_FAILED type of error s…
grangeway authored
158 }
3f4914c @siebrand Consistency updates
siebrand authored
159 }
43c61f9 formatting fixes continued
Kenzaburo Ito authored
160
3f4914c @siebrand Consistency updates
siebrand authored
161 echo '<br /><div align="center"><table class="width50" cellspacing="1">';
162 echo '<tr><td class="form-title">', $t_error_type, '</td></tr>';
163 echo '<tr><td><p class="center" style="color:red">', $t_error_description, '</p></td></tr>';
9f6ee3e Everyone seemed to prefer lower case API filenames and I had a few sp…
Julian Fitzell authored
164
3f4914c @siebrand Consistency updates
siebrand authored
165 echo '<tr><td><p class="center">';
166 if( null === $g_error_proceed_url ) {
167 echo lang_get( 'error_no_proceed' );
a8f55d5 @grangeway Inconsistent if-else block format.
grangeway authored
168 } else {
3f4914c @siebrand Consistency updates
siebrand authored
169 echo '<a href="', $g_error_proceed_url, '">', lang_get( 'proceed' ), '</a>';
170 }
171 echo '</p></td></tr>';
0ddb48c * config_defaults_inc.php
Julian Fitzell authored
172
3f4914c @siebrand Consistency updates
siebrand authored
173 if( ON == config_get_global( 'show_detailed_errors' ) ) {
174 echo '<tr><td>';
175 error_print_details( $p_file, $p_line, $p_context );
176 echo '</td></tr>';
177 echo '<tr><td>';
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
178 error_print_stack_trace();
3f4914c @siebrand Consistency updates
siebrand authored
179 echo '</td></tr>';
180 }
181 echo '</table></div>';
0ddb48c * config_defaults_inc.php
Julian Fitzell authored
182
3f4914c @siebrand Consistency updates
siebrand authored
183 if( isset( $t_old_contents ) ) {
184 echo '<p>Previous non-fatal errors occurred. Page contents follow.</p>';
185 echo '<div style="border: solid 1px black;padding: 4px">';
186 echo $t_old_contents;
187 echo '</div>';
188 }
189
190 if( $t_html_api ) {
191 if( $p_error != ERROR_DB_QUERY_FAILED && $t_db_connected == true ) {
230e3f4 @grangeway HTML api documentation + tidy up of api names
grangeway authored
192 html_page_bottom();
a8f55d5 @grangeway Inconsistent if-else block format.
grangeway authored
193 } else {
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
194 html_body_end();
195 html_end();
3f4914c @siebrand Consistency updates
siebrand authored
196 }
a8f55d5 @grangeway Inconsistent if-else block format.
grangeway authored
197 } else {
3f4914c @siebrand Consistency updates
siebrand authored
198 echo '</body></html>', "\n";
199 }
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
200 exit();
3f4914c @siebrand Consistency updates
siebrand authored
201 case 'inline':
202 echo '<p style="color:red">', $t_error_type, ': ', $t_error_description, '</p>';
b4bda13 @grangeway #008883: error_api.php: error_handled() returns true after an 'ignore…
grangeway authored
203 $g_error_handled = true;
3f4914c @siebrand Consistency updates
siebrand authored
204 break;
5cf7970 @grangeway Consistency update
grangeway authored
205 default:
b4bda13 @grangeway #008883: error_api.php: error_handled() returns true after an 'ignore…
grangeway authored
206 # do nothing - note we treat this as we've not handled an error, so any redirects go through.
7fd8643 @vboctor Fixed #5057: PHP 5/Mysql 4.0/Apache 2.0 - Index page fails to load
vboctor authored
207 }
208
3f4914c @siebrand Consistency updates
siebrand authored
209 if( $t_lang_pushed ) {
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
210 lang_pop();
9f6ee3e Everyone seemed to prefer lower case API filenames and I had a few sp…
Julian Fitzell authored
211 }
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
212
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
213 $g_error_parameters = array();
3f4914c @siebrand Consistency updates
siebrand authored
214 $g_error_proceed_url = null;
215 }
216
7a111a5 @grangeway PHPDoc updates
grangeway authored
217 /**
218 * Print out the error details including context
219 * @param string $p_file
220 * @param int $p_line
221 * @param string $p_context
222 * @return null
223 */
3f4914c @siebrand Consistency updates
siebrand authored
224 function error_print_details( $p_file, $p_line, $p_context ) {
225 ?>
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
226 <center>
227 <table class="width75">
228 <tr>
3f4914c @siebrand Consistency updates
siebrand authored
229 <td>Full path: <?php echo htmlentities( $p_file, ENT_COMPAT, lang_get( 'charset' ) );?></td>
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
230 </tr>
231 <tr>
3f4914c @siebrand Consistency updates
siebrand authored
232 <td>Line: <?php echo $p_line?></td>
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
233 </tr>
234 <tr>
235 <td>
3f4914c @siebrand Consistency updates
siebrand authored
236 <?php error_print_context( $p_context )?>
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
237 </td>
238 </tr>
239 </table>
240 </center>
43c61f9 formatting fixes continued
Kenzaburo Ito authored
241 <?php
3f4914c @siebrand Consistency updates
siebrand authored
242 }
243
7a111a5 @grangeway PHPDoc updates
grangeway authored
244 /**
245 * Print out the variable context given
246 * @param string $p_context
247 * @return null
248 */
3f4914c @siebrand Consistency updates
siebrand authored
249 function error_print_context( $p_context ) {
250 if( !is_array( $p_context ) ) {
251 return;
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
252 }
253
3f4914c @siebrand Consistency updates
siebrand authored
254 echo '<table class="width100"><tr><th>Variable</th><th>Value</th><th>Type</th></tr>';
ac7af06 @vboctor Sec #3611: Mask passwords when printing detailed error information.
vboctor authored
255
3f4914c @siebrand Consistency updates
siebrand authored
256 # print normal variables
257 foreach( $p_context as $t_var => $t_val ) {
258 if( !is_array( $t_val ) && !is_object( $t_val ) ) {
259 $t_type = gettype( $t_val );
260 $t_val = htmlentities( (string) $t_val, ENT_COMPAT, lang_get( 'charset' ) );
1f279e0 @vboctor Fix: Do not call custom_field_set_value() in bug report and bug updat…
vboctor authored
261
3f4914c @siebrand Consistency updates
siebrand authored
262 # Mask Passwords
263 if( strpos( $t_var, 'password' ) !== false ) {
264 $t_val = '**********';
1f279e0 @vboctor Fix: Do not call custom_field_set_value() in bug report and bug updat…
vboctor authored
265 }
3f4914c @siebrand Consistency updates
siebrand authored
266
267 echo '<tr><td>', $t_var, '</td><td>', $t_val, '</td><td>', $t_type, '</td></tr>', "\n";
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
268 }
3f4914c @siebrand Consistency updates
siebrand authored
269 }
1f279e0 @vboctor Fix: Do not call custom_field_set_value() in bug report and bug updat…
vboctor authored
270
3f4914c @siebrand Consistency updates
siebrand authored
271 # print arrays
272 foreach( $p_context as $t_var => $t_val ) {
273 if( is_array( $t_val ) && ( $t_var != 'GLOBALS' ) ) {
274 echo '<tr><td colspan="3" align="left"><br /><strong>', $t_var, '</strong></td></tr>';
275 echo '<tr><td colspan="3">';
276 error_print_context( $t_val );
277 echo '</td></tr>';
278 }
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
279 }
280
3f4914c @siebrand Consistency updates
siebrand authored
281 echo '</table>';
282 }
733d467 removed ob_clean call. Clearing the buffer may make for a nicer erro…
Kenzaburo Ito authored
283
7a111a5 @grangeway PHPDoc updates
grangeway authored
284 /**
285 * Print out a stack trace
286 * @return null
287 */
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
288 function error_print_stack_trace() {
3f4914c @siebrand Consistency updates
siebrand authored
289 echo '<center><table class="width75">';
290 echo '<tr><th>Filename</th><th>Line</th><th></th><th></th><th>Function</th><th>Args</th></tr>';
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
291
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
292 $t_stack = debug_backtrace();
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
293
3f4914c @siebrand Consistency updates
siebrand authored
294 array_shift( $t_stack );
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
295
3f4914c @siebrand Consistency updates
siebrand authored
296 # remove the call to this function from the stack trace
297 array_shift( $t_stack );
298
299 # remove the call to the error handler from the stack trace
300
301 foreach( $t_stack as $t_frame ) {
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
302 echo '<tr ', error_alternate_class(), '>';
3f4914c @siebrand Consistency updates
siebrand authored
303 echo '<td>', ( isset( $t_frame['file'] ) ? htmlentities( $t_frame['file'], ENT_COMPAT, lang_get( 'charset' ) ) : '-' ), '</td><td>', ( isset( $t_frame['line'] ) ? $t_frame['line'] : '-' ), '</td><td>', ( isset( $t_frame['class'] ) ? $t_frame['class'] : '-' ), '</td><td>', ( isset( $t_frame['type'] ) ? $t_frame['type'] : '-' ), '</td><td>', ( isset( $t_frame['function'] ) ? $t_frame['function'] : '-' ), '</td>';
304
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
305 $t_args = array();
3f4914c @siebrand Consistency updates
siebrand authored
306 if( isset( $t_frame['args'] ) && !empty( $t_frame['args'] ) ) {
307 foreach( $t_frame['args'] as $t_value ) {
308 $t_args[] = error_build_parameter_string( $t_value );
09817f1 improved backtrace printout for people with php >= 4.3.0
Julian Fitzell authored
309 }
3f4914c @siebrand Consistency updates
siebrand authored
310 echo '<td>( ', htmlentities( implode( $t_args, ', ' ), ENT_COMPAT, lang_get( 'charset' ) ), ' )</td></tr>';
a8f55d5 @grangeway Inconsistent if-else block format.
grangeway authored
311 } else {
3f4914c @siebrand Consistency updates
siebrand authored
312 echo '<td>-</td></tr>';
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
313 }
314 }
3f4914c @siebrand Consistency updates
siebrand authored
315 echo '</table></center>';
316 }
aa5a6b8 enable stack traces if you have the xdebug module loaded into php
Julian Fitzell authored
317
7a111a5 @grangeway PHPDoc updates
grangeway authored
318 /**
319 * Build a string describing the parameters to a function
320 * @param string $p_param
321 * @param bool $p_showtype default true
322 * @param int $p_depth default 0
323 * @return string
324 */
3f4914c @siebrand Consistency updates
siebrand authored
325 function error_build_parameter_string( $p_param, $p_showtype = true, $p_depth = 0 ) {
326 if( $p_depth++ > 10 ) {
327 return '<b>***Nesting Level Too Deep***</b>';
328 }
09817f1 improved backtrace printout for people with php >= 4.3.0
Julian Fitzell authored
329
3f4914c @siebrand Consistency updates
siebrand authored
330 if( is_array( $p_param ) ) {
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
331 $t_results = array();
09817f1 improved backtrace printout for people with php >= 4.3.0
Julian Fitzell authored
332
3f4914c @siebrand Consistency updates
siebrand authored
333 foreach( $p_param as $t_key => $t_value ) {
334 $t_results[] = '[' . error_build_parameter_string( $t_key, false, $p_depth ) . ']' . ' => ' . error_build_parameter_string( $t_value, false, $p_depth );
09817f1 improved backtrace printout for people with php >= 4.3.0
Julian Fitzell authored
335 }
3f4914c @siebrand Consistency updates
siebrand authored
336
337 return '<Array> { ' . implode( $t_results, ', ' ) . ' }';
09817f1 improved backtrace printout for people with php >= 4.3.0
Julian Fitzell authored
338 }
9aacdc6 @grangeway elseif -> else if
grangeway authored
339 else if( is_object( $p_param ) ) {
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
340 $t_results = array();
43c61f9 formatting fixes continued
Kenzaburo Ito authored
341
3f4914c @siebrand Consistency updates
siebrand authored
342 $t_class_name = get_class( $p_param );
343 $t_inst_vars = get_object_vars( $p_param );
43c61f9 formatting fixes continued
Kenzaburo Ito authored
344
3f4914c @siebrand Consistency updates
siebrand authored
345 foreach( $t_inst_vars as $t_name => $t_value ) {
346 $t_results[] = "[$t_name]" . ' => ' . error_build_parameter_string( $t_value, false, $p_depth );
347 }
43c61f9 formatting fixes continued
Kenzaburo Ito authored
348
3f4914c @siebrand Consistency updates
siebrand authored
349 return '<Object><' . $t_class_name . '> ( ' . implode( $t_results, ', ' ) . ' )';
a8f55d5 @grangeway Inconsistent if-else block format.
grangeway authored
350 } else {
3f4914c @siebrand Consistency updates
siebrand authored
351 if( $p_showtype ) {
352 return '<' . gettype( $p_param ) . '>' . var_export( $p_param, true );
a8f55d5 @grangeway Inconsistent if-else block format.
grangeway authored
353 } else {
3f4914c @siebrand Consistency updates
siebrand authored
354 return var_export( $p_param, true );
355 }
356 }
357 }
43c61f9 formatting fixes continued
Kenzaburo Ito authored
358
7a111a5 @grangeway PHPDoc updates
grangeway authored
359 /**
360 * Return an error string (in the current language) for the given error.
361 * @param int $p_error
362 * @return string
363 * @access public
364 */
3f4914c @siebrand Consistency updates
siebrand authored
365 function error_string( $p_error ) {
366 global $g_error_parameters;
43c61f9 formatting fixes continued
Kenzaburo Ito authored
367
3f4914c @siebrand Consistency updates
siebrand authored
368 $MANTIS_ERROR = lang_get( 'MANTIS_ERROR' );
1e7c6b9 Sorry for the muddled commit. I realize now that I ended up doing mo…
Julian Fitzell authored
369
3f4914c @siebrand Consistency updates
siebrand authored
370 # We pad the parameter array to make sure that we don't get errors if
371 # the caller didn't give enough parameters for the error string
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
372 $t_padding = array_pad( array(), 10, '' );
0ddb48c * config_defaults_inc.php
Julian Fitzell authored
373
3f4914c @siebrand Consistency updates
siebrand authored
374 $t_error = $MANTIS_ERROR[$p_error];
0ddb48c * config_defaults_inc.php
Julian Fitzell authored
375
3f4914c @siebrand Consistency updates
siebrand authored
376 # ripped from string_api
377 $t_string = call_user_func_array( 'sprintf', array_merge( array( $t_error ), $g_error_parameters, $t_padding ) );
378 return preg_replace( "/&amp;(#[0-9]+|[a-z]+);/i", "&$1;", @htmlspecialchars( $t_string, ENT_COMPAT, lang_get( 'charset' ) ) );
379 }
43c61f9 formatting fixes continued
Kenzaburo Ito authored
380
7a111a5 @grangeway PHPDoc updates
grangeway authored
381 /**
382 * Check if we have handled an error during this page
383 * Return true if an error has been handled, false otherwise
384 * @return bool
385 */
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
386 function error_handled() {
3f4914c @siebrand Consistency updates
siebrand authored
387 global $g_error_handled;
43c61f9 formatting fixes continued
Kenzaburo Ito authored
388
3f4914c @siebrand Consistency updates
siebrand authored
389 return( true == $g_error_handled );
390 }
5780543 @grangeway rewrite error_api some more
grangeway authored
391
5cf7970 @grangeway Consistency update
grangeway authored
392 /**
7a111a5 @grangeway PHPDoc updates
grangeway authored
393 * Set additional info parameters to be used when displaying the next error
394 * This function takes a variable number of parameters
395 *
396 * When writing internationalized error strings, note that you can change the
397 * order of parameters in the string. See the PHP manual page for the
398 * sprintf() function for more details.
399 * @access public
400 * @return null
401 */
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
402 function error_parameters() {
3f4914c @siebrand Consistency updates
siebrand authored
403 global $g_error_parameters;
404
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
405 $g_error_parameters = func_get_args();
3f4914c @siebrand Consistency updates
siebrand authored
406 }
407
5cf7970 @grangeway Consistency update
grangeway authored
408 /**
7a111a5 @grangeway PHPDoc updates
grangeway authored
409 * Set a url to give to the user to proceed after viewing the error
410 * @access public
411 * @param string p_url url given to user after viewing the error
412 * @return null
413 */
3f4914c @siebrand Consistency updates
siebrand authored
414 function error_proceed_url( $p_url ) {
415 global $g_error_proceed_url;
416
417 $g_error_proceed_url = $p_url;
418 }
419
5cf7970 @grangeway Consistency update
grangeway authored
420 /**
7a111a5 @grangeway PHPDoc updates
grangeway authored
421 * Simple version of helper_alternate_class for use by error api only.
422 * @access private
423 * @return string representing css class
424 * @usedby error_print_stack_trace
425 */
684b278 @grangeway Revert part of previous formatting commit: Array( ) should be array()
grangeway authored
426 function error_alternate_class() {
3f4914c @siebrand Consistency updates
siebrand authored
427 static $t_errindex = 1;
428
429 if( 1 == $t_errindex++ % 2 ) {
430 return 'class="row-1"';
a8f55d5 @grangeway Inconsistent if-else block format.
grangeway authored
431 } else {
3f4914c @siebrand Consistency updates
siebrand authored
432 return 'class="row-2"';
433 }
434 }
Something went wrong with that request. Please try again.