diff options
| -rw-r--r-- | NEWS | 3 | ||||
| -rw-r--r-- | ext/standard/info.c | 4 | ||||
| -rw-r--r-- | main/SAPI.c | 2 | ||||
| -rw-r--r-- | main/SAPI.h | 6 | ||||
| -rw-r--r-- | main/main.c | 13 | ||||
| -rw-r--r-- | main/php_ini.c | 137 | ||||
| -rw-r--r-- | main/php_ini.h | 2 | ||||
| -rw-r--r-- | sapi/aolserver/aolserver.c | 8 | ||||
| -rw-r--r-- | sapi/apache/mod_php4.c | 16 | ||||
| -rw-r--r-- | sapi/apache2filter/sapi_apache2.c | 8 | ||||
| -rw-r--r-- | sapi/caudium/caudium.c | 8 | ||||
| -rw-r--r-- | sapi/cgi/cgi_main.c | 13 | ||||
| -rw-r--r-- | sapi/isapi/php4isapi.c | 258 | ||||
| -rw-r--r-- | sapi/nsapi/nsapi.c | 10 | ||||
| -rw-r--r-- | sapi/phttpd/phttpd.c | 6 | ||||
| -rw-r--r-- | sapi/pi3web/pi3web_sapi.c | 12 | ||||
| -rw-r--r-- | sapi/roxen/roxen.c | 8 | ||||
| -rw-r--r-- | sapi/servlet/servlet.c | 8 | ||||
| -rw-r--r-- | sapi/thttpd/thttpd.c | 8 | 
19 files changed, 280 insertions, 250 deletions
| @@ -2,6 +2,9 @@ PHP 4.0                                                                    NEWS  |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||  ?? ??? 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) diff --git a/ext/standard/info.c b/ext/standard/info.c index c600cef189..5bcfaf6f1d 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -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 @@ PHPAPI void php_print_info(int flag)  		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" ); diff --git a/main/SAPI.c b/main/SAPI.c index eba50440dd..fb7b073d93 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -54,7 +54,7 @@ static void sapi_globals_ctor(sapi_globals_struct *sapi_globals)  }  /* 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, ...); diff --git a/main/SAPI.h b/main/SAPI.h index 9d7c70ac79..4e9ada0278 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -57,7 +57,7 @@ typedef struct _sapi_post_entry sapi_post_entry;  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 @@ struct _sapi_module_struct {  	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 @@ struct _sapi_post_entry {  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 */ diff --git a/main/main.c b/main/main.c index 8eacdaa7fa..aa6423b122 100644 --- a/main/main.c +++ b/main/main.c @@ -106,8 +106,6 @@ void *gLock;					/*mutex variable */  /* True globals (no need for thread safety) */  HashTable configuration_hash; -PHPAPI char *php_ini_path = NULL; -  #define SAFE_FILENAME(f) ((f)?(f):"-") @@ -700,15 +698,6 @@ void php_request_shutdown(void *dummy)  	}  } - -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 @@ int php_module_startup(sapi_module_struct *sf)  	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;  	} diff --git a/main/php_ini.c b/main/php_ini.c index 8c1b08c40b..0a0fc04bd2 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -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,96 +146,79 @@ static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,  } -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); -		} -		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; - -		zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, NULL); - -		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); +			efree(default_location);  		}  	} + +	PG(safe_mode) = 0; +	PG(open_basedir) = NULL; -#endif +	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; + +	if (!fh.handle.fp) { +		return SUCCESS;  /* having no configuration file is ok */ +	} +	fh.type = ZEND_HANDLE_FP; +	fh.filename = php_ini_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); +	}  	return SUCCESS;  } @@ -243,6 +227,9 @@ int php_init_config(void)  int php_shutdown_config(void)  {  	zend_hash_destroy(&configuration_hash); +	if (php_ini_opened_path) { +		efree(php_ini_opened_path); +	}  	return SUCCESS;  } diff --git a/main/php_ini.h b/main/php_ini.h index cd1b2b00a6..d7aa475d68 100644 --- a/main/php_ini.h +++ b/main/php_ini.h @@ -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 diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c index ff4b97bfe1..aabfe5a9e1 100644 --- a/sapi/aolserver/aolserver.c +++ b/sapi/aolserver/aolserver.c @@ -368,7 +368,7 @@ php_ns_sapi_register_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC)  /* 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 @@ int Ns_ModuleInit(char *server, char *module)  	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); diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c index f4b50c7c54..efdfee968e 100644 --- a/sapi/apache/mod_php4.c +++ b/sapi/apache/mod_php4.c @@ -249,7 +249,7 @@ static void sapi_apache_register_server_variables(zval *track_vars_array ELS_DC  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 char *php_apache_getenv(char *name, size_t name_len SLS_DC)  } -static sapi_module_struct sapi_module_conf = { +static sapi_module_struct apache_sapi_module = {  	"apache",						/* name */  	"Apache",						/* pretty name */ @@ -590,8 +590,8 @@ CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf,  #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 @@ int php_xbithack_handler(request_rec * r)  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 apache_php_module_shutdown_wrapper(void)  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 @@ void php_init_handler(server_rec *s, pool *p)  #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  	{ diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index a895813c22..04c7cad836 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -187,7 +187,7 @@ static void php_apache_sapi_log_message(char *msg)  	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 @@ ok:  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 @@ static void  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();  } diff --git a/sapi/caudium/caudium.c b/sapi/caudium/caudium.c index 747179f200..da1b2280ca 100644 --- a/sapi/caudium/caudium.c +++ b/sapi/caudium/caudium.c @@ -491,7 +491,7 @@ static zend_module_entry php_caudium_module = {  /* 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 @@ void pike_module_init( void )      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_init( void )  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(); diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index e3d88a3e26..0163867c5b 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -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 int sapi_cgi_deactivate(SLS_D) -static sapi_module_struct sapi_module = { +static sapi_module_struct cgi_sapi_module = {  	"cgi",							/* name */  	"CGI",							/* pretty name */ @@ -412,7 +410,7 @@ int main(int argc, char *argv[])  	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 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine  		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 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine  		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 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine  	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 diff --git a/sapi/isapi/php4isapi.c b/sapi/isapi/php4isapi.c index c2acf57310..03748e24ed 100644 --- a/sapi/isapi/php4isapi.c +++ b/sapi/isapi/php4isapi.c @@ -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 @@ static char *isapi_server_variables[] = {  	"REQUEST_METHOD",  	"SERVER_NAME",  	"SERVER_PORT", -	"SERVER_PORT_SECURE",  	"SERVER_PROTOCOL",  	"SERVER_SOFTWARE",  #ifndef WITH_ZEUS @@ -89,9 +90,7 @@ static char *isapi_server_variables[] = {  	"INSTANCE_ID",  	"INSTANCE_META_PATH",  	"LOGON_USER", -	"PATH_INFO",  	"REQUEST_URI", -	"SCRIPT_NAME",  	"URL",  #else  	"DOCUMENT_ROOT", @@ -100,11 +99,37 @@ static char *isapi_server_variables[] = {  }; +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 @@ static void php_info_isapi(ZEND_MODULE_INFO_FUNC_ARGS)  	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 char *sapi_isapi_read_cookies(SLS_D)  } -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 @@ static void sapi_isapi_register_server_variables(zval *track_vars_array ELS_DC S      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); +	} + +	/* 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]);  	} -	variable = php_strtok_r(variable_buf, "\r\n", &strtok_buf); -	while (variable) { -		char *colon = strchr(variable, ':'); -		if (colon) { -			char *value = colon+1; +	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, ':'); -			while (*value==' ') { -				value++; +			if (colon) { +				char *value = colon+1; + +				while (*value==' ') { +					value++; +				} +				*colon = 0; +				php_register_variable(variable, value, track_vars_array ELS_CC PLS_CC); +				*colon = ':';  			} -			*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 @@ static void sapi_isapi_register_server_variables(zval *track_vars_array ELS_DC S  		}  	}  #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 @@ BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pFilterVersion)  {  	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 @@ BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer)  {  	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 @@ __declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, L  	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 @@ __declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, L  			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; diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c index 8709eab78f..81fa6a9efc 100644 --- a/sapi/nsapi/nsapi.c +++ b/sapi/nsapi/nsapi.c @@ -320,7 +320,7 @@ sapi_nsapi_register_server_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC  	}  } -static sapi_module_struct sapi_module = { +static sapi_module_struct nsapi_sapi_module = {  	"nsapi",				/* name */  	"NSAPI",				/* pretty name */ @@ -531,8 +531,8 @@ nsapi_module_main(NSLS_D SLS_DC)  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 @@ php4_init(pblock *pb, Session *sn, Request *rq)  	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; diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c index a7abe61088..7ff5316491 100644 --- a/sapi/phttpd/phttpd.c +++ b/sapi/phttpd/phttpd.c @@ -163,7 +163,7 @@ php_phttpd_sapi_read_post(char *buf, uint count_bytes SLS_DC)  	return 0;  } -static sapi_module_struct sapi_module = { +static sapi_module_struct phttpd_sapi_module = {      "phttpd",      "PHTTPD", @@ -284,8 +284,8 @@ int php_doit(PHLS_D SLS_DC)  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); diff --git a/sapi/pi3web/pi3web_sapi.c b/sapi/pi3web/pi3web_sapi.c index c9ad0b8481..e079fac5e2 100644 --- a/sapi/pi3web/pi3web_sapi.c +++ b/sapi/pi3web/pi3web_sapi.c @@ -280,7 +280,7 @@ static char *sapi_pi3web_read_cookies(SLS_D)  } -static sapi_module_struct sapi_module = { +static sapi_module_struct pi3web_sapi_module = {  	"pi3web",				/* name */  	"PI3WEB",				/* pretty name */ @@ -428,17 +428,17 @@ DWORD fnWrapperProc(LPCONTROL_BLOCK lpCB)  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(); diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c index 8d4e1d66b0..c751635200 100644 --- a/sapi/roxen/roxen.c +++ b/sapi/roxen/roxen.c @@ -489,7 +489,7 @@ static int php_roxen_startup(sapi_module_struct *sapi_module)  /* 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 @@ void pike_module_init( void )      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_init( void )  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(); diff --git a/sapi/servlet/servlet.c b/sapi/servlet/servlet.c index 210e59c9b9..061186de27 100644 --- a/sapi/servlet/servlet.c +++ b/sapi/servlet/servlet.c @@ -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 @@ static char *sapi_servlet_read_cookies(SLS_D)   * 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 @@ JNIEXPORT void JNICALL Java_net_php_servlet_startup  	}  #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;  	} diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index 1d1467bd44..5a40ccccd6 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -164,7 +164,7 @@ static void sapi_thttpd_register_variables(zval *track_vars_array ELS_DC SLS_DC  		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_set_dont_close(void)  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();  	}  } | 
