]> granicus.if.org Git - php/commitdiff
Many patches. I hope I remember them all:
authorZeev Suraski <zeev@php.net>
Tue, 2 Jan 2001 22:49:31 +0000 (22:49 +0000)
committerZeev Suraski <zeev@php.net>
Tue, 2 Jan 2001 22:49:31 +0000 (22:49 +0000)
- 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.

19 files changed:
NEWS
ext/standard/info.c
main/SAPI.c
main/SAPI.h
main/main.c
main/php_ini.c
main/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

diff --git a/NEWS b/NEWS
index 583383cefd95ec5a33a9534db2b54aa4453d375e..235b6c1a42c782445a39bc2ae51722c5267f93a2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
index c600cef189e76060058e04e95f7ee091238fd8a2..5bcfaf6f1dc2c7b2c807d3f6b15f5edbb71ad47e 100644 (file)
@@ -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" );
index eba50440dde7a59ef945fca937c87139849b00c5..fb7b073d932427281d90a266cf1858f15e3bf7cd 100644 (file)
@@ -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, ...);
 
 
index 9d7c70ac7933a4d5de00eb7912429d69343efc42..4e9ada027845fbadc16071b86c5746caa6ac7c42 100644 (file)
@@ -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 */
 
index 8eacdaa7fa19cf202433db2e29fd3e03cb16a772..aa6423b12296957614f7f9360f6f25f94ef7d041 100644 (file)
@@ -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;
        }
 
index 8c1b08c40b02343091eb8575ae4efc91f54c364c..0a0fc04bd2c1f77d72236bc07c0cccf92c1aa559 100644 (file)
@@ -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;
 }
 
index cd1b2b00a63ea4495e684f4e369d0bc2d6675409..d7aa475d686b4e26f222fc7f9fef18c5cf53091e 100644 (file)
@@ -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 ff4b97bfe10853d5d72235abb4dbd9fe428d9eb9..aabfe5a9e1608f6bd6157838e121cc3fa9cfe992 100644 (file)
@@ -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);
        
index f4b50c7c5468f34118e8d372a047aec37648fe2f..efdfee968e221a70a075da276b41591d74fc404e 100644 (file)
@@ -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
        {
index a895813c221490ca7cf45ee7457884eb65a4487d..04c7cad836ac0a05a6075cc1dcb011ad8e426921 100644 (file)
@@ -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();
 }
index 747179f2000ae926b9db2a5dd037a17f1c9ba2a7..da1b2280caab83f27c73d95b3497c9ec95fbbe3b 100644 (file)
@@ -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();
index e3d88a3e2662682a9660f4ef2e08602115823c2b..0163867c5b9607b2923b31b3ea79504663357c6d 100644 (file)
@@ -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
index c2acf57310af74668088914b8256d7a098da8663..03748e24edd32978bd6d799a80c8a055ce18a682 100644 (file)
 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;
index 8709eab78f40e36352dea533f9f1faedec91fc6d..81fa6a9efca0815dbc795b2a8c1e4178ccf749e9 100644 (file)
@@ -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;
index a7abe610886e7de3bd9e688f434a1981fb1a83dd..7ff5316491ce8bf67684a9050d82a206d73efd5a 100644 (file)
@@ -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);
 
index c9ad0b8481afb6aef38594a72d48c3732920fdec..e079fac5e25aa285480451e4bab1e3928958c110 100644 (file)
@@ -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();
index 8d4e1d66b0f90e19ed6e6a499a2ee390d389375c..c751635200a944215d6318c32a1c6d43f3fce7d5 100644 (file)
@@ -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();
index 210e59c9b93658709161d19774f03444a545e104..061186de274eda6040974062a903247f612ddf0a 100644 (file)
@@ -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;
        }
index 1d1467bd4479ef443c9f8d15444e62b43c17f64e..5a40ccccd6750a79013a3081a2542c791bcd05c5 100644 (file)
@@ -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();
        }
 }