]> granicus.if.org Git - php/commitdiff
@- In CGI mode, $HTTP_SERVER_VARS now includes all of the environment variables
authorZeev Suraski <zeev@php.net>
Tue, 7 Nov 2000 18:25:29 +0000 (18:25 +0000)
committerZeev Suraski <zeev@php.net>
Tue, 7 Nov 2000 18:25:29 +0000 (18:25 +0000)
@  as well (Zeev)

main/main.c
main/php_variables.c
main/php_variables.h
sapi/cgi/cgi_main.c

index 3a8af10da3cf33dee2ac06eead27a1db5992dc7f..2ef64e9af1c02abd4bc1a0e45b31bd64e44323bf 100644 (file)
@@ -1015,7 +1015,10 @@ static int php_hash_environment(ELS_D SLS_DC PLS_DC)
        } else {
                p = PG(gpc_order);
                have_variables_order=0;
-               php_import_environment_variables(ELS_C PLS_CC);
+               ALLOC_ZVAL(PG(http_globals)[TRACK_VARS_ENV]);
+               array_init(PG(http_globals)[TRACK_VARS_ENV]);
+               INIT_PZVAL(PG(http_globals)[TRACK_VARS_ENV]);
+               php_import_environment_variables(PG(http_globals)[TRACK_VARS_ENV] ELS_CC PLS_CC);
        }
 
        while(p && *p) {
@@ -1044,7 +1047,10 @@ static int php_hash_environment(ELS_D SLS_DC PLS_DC)
                        case 'e':
                        case 'E':
                                if (have_variables_order) {
-                                       php_import_environment_variables(ELS_C PLS_CC);
+                                       ALLOC_ZVAL(PG(http_globals)[TRACK_VARS_ENV]);
+                                       array_init(PG(http_globals)[TRACK_VARS_ENV]);
+                                       INIT_PZVAL(PG(http_globals)[TRACK_VARS_ENV]);
+                                       php_import_environment_variables(PG(http_globals)[TRACK_VARS_ENV] ELS_CC PLS_CC);
                                } else {
                                        php_error(E_WARNING, "Unsupported 'e' element (environment) used in gpc_order - use variables_order instead");
                                }
index bff78e4a793c77549eb89ed617d2202df39b4456..08a201e874b89eec8ea88c6ec83fb31b1a89fe3c 100644 (file)
@@ -301,15 +301,9 @@ void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC)
 
 
 
-void php_import_environment_variables(ELS_D PLS_DC)
+void php_import_environment_variables(zval *array_ptr ELS_DC PLS_DC)
 {
        char **env, *p, *t;
-       zval *array_ptr=NULL;
-
-       ALLOC_ZVAL(array_ptr);
-       array_init(array_ptr);
-       INIT_PZVAL(array_ptr);
-       PG(http_globals)[TRACK_VARS_ENV] = array_ptr;
 
        for (env = environ; env != NULL && *env != NULL; env++) {
                p = strchr(*env, '=');
index f71fe2762b1d9e40ba70983b8600485a37e23668..bd0a98810aa5197e1feb28cbb37c277fd122c787 100644 (file)
@@ -31,7 +31,7 @@
 #define PARSE_STRING 3
 
 void php_treat_data(int arg, char *str, zval* destArray ELS_DC PLS_DC SLS_DC);
-void php_import_environment_variables(ELS_D PLS_DC);
+PHPAPI void php_import_environment_variables(zval *array_ptr ELS_DC PLS_DC);
 PHPAPI void php_register_variable(char *var, char *val, pval *track_vars_array ELS_DC PLS_DC);
 PHPAPI void php_register_variable_ex(char *var, zval *val, pval *track_vars_array ELS_DC PLS_DC);
 
index c320fa289147021207fb8c8acec60229b9fd8006..67ed3b80b551b74848c4e06668dfd7e0e783db09 100644 (file)
@@ -148,6 +148,11 @@ static void sapi_cgi_register_variables(zval *track_vars_array ELS_DC SLS_DC PLS
 {
        char *pi;
 
+       /* In CGI mode, we consider the environment to be a part of the server
+        * variables
+        */
+       php_import_environment_variables(track_vars_array ELS_CC PLS_CC);
+
        /* Build the special-case PHP_SELF variable for the CGI version */
 #if FORCE_CGI_REDIRECT
        php_register_variable("PHP_SELF", (SG(request_info).request_uri ? SG(request_info).request_uri:""), track_vars_array ELS_CC PLS_CC);