diff options
author | Zeev Suraski <zeev@php.net> | 2001-01-22 00:06:52 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2001-01-22 00:06:52 +0000 |
commit | 6255a24f1c421b67daf136e61a394d81cc8eb5ce (patch) | |
tree | 243e38d02351bf3d459f7386699216a767f4567b /sapi/apache | |
parent | 67cdb386a440e3b457669bfc5fd821bedd8e59b2 (diff) | |
download | php-git-6255a24f1c421b67daf136e61a394d81cc8eb5ce.tar.gz |
Don't overwrite PATH_TRANSLATED if it exists
Diffstat (limited to 'sapi/apache')
-rw-r--r-- | sapi/apache/mod_php4.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c index eef777848a..b752f28d2e 100644 --- a/sapi/apache/mod_php4.c +++ b/sapi/apache/mod_php4.c @@ -225,25 +225,35 @@ static void sapi_apache_register_server_variables(zval *track_vars_array ELS_DC array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env); table_entry *elts = (table_entry *) arr->elts; char *script_filename=NULL; + zval **path_translated; + HashTable *symbol_table; for (i = 0; i < arr->nelts; i++) { char *val; if (elts[i].val) { val = elts[i].val; - if (!strcmp(elts[i].key, "SCRIPT_FILENAME")) { - script_filename = val; - } } else { val = empty_string; } php_register_variable(elts[i].key, val, track_vars_array ELS_CC PLS_CC); } - /* insert special variables */ - if (script_filename) { - php_register_variable("PATH_TRANSLATED", script_filename, track_vars_array ELS_CC PLS_CC); + /* If PATH_TRANSLATED doesn't exist, copy it from SCRIPT_FILENAME */ + if (track_vars_array) { + symbol_table = track_vars_array->value.ht; + } else if (PG(register_globals)) { + /* should never happen nowadays */ + symbol_table = EG(active_symbol_table); + } else { + symbol_table = NULL; } + if (symbol_table + && !zend_hash_exists(symbol_table, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")) + && zend_hash_find(symbol_table, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &path_translated)) { + php_register_variable("PATH_TRANSLATED", Z_STRVAL_PP(path_translated), track_vars_array ELS_CC PLS_CC); + } + php_register_variable("PHP_SELF", ((request_rec *) SG(server_context))->uri, track_vars_array ELS_CC PLS_CC); } |