From a5ab6b9638c76748f7b9b66ebbd4d8cacf682250 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Sun, 2 May 1999 19:54:02 +0000 Subject: [PATCH] Move path_info to the SAPI structure --- cgi_main.c | 9 ++++++++- ext/hyperwave/hw.c | 4 ++-- ext/standard/info.c | 9 +++++++-- main/fopen_wrappers.c | 4 +++- main/main.c | 4 ++-- request_info.c | 22 ---------------------- 6 files changed, 22 insertions(+), 30 deletions(-) diff --git a/cgi_main.c b/cgi_main.c index 2fe4e50ecd..792e2fe9c6 100644 --- a/cgi_main.c +++ b/cgi_main.c @@ -115,6 +115,13 @@ static void php_cgi_usage(char *argv0) } +static void init_request_info(SLS_D) +{ + SG(request_info).query_string = getenv("QUERY_STRING"); + SG(request_info).request_uri = getenv("PATH_INFO"); +} + + int main(int argc, char *argv[]) { int cgi = 0, c, i, len; @@ -293,7 +300,7 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine php3_TreatHeaders(); - SG(request_info).query_string = getenv("QUERY_STRING"); + init_request_info(SLS_C); if (!cgi) { if (!SG(request_info).query_string) { diff --git a/ext/hyperwave/hw.c b/ext/hyperwave/hw.c index 8a813dde86..f2380dde05 100644 --- a/ext/hyperwave/hw.c +++ b/ext/hyperwave/hw.c @@ -1532,7 +1532,7 @@ void php3_hw_getcgi(INTERNAL_FUNCTION_PARAMETERS) { #else sprintf(cgi_env_str, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s", request_info.request_method, - request_info.path_info, + SG(request_info).request_uri, SG(request_info).query_string); #endif /* !!!! memory for object and attributes is allocated with malloc !!!! */ @@ -1784,7 +1784,7 @@ void php3_hw_pipecgi(INTERNAL_FUNCTION_PARAMETERS) { #else sprintf(cgi_env_str, "CGI_REQUEST_METHOD=%s\nCGI_PATH_INFO=%s\nCGI_QUERY_STRING=%s", request_info.request_method, - request_info.path_info, + SG(request_info).request_uri, SG(request_info).query_string); #endif /* !!!! memory for object, bodytag and attributes is allocated with malloc !!!! */ diff --git a/ext/standard/info.c b/ext/standard/info.c index ceee00eb3e..386b2d0abc 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -88,6 +88,7 @@ PHPAPI void _php3_info(void) #endif ELS_FETCH(); PLS_FETCH(); + SLS_FETCH(); #if WIN32|WINNT // Get build numbers for Windows NT or Win95 @@ -104,7 +105,9 @@ PHPAPI void _php3_info(void) PUTS("uri);*/ + if (SG(request_info).request_uri) { + PUTS(SG(request_info).request_uri); + } PUTS("?=PHPE9568F34-D428-11d2-A769-00AA001ACF42\" border=\"0\" width=\"100\" height=\"56\" align=\"right\">\n"); php3_printf("

PHP Version %s

\n", PHP_VERSION); PUTS("

by Rasmus Lerdorf,\n"); @@ -392,7 +395,9 @@ PHPAPI void _php3_info(void) PUTS("\n"); php3_printf("", get_zend_version()); PUTS("\n"); PUTS("

Zend

This program makes use of the Zend scripting language engine:
%s
uri);*/ + if (SG(request_info).request_uri) { + PUTS(SG(request_info).request_uri); + } PUTS("?=PHPE9568F35-D428-11d2-A769-00AA001ACF42\" border=\"0\" width=\"100\" height=\"89\">
\n"); diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 8b2814bf88..2a563c6bc7 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -31,6 +31,7 @@ #include "php.h" #include "php_globals.h" +#include "SAPI.h" #include #include @@ -205,9 +206,10 @@ PHPAPI FILE *php3_fopen_for_parser(void) char *temp, *path_info, *fn; int l; PLS_FETCH(); + SLS_FETCH(); fn = request_info.filename; - path_info = request_info.path_info; + path_info = SG(request_info).request_uri; #if HAVE_PWD_H if (PG(user_dir) && *PG(user_dir) && path_info && '/' == path_info[0] && '~' == path_info[1]) { diff --git a/main/main.c b/main/main.c index 7bef2e8af1..a745601c47 100644 --- a/main/main.c +++ b/main/main.c @@ -1024,7 +1024,7 @@ int _php3_hash_environment(PLS_D ELS_DC) /* Build the special-case PHP_SELF variable for the CGI version */ char *pi; #if FORCE_CGI_REDIRECT - pi = request_info.path_info; + pi = SG(request_info).request_uri; tmp = (pval *) emalloc(sizeof(pval)); tmp->value.str.val = emalloc(((pi)?strlen(pi):0) + 1); tmp->value.str.len = _php3_sprintf(tmp->value.str.val, "%s", (pi ? pi : "")); /* SAFE */ @@ -1035,7 +1035,7 @@ int _php3_hash_environment(PLS_D ELS_DC) int l = 0; char *sn; sn = request_info.script_name; - pi = request_info.path_info; + pi = SG(request_info).request_uri; if (sn) l += strlen(sn); if (pi) diff --git a/request_info.c b/request_info.c index 1045cbbcb4..7da4a9bf34 100644 --- a/request_info.c +++ b/request_info.c @@ -40,7 +40,6 @@ int php3_init_request_info(void *conf) char *buf; /* temporary buffers */ SLS_FETCH(); - request_info.path_info = getenv("PATH_INFO"); request_info.current_user = NULL; request_info.current_user_length = 0; request_info.request_method = getenv("REQUEST_METHOD"); @@ -122,27 +121,6 @@ int php3_init_request_info(void *conf) #endif -#if USE_SAPI -/* temporary until I figure a beter way to do it */ -int php3_init_request_info(void *conf) -{ - if (sapi_rqst->filename) - request_info.filename = estrdup(sapi_rqst->filename); - else - request_info.filename = NULL; - request_info.path_info = sapi_rqst->path_info; - request_info.current_user = sapi_rqst->current_user; - request_info.current_user_length = sapi_rqst->current_user_length; - request_info.request_method = sapi_rqst->request_method; - request_info.script_name = sapi_rqst->script_name; - request_info.content_length = sapi_rqst->content_length; - request_info.content_type = sapi_rqst->content_type; - request_info.cookies = sapi_rqst->cookies; - - return SUCCESS; -} -#endif - #if !CGI_BINARY int php3_destroy_request_info(void *conf) { -- 2.40.0