cvs: /php4 php_variables.c php_variables.h /php4 php_gpce.c php_gpce.h /php4 Makefile.in NEWS SAPI.h main.c php.ini-dist php4dll.dsp php4dllts.dsp
php_globals.h rfc1867.c /php4/ext/apache apache.c /php4/ext/standard string.c /php4/sapi/aolserver aolserver.c /php4/sapi/apache mod_php4.c
/php4/sapi/cgi cgi_main.c /php4/sapi/isapi php4isapi.c /php4/sapi/phttpd phttpd.c /php4/sapi/roxen roxen.c /php4/sapi/servlet servlet.c
/php4/sapi/thttpd thttpd.c
| From: | Zeev Suraski | Date: | Fri, 28 Jan 2000 17:25:24 +0000 |
| Subject: | cvs: /php4 php_variables.c php_variables.h /php4 php_gpce.c php_gpce.h /php4 Makefile.in NEWS SAPI.h main.c php.ini-dist php4dll.dsp php4dllts.dsp php_globals.h rfc1867.c /php4/ext/apache apache.c /php4/ext/standard string.c /php4/sapi/aolserver aolserver.c /php4/sapi/apache mod_php4.c /php4/sapi/cgi cgi_main.c /php4/sapi/isapi php4isapi.c /php4/sapi/phttpd phttpd.c /php4/sapi/roxen roxen.c /php4/sapi/servlet servlet.c /php4/sapi/thttpd thttpd.c |
||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-9521@lists.php.net to get a copy of this message | ||
zeev Fri Jan 28 09:25:24 2000 EDT
Added files:
/php4 php_variables.c php_variables.h
Removed files:
/php4 php_gpce.c php_gpce.h
Modified files:
/php4 Makefile.in NEWS SAPI.h main.c php.ini-dist php4dll.dsp
php4dllts.dsp php_globals.h rfc1867.c
/php4/ext/apache apache.c
/php4/ext/standard string.c
/php4/sapi/aolserver aolserver.c
/php4/sapi/apache mod_php4.c
/php4/sapi/cgi cgi_main.c
/php4/sapi/isapi php4isapi.c
/php4/sapi/phttpd phttpd.c
/php4/sapi/roxen roxen.c
/php4/sapi/servlet servlet.c
/php4/sapi/thttpd thttpd.c
Log:
Tried to centralize global variable registration as much as possible:
- Added $HTTP_ENV_VARS[] and $HTTP_SERVER_VARS[] support, which similarly
to $HTTP_GET_VARS[], contain environment and server variables. Setting
register_globals to Off will now also prevent registration of the
environment and server variables into the global scope (Zeev)
- Renamed gpc_globals to register_globals (Zeev)
- Introduced variables_order that deprecates gpc_order, and allows control
over the server and environment variables, in addition to GET/POST/Cookies
(Zeev)
Index: php4/Makefile.in
diff -u php4/Makefile.in:1.72 php4/Makefile.in:1.73
--- php4/Makefile.in:1.72 Fri Jan 28 05:31:11 2000
+++ php4/Makefile.in Fri Jan 28 09:24:49 2000
@@ -14,7 +14,7 @@
configuration-parser.c configuration-scanner.c request_info.c \
safe_mode.c fopen-wrappers.c php_realpath.c alloca.c \
php_ini.c SAPI.c rfc1867.c dlist.c php_content_types.c strlcpy.c \
- strlcat.c mergesort.c reentrancy.c php_gpce.c
+ strlcat.c mergesort.c reentrancy.c php_variables.c
LTLIBRARY_DEPENDENCIES = \
Zend/libZend.la \
Index: php4/NEWS
diff -u php4/NEWS:1.104 php4/NEWS:1.105
--- php4/NEWS:1.104 Mon Jan 10 07:17:16 2000
+++ php4/NEWS Fri Jan 28 09:24:49 2000
@@ -2,6 +2,14 @@
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ?? ????, Version 4.0 Beta 4
+- Added $HTTP_ENV_VARS[] and $HTTP_SERVER_VARS[] support, which similarly
+ to $HTTP_GET_VARS[], contain environment and server variables. Setting
+ register_globals to Off will now also prevent registration of the
+ environment and server variables into the global scope (Zeev)
+- Renamed gpc_globals to register_globals (Zeev)
+- Introduced variables_order that deprecates gpc_order, and allows control
+ over the server and environment variables, in addition to GET/POST/Cookies
+ (Zeev)
- new function cpdf_set_document_limits() (Uwe)
- Applied safe-mode patch to popen(). (Patch by Kristian Köhntopp)
- str_repeat() now returns correct length. (Thies)
Index: php4/SAPI.h
diff -u php4/SAPI.h:1.26 php4/SAPI.h:1.27
--- php4/SAPI.h:1.26 Thu Jan 13 09:37:20 2000
+++ php4/SAPI.h Fri Jan 28 09:24:49 2000
@@ -147,6 +147,8 @@
int (*read_post)(char *buffer, uint count_bytes SLS_DC);
char *(*read_cookies)(SLS_D);
+ void (*register_server_variables)(zval *track_vars_array ELS_DC SLS_DC PLS_DC);
+
void (*default_post_reader)(char *content_type_dup SLS_DC);
};
Index: php4/main.c
diff -u php4/main.c:1.182 php4/main.c:1.183
--- php4/main.c:1.182 Fri Jan 28 05:31:11 2000
+++ php4/main.c Fri Jan 28 09:24:49 2000
@@ -19,7 +19,7 @@
*/
-/* $Id: main.c,v 1.182 2000/01/28 13:31:11 zeev Exp $ */
+/* $Id: main.c,v 1.183 2000/01/28 17:24:49 zeev Exp $ */
#include <stdio.h>
@@ -50,7 +50,7 @@
#include "fopen-wrappers.h"
#include "ext/standard/php_standard.h"
#include "snprintf.h"
-#include "php_gpce.h"
+#include "php_variables.h"
#if WIN32|WINNT
#include <io.h>
#include <fcntl.h>
@@ -251,8 +251,9 @@
#endif
STD_PHP_INI_BOOLEAN("gpc_globals", "1", PHP_INI_ALL, OnUpdateBool, gpc_globals, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("gpc_order", "GPC", PHP_INI_ALL, OnUpdateStringUnempty, gpc_order, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("arg_separator", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator, php_core_globals, core_globals)
+ STD_PHP_INI_ENTRY("gpc_order", "GPC", PHP_INI_ALL, OnUpdateStringUnempty, gpc_order, php_core_globals, core_globals)
+ STD_PHP_INI_ENTRY("variables_order", NULL, PHP_INI_ALL, OnUpdateStringUnempty, variables_order, php_core_globals, core_globals)
+ STD_PHP_INI_ENTRY("arg_separator", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("ignore_user_abort", "1", PHP_INI_ALL, OnUpdateBool, ignore_user_abort, php_core_globals, core_globals)
PHP_INI_END()
@@ -702,24 +703,10 @@
}
if (SG(request_info).auth_user) {
- zval *auth_user;
-
- MAKE_STD_ZVAL(auth_user);
- auth_user->type = IS_STRING;
- auth_user->value.str.val = SG(request_info).auth_user;
- auth_user->value.str.len = strlen(auth_user->value.str.val);
-
- zend_hash_update(&EG(symbol_table), "PHP_AUTH_USER",
sizeof("PHP_AUTH_USER"), &auth_user, sizeof(zval *), NULL);
+ php_register_variable(SG(request_info).auth_user, "PHP_AUTH_USER", NULL ELS_CC PLS_CC);
}
if (SG(request_info).auth_password) {
- zval *auth_password;
-
- MAKE_STD_ZVAL(auth_password);
- auth_password->type = IS_STRING;
- auth_password->value.str.val = SG(request_info).auth_password;
- auth_password->value.str.len = strlen(auth_password->value.str.val);
-
- zend_hash_update(&EG(symbol_table), "PHP_AUTH_PW", sizeof("PHP_AUTH_PW"),
&auth_password, sizeof(zval *), NULL);
+ php_register_variable(SG(request_info).auth_password, "PHP_AUTH_PW", NULL ELS_CC
PLS_CC);
}
return SUCCESS;
@@ -1008,15 +995,36 @@
module_initialized = 0;
}
+
+static inline void php_register_server_variables(ELS_D SLS_DC PLS_DC)
+{
+ zval *array_ptr=NULL;
+
+ if (PG(track_vars)) {
+ ALLOC_ZVAL(array_ptr);
+ array_init(array_ptr);
+ INIT_PZVAL(array_ptr);
+ zend_hash_add(&EG(symbol_table), "HTTP_SERVER_VARS",
sizeof("HTTP_ENV_VARS"), &array_ptr, sizeof(pval *),NULL);
+ }
+ sapi_module.register_server_variables(array_ptr ELS_CC SLS_CC PLS_CC);
+}
+
-/* in 3.1 some of this should move into sapi */
-static int zend_hash_environment(PLS_D ELS_DC SLS_DC)
+static int zend_hash_environment(ELS_D SLS_DC PLS_DC)
{
- char **env, *p, *t;
+ char *p;
unsigned char _gpc_flags[3] = {0,0,0};
- pval *tmp;
-
- p = PG(gpc_order);
+ zend_bool have_variables_order;
+
+ if (PG(variables_order)) {
+ p = PG(variables_order);
+ have_variables_order=1;
+ } else {
+ p = PG(gpc_order);
+ have_variables_order=0;
+ php_import_environment_variables(ELS_C PLS_CC);
+ }
+
while(*p) {
switch(*p++) {
case 'p':
@@ -1040,94 +1048,27 @@
_gpc_flags[2]=1;
}
break;
+ case 'e':
+ case 'E':
+ if (have_variables_order) {
+ php_import_environment_variables(ELS_C PLS_CC);
+ } else {
+ php_error(E_CORE_WARNING, "Unsupported 'e' element (environment) used in
gpc_order - use variables_order instead");
+ }
+ break;
+ case 's':
+ case 'S':
+ if (sapi_module.register_server_variables) {
+ php_register_server_variables(ELS_C SLS_CC PLS_CC);
+ }
+ break;
}
}
-
- for (env = environ; env != NULL && *env != NULL; env++) {
- p = strchr(*env, '=');
- if (!p) { /* malformed entry? */
- continue;
- }
- t = estrndup(*env, p - *env);
- ALLOC_ZVAL(tmp);
- tmp->value.str.len = strlen(p + 1);
- tmp->value.str.val = estrndup(p + 1, tmp->value.str.len);
- tmp->type = IS_STRING;
- INIT_PZVAL(tmp);
- /* environmental variables never take precedence over get/post/cookie variables */
- zend_hash_add(&EG(symbol_table), t, p - *env + 1, &tmp, sizeof(pval *), NULL);
- efree(t);
- }
-#if APACHE
- {
- pval **tmp_ptr;
- register int i;
- array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
- table_entry *elts = (table_entry *) arr->elts;
- int len;
-
- for (i = 0; i < arr->nelts; i++) {
- len = strlen(elts[i].key);
- t = elts[i].key;
- ALLOC_ZVAL(tmp);
- if (elts[i].val) {
- tmp->value.str.len = strlen(elts[i].val);
- tmp->value.str.val = estrndup(elts[i].val, tmp->value.str.len);
- } else {
- tmp->value.str.len = 0;
- tmp->value.str.val = empty_string;
- }
- INIT_PZVAL(tmp);
- tmp->type = IS_STRING;
- zend_hash_update(&EG(symbol_table), t, strlen(t)+1, &tmp, sizeof(pval *), NULL);
- }
- /* insert special variables */
- if (zend_hash_find(&EG(symbol_table), "SCRIPT_FILENAME",
sizeof("SCRIPT_FILENAME"), (void **) &tmp_ptr) == SUCCESS) {
- (*tmp_ptr)->refcount++;
- zend_hash_update(&EG(symbol_table), "PATH_TRANSLATED",
sizeof("PATH_TRANSLATED"), tmp_ptr, sizeof(pval *), NULL);
- }
- ALLOC_ZVAL(tmp);
- tmp->value.str.len = strlen(((request_rec *) SG(server_context))->uri);
- tmp->value.str.val = estrndup(((request_rec *) SG(server_context))->uri,
tmp->value.str.len);
- INIT_PZVAL(tmp);
- tmp->type = IS_STRING;
- zend_hash_update(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void
*) &tmp, sizeof(pval *), NULL);
+ if (!have_variables_order) {
+ php_register_server_variables(ELS_C SLS_CC PLS_CC);
}
-#else
- {
- /* Build the special-case PHP_SELF variable for the CGI version */
- char *pi;
-#if FORCE_CGI_REDIRECT
- pi = SG(request_info).request_uri;
- ALLOC_ZVAL(tmp);
- tmp->value.str.val = emalloc(((pi)?strlen(pi):0) + 1);
- tmp->value.str.len = php_sprintf(tmp->value.str.val, "%s", (pi ? pi :
"")); /* SAFE */
- tmp->type = IS_STRING;
- INIT_PZVAL(tmp);
-#else
- int l = 0;
- char *sn;
- sn = request_info.script_name;
- pi = SG(request_info).request_uri;
- if (sn)
- l += strlen(sn);
- if (pi)
- l += strlen(pi);
- if (pi && sn && !strcmp(pi, sn)) {
- l -= strlen(pi);
- pi = NULL;
- }
- ALLOC_ZVAL(tmp);
- tmp->value.str.val = emalloc(l + 1);
- tmp->value.str.len = php_sprintf(tmp->value.str.val, "%s%s", (sn ? sn :
""), (pi ? pi : "")); /* SAFE */
- tmp->type = IS_STRING;
- INIT_PZVAL(tmp);
-#endif
- zend_hash_update(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void
*) & tmp, sizeof(pval *), NULL);
- }
-#endif
/* need argc/argv support as well */
@@ -1136,6 +1077,7 @@
return SUCCESS;
}
+
void _php_build_argv(char *s ELS_DC)
{
pval *arr, *tmp;
@@ -1193,6 +1135,7 @@
zend_file_handle prepend_file, append_file;
SLS_FETCH();
+ zend_hash_environment(ELS_C SLS_CC PLS_CC);
zend_activate_modules();
if (SG(request_info).query_string && SG(request_info).query_string[0]=='='
&& PG(expose_php)) {
@@ -1240,7 +1183,6 @@
}
EG(main_op_array) = zend_compile_files(0 CLS_CC, 3, prepend_file_p, primary_file, append_file_p);
if (EG(main_op_array)) {
- zend_hash_environment(PLS_C ELS_CC SLS_CC);
EG(active_op_array) = EG(main_op_array);
zend_execute(EG(main_op_array) ELS_CC);
}
Index: php4/php.ini-dist
diff -u php4/php.ini-dist:1.18 php4/php.ini-dist:1.19
--- php4/php.ini-dist:1.18 Thu Jan 13 12:39:33 2000
+++ php4/php.ini-dist Fri Jan 28 09:24:49 2000
@@ -135,16 +135,20 @@
;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;
-gpc_order = "GPC" ; Order of evaluation of GET/POST/Cookie data. Later values override
- ; earlier values (e.g., by default, POST variables override GET variables,
- ; and Cookie variables override both POST and GET variables).
-gpc_globals = On ; Whether or not to define GET/POST/Cookie variables in the global
- ; scope. You may want to turn this off if you don't want
+variables_order = "EGPCB" ; This directive describes the order in which PHP registers
+ ; GET, POST, Cookie, Environment and Built-in variables (G, P,
+ ; C, E & B respectively, often referred to as EGPCB or GPC).
+ ; Registration is done from left to right, newer values override
+ ; older values.
+register_globals = On ; Whether or not to register the EGPCB variables as global
+ ; variables. You may want to turn this off if you don't want
; to clutter your scripts' global scope with user data. This makes
; most sense when coupled with track_vars - in which case you can
- ; access all of the GPC variables through the $HTTP_GET_VARS[],
- ; $HTTP_POST_VARS[] and $HTTP_COOKIE_VARS[] variables.
-track_vars = On ; enable $HTTP_GET_VARS[], $HTTP_POST_VARS[] and $HTTP_COOKIE_VARS[] arrays
+ ; access all of the GPC variables through the $HTTP_*_VARS[],
+ ; variables.
+track_vars = On ; enable the $HTTP_*_VARS[] arrays, where * is one of
+ ; ENV, POST, GET, COOKIE or SERVER.
+gpc_order = "GPC" ; This directive is deprecated. Use variables_order instead.
; Magic quotes
magic_quotes_gpc = On ; magic quotes for incoming GET/POST/Cookie data
Index: php4/php4dll.dsp
diff -u php4/php4dll.dsp:1.29 php4/php4dll.dsp:1.30
--- php4/php4dll.dsp:1.29 Fri Jan 28 06:46:19 2000
+++ php4/php4dll.dsp Fri Jan 28 09:24:49 2000
@@ -164,7 +164,7 @@
# End Source File
# Begin Source File
-SOURCE=.\php_gpce.c
+SOURCE=.\php_variables.c
# End Source File
# Begin Source File
@@ -264,7 +264,7 @@
# End Source File
# Begin Source File
-SOURCE=.\php_gpce.h
+SOURCE=.\php_variables.h
# End Source File
# Begin Source File
Index: php4/php4dllts.dsp
diff -u php4/php4dllts.dsp:1.46 php4/php4dllts.dsp:1.47
--- php4/php4dllts.dsp:1.46 Fri Jan 28 06:46:19 2000
+++ php4/php4dllts.dsp Fri Jan 28 09:24:49 2000
@@ -160,15 +160,15 @@
# End Source File
# Begin Source File
-SOURCE=.\php_gpce.c
+SOURCE=.\php_ini.c
# End Source File
# Begin Source File
-SOURCE=.\php_ini.c
+SOURCE=.\php_realpath.c
# End Source File
# Begin Source File
-SOURCE=.\php_realpath.c
+SOURCE=.\php_variables.c
# End Source File
# Begin Source File
@@ -260,10 +260,6 @@
# End Source File
# Begin Source File
-SOURCE=.\php_gpce.h
-# End Source File
-# Begin Source File
-
SOURCE=.\php_ini.h
# End Source File
# Begin Source File
@@ -273,6 +269,10 @@
# Begin Source File
SOURCE=.\php_regex.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\php_variables.h
# End Source File
# Begin Source File
Index: php4/php_globals.h
diff -u php4/php_globals.h:1.36 php4/php_globals.h:1.37
--- php4/php_globals.h:1.36 Sun Jan 16 13:03:48 2000
+++ php4/php_globals.h Fri Jan 28 09:24:49 2000
@@ -81,6 +81,7 @@
char *arg_separator;
char *gpc_order;
+ char *variables_order;
zend_bool expose_php;
Index: php4/rfc1867.c
diff -u php4/rfc1867.c:1.22 php4/rfc1867.c:1.23
--- php4/rfc1867.c:1.22 Fri Jan 28 06:57:19 2000
+++ php4/rfc1867.c Fri Jan 28 09:24:49 2000
@@ -15,7 +15,7 @@
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
-/* $Id: rfc1867.c,v 1.22 2000/01/28 14:57:19 zeev Exp $ */
+/* $Id: rfc1867.c,v 1.23 2000/01/28 17:24:49 zeev Exp $ */
#include <stdio.h>
#include "php.h"
@@ -23,7 +23,7 @@
#include "ext/standard/file.h" /* for php_file_le_uploads() */
#include "zend_globals.h"
#include "php_globals.h"
-#include "php_gpce.h"
+#include "php_variables.h"
#include "rfc1867.h"
Index: php4/ext/apache/apache.c
diff -u php4/ext/apache/apache.c:1.26 php4/ext/apache/apache.c:1.27
--- php4/ext/apache/apache.c:1.26 Fri Dec 31 17:31:28 1999
+++ php4/ext/apache/apache.c Fri Jan 28 09:24:50 2000
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: apache.c,v 1.26 2000/01/01 01:31:28 sas Exp $ */
+/* $Id: apache.c,v 1.27 2000/01/28 17:24:50 zeev Exp $ */
#include "php.h"
#include "ext/standard/head.h"
#include "php_globals.h"
@@ -415,6 +415,7 @@
destroy_sub_req(rr);
}
/* }}} */
+
#if 0
This function is most likely a bad idea. Just playing with it for now.
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.87 php4/ext/standard/string.c:1.88
--- php4/ext/standard/string.c:1.87 Fri Jan 28 05:31:12 2000
+++ php4/ext/standard/string.c Fri Jan 28 09:24:50 2000
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.87 2000/01/28 13:31:12 zeev Exp $ */
+/* $Id: string.c,v 1.88 2000/01/28 17:24:50 zeev Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -26,7 +26,7 @@
#include "php.h"
#include "reg.h"
#include "php_string.h"
-#include "php_gpce.h"
+#include "php_variables.h"
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif
Index: php4/sapi/aolserver/aolserver.c
diff -u php4/sapi/aolserver/aolserver.c:1.28 php4/sapi/aolserver/aolserver.c:1.29
--- php4/sapi/aolserver/aolserver.c:1.28 Thu Jan 13 09:37:20 2000
+++ php4/sapi/aolserver/aolserver.c Fri Jan 28 09:24:50 2000
@@ -22,7 +22,7 @@
* - CGI/1.1 conformance
*/
-/* $Id: aolserver.c,v 1.28 2000/01/13 17:37:20 zeev Exp $ */
+/* $Id: aolserver.c,v 1.29 2000/01/28 17:24:50 zeev Exp $ */
/* conflict between PHP and AOLserver headers */
#define Debug php_Debug
@@ -206,7 +206,7 @@
NSLS_FETCH();
PUTS("<table border=5 width=600>\n");
- php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.28
2000/01/13 17:37:20 zeev Exp $");
+ php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.29
2000/01/28 17:24:50 zeev Exp $");
php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -307,6 +307,8 @@
php_ns_sapi_read_post, /* read POST data */
php_ns_sapi_read_cookies, /* read Cookies */
+
+ NULL, /* register server variables */
STANDARD_SAPI_MODULE_PROPERTIES
};
Index: php4/sapi/apache/mod_php4.c
diff -u php4/sapi/apache/mod_php4.c:1.13 php4/sapi/apache/mod_php4.c:1.14
--- php4/sapi/apache/mod_php4.c:1.13 Mon Jan 17 09:33:37 2000
+++ php4/sapi/apache/mod_php4.c Fri Jan 28 09:24:50 2000
@@ -17,7 +17,7 @@
| PHP 4.0 patches by Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: mod_php4.c,v 1.13 2000/01/17 17:33:37 zeev Exp $ */
+/* $Id: mod_php4.c,v 1.14 2000/01/28 17:24:50 zeev Exp $ */
#include "zend.h"
#include "php.h"
@@ -222,6 +222,39 @@
}
+static void sapi_apache_register_server_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC)
+{
+ pval **tmp_ptr;
+ register int i;
+ array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
+ table_entry *elts = (table_entry *) arr->elts;
+ int len;
+ char *script_filename=NULL;
+ ELS_FETCH();
+ PLS_FETCH();
+
+ for (i = 0; i < arr->nelts; i++) {
+ char *val;
+
+ if (elts[i].val) {
+ val = elts[i].val;
+ if (!strcmp(val, "SCRIPT_FILENAME")) {
+ script_filename = val;
+ }
+ } else {
+ val = empty_string;
+ }
+ php_register_variable(val, elts[i].key, NULL ELS_CC PLS_CC);
+ }
+
+ /* insert special variables */
+ if (script_filename) {
+ php_register_variable(script_filename, "PATH_TRANSLATED", NULL ELS_CC PLS_CC);
+ }
+ php_register_variable(SG(server_context)->uri, "PHP_SELF", NULL ELS_CC PLS_CC);
+}
+*
+
static sapi_module_struct sapi_module = {
"Apache", /* name */
@@ -240,6 +273,8 @@
sapi_apache_read_post, /* read POST data */
sapi_apache_read_cookies, /* read Cookies */
+
+ sapi_apache_register_server_variables, /* register server variables */
STANDARD_SAPI_MODULE_PROPERTIES
};
Index: php4/sapi/cgi/cgi_main.c
diff -u php4/sapi/cgi/cgi_main.c:1.15 php4/sapi/cgi/cgi_main.c:1.16
--- php4/sapi/cgi/cgi_main.c:1.15 Thu Jan 13 09:37:21 2000
+++ php4/sapi/cgi/cgi_main.c Fri Jan 28 09:24:51 2000
@@ -21,6 +21,7 @@
#include "php.h"
#include "php_globals.h"
+#include "php_variables.h"
#include "SAPI.h"
@@ -126,6 +127,37 @@
}
+static void sapi_cgi_register_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC)
+{
+ char *pi;
+
+ /* Build the special-case PHP_SELF variable for the CGI version */
+#if FORCE_CGI_REDIRECT
+ php_register_variable((SG(request_info).request_uri ? SG(request_info).request_uri,
"PHP_SELF", track_vars_array ELS_CC PLS_CC);
+#else
+ {
+ char *sn;
+ char *val;
+ int l=0;
+
+ sn = request_info.script_name;
+ pi = SG(request_info).request_uri;
+ if (sn)
+ l += strlen(sn);
+ if (pi)
+ l += strlen(pi);
+ if (pi && sn && !strcmp(pi, sn)) {
+ l -= strlen(pi);
+ pi = NULL;
+ }
+ val = emalloc(l + 1);
+ php_sprintf(val, "%s%s", (sn ? sn : ""), (pi ? pi : "")); /* SAFE
*/
+ php_register_variable(val, "PHP_SELF", track_vars_array ELS_CC PLS_CC);
+ }
+#endif
+}
+
+
static sapi_module_struct sapi_module = {
"CGI", /* name */
@@ -143,6 +175,8 @@
sapi_cgi_read_post, /* read POST data */
sapi_cgi_read_cookies, /* read Cookies */
+
+ sapi_cgi_register_variables, /* register server variables */
STANDARD_SAPI_MODULE_PROPERTIES
};
Index: php4/sapi/isapi/php4isapi.c
diff -u php4/sapi/isapi/php4isapi.c:1.11 php4/sapi/isapi/php4isapi.c:1.12
--- php4/sapi/isapi/php4isapi.c:1.11 Thu Jan 13 09:37:21 2000
+++ php4/sapi/isapi/php4isapi.c Fri Jan 28 09:24:51 2000
@@ -28,6 +28,7 @@
#include "SAPI.h"
#include "php_globals.h"
#include "ext/standard/info.h"
+#include "php_variables.h"
#ifdef WITH_ZEUS
#include "zeus.h"
@@ -290,6 +291,54 @@
}
+static void sapi_isapi_register_server_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC)
+{
+ char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE];
+ char *variable_buf;
+ DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
+ char *variable;
+ char *strtok_buf = NULL;
+ LPEXTENSION_CONTROL_BLOCK lpECB;
+
+ lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context);
+
+ if (lpECB->GetServerVariable(lpECB->ConnID, "ALL_HTTP", static_variable_buf,
&variable_len)) {
+ variable_buf = static_variable_buf;
+ } else {
+ if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) {
+ variable_buf = (char *) emalloc(variable_len);
+ if (!lpECB->GetServerVariable(lpECB->ConnID, "ALL_HTTP", variable_buf,
&variable_len)) {
+ efree(variable_buf);
+ return;
+ }
+ } else {
+ return;
+ }
+ }
+ variable = strtok_r(variable_buf, "\r\n", &strtok_buf);
+ while (variable) {
+ char *colon = strchr(variable, ':');
+
+ if (colon) {
+ char *value = colon+1;
+ zval *entry;
+
+ ALLOC_ZVAL(entry);
+ while (*value==' ') {
+ value++;
+ }
+ *colon = 0;
+ php_register_variable(value, variable, track_vars_array ELS_CC PLS_CC);
+ *colon = ':';
+ }
+ variable = strtok_r(NULL, "\r\n", &strtok_buf);
+ }
+ if (variable_buf!=static_variable_buf) {
+ efree(variable_buf);
+ }
+}
+
+
static sapi_module_struct sapi_module = {
"ISAPI", /* name */
@@ -308,6 +357,8 @@
sapi_isapi_read_post, /* read POST data */
sapi_isapi_read_cookies, /* read Cookies */
+ sapi_isapi_register_server_variables, /* register server variables */
+
STANDARD_SAPI_MODULE_PROPERTIES
};
@@ -378,58 +429,6 @@
}
-static void hash_isapi_variables(ELS_D SLS_DC)
-{
- char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE];
- char *variable_buf;
- DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
- char *variable;
- char *strtok_buf = NULL;
- LPEXTENSION_CONTROL_BLOCK lpECB;
-
- lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context);
-
- if (lpECB->GetServerVariable(lpECB->ConnID, "ALL_HTTP", static_variable_buf,
&variable_len)) {
- variable_buf = static_variable_buf;
- } else {
- if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) {
- variable_buf = (char *) emalloc(variable_len);
- if (!lpECB->GetServerVariable(lpECB->ConnID, "ALL_HTTP", variable_buf,
&variable_len)) {
- efree(variable_buf);
- return;
- }
- } else {
- return;
- }
- }
- variable = strtok_r(variable_buf, "\r\n", &strtok_buf);
- while (variable) {
- char *colon = strchr(variable, ':');
-
- if (colon) {
- char *value = colon+1;
- zval *entry;
-
- ALLOC_ZVAL(entry);
- while (*value==' ') {
- value++;
- }
- *colon = 0;
- INIT_PZVAL(entry);
- entry->value.str.len = strlen(value);
- entry->value.str.val = estrndup(value, entry->value.str.len);
- entry->type = IS_STRING;
- zend_hash_add(&EG(symbol_table), variable, strlen(variable)+1, &entry, sizeof(zval *),
NULL);
- *colon = ':';
- }
- variable = strtok_r(NULL, "\r\n", &strtok_buf);
- }
- if (variable_buf!=static_variable_buf) {
- efree(variable_buf);
- }
-}
-
-
DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB)
{
zend_file_handle file_handle;
@@ -450,7 +449,6 @@
file_handle.type = ZEND_HANDLE_FILENAME;
php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC);
- hash_isapi_variables(ELS_C SLS_CC);
php_execute_script(&file_handle CLS_CC ELS_CC PLS_CC);
if (SG(request_info).cookie_data) {
efree(SG(request_info).cookie_data);
Index: php4/sapi/phttpd/phttpd.c
diff -u php4/sapi/phttpd/phttpd.c:1.6 php4/sapi/phttpd/phttpd.c:1.7
--- php4/sapi/phttpd/phttpd.c:1.6 Thu Jan 13 09:37:22 2000
+++ php4/sapi/phttpd/phttpd.c Fri Jan 28 09:24:52 2000
@@ -179,6 +179,8 @@
php_phttpd_sapi_read_post, /* read POST data */
php_phttpd_sapi_read_cookies, /* read Cookies */
+ NULL, /* register server variables */
+
STANDARD_SAPI_MODULE_PROPERTIES
};
Index: php4/sapi/roxen/roxen.c
diff -u php4/sapi/roxen/roxen.c:1.12 php4/sapi/roxen/roxen.c:1.13
--- php4/sapi/roxen/roxen.c:1.12 Thu Jan 13 09:37:22 2000
+++ php4/sapi/roxen/roxen.c Fri Jan 28 09:24:52 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: roxen.c,v 1.12 2000/01/13 17:37:22 zeev Exp $ */
+/* $Id: roxen.c,v 1.13 2000/01/28 17:24:52 zeev Exp $ */
#include "php.h"
#ifdef HAVE_ROXEN
@@ -470,7 +470,7 @@
/* char buf[512]; */
PUTS("<table border=5 width=600>\n");
- php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.12 2000/01/13
17:37:22 zeev Exp $");
+ php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.13 2000/01/28
17:24:52 zeev Exp $");
/* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate());
php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile());
php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog());
@@ -532,6 +532,9 @@
php_roxen_sapi_read_post, /* read POST data */
php_roxen_sapi_read_cookies, /* read Cookies */
+
+ NULL, /* register server variables */
+
STANDARD_SAPI_MODULE_PROPERTIES
};
Index: php4/sapi/servlet/servlet.c
diff -u php4/sapi/servlet/servlet.c:1.10 php4/sapi/servlet/servlet.c:1.11
--- php4/sapi/servlet/servlet.c:1.10 Thu Jan 13 09:37:23 2000
+++ php4/sapi/servlet/servlet.c Fri Jan 28 09:24:53 2000
@@ -227,6 +227,8 @@
sapi_servlet_read_post, /* read POST data */
sapi_servlet_read_cookies, /* read Cookies */
+ NULL, /* register server variables */
+
STANDARD_SAPI_MODULE_PROPERTIES
};
Index: php4/sapi/thttpd/thttpd.c
diff -u php4/sapi/thttpd/thttpd.c:1.4 php4/sapi/thttpd/thttpd.c:1.5
--- php4/sapi/thttpd/thttpd.c:1.4 Thu Jan 13 09:37:24 2000
+++ php4/sapi/thttpd/thttpd.c Fri Jan 28 09:24:53 2000
@@ -118,6 +118,8 @@
sapi_thttpd_read_post,
sapi_thttpd_read_cookies,
+ NULL, /* register server variables */
+
STANDARD_SAPI_MODULE_PROPERTIES
};