Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 849 lines (748 sloc) 24.469 kb
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
1 /*
2 +----------------------------------------------------------------------+
dbeb4158 »
2004-01-08 - A belated happy holidays and PHP 5
3 | PHP Version 5 |
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
4 +----------------------------------------------------------------------+
8775a375 »
2012-01-01 - Year++
5 | Copyright (c) 1997-2012 The PHP Group |
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
6 +----------------------------------------------------------------------+
5bd93221 »
2006-01-01 bump year and license version
7 | This source file is subject to version 3.01 of the PHP license, |
c5724cbd »
1999-07-16 License update
8 | that is bundled with this package in the file LICENSE, and is |
f68c7ff2 »
2003-06-10 updating license information in the headers.
9 | available through the world-wide-web at the following url: |
5bd93221 »
2006-01-01 bump year and license version
10 | http://www.php.net/license/3_01.txt |
c5724cbd »
1999-07-16 License update
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
14 +----------------------------------------------------------------------+
15 | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
15fee4d3 »
1999-09-11 - Seriously optimize and clean php_parse_gpc_data()
16 | Zeev Suraski <zeev@zend.com> |
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
17 +----------------------------------------------------------------------+
18 */
8e3f23e3 »
2003-02-19 ws fixes + missing $Id$ tags, headers added
19
349b2beb »
2001-04-06 fixed typo in CVS id
20 /* $Id$ */
6f7c0ede »
1999-04-23 Remove tls.[ch]
21
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
22 #include <stdio.h>
23 #include "php.h"
fc678100 »
2000-01-28 post.c really had nothing to do with POST anymore, and it belongs to …
24 #include "ext/standard/php_standard.h"
66c05f70 »
2003-03-03 Fixed compiler warnings.
25 #include "ext/standard/credits.h"
9ab35ae3 »
2000-01-28 Tried to centralize global variable registration as much as possible:
26 #include "php_variables.h"
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
27 #include "php_globals.h"
8e0ae5d1 »
2000-08-21 Cleaning up some mess
28 #include "php_content_types.h"
3cd0af11 »
1999-04-26 * Get the Apache module to compile again
29 #include "SAPI.h"
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
30 #include "zend_globals.h"
31
96b9c0a5 »
2002-10-13 make php_import_environment_variables overwritable so fastcgi can cor…
32 /* for systems that need to override reading of environment variables */
33 void _php_import_environment_variables(zval *array_ptr TSRMLS_DC);
34 PHPAPI void (*php_import_environment_variables)(zval *array_ptr TSRMLS_DC) = _php_import_environment_variables;
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
35
d87cc976 »
2001-07-28 Redesigned thread safety mechanism - nua nua
36 PHPAPI void php_register_variable(char *var, char *strval, zval *track_vars_array TSRMLS_DC)
fe6f8712 »
2001-07-27 - Get rid of ELS_*(), and use TSRMLS_*() instead.
37 {
d87cc976 »
2001-07-28 Redesigned thread safety mechanism - nua nua
38 php_register_variable_safe(var, strval, strlen(strval), track_vars_array TSRMLS_CC);
0731f54d »
2000-12-12 Fix #7987: POST/GET: string with \0(%00) values not parsed correctly
39 }
40
41 /* binary-safe version */
d87cc976 »
2001-07-28 Redesigned thread safety mechanism - nua nua
42 PHPAPI void php_register_variable_safe(char *var, char *strval, int str_len, zval *track_vars_array TSRMLS_DC)
739bdec5 »
2000-02-19 Worked on beautifying rfc1867.c a bit
43 {
44 zval new_entry;
6ad0dbf5 »
2002-08-08 Add some assertion
45 assert(strval != NULL);
46
739bdec5 »
2000-02-19 Worked on beautifying rfc1867.c a bit
47 /* Prepare value */
c0332885 »
2001-09-25 Back-substitute for Z_* macro's. If it breaks some extension (the scr…
48 Z_STRLEN(new_entry) = str_len;
cc1c7af0 »
2011-07-22 - remove magic quotes support, functions are kept (see the NEWS entry…
49 Z_STRVAL(new_entry) = estrndup(strval, Z_STRLEN(new_entry));
c0332885 »
2001-09-25 Back-substitute for Z_* macro's. If it breaks some extension (the scr…
50 Z_TYPE(new_entry) = IS_STRING;
739bdec5 »
2000-02-19 Worked on beautifying rfc1867.c a bit
51
d87cc976 »
2001-07-28 Redesigned thread safety mechanism - nua nua
52 php_register_variable_ex(var, &new_entry, track_vars_array TSRMLS_CC);
739bdec5 »
2000-02-19 Worked on beautifying rfc1867.c a bit
53 }
54
f52d71d1 »
2008-08-30 Fix for bugs 13961, 39927 and 45947
55 PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars_array TSRMLS_DC)
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
56 {
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
57 char *p = NULL;
58 char *ip; /* index pointer */
29a909ed »
2012-02-02 Fixed memory leaks
59 char *index;
f52d71d1 »
2008-08-30 Fix for bugs 13961, 39927 and 45947
60 char *var, *var_orig;
739bdec5 »
2000-02-19 Worked on beautifying rfc1867.c a bit
61 int var_len, index_len;
93a52384 »
2003-06-14 Fixed bug #24007 (Problem with register_globals & arrays)
62 zval *gpc_element, **gpc_element_p;
e9d452b9 »
2006-04-07 Optimization
63 zend_bool is_array = 0;
e642d180 »
2005-04-23 ws, pval -> zval
64 HashTable *symtable1 = NULL;
ab6ce922 »
2010-08-26 Use stack instead of heap
65 ALLOCA_FLAG(use_heap)
eb321449 »
2000-09-05 - Remove track_vars - it is now always on
66
5f178004 »
2008-08-30 Oops, fix the assert.
67 assert(var_name != NULL);
322d57ff »
2008-08-30 WS
68
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
69 if (track_vars_array) {
683251eb »
2002-12-07 Fixed bug #20796. $_GET/$_POST/$_COOKIE data can get overwritten when
70 symtable1 = Z_ARRVAL_P(track_vars_array);
71 }
febee112 »
2010-04-21 Removed register_globals
72
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
73 if (!symtable1) {
eb321449 »
2000-09-05 - Remove track_vars - it is now always on
74 /* Nothing to do */
739bdec5 »
2000-02-19 Worked on beautifying rfc1867.c a bit
75 zval_dtor(val);
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
76 return;
77 }
78
e9d452b9 »
2006-04-07 Optimization
79
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
80 /* ignore leading spaces in the variable name */
ab6ce922 »
2010-08-26 Use stack instead of heap
81 while (*var_name && *var_name==' ') {
82 var_name++;
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
83 }
ab6ce922 »
2010-08-26 Use stack instead of heap
84
85 /*
86 * Prepare variable name
87 */
88 var_len = strlen(var_name);
89 var = var_orig = do_alloca(var_len + 1, use_heap);
90 memcpy(var_orig, var_name, var_len + 1);
e9d452b9 »
2006-04-07 Optimization
91
92 /* ensure that we don't have spaces or dots in the variable name (not binary safe) */
93 for (p = var; *p; p++) {
94 if (*p == ' ' || *p == '.') {
95 *p='_';
96 } else if (*p == '[') {
97 is_array = 1;
98 ip = p;
99 *p = 0;
100 break;
101 }
102 }
103 var_len = p - var;
104
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
105 if (var_len==0) { /* empty variable name, or variable name with a space in it */
739bdec5 »
2000-02-19 Worked on beautifying rfc1867.c a bit
106 zval_dtor(val);
ab6ce922 »
2010-08-26 Use stack instead of heap
107 free_alloca(var_orig, use_heap);
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
108 return;
109 }
1a04335e »
2005-09-28 MFH: Fixed possible GLOBALS variable override when register_globals a…
110
111 /* GLOBALS hijack attempt, reject parameter */
e9d452b9 »
2006-04-07 Optimization
112 if (symtable1 == EG(active_symbol_table) &&
113 var_len == sizeof("GLOBALS")-1 &&
114 !memcmp(var, "GLOBALS", sizeof("GLOBALS")-1)) {
1a04335e »
2005-09-28 MFH: Fixed possible GLOBALS variable override when register_globals a…
115 zval_dtor(val);
ab6ce922 »
2010-08-26 Use stack instead of heap
116 free_alloca(var_orig, use_heap);
1a04335e »
2005-09-28 MFH: Fixed possible GLOBALS variable override when register_globals a…
117 return;
118 }
119
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
120 index = var;
121 index_len = var_len;
122
e9d452b9 »
2006-04-07 Optimization
123 if (is_array) {
32fb34e2 »
2007-03-02 limit nesting level of input variables
124 int nest_level = 0;
e9d452b9 »
2006-04-07 Optimization
125 while (1) {
ba8cfb4a »
2005-08-10 Minor consistency cleanup
126 char *index_s;
1f506818 »
2002-12-29 Fixed bug #21149 (fixed handling of unterminated '[').
127 int new_idx_len = 0;
128
a0215e9a »
2007-03-02 fix variable name
129 if(++nest_level > PG(max_input_nesting_level)) {
a8be5f41 »
2007-06-03 Improved fix for MOPB-02-2007
130 HashTable *ht;
32fb34e2 »
2007-03-02 limit nesting level of input variables
131 /* too many levels of nesting */
a8be5f41 »
2007-06-03 Improved fix for MOPB-02-2007
132
133 if (track_vars_array) {
134 ht = Z_ARRVAL_P(track_vars_array);
66721716 »
2012-02-08 Fixed bug #61000 (Exceeding max nesting level doesn't delete numerica…
135 zend_symtable_del(ht, var, var_len + 1);
a8be5f41 »
2007-06-03 Improved fix for MOPB-02-2007
136 }
137
138 zval_dtor(val);
139
521917bd »
2007-07-18 MFH
140 /* do not output the error message to the screen,
141 this helps us to to avoid "information disclosure" */
a8be5f41 »
2007-06-03 Improved fix for MOPB-02-2007
142 if (!PG(display_errors)) {
f26145fa »
2007-06-03 MFH:- Improved the error message for exceeding max_input_nesting_level.
143 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variable nesting level exceeded %ld. To increase the limit change max_input_nesting_level in php.ini.", PG(max_input_nesting_level));
a8be5f41 »
2007-06-03 Improved fix for MOPB-02-2007
144 }
ab6ce922 »
2010-08-26 Use stack instead of heap
145 free_alloca(var_orig, use_heap);
a8be5f41 »
2007-06-03 Improved fix for MOPB-02-2007
146 return;
32fb34e2 »
2007-03-02 limit nesting level of input variables
147 }
148
1f506818 »
2002-12-29 Fixed bug #21149 (fixed handling of unterminated '[').
149 ip++;
150 index_s = ip;
151 if (isspace(*ip)) {
152 ip++;
153 }
154 if (*ip==']') {
155 index_s = NULL;
156 } else {
157 ip = strchr(ip, ']');
158 if (!ip) {
159 /* PHP variables cannot contain '[' in their names, so we replace the character with a '_' */
160 *(index_s - 1) = '_';
e865bc2b »
2004-10-18 fix bug #30442 ( segmentation fault when parsing ?getvariable[][ )
161
a8be5f41 »
2007-06-03 Improved fix for MOPB-02-2007
162 index_len = 0;
e865bc2b »
2004-10-18 fix bug #30442 ( segmentation fault when parsing ?getvariable[][ )
163 if (index) {
a8be5f41 »
2007-06-03 Improved fix for MOPB-02-2007
164 index_len = strlen(index);
e865bc2b »
2004-10-18 fix bug #30442 ( segmentation fault when parsing ?getvariable[][ )
165 }
1f506818 »
2002-12-29 Fixed bug #21149 (fixed handling of unterminated '[').
166 goto plain_var;
167 return;
168 }
169 *ip = 0;
170 new_idx_len = strlen(index_s);
171 }
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
172
173 if (!index) {
174 MAKE_STD_ZVAL(gpc_element);
175 array_init(gpc_element);
29a909ed »
2012-02-02 Fixed memory leaks
176 if (zend_hash_next_index_insert(symtable1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p) == FAILURE) {
177 zval_ptr_dtor(&gpc_element);
178 zval_dtor(val);
179 free_alloca(var_orig, use_heap);
180 return;
181 }
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
182 } else {
29a909ed »
2012-02-02 Fixed memory leaks
183 if (zend_symtable_find(symtable1, index, index_len + 1, (void **) &gpc_element_p) == FAILURE
c0332885 »
2001-09-25 Back-substitute for Z_* macro's. If it breaks some extension (the scr…
184 || Z_TYPE_PP(gpc_element_p) != IS_ARRAY) {
2ad7f44b »
2012-02-14 Improved max_input_vars directive to check nested variables
185 MAKE_STD_ZVAL(gpc_element);
186 array_init(gpc_element);
187 zend_symtable_update(symtable1, index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
188 }
189 }
c0332885 »
2001-09-25 Back-substitute for Z_* macro's. If it breaks some extension (the scr…
190 symtable1 = Z_ARRVAL_PP(gpc_element_p);
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
191 /* ip pointed to the '[' character, now obtain the key */
1f506818 »
2002-12-29 Fixed bug #21149 (fixed handling of unterminated '[').
192 index = index_s;
193 index_len = new_idx_len;
194
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
195 ip++;
e642d180 »
2005-04-23 ws, pval -> zval
196 if (*ip == '[') {
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
197 is_array = 1;
198 *ip = 0;
199 } else {
efad3787 »
2006-05-03 Fixed bug #37276 (problems witch $_POST array)
200 goto plain_var;
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
201 }
e9d452b9 »
2006-04-07 Optimization
202 }
203 } else {
1f506818 »
2002-12-29 Fixed bug #21149 (fixed handling of unterminated '[').
204 plain_var:
e9d452b9 »
2006-04-07 Optimization
205 MAKE_STD_ZVAL(gpc_element);
206 gpc_element->value = val->value;
207 Z_TYPE_P(gpc_element) = Z_TYPE_P(val);
208 if (!index) {
29a909ed »
2012-02-02 Fixed memory leaks
209 if (zend_hash_next_index_insert(symtable1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p) == FAILURE) {
210 zval_ptr_dtor(&gpc_element);
211 }
e9d452b9 »
2006-04-07 Optimization
212 } else {
213 /*
214 * According to rfc2965, more specific paths are listed above the less specific ones.
215 * If we encounter a duplicate cookie name, we should skip it, since it is not possible
216 * to have the same (plain text) cookie name for the same path and we should not overwrite
217 * more specific cookies with the less specific ones.
218 */
219 if (PG(http_globals)[TRACK_VARS_COOKIE] &&
220 symtable1 == Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_COOKIE]) &&
29a909ed »
2012-02-02 Fixed memory leaks
221 zend_symtable_exists(symtable1, index, index_len + 1)) {
e9d452b9 »
2006-04-07 Optimization
222 zval_ptr_dtor(&gpc_element);
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
223 } else {
2ad7f44b »
2012-02-14 Improved max_input_vars directive to check nested variables
224 zend_symtable_update(symtable1, index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
225 }
226 }
227 }
ab6ce922 »
2010-08-26 Use stack instead of heap
228 free_alloca(var_orig, use_heap);
b2c0acb9 »
1999-09-12 - Rewrote the GET/POST/Cookie data reader to support multi-dimensional
229 }
230
0dab84d0 »
2001-08-15 fix SAPI_POST_* exports
231 SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)
a6393de6 »
2000-02-17 Make POST handling the way it should be. RFC1867, and any future POST…
232 {
7ba86d07 »
2006-07-27 Fixed bug #38236 (Binary data gets corrupted on multipart/formdata PO…
233 char *var, *val, *e, *s, *p;
a6393de6 »
2000-02-17 Make POST handling the way it should be. RFC1867, and any future POST…
234 zval *array_ptr = (zval *) arg;
2ad7f44b »
2012-02-14 Improved max_input_vars directive to check nested variables
235 long count = 0;
a6393de6 »
2000-02-17 Make POST handling the way it should be. RFC1867, and any future POST…
236
e642d180 »
2005-04-23 ws, pval -> zval
237 if (SG(request_info).post_data == NULL) {
5b3ee5f2 »
2002-07-24 break out if there is no data to work on.
238 return;
239 }
240
7ba86d07 »
2006-07-27 Fixed bug #38236 (Binary data gets corrupted on multipart/formdata PO…
241 s = SG(request_info).post_data;
242 e = s + SG(request_info).post_data_length;
a6393de6 »
2000-02-17 Make POST handling the way it should be. RFC1867, and any future POST…
243
7ba86d07 »
2006-07-27 Fixed bug #38236 (Binary data gets corrupted on multipart/formdata PO…
244 while (s < e && (p = memchr(s, '&', (e - s)))) {
245 last_value:
246 if ((val = memchr(s, '=', (p - s)))) { /* have a value */
750b0338 »
2003-11-29 - Fix sapi_input_filter patch. Returning 1 from the filter handler sh…
247 unsigned int val_len, new_val_len;
0731f54d »
2000-12-12 Fix #7987: POST/GET: string with \0(%00) values not parsed correctly
248
2ad7f44b »
2012-02-14 Improved max_input_vars directive to check nested variables
249 if (++count > PG(max_input_vars)) {
250 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
251 return;
252 }
7ba86d07 »
2006-07-27 Fixed bug #38236 (Binary data gets corrupted on multipart/formdata PO…
253 var = s;
254
255 php_url_decode(var, (val - s));
256 val++;
257 val_len = php_url_decode(val, (p - val));
59d55efb »
2004-06-26 As long we pass values by reference this is needed. Ugly!
258 val = estrndup(val, val_len);
750b0338 »
2003-11-29 - Fix sapi_input_filter patch. Returning 1 from the filter handler sh…
259 if (sapi_module.input_filter(PARSE_POST, var, &val, val_len, &new_val_len TSRMLS_CC)) {
260 php_register_variable_safe(var, val, new_val_len, array_ptr TSRMLS_CC);
370dfd39 »
2003-11-26 - Prevent registration of the variable when a zero-length is returned
261 }
59d55efb »
2004-06-26 As long we pass values by reference this is needed. Ugly!
262 efree(val);
a6393de6 »
2000-02-17 Make POST handling the way it should be. RFC1867, and any future POST…
263 }
7ba86d07 »
2006-07-27 Fixed bug #38236 (Binary data gets corrupted on multipart/formdata PO…
264 s = p + 1;
265 }
266 if (s < e) {
267 p = e;
268 goto last_value;
a6393de6 »
2000-02-17 Make POST handling the way it should be. RFC1867, and any future POST…
269 }
270 }
271
7429c2dc »
2003-02-19 Input Filter support. See README.input_filter for details.
272 SAPI_API SAPI_INPUT_FILTER_FUNC(php_default_input_filter)
273 {
274 /* TODO: check .ini setting here and apply user-defined input filter */
c3545444 »
2005-07-25 I could have sworn I committed this a while ago. Just a tiny NULL safety
275 if(new_val_len) *new_val_len = val_len;
74eed615 »
2003-12-01 - Fix the default SAPI filter too; all weird problems should be gone …
276 return 1;
7429c2dc »
2003-02-19 Input Filter support. See README.input_filter for details.
277 }
278
7527bf0c »
2002-08-02 made sapi_register_treat_data() to support multibyte input encoding t…
279 SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
280 {
e642d180 »
2005-04-23 ws, pval -> zval
281 char *res = NULL, *var, *val, *separator = NULL;
43ff395b »
2000-11-02 Const'ify part of sapi_request_info.
282 const char *c_var;
e642d180 »
2005-04-23 ws, pval -> zval
283 zval *array_ptr;
284 int free_buffer = 0;
38819040 »
1999-11-26 Replace strtok with strtok_r
285 char *strtok_buf = NULL;
2ad7f44b »
2012-02-14 Improved max_input_vars directive to check nested variables
286 long count = 0;
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
287
288 switch (arg) {
289 case PARSE_POST:
290 case PARSE_GET:
291 case PARSE_COOKIE:
eb321449 »
2000-09-05 - Remove track_vars - it is now always on
292 ALLOC_ZVAL(array_ptr);
293 array_init(array_ptr);
294 INIT_PZVAL(array_ptr);
295 switch (arg) {
296 case PARSE_POST:
28446a4e »
2005-06-01 Fixed "refcount" counting for autoglobals
297 if (PG(http_globals)[TRACK_VARS_POST]) {
298 zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_POST]);
299 }
eb321449 »
2000-09-05 - Remove track_vars - it is now always on
300 PG(http_globals)[TRACK_VARS_POST] = array_ptr;
301 break;
302 case PARSE_GET:
28446a4e »
2005-06-01 Fixed "refcount" counting for autoglobals
303 if (PG(http_globals)[TRACK_VARS_GET]) {
304 zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_GET]);
305 }
eb321449 »
2000-09-05 - Remove track_vars - it is now always on
306 PG(http_globals)[TRACK_VARS_GET] = array_ptr;
307 break;
308 case PARSE_COOKIE:
28446a4e »
2005-06-01 Fixed "refcount" counting for autoglobals
309 if (PG(http_globals)[TRACK_VARS_COOKIE]) {
310 zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_COOKIE]);
311 }
eb321449 »
2000-09-05 - Remove track_vars - it is now always on
312 PG(http_globals)[TRACK_VARS_COOKIE] = array_ptr;
313 break;
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
314 }
315 break;
316 default:
e642d180 »
2005-04-23 ws, pval -> zval
317 array_ptr = destArray;
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
318 break;
319 }
320
e642d180 »
2005-04-23 ws, pval -> zval
321 if (arg == PARSE_POST) {
d87cc976 »
2001-07-28 Redesigned thread safety mechanism - nua nua
322 sapi_handle_post(array_ptr TSRMLS_CC);
a6393de6 »
2000-02-17 Make POST handling the way it should be. RFC1867, and any future POST…
323 return;
324 }
325
326 if (arg == PARSE_GET) { /* GET data */
43ff395b »
2000-11-02 Const'ify part of sapi_request_info.
327 c_var = SG(request_info).query_string;
328 if (c_var && *c_var) {
329 res = (char *) estrdup(c_var);
4079f914 »
1999-05-09 * Make read_post() read input by chunks instead of returning a single…
330 free_buffer = 1;
331 } else {
332 free_buffer = 0;
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
333 }
334 } else if (arg == PARSE_COOKIE) { /* Cookie data */
43ff395b »
2000-11-02 Const'ify part of sapi_request_info.
335 c_var = SG(request_info).cookie_data;
336 if (c_var && *c_var) {
337 res = (char *) estrdup(c_var);
4079f914 »
1999-05-09 * Make read_post() read input by chunks instead of returning a single…
338 free_buffer = 1;
339 } else {
340 free_buffer = 0;
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
341 }
342 } else if (arg == PARSE_STRING) { /* String data */
343 res = str;
4079f914 »
1999-05-09 * Make read_post() read input by chunks instead of returning a single…
344 free_buffer = 1;
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
345 }
a6393de6 »
2000-02-17 Make POST handling the way it should be. RFC1867, and any future POST…
346
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
347 if (!res) {
348 return;
349 }
350
c34d2b91 »
2001-04-04 Added new configuration directives:
351 switch (arg) {
352 case PARSE_GET:
353 case PARSE_STRING:
354 separator = (char *) estrdup(PG(arg_separator).input);
355 break;
356 case PARSE_COOKIE:
e77c65f0 »
2005-07-18 Revert cookie patch for BC reasons.
357 separator = ";\0";
c34d2b91 »
2001-04-04 Added new configuration directives:
358 break;
359 }
360
460293fb »
2001-04-04 Cookies use ; as argument separator.
361 var = php_strtok_r(res, separator, &strtok_buf);
362
a6393de6 »
2000-02-17 Make POST handling the way it should be. RFC1867, and any future POST…
363 while (var) {
364 val = strchr(var, '=');
847741cb »
2006-12-09 Strip leading spaces from cookie names, that can come from multi-cookie
365
366 if (arg == PARSE_COOKIE) {
367 /* Remove leading spaces from cookie names, needed for multi-cookie header where ; can be followed by a space */
368 while (isspace(*var)) {
369 var++;
370 }
371 if (var == val || *var == '\0') {
372 goto next_cookie;
373 }
374 }
375
2ad7f44b »
2012-02-14 Improved max_input_vars directive to check nested variables
376 if (++count > PG(max_input_vars)) {
377 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
378 break;
379 }
380
a6393de6 »
2000-02-17 Make POST handling the way it should be. RFC1867, and any future POST…
381 if (val) { /* have a value */
0731f54d »
2000-12-12 Fix #7987: POST/GET: string with \0(%00) values not parsed correctly
382 int val_len;
750b0338 »
2003-11-29 - Fix sapi_input_filter patch. Returning 1 from the filter handler sh…
383 unsigned int new_val_len;
0731f54d »
2000-12-12 Fix #7987: POST/GET: string with \0(%00) values not parsed correctly
384
a6393de6 »
2000-02-17 Make POST handling the way it should be. RFC1867, and any future POST…
385 *val++ = '\0';
386 php_url_decode(var, strlen(var));
b83255aa »
2002-09-08 Fix last commit. This line isn't supposed to be replaced.
387 val_len = php_url_decode(val, strlen(val));
59d55efb »
2004-06-26 As long we pass values by reference this is needed. Ugly!
388 val = estrndup(val, val_len);
8c075de7 »
2004-07-11 Fixed: PARSE_TYPE parameter to input_filter
389 if (sapi_module.input_filter(arg, var, &val, val_len, &new_val_len TSRMLS_CC)) {
750b0338 »
2003-11-29 - Fix sapi_input_filter patch. Returning 1 from the filter handler sh…
390 php_register_variable_safe(var, val, new_val_len, array_ptr TSRMLS_CC);
370dfd39 »
2003-11-26 - Prevent registration of the variable when a zero-length is returned
391 }
59d55efb »
2004-06-26 As long we pass values by reference this is needed. Ugly!
392 efree(val);
a842e12a »
2002-07-31 Fix for non-mbstring builds. Bad Yasuo! :)
393 } else {
0e8de752 »
2004-07-11 Ooups...
394 int val_len;
395 unsigned int new_val_len;
396
17e0d9c6 »
2002-09-07 MFB
397 php_url_decode(var, strlen(var));
8c075de7 »
2004-07-11 Fixed: PARSE_TYPE parameter to input_filter
398 val_len = 0;
399 val = estrndup("", val_len);
400 if (sapi_module.input_filter(arg, var, &val, val_len, &new_val_len TSRMLS_CC)) {
401 php_register_variable_safe(var, val, new_val_len, array_ptr TSRMLS_CC);
402 }
403 efree(val);
92e542db »
2002-07-28 Fixed some.php?a&b&c does not initilize $_GET['a'], $_GET['b'], $_GET…
404 }
847741cb »
2006-12-09 Strip leading spaces from cookie names, that can come from multi-cookie
405 next_cookie:
460293fb »
2001-04-04 Cookies use ; as argument separator.
406 var = php_strtok_r(NULL, separator, &strtok_buf);
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
407 }
c34d2b91 »
2001-04-04 Added new configuration directives:
408
e642d180 »
2005-04-23 ws, pval -> zval
409 if (arg != PARSE_COOKIE) {
c34d2b91 »
2001-04-04 Added new configuration directives:
410 efree(separator);
411 }
412
4079f914 »
1999-05-09 * Make read_post() read input by chunks instead of returning a single…
413 if (free_buffer) {
414 efree(res);
415 }
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
416 }
417
96b9c0a5 »
2002-10-13 make php_import_environment_variables overwritable so fastcgi can cor…
418 void _php_import_environment_variables(zval *array_ptr TSRMLS_DC)
9ab35ae3 »
2000-01-28 Tried to centralize global variable registration as much as possible:
419 {
961ad8e2 »
2003-03-27 Improved php_import_environment_variables: avoid emalloc()ing in most…
420 char buf[128];
421 char **env, *p, *t = buf;
422 size_t alloc_size = sizeof(buf);
e1eb238c »
2003-03-28 On 64bit platforms, pointers are 64bit long..
423 unsigned long nlen; /* ptrdiff_t is not portable */
961ad8e2 »
2003-03-27 Improved php_import_environment_variables: avoid emalloc()ing in most…
424
9ab35ae3 »
2000-01-28 Tried to centralize global variable registration as much as possible:
425 for (env = environ; env != NULL && *env != NULL; env++) {
426 p = strchr(*env, '=');
427 if (!p) { /* malformed entry? */
428 continue;
429 }
961ad8e2 »
2003-03-27 Improved php_import_environment_variables: avoid emalloc()ing in most…
430 nlen = p - *env;
431 if (nlen >= alloc_size) {
432 alloc_size = nlen + 64;
433 t = (t == buf ? emalloc(alloc_size): erealloc(t, alloc_size));
434 }
435 memcpy(t, *env, nlen);
436 t[nlen] = '\0';
e642d180 »
2005-04-23 ws, pval -> zval
437 php_register_variable(t, p + 1, array_ptr TSRMLS_CC);
961ad8e2 »
2003-03-27 Improved php_import_environment_variables: avoid emalloc()ing in most…
438 }
439 if (t != buf && t != NULL) {
9ab35ae3 »
2000-01-28 Tried to centralize global variable registration as much as possible:
440 efree(t);
441 }
442 }
443
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
444 zend_bool php_std_auto_global_callback(char *name, uint name_len TSRMLS_DC)
445 {
446 zend_printf("%s\n", name);
447 return 0; /* don't rearm */
448 }
449
450 /* {{{ php_build_argv
451 */
452 static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
453 {
e642d180 »
2005-04-23 ws, pval -> zval
454 zval *arr, *argc, *tmp;
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
455 int count = 0;
456 char *ss, *space;
457
febee112 »
2010-04-21 Removed register_globals
458 if (!(SG(request_info).argc || track_vars_array)) {
b3920d50 »
2003-10-01 Made the $argc and $argv always available as globals in CLI, and not as
459 return;
460 }
461
73e4913c »
2006-04-18 Fixed memory leaks
462 ALLOC_INIT_ZVAL(arr);
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
463 array_init(arr);
464
465 /* Prepare argv */
466 if (SG(request_info).argc) { /* are we in cli sapi? */
467 int i;
e642d180 »
2005-04-23 ws, pval -> zval
468 for (i = 0; i < SG(request_info).argc; i++) {
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
469 ALLOC_ZVAL(tmp);
470 Z_TYPE_P(tmp) = IS_STRING;
471 Z_STRLEN_P(tmp) = strlen(SG(request_info).argv[i]);
472 Z_STRVAL_P(tmp) = estrndup(SG(request_info).argv[i], Z_STRLEN_P(tmp));
473 INIT_PZVAL(tmp);
e642d180 »
2005-04-23 ws, pval -> zval
474 if (zend_hash_next_index_insert(Z_ARRVAL_P(arr), &tmp, sizeof(zval *), NULL) == FAILURE) {
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
475 if (Z_TYPE_P(tmp) == IS_STRING) {
476 efree(Z_STRVAL_P(tmp));
477 }
478 }
479 }
480 } else if (s && *s) {
481 ss = s;
482 while (ss) {
483 space = strchr(ss, '+');
484 if (space) {
485 *space = '\0';
486 }
487 /* auto-type */
488 ALLOC_ZVAL(tmp);
489 Z_TYPE_P(tmp) = IS_STRING;
490 Z_STRLEN_P(tmp) = strlen(ss);
491 Z_STRVAL_P(tmp) = estrndup(ss, Z_STRLEN_P(tmp));
492 INIT_PZVAL(tmp);
493 count++;
e642d180 »
2005-04-23 ws, pval -> zval
494 if (zend_hash_next_index_insert(Z_ARRVAL_P(arr), &tmp, sizeof(zval *), NULL) == FAILURE) {
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
495 if (Z_TYPE_P(tmp) == IS_STRING) {
496 efree(Z_STRVAL_P(tmp));
497 }
498 }
499 if (space) {
500 *space = '+';
501 ss = space + 1;
502 } else {
503 ss = space;
504 }
505 }
506 }
507
508 /* prepare argc */
73e4913c »
2006-04-18 Fixed memory leaks
509 ALLOC_INIT_ZVAL(argc);
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
510 if (SG(request_info).argc) {
511 Z_LVAL_P(argc) = SG(request_info).argc;
512 } else {
513 Z_LVAL_P(argc) = count;
514 }
515 Z_TYPE_P(argc) = IS_LONG;
516
febee112 »
2010-04-21 Removed register_globals
517 if (SG(request_info).argc) {
4b4d634c »
2007-10-07 MFH: Added macros for managing zval refcounts and is_ref statuses
518 Z_ADDREF_P(arr);
519 Z_ADDREF_P(argc);
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
520 zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL);
521 zend_hash_add(&EG(symbol_table), "argc", sizeof("argc"), &argc, sizeof(zval *), NULL);
dd7bdcf4 »
2003-10-07 Fix $_SERVER['argv'] and $_SERVER['argc']
522 }
523 if (track_vars_array) {
4b4d634c »
2007-10-07 MFH: Added macros for managing zval refcounts and is_ref statuses
524 Z_ADDREF_P(arr);
525 Z_ADDREF_P(argc);
e642d180 »
2005-04-23 ws, pval -> zval
526 zend_hash_update(Z_ARRVAL_P(track_vars_array), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL);
527 zend_hash_update(Z_ARRVAL_P(track_vars_array), "argc", sizeof("argc"), &argc, sizeof(zval *), NULL);
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
528 }
73e4913c »
2006-04-18 Fixed memory leaks
529 zval_ptr_dtor(&arr);
530 zval_ptr_dtor(&argc);
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
531 }
532 /* }}} */
533
534 /* {{{ php_register_server_variables
535 */
536 static inline void php_register_server_variables(TSRMLS_D)
537 {
e642d180 »
2005-04-23 ws, pval -> zval
538 zval *array_ptr = NULL;
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
539
540 ALLOC_ZVAL(array_ptr);
541 array_init(array_ptr);
542 INIT_PZVAL(array_ptr);
28446a4e »
2005-06-01 Fixed "refcount" counting for autoglobals
543 if (PG(http_globals)[TRACK_VARS_SERVER]) {
544 zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_SERVER]);
545 }
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
546 PG(http_globals)[TRACK_VARS_SERVER] = array_ptr;
547
548 /* Server variables */
549 if (sapi_module.register_server_variables) {
550 sapi_module.register_server_variables(array_ptr TSRMLS_CC);
551 }
552
553 /* PHP Authentication support */
554 if (SG(request_info).auth_user) {
555 php_register_variable("PHP_AUTH_USER", SG(request_info).auth_user, array_ptr TSRMLS_CC);
556 }
557 if (SG(request_info).auth_password) {
558 php_register_variable("PHP_AUTH_PW", SG(request_info).auth_password, array_ptr TSRMLS_CC);
559 }
8235a70e »
2005-04-04 added a server variable PHP_AUTH_DIGEST to support HTTP Digest Authen…
560 if (SG(request_info).auth_digest) {
561 php_register_variable("PHP_AUTH_DIGEST", SG(request_info).auth_digest, array_ptr TSRMLS_CC);
562 }
0802b128 »
2004-10-24 Make request start time be available via $_SERVER['REQUEST_TIME'].
563 /* store request init time */
564 {
a4305214 »
2012-01-06 Changed: restoring REQUEST_TIME as a long, introducing REQUEST_TIME_F…
565 zval request_time_float, request_time_long;
566 Z_TYPE(request_time_float) = IS_DOUBLE;
567 Z_DVAL(request_time_float) = sapi_get_request_time(TSRMLS_C);
568 php_register_variable_ex("REQUEST_TIME_FLOAT", &request_time_float, array_ptr TSRMLS_CC);
569 Z_TYPE(request_time_long) = IS_LONG;
570 Z_LVAL(request_time_long) = zend_dval_to_lval(Z_DVAL(request_time_float));
571 php_register_variable_ex("REQUEST_TIME", &request_time_long, array_ptr TSRMLS_CC);
0802b128 »
2004-10-24 Make request start time be available via $_SERVER['REQUEST_TIME'].
572 }
573
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
574 }
575 /* }}} */
576
023c8a7d »
2003-07-21 Fix register_globals
577 /* {{{ php_autoglobal_merge
578 */
579 static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC)
580 {
0a49c033 »
2003-07-22 - Use the new infrastructure of zend_symtable_*() (fixes bug #24565)
581 zval **src_entry, **dest_entry;
582 char *string_key;
583 uint string_key_len;
584 ulong num_key;
585 HashPosition pos;
586 int key_type;
febee112 »
2010-04-21 Removed register_globals
587 int globals_check = (dest == (&EG(symbol_table)));
023c8a7d »
2003-07-21 Fix register_globals
588
589 zend_hash_internal_pointer_reset_ex(src, &pos);
590 while (zend_hash_get_current_data_ex(src, (void **)&src_entry, &pos) == SUCCESS) {
591 key_type = zend_hash_get_current_key_ex(src, &string_key, &string_key_len, &num_key, 0, &pos);
0a49c033 »
2003-07-22 - Use the new infrastructure of zend_symtable_*() (fixes bug #24565)
592 if (Z_TYPE_PP(src_entry) != IS_ARRAY
e642d180 »
2005-04-23 ws, pval -> zval
593 || (key_type == HASH_KEY_IS_STRING && zend_hash_find(dest, string_key, string_key_len, (void **) &dest_entry) != SUCCESS)
594 || (key_type == HASH_KEY_IS_LONG && zend_hash_index_find(dest, num_key, (void **)&dest_entry) != SUCCESS)
595 || Z_TYPE_PP(dest_entry) != IS_ARRAY
04848558 »
2011-08-23 - ws
596 ) {
4b4d634c »
2007-10-07 MFH: Added macros for managing zval refcounts and is_ref statuses
597 Z_ADDREF_PP(src_entry);
023c8a7d »
2003-07-21 Fix register_globals
598 if (key_type == HASH_KEY_IS_STRING) {
ed9e8c7c »
2005-02-17 Fixed bug #31440 ($GLOBALS can be overwritten via GPC when register_g…
599 if (!globals_check || string_key_len != sizeof("GLOBALS") || memcmp(string_key, "GLOBALS", sizeof("GLOBALS") - 1)) {
600 zend_hash_update(dest, string_key, string_key_len, src_entry, sizeof(zval *), NULL);
601 } else {
4b4d634c »
2007-10-07 MFH: Added macros for managing zval refcounts and is_ref statuses
602 Z_DELREF_PP(src_entry);
ed9e8c7c »
2005-02-17 Fixed bug #31440 ($GLOBALS can be overwritten via GPC when register_g…
603 }
023c8a7d »
2003-07-21 Fix register_globals
604 } else {
605 zend_hash_index_update(dest, num_key, src_entry, sizeof(zval *), NULL);
606 }
607 } else {
608 SEPARATE_ZVAL(dest_entry);
609 php_autoglobal_merge(Z_ARRVAL_PP(dest_entry), Z_ARRVAL_PP(src_entry) TSRMLS_CC);
610 }
611 zend_hash_move_forward_ex(src, &pos);
612 }
613 }
614 /* }}} */
615
e43ff135 »
2011-09-13 Fixed ZE specific compile warnings (Bug #55629)
616 static zend_bool php_auto_globals_create_server(const char *name, uint name_len TSRMLS_DC);
617 static zend_bool php_auto_globals_create_env(const char *name, uint name_len TSRMLS_DC);
618 static zend_bool php_auto_globals_create_request(const char *name, uint name_len TSRMLS_DC);
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
619
620 /* {{{ php_hash_environment
621 */
622 int php_hash_environment(TSRMLS_D)
623 {
f0c8366a »
2010-07-08 - use interned strings for auto globals
624 memset(PG(http_globals), 0, sizeof(PG(http_globals)));
625 zend_activate_auto_globals(TSRMLS_C);
b3920d50 »
2003-10-01 Made the $argc and $argv always available as globals in CLI, and not as
626 if (PG(register_argc_argv)) {
627 php_build_argv(SG(request_info).query_string, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC);
628 }
f0c8366a »
2010-07-08 - use interned strings for auto globals
629 return SUCCESS;
630 }
631 /* }}} */
b3920d50 »
2003-10-01 Made the $argc and $argv always available as globals in CLI, and not as
632
e43ff135 »
2011-09-13 Fixed ZE specific compile warnings (Bug #55629)
633 static zend_bool php_auto_globals_create_get(const char *name, uint name_len TSRMLS_DC)
f0c8366a »
2010-07-08 - use interned strings for auto globals
634 {
635 zval *vars;
636
637 if (PG(variables_order) && (strchr(PG(variables_order),'G') || strchr(PG(variables_order),'g'))) {
638 sapi_module.treat_data(PARSE_GET, NULL, NULL TSRMLS_CC);
639 vars = PG(http_globals)[TRACK_VARS_GET];
640 } else {
641 ALLOC_ZVAL(vars);
642 array_init(vars);
643 INIT_PZVAL(vars);
644 if (PG(http_globals)[TRACK_VARS_GET]) {
645 zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_GET]);
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
646 }
f0c8366a »
2010-07-08 - use interned strings for auto globals
647 PG(http_globals)[TRACK_VARS_GET] = vars;
648 }
649
650 zend_hash_update(&EG(symbol_table), name, name_len + 1, &vars, sizeof(zval *), NULL);
651 Z_ADDREF_P(vars);
652
653 return 0; /* don't rearm */
654 }
655
e43ff135 »
2011-09-13 Fixed ZE specific compile warnings (Bug #55629)
656 static zend_bool php_auto_globals_create_post(const char *name, uint name_len TSRMLS_DC)
f0c8366a »
2010-07-08 - use interned strings for auto globals
657 {
658 zval *vars;
659
660 if (PG(variables_order) &&
04848558 »
2011-08-23 - ws
661 (strchr(PG(variables_order),'P') || strchr(PG(variables_order),'p')) &&
f0c8366a »
2010-07-08 - use interned strings for auto globals
662 !SG(headers_sent) &&
663 SG(request_info).request_method &&
664 !strcasecmp(SG(request_info).request_method, "POST")) {
665 sapi_module.treat_data(PARSE_POST, NULL, NULL TSRMLS_CC);
666 vars = PG(http_globals)[TRACK_VARS_POST];
667 } else {
668 ALLOC_ZVAL(vars);
669 array_init(vars);
670 INIT_PZVAL(vars);
671 if (PG(http_globals)[TRACK_VARS_POST]) {
672 zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_POST]);
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
673 }
f0c8366a »
2010-07-08 - use interned strings for auto globals
674 PG(http_globals)[TRACK_VARS_POST] = vars;
675 }
676
677 zend_hash_update(&EG(symbol_table), name, name_len + 1, &vars, sizeof(zval *), NULL);
678 Z_ADDREF_P(vars);
679
680 return 0; /* don't rearm */
681 }
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
682
e43ff135 »
2011-09-13 Fixed ZE specific compile warnings (Bug #55629)
683 static zend_bool php_auto_globals_create_cookie(const char *name, uint name_len TSRMLS_DC)
f0c8366a »
2010-07-08 - use interned strings for auto globals
684 {
685 zval *vars;
686
687 if (PG(variables_order) && (strchr(PG(variables_order),'C') || strchr(PG(variables_order),'c'))) {
688 sapi_module.treat_data(PARSE_COOKIE, NULL, NULL TSRMLS_CC);
689 vars = PG(http_globals)[TRACK_VARS_COOKIE];
690 } else {
691 ALLOC_ZVAL(vars);
692 array_init(vars);
693 INIT_PZVAL(vars);
694 if (PG(http_globals)[TRACK_VARS_COOKIE]) {
695 zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_COOKIE]);
696 }
697 PG(http_globals)[TRACK_VARS_COOKIE] = vars;
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
698 }
699
f0c8366a »
2010-07-08 - use interned strings for auto globals
700 zend_hash_update(&EG(symbol_table), name, name_len + 1, &vars, sizeof(zval *), NULL);
701 Z_ADDREF_P(vars);
702
703 return 0; /* don't rearm */
704 }
705
e43ff135 »
2011-09-13 Fixed ZE specific compile warnings (Bug #55629)
706 static zend_bool php_auto_globals_create_files(const char *name, uint name_len TSRMLS_DC)
f0c8366a »
2010-07-08 - use interned strings for auto globals
707 {
708 zval *vars;
709
710 if (PG(http_globals)[TRACK_VARS_FILES]) {
711 vars = PG(http_globals)[TRACK_VARS_FILES];
712 } else {
713 ALLOC_ZVAL(vars);
714 array_init(vars);
715 INIT_PZVAL(vars);
716 PG(http_globals)[TRACK_VARS_FILES] = vars;
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
717 }
718
f0c8366a »
2010-07-08 - use interned strings for auto globals
719 zend_hash_update(&EG(symbol_table), name, name_len + 1, &vars, sizeof(zval *), NULL);
720 Z_ADDREF_P(vars);
721
722 return 0; /* don't rearm */
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
723 }
724
e43ff135 »
2011-09-13 Fixed ZE specific compile warnings (Bug #55629)
725 static zend_bool php_auto_globals_create_server(const char *name, uint name_len TSRMLS_DC)
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
726 {
5f880990 »
2005-09-01 MFH: Fixed bug #34331 (php crashes when variables_order is empty).
727 if (PG(variables_order) && (strchr(PG(variables_order),'S') || strchr(PG(variables_order),'s'))) {
1add2cc7 »
2005-05-25 Fixed bug #29971 (variables_order behaviour)
728 php_register_server_variables(TSRMLS_C);
d3557049 »
2006-03-20 Fixed register_argc_argv behavior. Now it behave in the same way as b…
729
730 if (PG(register_argc_argv)) {
731 if (SG(request_info).argc) {
732 zval **argc, **argv;
733
734 if (zend_hash_find(&EG(symbol_table), "argc", sizeof("argc"), (void**)&argc) == SUCCESS &&
04848558 »
2011-08-23 - ws
735 zend_hash_find(&EG(symbol_table), "argv", sizeof("argv"), (void**)&argv) == SUCCESS) {
4b4d634c »
2007-10-07 MFH: Added macros for managing zval refcounts and is_ref statuses
736 Z_ADDREF_PP(argc);
737 Z_ADDREF_PP(argv);
d3557049 »
2006-03-20 Fixed register_argc_argv behavior. Now it behave in the same way as b…
738 zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv"), argv, sizeof(zval *), NULL);
739 zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argc", sizeof("argc"), argc, sizeof(zval *), NULL);
740 }
741 } else {
742 php_build_argv(SG(request_info).query_string, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC);
743 }
744 }
745
1add2cc7 »
2005-05-25 Fixed bug #29971 (variables_order behaviour)
746 } else {
747 zval *server_vars=NULL;
748 ALLOC_ZVAL(server_vars);
749 array_init(server_vars);
750 INIT_PZVAL(server_vars);
28446a4e »
2005-06-01 Fixed "refcount" counting for autoglobals
751 if (PG(http_globals)[TRACK_VARS_SERVER]) {
752 zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_SERVER]);
753 }
1add2cc7 »
2005-05-25 Fixed bug #29971 (variables_order behaviour)
754 PG(http_globals)[TRACK_VARS_SERVER] = server_vars;
755 }
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
756
e642d180 »
2005-04-23 ws, pval -> zval
757 zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_SERVER], sizeof(zval *), NULL);
4b4d634c »
2007-10-07 MFH: Added macros for managing zval refcounts and is_ref statuses
758 Z_ADDREF_P(PG(http_globals)[TRACK_VARS_SERVER]);
d3557049 »
2006-03-20 Fixed register_argc_argv behavior. Now it behave in the same way as b…
759
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
760 return 0; /* don't rearm */
761 }
762
e43ff135 »
2011-09-13 Fixed ZE specific compile warnings (Bug #55629)
763 static zend_bool php_auto_globals_create_env(const char *name, uint name_len TSRMLS_DC)
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
764 {
e642d180 »
2005-04-23 ws, pval -> zval
765 zval *env_vars = NULL;
e5cfb1d0 »
2004-07-10 - Better stability during premature shutdown of request startup
766 ALLOC_ZVAL(env_vars);
767 array_init(env_vars);
768 INIT_PZVAL(env_vars);
28446a4e »
2005-06-01 Fixed "refcount" counting for autoglobals
769 if (PG(http_globals)[TRACK_VARS_ENV]) {
770 zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_ENV]);
771 }
e5cfb1d0 »
2004-07-10 - Better stability during premature shutdown of request startup
772 PG(http_globals)[TRACK_VARS_ENV] = env_vars;
773
5f880990 »
2005-09-01 MFH: Fixed bug #34331 (php crashes when variables_order is empty).
774 if (PG(variables_order) && (strchr(PG(variables_order),'E') || strchr(PG(variables_order),'e'))) {
1add2cc7 »
2005-05-25 Fixed bug #29971 (variables_order behaviour)
775 php_import_environment_variables(PG(http_globals)[TRACK_VARS_ENV] TSRMLS_CC);
776 }
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
777
e642d180 »
2005-04-23 ws, pval -> zval
778 zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_ENV], sizeof(zval *), NULL);
4b4d634c »
2007-10-07 MFH: Added macros for managing zval refcounts and is_ref statuses
779 Z_ADDREF_P(PG(http_globals)[TRACK_VARS_ENV]);
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
780
781 return 0; /* don't rearm */
782 }
783
e43ff135 »
2011-09-13 Fixed ZE specific compile warnings (Bug #55629)
784 static zend_bool php_auto_globals_create_request(const char *name, uint name_len TSRMLS_DC)
622da332 »
2003-03-02 - Optimize $_REQUEST
785 {
786 zval *form_variables;
0eb76eb2 »
2003-07-31 Fixed bug #24883 (variables created through register_globals, ignore
787 unsigned char _gpc_flags[3] = {0, 0, 0};
622da332 »
2003-03-02 - Optimize $_REQUEST
788 char *p;
789
790 ALLOC_ZVAL(form_variables);
791 array_init(form_variables);
792 INIT_PZVAL(form_variables);
793
2f27a0b1 »
2010-11-17 - Cleanup
794 if (PG(request_order) != NULL) {
a9fe1010 »
2008-03-12 [DOC] add request_order INI variable to control $_REQUEST content
795 p = PG(request_order);
796 } else {
797 p = PG(variables_order);
798 }
799
800 for (; p && *p; p++) {
622da332 »
2003-03-02 - Optimize $_REQUEST
801 switch (*p) {
802 case 'g':
803 case 'G':
0eb76eb2 »
2003-07-31 Fixed bug #24883 (variables created through register_globals, ignore
804 if (!_gpc_flags[0]) {
805 php_autoglobal_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_GET]) TSRMLS_CC);
806 _gpc_flags[0] = 1;
807 }
622da332 »
2003-03-02 - Optimize $_REQUEST
808 break;
809 case 'p':
810 case 'P':
0eb76eb2 »
2003-07-31 Fixed bug #24883 (variables created through register_globals, ignore
811 if (!_gpc_flags[1]) {
812 php_autoglobal_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_POST]) TSRMLS_CC);
813 _gpc_flags[1] = 1;
814 }
622da332 »
2003-03-02 - Optimize $_REQUEST
815 break;
816 case 'c':
817 case 'C':
0eb76eb2 »
2003-07-31 Fixed bug #24883 (variables created through register_globals, ignore
818 if (!_gpc_flags[2]) {
819 php_autoglobal_merge(Z_ARRVAL_P(form_variables), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_COOKIE]) TSRMLS_CC);
820 _gpc_flags[2] = 1;
821 }
622da332 »
2003-03-02 - Optimize $_REQUEST
822 break;
823 }
824 }
825
f0c8366a »
2010-07-08 - use interned strings for auto globals
826 zend_hash_update(&EG(symbol_table), name, name_len + 1, &form_variables, sizeof(zval *), NULL);
622da332 »
2003-03-02 - Optimize $_REQUEST
827 return 0;
828 }
829
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
830 void php_startup_auto_globals(TSRMLS_D)
831 {
2f27a0b1 »
2010-11-17 - Cleanup
832 zend_register_auto_global(ZEND_STRL("_GET"), 0, php_auto_globals_create_get TSRMLS_CC);
833 zend_register_auto_global(ZEND_STRL("_POST"), 0, php_auto_globals_create_post TSRMLS_CC);
834 zend_register_auto_global(ZEND_STRL("_COOKIE"), 0, php_auto_globals_create_cookie TSRMLS_CC);
835 zend_register_auto_global(ZEND_STRL("_SERVER"), PG(auto_globals_jit), php_auto_globals_create_server TSRMLS_CC);
836 zend_register_auto_global(ZEND_STRL("_ENV"), PG(auto_globals_jit), php_auto_globals_create_env TSRMLS_CC);
837 zend_register_auto_global(ZEND_STRL("_REQUEST"), PG(auto_globals_jit), php_auto_globals_create_request TSRMLS_CC);
838 zend_register_auto_global(ZEND_STRL("_FILES"), 0, php_auto_globals_create_files TSRMLS_CC);
4e55747a »
2003-03-02 Add JIT initialization for _SERVER and _ENV
839 }
840
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
841 /*
842 * Local variables:
843 * tab-width: 4
844 * c-basic-offset: 4
845 * End:
78747bd2 »
2001-09-09 - Don't wrap lines... this is annoying while coding.
846 * vim600: sw=4 ts=4 fdm=marker
847 * vim<600: sw=4 ts=4
2c0ad3ee »
1999-04-22 last bunch of extensions moving to ext/
848 */
Something went wrong with that request. Please try again.