]> granicus.if.org Git - php/commitdiff
Make the session module more independent
authorZeev Suraski <zeev@php.net>
Sun, 26 Aug 2001 01:09:20 +0000 (01:09 +0000)
committerZeev Suraski <zeev@php.net>
Sun, 26 Aug 2001 01:09:20 +0000 (01:09 +0000)
ext/session/php_session.h
ext/session/session.c
ext/standard/basic_functions.c
ext/standard/basic_functions.h

index 6ddcb4bd7e6ece9d39a5955fd3461b70c8f53847..a9bc88ea8ea458affd200ca9e17503c24312c118 100644 (file)
@@ -90,6 +90,7 @@ typedef struct _php_ps_globals {
        zend_bool auto_start;
        zend_bool define_sid;
        zend_bool use_cookies;
+       zend_bool use_trans_sid;
 } php_ps_globals;
 
 extern zend_module_entry session_module_entry;
@@ -148,8 +149,6 @@ void session_adapt_url(const char *, size_t, char **, size_t * TSRMLS_DC);
 
 void php_set_session_var(char *name, size_t namelen, zval *state_val,HashTable *var_hash TSRMLS_DC);
 int php_get_session_var(char *name, size_t namelen, zval ***state_var TSRMLS_DC);
-void php_session_start_output_handler(INIT_FUNC_ARGS, uint chunk_size);
-void php_session_end_output_handler(SHUTDOWN_FUNC_ARGS);
 
 int php_session_register_module(ps_module *);
 
index c71e598c0134c74e08f3eb18668c3a52cdea0358..ac3b6f0c018136c41d1c8492c33908a32190a81d 100644 (file)
@@ -83,6 +83,33 @@ php_ps_globals ps_globals;
 static ps_module *_php_find_ps_module(char *name TSRMLS_DC);
 static const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC);
 
+static void php_session_output_handler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
+{
+       zend_bool do_flush;
+       
+       if (mode&PHP_OUTPUT_HANDLER_END) {
+               do_flush=1;
+       }
+       session_adapt_uris(output, output_len, handled_output, handled_output_len, do_flush TSRMLS_CC);
+}
+
+
+static void php_session_start_output_handler(INIT_FUNC_ARGS, uint chunk_size)
+{
+       PHP_RINIT(url_scanner)(INIT_FUNC_ARGS_PASSTHRU);
+       PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);
+       php_start_ob_buffer(NULL, chunk_size TSRMLS_CC);
+       php_ob_set_internal_handler(php_session_output_handler, chunk_size TSRMLS_CC);
+}
+
+
+static void php_session_end_output_handler(SHUTDOWN_FUNC_ARGS)
+{
+       PHP_RSHUTDOWN(url_scanner_ex)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+       PHP_RSHUTDOWN(url_scanner)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+}
+
+
 static PHP_INI_MH(OnUpdateSaveHandler)
 {
        PS(mod) = _php_find_ps_module(new_value TSRMLS_CC);
@@ -123,6 +150,7 @@ PHP_INI_BEGIN()
        STD_PHP_INI_ENTRY("session.entropy_length",             "0",                    PHP_INI_ALL, OnUpdateInt,                       entropy_length,         php_ps_globals, ps_globals)
        STD_PHP_INI_ENTRY("session.cache_limiter",              "nocache",              PHP_INI_ALL, OnUpdateString,            cache_limiter,          php_ps_globals, ps_globals)
        STD_PHP_INI_ENTRY("session.cache_expire",               "180",                  PHP_INI_ALL, OnUpdateInt,                       cache_expire,           php_ps_globals, ps_globals)
+       STD_PHP_INI_ENTRY("session.use_trans_sid",              "1",                    PHP_INI_ALL, OnUpdateBool,                      use_trans_sid,          php_ps_globals, ps_globals)
        /* Commented out until future discussion */
        /* PHP_INI_ENTRY("session.encode_sources", "globals,track", PHP_INI_ALL, NULL) */
 PHP_INI_END()
@@ -1360,6 +1388,10 @@ PHP_RINIT_FUNCTION(session)
                php_session_start(TSRMLS_C);
        }
 
+       if (PS(use_trans_sid)) {
+               php_session_start_output_handler(INIT_FUNC_ARGS_PASSTHRU, 4096);
+       }
+
        return SUCCESS;
 }
 
@@ -1378,6 +1410,9 @@ PHP_FUNCTION(session_write_close)
 
 PHP_RSHUTDOWN_FUNCTION(session)
 {
+       if (PS(use_trans_sid)) {
+               php_session_end_output_handler(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+       }
        php_session_flush(TSRMLS_C);
        php_rshutdown_session_globals(TSRMLS_C);
        return SUCCESS;
@@ -1418,34 +1453,6 @@ PHP_MINFO_FUNCTION(session)
 }
 
 
-static void php_session_output_handler(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC)
-{
-       zend_bool do_flush;
-       
-       if (mode&PHP_OUTPUT_HANDLER_END) {
-               do_flush=1;
-       }
-       session_adapt_uris(output, output_len, handled_output, handled_output_len, do_flush TSRMLS_CC);
-}
-
-
-void php_session_start_output_handler(INIT_FUNC_ARGS, uint chunk_size)
-{
-       memset(&BG(url_adapt_state), 0, sizeof(BG(url_adapt_state)));
-       memset(&BG(url_adapt_state_ex), 0, sizeof(BG(url_adapt_state_ex)));
-       PHP_RINIT(url_scanner)(INIT_FUNC_ARGS_PASSTHRU);
-       PHP_RINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);
-       php_start_ob_buffer(NULL, chunk_size TSRMLS_CC);
-       php_ob_set_internal_handler(php_session_output_handler, chunk_size TSRMLS_CC);
-}
-
-
-void php_session_end_output_handler(SHUTDOWN_FUNC_ARGS)
-{
-       PHP_RSHUTDOWN(url_scanner_ex)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
-       PHP_RSHUTDOWN(url_scanner)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
-}
-
 /*
  * Local variables:
  * tab-width: 4
index dd3fe898ee5ed6325f10e69529c25108e45d6cfd..93cc62edad26c9d15d9190adf5e62d5e5a026cb6 100644 (file)
@@ -662,7 +662,6 @@ static PHP_INI_MH(OnUpdateSafeModeAllowedEnvVars)
 PHP_INI_BEGIN()
        PHP_INI_ENTRY_EX("safe_mode_protected_env_vars",        SAFE_MODE_PROTECTED_ENV_VARS,   PHP_INI_SYSTEM,         OnUpdateSafeModeProtectedEnvVars,               NULL)
        PHP_INI_ENTRY_EX("safe_mode_allowed_env_vars",          SAFE_MODE_ALLOWED_ENV_VARS,             PHP_INI_SYSTEM,         OnUpdateSafeModeAllowedEnvVars,                 NULL)
-       STD_PHP_INI_ENTRY("session.use_trans_sid",          "1",                                                        PHP_INI_ALL,                    OnUpdateBool,                   use_trans_sid,                  php_basic_globals,                      basic_globals)
 PHP_INI_END()
 
 
@@ -713,6 +712,9 @@ static void basic_globals_ctor(php_basic_globals *basic_globals_p TSRMLS_DC)
        zend_hash_init(&BG(sm_protected_env_vars), 5, NULL, NULL, 1);
        BG(sm_allowed_env_vars) = NULL;
 
+       memset(&BG(url_adapt_state), 0, sizeof(BG(url_adapt_state)));
+       memset(&BG(url_adapt_state_ex), 0, sizeof(BG(url_adapt_state_ex)));
+
 #ifdef PHP_WIN32
        CoInitialize(NULL);
 #endif
@@ -871,11 +873,6 @@ PHP_RINIT_FUNCTION(basic)
        PHP_RINIT(filestat)(INIT_FUNC_ARGS_PASSTHRU);
        PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
        PHP_RINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
-
-       if (BG(use_trans_sid)) {
-               php_session_start_output_handler(INIT_FUNC_ARGS_PASSTHRU, 4096);
-       }
-
        return SUCCESS;
 }
 
@@ -902,10 +899,6 @@ PHP_RSHUTDOWN_FUNCTION(basic)
        PHP_RSHUTDOWN(syslog)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
        PHP_RSHUTDOWN(assert)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
 
-       if (BG(use_trans_sid)) {
-               php_session_end_output_handler(SHUTDOWN_FUNC_ARGS_PASSTHRU);
-       }
-
        if (BG(user_tick_functions)) {
                zend_llist_destroy(BG(user_tick_functions));
                efree(BG(user_tick_functions));
index e31eb230fd428e37207f6a93ed8e62c8119ab66d..82a698ec82a4a0178c36c7111b85d7b08dcef807 100644 (file)
@@ -179,7 +179,6 @@ typedef struct {
 
        /* var.c */
        zend_class_entry *incomplete_class;
-       zend_bool use_trans_sid;
 
        /* url_scanner.c */
        url_adapt_state_t url_adapt_state;