Line 0
Link Here
|
|
|
1 |
--- main/main.c.orig Sun Jun 22 11:16:39 2003 |
2 |
+++ main/main.c Sun Jun 22 11:17:00 2003 |
3 |
|
4 |
@@ -134,7 +134,6 @@ static int short_track_vars_names_length |
5 |
|
6 |
#define NUM_TRACK_VARS (sizeof(short_track_vars_names_length)/sizeof(int)) |
7 |
|
8 |
- |
9 |
#define SAFE_FILENAME(f) ((f)?(f):"-") |
10 |
|
11 |
/* {{{ PHP_INI_MH |
12 |
@@ -1362,7 +1361,7 @@ static void php_autoglobal_merge(HashTab |
13 |
static int php_hash_environment(TSRMLS_D) |
14 |
{ |
15 |
char *p; |
16 |
- unsigned char _gpc_flags[3] = {0, 0, 0}; |
17 |
+ int _gpc_flags[5] = {0, 0, 0, 0, 0}; |
18 |
zend_bool have_variables_order; |
19 |
zval *dummy_track_vars_array = NULL; |
20 |
zend_bool initialized_dummy_track_vars_array=0; |
21 |
@@ -1409,42 +1408,48 @@ static int php_hash_environment(TSRMLS_D |
22 |
case 'P': |
23 |
if (!_gpc_flags[0] && !SG(headers_sent) && SG(request_info).request_method && !strcmp(SG(request_info).request_method, "POST")) { |
24 |
sapi_module.treat_data(PARSE_POST, NULL, NULL TSRMLS_CC); /* POST Data */ |
25 |
- _gpc_flags[0]=1; |
26 |
+ _gpc_flags[0]=TRACK_VARS_POST + 1; |
27 |
} |
28 |
break; |
29 |
case 'c': |
30 |
case 'C': |
31 |
if (!_gpc_flags[1]) { |
32 |
sapi_module.treat_data(PARSE_COOKIE, NULL, NULL TSRMLS_CC); /* Cookie Data */ |
33 |
- _gpc_flags[1]=1; |
34 |
+ _gpc_flags[1]=TRACK_VARS_COOKIE + 1; |
35 |
} |
36 |
break; |
37 |
case 'g': |
38 |
case 'G': |
39 |
if (!_gpc_flags[2]) { |
40 |
sapi_module.treat_data(PARSE_GET, NULL, NULL TSRMLS_CC); /* GET Data */ |
41 |
- _gpc_flags[2]=1; |
42 |
+ _gpc_flags[2]=TRACK_VARS_GET + 1; |
43 |
} |
44 |
break; |
45 |
case 'e': |
46 |
case 'E': |
47 |
- if (have_variables_order) { |
48 |
- ALLOC_ZVAL(PG(http_globals)[TRACK_VARS_ENV]); |
49 |
- array_init(PG(http_globals)[TRACK_VARS_ENV]); |
50 |
- INIT_PZVAL(PG(http_globals)[TRACK_VARS_ENV]); |
51 |
- php_import_environment_variables(PG(http_globals)[TRACK_VARS_ENV] TSRMLS_CC); |
52 |
- } else { |
53 |
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported 'e' element (environment) used in gpc_order - use variables_order instead"); |
54 |
+ if (!_gpc_flags[3]) { |
55 |
+ if (have_variables_order) { |
56 |
+ ALLOC_ZVAL(PG(http_globals)[TRACK_VARS_ENV]); |
57 |
+ array_init(PG(http_globals)[TRACK_VARS_ENV]); |
58 |
+ INIT_PZVAL(PG(http_globals)[TRACK_VARS_ENV]); |
59 |
+ php_import_environment_variables(PG(http_globals)[TRACK_VARS_ENV] TSRMLS_CC); |
60 |
+ } else { |
61 |
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported 'e' element (environment) used in gpc_order - use variables_order instead"); |
62 |
+ } |
63 |
+ _gpc_flags[3]=TRACK_VARS_ENV + 1; |
64 |
} |
65 |
break; |
66 |
case 's': |
67 |
case 'S': |
68 |
- php_register_server_variables(TSRMLS_C); |
69 |
+ if (!_gpc_flags[4]) { |
70 |
+ php_register_server_variables(TSRMLS_C); |
71 |
+ _gpc_flags[4]=TRACK_VARS_SERVER + 1; |
72 |
+ } |
73 |
break; |
74 |
} |
75 |
} |
76 |
|
77 |
- if (!have_variables_order) { |
78 |
+ if (!have_variables_order && !PG(http_globals)[TRACK_VARS_SERVER]) { |
79 |
php_register_server_variables(TSRMLS_C); |
80 |
} |
81 |
|
82 |
@@ -1453,6 +1458,14 @@ static int php_hash_environment(TSRMLS_D |
83 |
php_build_argv(SG(request_info).query_string TSRMLS_CC); |
84 |
} |
85 |
|
86 |
+ if (PG(register_globals)) { |
87 |
+ for (i = 0; i < 5; i++) { |
88 |
+ if (PG(http_globals)[i]) { |
89 |
+ php_autoglobal_merge(&EG(symbol_table), Z_ARRVAL_P(PG(http_globals)[i]) TSRMLS_CC); |
90 |
+ } |
91 |
+ } |
92 |
+ } |
93 |
+ |
94 |
for (i=0; i<NUM_TRACK_VARS; i++) { |
95 |
if (!PG(http_globals)[i]) { |
96 |
if (!initialized_dummy_track_vars_array) { |
97 |
@@ -1478,39 +1491,12 @@ static int php_hash_environment(TSRMLS_D |
98 |
array_init(form_variables); |
99 |
INIT_PZVAL(form_variables); |
100 |
|
101 |
- for (p=variables_order; p && *p; p++) { |
102 |
- switch (*p) { |
103 |
- case 'g': |
104 |
- case 'G': |
105 |
- php_autoglobal_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_GET]) TSRMLS_CC); |
106 |
- break; |
107 |
- case 'p': |
108 |
- case 'P': |
109 |
- php_autoglobal_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_POST]) TSRMLS_CC); |
110 |
- break; |
111 |
- case 'c': |
112 |
- case 'C': |
113 |
- php_autoglobal_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_COOKIE]) TSRMLS_CC); |
114 |
- break; |
115 |
- } |
116 |
- } |
117 |
- |
118 |
- if (PG(register_globals)) { |
119 |
- HashPosition pos; |
120 |
- zval **data; |
121 |
- char *string_key; |
122 |
- uint string_key_len; |
123 |
- ulong num_key; |
124 |
- |
125 |
- zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(form_variables), &pos); |
126 |
- while (zend_hash_get_current_data_ex(Z_ARRVAL_P(form_variables), (void **)&data, &pos) == SUCCESS) { |
127 |
- /* we only register string keys, since we cannot have $1234 */ |
128 |
- if (zend_hash_get_current_key_ex(Z_ARRVAL_P(form_variables), &string_key, &string_key_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING) { |
129 |
- ZEND_SET_SYMBOL_WITH_LENGTH(&EG(symbol_table), string_key, string_key_len, *data, (*data)->refcount+1, 0); |
130 |
- } |
131 |
- zend_hash_move_forward_ex(Z_ARRVAL_P(form_variables), &pos); |
132 |
+ for (i = 0; i < 3; i++) { |
133 |
+ if (_gpc_flags[i]) { |
134 |
+ php_autoglobal_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[(_gpc_flags[i] - 1)]) TSRMLS_CC); |
135 |
} |
136 |
} |
137 |
+ |
138 |
zend_hash_update(&EG(symbol_table), "_REQUEST", sizeof("_REQUEST"), &form_variables, sizeof(zval *), NULL); |
139 |
} |