1999-04-22 10:48:28 +08:00
/*
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2004-01-08 16:18:22 +08:00
| PHP Version 5 |
1999-04-22 10:48:28 +08:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2011-01-01 10:17:06 +08:00
| Copyright ( c ) 1997 - 2011 The PHP Group |
1999-04-22 10:48:28 +08:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
2006-01-01 20:51:34 +08:00
| This source file is subject to version 3.01 of the PHP license , |
1999-07-16 21:13:16 +08:00
| that is bundled with this package in the file LICENSE , and is |
2003-06-11 04:04:29 +08:00
| available through the world - wide - web at the following url : |
2006-01-01 20:51:34 +08:00
| http : //www.php.net/license/3_01.txt |
1999-07-16 21:13:16 +08:00
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world - wide - web , please send a note to |
| license @ php . net so we can mail you a copy immediately . |
1999-04-22 10:48:28 +08:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| Authors : Rasmus Lerdorf < rasmus @ lerdorf . on . ca > |
1999-09-11 23:04:45 +08:00
| Zeev Suraski < zeev @ zend . com > |
1999-04-22 10:48:28 +08:00
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
*/
2003-02-19 16:40:19 +08:00
2001-04-06 09:50:40 +08:00
/* $Id$ */
1999-04-24 04:06:01 +08:00
1999-04-22 10:48:28 +08:00
# include <stdio.h>
# include "php.h"
2000-01-28 21:31:12 +08:00
# include "ext/standard/php_standard.h"
2003-03-04 03:37:09 +08:00
# include "ext/standard/credits.h"
2000-01-29 01:24:53 +08:00
# include "php_variables.h"
1999-04-22 10:48:28 +08:00
# include "php_globals.h"
2000-08-21 17:50:53 +08:00
# include "php_content_types.h"
1999-04-27 01:26:37 +08:00
# include "SAPI.h"
2003-03-04 03:37:09 +08:00
# include "php_logos.h"
1999-04-22 10:48:28 +08:00
# include "zend_globals.h"
2002-10-13 16:38:09 +08:00
/* for systems that need to override reading of environment variables */
void _php_import_environment_variables ( zval * array_ptr TSRMLS_DC ) ;
PHPAPI void ( * php_import_environment_variables ) ( zval * array_ptr TSRMLS_DC ) = _php_import_environment_variables ;
1999-04-22 10:48:28 +08:00
2001-07-28 19:36:37 +08:00
PHPAPI void php_register_variable ( char * var , char * strval , zval * track_vars_array TSRMLS_DC )
2001-07-27 18:16:41 +08:00
{
2001-07-28 19:36:37 +08:00
php_register_variable_safe ( var , strval , strlen ( strval ) , track_vars_array TSRMLS_CC ) ;
2000-12-12 18:47:47 +08:00
}
/* binary-safe version */
2001-07-28 19:36:37 +08:00
PHPAPI void php_register_variable_safe ( char * var , char * strval , int str_len , zval * track_vars_array TSRMLS_DC )
2000-02-20 04:12:26 +08:00
{
zval new_entry ;
2002-08-08 11:08:54 +08:00
assert ( strval ! = NULL ) ;
2000-02-20 04:12:26 +08:00
/* Prepare value */
2001-09-26 05:58:48 +08:00
Z_STRLEN ( new_entry ) = str_len ;
2000-02-20 04:12:26 +08:00
if ( PG ( magic_quotes_gpc ) ) {
2001-09-26 05:58:48 +08:00
Z_STRVAL ( new_entry ) = php_addslashes ( strval , Z_STRLEN ( new_entry ) , & Z_STRLEN ( new_entry ) , 0 TSRMLS_CC ) ;
2000-02-20 04:12:26 +08:00
} else {
2001-09-26 05:58:48 +08:00
Z_STRVAL ( new_entry ) = estrndup ( strval , Z_STRLEN ( new_entry ) ) ;
2000-02-20 04:12:26 +08:00
}
2001-09-26 05:58:48 +08:00
Z_TYPE ( new_entry ) = IS_STRING ;
2000-02-20 04:12:26 +08:00
2001-07-28 19:36:37 +08:00
php_register_variable_ex ( var , & new_entry , track_vars_array TSRMLS_CC ) ;
2000-02-20 04:12:26 +08:00
}
2008-08-31 00:47:46 +08:00
PHPAPI void php_register_variable_ex ( char * var_name , zval * val , zval * track_vars_array TSRMLS_DC )
1999-09-13 07:51:12 +08:00
{
char * p = NULL ;
char * ip ; /* index pointer */
2005-08-11 07:33:10 +08:00
char * index , * escaped_index = NULL ;
2008-08-31 00:47:46 +08:00
char * var , * var_orig ;
2000-02-20 04:12:26 +08:00
int var_len , index_len ;
2003-06-14 23:08:27 +08:00
zval * gpc_element , * * gpc_element_p ;
2006-04-07 21:57:27 +08:00
zend_bool is_array = 0 ;
2005-04-24 03:30:29 +08:00
HashTable * symtable1 = NULL ;
2010-08-26 20:20:35 +08:00
ALLOCA_FLAG ( use_heap )
2000-09-06 03:06:29 +08:00
2008-08-31 02:27:29 +08:00
assert ( var_name ! = NULL ) ;
2008-08-31 06:26:09 +08:00
1999-09-13 07:51:12 +08:00
if ( track_vars_array ) {
2002-12-08 00:05:27 +08:00
symtable1 = Z_ARRVAL_P ( track_vars_array ) ;
}
2010-04-21 09:27:22 +08:00
1999-09-13 07:51:12 +08:00
if ( ! symtable1 ) {
2000-09-06 03:06:29 +08:00
/* Nothing to do */
2000-02-20 04:12:26 +08:00
zval_dtor ( val ) ;
1999-09-13 07:51:12 +08:00
return ;
}
2006-04-07 21:57:27 +08:00
1999-09-13 07:51:12 +08:00
/* ignore leading spaces in the variable name */
2010-08-26 20:20:35 +08:00
while ( * var_name & & * var_name = = ' ' ) {
var_name + + ;
1999-09-13 07:51:12 +08:00
}
2010-08-26 20:20:35 +08:00
/*
* 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 ) ;
2006-04-07 21:57:27 +08:00
/* ensure that we don't have spaces or dots in the variable name (not binary safe) */
for ( p = var ; * p ; p + + ) {
if ( * p = = ' ' | | * p = = ' . ' ) {
* p = ' _ ' ;
} else if ( * p = = ' [ ' ) {
is_array = 1 ;
ip = p ;
* p = 0 ;
break ;
}
}
var_len = p - var ;
1999-09-13 07:51:12 +08:00
if ( var_len = = 0 ) { /* empty variable name, or variable name with a space in it */
2000-02-20 04:12:26 +08:00
zval_dtor ( val ) ;
2010-08-26 20:20:35 +08:00
free_alloca ( var_orig , use_heap ) ;
1999-09-13 07:51:12 +08:00
return ;
}
2005-09-29 06:39:52 +08:00
/* GLOBALS hijack attempt, reject parameter */
2006-04-07 21:57:27 +08:00
if ( symtable1 = = EG ( active_symbol_table ) & &
var_len = = sizeof ( " GLOBALS " ) - 1 & &
! memcmp ( var , " GLOBALS " , sizeof ( " GLOBALS " ) - 1 ) ) {
2005-09-29 06:39:52 +08:00
zval_dtor ( val ) ;
2010-08-26 20:20:35 +08:00
free_alloca ( var_orig , use_heap ) ;
2005-09-29 06:39:52 +08:00
return ;
}
1999-09-13 07:51:12 +08:00
index = var ;
index_len = var_len ;
2006-04-07 21:57:27 +08:00
if ( is_array ) {
2007-03-03 05:58:05 +08:00
int nest_level = 0 ;
2006-04-07 21:57:27 +08:00
while ( 1 ) {
2005-08-11 07:33:10 +08:00
char * index_s ;
2002-12-30 05:02:17 +08:00
int new_idx_len = 0 ;
2007-03-03 06:03:05 +08:00
if ( + + nest_level > PG ( max_input_nesting_level ) ) {
2007-06-04 00:19:14 +08:00
HashTable * ht ;
2007-03-03 05:58:05 +08:00
/* too many levels of nesting */
2007-06-04 00:19:14 +08:00
if ( track_vars_array ) {
ht = Z_ARRVAL_P ( track_vars_array ) ;
2007-09-29 19:18:42 +08:00
zend_hash_del ( ht , var , var_len + 1 ) ;
2007-06-04 00:19:14 +08:00
}
zval_dtor ( val ) ;
2007-07-18 19:46:50 +08:00
/* do not output the error message to the screen,
this helps us to to avoid " information disclosure " */
2007-06-04 00:19:14 +08:00
if ( ! PG ( display_errors ) ) {
2007-06-04 00:54:06 +08:00
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 ) ) ;
2007-06-04 00:19:14 +08:00
}
2010-08-26 20:20:35 +08:00
free_alloca ( var_orig , use_heap ) ;
2007-06-04 00:19:14 +08:00
return ;
2007-03-03 05:58:05 +08:00
}
2002-12-30 05:02:17 +08:00
ip + + ;
index_s = ip ;
if ( isspace ( * ip ) ) {
ip + + ;
}
if ( * ip = = ' ] ' ) {
index_s = NULL ;
} else {
ip = strchr ( ip , ' ] ' ) ;
if ( ! ip ) {
/* PHP variables cannot contain '[' in their names, so we replace the character with a '_' */
* ( index_s - 1 ) = ' _ ' ;
2004-10-18 23:05:06 +08:00
2007-06-04 00:19:14 +08:00
index_len = 0 ;
2004-10-18 23:05:06 +08:00
if ( index ) {
2007-06-04 00:19:14 +08:00
index_len = strlen ( index ) ;
2004-10-18 23:05:06 +08:00
}
2002-12-30 05:02:17 +08:00
goto plain_var ;
return ;
}
* ip = 0 ;
new_idx_len = strlen ( index_s ) ;
}
1999-09-13 07:51:12 +08:00
if ( ! index ) {
MAKE_STD_ZVAL ( gpc_element ) ;
array_init ( gpc_element ) ;
zend_hash_next_index_insert ( symtable1 , & gpc_element , sizeof ( zval * ) , ( void * * ) & gpc_element_p ) ;
} else {
2007-04-17 23:06:50 +08:00
if ( PG ( magic_quotes_gpc ) ) {
2001-08-06 11:50:52 +08:00
escaped_index = php_addslashes ( index , index_len , & index_len , 0 TSRMLS_CC ) ;
1999-09-13 07:51:12 +08:00
} else {
escaped_index = index ;
}
2005-04-24 03:30:29 +08:00
if ( zend_symtable_find ( symtable1 , escaped_index , index_len + 1 , ( void * * ) & gpc_element_p ) = = FAILURE
2001-09-26 05:58:48 +08:00
| | Z_TYPE_PP ( gpc_element_p ) ! = IS_ARRAY ) {
1999-09-13 07:51:12 +08:00
MAKE_STD_ZVAL ( gpc_element ) ;
array_init ( gpc_element ) ;
2005-04-24 03:30:29 +08:00
zend_symtable_update ( symtable1 , escaped_index , index_len + 1 , & gpc_element , sizeof ( zval * ) , ( void * * ) & gpc_element_p ) ;
1999-09-13 07:51:12 +08:00
}
2005-04-24 03:30:29 +08:00
if ( index ! = escaped_index ) {
1999-09-13 07:51:12 +08:00
efree ( escaped_index ) ;
}
}
2001-09-26 05:58:48 +08:00
symtable1 = Z_ARRVAL_PP ( gpc_element_p ) ;
1999-09-13 07:51:12 +08:00
/* ip pointed to the '[' character, now obtain the key */
2002-12-30 05:02:17 +08:00
index = index_s ;
index_len = new_idx_len ;
1999-09-13 07:51:12 +08:00
ip + + ;
2005-04-24 03:30:29 +08:00
if ( * ip = = ' [ ' ) {
1999-09-13 07:51:12 +08:00
is_array = 1 ;
* ip = 0 ;
} else {
2006-05-03 19:24:29 +08:00
goto plain_var ;
1999-09-13 07:51:12 +08:00
}
2006-04-07 21:57:27 +08:00
}
} else {
2002-12-30 05:02:17 +08:00
plain_var :
2006-04-07 21:57:27 +08:00
MAKE_STD_ZVAL ( gpc_element ) ;
gpc_element - > value = val - > value ;
Z_TYPE_P ( gpc_element ) = Z_TYPE_P ( val ) ;
if ( ! index ) {
zend_hash_next_index_insert ( symtable1 , & gpc_element , sizeof ( zval * ) , ( void * * ) & gpc_element_p ) ;
} 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 .
* If we encounter a duplicate cookie name , we should skip it , since it is not possible
* to have the same ( plain text ) cookie name for the same path and we should not overwrite
* more specific cookies with the less specific ones .
*/
if ( 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 ) ) {
zval_ptr_dtor ( & gpc_element ) ;
1999-09-13 07:51:12 +08:00
} else {
2005-04-24 03:30:29 +08:00
zend_symtable_update ( symtable1 , escaped_index , index_len + 1 , & gpc_element , sizeof ( zval * ) , ( void * * ) & gpc_element_p ) ;
1999-09-13 07:51:12 +08:00
}
2006-04-07 21:57:27 +08:00
if ( escaped_index ! = index ) {
efree ( escaped_index ) ;
}
1999-09-13 07:51:12 +08:00
}
}
2010-08-26 20:20:35 +08:00
free_alloca ( var_orig , use_heap ) ;
1999-09-13 07:51:12 +08:00
}
2001-08-16 02:01:48 +08:00
SAPI_API SAPI_POST_HANDLER_FUNC ( php_std_post_handler )
2000-02-18 04:23:59 +08:00
{
2006-07-27 23:37:56 +08:00
char * var , * val , * e , * s , * p ;
2000-02-18 04:23:59 +08:00
zval * array_ptr = ( zval * ) arg ;
2005-04-24 03:30:29 +08:00
if ( SG ( request_info ) . post_data = = NULL ) {
2002-07-24 19:25:36 +08:00
return ;
}
2006-07-27 23:37:56 +08:00
s = SG ( request_info ) . post_data ;
e = s + SG ( request_info ) . post_data_length ;
2000-02-18 04:23:59 +08:00
2006-07-27 23:37:56 +08:00
while ( s < e & & ( p = memchr ( s , ' & ' , ( e - s ) ) ) ) {
last_value :
if ( ( val = memchr ( s , ' = ' , ( p - s ) ) ) ) { /* have a value */
2003-11-29 23:24:35 +08:00
unsigned int val_len , new_val_len ;
2000-12-12 18:47:47 +08:00
2006-07-27 23:37:56 +08:00
var = s ;
php_url_decode ( var , ( val - s ) ) ;
val + + ;
val_len = php_url_decode ( val , ( p - val ) ) ;
2004-06-26 16:09:28 +08:00
val = estrndup ( val , val_len ) ;
2003-11-29 23:24:35 +08:00
if ( sapi_module . input_filter ( PARSE_POST , var , & val , val_len , & new_val_len TSRMLS_CC ) ) {
php_register_variable_safe ( var , val , new_val_len , array_ptr TSRMLS_CC ) ;
2003-11-26 17:53:22 +08:00
}
2004-06-26 16:09:28 +08:00
efree ( val ) ;
2000-02-18 04:23:59 +08:00
}
2006-07-27 23:37:56 +08:00
s = p + 1 ;
}
if ( s < e ) {
p = e ;
goto last_value ;
2000-02-18 04:23:59 +08:00
}
}
2003-02-20 03:41:09 +08:00
SAPI_API SAPI_INPUT_FILTER_FUNC ( php_default_input_filter )
{
/* TODO: check .ini setting here and apply user-defined input filter */
2005-07-26 06:37:35 +08:00
if ( new_val_len ) * new_val_len = val_len ;
2003-12-02 03:25:07 +08:00
return 1 ;
2003-02-20 03:41:09 +08:00
}
2002-08-02 14:53:48 +08:00
SAPI_API SAPI_TREAT_DATA_FUNC ( php_default_treat_data )
1999-04-22 10:48:28 +08:00
{
2005-04-24 03:30:29 +08:00
char * res = NULL , * var , * val , * separator = NULL ;
2000-11-02 23:47:02 +08:00
const char * c_var ;
2005-04-24 03:30:29 +08:00
zval * array_ptr ;
int free_buffer = 0 ;
1999-11-26 21:34:31 +08:00
char * strtok_buf = NULL ;
1999-04-22 10:48:28 +08:00
switch ( arg ) {
case PARSE_POST :
case PARSE_GET :
case PARSE_COOKIE :
2000-09-06 03:06:29 +08:00
ALLOC_ZVAL ( array_ptr ) ;
array_init ( array_ptr ) ;
INIT_PZVAL ( array_ptr ) ;
switch ( arg ) {
case PARSE_POST :
2005-06-01 17:44:10 +08:00
if ( PG ( http_globals ) [ TRACK_VARS_POST ] ) {
zval_ptr_dtor ( & PG ( http_globals ) [ TRACK_VARS_POST ] ) ;
}
2000-09-06 03:06:29 +08:00
PG ( http_globals ) [ TRACK_VARS_POST ] = array_ptr ;
break ;
case PARSE_GET :
2005-06-01 17:44:10 +08:00
if ( PG ( http_globals ) [ TRACK_VARS_GET ] ) {
zval_ptr_dtor ( & PG ( http_globals ) [ TRACK_VARS_GET ] ) ;
}
2000-09-06 03:06:29 +08:00
PG ( http_globals ) [ TRACK_VARS_GET ] = array_ptr ;
break ;
case PARSE_COOKIE :
2005-06-01 17:44:10 +08:00
if ( PG ( http_globals ) [ TRACK_VARS_COOKIE ] ) {
zval_ptr_dtor ( & PG ( http_globals ) [ TRACK_VARS_COOKIE ] ) ;
}
2000-09-06 03:06:29 +08:00
PG ( http_globals ) [ TRACK_VARS_COOKIE ] = array_ptr ;
break ;
1999-04-22 10:48:28 +08:00
}
break ;
default :
2005-04-24 03:30:29 +08:00
array_ptr = destArray ;
1999-04-22 10:48:28 +08:00
break ;
}
2005-04-24 03:30:29 +08:00
if ( arg = = PARSE_POST ) {
2001-07-28 19:36:37 +08:00
sapi_handle_post ( array_ptr TSRMLS_CC ) ;
2000-02-18 04:23:59 +08:00
return ;
}
if ( arg = = PARSE_GET ) { /* GET data */
2000-11-02 23:47:02 +08:00
c_var = SG ( request_info ) . query_string ;
if ( c_var & & * c_var ) {
res = ( char * ) estrdup ( c_var ) ;
1999-05-10 02:40:59 +08:00
free_buffer = 1 ;
} else {
free_buffer = 0 ;
1999-04-22 10:48:28 +08:00
}
} else if ( arg = = PARSE_COOKIE ) { /* Cookie data */
2000-11-02 23:47:02 +08:00
c_var = SG ( request_info ) . cookie_data ;
if ( c_var & & * c_var ) {
res = ( char * ) estrdup ( c_var ) ;
1999-05-10 02:40:59 +08:00
free_buffer = 1 ;
} else {
free_buffer = 0 ;
1999-04-22 10:48:28 +08:00
}
} else if ( arg = = PARSE_STRING ) { /* String data */
res = str ;
1999-05-10 02:40:59 +08:00
free_buffer = 1 ;
1999-04-22 10:48:28 +08:00
}
2000-02-18 04:23:59 +08:00
1999-04-22 10:48:28 +08:00
if ( ! res ) {
return ;
}
2001-04-05 04:46:26 +08:00
switch ( arg ) {
case PARSE_GET :
case PARSE_STRING :
separator = ( char * ) estrdup ( PG ( arg_separator ) . input ) ;
break ;
case PARSE_COOKIE :
2005-07-19 03:18:03 +08:00
separator = " ; \0 " ;
2001-04-05 04:46:26 +08:00
break ;
}
2001-04-04 08:37:06 +08:00
var = php_strtok_r ( res , separator , & strtok_buf ) ;
2000-02-18 04:23:59 +08:00
while ( var ) {
val = strchr ( var , ' = ' ) ;
2006-12-09 21:01:23 +08:00
if ( arg = = PARSE_COOKIE ) {
/* Remove leading spaces from cookie names, needed for multi-cookie header where ; can be followed by a space */
while ( isspace ( * var ) ) {
var + + ;
}
if ( var = = val | | * var = = ' \0 ' ) {
goto next_cookie ;
}
}
2000-02-18 04:23:59 +08:00
if ( val ) { /* have a value */
2000-12-12 18:47:47 +08:00
int val_len ;
2003-11-29 23:24:35 +08:00
unsigned int new_val_len ;
2000-12-12 18:47:47 +08:00
2000-02-18 04:23:59 +08:00
* val + + = ' \0 ' ;
php_url_decode ( var , strlen ( var ) ) ;
2002-09-08 08:27:05 +08:00
val_len = php_url_decode ( val , strlen ( val ) ) ;
2004-06-26 16:09:28 +08:00
val = estrndup ( val , val_len ) ;
2004-07-12 04:13:39 +08:00
if ( sapi_module . input_filter ( arg , var , & val , val_len , & new_val_len TSRMLS_CC ) ) {
2003-11-29 23:24:35 +08:00
php_register_variable_safe ( var , val , new_val_len , array_ptr TSRMLS_CC ) ;
2003-11-26 17:53:22 +08:00
}
2004-06-26 16:09:28 +08:00
efree ( val ) ;
2002-08-01 00:25:12 +08:00
} else {
2004-07-12 05:14:50 +08:00
int val_len ;
unsigned int new_val_len ;
2002-09-08 05:04:14 +08:00
php_url_decode ( var , strlen ( var ) ) ;
2004-07-12 04:13:39 +08:00
val_len = 0 ;
val = estrndup ( " " , val_len ) ;
if ( sapi_module . input_filter ( arg , var , & val , val_len , & new_val_len TSRMLS_CC ) ) {
php_register_variable_safe ( var , val , new_val_len , array_ptr TSRMLS_CC ) ;
}
efree ( val ) ;
2002-07-28 12:18:40 +08:00
}
2006-12-09 21:01:23 +08:00
next_cookie :
2001-04-04 08:37:06 +08:00
var = php_strtok_r ( NULL , separator , & strtok_buf ) ;
1999-04-22 10:48:28 +08:00
}
2001-04-05 04:46:26 +08:00
2005-04-24 03:30:29 +08:00
if ( arg ! = PARSE_COOKIE ) {
2001-04-05 04:46:26 +08:00
efree ( separator ) ;
}
1999-05-10 02:40:59 +08:00
if ( free_buffer ) {
efree ( res ) ;
}
1999-04-22 10:48:28 +08:00
}
2002-10-13 16:38:09 +08:00
void _php_import_environment_variables ( zval * array_ptr TSRMLS_DC )
2000-01-29 01:24:53 +08:00
{
2003-03-28 05:13:47 +08:00
char buf [ 128 ] ;
char * * env , * p , * t = buf ;
size_t alloc_size = sizeof ( buf ) ;
2003-03-29 01:09:04 +08:00
unsigned long nlen ; /* ptrdiff_t is not portable */
2003-03-28 05:13:47 +08:00
2003-03-24 03:30:31 +08:00
/* turn off magic_quotes while importing environment variables */
int magic_quotes_gpc = PG ( magic_quotes_gpc ) ;
PG ( magic_quotes_gpc ) = 0 ;
2000-01-29 01:24:53 +08:00
for ( env = environ ; env ! = NULL & & * env ! = NULL ; env + + ) {
p = strchr ( * env , ' = ' ) ;
if ( ! p ) { /* malformed entry? */
continue ;
}
2003-03-28 05:13:47 +08:00
nlen = p - * env ;
if ( nlen > = alloc_size ) {
alloc_size = nlen + 64 ;
t = ( t = = buf ? emalloc ( alloc_size ) : erealloc ( t , alloc_size ) ) ;
}
memcpy ( t , * env , nlen ) ;
t [ nlen ] = ' \0 ' ;
2005-04-24 03:30:29 +08:00
php_register_variable ( t , p + 1 , array_ptr TSRMLS_CC ) ;
2003-03-28 05:13:47 +08:00
}
if ( t ! = buf & & t ! = NULL ) {
2000-01-29 01:24:53 +08:00
efree ( t ) ;
}
2003-03-24 03:30:31 +08:00
PG ( magic_quotes_gpc ) = magic_quotes_gpc ;
2000-01-29 01:24:53 +08:00
}
2003-03-02 18:19:15 +08:00
zend_bool php_std_auto_global_callback ( char * name , uint name_len TSRMLS_DC )
{
zend_printf ( " %s \n " , name ) ;
return 0 ; /* don't rearm */
}
/* {{{ php_build_argv
*/
static void php_build_argv ( char * s , zval * track_vars_array TSRMLS_DC )
{
2005-04-24 03:30:29 +08:00
zval * arr , * argc , * tmp ;
2003-03-02 18:19:15 +08:00
int count = 0 ;
char * ss , * space ;
2010-04-21 09:27:22 +08:00
if ( ! ( SG ( request_info ) . argc | | track_vars_array ) ) {
2003-10-02 07:11:59 +08:00
return ;
}
2006-04-18 14:58:43 +08:00
ALLOC_INIT_ZVAL ( arr ) ;
2003-03-02 18:19:15 +08:00
array_init ( arr ) ;
/* Prepare argv */
if ( SG ( request_info ) . argc ) { /* are we in cli sapi? */
int i ;
2005-04-24 03:30:29 +08:00
for ( i = 0 ; i < SG ( request_info ) . argc ; i + + ) {
2003-03-02 18:19:15 +08:00
ALLOC_ZVAL ( tmp ) ;
Z_TYPE_P ( tmp ) = IS_STRING ;
Z_STRLEN_P ( tmp ) = strlen ( SG ( request_info ) . argv [ i ] ) ;
Z_STRVAL_P ( tmp ) = estrndup ( SG ( request_info ) . argv [ i ] , Z_STRLEN_P ( tmp ) ) ;
INIT_PZVAL ( tmp ) ;
2005-04-24 03:30:29 +08:00
if ( zend_hash_next_index_insert ( Z_ARRVAL_P ( arr ) , & tmp , sizeof ( zval * ) , NULL ) = = FAILURE ) {
2003-03-02 18:19:15 +08:00
if ( Z_TYPE_P ( tmp ) = = IS_STRING ) {
efree ( Z_STRVAL_P ( tmp ) ) ;
}
}
}
} else if ( s & & * s ) {
ss = s ;
while ( ss ) {
space = strchr ( ss , ' + ' ) ;
if ( space ) {
* space = ' \0 ' ;
}
/* auto-type */
ALLOC_ZVAL ( tmp ) ;
Z_TYPE_P ( tmp ) = IS_STRING ;
Z_STRLEN_P ( tmp ) = strlen ( ss ) ;
Z_STRVAL_P ( tmp ) = estrndup ( ss , Z_STRLEN_P ( tmp ) ) ;
INIT_PZVAL ( tmp ) ;
count + + ;
2005-04-24 03:30:29 +08:00
if ( zend_hash_next_index_insert ( Z_ARRVAL_P ( arr ) , & tmp , sizeof ( zval * ) , NULL ) = = FAILURE ) {
2003-03-02 18:19:15 +08:00
if ( Z_TYPE_P ( tmp ) = = IS_STRING ) {
efree ( Z_STRVAL_P ( tmp ) ) ;
}
}
if ( space ) {
* space = ' + ' ;
ss = space + 1 ;
} else {
ss = space ;
}
}
}
/* prepare argc */
2006-04-18 14:58:43 +08:00
ALLOC_INIT_ZVAL ( argc ) ;
2003-03-02 18:19:15 +08:00
if ( SG ( request_info ) . argc ) {
Z_LVAL_P ( argc ) = SG ( request_info ) . argc ;
} else {
Z_LVAL_P ( argc ) = count ;
}
Z_TYPE_P ( argc ) = IS_LONG ;
2010-04-21 09:27:22 +08:00
if ( SG ( request_info ) . argc ) {
2007-10-07 13:22:07 +08:00
Z_ADDREF_P ( arr ) ;
Z_ADDREF_P ( argc ) ;
2003-03-02 18:19:15 +08:00
zend_hash_update ( & EG ( symbol_table ) , " argv " , sizeof ( " argv " ) , & arr , sizeof ( zval * ) , NULL ) ;
zend_hash_add ( & EG ( symbol_table ) , " argc " , sizeof ( " argc " ) , & argc , sizeof ( zval * ) , NULL ) ;
2003-10-07 16:46:16 +08:00
}
if ( track_vars_array ) {
2007-10-07 13:22:07 +08:00
Z_ADDREF_P ( arr ) ;
Z_ADDREF_P ( argc ) ;
2005-04-24 03:30:29 +08:00
zend_hash_update ( Z_ARRVAL_P ( track_vars_array ) , " argv " , sizeof ( " argv " ) , & arr , sizeof ( zval * ) , NULL ) ;
zend_hash_update ( Z_ARRVAL_P ( track_vars_array ) , " argc " , sizeof ( " argc " ) , & argc , sizeof ( zval * ) , NULL ) ;
2003-03-02 18:19:15 +08:00
}
2006-04-18 14:58:43 +08:00
zval_ptr_dtor ( & arr ) ;
zval_ptr_dtor ( & argc ) ;
2003-03-02 18:19:15 +08:00
}
/* }}} */
/* {{{ php_handle_special_queries
*/
PHPAPI int php_handle_special_queries ( TSRMLS_D )
{
2005-04-24 03:30:29 +08:00
if ( PG ( expose_php ) & & SG ( request_info ) . query_string & & SG ( request_info ) . query_string [ 0 ] = = ' = ' ) {
if ( php_info_logos ( SG ( request_info ) . query_string + 1 TSRMLS_CC ) ) {
2003-03-02 18:19:15 +08:00
return 1 ;
2005-04-24 03:30:29 +08:00
} else if ( ! strcmp ( SG ( request_info ) . query_string + 1 , PHP_CREDITS_GUID ) ) {
2003-03-25 16:07:13 +08:00
php_print_credits ( PHP_CREDITS_ALL TSRMLS_CC ) ;
2003-03-02 18:19:15 +08:00
return 1 ;
}
}
return 0 ;
}
/* }}} */
/* {{{ php_register_server_variables
*/
static inline void php_register_server_variables ( TSRMLS_D )
{
2005-04-24 03:30:29 +08:00
zval * array_ptr = NULL ;
2003-03-30 09:06:54 +08:00
/* turn off magic_quotes while importing server variables */
int magic_quotes_gpc = PG ( magic_quotes_gpc ) ;
2003-03-02 18:19:15 +08:00
ALLOC_ZVAL ( array_ptr ) ;
array_init ( array_ptr ) ;
INIT_PZVAL ( array_ptr ) ;
2005-06-01 17:44:10 +08:00
if ( PG ( http_globals ) [ TRACK_VARS_SERVER ] ) {
zval_ptr_dtor ( & PG ( http_globals ) [ TRACK_VARS_SERVER ] ) ;
}
2003-03-02 18:19:15 +08:00
PG ( http_globals ) [ TRACK_VARS_SERVER ] = array_ptr ;
2003-03-30 09:06:54 +08:00
PG ( magic_quotes_gpc ) = 0 ;
2003-03-02 18:19:15 +08:00
/* Server variables */
if ( sapi_module . register_server_variables ) {
sapi_module . register_server_variables ( array_ptr TSRMLS_CC ) ;
}
/* PHP Authentication support */
if ( SG ( request_info ) . auth_user ) {
php_register_variable ( " PHP_AUTH_USER " , SG ( request_info ) . auth_user , array_ptr TSRMLS_CC ) ;
}
if ( SG ( request_info ) . auth_password ) {
php_register_variable ( " PHP_AUTH_PW " , SG ( request_info ) . auth_password , array_ptr TSRMLS_CC ) ;
}
2005-04-04 23:06:36 +08:00
if ( SG ( request_info ) . auth_digest ) {
php_register_variable ( " PHP_AUTH_DIGEST " , SG ( request_info ) . auth_digest , array_ptr TSRMLS_CC ) ;
}
2004-10-25 01:41:13 +08:00
/* store request init time */
{
zval new_entry ;
2010-11-07 01:14:21 +08:00
Z_TYPE ( new_entry ) = IS_DOUBLE ;
Z_DVAL ( new_entry ) = sapi_get_request_time ( TSRMLS_C ) ;
2004-10-25 01:41:13 +08:00
php_register_variable_ex ( " REQUEST_TIME " , & new_entry , array_ptr TSRMLS_CC ) ;
}
2003-03-30 09:06:54 +08:00
PG ( magic_quotes_gpc ) = magic_quotes_gpc ;
2003-03-02 18:19:15 +08:00
}
/* }}} */
2003-07-22 01:42:24 +08:00
/* {{{ php_autoglobal_merge
*/
static void php_autoglobal_merge ( HashTable * dest , HashTable * src TSRMLS_DC )
{
2003-07-23 00:08:50 +08:00
zval * * src_entry , * * dest_entry ;
char * string_key ;
uint string_key_len ;
ulong num_key ;
HashPosition pos ;
int key_type ;
2010-04-21 09:27:22 +08:00
int globals_check = ( dest = = ( & EG ( symbol_table ) ) ) ;
2003-07-22 01:42:24 +08:00
zend_hash_internal_pointer_reset_ex ( src , & pos ) ;
while ( zend_hash_get_current_data_ex ( src , ( void * * ) & src_entry , & pos ) = = SUCCESS ) {
key_type = zend_hash_get_current_key_ex ( src , & string_key , & string_key_len , & num_key , 0 , & pos ) ;
2003-07-23 00:08:50 +08:00
if ( Z_TYPE_PP ( src_entry ) ! = IS_ARRAY
2005-04-24 03:30:29 +08:00
| | ( 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 )
| | Z_TYPE_PP ( dest_entry ) ! = IS_ARRAY
) {
2007-10-07 13:22:07 +08:00
Z_ADDREF_PP ( src_entry ) ;
2003-07-22 01:42:24 +08:00
if ( key_type = = HASH_KEY_IS_STRING ) {
2005-02-17 12:44:11 +08:00
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 ) ;
} else {
2007-10-07 13:22:07 +08:00
Z_DELREF_PP ( src_entry ) ;
2005-02-17 12:44:11 +08:00
}
2003-07-22 01:42:24 +08:00
} else {
zend_hash_index_update ( dest , num_key , src_entry , sizeof ( zval * ) , NULL ) ;
}
} else {
SEPARATE_ZVAL ( dest_entry ) ;
php_autoglobal_merge ( Z_ARRVAL_PP ( dest_entry ) , Z_ARRVAL_PP ( src_entry ) TSRMLS_CC ) ;
}
zend_hash_move_forward_ex ( src , & pos ) ;
}
}
/* }}} */
2003-03-02 18:19:15 +08:00
static zend_bool php_auto_globals_create_server ( char * name , uint name_len TSRMLS_DC ) ;
static zend_bool php_auto_globals_create_env ( char * name , uint name_len TSRMLS_DC ) ;
2003-03-02 21:35:01 +08:00
static zend_bool php_auto_globals_create_request ( char * name , uint name_len TSRMLS_DC ) ;
2003-03-02 18:19:15 +08:00
/* {{{ php_hash_environment
*/
int php_hash_environment ( TSRMLS_D )
{
2010-07-08 22:05:11 +08:00
memset ( PG ( http_globals ) , 0 , sizeof ( PG ( http_globals ) ) ) ;
zend_activate_auto_globals ( TSRMLS_C ) ;
2003-10-02 07:11:59 +08:00
if ( PG ( register_argc_argv ) ) {
php_build_argv ( SG ( request_info ) . query_string , PG ( http_globals ) [ TRACK_VARS_SERVER ] TSRMLS_CC ) ;
}
2010-07-08 22:05:11 +08:00
return SUCCESS ;
}
/* }}} */
2003-10-02 07:11:59 +08:00
2010-07-08 22:05:11 +08:00
static zend_bool php_auto_globals_create_get ( char * name , uint name_len TSRMLS_DC )
{
zval * vars ;
if ( PG ( variables_order ) & & ( strchr ( PG ( variables_order ) , ' G ' ) | | strchr ( PG ( variables_order ) , ' g ' ) ) ) {
sapi_module . treat_data ( PARSE_GET , NULL , NULL TSRMLS_CC ) ;
vars = PG ( http_globals ) [ TRACK_VARS_GET ] ;
} else {
ALLOC_ZVAL ( vars ) ;
array_init ( vars ) ;
INIT_PZVAL ( vars ) ;
if ( PG ( http_globals ) [ TRACK_VARS_GET ] ) {
zval_ptr_dtor ( & PG ( http_globals ) [ TRACK_VARS_GET ] ) ;
2003-03-02 18:19:15 +08:00
}
2010-07-08 22:05:11 +08:00
PG ( http_globals ) [ TRACK_VARS_GET ] = vars ;
}
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_post ( char * name , uint name_len TSRMLS_DC )
{
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 ] ) ;
2003-03-02 18:19:15 +08:00
}
2010-07-08 22:05:11 +08:00
PG ( http_globals ) [ TRACK_VARS_POST ] = vars ;
}
zend_hash_update ( & EG ( symbol_table ) , name , name_len + 1 , & vars , sizeof ( zval * ) , NULL ) ;
Z_ADDREF_P ( vars ) ;
return 0 ; /* don't rearm */
}
2003-03-02 18:19:15 +08:00
2010-07-08 22:05:11 +08:00
static zend_bool php_auto_globals_create_cookie ( 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 ;
2003-03-02 18:19:15 +08:00
}
2010-07-08 22:05:11 +08:00
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_files ( 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 ;
2003-03-02 18:19:15 +08:00
}
2010-07-08 22:05:11 +08:00
zend_hash_update ( & EG ( symbol_table ) , name , name_len + 1 , & vars , sizeof ( zval * ) , NULL ) ;
Z_ADDREF_P ( vars ) ;
return 0 ; /* don't rearm */
2003-03-02 18:19:15 +08:00
}
static zend_bool php_auto_globals_create_server ( char * name , uint name_len TSRMLS_DC )
{
2005-09-02 03:15:19 +08:00
if ( PG ( variables_order ) & & ( strchr ( PG ( variables_order ) , ' S ' ) | | strchr ( PG ( variables_order ) , ' s ' ) ) ) {
2005-05-26 01:41:50 +08:00
php_register_server_variables ( TSRMLS_C ) ;
2006-03-20 18:15:02 +08:00
if ( PG ( register_argc_argv ) ) {
if ( SG ( request_info ) . argc ) {
zval * * argc , * * argv ;
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 ) {
2007-10-07 13:22:07 +08:00
Z_ADDREF_PP ( argc ) ;
Z_ADDREF_PP ( argv ) ;
2006-03-20 18:15:02 +08:00
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 ] ) , " argc " , sizeof ( " argc " ) , argc , sizeof ( zval * ) , NULL ) ;
}
} else {
php_build_argv ( SG ( request_info ) . query_string , PG ( http_globals ) [ TRACK_VARS_SERVER ] TSRMLS_CC ) ;
}
}
2005-05-26 01:41:50 +08:00
} else {
zval * server_vars = NULL ;
ALLOC_ZVAL ( server_vars ) ;
array_init ( server_vars ) ;
INIT_PZVAL ( server_vars ) ;
2005-06-01 17:44:10 +08:00
if ( PG ( http_globals ) [ TRACK_VARS_SERVER ] ) {
zval_ptr_dtor ( & PG ( http_globals ) [ TRACK_VARS_SERVER ] ) ;
}
2005-05-26 01:41:50 +08:00
PG ( http_globals ) [ TRACK_VARS_SERVER ] = server_vars ;
}
2003-03-02 18:19:15 +08:00
2005-04-24 03:30:29 +08:00
zend_hash_update ( & EG ( symbol_table ) , name , name_len + 1 , & PG ( http_globals ) [ TRACK_VARS_SERVER ] , sizeof ( zval * ) , NULL ) ;
2007-10-07 13:22:07 +08:00
Z_ADDREF_P ( PG ( http_globals ) [ TRACK_VARS_SERVER ] ) ;
2006-03-20 18:15:02 +08:00
2003-03-02 18:19:15 +08:00
return 0 ; /* don't rearm */
}
static zend_bool php_auto_globals_create_env ( char * name , uint name_len TSRMLS_DC )
{
2005-04-24 03:30:29 +08:00
zval * env_vars = NULL ;
2004-07-10 15:46:17 +08:00
ALLOC_ZVAL ( env_vars ) ;
array_init ( env_vars ) ;
INIT_PZVAL ( env_vars ) ;
2005-06-01 17:44:10 +08:00
if ( PG ( http_globals ) [ TRACK_VARS_ENV ] ) {
zval_ptr_dtor ( & PG ( http_globals ) [ TRACK_VARS_ENV ] ) ;
}
2004-07-10 15:46:17 +08:00
PG ( http_globals ) [ TRACK_VARS_ENV ] = env_vars ;
2005-09-02 03:15:19 +08:00
if ( PG ( variables_order ) & & ( strchr ( PG ( variables_order ) , ' E ' ) | | strchr ( PG ( variables_order ) , ' e ' ) ) ) {
2005-05-26 01:41:50 +08:00
php_import_environment_variables ( PG ( http_globals ) [ TRACK_VARS_ENV ] TSRMLS_CC ) ;
}
2003-03-02 18:19:15 +08:00
2005-04-24 03:30:29 +08:00
zend_hash_update ( & EG ( symbol_table ) , name , name_len + 1 , & PG ( http_globals ) [ TRACK_VARS_ENV ] , sizeof ( zval * ) , NULL ) ;
2007-10-07 13:22:07 +08:00
Z_ADDREF_P ( PG ( http_globals ) [ TRACK_VARS_ENV ] ) ;
2003-03-02 18:19:15 +08:00
return 0 ; /* don't rearm */
}
2003-03-02 21:35:01 +08:00
static zend_bool php_auto_globals_create_request ( char * name , uint name_len TSRMLS_DC )
{
zval * form_variables ;
2003-08-01 06:29:32 +08:00
unsigned char _gpc_flags [ 3 ] = { 0 , 0 , 0 } ;
2003-03-02 21:35:01 +08:00
char * p ;
ALLOC_ZVAL ( form_variables ) ;
array_init ( form_variables ) ;
INIT_PZVAL ( form_variables ) ;
2010-11-17 19:55:37 +08:00
if ( PG ( request_order ) ! = NULL ) {
2008-03-13 04:24:45 +08:00
p = PG ( request_order ) ;
} else {
p = PG ( variables_order ) ;
}
for ( ; p & & * p ; p + + ) {
2003-03-02 21:35:01 +08:00
switch ( * p ) {
case ' g ' :
case ' G ' :
2003-08-01 06:29:32 +08:00
if ( ! _gpc_flags [ 0 ] ) {
php_autoglobal_merge ( Z_ARRVAL_P ( form_variables ) , Z_ARRVAL_P ( PG ( http_globals ) [ TRACK_VARS_GET ] ) TSRMLS_CC ) ;
_gpc_flags [ 0 ] = 1 ;
}
2003-03-02 21:35:01 +08:00
break ;
case ' p ' :
case ' P ' :
2003-08-01 06:29:32 +08:00
if ( ! _gpc_flags [ 1 ] ) {
php_autoglobal_merge ( Z_ARRVAL_P ( form_variables ) , Z_ARRVAL_P ( PG ( http_globals ) [ TRACK_VARS_POST ] ) TSRMLS_CC ) ;
_gpc_flags [ 1 ] = 1 ;
}
2003-03-02 21:35:01 +08:00
break ;
case ' c ' :
case ' C ' :
2003-08-01 06:29:32 +08:00
if ( ! _gpc_flags [ 2 ] ) {
php_autoglobal_merge ( Z_ARRVAL_P ( form_variables ) , Z_ARRVAL_P ( PG ( http_globals ) [ TRACK_VARS_COOKIE ] ) TSRMLS_CC ) ;
_gpc_flags [ 2 ] = 1 ;
}
2003-03-02 21:35:01 +08:00
break ;
}
}
2010-07-08 22:05:11 +08:00
zend_hash_update ( & EG ( symbol_table ) , name , name_len + 1 , & form_variables , sizeof ( zval * ) , NULL ) ;
2003-03-02 21:35:01 +08:00
return 0 ;
}
2003-03-02 18:19:15 +08:00
void php_startup_auto_globals ( TSRMLS_D )
{
2010-11-17 19:55:37 +08:00
zend_register_auto_global ( ZEND_STRL ( " _GET " ) , 0 , php_auto_globals_create_get TSRMLS_CC ) ;
zend_register_auto_global ( ZEND_STRL ( " _POST " ) , 0 , php_auto_globals_create_post TSRMLS_CC ) ;
zend_register_auto_global ( ZEND_STRL ( " _COOKIE " ) , 0 , php_auto_globals_create_cookie TSRMLS_CC ) ;
zend_register_auto_global ( ZEND_STRL ( " _SERVER " ) , PG ( auto_globals_jit ) , php_auto_globals_create_server TSRMLS_CC ) ;
zend_register_auto_global ( ZEND_STRL ( " _ENV " ) , PG ( auto_globals_jit ) , php_auto_globals_create_env TSRMLS_CC ) ;
zend_register_auto_global ( ZEND_STRL ( " _REQUEST " ) , PG ( auto_globals_jit ) , php_auto_globals_create_request TSRMLS_CC ) ;
zend_register_auto_global ( ZEND_STRL ( " _FILES " ) , 0 , php_auto_globals_create_files TSRMLS_CC ) ;
2003-03-02 18:19:15 +08:00
}
1999-04-22 10:48:28 +08:00
/*
* Local variables :
* tab - width : 4
* c - basic - offset : 4
* End :
2001-09-09 21:29:31 +08:00
* vim600 : sw = 4 ts = 4 fdm = marker
* vim < 600 : sw = 4 ts = 4
1999-04-22 10:48:28 +08:00
*/