>First of all i like the way you did it. >But why do you cut the errors by using snprintf with maximum >length set to ERRORURL_BUF_LEN. Instead you can simply use >spprintf and we would get the whole message. I guess you did >it because you created a GET solution?
Well, I guess it could be implemented with spprintf -- However For the use I really didn't see the need to use it. The only Real "variables" in the string length are the filename/path and The error-message.. These are of pretty finite length so I figured A few kilobytes statically wouldn't hurt anyone and makes it That much more efficient. >marcus > >At 12:56 21.11.2002, John Coggeshall wrote: > >>Okay... >> >>Well, even though I've yet to convince Derick and a few >others... I did >>see enough interest in this to create a patch. This creates two new >>directives: error_redirect (bool) which turns this on/off, and >>error_redirect_url (string) which is the URL to redirect to >upon error. >>In order for these directives to have any effect, the headers (of >>course) must not have been already sent. This means that >either output >>buffering must be enabled, or the script never got around to >outputting >>anything. This patch will allow users to handle every error PHP >>generates if desired (including E_PARSE, etc). >> >>The URL which is redirected to is passed the following >parameters via a >>GET statement: >> >>errno - The error number (i.e. E_PARSE, whatever) >>Errfile - The path/file of the effected file >>Errline - The line which the error occurred >>Errmsg - The message provided describing the error: >> >>If the redirection fails (i.e. because headers had already been sent, >>whatever) the standard PHP error routine is used. >> >>Disclaimer: This is totally meant to be RFC at this point. It works, >>but Its not very friendly right now with the other error stuff (i.e. >>error_prepend, etc). If I can get a +1 on this concept, I'll clean >>things up before I commit. >> >>John >> >>--- php4/main/main.org.c Thu Nov 21 05:43:05 2002 >>+++ php4/main/main.c Thu Nov 21 05:43:18 2002 >>@@ -236,6 +236,8 @@ >> STD_PHP_INI_ENTRY("docref_root", "http://www.php.net/", >>PHP_INI_ALL, OnUpdateString, docref_root, >>php_core_globals, core_globals) >> STD_PHP_INI_ENTRY("docref_ext", "", >>PHP_INI_ALL, OnUpdateString, docref_ext, >>php_core_globals, core_globals) >> STD_PHP_INI_BOOLEAN("html_errors", "1", >>PHP_INI_ALL, OnUpdateBool, html_errors, >>php_core_globals, core_globals) >>+ STD_PHP_INI_BOOLEAN("error_redirect", "0", >>PHP_INI_SYSTEM, OnUpdateBool, >error_redirect, >>php_core_globals, core_globals) >> >>+ STD_PHP_INI_ENTRY("error_redirect_url", NULL, >>PHP_INI_SYSTEM, OnUpdateString, >>error_redirect_url, php_core_globals, core_globals) >> STD_PHP_INI_BOOLEAN("xmlrpc_errors", "0", >>PHP_INI_SYSTEM, OnUpdateBool, xmlrpc_errors, >>php_core_globals, core_globals) >> STD_PHP_INI_ENTRY("xmlrpc_error_number", "0", >>PHP_INI_ALL, OnUpdateInt, >>xmlrpc_error_number, php_core_globals, core_globals) >> STD_PHP_INI_ENTRY("max_input_time", "-1", >>PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateInt, >>max_input_time,php_core_globals, core_globals) >>@@ -605,7 +607,40 @@ >> if (prepend_string) { >> PUTS(prepend_string); >> } >>- php_printf(error_format, >error_type_str, buffer, >>error_filename, error_lineno); >>+ if(PG(error_redirect) && !SG(headers_sent)) { >>+ >>+ sapi_header_line ctr = {0}; >>+ char *url_params; >>+ >>+ int out_url_len, t_header_len; >>+ >>+ url_params = do_alloca(ERRORURL_BUF_LEN); >>+ >>+ snprintf(url_params, >>+ ERRORURL_BUF_LEN-1, >>+ >>"?errno=%d&errfile=%s&errline=%d&errmsg=%s", >>+ type, >>+ php_url_encode((char >>*)error_filename, strlen(error_filename), NULL), >>+ error_lineno, >>+ php_url_encode(buffer, >>strlen(buffer), NULL)); >>+ >>+ /* The +10 is to account for >"Location: " >>*/ >>+ t_header_len = >>strlen(PG(error_redirect_url)) + strlen(url_params) + 10; >>+ ctr.line = do_alloca(t_header_len); >>+ snprintf(ctr.line, >>t_header_len+9,"Location: %s%s", PG(error_redirect_url), url_params); >>+ >>+ ctr.line_len = strlen(ctr.line); >>+ >>+ sapi_header_op(SAPI_HEADER_REPLACE, &ctr >>TSRMLS_CC); >>+ >>+ free_alloca(url_params); >>+ free_alloca(ctr.line); >>+ >>+ } else { >>+ >>+ php_printf(error_format, error_type_str, >>buffer, error_filename, error_lineno); >>+ } >>+ >> if (PG(xmlrpc_errors)) { >> free_alloca(error_format); >> } >> >> >>-- >>PHP Development Mailing List <http://www.php.net/> >>To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php