cvs: /php4 ChangeLog main.c php.ini-dist php_globals.h /php4/ext/standard post.c

From: Date: Sat, 11 Sep 1999 15:04:45 +0000
Subject: cvs: /php4 ChangeLog main.c php.ini-dist php_globals.h /php4/ext/standard post.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-4322@lists.php.net to get a copy of this message
zeev Sat Sep 11 11:04:45 1999 EDT Modified files: /php4 ChangeLog main.c php.ini-dist php_globals.h /php4/ext/standard post.c Log: - Seriously optimize and clean php_parse_gpc_data() - Added gpc_globals directive to turn global definitions of GPC variables on/off (untested) Index: php4/ChangeLog diff -u php4/ChangeLog:1.89 php4/ChangeLog:1.90 --- php4/ChangeLog:1.89 Wed Sep 8 08:26:31 1999 +++ php4/ChangeLog Sat Sep 11 11:04:45 1999 @@ -2,7 +2,10 @@ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ?? 1999, Version 4.0 Beta 3 -- Add versioning support for shared library (Sascha) +- Added gpc_globals variable directive to php.ini. By default it is On, but + if it is set to Off, GET, POST and Cookie variables will not be inserted + to the global scope. Mostly makes sense when coupled with track_vars (Zeev) +- Added versioning support for shared library (Sascha) - Added second parameter to array_keys which specifies search value for which the key should be returned (Andrey) - Resourcified Informix driver (Danny) Index: php4/main.c diff -u php4/main.c:1.116 php4/main.c:1.117 --- php4/main.c:1.116 Sat Sep 11 10:09:29 1999 +++ php4/main.c Sat Sep 11 11:04:45 1999 @@ -19,7 +19,7 @@ */ -/* $Id: main.c,v 1.116 1999/09/11 14:09:29 zeev Exp $ */ +/* $Id: main.c,v 1.117 1999/09/11 15:04:45 zeev Exp $ */ #include <stdio.h> @@ -226,6 +226,7 @@ PHP_INI_ENTRY("memory_limit", "8388608", PHP_INI_ALL, OnChangeMemoryLimit) STD_PHP_INI_BOOLEAN("track_vars", (PHP_TRACK_VARS?"1":"0"), PHP_INI_ALL, OnUpdateBool, track_vars, php_core_globals, core_globals) + STD_PHP_INI_BOOLEAN("gpc_globals", "1", PHP_INI_ALL, OnUpdateBool, gpc_globals, php_core_globals, core_globals) STD_PHP_INI_ENTRY("gpc_order", "GPC", PHP_INI_ALL, OnUpdateStringUnempty, gpc_order, php_core_globals, core_globals) STD_PHP_INI_ENTRY("arg_separator", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("ignore_user_abort", "1", PHP_INI_ALL, OnUpdateInt, ignore_user_abort, php_core_globals, core_globals) Index: php4/php.ini-dist diff -u php4/php.ini-dist:1.5 php4/php.ini-dist:1.6 --- php4/php.ini-dist:1.5 Tue Aug 24 19:12:50 1999 +++ php4/php.ini-dist Sat Sep 11 11:04:45 1999 @@ -94,11 +94,23 @@ ;;;;;;;;;;;;;;;;; ; Data Handling ; ;;;;;;;;;;;;;;;;; +gpc_order = "GPC" ; Order of evaluation of GET/POST/Cookie data. Later values override + ; earlier values (e.g., by default, POST variables override GET variables, + ; and Cookie variables override both POST and GET variables). +gpc_globals = On ; Whether or not to define GET/POST/Cookie variables in the global + ; scope. You may want to turn this off if you don't want + ; to clutter your scripts' global scope with user data. This makes + ; most sense when coupled with track_vars - in which case you can + ; access all of the GPC variables through the $HTTP_GET_VARS[], + ; $HTTP_POST_VARS[] and $HTTP_COOKIE_VARS[] variables. +track_vars = On ; enable $HTTP_GET_VARS[], $HTTP_POST_VARS[] and $HTTP_COOKIE_VARS[] arrays + +; Magic quotes magic_quotes_gpc = On ; magic quotes for incoming GET/POST/Cookie data magic_quotes_runtime= Off ; magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc. magic_quotes_sybase = Off ; Use Sybase-style magic quotes (escape ' with '' instead of \') -track_vars = On ; enable $HTTP_GET_VARS[], $HTTP_POST_VARS[] and $HTTP_COOKIE_VARS[] arrays -; automatically add files before or after any PHP 3.0 document + +; automatically add files before or after any PHP document auto_prepend_file = auto_append_file = @@ -220,7 +232,7 @@ ;sybase.interface_file = "/usr/sybase/interfaces" sybase.min_error_severity = 10 ; minimum error severity to display sybase.min_message_severity = 10 ; minimum message severity to display -sybase.compatability_mode = Off ; compatability mode with earlier versions of PHP 3.0. +sybase.compatability_mode = Off ; compatability mode with old versions of PHP 3.0. ; If on, this will cause PHP to automatically assign types to results ; according to their Sybase type, instead of treating them all as ; strings. This compatability mode will probably not stay around Index: php4/php_globals.h diff -u php4/php_globals.h:1.22 php4/php_globals.h:1.23 --- php4/php_globals.h:1.22 Sun Sep 5 07:38:01 1999 +++ php4/php_globals.h Sat Sep 11 11:04:45 1999 @@ -80,6 +80,7 @@ char *gpc_order; zend_bool track_vars; + zend_bool gpc_globals; zend_bool y2k_compliance; Index: php4/ext/standard/post.c diff -u php4/ext/standard/post.c:1.20 php4/ext/standard/post.c:1.21 --- php4/ext/standard/post.c:1.20 Sat Sep 11 10:09:29 1999 +++ php4/ext/standard/post.c Sat Sep 11 11:04:45 1999 @@ -13,6 +13,7 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | + | Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ /* $Id: */ @@ -36,17 +37,23 @@ void php_parse_gpc_data(char *val, char *var, pval *track_vars_array ELS_DC PLS_DC) { int var_type; - char *ind, *tmp = NULL, *ret = NULL; + char *ind, *tmp = NULL, *array_index = NULL; int var_len, val_len; - pval *entry; + pval *gpc_element; + zend_bool do_insert; + if (!PG(gpc_globals) && !track_vars_array) { + /* we don't need track_vars, and we're not setting GPC globals either. */ + return; + } + var_type = php3_check_ident_type(var); if (var_type == GPC_INDEXED_ARRAY) { ind = php3_get_ident_index(var); if (PG(magic_quotes_gpc)) { - ret = php_addslashes(ind, 0, NULL, 1); + array_index = php_addslashes(ind, 0, NULL, 1); } else { - ret = ind; + array_index = ind; } } if (var_type & GPC_ARRAY) { /* array (indexed or not) */ @@ -82,93 +89,68 @@ } if (var_type & GPC_ARRAY) { - pval *arr1, *arr2; - pval **arr_ptr; - - /* If the array doesn't exist, create it */ - if (zend_hash_find(EG(active_symbol_table), var, var_len+1, (void **) &arr_ptr) == FAILURE) { - arr1 = (pval *) emalloc(sizeof(pval)); - INIT_PZVAL(arr1); - if (array_init(arr1)==FAILURE) { - return; - } - zend_hash_update(EG(active_symbol_table), var, var_len+1, &arr1, sizeof(pval *), NULL); - if (track_vars_array) { - arr2 = (pval *) emalloc(sizeof(pval)); - INIT_PZVAL(arr2); - if (array_init(arr2)==FAILURE) { - return; - } - zend_hash_update(track_vars_array->value.ht, var, var_len+1, (void *) &arr2, sizeof(pval *),NULL); - } + pval *gpc_element; + pval **arr_ptr_ptr; + pval *array_element; + + if (zend_hash_find(EG(active_symbol_table), var, var_len+1, (void **) &arr_ptr_ptr) == FAILURE) { + /* If the array doesn't exist, create it */ + MAKE_STD_ZVAL(gpc_element); + array_init(gpc_element); + do_insert=1; } else { - if ((*arr_ptr)->type!=IS_ARRAY) { - if (--(*arr_ptr) > 0) { - *arr_ptr = (pval *) emalloc(sizeof(pval)); - INIT_PZVAL(*arr_ptr); + if ((*arr_ptr_ptr)->type!=IS_ARRAY) { + if (--(*arr_ptr_ptr)->refcount > 0) { + MAKE_STD_ZVAL(*arr_ptr_ptr); } else { - pval_destructor(*arr_ptr); - } - if (array_init(*arr_ptr)==FAILURE) { - return; - } - if (track_vars_array) { - arr2 = (pval *) emalloc(sizeof(pval)); - INIT_PZVAL(arr2); - if (array_init(arr2)==FAILURE) { - return; - } - zend_hash_update(track_vars_array->value.ht, var, var_len+1, (void *) &arr2, sizeof(pval *),NULL); + zval_dtor(*arr_ptr_ptr); } + array_init(*arr_ptr_ptr); } - arr1 = *arr_ptr; - if (track_vars_array && zend_hash_find(track_vars_array->value.ht, var, var_len+1, (void **) &arr_ptr) == FAILURE) { - return; - } - arr2 = *arr_ptr; + gpc_element = *arr_ptr_ptr; + do_insert=0; } - /* Now create the element */ - entry = (pval *) emalloc(sizeof(pval)); - INIT_PZVAL(entry); - entry->value.str.val = val; - entry->value.str.len = val_len; - entry->type = IS_STRING; - - /* And then insert it */ - if (ret) { /* array */ - if (php3_check_type(ret) == IS_LONG) { /* numeric index */ - zend_hash_index_update(arr1->value.ht, atol(ret), &entry, sizeof(pval *),NULL); /* s[ret]=tmp */ - if (track_vars_array) { - zend_hash_index_update(arr2->value.ht, atol(ret), &entry, sizeof(pval *),NULL); - entry->refcount++; - } - } else { /* associative index */ - zend_hash_update(arr1->value.ht, ret, strlen(ret)+1, &entry, sizeof(pval *),NULL); /* s["ret"]=tmp */ - if (track_vars_array) { - zend_hash_update(arr2->value.ht, ret, strlen(ret)+1, &entry, sizeof(pval *),NULL); - entry->refcount++; - } - } - efree(ret); - ret = NULL; - } else { /* non-indexed array */ - zend_hash_next_index_insert(arr1->value.ht, &entry, sizeof(pval *),NULL); - if (track_vars_array) { - zend_hash_next_index_insert(arr2->value.ht, &entry, sizeof(pval *),NULL); - entry->refcount++; + + /* Create the element */ + array_element = (pval *) emalloc(sizeof(pval)); + INIT_PZVAL(array_element); + array_element->value.str.val = val; + array_element->value.str.len = val_len; + array_element->type = IS_STRING; + + /* Insert it */ + if (array_index) { + /* indexed array */ + if (php3_check_type(array_index) == IS_LONG) { + /* numeric index */ + zend_hash_index_update(gpc_element->value.ht, atol(array_index), &array_element, sizeof(pval *), NULL); /* s[array_index]=tmp */ + } else { + /* associative index */ + zend_hash_update(gpc_element->value.ht, array_index, strlen(array_index)+1, &array_element, sizeof(pval *), NULL); /* s["ret"]=tmp */ } + efree(array_index); + } else { + /* non-indexed array */ + zend_hash_next_index_insert(gpc_element->value.ht, &array_element, sizeof(pval *), NULL); } } else { /* we have a normal variable */ - pval *entry = (pval *) emalloc(sizeof(pval)); - - entry->type = IS_STRING; - INIT_PZVAL(entry); - entry->value.str.val = val; - entry->value.str.len = val_len; - zend_hash_update(EG(active_symbol_table), var, var_len+1, (void *) &entry, sizeof(pval *),NULL); + MAKE_STD_ZVAL(gpc_element); + gpc_element->type = IS_STRING; + gpc_element->refcount = 0; + gpc_element->value.str.val = val; + gpc_element->value.str.len = val_len; + do_insert=1; + } + + if (do_insert) { + gpc_element->refcount = 0; + if (PG(gpc_globals)) { + zend_hash_update(EG(active_symbol_table), var, var_len+1, &gpc_element, sizeof(pval *), NULL); + gpc_element->refcount++; + } if (track_vars_array) { - entry->refcount++; - zend_hash_update(track_vars_array->value.ht, var, var_len+1, (void *) &entry, sizeof(pval *), NULL); + zend_hash_update(EG(active_symbol_table), var, var_len+1, &gpc_element, sizeof(pval *), NULL); + gpc_element->refcount++; } } }

« previous php.version4 (#4322) next »