version 1.1.1.1, 2012/02/21 23:48:05
|
version 1.1.1.2, 2012/05/29 12:34:35
|
Line 47 PHPAPI void php_register_variable_safe(char *var, char
|
Line 47 PHPAPI void php_register_variable_safe(char *var, char
|
|
|
/* Prepare value */ |
/* Prepare value */ |
Z_STRLEN(new_entry) = str_len; |
Z_STRLEN(new_entry) = str_len; |
if (PG(magic_quotes_gpc)) { | Z_STRVAL(new_entry) = estrndup(strval, Z_STRLEN(new_entry)); |
Z_STRVAL(new_entry) = php_addslashes(strval, Z_STRLEN(new_entry), &Z_STRLEN(new_entry), 0 TSRMLS_CC); | |
} else { | |
Z_STRVAL(new_entry) = estrndup(strval, Z_STRLEN(new_entry)); | |
} | |
Z_TYPE(new_entry) = IS_STRING; |
Z_TYPE(new_entry) = IS_STRING; |
|
|
php_register_variable_ex(var, &new_entry, track_vars_array TSRMLS_CC); |
php_register_variable_ex(var, &new_entry, track_vars_array TSRMLS_CC); |
Line 61 PHPAPI void php_register_variable_ex(char *var_name, z
|
Line 57 PHPAPI void php_register_variable_ex(char *var_name, z
|
{ |
{ |
char *p = NULL; |
char *p = NULL; |
char *ip; /* index pointer */ |
char *ip; /* index pointer */ |
char *index, *escaped_index = NULL; | char *index; |
char *var, *var_orig; |
char *var, *var_orig; |
int var_len, index_len; |
int var_len, index_len; |
zval *gpc_element, **gpc_element_p; |
zval *gpc_element, **gpc_element_p; |
zend_bool is_array = 0; |
zend_bool is_array = 0; |
HashTable *symtable1 = NULL; |
HashTable *symtable1 = NULL; |
|
ALLOCA_FLAG(use_heap) |
|
|
assert(var_name != NULL); |
assert(var_name != NULL); |
|
|
if (track_vars_array) { |
if (track_vars_array) { |
symtable1 = Z_ARRVAL_P(track_vars_array); |
symtable1 = Z_ARRVAL_P(track_vars_array); |
} else if (PG(register_globals)) { |
|
if (!EG(active_symbol_table)) { |
|
zend_rebuild_symbol_table(TSRMLS_C); |
|
} |
|
symtable1 = EG(active_symbol_table); |
|
} |
} |
|
|
if (!symtable1) { |
if (!symtable1) { |
/* Nothing to do */ |
/* Nothing to do */ |
zval_dtor(val); |
zval_dtor(val); |
return; |
return; |
} |
} |
|
|
|
|
|
/* ignore leading spaces in the variable name */ |
|
while (*var_name && *var_name==' ') { |
|
var_name++; |
|
} |
|
|
/* |
/* |
* Prepare variable name |
* Prepare variable name |
*/ |
*/ |
|
var_len = strlen(var_name); |
|
var = var_orig = do_alloca(var_len + 1, use_heap); |
|
memcpy(var_orig, var_name, var_len + 1); |
|
|
var_orig = estrdup(var_name); |
|
var = var_orig; |
|
/* ignore leading spaces in the variable name */ |
|
while (*var && *var==' ') { |
|
var++; |
|
} |
|
|
|
/* ensure that we don't have spaces or dots in the variable name (not binary safe) */ |
/* ensure that we don't have spaces or dots in the variable name (not binary safe) */ |
for (p = var; *p; p++) { |
for (p = var; *p; p++) { |
if (*p == ' ' || *p == '.') { |
if (*p == ' ' || *p == '.') { |
Line 110 PHPAPI void php_register_variable_ex(char *var_name, z
|
Line 105 PHPAPI void php_register_variable_ex(char *var_name, z
|
|
|
if (var_len==0) { /* empty variable name, or variable name with a space in it */ |
if (var_len==0) { /* empty variable name, or variable name with a space in it */ |
zval_dtor(val); |
zval_dtor(val); |
efree(var_orig); | free_alloca(var_orig, use_heap); |
return; |
return; |
} |
} |
|
|
Line 119 PHPAPI void php_register_variable_ex(char *var_name, z
|
Line 114 PHPAPI void php_register_variable_ex(char *var_name, z
|
var_len == sizeof("GLOBALS")-1 && |
var_len == sizeof("GLOBALS")-1 && |
!memcmp(var, "GLOBALS", sizeof("GLOBALS")-1)) { |
!memcmp(var, "GLOBALS", sizeof("GLOBALS")-1)) { |
zval_dtor(val); |
zval_dtor(val); |
efree(var_orig); | free_alloca(var_orig, use_heap); |
return; |
return; |
} |
} |
|
|
Line 138 PHPAPI void php_register_variable_ex(char *var_name, z
|
Line 133 PHPAPI void php_register_variable_ex(char *var_name, z
|
|
|
if (track_vars_array) { |
if (track_vars_array) { |
ht = Z_ARRVAL_P(track_vars_array); |
ht = Z_ARRVAL_P(track_vars_array); |
zend_hash_del(ht, var, var_len + 1); | zend_symtable_del(ht, var, var_len + 1); |
} else if (PG(register_globals)) { | |
ht = EG(active_symbol_table); | |
zend_hash_del(ht, var, var_len + 1); | |
} |
} |
|
|
zval_dtor(val); |
zval_dtor(val); |
Line 151 PHPAPI void php_register_variable_ex(char *var_name, z
|
Line 143 PHPAPI void php_register_variable_ex(char *var_name, z
|
if (!PG(display_errors)) { |
if (!PG(display_errors)) { |
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)); |
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)); |
} |
} |
efree(var_orig); | free_alloca(var_orig, use_heap); |
return; |
return; |
} |
} |
|
|
Line 185 PHPAPI void php_register_variable_ex(char *var_name, z
|
Line 177 PHPAPI void php_register_variable_ex(char *var_name, z
|
if (zend_hash_next_index_insert(symtable1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p) == FAILURE) { |
if (zend_hash_next_index_insert(symtable1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p) == FAILURE) { |
zval_ptr_dtor(&gpc_element); |
zval_ptr_dtor(&gpc_element); |
zval_dtor(val); |
zval_dtor(val); |
efree(var_orig); | free_alloca(var_orig, use_heap); |
return; |
return; |
} |
} |
} else { |
} else { |
if (PG(magic_quotes_gpc)) { | if (zend_symtable_find(symtable1, index, index_len + 1, (void **) &gpc_element_p) == FAILURE |
escaped_index = php_addslashes(index, index_len, &index_len, 0 TSRMLS_CC); | |
} else { | |
escaped_index = index; | |
} | |
if (zend_symtable_find(symtable1, escaped_index, index_len + 1, (void **) &gpc_element_p) == FAILURE | |
|| Z_TYPE_PP(gpc_element_p) != IS_ARRAY) { |
|| Z_TYPE_PP(gpc_element_p) != IS_ARRAY) { |
if (zend_hash_num_elements(symtable1) <= PG(max_input_vars)) { | MAKE_STD_ZVAL(gpc_element); |
if (zend_hash_num_elements(symtable1) == PG(max_input_vars)) { | array_init(gpc_element); |
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)); | zend_symtable_update(symtable1, index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p); |
} | |
MAKE_STD_ZVAL(gpc_element); | |
array_init(gpc_element); | |
zend_symtable_update(symtable1, escaped_index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p); | |
} else { | |
if (index != escaped_index) { | |
efree(escaped_index); | |
} | |
zval_dtor(val); | |
efree(var_orig); | |
return; | |
} | |
} |
} |
if (index != escaped_index) { |
|
efree(escaped_index); |
|
} |
|
} |
} |
symtable1 = Z_ARRVAL_PP(gpc_element_p); |
symtable1 = Z_ARRVAL_PP(gpc_element_p); |
/* ip pointed to the '[' character, now obtain the key */ |
/* ip pointed to the '[' character, now obtain the key */ |
Line 239 plain_var:
|
Line 211 plain_var:
|
zval_ptr_dtor(&gpc_element); |
zval_ptr_dtor(&gpc_element); |
} |
} |
} else { |
} else { |
if (PG(magic_quotes_gpc)) { |
|
escaped_index = php_addslashes(index, index_len, &index_len, 0 TSRMLS_CC); |
|
} else { |
|
escaped_index = index; |
|
} |
|
/* |
/* |
* According to rfc2965, more specific paths are listed above the less specific ones. |
* According to rfc2965, more specific paths are listed above the less specific ones. |
* If we encounter a duplicate cookie name, we should skip it, since it is not possible |
* If we encounter a duplicate cookie name, we should skip it, since it is not possible |
Line 252 plain_var:
|
Line 219 plain_var:
|
*/ |
*/ |
if (PG(http_globals)[TRACK_VARS_COOKIE] && |
if (PG(http_globals)[TRACK_VARS_COOKIE] && |
symtable1 == Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_COOKIE]) && |
symtable1 == Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_COOKIE]) && |
zend_symtable_exists(symtable1, escaped_index, index_len + 1)) { | zend_symtable_exists(symtable1, index, index_len + 1)) { |
zval_ptr_dtor(&gpc_element); |
zval_ptr_dtor(&gpc_element); |
} else { |
} else { |
if (zend_hash_num_elements(symtable1) <= PG(max_input_vars)) { | zend_symtable_update(symtable1, index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p); |
if (zend_hash_num_elements(symtable1) == PG(max_input_vars)) { | |
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)); | |
} | |
zend_symtable_update(symtable1, escaped_index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p); | |
} else { | |
zval_ptr_dtor(&gpc_element); | |
} | |
} |
} |
if (escaped_index != index) { |
|
efree(escaped_index); |
|
} |
|
} |
} |
} |
} |
efree(var_orig); | free_alloca(var_orig, use_heap); |
} |
} |
|
|
SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler) |
SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler) |
{ |
{ |
char *var, *val, *e, *s, *p; |
char *var, *val, *e, *s, *p; |
zval *array_ptr = (zval *) arg; |
zval *array_ptr = (zval *) arg; |
|
long count = 0; |
|
|
if (SG(request_info).post_data == NULL) { |
if (SG(request_info).post_data == NULL) { |
return; |
return; |
Line 289 last_value:
|
Line 247 last_value:
|
if ((val = memchr(s, '=', (p - s)))) { /* have a value */ |
if ((val = memchr(s, '=', (p - s)))) { /* have a value */ |
unsigned int val_len, new_val_len; |
unsigned int val_len, new_val_len; |
|
|
|
if (++count > PG(max_input_vars)) { |
|
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)); |
|
return; |
|
} |
var = s; |
var = s; |
|
|
php_url_decode(var, (val - s)); |
php_url_decode(var, (val - s)); |
Line 322 SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
|
Line 284 SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
|
zval *array_ptr; |
zval *array_ptr; |
int free_buffer = 0; |
int free_buffer = 0; |
char *strtok_buf = NULL; |
char *strtok_buf = NULL; |
|
long count = 0; |
|
|
switch (arg) { |
switch (arg) { |
case PARSE_POST: |
case PARSE_POST: |
Line 411 SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
|
Line 374 SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
|
} |
} |
} |
} |
|
|
|
if (++count > PG(max_input_vars)) { |
|
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)); |
|
break; |
|
} |
|
|
if (val) { /* have a value */ |
if (val) { /* have a value */ |
int val_len; |
int val_len; |
unsigned int new_val_len; |
unsigned int new_val_len; |
Line 455 void _php_import_environment_variables(zval *array_ptr
|
Line 423 void _php_import_environment_variables(zval *array_ptr
|
size_t alloc_size = sizeof(buf); |
size_t alloc_size = sizeof(buf); |
unsigned long nlen; /* ptrdiff_t is not portable */ |
unsigned long nlen; /* ptrdiff_t is not portable */ |
|
|
/* turn off magic_quotes while importing environment variables */ |
|
int magic_quotes_gpc = PG(magic_quotes_gpc); |
|
PG(magic_quotes_gpc) = 0; |
|
|
|
for (env = environ; env != NULL && *env != NULL; env++) { |
for (env = environ; env != NULL && *env != NULL; env++) { |
p = strchr(*env, '='); |
p = strchr(*env, '='); |
if (!p) { /* malformed entry? */ |
if (!p) { /* malformed entry? */ |
Line 476 void _php_import_environment_variables(zval *array_ptr
|
Line 440 void _php_import_environment_variables(zval *array_ptr
|
if (t != buf && t != NULL) { |
if (t != buf && t != NULL) { |
efree(t); |
efree(t); |
} |
} |
PG(magic_quotes_gpc) = magic_quotes_gpc; |
|
} |
} |
|
|
zend_bool php_std_auto_global_callback(char *name, uint name_len TSRMLS_DC) |
zend_bool php_std_auto_global_callback(char *name, uint name_len TSRMLS_DC) |
Line 493 static void php_build_argv(char *s, zval *track_vars_a
|
Line 456 static void php_build_argv(char *s, zval *track_vars_a
|
int count = 0; |
int count = 0; |
char *ss, *space; |
char *ss, *space; |
|
|
if (!(PG(register_globals) || SG(request_info).argc || track_vars_array)) { | if (!(SG(request_info).argc || track_vars_array)) { |
return; |
return; |
} |
} |
|
|
Line 552 static void php_build_argv(char *s, zval *track_vars_a
|
Line 515 static void php_build_argv(char *s, zval *track_vars_a
|
} |
} |
Z_TYPE_P(argc) = IS_LONG; |
Z_TYPE_P(argc) = IS_LONG; |
|
|
if (PG(register_globals) || SG(request_info).argc) { | if (SG(request_info).argc) { |
Z_ADDREF_P(arr); |
Z_ADDREF_P(arr); |
Z_ADDREF_P(argc); |
Z_ADDREF_P(argc); |
zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL); |
zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL); |
Line 590 PHPAPI int php_handle_special_queries(TSRMLS_D)
|
Line 553 PHPAPI int php_handle_special_queries(TSRMLS_D)
|
static inline void php_register_server_variables(TSRMLS_D) |
static inline void php_register_server_variables(TSRMLS_D) |
{ |
{ |
zval *array_ptr = NULL; |
zval *array_ptr = NULL; |
/* turn off magic_quotes while importing server variables */ |
|
int magic_quotes_gpc = PG(magic_quotes_gpc); |
|
|
|
ALLOC_ZVAL(array_ptr); |
ALLOC_ZVAL(array_ptr); |
array_init(array_ptr); |
array_init(array_ptr); |
Line 600 static inline void php_register_server_variables(TSRML
|
Line 561 static inline void php_register_server_variables(TSRML
|
zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_SERVER]); |
zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_SERVER]); |
} |
} |
PG(http_globals)[TRACK_VARS_SERVER] = array_ptr; |
PG(http_globals)[TRACK_VARS_SERVER] = array_ptr; |
PG(magic_quotes_gpc) = 0; |
|
|
|
/* Server variables */ |
/* Server variables */ |
if (sapi_module.register_server_variables) { |
if (sapi_module.register_server_variables) { |
Line 619 static inline void php_register_server_variables(TSRML
|
Line 579 static inline void php_register_server_variables(TSRML
|
} |
} |
/* store request init time */ |
/* store request init time */ |
{ |
{ |
zval new_entry; | zval request_time_float, request_time_long; |
Z_TYPE(new_entry) = IS_LONG; | Z_TYPE(request_time_float) = IS_DOUBLE; |
Z_LVAL(new_entry) = sapi_get_request_time(TSRMLS_C); | Z_DVAL(request_time_float) = sapi_get_request_time(TSRMLS_C); |
php_register_variable_ex("REQUEST_TIME", &new_entry, array_ptr TSRMLS_CC); | php_register_variable_ex("REQUEST_TIME_FLOAT", &request_time_float, array_ptr TSRMLS_CC); |
| Z_TYPE(request_time_long) = IS_LONG; |
| Z_LVAL(request_time_long) = zend_dval_to_lval(Z_DVAL(request_time_float)); |
| php_register_variable_ex("REQUEST_TIME", &request_time_long, array_ptr TSRMLS_CC); |
} |
} |
|
|
PG(magic_quotes_gpc) = magic_quotes_gpc; |
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
Line 639 static void php_autoglobal_merge(HashTable *dest, Hash
|
Line 601 static void php_autoglobal_merge(HashTable *dest, Hash
|
ulong num_key; |
ulong num_key; |
HashPosition pos; |
HashPosition pos; |
int key_type; |
int key_type; |
int globals_check = (PG(register_globals) && (dest == (&EG(symbol_table)))); | int globals_check = (dest == (&EG(symbol_table))); |
|
|
zend_hash_internal_pointer_reset_ex(src, &pos); |
zend_hash_internal_pointer_reset_ex(src, &pos); |
while (zend_hash_get_current_data_ex(src, (void **)&src_entry, &pos) == SUCCESS) { |
while (zend_hash_get_current_data_ex(src, (void **)&src_entry, &pos) == SUCCESS) { |
Line 648 static void php_autoglobal_merge(HashTable *dest, Hash
|
Line 610 static void php_autoglobal_merge(HashTable *dest, Hash
|
|| (key_type == HASH_KEY_IS_STRING && zend_hash_find(dest, string_key, string_key_len, (void **) &dest_entry) != SUCCESS) |
|| (key_type == HASH_KEY_IS_STRING && zend_hash_find(dest, string_key, string_key_len, (void **) &dest_entry) != SUCCESS) |
|| (key_type == HASH_KEY_IS_LONG && zend_hash_index_find(dest, num_key, (void **)&dest_entry) != SUCCESS) |
|| (key_type == HASH_KEY_IS_LONG && zend_hash_index_find(dest, num_key, (void **)&dest_entry) != SUCCESS) |
|| Z_TYPE_PP(dest_entry) != IS_ARRAY |
|| Z_TYPE_PP(dest_entry) != IS_ARRAY |
) { | ) { |
Z_ADDREF_PP(src_entry); |
Z_ADDREF_PP(src_entry); |
if (key_type == HASH_KEY_IS_STRING) { |
if (key_type == HASH_KEY_IS_STRING) { |
/* if register_globals is on and working with main symbol table, prevent overwriting of GLOBALS */ |
|
if (!globals_check || string_key_len != sizeof("GLOBALS") || memcmp(string_key, "GLOBALS", sizeof("GLOBALS") - 1)) { |
if (!globals_check || string_key_len != sizeof("GLOBALS") || memcmp(string_key, "GLOBALS", sizeof("GLOBALS") - 1)) { |
zend_hash_update(dest, string_key, string_key_len, src_entry, sizeof(zval *), NULL); |
zend_hash_update(dest, string_key, string_key_len, src_entry, sizeof(zval *), NULL); |
} else { |
} else { |
Line 669 static void php_autoglobal_merge(HashTable *dest, Hash
|
Line 630 static void php_autoglobal_merge(HashTable *dest, Hash
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS_DC); | static zend_bool php_auto_globals_create_server(const char *name, uint name_len TSRMLS_DC); |
static zend_bool php_auto_globals_create_env(char *name, uint name_len TSRMLS_DC); | static zend_bool php_auto_globals_create_env(const char *name, uint name_len TSRMLS_DC); |
static zend_bool php_auto_globals_create_request(char *name, uint name_len TSRMLS_DC); | static zend_bool php_auto_globals_create_request(const char *name, uint name_len TSRMLS_DC); |
|
|
/* {{{ php_hash_environment |
/* {{{ php_hash_environment |
*/ |
*/ |
int php_hash_environment(TSRMLS_D) |
int php_hash_environment(TSRMLS_D) |
{ |
{ |
char *p; | memset(PG(http_globals), 0, sizeof(PG(http_globals))); |
unsigned char _gpc_flags[5] = {0, 0, 0, 0, 0}; | zend_activate_auto_globals(TSRMLS_C); |
zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays)); | if (PG(register_argc_argv)) { |
struct auto_global_record { | php_build_argv(SG(request_info).query_string, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC); |
char *name; | |
uint name_len; | |
char *long_name; | |
uint long_name_len; | |
zend_bool jit_initialization; | |
} auto_global_records[] = { | |
{ "_POST", sizeof("_POST"), "HTTP_POST_VARS", sizeof("HTTP_POST_VARS"), 0 }, | |
{ "_GET", sizeof("_GET"), "HTTP_GET_VARS", sizeof("HTTP_GET_VARS"), 0 }, | |
{ "_COOKIE", sizeof("_COOKIE"), "HTTP_COOKIE_VARS", sizeof("HTTP_COOKIE_VARS"), 0 }, | |
{ "_SERVER", sizeof("_SERVER"), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), 1 }, | |
{ "_ENV", sizeof("_ENV"), "HTTP_ENV_VARS", sizeof("HTTP_ENV_VARS"), 1 }, | |
{ "_FILES", sizeof("_FILES"), "HTTP_POST_FILES", sizeof("HTTP_POST_FILES"), 0 }, | |
}; | |
size_t num_track_vars = sizeof(auto_global_records)/sizeof(struct auto_global_record); | |
size_t i; | |
| |
/* jit_initialization = 0; */ | |
for (i=0; i<num_track_vars; i++) { | |
PG(http_globals)[i] = NULL; | |
} |
} |
|
return SUCCESS; |
|
} |
|
/* }}} */ |
|
|
for (p=PG(variables_order); p && *p; p++) { | static zend_bool php_auto_globals_create_get(const char *name, uint name_len TSRMLS_DC) |
switch(*p) { | { |
case 'p': | zval *vars; |
case 'P': | |
if (!_gpc_flags[0] && !SG(headers_sent) && SG(request_info).request_method && !strcasecmp(SG(request_info).request_method, "POST")) { | if (PG(variables_order) && (strchr(PG(variables_order),'G') || strchr(PG(variables_order),'g'))) { |
sapi_module.treat_data(PARSE_POST, NULL, NULL TSRMLS_CC); /* POST Data */ | sapi_module.treat_data(PARSE_GET, NULL, NULL TSRMLS_CC); |
_gpc_flags[0] = 1; | vars = PG(http_globals)[TRACK_VARS_GET]; |
if (PG(register_globals)) { | } else { |
php_autoglobal_merge(&EG(symbol_table), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_POST]) TSRMLS_CC); | ALLOC_ZVAL(vars); |
} | array_init(vars); |
} | INIT_PZVAL(vars); |
break; | if (PG(http_globals)[TRACK_VARS_GET]) { |
case 'c': | zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_GET]); |
case 'C': | |
if (!_gpc_flags[1]) { | |
sapi_module.treat_data(PARSE_COOKIE, NULL, NULL TSRMLS_CC); /* Cookie Data */ | |
_gpc_flags[1] = 1; | |
if (PG(register_globals)) { | |
php_autoglobal_merge(&EG(symbol_table), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_COOKIE]) TSRMLS_CC); | |
} | |
} | |
break; | |
case 'g': | |
case 'G': | |
if (!_gpc_flags[2]) { | |
sapi_module.treat_data(PARSE_GET, NULL, NULL TSRMLS_CC); /* GET Data */ | |
_gpc_flags[2] = 1; | |
if (PG(register_globals)) { | |
php_autoglobal_merge(&EG(symbol_table), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_GET]) TSRMLS_CC); | |
} | |
} | |
break; | |
case 'e': | |
case 'E': | |
if (!jit_initialization && !_gpc_flags[3]) { | |
zend_auto_global_disable_jit("_ENV", sizeof("_ENV")-1 TSRMLS_CC); | |
php_auto_globals_create_env("_ENV", sizeof("_ENV")-1 TSRMLS_CC); | |
_gpc_flags[3] = 1; | |
if (PG(register_globals)) { | |
php_autoglobal_merge(&EG(symbol_table), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV]) TSRMLS_CC); | |
} | |
} | |
break; | |
case 's': | |
case 'S': | |
if (!jit_initialization && !_gpc_flags[4]) { | |
zend_auto_global_disable_jit("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC); | |
php_register_server_variables(TSRMLS_C); | |
_gpc_flags[4] = 1; | |
if (PG(register_globals)) { | |
php_autoglobal_merge(&EG(symbol_table), Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]) TSRMLS_CC); | |
} | |
} | |
break; | |
} |
} |
|
PG(http_globals)[TRACK_VARS_GET] = vars; |
} |
} |
|
|
/* argv/argc support */ | zend_hash_update(&EG(symbol_table), name, name_len + 1, &vars, sizeof(zval *), NULL); |
if (PG(register_argc_argv)) { | Z_ADDREF_P(vars); |
php_build_argv(SG(request_info).query_string, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC); | |
} | return 0; /* don't rearm */ |
| } |
|
|
for (i=0; i<num_track_vars; i++) { | static zend_bool php_auto_globals_create_post(const char *name, uint name_len TSRMLS_DC) |
if (jit_initialization && auto_global_records[i].jit_initialization) { | { |
continue; | zval *vars; |
| |
| if (PG(variables_order) && |
| (strchr(PG(variables_order),'P') || strchr(PG(variables_order),'p')) && |
| !SG(headers_sent) && |
| SG(request_info).request_method && |
| !strcasecmp(SG(request_info).request_method, "POST")) { |
| sapi_module.treat_data(PARSE_POST, NULL, NULL TSRMLS_CC); |
| vars = PG(http_globals)[TRACK_VARS_POST]; |
| } else { |
| ALLOC_ZVAL(vars); |
| array_init(vars); |
| INIT_PZVAL(vars); |
| if (PG(http_globals)[TRACK_VARS_POST]) { |
| zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_POST]); |
} |
} |
if (!PG(http_globals)[i]) { | PG(http_globals)[TRACK_VARS_POST] = vars; |
ALLOC_ZVAL(PG(http_globals)[i]); | } |
array_init(PG(http_globals)[i]); | |
INIT_PZVAL(PG(http_globals)[i]); | |
} | |
|
|
Z_ADDREF_P(PG(http_globals)[i]); | zend_hash_update(&EG(symbol_table), name, name_len + 1, &vars, sizeof(zval *), NULL); |
zend_hash_update(&EG(symbol_table), auto_global_records[i].name, auto_global_records[i].name_len, &PG(http_globals)[i], sizeof(zval *), NULL); | Z_ADDREF_P(vars); |
if (PG(register_long_arrays)) { | |
zend_hash_update(&EG(symbol_table), auto_global_records[i].long_name, auto_global_records[i].long_name_len, &PG(http_globals)[i], sizeof(zval *), NULL); | return 0; /* don't rearm */ |
Z_ADDREF_P(PG(http_globals)[i]); | } |
| |
| static zend_bool php_auto_globals_create_cookie(const char *name, uint name_len TSRMLS_DC) |
| { |
| zval *vars; |
| |
| if (PG(variables_order) && (strchr(PG(variables_order),'C') || strchr(PG(variables_order),'c'))) { |
| sapi_module.treat_data(PARSE_COOKIE, NULL, NULL TSRMLS_CC); |
| vars = PG(http_globals)[TRACK_VARS_COOKIE]; |
| } else { |
| ALLOC_ZVAL(vars); |
| array_init(vars); |
| INIT_PZVAL(vars); |
| if (PG(http_globals)[TRACK_VARS_COOKIE]) { |
| zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_COOKIE]); |
} |
} |
|
PG(http_globals)[TRACK_VARS_COOKIE] = vars; |
} |
} |
|
|
/* Create _REQUEST */ | zend_hash_update(&EG(symbol_table), name, name_len + 1, &vars, sizeof(zval *), NULL); |
if (!jit_initialization) { | Z_ADDREF_P(vars); |
zend_auto_global_disable_jit("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC); | |
php_auto_globals_create_request("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC); | return 0; /* don't rearm */ |
| } |
| |
| static zend_bool php_auto_globals_create_files(const char *name, uint name_len TSRMLS_DC) |
| { |
| zval *vars; |
| |
| if (PG(http_globals)[TRACK_VARS_FILES]) { |
| vars = PG(http_globals)[TRACK_VARS_FILES]; |
| } else { |
| ALLOC_ZVAL(vars); |
| array_init(vars); |
| INIT_PZVAL(vars); |
| PG(http_globals)[TRACK_VARS_FILES] = vars; |
} |
} |
|
|
return SUCCESS; | zend_hash_update(&EG(symbol_table), name, name_len + 1, &vars, sizeof(zval *), NULL); |
| Z_ADDREF_P(vars); |
| |
| return 0; /* don't rearm */ |
} |
} |
/* }}} */ |
|
|
|
static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS_DC) | static zend_bool php_auto_globals_create_server(const char *name, uint name_len TSRMLS_DC) |
{ |
{ |
if (PG(variables_order) && (strchr(PG(variables_order),'S') || strchr(PG(variables_order),'s'))) { |
if (PG(variables_order) && (strchr(PG(variables_order),'S') || strchr(PG(variables_order),'s'))) { |
php_register_server_variables(TSRMLS_C); |
php_register_server_variables(TSRMLS_C); |
Line 802 static zend_bool php_auto_globals_create_server(char *
|
Line 749 static zend_bool php_auto_globals_create_server(char *
|
zval **argc, **argv; |
zval **argc, **argv; |
|
|
if (zend_hash_find(&EG(symbol_table), "argc", sizeof("argc"), (void**)&argc) == SUCCESS && |
if (zend_hash_find(&EG(symbol_table), "argc", sizeof("argc"), (void**)&argc) == SUCCESS && |
zend_hash_find(&EG(symbol_table), "argv", sizeof("argv"), (void**)&argv) == SUCCESS) { | zend_hash_find(&EG(symbol_table), "argv", sizeof("argv"), (void**)&argv) == SUCCESS) { |
Z_ADDREF_PP(argc); |
Z_ADDREF_PP(argc); |
Z_ADDREF_PP(argv); |
Z_ADDREF_PP(argv); |
zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv"), argv, sizeof(zval *), NULL); |
zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv"), argv, sizeof(zval *), NULL); |
Line 826 static zend_bool php_auto_globals_create_server(char *
|
Line 773 static zend_bool php_auto_globals_create_server(char *
|
|
|
zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_SERVER], sizeof(zval *), NULL); |
zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_SERVER], sizeof(zval *), NULL); |
Z_ADDREF_P(PG(http_globals)[TRACK_VARS_SERVER]); |
Z_ADDREF_P(PG(http_globals)[TRACK_VARS_SERVER]); |
|
|
if (PG(register_long_arrays)) { |
|
zend_hash_update(&EG(symbol_table), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), &PG(http_globals)[TRACK_VARS_SERVER], sizeof(zval *), NULL); |
|
Z_ADDREF_P(PG(http_globals)[TRACK_VARS_SERVER]); |
|
} |
|
|
|
return 0; /* don't rearm */ |
return 0; /* don't rearm */ |
} |
} |
|
|
static zend_bool php_auto_globals_create_env(char *name, uint name_len TSRMLS_DC) | static zend_bool php_auto_globals_create_env(const char *name, uint name_len TSRMLS_DC) |
{ |
{ |
zval *env_vars = NULL; |
zval *env_vars = NULL; |
ALLOC_ZVAL(env_vars); |
ALLOC_ZVAL(env_vars); |
Line 853 static zend_bool php_auto_globals_create_env(char *nam
|
Line 795 static zend_bool php_auto_globals_create_env(char *nam
|
zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_ENV], sizeof(zval *), NULL); |
zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_ENV], sizeof(zval *), NULL); |
Z_ADDREF_P(PG(http_globals)[TRACK_VARS_ENV]); |
Z_ADDREF_P(PG(http_globals)[TRACK_VARS_ENV]); |
|
|
if (PG(register_long_arrays)) { |
|
zend_hash_update(&EG(symbol_table), "HTTP_ENV_VARS", sizeof("HTTP_ENV_VARS"), &PG(http_globals)[TRACK_VARS_ENV], sizeof(zval *), NULL); |
|
Z_ADDREF_P(PG(http_globals)[TRACK_VARS_ENV]); |
|
} |
|
|
|
return 0; /* don't rearm */ |
return 0; /* don't rearm */ |
} |
} |
|
|
static zend_bool php_auto_globals_create_request(char *name, uint name_len TSRMLS_DC) | static zend_bool php_auto_globals_create_request(const char *name, uint name_len TSRMLS_DC) |
{ |
{ |
zval *form_variables; |
zval *form_variables; |
unsigned char _gpc_flags[3] = {0, 0, 0}; |
unsigned char _gpc_flags[3] = {0, 0, 0}; |
Line 871 static zend_bool php_auto_globals_create_request(char
|
Line 808 static zend_bool php_auto_globals_create_request(char
|
array_init(form_variables); |
array_init(form_variables); |
INIT_PZVAL(form_variables); |
INIT_PZVAL(form_variables); |
|
|
if(PG(request_order) != NULL) { | if (PG(request_order) != NULL) { |
p = PG(request_order); |
p = PG(request_order); |
} else { |
} else { |
p = PG(variables_order); |
p = PG(variables_order); |
Line 903 static zend_bool php_auto_globals_create_request(char
|
Line 840 static zend_bool php_auto_globals_create_request(char
|
} |
} |
} |
} |
|
|
zend_hash_update(&EG(symbol_table), "_REQUEST", sizeof("_REQUEST"), &form_variables, sizeof(zval *), NULL); | zend_hash_update(&EG(symbol_table), name, name_len + 1, &form_variables, sizeof(zval *), NULL); |
return 0; |
return 0; |
} |
} |
|
|
void php_startup_auto_globals(TSRMLS_D) |
void php_startup_auto_globals(TSRMLS_D) |
{ |
{ |
zend_register_auto_global("_GET", sizeof("_GET")-1, NULL TSRMLS_CC); | zend_register_auto_global(ZEND_STRL("_GET"), 0, php_auto_globals_create_get TSRMLS_CC); |
zend_register_auto_global("_POST", sizeof("_POST")-1, NULL TSRMLS_CC); | zend_register_auto_global(ZEND_STRL("_POST"), 0, php_auto_globals_create_post TSRMLS_CC); |
zend_register_auto_global("_COOKIE", sizeof("_COOKIE")-1, NULL TSRMLS_CC); | zend_register_auto_global(ZEND_STRL("_COOKIE"), 0, php_auto_globals_create_cookie TSRMLS_CC); |
zend_register_auto_global("_SERVER", sizeof("_SERVER")-1, php_auto_globals_create_server TSRMLS_CC); | zend_register_auto_global(ZEND_STRL("_SERVER"), PG(auto_globals_jit), php_auto_globals_create_server TSRMLS_CC); |
zend_register_auto_global("_ENV", sizeof("_ENV")-1, php_auto_globals_create_env TSRMLS_CC); | zend_register_auto_global(ZEND_STRL("_ENV"), PG(auto_globals_jit), php_auto_globals_create_env TSRMLS_CC); |
zend_register_auto_global("_REQUEST", sizeof("_REQUEST")-1, php_auto_globals_create_request TSRMLS_CC); | zend_register_auto_global(ZEND_STRL("_REQUEST"), PG(auto_globals_jit), php_auto_globals_create_request TSRMLS_CC); |
zend_register_auto_global("_FILES", sizeof("_FILES")-1, NULL TSRMLS_CC); | zend_register_auto_global(ZEND_STRL("_FILES"), 0, php_auto_globals_create_files TSRMLS_CC); |
} |
} |
|
|
/* |
/* |