cvs: php4 / NEWS /ext/standard info.c /main SAPI.c SAPI.h main.c php_ini.c php_ini.h /sapi/aolserver aolserver.c /sapi/apache mod_php4.c
/sapi/apache2filter sapi_apache2.c /sapi/caudium caudium.c /sapi/cgi cgi_main.c /sapi/isapi php4isapi.c /sapi/nsapi nsapi.c /sapi/phttpd phttpd.c
/sapi/pi3web pi3web_sapi.c /sapi/roxen roxen.c /sapi/servlet servlet.c /sapi/thttpd thttpd.c
| From: | Zeev Suraski | Date: | Tue, 02 Jan 2001 22:49:33 +0000 |
| Subject: | cvs: php4 / NEWS /ext/standard info.c /main SAPI.c SAPI.h main.c php_ini.c php_ini.h /sapi/aolserver aolserver.c /sapi/apache mod_php4.c /sapi/apache2filter sapi_apache2.c /sapi/caudium caudium.c /sapi/cgi cgi_main.c /sapi/isapi php4isapi.c /sapi/nsapi nsapi.c /sapi/phttpd phttpd.c /sapi/pi3web pi3web_sapi.c /sapi/roxen roxen.c /sapi/servlet servlet.c /sapi/thttpd thttpd.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-3331@lists.php.net to get a copy of this message | ||
zeev Tue Jan 2 14:49:33 2001 EDT
Modified files:
/php4 NEWS
/php4/ext/standard info.c
/php4/main SAPI.c SAPI.h main.c php_ini.c php_ini.h
/php4/sapi/aolserver aolserver.c
/php4/sapi/apache mod_php4.c
/php4/sapi/apache2filter sapi_apache2.c
/php4/sapi/caudium caudium.c
/php4/sapi/cgi cgi_main.c
/php4/sapi/isapi php4isapi.c
/php4/sapi/nsapi nsapi.c
/php4/sapi/phttpd phttpd.c
/php4/sapi/pi3web pi3web_sapi.c
/php4/sapi/roxen roxen.c
/php4/sapi/servlet servlet.c
/php4/sapi/thttpd thttpd.c
Log:
Many patches. I hope I remember them all:
- Make sapi_module available to external modules (PHPAPI)
- Make the php.ini path reported in phpinfo() always point to
real full path of the php.ini file
- Optimized the ISAPI module not to read unnecessary server
variables and read necessary variables at most once.
Index: php4/NEWS diff -u php4/NEWS:1.548 php4/NEWS:1.549 --- php4/NEWS:1.548 Thu Dec 21 18:09:09 2000 +++ php4/NEWS Tue Jan 2 14:49:26 2001 @@ -2,6 +2,9 @@ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 200?, Version 4.0.5 +- Made the php.ini path reported in phpinfo() always point to the absolute + path that was opened (Zeev) +- Made the INI mechanism thread safe (Zeev, Zend engine) - Changed setlocale() to use LC_* constants. (Jani) - ctype functions now follow the extension naming conventions (Hartmut) - Added iconv() function (using libc or libiconv) (Stig) Index: php4/ext/standard/info.c diff -u php4/ext/standard/info.c:1.127 php4/ext/standard/info.c:1.128 --- php4/ext/standard/info.c:1.127 Wed Dec 27 07:43:05 2000 +++ php4/ext/standard/info.c Tue Jan 2 14:49:26 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: info.c,v 1.127 2000/12/27 15:43:05 zeev Exp $ */ +/* $Id: info.c,v 1.128 2001/01/02 22:49:26 zeev Exp $ */ #include "php.h" #include "php_ini.h" @@ -39,7 +39,7 @@ #define SECTION(name) PUTS("<H2 align=\"center\">" name "</H2>\n") -PHPAPI extern char *php_ini_path; +PHPAPI extern char *php_ini_opened_path; static int _display_module_info(zend_module_entry *module, void *arg) { @@ -197,7 +197,7 @@ php_info_print_table_row(2, "Virtual Directory Support", "disabled" ); #endif - php_info_print_table_row(2, "Configuration File (php.ini) Path", php_ini_path?php_ini_path:CONFIGURATION_FILE_PATH ); + php_info_print_table_row(2, "Configuration File (php.ini) Path", php_ini_opened_path?php_ini_opened_path:CONFIGURATION_FILE_PATH); #if ZEND_DEBUG php_info_print_table_row(2, "ZEND_DEBUG", "enabled" ); Index: php4/main/SAPI.c diff -u php4/main/SAPI.c:1.98 php4/main/SAPI.c:1.99 --- php4/main/SAPI.c:1.98 Tue Nov 28 17:22:49 2000 +++ php4/main/SAPI.c Tue Jan 2 14:49:26 2001 @@ -54,7 +54,7 @@ } /* True globals (no need for thread safety) */ -sapi_module_struct sapi_module; +SAPI_API sapi_module_struct sapi_module; SAPI_API void (*sapi_error)(int error_type, const char *message, ...); Index: php4/main/SAPI.h diff -u php4/main/SAPI.h:1.64 php4/main/SAPI.h:1.65 --- php4/main/SAPI.h:1.64 Mon Nov 27 22:54:16 2000 +++ php4/main/SAPI.h Tue Jan 2 14:49:26 2001 @@ -57,7 +57,7 @@ typedef struct _sapi_module_struct sapi_module_struct; -extern sapi_module_struct sapi_module; /* true global */ +extern SAPI_API sapi_module_struct sapi_module; /* true global */ /* Some values in this structure needs to be filled in before * calling sapi_activate(). We WILL change the `char *' entries, @@ -188,6 +188,8 @@ void (*register_server_variables)(zval *track_vars_array ELS_DC SLS_DC PLS_DC); void (*log_message)(char *message); + char *php_ini_path_override; + void (*block_interruptions)(void); void (*unblock_interruptions)(void); @@ -222,7 +224,7 @@ SAPI_POST_READER_FUNC(sapi_read_standard_form_data); SAPI_POST_READER_FUNC(php_default_post_reader); -#define STANDARD_SAPI_MODULE_PROPERTIES NULL +#define STANDARD_SAPI_MODULE_PROPERTIES NULL, NULL #endif /* SAPI_H */ Index: php4/main/main.c diff -u php4/main/main.c:1.344 php4/main/main.c:1.345 --- php4/main/main.c:1.344 Wed Dec 27 07:43:05 2000 +++ php4/main/main.c Tue Jan 2 14:49:26 2001 @@ -19,7 +19,7 @@ */ -/* $Id: main.c,v 1.344 2000/12/27 15:43:05 zeev Exp $ */ +/* $Id: main.c,v 1.345 2001/01/02 22:49:26 zeev Exp $ */ #include <stdio.h> @@ -106,9 +106,7 @@ /* True globals (no need for thread safety) */ HashTable configuration_hash; -PHPAPI char *php_ini_path = NULL; - #define SAFE_FILENAME(f) ((f)?(f):"-") static PHP_INI_MH(OnSetPrecision) @@ -700,15 +698,6 @@ } } - -static int php_config_ini_startup(void) -{ - if (php_init_config() == FAILURE) { - php_printf("PHP: Unable to parse configuration file.\n"); - return FAILURE; - } - return SUCCESS; -} static void php_config_ini_shutdown(void) { @@ -860,7 +849,7 @@ le_index_ptr = zend_register_list_destructors_ex(NULL, NULL, "index pointer", 0); FREE_MUTEX(gLock); - if (php_config_ini_startup() == FAILURE) { + if (php_init_config(sf->php_ini_path_override) == FAILURE) { return FAILURE; } Index: php4/main/php_ini.c diff -u php4/main/php_ini.c:1.45 php4/main/php_ini.c:1.46 --- php4/main/php_ini.c:1.45 Wed Dec 27 07:43:05 2000 +++ php4/main/php_ini.c Tue Jan 2 14:49:26 2001 @@ -24,8 +24,9 @@ #include "ext/standard/dl.h" #include "zend_extensions.h" +/* True globals */ static HashTable configuration_hash; -PHPAPI extern char *php_ini_path; +PHPAPI char *php_ini_opened_path=NULL; static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type) @@ -145,97 +146,80 @@ } -int php_init_config(void) +int php_init_config(char *php_ini_path_override) { + char *env_location, *php_ini_search_path; + int safe_mode_state; + char *open_basedir; + int free_ini_search_path=0; + zend_file_handle fh; PLS_FETCH(); if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) pvalue_config_destructor, 1)==FAILURE) { return FAILURE; } -#if USE_CONFIG_FILE - { - char *env_location,*default_location,*php_ini_search_path; - int safe_mode_state = PG(safe_mode); - char *open_basedir = PG(open_basedir); - char *opened_path; - int free_default_location=0; - zend_file_handle fh; - - env_location = getenv("PHPRC"); - if (!env_location) { - env_location=""; - } -#ifdef PHP_WIN32 - { - if (php_ini_path) { - default_location = php_ini_path; - } else { - default_location = (char *) malloc(512); - - if (!GetWindowsDirectory(default_location,255)) { - default_location[0]=0; - } - free_default_location=1; - } - } -#else - if (!php_ini_path) { - default_location = CONFIGURATION_FILE_PATH; - } else { - default_location = php_ini_path; - } -#endif + safe_mode_state = PG(safe_mode); + open_basedir = PG(open_basedir); -/* build a path */ - php_ini_search_path = (char *) malloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1); + env_location = getenv("PHPRC"); + if (!env_location) { + env_location=""; + } + if (php_ini_path_override) { + php_ini_search_path = php_ini_path_override; + free_ini_search_path = 0; + } else { + char *default_location; + int free_default_location; - if (!php_ini_path) { #ifdef PHP_WIN32 - sprintf(php_ini_search_path,".;%s;%s",env_location,default_location); + default_location = (char *) emalloc(512); + + if (!GetWindowsDirectory(default_location,255)) { + default_location[0]=0; + } + free_default_location=1; #else - sprintf(php_ini_search_path,".:%s:%s",env_location,default_location); + default_location = CONFIGURATION_FILE_PATH; + free_default_location=0; #endif - } else { - /* if path was set via -c flag, only look there */ - strcpy(php_ini_search_path,default_location); - } - PG(safe_mode) = 0; - PG(open_basedir) = NULL; - - - fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &opened_path); - free(php_ini_search_path); + php_ini_search_path = (char *) emalloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1); + free_ini_search_path = 1; + sprintf(php_ini_search_path, ".%c%s%c%s", ZEND_PATHS_SEPARATOR, env_location, ZEND_PATHS_SEPARATOR, default_location); if (free_default_location) { - free(default_location); + efree(default_location); } - PG(safe_mode) = safe_mode_state; - PG(open_basedir) = open_basedir; + } - if (!fh.handle.fp) { - return SUCCESS; /* having no configuration file is ok */ - } - fh.type = ZEND_HANDLE_FP; - fh.filename = opened_path; + PG(safe_mode) = 0; + PG(open_basedir) = NULL; + + fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path); + if (free_ini_search_path) { + efree(php_ini_search_path); + } + PG(safe_mode) = safe_mode_state; + PG(open_basedir) = open_basedir; - zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, NULL); + if (!fh.handle.fp) { + return SUCCESS; /* having no configuration file is ok */ + } + fh.type = ZEND_HANDLE_FP; + fh.filename = php_ini_opened_path; - if (opened_path) { - zval tmp; - - tmp.value.str.val = strdup(opened_path); - tmp.value.str.len = strlen(opened_path); - tmp.type = IS_STRING; - zend_hash_update(&configuration_hash,"cfg_file_path",sizeof("cfg_file_path"),(void *) &tmp,sizeof(zval),NULL); -#if DEBUG_CFG_PARSER - php_printf("INI file opened at '%s'\n",opened_path); -#endif - efree(opened_path); - } + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, NULL); + + if (php_ini_opened_path) { + zval tmp; + + tmp.value.str.len = strlen(php_ini_opened_path); + tmp.value.str.val = zend_strndup(php_ini_opened_path, tmp.value.str.len); + tmp.type = IS_STRING; + zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"),(void *) &tmp,sizeof(zval), NULL); + persist_alloc(php_ini_opened_path); } -#endif - return SUCCESS; } @@ -243,6 +227,9 @@ int php_shutdown_config(void) { zend_hash_destroy(&configuration_hash); + if (php_ini_opened_path) { + efree(php_ini_opened_path); + } return SUCCESS; } Index: php4/main/php_ini.h diff -u php4/main/php_ini.h:1.29 php4/main/php_ini.h:1.30 --- php4/main/php_ini.h:1.29 Mon Oct 30 15:39:14 2000 +++ php4/main/php_ini.h Tue Jan 2 14:49:27 2001 @@ -21,7 +21,7 @@ #include "zend_ini.h" -int php_init_config(void); +int php_init_config(char *php_ini_path_override); int php_shutdown_config(void); #define PHP_INI_USER ZEND_INI_USER Index: php4/sapi/aolserver/aolserver.c diff -u php4/sapi/aolserver/aolserver.c:1.53 php4/sapi/aolserver/aolserver.c:1.54 --- php4/sapi/aolserver/aolserver.c:1.53 Fri Nov 17 18:44:01 2000 +++ php4/sapi/aolserver/aolserver.c Tue Jan 2 14:49:27 2001 @@ -22,7 +22,7 @@ * - CGI/1.1 conformance */ -/* $Id: aolserver.c,v 1.53 2000/11/18 02:44:01 zeev Exp $ */ +/* $Id: aolserver.c,v 1.54 2001/01/02 22:49:27 zeev Exp $ */ /* conflict between PHP and AOLserver headers */ #define Debug php_Debug @@ -211,7 +211,7 @@ NSLS_FETCH(); php_info_print_table_start(); - php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.53 2000/11/18 02:44:01 zeev Exp $"); + php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.54 2001/01/02 22:49:27 zeev Exp $"); php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); @@ -368,7 +368,7 @@ /* this structure is static (as in "it does not change") */ -static sapi_module_struct sapi_module = { +static sapi_module_struct aolserver_sapi_module = { "aolserver", "AOLserver", @@ -606,15 +606,15 @@ php_ns_context *ctx; tsrm_startup(1, 1, 0, NULL); - sapi_startup(&sapi_module); - sapi_module.startup(&sapi_module); + sapi_startup(&aolserver_sapi_module); + sapi_module.startup(&aolserver_sapi_module); /* TSRM is used to allocate a per-thread structure */ ns_globals_id = ts_allocate_id(sizeof(ns_globals_struct), NULL, NULL); /* the context contains data valid for all threads */ ctx = malloc(sizeof *ctx); - ctx->sapi_module = &sapi_module; + ctx->sapi_module = &aolserver_sapi_module; ctx->ns_server = strdup(server); ctx->ns_module = strdup(module); Index: php4/sapi/apache/mod_php4.c diff -u php4/sapi/apache/mod_php4.c:1.80 php4/sapi/apache/mod_php4.c:1.81 --- php4/sapi/apache/mod_php4.c:1.80 Fri Dec 29 16:38:47 2000 +++ php4/sapi/apache/mod_php4.c Tue Jan 2 14:49:27 2001 @@ -17,7 +17,7 @@ | PHP 4.0 patches by Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: mod_php4.c,v 1.80 2000/12/30 00:38:47 zeev Exp $ */ +/* $Id: mod_php4.c,v 1.81 2001/01/02 22:49:27 zeev Exp $ */ #define NO_REGEX_EXTRA_H #ifdef WIN32 @@ -249,7 +249,7 @@ static int php_apache_startup(sapi_module_struct *sapi_module) { - if(php_module_startup(sapi_module) == FAILURE + if(php_module_startup(sapi_module, NULL) == FAILURE || zend_startup_module(&apache_module_entry) == FAILURE) { return FAILURE; } else { @@ -320,7 +320,7 @@ } -static sapi_module_struct sapi_module_conf = { +static sapi_module_struct apache_sapi_module = { "apache", /* name */ "Apache", /* pretty name */ @@ -590,8 +590,8 @@ #ifdef ZTS tsrm_startup(1, 1, 0, NULL); #endif - sapi_startup(&sapi_module_conf); - php_apache_startup(&sapi_module_conf); + sapi_startup(&apache_sapi_module); + php_apache_startup(&apache_sapi_module); } per_dir_entry.type = mode; @@ -675,7 +675,7 @@ static void apache_php_module_shutdown_wrapper(void) { apache_php_initialized = 0; - sapi_module_conf.shutdown(&sapi_module_conf); + apache_sapi_module.shutdown(&apache_sapi_module); #if MODULE_MAGIC_NUMBER >= 19970728 /* This function is only called on server exit if the apache API @@ -693,7 +693,7 @@ static void php_child_exit_handler(server_rec *s, pool *p) { /* apache_php_initialized = 0; */ - sapi_module_conf.shutdown(&sapi_module_conf); + apache_sapi_module.shutdown(&apache_sapi_module); #ifdef ZTS tsrm_shutdown(); @@ -709,8 +709,8 @@ #ifdef ZTS tsrm_startup(1, 1, 0, NULL); #endif - sapi_startup(&sapi_module_conf); - php_apache_startup(&sapi_module_conf); + sapi_startup(&apache_sapi_module); + php_apache_startup(&apache_sapi_module); } #if MODULE_MAGIC_NUMBER >= 19980527 { Index: php4/sapi/apache2filter/sapi_apache2.c diff -u php4/sapi/apache2filter/sapi_apache2.c:1.22 php4/sapi/apache2filter/sapi_apache2.c:1.23 --- php4/sapi/apache2filter/sapi_apache2.c:1.22 Fri Nov 17 18:44:02 2000 +++ php4/sapi/apache2filter/sapi_apache2.c Tue Jan 2 14:49:28 2001 @@ -187,7 +187,7 @@ apr_puts(msg, ctx->f->r->server->error_log); } -static sapi_module_struct sapi_module = { +static sapi_module_struct apache2_sapi_module = { "apache2filter", "Apache 2.0 Filter", @@ -420,7 +420,7 @@ static apr_status_t php_apache_server_shutdown(void *tmp) { - sapi_module.shutdown(&sapi_module); + apache2_sapi_module.shutdown(&apache2_sapi_module); sapi_shutdown(); tsrm_shutdown(); return APR_SUCCESS; @@ -430,8 +430,8 @@ php_apache_server_startup(apr_pool_t *pchild, server_rec *s) { tsrm_startup(1, 1, 0, NULL); - sapi_startup(&sapi_module); - sapi_module.startup(&sapi_module); + sapi_startup(&apache1_sapi_module); + apache2_sapi_module.startup(&apache2_sapi_module); apr_register_cleanup(pchild, NULL, php_apache_server_shutdown, NULL); php_apache_register_module(); } Index: php4/sapi/caudium/caudium.c diff -u php4/sapi/caudium/caudium.c:1.7 php4/sapi/caudium/caudium.c:1.8 --- php4/sapi/caudium/caudium.c:1.7 Thu Dec 7 11:01:13 2000 +++ php4/sapi/caudium/caudium.c Tue Jan 2 14:49:28 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: caudium.c,v 1.7 2000/12/07 19:01:13 neotron Exp $ */ +/* $Id: caudium.c,v 1.8 2001/01/02 22:49:28 zeev Exp $ */ #include "php.h" #ifdef HAVE_CAUDIUM @@ -458,7 +458,7 @@ { /* char buf[512]; */ php_info_print_table_start(); - php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c,v 1.7 2000/12/07 19:01:13 neotron Exp $"); + php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c,v 1.8 2001/01/02 22:49:28 zeev Exp $"); /* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); @@ -491,7 +491,7 @@ /* this structure is static (as in "it does not change") */ -static sapi_module_struct sapi_module = { +static sapi_module_struct caudium_sapi_module = { "caudium", "Caudium", php_module_startup, /* startup */ @@ -781,8 +781,8 @@ caudium_php_initialized = 1; tsrm_startup(1, 1, 0, NULL); caudium_globals_id = ts_allocate_id(sizeof(php_caudium_request), NULL, NULL); - sapi_startup(&sapi_module); - sapi_module.startup(&sapi_module); + sapi_startup(&caudium_sapi_module); + sapi_module.startup(&caudium_sapi_module); zend_startup_module(&php_caudium_module); PHP_INIT_LOCK(); } @@ -800,7 +800,7 @@ void pike_module_exit(void) { caudium_php_initialized = 0; - sapi_module.shutdown(&sapi_module); + sapi_module.shutdown(&caudium_sapi_module); if(php_program) free_program(php_program); tsrm_shutdown(); PHP_DESTROY(); Index: php4/sapi/cgi/cgi_main.c diff -u php4/sapi/cgi/cgi_main.c:1.89 php4/sapi/cgi/cgi_main.c:1.90 --- php4/sapi/cgi/cgi_main.c:1.89 Sun Dec 3 00:37:43 2000 +++ php4/sapi/cgi/cgi_main.c Tue Jan 2 14:49:28 2001 @@ -75,8 +75,6 @@ #include "php_getopt.h" -PHPAPI extern char *php_ini_path; - #define PHP_MODE_STANDARD 1 #define PHP_MODE_HIGHLIGHT 2 #define PHP_MODE_INDENT 3 @@ -201,7 +199,7 @@ -static sapi_module_struct sapi_module = { +static sapi_module_struct cgi_sapi_module = { "cgi", /* name */ "CGI", /* pretty name */ @@ -412,7 +410,7 @@ tsrm_startup(1,1,0, NULL); #endif - sapi_startup(&sapi_module); + sapi_startup(&cgi_sapi_module); #ifdef PHP_WIN32 _fmode = _O_BINARY; /*sets default for file streams to binary */ @@ -468,7 +466,7 @@ while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) { switch (c) { case 'c': - php_ini_path = strdup(ap_php_optarg); /* intentional leak */ + cgi_sapi_module.php_ini_path_override = strdup(ap_php_optarg); break; } @@ -477,7 +475,7 @@ ap_php_optarg = orig_optarg; } - if (php_module_startup(&sapi_module)==FAILURE) { + if (php_module_startup(&cgi_sapi_module)==FAILURE) { return FAILURE; } #ifdef ZTS @@ -773,6 +771,9 @@ STR_FREE(SG(request_info).path_translated); + if (cgi_sapi_module.php_ini_path_override) { + free(cgi_sapi_module.php_ini_path_override); + } #ifdef ZTS tsrm_shutdown(); #endif Index: php4/sapi/isapi/php4isapi.c diff -u php4/sapi/isapi/php4isapi.c:1.62 php4/sapi/isapi/php4isapi.c:1.63 --- php4/sapi/isapi/php4isapi.c:1.62 Fri Dec 15 08:18:55 2000 +++ php4/sapi/isapi/php4isapi.c Tue Jan 2 14:49:29 2001 @@ -50,28 +50,30 @@ static zend_bool bFilterLoaded=0; static zend_bool bTerminateThreadsOnError=0; -static char *isapi_server_variables[] = { +static char *isapi_special_server_variable_names[] = { "ALL_HTTP", + "HTTPS", +#ifndef WITH_ZEUS + "SCRIPT_NAME", +#else + "PATH_INFO", +#endif + NULL +}; + +#define NUM_SPECIAL_VARS (sizeof(isapi_special_server_variable_names)/sizeof(char *)) +#define SPECIAL_VAR_ALL_HTTP 0 +#define SPECIAL_VAR_HTTPS 1 +#define SPECIAL_VAR_PHP_SELF 2 + +static char *isapi_special_server_variables[NUM_SPECIAL_VARS]; + +static char *isapi_server_variable_names[] = { "AUTH_PASSWORD", "AUTH_TYPE", "AUTH_USER", - "CERT_COOKIE", - "CERT_FLAGS", - "CERT_ISSUER", - "CERT_KEYSIZE", - "CERT_SECRETKEYSIZE", - "CERT_SERIALNUMBER", - "CERT_SERVER_ISSUER", - "CERT_SERVER_SUBJECT", - "CERT_SUBJECT", "CONTENT_LENGTH", "CONTENT_TYPE", - "HTTP_COOKIE", - "HTTPS_KEYSIZE", - "HTTPS_SECRETKEYSIZE", - "HTTPS_SERVER_ISSUER", - "HTTPS_SERVER_SUBJECT", - "HTTPS", "PATH_TRANSLATED", "QUERY_STRING", "REMOTE_ADDR", @@ -80,7 +82,6 @@ "REQUEST_METHOD", "SERVER_NAME", "SERVER_PORT", - "SERVER_PORT_SECURE", "SERVER_PROTOCOL", "SERVER_SOFTWARE", #ifndef WITH_ZEUS @@ -89,9 +90,7 @@ "INSTANCE_ID", "INSTANCE_META_PATH", "LOGON_USER", - "PATH_INFO", "REQUEST_URI", - "SCRIPT_NAME", "URL", #else "DOCUMENT_ROOT", @@ -100,11 +99,37 @@ }; +static char *isapi_secure_server_variable_names[] = { + "CERT_COOKIE", + "CERT_FLAGS", + "CERT_ISSUER", + "CERT_KEYSIZE", + "CERT_SECRETKEYSIZE", + "CERT_SERIALNUMBER", + "CERT_SERVER_ISSUER", + "CERT_SERVER_SUBJECT", + "CERT_SUBJECT", + "HTTPS_KEYSIZE", + "HTTPS_SECRETKEYSIZE", + "HTTPS_SERVER_ISSUER", + "HTTPS_SERVER_SUBJECT", + "SERVER_PORT_SECURE", + NULL +}; + + static void php_info_isapi(ZEND_MODULE_INFO_FUNC_ARGS) { - char **p = isapi_server_variables; + char **p; char variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; DWORD variable_len; + char **all_variables[] = { + isapi_server_variable_names, + isapi_special_server_variable_names, + isapi_secure_server_variable_names, + NULL + }; + char ***server_variable_names; LPEXTENSION_CONTROL_BLOCK lpECB; SLS_FETCH(); @@ -112,22 +137,27 @@ php_info_print_table_start(); php_info_print_table_header(2, "Server Variable", "Value"); - while (*p) { - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len) - && variable_buf[0]) { - php_info_print_table_row(2, *p, variable_buf); - } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - char *tmp_variable_buf; - - tmp_variable_buf = (char *) emalloc(variable_len); - if (lpECB->GetServerVariable(lpECB->ConnID, *p, tmp_variable_buf, &variable_len) + server_variable_names = all_variables; + while (*server_variable_names) { + p = *server_variable_names; + while (*p) { + variable_len = ISAPI_SERVER_VAR_BUF_SIZE; + if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len) && variable_buf[0]) { - php_info_print_table_row(2, *p, tmp_variable_buf); + php_info_print_table_row(2, *p, variable_buf); + } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { + char *tmp_variable_buf; + + tmp_variable_buf = (char *) emalloc(variable_len); + if (lpECB->GetServerVariable(lpECB->ConnID, *p, tmp_variable_buf, &variable_len) + && variable_buf[0]) { + php_info_print_table_row(2, *p, tmp_variable_buf); + } + efree(tmp_variable_buf); } - efree(tmp_variable_buf); + p++; } - p++; + server_variable_names++; } php_info_print_table_end(); } @@ -304,38 +334,15 @@ } -static void sapi_isapi_register_server_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC) +#ifdef WITH_ZEUS +static void sapi_isapi_register_zeus_variables(LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array ELS_DC PLS_DC) { char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; - char *variable_buf; DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - char *variable; char *strtok_buf = NULL; - LPEXTENSION_CONTROL_BLOCK lpECB; - char **p = isapi_server_variables; - - lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); - - /* Register the standard ISAPI variables */ - while (*p) { - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if (lpECB->GetServerVariable(lpECB->ConnID, *p, static_variable_buf, &variable_len) - && static_variable_buf[0]) { - php_register_variable(*p, static_variable_buf, track_vars_array ELS_CC PLS_CC); - } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - variable_buf = (char *) emalloc(variable_len); - if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len) - && variable_buf[0]) { - php_register_variable(*p, variable_buf, track_vars_array ELS_CC PLS_CC); - } - efree(variable_buf); - } - p++; - } -#ifdef WITH_ZEUS /* - * Zeus' map module translates the given URL onto the PHP ISAPI libray; + * Zeus' map module translates the given URL onto the PHP ISAPI library; * from an internal point of view, SCRIPT_NAME and URL are correct, * but from the end-users point of view, it is not... We need to * reconstruct the SCRIPT_NAME and URL from PATH_INFO, and then @@ -359,51 +366,98 @@ if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_TRANSLATED", static_variable_buf, &variable_len) && static_variable_buf[0] ) { php_register_variable( "SCRIPT_FILENAME", static_variable_buf, track_vars_array ELS_CC PLS_CC ); } +} #endif - /* PHP_SELF support */ - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; -#ifdef WITH_ZEUS - if (lpECB->GetServerVariable(lpECB->ConnID, "PATH_INFO", static_variable_buf, &variable_len) -#else - if (lpECB->GetServerVariable(lpECB->ConnID, "SCRIPT_NAME", static_variable_buf, &variable_len) -#endif - && static_variable_buf[0]) { - php_register_variable("PHP_SELF", static_variable_buf, track_vars_array ELS_CC PLS_CC); - } - - /* Register the internal bits of ALL_HTTP */ - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; +static void sapi_isapi_register_server_variables2(char **server_variables, LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array, char **recorded_values ELS_DC PLS_DC) +{ + char **p=server_variables; + DWORD variable_len; + char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; + char *variable_buf; - if (lpECB->GetServerVariable(lpECB->ConnID, "ALL_HTTP", static_variable_buf, &variable_len)) { - variable_buf = static_variable_buf; - } else { - if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) { + while (*p) { + variable_len = ISAPI_SERVER_VAR_BUF_SIZE; + if (lpECB->GetServerVariable(lpECB->ConnID, *p, static_variable_buf, &variable_len) + && static_variable_buf[0]) { + php_register_variable(*p, static_variable_buf, track_vars_array ELS_CC PLS_CC); + if (recorded_values) { + recorded_values[p-server_variables] = estrndup(static_variable_buf, variable_len); + } + } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { variable_buf = (char *) emalloc(variable_len); - if (!lpECB->GetServerVariable(lpECB->ConnID, "ALL_HTTP", variable_buf, &variable_len)) { + if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len) + && variable_buf[0]) { + php_register_variable(*p, variable_buf, track_vars_array ELS_CC PLS_CC); + } + if (recorded_values) { + recorded_values[p-server_variables] = variable_buf; + } else { efree(variable_buf); - return; } - } else { - return; } + p++; + } +} + + +static void sapi_isapi_register_server_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC) +{ + DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; + char *variable; + char *strtok_buf = NULL; + LPEXTENSION_CONTROL_BLOCK lpECB; + + lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); + + /* Register the special ISAPI variables */ + memset(isapi_special_server_variables, 0, sizeof(isapi_special_server_variables)); + sapi_isapi_register_server_variables2(isapi_special_server_variable_names, lpECB, track_vars_array, isapi_special_server_variables ELS_CC PLS_CC); + if (SG(request_info).cookie_data) { + php_register_variable("HTTP_COOKIE", SG(request_info).cookie_data, track_vars_array ELS_CC PLS_CC); } - variable = php_strtok_r(variable_buf, "\r\n", &strtok_buf); - while (variable) { - char *colon = strchr(variable, ':'); - - if (colon) { - char *value = colon+1; - - while (*value==' ') { - value++; - } - *colon = 0; - php_register_variable(variable, value, track_vars_array ELS_CC PLS_CC); - *colon = ':'; + + /* Register the standard ISAPI variables */ + sapi_isapi_register_server_variables2(isapi_server_variable_names, lpECB, track_vars_array, NULL ELS_CC PLS_CC); + + if (isapi_special_server_variables[SPECIAL_VAR_HTTPS] + && atoi(isapi_special_server_variables[SPECIAL_VAR_HTTPS])) { + /* Register SSL ISAPI variables */ + sapi_isapi_register_server_variables2(isapi_secure_server_variable_names, lpECB, track_vars_array, NULL ELS_CC PLS_CC); + } + efree(isapi_special_server_variables[SPECIAL_VAR_HTTPS]); + + +#ifdef WITH_ZEUS + sapi_isapi_register_zeus_variables(lpECB, track_vars_array ELS_CC PLS_CC); +#endif + + /* PHP_SELF support */ + if (isapi_special_server_variables[SPECIAL_VAR_PHP_SELF]) { + php_register_variable("PHP_SELF", isapi_special_server_variables[SPECIAL_VAR_PHP_SELF], track_vars_array ELS_CC PLS_CC); + efree(isapi_special_server_variables[SPECIAL_VAR_PHP_SELF]); + } + + if (isapi_special_server_variables[SPECIAL_VAR_ALL_HTTP]) { + /* Register the internal bits of ALL_HTTP */ + variable = php_strtok_r(isapi_special_server_variables[SPECIAL_VAR_ALL_HTTP], "\r\n", &strtok_buf); + while (variable) { + char *colon = strchr(variable, ':'); + + if (colon) { + char *value = colon+1; + + while (*value==' ') { + value++; + } + *colon = 0; + php_register_variable(variable, value, track_vars_array ELS_CC PLS_CC); + *colon = ':'; + } + variable = php_strtok_r(NULL, "\r\n", &strtok_buf); } - variable = php_strtok_r(NULL, "\r\n", &strtok_buf); + efree(isapi_special_server_variables[SPECIAL_VAR_ALL_HTTP]); } #ifdef PHP_WIN32 @@ -421,14 +475,10 @@ } } #endif - - if (variable_buf!=static_variable_buf) { - efree(variable_buf); - } } -static sapi_module_struct sapi_module = { +static sapi_module_struct isapi_sapi_module = { "isapi", /* name */ "ISAPI", /* pretty name */ @@ -466,7 +516,7 @@ { bFilterLoaded = 1; pFilterVersion->dwFilterVersion = HTTP_FILTER_REVISION; - strcpy(pFilterVersion->lpszFilterDesc, sapi_module.pretty_name); + strcpy(pFilterVersion->lpszFilterDesc, isapi_sapi_module.pretty_name); pFilterVersion->dwFlags= (SF_NOTIFY_AUTHENTICATION | SF_NOTIFY_PREPROC_HEADERS); return TRUE; } @@ -537,9 +587,9 @@ { pVer->dwExtensionVersion = HSE_VERSION; #ifdef WITH_ZEUS - strncpy( pVer->lpszExtensionDesc, sapi_module.name, HSE_MAX_EXT_DLL_NAME_LEN); + strncpy( pVer->lpszExtensionDesc, isapi_sapi_module.name, HSE_MAX_EXT_DLL_NAME_LEN); #else - lstrcpyn(pVer->lpszExtensionDesc, sapi_module.name, HSE_MAX_EXT_DLL_NAME_LEN); + lstrcpyn(pVer->lpszExtensionDesc, isapi_sapi_module.name, HSE_MAX_EXT_DLL_NAME_LEN); #endif return TRUE; } @@ -661,9 +711,9 @@ switch (fdwReason) { case DLL_PROCESS_ATTACH: tsrm_startup(1, 1, TSRM_ERROR_LEVEL_CORE, "C:\\TSRM.log"); - sapi_startup(&sapi_module); - if (sapi_module.startup) { - sapi_module.startup(&sapi_module); + sapi_startup(&isapi_sapi_module); + if (isapi_sapi_module.startup) { + isapi_sapi_module.startup(&sapi_module); } break; case DLL_THREAD_ATTACH: @@ -672,8 +722,8 @@ ts_free_thread(); break; case DLL_PROCESS_DETACH: - if (sapi_module.shutdown) { - sapi_module.shutdown(&sapi_module); + if (isapi_sapi_module.shutdown) { + isapi_sapi_module.shutdown(&sapi_module); } tsrm_shutdown(); break; Index: php4/sapi/nsapi/nsapi.c diff -u php4/sapi/nsapi/nsapi.c:1.14 php4/sapi/nsapi/nsapi.c:1.15 --- php4/sapi/nsapi/nsapi.c:1.14 Fri Nov 17 18:44:03 2000 +++ php4/sapi/nsapi/nsapi.c Tue Jan 2 14:49:29 2001 @@ -320,7 +320,7 @@ } } -static sapi_module_struct sapi_module = { +static sapi_module_struct nsapi_sapi_module = { "nsapi", /* name */ "NSAPI", /* pretty name */ @@ -531,8 +531,8 @@ void NSAPI_PUBLIC php4_close(void *vparam) { - if (sapi_module.shutdown) { - sapi_module.shutdown(&sapi_module); + if (nsapi_sapi_module.shutdown) { + nsapi_sapi_module.shutdown(&nsapi_sapi_module); } tsrm_shutdown(); } @@ -545,8 +545,8 @@ tsrm_startup(1, 1, 0, NULL); core_globals = ts_resource(core_globals_id); - sapi_startup(&sapi_module); - sapi_module.startup(&sapi_module); + sapi_startup(&nsapi_sapi_module); + nsapi_sapi_module.startup(&nsapi_sapi_module); log_error(LOG_INFORM, "php4_init", sn, rq, "Initialized PHP Module\n"); return REQ_PROCEED; Index: php4/sapi/phttpd/phttpd.c diff -u php4/sapi/phttpd/phttpd.c:1.23 php4/sapi/phttpd/phttpd.c:1.24 --- php4/sapi/phttpd/phttpd.c:1.23 Sat Dec 16 12:52:43 2000 +++ php4/sapi/phttpd/phttpd.c Tue Jan 2 14:49:30 2001 @@ -163,7 +163,7 @@ return 0; } -static sapi_module_struct sapi_module = { +static sapi_module_struct phttpd_sapi_module = { "phttpd", "PHTTPD", @@ -284,8 +284,8 @@ int pm_init(const char **argv) { tsrm_startup(1, 1, 0, NULL); - sapi_startup(&sapi_module); - sapi_module.startup(&sapi_module); + sapi_startup(&phttpd_sapi_module); + phttpd_sapi_module.startup(&phttpd_sapi_module); ph_globals_id = ts_allocate_id(sizeof(phttpd_globals_struct), NULL, NULL); Index: php4/sapi/pi3web/pi3web_sapi.c diff -u php4/sapi/pi3web/pi3web_sapi.c:1.13 php4/sapi/pi3web/pi3web_sapi.c:1.14 --- php4/sapi/pi3web/pi3web_sapi.c:1.13 Thu Dec 28 00:31:42 2000 +++ php4/sapi/pi3web/pi3web_sapi.c Tue Jan 2 14:49:30 2001 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pi3web_sapi.c,v 1.13 2000/12/28 08:31:42 holger Exp $ */ +/* $Id: pi3web_sapi.c,v 1.14 2001/01/02 22:49:30 zeev Exp $ */ #if WIN32|WINNT # include <windows.h> @@ -80,7 +80,7 @@ PUTS("<table border=0 cellpadding=3 cellspacing=1 width=600 align=center>\n"); PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">Pi3Web Server Information</th></tr>\n"); php_info_print_table_header(2, "Information Field", "Value"); - php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.13 2000/12/28 08:31:42 holger Exp $"); + php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.14 2001/01/02 22:49:30 zeev Exp $"); php_info_print_table_row(2, "Server Name Stamp", HTTPCore_getServerStamp()); snprintf(variable_buf, 511, "%d", HTTPCore_debugEnabled()); php_info_print_table_row(2, "Debug Enabled", variable_buf); @@ -280,7 +280,7 @@ } -static sapi_module_struct sapi_module = { +static sapi_module_struct pi3web_sapi_module = { "pi3web", /* name */ "PI3WEB", /* pretty name */ @@ -428,17 +428,17 @@ BOOL PHP4_startup() { tsrm_startup(1, 1, 0, NULL); - sapi_startup(&sapi_module); - if (sapi_module.startup) { - sapi_module.startup(&sapi_module); + sapi_startup(&pi3web_sapi_module); + if (pi3web_sapi_module.startup) { + pi3web_sapi_module.startup(&pi3web_sapi_module); }; IWasLoaded = 1; return IWasLoaded; }; BOOL PHP4_shutdown() { - if (sapi_module.shutdown) { - sapi_module.shutdown(&sapi_module); + if (pi3web_sapi_module.shutdown) { + pi3web_sapi_module.shutdown(&pi3web_sapi_module); }; sapi_shutdown(); tsrm_shutdown(); Index: php4/sapi/roxen/roxen.c diff -u php4/sapi/roxen/roxen.c:1.39 php4/sapi/roxen/roxen.c:1.40 --- php4/sapi/roxen/roxen.c:1.39 Fri Nov 17 18:44:04 2000 +++ php4/sapi/roxen/roxen.c Tue Jan 2 14:49:30 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: roxen.c,v 1.39 2000/11/18 02:44:04 zeev Exp $ */ +/* $Id: roxen.c,v 1.40 2001/01/02 22:49:30 zeev Exp $ */ #include "php.h" #ifdef HAVE_ROXEN @@ -446,7 +446,7 @@ { /* char buf[512]; */ php_info_print_table_start(); - php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.39 2000/11/18 02:44:04 zeev Exp $"); + php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.40 2001/01/02 22:49:30 zeev Exp $"); /* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); @@ -489,7 +489,7 @@ /* this structure is static (as in "it does not change") */ -static sapi_module_struct sapi_module = { +static sapi_module_struct roxen_sapi_module = { "roxen", "Roxen", php_module_startup, /* startup */ @@ -708,8 +708,8 @@ roxen_globals_id = ts_allocate_id(sizeof(php_roxen_request), NULL, NULL); #endif #endif - sapi_startup(&sapi_module); - php_roxen_startup(&sapi_module); + sapi_startup(&roxen_sapi_module); + php_roxen_startup(&roxen_sapi_module); roxen_php_initialized = 1; PHP_INIT_LOCK(); } @@ -729,7 +729,7 @@ void pike_module_exit(void) { roxen_php_initialized = 0; - sapi_module.shutdown(&sapi_module); + roxen_sapi_module.shutdown(&roxen_sapi_module); if(php_program) free_program(php_program); #ifdef ZTS tsrm_shutdown(); Index: php4/sapi/servlet/servlet.c diff -u php4/sapi/servlet/servlet.c:1.42 php4/sapi/servlet/servlet.c:1.43 --- php4/sapi/servlet/servlet.c:1.42 Sat Dec 16 12:52:43 2000 +++ php4/sapi/servlet/servlet.c Tue Jan 2 14:49:31 2001 @@ -65,8 +65,6 @@ #include "zend_highlight.h" #include "zend_indent.h" -PHPAPI extern char *php_ini_path; - JNIEXPORT void JNICALL Java_net_php_reflect_setEnv (JNIEnv *newJenv, jclass self); @@ -216,7 +214,7 @@ * sapi maintenance */ -static sapi_module_struct sapi_module = { +static sapi_module_struct servlet_sapi_module = { "java_servlet", /* name */ "Java Servlet", /* pretty name */ @@ -263,9 +261,9 @@ } #endif - sapi_startup(&sapi_module); + sapi_startup(&servlet_sapi_module); - if (php_module_startup(&sapi_module)==FAILURE) { + if (php_module_startup(&servlet_sapi_module)==FAILURE) { ThrowServletException(jenv,"module startup failure"); return; } Index: php4/sapi/thttpd/thttpd.c diff -u php4/sapi/thttpd/thttpd.c:1.29 php4/sapi/thttpd/thttpd.c:1.30 --- php4/sapi/thttpd/thttpd.c:1.29 Mon Nov 13 05:23:56 2000 +++ php4/sapi/thttpd/thttpd.c Tue Jan 2 14:49:31 2001 @@ -164,7 +164,7 @@ php_register_variable("AUTH_TYPE", "Basic", track_vars_array ELS_CC PLS_C); } -static sapi_module_struct sapi_module = { +static sapi_module_struct thttpd_sapi_module = { "thttpd", "thttpd", @@ -306,15 +306,15 @@ void thttpd_php_init(void) { - sapi_startup(&sapi_module); - sapi_module.startup(&sapi_module); + sapi_startup(&thttpd_sapi_module); + thttpd_sapi_module.startup(&thttpd_sapi_module); SG(server_context) = (void *) 1; } void thttpd_php_shutdown(void) { if (SG(server_context) != NULL) { - sapi_module.shutdown(&sapi_module); + thttpd_sapi_module.shutdown(&thttpd_sapi_module); sapi_shutdown(); } }
Index: php4/NEWS diff -u php4/NEWS:1.548 php4/NEWS:1.549 --- php4/NEWS:1.548 Thu Dec 21 18:09:09 2000 +++ php4/NEWS Tue Jan 2 14:49:26 2001 @@ -2,6 +2,9 @@ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 200?, Version 4.0.5 +- Made the php.ini path reported in phpinfo() always point to the absolute + path that was opened (Zeev) +- Made the INI mechanism thread safe (Zeev, Zend engine) - Changed setlocale() to use LC_* constants. (Jani) - ctype functions now follow the extension naming conventions (Hartmut) - Added iconv() function (using libc or libiconv) (Stig) Index: php4/ext/standard/info.c diff -u php4/ext/standard/info.c:1.127 php4/ext/standard/info.c:1.128 --- php4/ext/standard/info.c:1.127 Wed Dec 27 07:43:05 2000 +++ php4/ext/standard/info.c Tue Jan 2 14:49:26 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: info.c,v 1.127 2000/12/27 15:43:05 zeev Exp $ */ +/* $Id: info.c,v 1.128 2001/01/02 22:49:26 zeev Exp $ */ #include "php.h" #include "php_ini.h" @@ -39,7 +39,7 @@ #define SECTION(name) PUTS("<H2 align=\"center\">" name "</H2>\n") -PHPAPI extern char *php_ini_path; +PHPAPI extern char *php_ini_opened_path; static int _display_module_info(zend_module_entry *module, void *arg) { @@ -197,7 +197,7 @@ php_info_print_table_row(2, "Virtual Directory Support", "disabled" ); #endif - php_info_print_table_row(2, "Configuration File (php.ini) Path", php_ini_path?php_ini_path:CONFIGURATION_FILE_PATH ); + php_info_print_table_row(2, "Configuration File (php.ini) Path", php_ini_opened_path?php_ini_opened_path:CONFIGURATION_FILE_PATH); #if ZEND_DEBUG php_info_print_table_row(2, "ZEND_DEBUG", "enabled" ); Index: php4/main/SAPI.c diff -u php4/main/SAPI.c:1.98 php4/main/SAPI.c:1.99 --- php4/main/SAPI.c:1.98 Tue Nov 28 17:22:49 2000 +++ php4/main/SAPI.c Tue Jan 2 14:49:26 2001 @@ -54,7 +54,7 @@ } /* True globals (no need for thread safety) */ -sapi_module_struct sapi_module; +SAPI_API sapi_module_struct sapi_module; SAPI_API void (*sapi_error)(int error_type, const char *message, ...); Index: php4/main/SAPI.h diff -u php4/main/SAPI.h:1.64 php4/main/SAPI.h:1.65 --- php4/main/SAPI.h:1.64 Mon Nov 27 22:54:16 2000 +++ php4/main/SAPI.h Tue Jan 2 14:49:26 2001 @@ -57,7 +57,7 @@ typedef struct _sapi_module_struct sapi_module_struct; -extern sapi_module_struct sapi_module; /* true global */ +extern SAPI_API sapi_module_struct sapi_module; /* true global */ /* Some values in this structure needs to be filled in before * calling sapi_activate(). We WILL change the `char *' entries, @@ -188,6 +188,8 @@ void (*register_server_variables)(zval *track_vars_array ELS_DC SLS_DC PLS_DC); void (*log_message)(char *message); + char *php_ini_path_override; + void (*block_interruptions)(void); void (*unblock_interruptions)(void); @@ -222,7 +224,7 @@ SAPI_POST_READER_FUNC(sapi_read_standard_form_data); SAPI_POST_READER_FUNC(php_default_post_reader); -#define STANDARD_SAPI_MODULE_PROPERTIES NULL +#define STANDARD_SAPI_MODULE_PROPERTIES NULL, NULL #endif /* SAPI_H */ Index: php4/main/main.c diff -u php4/main/main.c:1.344 php4/main/main.c:1.345 --- php4/main/main.c:1.344 Wed Dec 27 07:43:05 2000 +++ php4/main/main.c Tue Jan 2 14:49:26 2001 @@ -19,7 +19,7 @@ */ -/* $Id: main.c,v 1.344 2000/12/27 15:43:05 zeev Exp $ */ +/* $Id: main.c,v 1.345 2001/01/02 22:49:26 zeev Exp $ */ #include <stdio.h> @@ -106,9 +106,7 @@ /* True globals (no need for thread safety) */ HashTable configuration_hash; -PHPAPI char *php_ini_path = NULL; - #define SAFE_FILENAME(f) ((f)?(f):"-") static PHP_INI_MH(OnSetPrecision) @@ -700,15 +698,6 @@ } } - -static int php_config_ini_startup(void) -{ - if (php_init_config() == FAILURE) { - php_printf("PHP: Unable to parse configuration file.\n"); - return FAILURE; - } - return SUCCESS; -} static void php_config_ini_shutdown(void) { @@ -860,7 +849,7 @@ le_index_ptr = zend_register_list_destructors_ex(NULL, NULL, "index pointer", 0); FREE_MUTEX(gLock); - if (php_config_ini_startup() == FAILURE) { + if (php_init_config(sf->php_ini_path_override) == FAILURE) { return FAILURE; } Index: php4/main/php_ini.c diff -u php4/main/php_ini.c:1.45 php4/main/php_ini.c:1.46 --- php4/main/php_ini.c:1.45 Wed Dec 27 07:43:05 2000 +++ php4/main/php_ini.c Tue Jan 2 14:49:26 2001 @@ -24,8 +24,9 @@ #include "ext/standard/dl.h" #include "zend_extensions.h" +/* True globals */ static HashTable configuration_hash; -PHPAPI extern char *php_ini_path; +PHPAPI char *php_ini_opened_path=NULL; static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type) @@ -145,97 +146,80 @@ } -int php_init_config(void) +int php_init_config(char *php_ini_path_override) { + char *env_location, *php_ini_search_path; + int safe_mode_state; + char *open_basedir; + int free_ini_search_path=0; + zend_file_handle fh; PLS_FETCH(); if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) pvalue_config_destructor, 1)==FAILURE) { return FAILURE; } -#if USE_CONFIG_FILE - { - char *env_location,*default_location,*php_ini_search_path; - int safe_mode_state = PG(safe_mode); - char *open_basedir = PG(open_basedir); - char *opened_path; - int free_default_location=0; - zend_file_handle fh; - - env_location = getenv("PHPRC"); - if (!env_location) { - env_location=""; - } -#ifdef PHP_WIN32 - { - if (php_ini_path) { - default_location = php_ini_path; - } else { - default_location = (char *) malloc(512); - - if (!GetWindowsDirectory(default_location,255)) { - default_location[0]=0; - } - free_default_location=1; - } - } -#else - if (!php_ini_path) { - default_location = CONFIGURATION_FILE_PATH; - } else { - default_location = php_ini_path; - } -#endif + safe_mode_state = PG(safe_mode); + open_basedir = PG(open_basedir); -/* build a path */ - php_ini_search_path = (char *) malloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1); + env_location = getenv("PHPRC"); + if (!env_location) { + env_location=""; + } + if (php_ini_path_override) { + php_ini_search_path = php_ini_path_override; + free_ini_search_path = 0; + } else { + char *default_location; + int free_default_location; - if (!php_ini_path) { #ifdef PHP_WIN32 - sprintf(php_ini_search_path,".;%s;%s",env_location,default_location); + default_location = (char *) emalloc(512); + + if (!GetWindowsDirectory(default_location,255)) { + default_location[0]=0; + } + free_default_location=1; #else - sprintf(php_ini_search_path,".:%s:%s",env_location,default_location); + default_location = CONFIGURATION_FILE_PATH; + free_default_location=0; #endif - } else { - /* if path was set via -c flag, only look there */ - strcpy(php_ini_search_path,default_location); - } - PG(safe_mode) = 0; - PG(open_basedir) = NULL; - - - fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &opened_path); - free(php_ini_search_path); + php_ini_search_path = (char *) emalloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1); + free_ini_search_path = 1; + sprintf(php_ini_search_path, ".%c%s%c%s", ZEND_PATHS_SEPARATOR, env_location, ZEND_PATHS_SEPARATOR, default_location); if (free_default_location) { - free(default_location); + efree(default_location); } - PG(safe_mode) = safe_mode_state; - PG(open_basedir) = open_basedir; + } - if (!fh.handle.fp) { - return SUCCESS; /* having no configuration file is ok */ - } - fh.type = ZEND_HANDLE_FP; - fh.filename = opened_path; + PG(safe_mode) = 0; + PG(open_basedir) = NULL; + + fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path); + if (free_ini_search_path) { + efree(php_ini_search_path); + } + PG(safe_mode) = safe_mode_state; + PG(open_basedir) = open_basedir; - zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, NULL); + if (!fh.handle.fp) { + return SUCCESS; /* having no configuration file is ok */ + } + fh.type = ZEND_HANDLE_FP; + fh.filename = php_ini_opened_path; - if (opened_path) { - zval tmp; - - tmp.value.str.val = strdup(opened_path); - tmp.value.str.len = strlen(opened_path); - tmp.type = IS_STRING; - zend_hash_update(&configuration_hash,"cfg_file_path",sizeof("cfg_file_path"),(void *) &tmp,sizeof(zval),NULL); -#if DEBUG_CFG_PARSER - php_printf("INI file opened at '%s'\n",opened_path); -#endif - efree(opened_path); - } + zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, NULL); + + if (php_ini_opened_path) { + zval tmp; + + tmp.value.str.len = strlen(php_ini_opened_path); + tmp.value.str.val = zend_strndup(php_ini_opened_path, tmp.value.str.len); + tmp.type = IS_STRING; + zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"),(void *) &tmp,sizeof(zval), NULL); + persist_alloc(php_ini_opened_path); } -#endif - return SUCCESS; } @@ -243,6 +227,9 @@ int php_shutdown_config(void) { zend_hash_destroy(&configuration_hash); + if (php_ini_opened_path) { + efree(php_ini_opened_path); + } return SUCCESS; } Index: php4/main/php_ini.h diff -u php4/main/php_ini.h:1.29 php4/main/php_ini.h:1.30 --- php4/main/php_ini.h:1.29 Mon Oct 30 15:39:14 2000 +++ php4/main/php_ini.h Tue Jan 2 14:49:27 2001 @@ -21,7 +21,7 @@ #include "zend_ini.h" -int php_init_config(void); +int php_init_config(char *php_ini_path_override); int php_shutdown_config(void); #define PHP_INI_USER ZEND_INI_USER Index: php4/sapi/aolserver/aolserver.c diff -u php4/sapi/aolserver/aolserver.c:1.53 php4/sapi/aolserver/aolserver.c:1.54 --- php4/sapi/aolserver/aolserver.c:1.53 Fri Nov 17 18:44:01 2000 +++ php4/sapi/aolserver/aolserver.c Tue Jan 2 14:49:27 2001 @@ -22,7 +22,7 @@ * - CGI/1.1 conformance */ -/* $Id: aolserver.c,v 1.53 2000/11/18 02:44:01 zeev Exp $ */ +/* $Id: aolserver.c,v 1.54 2001/01/02 22:49:27 zeev Exp $ */ /* conflict between PHP and AOLserver headers */ #define Debug php_Debug @@ -211,7 +211,7 @@ NSLS_FETCH(); php_info_print_table_start(); - php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.53 2000/11/18 02:44:01 zeev Exp $"); + php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c,v 1.54 2001/01/02 22:49:27 zeev Exp $"); php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); @@ -368,7 +368,7 @@ /* this structure is static (as in "it does not change") */ -static sapi_module_struct sapi_module = { +static sapi_module_struct aolserver_sapi_module = { "aolserver", "AOLserver", @@ -606,15 +606,15 @@ php_ns_context *ctx; tsrm_startup(1, 1, 0, NULL); - sapi_startup(&sapi_module); - sapi_module.startup(&sapi_module); + sapi_startup(&aolserver_sapi_module); + sapi_module.startup(&aolserver_sapi_module); /* TSRM is used to allocate a per-thread structure */ ns_globals_id = ts_allocate_id(sizeof(ns_globals_struct), NULL, NULL); /* the context contains data valid for all threads */ ctx = malloc(sizeof *ctx); - ctx->sapi_module = &sapi_module; + ctx->sapi_module = &aolserver_sapi_module; ctx->ns_server = strdup(server); ctx->ns_module = strdup(module); Index: php4/sapi/apache/mod_php4.c diff -u php4/sapi/apache/mod_php4.c:1.80 php4/sapi/apache/mod_php4.c:1.81 --- php4/sapi/apache/mod_php4.c:1.80 Fri Dec 29 16:38:47 2000 +++ php4/sapi/apache/mod_php4.c Tue Jan 2 14:49:27 2001 @@ -17,7 +17,7 @@ | PHP 4.0 patches by Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: mod_php4.c,v 1.80 2000/12/30 00:38:47 zeev Exp $ */ +/* $Id: mod_php4.c,v 1.81 2001/01/02 22:49:27 zeev Exp $ */ #define NO_REGEX_EXTRA_H #ifdef WIN32 @@ -249,7 +249,7 @@ static int php_apache_startup(sapi_module_struct *sapi_module) { - if(php_module_startup(sapi_module) == FAILURE + if(php_module_startup(sapi_module, NULL) == FAILURE || zend_startup_module(&apache_module_entry) == FAILURE) { return FAILURE; } else { @@ -320,7 +320,7 @@ } -static sapi_module_struct sapi_module_conf = { +static sapi_module_struct apache_sapi_module = { "apache", /* name */ "Apache", /* pretty name */ @@ -590,8 +590,8 @@ #ifdef ZTS tsrm_startup(1, 1, 0, NULL); #endif - sapi_startup(&sapi_module_conf); - php_apache_startup(&sapi_module_conf); + sapi_startup(&apache_sapi_module); + php_apache_startup(&apache_sapi_module); } per_dir_entry.type = mode; @@ -675,7 +675,7 @@ static void apache_php_module_shutdown_wrapper(void) { apache_php_initialized = 0; - sapi_module_conf.shutdown(&sapi_module_conf); + apache_sapi_module.shutdown(&apache_sapi_module); #if MODULE_MAGIC_NUMBER >= 19970728 /* This function is only called on server exit if the apache API @@ -693,7 +693,7 @@ static void php_child_exit_handler(server_rec *s, pool *p) { /* apache_php_initialized = 0; */ - sapi_module_conf.shutdown(&sapi_module_conf); + apache_sapi_module.shutdown(&apache_sapi_module); #ifdef ZTS tsrm_shutdown(); @@ -709,8 +709,8 @@ #ifdef ZTS tsrm_startup(1, 1, 0, NULL); #endif - sapi_startup(&sapi_module_conf); - php_apache_startup(&sapi_module_conf); + sapi_startup(&apache_sapi_module); + php_apache_startup(&apache_sapi_module); } #if MODULE_MAGIC_NUMBER >= 19980527 { Index: php4/sapi/apache2filter/sapi_apache2.c diff -u php4/sapi/apache2filter/sapi_apache2.c:1.22 php4/sapi/apache2filter/sapi_apache2.c:1.23 --- php4/sapi/apache2filter/sapi_apache2.c:1.22 Fri Nov 17 18:44:02 2000 +++ php4/sapi/apache2filter/sapi_apache2.c Tue Jan 2 14:49:28 2001 @@ -187,7 +187,7 @@ apr_puts(msg, ctx->f->r->server->error_log); } -static sapi_module_struct sapi_module = { +static sapi_module_struct apache2_sapi_module = { "apache2filter", "Apache 2.0 Filter", @@ -420,7 +420,7 @@ static apr_status_t php_apache_server_shutdown(void *tmp) { - sapi_module.shutdown(&sapi_module); + apache2_sapi_module.shutdown(&apache2_sapi_module); sapi_shutdown(); tsrm_shutdown(); return APR_SUCCESS; @@ -430,8 +430,8 @@ php_apache_server_startup(apr_pool_t *pchild, server_rec *s) { tsrm_startup(1, 1, 0, NULL); - sapi_startup(&sapi_module); - sapi_module.startup(&sapi_module); + sapi_startup(&apache1_sapi_module); + apache2_sapi_module.startup(&apache2_sapi_module); apr_register_cleanup(pchild, NULL, php_apache_server_shutdown, NULL); php_apache_register_module(); } Index: php4/sapi/caudium/caudium.c diff -u php4/sapi/caudium/caudium.c:1.7 php4/sapi/caudium/caudium.c:1.8 --- php4/sapi/caudium/caudium.c:1.7 Thu Dec 7 11:01:13 2000 +++ php4/sapi/caudium/caudium.c Tue Jan 2 14:49:28 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: caudium.c,v 1.7 2000/12/07 19:01:13 neotron Exp $ */ +/* $Id: caudium.c,v 1.8 2001/01/02 22:49:28 zeev Exp $ */ #include "php.h" #ifdef HAVE_CAUDIUM @@ -458,7 +458,7 @@ { /* char buf[512]; */ php_info_print_table_start(); - php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c,v 1.7 2000/12/07 19:01:13 neotron Exp $"); + php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c,v 1.8 2001/01/02 22:49:28 zeev Exp $"); /* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); @@ -491,7 +491,7 @@ /* this structure is static (as in "it does not change") */ -static sapi_module_struct sapi_module = { +static sapi_module_struct caudium_sapi_module = { "caudium", "Caudium", php_module_startup, /* startup */ @@ -781,8 +781,8 @@ caudium_php_initialized = 1; tsrm_startup(1, 1, 0, NULL); caudium_globals_id = ts_allocate_id(sizeof(php_caudium_request), NULL, NULL); - sapi_startup(&sapi_module); - sapi_module.startup(&sapi_module); + sapi_startup(&caudium_sapi_module); + sapi_module.startup(&caudium_sapi_module); zend_startup_module(&php_caudium_module); PHP_INIT_LOCK(); } @@ -800,7 +800,7 @@ void pike_module_exit(void) { caudium_php_initialized = 0; - sapi_module.shutdown(&sapi_module); + sapi_module.shutdown(&caudium_sapi_module); if(php_program) free_program(php_program); tsrm_shutdown(); PHP_DESTROY(); Index: php4/sapi/cgi/cgi_main.c diff -u php4/sapi/cgi/cgi_main.c:1.89 php4/sapi/cgi/cgi_main.c:1.90 --- php4/sapi/cgi/cgi_main.c:1.89 Sun Dec 3 00:37:43 2000 +++ php4/sapi/cgi/cgi_main.c Tue Jan 2 14:49:28 2001 @@ -75,8 +75,6 @@ #include "php_getopt.h" -PHPAPI extern char *php_ini_path; - #define PHP_MODE_STANDARD 1 #define PHP_MODE_HIGHLIGHT 2 #define PHP_MODE_INDENT 3 @@ -201,7 +199,7 @@ -static sapi_module_struct sapi_module = { +static sapi_module_struct cgi_sapi_module = { "cgi", /* name */ "CGI", /* pretty name */ @@ -412,7 +410,7 @@ tsrm_startup(1,1,0, NULL); #endif - sapi_startup(&sapi_module); + sapi_startup(&cgi_sapi_module); #ifdef PHP_WIN32 _fmode = _O_BINARY; /*sets default for file streams to binary */ @@ -468,7 +466,7 @@ while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) { switch (c) { case 'c': - php_ini_path = strdup(ap_php_optarg); /* intentional leak */ + cgi_sapi_module.php_ini_path_override = strdup(ap_php_optarg); break; } @@ -477,7 +475,7 @@ ap_php_optarg = orig_optarg; } - if (php_module_startup(&sapi_module)==FAILURE) { + if (php_module_startup(&cgi_sapi_module)==FAILURE) { return FAILURE; } #ifdef ZTS @@ -773,6 +771,9 @@ STR_FREE(SG(request_info).path_translated); + if (cgi_sapi_module.php_ini_path_override) { + free(cgi_sapi_module.php_ini_path_override); + } #ifdef ZTS tsrm_shutdown(); #endif Index: php4/sapi/isapi/php4isapi.c diff -u php4/sapi/isapi/php4isapi.c:1.62 php4/sapi/isapi/php4isapi.c:1.63 --- php4/sapi/isapi/php4isapi.c:1.62 Fri Dec 15 08:18:55 2000 +++ php4/sapi/isapi/php4isapi.c Tue Jan 2 14:49:29 2001 @@ -50,28 +50,30 @@ static zend_bool bFilterLoaded=0; static zend_bool bTerminateThreadsOnError=0; -static char *isapi_server_variables[] = { +static char *isapi_special_server_variable_names[] = { "ALL_HTTP", + "HTTPS", +#ifndef WITH_ZEUS + "SCRIPT_NAME", +#else + "PATH_INFO", +#endif + NULL +}; + +#define NUM_SPECIAL_VARS (sizeof(isapi_special_server_variable_names)/sizeof(char *)) +#define SPECIAL_VAR_ALL_HTTP 0 +#define SPECIAL_VAR_HTTPS 1 +#define SPECIAL_VAR_PHP_SELF 2 + +static char *isapi_special_server_variables[NUM_SPECIAL_VARS]; + +static char *isapi_server_variable_names[] = { "AUTH_PASSWORD", "AUTH_TYPE", "AUTH_USER", - "CERT_COOKIE", - "CERT_FLAGS", - "CERT_ISSUER", - "CERT_KEYSIZE", - "CERT_SECRETKEYSIZE", - "CERT_SERIALNUMBER", - "CERT_SERVER_ISSUER", - "CERT_SERVER_SUBJECT", - "CERT_SUBJECT", "CONTENT_LENGTH", "CONTENT_TYPE", - "HTTP_COOKIE", - "HTTPS_KEYSIZE", - "HTTPS_SECRETKEYSIZE", - "HTTPS_SERVER_ISSUER", - "HTTPS_SERVER_SUBJECT", - "HTTPS", "PATH_TRANSLATED", "QUERY_STRING", "REMOTE_ADDR", @@ -80,7 +82,6 @@ "REQUEST_METHOD", "SERVER_NAME", "SERVER_PORT", - "SERVER_PORT_SECURE", "SERVER_PROTOCOL", "SERVER_SOFTWARE", #ifndef WITH_ZEUS @@ -89,9 +90,7 @@ "INSTANCE_ID", "INSTANCE_META_PATH", "LOGON_USER", - "PATH_INFO", "REQUEST_URI", - "SCRIPT_NAME", "URL", #else "DOCUMENT_ROOT", @@ -100,11 +99,37 @@ }; +static char *isapi_secure_server_variable_names[] = { + "CERT_COOKIE", + "CERT_FLAGS", + "CERT_ISSUER", + "CERT_KEYSIZE", + "CERT_SECRETKEYSIZE", + "CERT_SERIALNUMBER", + "CERT_SERVER_ISSUER", + "CERT_SERVER_SUBJECT", + "CERT_SUBJECT", + "HTTPS_KEYSIZE", + "HTTPS_SECRETKEYSIZE", + "HTTPS_SERVER_ISSUER", + "HTTPS_SERVER_SUBJECT", + "SERVER_PORT_SECURE", + NULL +}; + + static void php_info_isapi(ZEND_MODULE_INFO_FUNC_ARGS) { - char **p = isapi_server_variables; + char **p; char variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; DWORD variable_len; + char **all_variables[] = { + isapi_server_variable_names, + isapi_special_server_variable_names, + isapi_secure_server_variable_names, + NULL + }; + char ***server_variable_names; LPEXTENSION_CONTROL_BLOCK lpECB; SLS_FETCH(); @@ -112,22 +137,27 @@ php_info_print_table_start(); php_info_print_table_header(2, "Server Variable", "Value"); - while (*p) { - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len) - && variable_buf[0]) { - php_info_print_table_row(2, *p, variable_buf); - } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - char *tmp_variable_buf; - - tmp_variable_buf = (char *) emalloc(variable_len); - if (lpECB->GetServerVariable(lpECB->ConnID, *p, tmp_variable_buf, &variable_len) + server_variable_names = all_variables; + while (*server_variable_names) { + p = *server_variable_names; + while (*p) { + variable_len = ISAPI_SERVER_VAR_BUF_SIZE; + if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len) && variable_buf[0]) { - php_info_print_table_row(2, *p, tmp_variable_buf); + php_info_print_table_row(2, *p, variable_buf); + } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { + char *tmp_variable_buf; + + tmp_variable_buf = (char *) emalloc(variable_len); + if (lpECB->GetServerVariable(lpECB->ConnID, *p, tmp_variable_buf, &variable_len) + && variable_buf[0]) { + php_info_print_table_row(2, *p, tmp_variable_buf); + } + efree(tmp_variable_buf); } - efree(tmp_variable_buf); + p++; } - p++; + server_variable_names++; } php_info_print_table_end(); } @@ -304,38 +334,15 @@ } -static void sapi_isapi_register_server_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC) +#ifdef WITH_ZEUS +static void sapi_isapi_register_zeus_variables(LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array ELS_DC PLS_DC) { char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; - char *variable_buf; DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - char *variable; char *strtok_buf = NULL; - LPEXTENSION_CONTROL_BLOCK lpECB; - char **p = isapi_server_variables; - - lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); - - /* Register the standard ISAPI variables */ - while (*p) { - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if (lpECB->GetServerVariable(lpECB->ConnID, *p, static_variable_buf, &variable_len) - && static_variable_buf[0]) { - php_register_variable(*p, static_variable_buf, track_vars_array ELS_CC PLS_CC); - } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - variable_buf = (char *) emalloc(variable_len); - if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len) - && variable_buf[0]) { - php_register_variable(*p, variable_buf, track_vars_array ELS_CC PLS_CC); - } - efree(variable_buf); - } - p++; - } -#ifdef WITH_ZEUS /* - * Zeus' map module translates the given URL onto the PHP ISAPI libray; + * Zeus' map module translates the given URL onto the PHP ISAPI library; * from an internal point of view, SCRIPT_NAME and URL are correct, * but from the end-users point of view, it is not... We need to * reconstruct the SCRIPT_NAME and URL from PATH_INFO, and then @@ -359,51 +366,98 @@ if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_TRANSLATED", static_variable_buf, &variable_len) && static_variable_buf[0] ) { php_register_variable( "SCRIPT_FILENAME", static_variable_buf, track_vars_array ELS_CC PLS_CC ); } +} #endif - /* PHP_SELF support */ - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; -#ifdef WITH_ZEUS - if (lpECB->GetServerVariable(lpECB->ConnID, "PATH_INFO", static_variable_buf, &variable_len) -#else - if (lpECB->GetServerVariable(lpECB->ConnID, "SCRIPT_NAME", static_variable_buf, &variable_len) -#endif - && static_variable_buf[0]) { - php_register_variable("PHP_SELF", static_variable_buf, track_vars_array ELS_CC PLS_CC); - } - - /* Register the internal bits of ALL_HTTP */ - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; +static void sapi_isapi_register_server_variables2(char **server_variables, LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array, char **recorded_values ELS_DC PLS_DC) +{ + char **p=server_variables; + DWORD variable_len; + char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; + char *variable_buf; - if (lpECB->GetServerVariable(lpECB->ConnID, "ALL_HTTP", static_variable_buf, &variable_len)) { - variable_buf = static_variable_buf; - } else { - if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) { + while (*p) { + variable_len = ISAPI_SERVER_VAR_BUF_SIZE; + if (lpECB->GetServerVariable(lpECB->ConnID, *p, static_variable_buf, &variable_len) + && static_variable_buf[0]) { + php_register_variable(*p, static_variable_buf, track_vars_array ELS_CC PLS_CC); + if (recorded_values) { + recorded_values[p-server_variables] = estrndup(static_variable_buf, variable_len); + } + } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { variable_buf = (char *) emalloc(variable_len); - if (!lpECB->GetServerVariable(lpECB->ConnID, "ALL_HTTP", variable_buf, &variable_len)) { + if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len) + && variable_buf[0]) { + php_register_variable(*p, variable_buf, track_vars_array ELS_CC PLS_CC); + } + if (recorded_values) { + recorded_values[p-server_variables] = variable_buf; + } else { efree(variable_buf); - return; } - } else { - return; } + p++; + } +} + + +static void sapi_isapi_register_server_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC) +{ + DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; + char *variable; + char *strtok_buf = NULL; + LPEXTENSION_CONTROL_BLOCK lpECB; + + lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); + + /* Register the special ISAPI variables */ + memset(isapi_special_server_variables, 0, sizeof(isapi_special_server_variables)); + sapi_isapi_register_server_variables2(isapi_special_server_variable_names, lpECB, track_vars_array, isapi_special_server_variables ELS_CC PLS_CC); + if (SG(request_info).cookie_data) { + php_register_variable("HTTP_COOKIE", SG(request_info).cookie_data, track_vars_array ELS_CC PLS_CC); } - variable = php_strtok_r(variable_buf, "\r\n", &strtok_buf); - while (variable) { - char *colon = strchr(variable, ':'); - - if (colon) { - char *value = colon+1; - - while (*value==' ') { - value++; - } - *colon = 0; - php_register_variable(variable, value, track_vars_array ELS_CC PLS_CC); - *colon = ':'; + + /* Register the standard ISAPI variables */ + sapi_isapi_register_server_variables2(isapi_server_variable_names, lpECB, track_vars_array, NULL ELS_CC PLS_CC); + + if (isapi_special_server_variables[SPECIAL_VAR_HTTPS] + && atoi(isapi_special_server_variables[SPECIAL_VAR_HTTPS])) { + /* Register SSL ISAPI variables */ + sapi_isapi_register_server_variables2(isapi_secure_server_variable_names, lpECB, track_vars_array, NULL ELS_CC PLS_CC); + } + efree(isapi_special_server_variables[SPECIAL_VAR_HTTPS]); + + +#ifdef WITH_ZEUS + sapi_isapi_register_zeus_variables(lpECB, track_vars_array ELS_CC PLS_CC); +#endif + + /* PHP_SELF support */ + if (isapi_special_server_variables[SPECIAL_VAR_PHP_SELF]) { + php_register_variable("PHP_SELF", isapi_special_server_variables[SPECIAL_VAR_PHP_SELF], track_vars_array ELS_CC PLS_CC); + efree(isapi_special_server_variables[SPECIAL_VAR_PHP_SELF]); + } + + if (isapi_special_server_variables[SPECIAL_VAR_ALL_HTTP]) { + /* Register the internal bits of ALL_HTTP */ + variable = php_strtok_r(isapi_special_server_variables[SPECIAL_VAR_ALL_HTTP], "\r\n", &strtok_buf); + while (variable) { + char *colon = strchr(variable, ':'); + + if (colon) { + char *value = colon+1; + + while (*value==' ') { + value++; + } + *colon = 0; + php_register_variable(variable, value, track_vars_array ELS_CC PLS_CC); + *colon = ':'; + } + variable = php_strtok_r(NULL, "\r\n", &strtok_buf); } - variable = php_strtok_r(NULL, "\r\n", &strtok_buf); + efree(isapi_special_server_variables[SPECIAL_VAR_ALL_HTTP]); } #ifdef PHP_WIN32 @@ -421,14 +475,10 @@ } } #endif - - if (variable_buf!=static_variable_buf) { - efree(variable_buf); - } } -static sapi_module_struct sapi_module = { +static sapi_module_struct isapi_sapi_module = { "isapi", /* name */ "ISAPI", /* pretty name */ @@ -466,7 +516,7 @@ { bFilterLoaded = 1; pFilterVersion->dwFilterVersion = HTTP_FILTER_REVISION; - strcpy(pFilterVersion->lpszFilterDesc, sapi_module.pretty_name); + strcpy(pFilterVersion->lpszFilterDesc, isapi_sapi_module.pretty_name); pFilterVersion->dwFlags= (SF_NOTIFY_AUTHENTICATION | SF_NOTIFY_PREPROC_HEADERS); return TRUE; } @@ -537,9 +587,9 @@ { pVer->dwExtensionVersion = HSE_VERSION; #ifdef WITH_ZEUS - strncpy( pVer->lpszExtensionDesc, sapi_module.name, HSE_MAX_EXT_DLL_NAME_LEN); + strncpy( pVer->lpszExtensionDesc, isapi_sapi_module.name, HSE_MAX_EXT_DLL_NAME_LEN); #else - lstrcpyn(pVer->lpszExtensionDesc, sapi_module.name, HSE_MAX_EXT_DLL_NAME_LEN); + lstrcpyn(pVer->lpszExtensionDesc, isapi_sapi_module.name, HSE_MAX_EXT_DLL_NAME_LEN); #endif return TRUE; } @@ -661,9 +711,9 @@ switch (fdwReason) { case DLL_PROCESS_ATTACH: tsrm_startup(1, 1, TSRM_ERROR_LEVEL_CORE, "C:\\TSRM.log"); - sapi_startup(&sapi_module); - if (sapi_module.startup) { - sapi_module.startup(&sapi_module); + sapi_startup(&isapi_sapi_module); + if (isapi_sapi_module.startup) { + isapi_sapi_module.startup(&sapi_module); } break; case DLL_THREAD_ATTACH: @@ -672,8 +722,8 @@ ts_free_thread(); break; case DLL_PROCESS_DETACH: - if (sapi_module.shutdown) { - sapi_module.shutdown(&sapi_module); + if (isapi_sapi_module.shutdown) { + isapi_sapi_module.shutdown(&sapi_module); } tsrm_shutdown(); break; Index: php4/sapi/nsapi/nsapi.c diff -u php4/sapi/nsapi/nsapi.c:1.14 php4/sapi/nsapi/nsapi.c:1.15 --- php4/sapi/nsapi/nsapi.c:1.14 Fri Nov 17 18:44:03 2000 +++ php4/sapi/nsapi/nsapi.c Tue Jan 2 14:49:29 2001 @@ -320,7 +320,7 @@ } } -static sapi_module_struct sapi_module = { +static sapi_module_struct nsapi_sapi_module = { "nsapi", /* name */ "NSAPI", /* pretty name */ @@ -531,8 +531,8 @@ void NSAPI_PUBLIC php4_close(void *vparam) { - if (sapi_module.shutdown) { - sapi_module.shutdown(&sapi_module); + if (nsapi_sapi_module.shutdown) { + nsapi_sapi_module.shutdown(&nsapi_sapi_module); } tsrm_shutdown(); } @@ -545,8 +545,8 @@ tsrm_startup(1, 1, 0, NULL); core_globals = ts_resource(core_globals_id); - sapi_startup(&sapi_module); - sapi_module.startup(&sapi_module); + sapi_startup(&nsapi_sapi_module); + nsapi_sapi_module.startup(&nsapi_sapi_module); log_error(LOG_INFORM, "php4_init", sn, rq, "Initialized PHP Module\n"); return REQ_PROCEED; Index: php4/sapi/phttpd/phttpd.c diff -u php4/sapi/phttpd/phttpd.c:1.23 php4/sapi/phttpd/phttpd.c:1.24 --- php4/sapi/phttpd/phttpd.c:1.23 Sat Dec 16 12:52:43 2000 +++ php4/sapi/phttpd/phttpd.c Tue Jan 2 14:49:30 2001 @@ -163,7 +163,7 @@ return 0; } -static sapi_module_struct sapi_module = { +static sapi_module_struct phttpd_sapi_module = { "phttpd", "PHTTPD", @@ -284,8 +284,8 @@ int pm_init(const char **argv) { tsrm_startup(1, 1, 0, NULL); - sapi_startup(&sapi_module); - sapi_module.startup(&sapi_module); + sapi_startup(&phttpd_sapi_module); + phttpd_sapi_module.startup(&phttpd_sapi_module); ph_globals_id = ts_allocate_id(sizeof(phttpd_globals_struct), NULL, NULL); Index: php4/sapi/pi3web/pi3web_sapi.c diff -u php4/sapi/pi3web/pi3web_sapi.c:1.13 php4/sapi/pi3web/pi3web_sapi.c:1.14 --- php4/sapi/pi3web/pi3web_sapi.c:1.13 Thu Dec 28 00:31:42 2000 +++ php4/sapi/pi3web/pi3web_sapi.c Tue Jan 2 14:49:30 2001 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pi3web_sapi.c,v 1.13 2000/12/28 08:31:42 holger Exp $ */ +/* $Id: pi3web_sapi.c,v 1.14 2001/01/02 22:49:30 zeev Exp $ */ #if WIN32|WINNT # include <windows.h> @@ -80,7 +80,7 @@ PUTS("<table border=0 cellpadding=3 cellspacing=1 width=600 align=center>\n"); PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">Pi3Web Server Information</th></tr>\n"); php_info_print_table_header(2, "Information Field", "Value"); - php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.13 2000/12/28 08:31:42 holger Exp $"); + php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c,v 1.14 2001/01/02 22:49:30 zeev Exp $"); php_info_print_table_row(2, "Server Name Stamp", HTTPCore_getServerStamp()); snprintf(variable_buf, 511, "%d", HTTPCore_debugEnabled()); php_info_print_table_row(2, "Debug Enabled", variable_buf); @@ -280,7 +280,7 @@ } -static sapi_module_struct sapi_module = { +static sapi_module_struct pi3web_sapi_module = { "pi3web", /* name */ "PI3WEB", /* pretty name */ @@ -428,17 +428,17 @@ BOOL PHP4_startup() { tsrm_startup(1, 1, 0, NULL); - sapi_startup(&sapi_module); - if (sapi_module.startup) { - sapi_module.startup(&sapi_module); + sapi_startup(&pi3web_sapi_module); + if (pi3web_sapi_module.startup) { + pi3web_sapi_module.startup(&pi3web_sapi_module); }; IWasLoaded = 1; return IWasLoaded; }; BOOL PHP4_shutdown() { - if (sapi_module.shutdown) { - sapi_module.shutdown(&sapi_module); + if (pi3web_sapi_module.shutdown) { + pi3web_sapi_module.shutdown(&pi3web_sapi_module); }; sapi_shutdown(); tsrm_shutdown(); Index: php4/sapi/roxen/roxen.c diff -u php4/sapi/roxen/roxen.c:1.39 php4/sapi/roxen/roxen.c:1.40 --- php4/sapi/roxen/roxen.c:1.39 Fri Nov 17 18:44:04 2000 +++ php4/sapi/roxen/roxen.c Tue Jan 2 14:49:30 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: roxen.c,v 1.39 2000/11/18 02:44:04 zeev Exp $ */ +/* $Id: roxen.c,v 1.40 2001/01/02 22:49:30 zeev Exp $ */ #include "php.h" #ifdef HAVE_ROXEN @@ -446,7 +446,7 @@ { /* char buf[512]; */ php_info_print_table_start(); - php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.39 2000/11/18 02:44:04 zeev Exp $"); + php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c,v 1.40 2001/01/02 22:49:30 zeev Exp $"); /* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); @@ -489,7 +489,7 @@ /* this structure is static (as in "it does not change") */ -static sapi_module_struct sapi_module = { +static sapi_module_struct roxen_sapi_module = { "roxen", "Roxen", php_module_startup, /* startup */ @@ -708,8 +708,8 @@ roxen_globals_id = ts_allocate_id(sizeof(php_roxen_request), NULL, NULL); #endif #endif - sapi_startup(&sapi_module); - php_roxen_startup(&sapi_module); + sapi_startup(&roxen_sapi_module); + php_roxen_startup(&roxen_sapi_module); roxen_php_initialized = 1; PHP_INIT_LOCK(); } @@ -729,7 +729,7 @@ void pike_module_exit(void) { roxen_php_initialized = 0; - sapi_module.shutdown(&sapi_module); + roxen_sapi_module.shutdown(&roxen_sapi_module); if(php_program) free_program(php_program); #ifdef ZTS tsrm_shutdown(); Index: php4/sapi/servlet/servlet.c diff -u php4/sapi/servlet/servlet.c:1.42 php4/sapi/servlet/servlet.c:1.43 --- php4/sapi/servlet/servlet.c:1.42 Sat Dec 16 12:52:43 2000 +++ php4/sapi/servlet/servlet.c Tue Jan 2 14:49:31 2001 @@ -65,8 +65,6 @@ #include "zend_highlight.h" #include "zend_indent.h" -PHPAPI extern char *php_ini_path; - JNIEXPORT void JNICALL Java_net_php_reflect_setEnv (JNIEnv *newJenv, jclass self); @@ -216,7 +214,7 @@ * sapi maintenance */ -static sapi_module_struct sapi_module = { +static sapi_module_struct servlet_sapi_module = { "java_servlet", /* name */ "Java Servlet", /* pretty name */ @@ -263,9 +261,9 @@ } #endif - sapi_startup(&sapi_module); + sapi_startup(&servlet_sapi_module); - if (php_module_startup(&sapi_module)==FAILURE) { + if (php_module_startup(&servlet_sapi_module)==FAILURE) { ThrowServletException(jenv,"module startup failure"); return; } Index: php4/sapi/thttpd/thttpd.c diff -u php4/sapi/thttpd/thttpd.c:1.29 php4/sapi/thttpd/thttpd.c:1.30 --- php4/sapi/thttpd/thttpd.c:1.29 Mon Nov 13 05:23:56 2000 +++ php4/sapi/thttpd/thttpd.c Tue Jan 2 14:49:31 2001 @@ -164,7 +164,7 @@ php_register_variable("AUTH_TYPE", "Basic", track_vars_array ELS_CC PLS_C); } -static sapi_module_struct sapi_module = { +static sapi_module_struct thttpd_sapi_module = { "thttpd", "thttpd", @@ -306,15 +306,15 @@ void thttpd_php_init(void) { - sapi_startup(&sapi_module); - sapi_module.startup(&sapi_module); + sapi_startup(&thttpd_sapi_module); + thttpd_sapi_module.startup(&thttpd_sapi_module); SG(server_context) = (void *) 1; } void thttpd_php_shutdown(void) { if (SG(server_context) != NULL) { - sapi_module.shutdown(&sapi_module); + thttpd_sapi_module.shutdown(&thttpd_sapi_module); sapi_shutdown(); } }