\n");
- PUTS("Variable | Value |
\n");
+ php_info_print_table_header(2, "Variable", "Value");
if (_php3_hash_find(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void **) &data) != FAILURE) {
- PUTS("");
- PUTS("PHP_SELF");
- PUTS(" | ");
- PUTS((*data)->value.str.val);
- PUTS(" |
\n");
+ php_info_print_table_row(2, "PHP_SELF", (*data)->value.str.val);
}
if (_php3_hash_find(&EG(symbol_table), "PHP_AUTH_TYPE", sizeof("PHP_AUTH_TYPE"), (void **) &data) != FAILURE) {
- PUTS("");
- PUTS("PHP_AUTH_TYPE");
- PUTS(" | ");
- PUTS((*data)->value.str.val);
- PUTS(" |
\n");
+ php_info_print_table_row(2, "PHP_AUTH_TYPE", (*data)->value.str.val);
}
if (_php3_hash_find(&EG(symbol_table), "PHP_AUTH_USER", sizeof("PHP_AUTH_USER"), (void **) &data) != FAILURE) {
- PUTS("");
- PUTS("PHP_AUTH_USER");
- PUTS(" | ");
- PUTS((*data)->value.str.val);
- PUTS(" |
\n");
+ php_info_print_table_row(2, "PHP_AUTH_USER", (*data)->value.str.val);
}
if (_php3_hash_find(&EG(symbol_table), "PHP_AUTH_PW", sizeof("PHP_AUTH_PW"), (void **) &data) != FAILURE) {
- PUTS("");
- PUTS("PHP_AUTH_PW");
- PUTS(" | ");
- PUTS((*data)->value.str.val);
- PUTS(" |
\n");
+ php_info_print_table_row(2, "PHP_AUTH_PW", (*data)->value.str.val);
}
if (_php3_hash_find(&EG(symbol_table), "HTTP_GET_VARS", sizeof("HTTP_GET_VARS"), (void **) &data) != FAILURE) {
_php3_hash_internal_pointer_reset((*data)->value.ht);
@@ -338,13 +255,9 @@ PHPAPI void _php3_info(void)
SECTION("Apache Environment");
PUTS("\n");
- PUTS("Variable | Value |
\n");
+ php_info_print_table_header(2, "Variable", "Value");
for (i=0; i < arr->nelts; i++) {
- PUTS("");
- PUTS(elts[i].key);
- PUTS(" | ");
- PUTS(elts[i].val);
- PUTS(" |
\n");
+ php_info_print_table_row(2, elts[i].key, elts[i].val);
}
PUTS("
\n");
}
@@ -362,18 +275,12 @@ PHPAPI void _php3_info(void)
SECTION("HTTP Headers Information");
PUTS("\n");
PUTS(" HTTP Request Headers |
\n");
- PUTS("HTTP Request | ");
- PUTS(r->the_request);
- PUTS(" |
\n");
+ php_info_print_table_row(2, "HTTP Request", r->the_request);
env_arr = table_elts(r->headers_in);
env = (table_entry *)env_arr->elts;
for (i = 0; i < env_arr->nelts; ++i) {
if (env[i].key) {
- PUTS("");
- PUTS(env[i].key);
- PUTS(" | ");
- PUTS(env[i].val);
- PUTS(" |
\n");
+ php_info_print_table_row(2, env[i].key, env[i].val);
}
}
PUTS(" HTTP Response Headers |
\n");
@@ -381,11 +288,7 @@ PHPAPI void _php3_info(void)
env = (table_entry *)env_arr->elts;
for(i = 0; i < env_arr->nelts; ++i) {
if (env[i].key) {
- PUTS("");
- PUTS(env[i].key);
- PUTS(" | ");
- PUTS(env[i].val);
- PUTS(" |
\n");
+ php_info_print_table_row(2, env[i].key, env[i].val);
}
}
PUTS("
\n\n");
@@ -394,15 +297,6 @@ PHPAPI void _php3_info(void)
PUTS("");
- PUTS("
\n");
- PUTS("\n");
- php3_printf("ZendThis program makes use of the Zend scripting language engine:
%s | ", get_zend_version());
- PUTS(" | \n");
- PUTS("
\n");
SECTION("PHP License");
PUTS("This program is free software; you can redistribute it and/or modify\n");
@@ -426,6 +320,53 @@ PHPAPI void _php3_info(void)
}
+
+PHPAPI void php_info_print_table_header(int num_cols, ...)
+{
+ int i;
+ va_list row_elements;
+ char *row_element;
+
+ va_start(row_elements, num_cols);
+
+ php3_printf("");
+ for (i=0; i%s", row_element);
+ }
+ php3_printf("
\n");
+
+ va_end(row_elements);
+}
+
+
+PHPAPI void php_info_print_table_row(int num_cols, ...)
+{
+ int i;
+ va_list row_elements;
+ char *color = ENTRY_NAME_COLOR;
+ char *row_element;
+
+ va_start(row_elements, num_cols);
+
+ php3_printf("");
+ for (i=0; i%s", color, row_element);
+ color = CONTENTS_COLOR;
+ }
+ php3_printf("
\n");
+
+ va_end(row_elements);
+}
+
+
/* {{{ proto void phpinfo(void)
Output a page of useful information about PHP and the current request */
void php3_info(INTERNAL_FUNCTION_PARAMETERS)
diff --git a/ext/standard/info.h b/ext/standard/info.h
index 49adc456f6..73db458108 100644
--- a/ext/standard/info.h
+++ b/ext/standard/info.h
@@ -32,9 +32,11 @@
#ifndef _INFO_H
#define _INFO_H
-extern void php3_version(INTERNAL_FUNCTION_PARAMETERS);
-extern void php3_info(INTERNAL_FUNCTION_PARAMETERS);
-
+void php3_version(INTERNAL_FUNCTION_PARAMETERS);
+void php3_info(INTERNAL_FUNCTION_PARAMETERS);
PHPAPI void _php3_info(void);
+PHPAPI void php_info_print_table_header(int num_cols, ...);
+PHPAPI void php_info_print_table_row(int num_cols, ...);
+
#endif /* _INFO_H */
diff --git a/ext/standard/mail.c b/ext/standard/mail.c
index da06d4007d..a6e97161ed 100644
--- a/ext/standard/mail.c
+++ b/ext/standard/mail.c
@@ -160,7 +160,7 @@ int _php3_mail(char *to, char *subject, char *message, char *headers)
return 1;
}
-void php3_info_mail(void)
+void php3_info_mail(ZEND_MODULE_INFO_FUNC_ARGS)
{
#if MSVC5
PUTS("Internal Sendmail support for Windows 4");
@@ -172,7 +172,7 @@ void php3_info_mail(void)
#else
void php3_mail(INTERNAL_FUNCTION_PARAMETERS) {}
-void php3_info_mail() {}
+void php3_info_mail(ZEND_MODULE_INFO_FUNC_ARGS) {}
#endif
diff --git a/ext/standard/php3_mail.h b/ext/standard/php3_mail.h
index 3fb763ecb0..71ac97fe8f 100644
--- a/ext/standard/php3_mail.h
+++ b/ext/standard/php3_mail.h
@@ -37,7 +37,7 @@ extern php3_module_entry mail_module_entry;
#define mail_module_ptr &mail_module_entry
extern void php3_mail(INTERNAL_FUNCTION_PARAMETERS);
-extern void php3_info_mail(void);
+extern void php3_info_mail(ZEND_MODULE_INFO_FUNC_ARGS);
extern int _php3_mail(char *to, char *subject, char *message, char *headers);
#else
diff --git a/ext/standard/post.c b/ext/standard/post.c
index f961602e77..7be502ff69 100644
--- a/ext/standard/post.c
+++ b/ext/standard/post.c
@@ -42,6 +42,7 @@
* This reads the post form data into a string.
* Remember to free this pointer when done with it.
*/
+#if APACHE
static char *php3_getpost(pval *http_post_vars PLS_DC)
{
char *buf = NULL;
@@ -149,6 +150,14 @@ static char *php3_getpost(pval *http_post_vars PLS_DC)
#endif
return (buf);
}
+#else
+static char *php3_getpost(pval *http_post_vars PLS_DC)
+{
+ SLS_FETCH();
+
+ return SG(request_info).post_data;
+}
+#endif
/*
@@ -352,7 +361,7 @@ void php3_treat_data(int arg, char *str)
res = (char *) estrdup(var);
}
} else if (arg == PARSE_COOKIE) { /* Cookie data */
- var = (char *)request_info.cookies;
+ var = SG(request_info).cookie_data;
if (var && *var) {
res = (char *) estrdup(var);
}
diff --git a/ext/sybase/php3_sybase-ct.h b/ext/sybase/php3_sybase-ct.h
index 1ce0a30f0c..c8e89a6213 100644
--- a/ext/sybase/php3_sybase-ct.h
+++ b/ext/sybase/php3_sybase-ct.h
@@ -49,7 +49,7 @@ extern int php3_minit_sybct(INIT_FUNC_ARGS);
extern int php3_rinit_sybct(INIT_FUNC_ARGS);
extern int php3_mshutdown_sybct(SHUTDOWN_FUNC_ARGS);
extern int php3_rshutdown_sybct(SHUTDOWN_FUNC_ARGS);
-extern void php3_info_sybct(void);
+extern void php3_info_sybct(ZEND_MODULE_INFO_FUNC_ARGS);
extern void php3_sybct_connect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_sybct_pconnect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_sybct_close(INTERNAL_FUNCTION_PARAMETERS);
diff --git a/ext/sybase/php3_sybase.h b/ext/sybase/php3_sybase.h
index dbfcdd767a..3b1a5e18a1 100644
--- a/ext/sybase/php3_sybase.h
+++ b/ext/sybase/php3_sybase.h
@@ -47,7 +47,7 @@ extern int php3_minit_sybase(INIT_FUNC_ARGS);
extern int php3_rinit_sybase(INIT_FUNC_ARGS);
extern int php3_mshutdown_sybase(SHUTDOWN_FUNC_ARGS);
extern int php3_rshutdown_sybase(SHUTDOWN_FUNC_ARGS);
-extern void php3_info_sybase(void);
+extern void php3_info_sybase(ZEND_MODULE_INFO_FUNC_ARGS);
extern void php3_sybase_connect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_sybase_pconnect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_sybase_close(INTERNAL_FUNCTION_PARAMETERS);
diff --git a/ext/sybase/sybase-ct.c b/ext/sybase/sybase-ct.c
index 7f45658d6b..58ba286bad 100644
--- a/ext/sybase/sybase-ct.c
+++ b/ext/sybase/sybase-ct.c
@@ -1596,7 +1596,7 @@ void php3_sybct_affected_rows(INTERNAL_FUNCTION_PARAMETERS)
}
-void php3_info_sybct(void)
+void php3_info_sybct(ZEND_MODULE_INFO_FUNC_ARGS)
{
char maxp[16],maxl[16];
diff --git a/ext/sybase/sybase.c b/ext/sybase/sybase.c
index df17867142..94a8c9ccd1 100644
--- a/ext/sybase/sybase.c
+++ b/ext/sybase/sybase.c
@@ -1186,7 +1186,7 @@ void php3_sybase_result(INTERNAL_FUNCTION_PARAMETERS)
}
-void php3_info_sybase(void)
+void php3_info_sybase(ZEND_MODULE_INFO_FUNC_ARGS)
{
char maxp[16],maxl[16];
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index eed6a3f6e0..299be2cfc3 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -102,7 +102,7 @@ int php3_minit_xml(INIT_FUNC_ARGS);
int php3_rinit_xml(INIT_FUNC_ARGS);
int php3_mshutdown_xml(SHUTDOWN_FUNC_ARGS);
int php3_rshutdown_xml(SHUTDOWN_FUNC_ARGS);
-void php3_info_xml(void);
+void php3_info_xml(ZEND_MODULE_INFO_FUNC_ARGS);
static xml_parser *xml_get_parser(int, const char *, HashTable *);
static void xml_destroy_parser(xml_parser *);
@@ -273,7 +273,7 @@ int php3_rshutdown_xml(SHUTDOWN_FUNC_ARGS)
/* }}} */
/* {{{ php3_info_xml() */
-void php3_info_xml()
+void php3_info_xml(ZEND_MODULE_INFO_FUNC_ARGS)
{
PUTS("XML support active");
}
diff --git a/ext/zlib/php3_zlib.h b/ext/zlib/php3_zlib.h
index 22052fbab4..710c694cba 100644
--- a/ext/zlib/php3_zlib.h
+++ b/ext/zlib/php3_zlib.h
@@ -40,7 +40,7 @@ extern php3_module_entry php3_zlib_module_entry;
extern int php3_minit_zlib(INIT_FUNC_ARGS);
extern int php3_mshutdown_zlib(SHUTDOWN_FUNC_ARGS);
-extern void php3_info_zlib(void);
+extern void php3_info_zlib(ZEND_MODULE_INFO_FUNC_ARGS);
extern void php3_gzopen(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_gzclose(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_gzeof(INTERNAL_FUNCTION_PARAMETERS);
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 46ff513c56..c72c07c26d 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -179,7 +179,7 @@ int php3_mshutdown_zlib(SHUTDOWN_FUNC_ARGS){
return SUCCESS;
}
-void php3_info_zlib(void)
+void php3_info_zlib(ZEND_MODULE_INFO_FUNC_ARGS)
{
PUTS("Zlib support active (compiled with ");
PUTS(ZLIB_VERSION);
diff --git a/main/SAPI.c b/main/SAPI.c
index 1df5fe4fea..a5b9b21b9d 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -2,10 +2,12 @@
+----------------------------------------------------------------------+
| Server API Abstraction Layer |
+----------------------------------------------------------------------+
- | Copyright (c) 1999 SAPI Development Team |
+ | Copyright (c) 1998, 1999 SAPI Development Team |
+----------------------------------------------------------------------+
- | This source file is subject to the GNU public license, that is |
- | bundled with this package in the file LICENSE. |
+ | This source file is subject to the Zend license, that is bundled |
+ | with this package in the file LICENSE. If you did not receive a |
+ | copy of the Zend license, please mail us at zend@zend.com so we can |
+ | send you a copy immediately. |
+----------------------------------------------------------------------+
| Design: Shane Caraveo |
| Authors: Andi Gutmans |
@@ -59,17 +61,21 @@ static void sapi_free_header(sapi_header_struct *sapi_header)
SAPI_API void sapi_activate(SLS_D)
{
zend_llist_init(&SG(sapi_headers).headers, sizeof(sapi_header_struct), (void (*)(void *)) sapi_free_header, 0);
- SG(sapi_headers).content_type.header = NULL;
+ SG(sapi_headers).send_default_content_type = 1;
SG(sapi_headers).http_response_code = 200;
SG(headers_sent) = 0;
+ if (SG(server_context)) {
+ SG(request_info).post_data = sapi_module.read_post(SLS_C);
+ SG(request_info).cookie_data = sapi_module.read_cookies(SLS_C);
+ }
}
SAPI_API void sapi_deactivate(SLS_D)
{
zend_llist_destroy(&SG(sapi_headers).headers);
- if (SG(sapi_headers).content_type.header) {
- efree(SG(sapi_headers).content_type.header);
+ if (SG(server_context) && SG(request_info).post_data) {
+ efree(SG(request_info).post_data);
}
}
@@ -93,7 +99,7 @@ SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
sapi_header.header_len = header_line_len;
if (sapi_module.header_handler) {
- retval = sapi_module.header_handler(&sapi_header, &SG(sapi_headers));
+ retval = sapi_module.header_handler(&sapi_header, &SG(sapi_headers) SLS_CC);
} else {
retval = SAPI_HEADER_ADD;
}
@@ -107,13 +113,7 @@ SAPI_API int sapi_add_header(char *header_line, uint header_line_len)
if (colon_offset) {
*colon_offset = 0;
if (!STRCASECMP(header_line, "Content-Type")) {
- if (SG(sapi_headers).content_type.header) {
- efree(SG(sapi_headers).content_type.header);
- }
- *colon_offset = ':';
- SG(sapi_headers).content_type.header = (char *) header_line;
- SG(sapi_headers).content_type.header_len = header_line_len;
- return SUCCESS;
+ SG(sapi_headers).send_default_content_type = 0;
}
*colon_offset = ':';
}
@@ -145,9 +145,7 @@ SAPI_API int sapi_send_headers()
return SUCCESS;
break;
case SAPI_HEADER_DO_SEND:
- if (SG(sapi_headers).content_type.header) {
- sapi_module.send_header(&SG(sapi_headers).content_type, SG(server_context));
- } else {
+ if (SG(sapi_headers).send_default_content_type) {
sapi_module.send_header(&default_header, SG(server_context));
}
zend_llist_apply_with_argument(&SG(sapi_headers).headers, (void (*)(void *, void *)) sapi_module.send_header, SG(server_context));
diff --git a/main/SAPI.h b/main/SAPI.h
index 58925b630e..03bc4f7868 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -24,8 +24,8 @@ typedef struct {
typedef struct {
zend_llist headers;
- sapi_header_struct content_type;
int http_response_code;
+ unsigned char send_default_content_type;
} sapi_headers_struct;
@@ -36,11 +36,17 @@ extern sapi_module_struct sapi_module; /* true global */
typedef struct {
+ char *request_method;
char *query_string;
+ char *post_data;
+ char *cookie_data;
+ uint content_length;
char *path_translated;
char *request_uri;
+ char *content_type;
+
unsigned char headers_only;
} sapi_request_info;
@@ -89,9 +95,12 @@ struct _sapi_module_struct {
void (*sapi_error)(int type, const char *error_msg, ...);
- int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers);
+ int (*header_handler)(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC);
int (*send_headers)(sapi_headers_struct *sapi_headers SLS_DC);
void (*send_header)(sapi_header_struct *sapi_header, void *server_context);
+
+ char *(*read_post)(SLS_D);
+ char *(*read_cookies)(SLS_D);
};
diff --git a/main/main.c b/main/main.c
index 52a1f07b85..a14dbbabcf 100644
--- a/main/main.c
+++ b/main/main.c
@@ -186,41 +186,41 @@ static PHP_INI_MH(OnUpdateErrorReporting)
# define DEFAULT_SENDMAIL_PATH NULL
#endif
PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("short_open_tag", "1", PHP_INI_ALL, OnUpdateInt, short_tags, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("asp_tags", "0", PHP_INI_ALL, OnUpdateInt, asp_tags, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("short_open_tag", "1", PHP_INI_ALL, OnUpdateInt, short_tags, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("asp_tags", "0", PHP_INI_ALL, OnUpdateInt, asp_tags, php_core_globals, core_globals)
PHP_INI_ENTRY("precision", "14", PHP_INI_ALL, OnSetPrecision)
- PHP_INI_ENTRY("highlight.comment", HL_COMMENT_COLOR, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("highlight.default", HL_DEFAULT_COLOR, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("highlight.html", HL_HTML_COLOR, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("highlight.string", HL_STRING_COLOR, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("highlight.bg", HL_BG_COLOR, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("highlight.keyword", HL_KEYWORD_COLOR, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY_EX("highlight.comment", HL_COMMENT_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
+ PHP_INI_ENTRY_EX("highlight.default", HL_DEFAULT_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
+ PHP_INI_ENTRY_EX("highlight.html", HL_HTML_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
+ PHP_INI_ENTRY_EX("highlight.string", HL_STRING_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
+ PHP_INI_ENTRY_EX("highlight.bg", HL_BG_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
+ PHP_INI_ENTRY_EX("highlight.keyword", HL_KEYWORD_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
- STD_PHP_INI_ENTRY("magic_quotes_gpc", "1", PHP_INI_ALL, OnUpdateInt, magic_quotes_gpc, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("magic_quotes_runtime", "0", PHP_INI_ALL, OnUpdateInt, magic_quotes_runtime, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("magic_quotes_sybase", "0", PHP_INI_ALL, OnUpdateInt, magic_quotes_sybase, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("magic_quotes_gpc", "1", PHP_INI_ALL, OnUpdateInt, magic_quotes_gpc, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("magic_quotes_runtime", "0", PHP_INI_ALL, OnUpdateInt, magic_quotes_runtime, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("magic_quotes_sybase", "0", PHP_INI_ALL, OnUpdateInt, magic_quotes_sybase, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("safe_mode", "0", PHP_INI_SYSTEM, OnUpdateInt, safe_mode, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("sql.safe_mode", "0", PHP_INI_SYSTEM, OnUpdateInt, sql_safe_mode, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("safe_mode", "0", PHP_INI_SYSTEM, OnUpdateInt, safe_mode, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("sql.safe_mode", "0", PHP_INI_SYSTEM, OnUpdateInt, sql_safe_mode, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("safe_mode_exec_dir", "1", PHP_INI_SYSTEM, OnUpdateString, safe_mode_exec_dir, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateInt, enable_dl, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateInt, enable_dl, php_core_globals, core_globals)
PHP_INI_ENTRY("SMTP", "localhost", PHP_INI_ALL, NULL)
PHP_INI_ENTRY("sendmail_path", DEFAULT_SENDMAIL_PATH, PHP_INI_SYSTEM, NULL)
PHP_INI_ENTRY("sendmail_from", NULL, PHP_INI_ALL, NULL)
PHP_INI_ENTRY("error_reporting", NULL, PHP_INI_ALL, OnUpdateErrorReporting)
- STD_PHP_INI_ENTRY("display_errors", "1", PHP_INI_ALL, OnUpdateInt, display_errors, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("track_errors", "0", PHP_INI_ALL, OnUpdateInt, track_errors, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("log_errors", "0", PHP_INI_ALL, OnUpdateInt, log_errors, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("display_errors", "1", PHP_INI_ALL, OnUpdateInt, display_errors, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("track_errors", "0", PHP_INI_ALL, OnUpdateInt, track_errors, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("log_errors", "0", PHP_INI_ALL, OnUpdateInt, log_errors, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateString, error_log, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_ALL, OnUpdateString, auto_prepend_file, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("auto_append_file", NULL, PHP_INI_ALL, OnUpdateString, auto_append_file, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("y2k_compliance", "0", PHP_INI_ALL, OnUpdateInt, y2k_compliance, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("y2k_compliance", "0", PHP_INI_ALL, OnUpdateInt, y2k_compliance, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("doc_root", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, doc_root, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("user_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, user_dir, php_core_globals, core_globals)
@@ -233,12 +233,12 @@ PHP_INI_BEGIN()
PHP_INI_ENTRY("browscap", NULL, PHP_INI_SYSTEM, NULL)
- PHP_INI_ENTRY("define_syslog_variables", "0", PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY_EX("define_syslog_variables", "0", PHP_INI_ALL, NULL, php_ini_boolean_displayer_cb)
PHP_INI_ENTRY("max_execution_time", "30", PHP_INI_ALL, OnChangeMaxExecutionTime)
PHP_INI_ENTRY("memory_limit", "8388608", PHP_INI_ALL, OnChangeMemoryLimit)
- STD_PHP_INI_ENTRY("track_vars", "0", PHP_INI_ALL, OnUpdateInt, track_vars, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("track_vars", "0", PHP_INI_ALL, OnUpdateInt, track_vars, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("gpc_order", "GPC", PHP_INI_ALL, OnUpdateStringUnempty, gpc_order, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("arg_separator", "&", PHP_INI_ALL, OnUpdateStringUnempty, arg_separator, php_core_globals, core_globals)
PHP_INI_END()
@@ -771,6 +771,7 @@ int php_module_startup(sapi_module_struct *sf)
int module_number=0; /* for REGISTER_INI_ENTRIES() */
#ifdef ZTS
php_core_globals *core_globals;
+ sapi_globals_struct *sapi_globals = ts_resource(sapi_globals_id);
#endif
#if (WIN32|WINNT) && !(USE_SAPI)
WORD wVersionRequested;
@@ -779,6 +780,8 @@ int php_module_startup(sapi_module_struct *sf)
wVersionRequested = MAKEWORD(2, 0);
#endif
+ SG(server_context) = NULL;
+ sapi_activate(SLS_C);
if (module_initialized) {
return SUCCESS;
@@ -805,6 +808,7 @@ int php_module_startup(sapi_module_struct *sf)
#endif
PG(header_is_being_sent) = 0;
+ SG(request_info).headers_only = 0;
#if HAVE_SETLOCALE
setlocale(LC_CTYPE, "");
@@ -838,6 +842,7 @@ int php_module_startup(sapi_module_struct *sf)
return FAILURE;
}
module_initialized = 1;
+ sapi_deactivate(SLS_C);
return SUCCESS;
}
@@ -903,7 +908,7 @@ int _php3_hash_environment(PLS_D ELS_DC)
switch(*p++) {
case 'p':
case 'P':
- if (!_gpc_flags[0] && php3_headers_unsent() && request_info.request_method && !strcasecmp(request_info.request_method, "post")) {
+ if (!_gpc_flags[0] && !SG(headers_sent) && SG(request_info).request_method && !strcasecmp(SG(request_info).request_method, "POST")) {
php3_treat_data(PARSE_POST, NULL); /* POST Data */
_gpc_flags[0]=1;
}
diff --git a/main/php_ini.c b/main/php_ini.c
index 815b582cbd..fbe1ad0dab 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -34,6 +34,10 @@
#include "php_ini.h"
#include "zend_alloc.h"
#include "php_globals.h"
+#include "ext/standard/info.h"
+
+#define ENTRY_NAME_COLOR "#999999"
+#define CONTENTS_COLOR "#DDDDDD"
static HashTable known_directives;
@@ -93,7 +97,7 @@ int php_ini_rshutdown()
* Registration / unregistration
*/
-int php_register_ini_entries(php_ini_entry *ini_entry, int module_number)
+PHPAPI int php_register_ini_entries(php_ini_entry *ini_entry, int module_number)
{
php_ini_entry *p = ini_entry;
php_ini_entry *hashed_ini_entry;
@@ -126,13 +130,13 @@ int php_register_ini_entries(php_ini_entry *ini_entry, int module_number)
}
-void php_unregister_ini_entries(int module_number)
+PHPAPI void php_unregister_ini_entries(int module_number)
{
_php3_hash_apply_with_argument(&known_directives, (int (*)(void *, void *)) php_remove_ini_entries, (void *) &module_number);
}
-int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type)
+PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type)
{
php_ini_entry *ini_entry;
char *duplicate;
@@ -166,7 +170,7 @@ int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_
}
-int php_restore_ini_entry(char *name, uint name_length)
+PHPAPI int php_restore_ini_entry(char *name, uint name_length)
{
php_ini_entry *ini_entry;
@@ -182,11 +186,25 @@ int php_restore_ini_entry(char *name, uint name_length)
}
+PHPAPI int php_ini_register_displayer(char *name, uint name_length, void (*displayer)(php_ini_entry *ini_entry, int type))
+{
+ php_ini_entry *ini_entry;
+
+ if (_php3_hash_find(&known_directives, name, name_length, (void **) &ini_entry)==FAILURE) {
+ return FAILURE;
+ }
+
+ ini_entry->displayer = displayer;
+ return SUCCESS;
+}
+
+
+
/*
* Data retrieval
*/
-long php_ini_long(char *name, uint name_length, int orig)
+PHPAPI long php_ini_long(char *name, uint name_length, int orig)
{
php_ini_entry *ini_entry;
@@ -202,7 +220,7 @@ long php_ini_long(char *name, uint name_length, int orig)
}
-double php_ini_double(char *name, uint name_length, int orig)
+PHPAPI double php_ini_double(char *name, uint name_length, int orig)
{
php_ini_entry *ini_entry;
@@ -218,7 +236,7 @@ double php_ini_double(char *name, uint name_length, int orig)
}
-char *php_ini_string(char *name, uint name_length, int orig)
+PHPAPI char *php_ini_string(char *name, uint name_length, int orig)
{
php_ini_entry *ini_entry;
@@ -235,7 +253,101 @@ char *php_ini_string(char *name, uint name_length, int orig)
-/* Standard message handlers for core_globals */
+static void php_ini_displayer_cb(php_ini_entry *ini_entry, int type)
+{
+ if (ini_entry->displayer) {
+ ini_entry->displayer(ini_entry, type);
+ } else {
+ char *display_string;
+ uint display_string_length;
+
+ if (type==PHP_INI_DISPLAY_ORIG && ini_entry->orig_value) {
+ display_string = ini_entry->orig_value;
+ display_string_length = ini_entry->orig_value_length;
+ } else if (ini_entry->value && ini_entry->value[0]) {
+ display_string = ini_entry->value;
+ display_string_length = ini_entry->value_length;
+ } else {
+ display_string = "no value";
+ display_string_length = sizeof("no value")-1;
+ }
+ PHPWRITE(display_string, display_string_length);
+ }
+}
+
+
+PHP_INI_DISP(php_ini_boolean_displayer_cb)
+{
+ int value;
+
+ if (type==PHP_INI_DISPLAY_ORIG && ini_entry->orig_value) {
+ value = atoi(ini_entry->orig_value);
+ } else if (ini_entry->value) {
+ value = atoi(ini_entry->value);
+ } else {
+ value = 0;
+ }
+ if (value) {
+ PUTS("On");
+ } else {
+ PUTS("Off");
+ }
+}
+
+
+PHP_INI_DISP(php_ini_color_displayer_cb)
+{
+ char *value;
+
+ if (type==PHP_INI_DISPLAY_ORIG && ini_entry->orig_value) {
+ value = ini_entry->orig_value;
+ } else if (ini_entry->value) {
+ value = ini_entry->value;
+ } else {
+ value = NULL;
+ }
+ if (value) {
+ php3_printf("%s", value, value);
+ } else {
+ PUTS("no value;");
+ }
+}
+
+
+static int php_ini_displayer(php_ini_entry *ini_entry, int module_number)
+{
+ if (ini_entry->module_number != module_number) {
+ return 0;
+ }
+
+ PUTS("");
+ PHPWRITE(ini_entry->name, ini_entry->name_length-1);
+ PUTS(" | ");
+ php_ini_displayer_cb(ini_entry, PHP_INI_DISPLAY_ACTIVE);
+ PUTS(" | ");
+ php_ini_displayer_cb(ini_entry, PHP_INI_DISPLAY_ORIG);
+ PUTS(" |
\n");
+ return 0;
+}
+
+
+PHPAPI void display_ini_entries(zend_module_entry *module)
+{
+ int module_number;
+
+ if (module) {
+ module_number = module->module_number;
+ } else {
+ module_number = 0;
+ }
+ PUTS("\n");
+ php_info_print_table_header(3, "Directive", "Master Value", "Local Value");
+ zend_hash_apply_with_argument(&known_directives, (int (*)(void *, void *)) php_ini_displayer, (void *) module_number);
+ PUTS("
\n");
+}
+
+
+/* Standard message handlers */
PHP_INI_MH(OnUpdateInt)
{
diff --git a/main/php_ini.h b/main/php_ini.h
index f76dd83cbb..de9a994858 100644
--- a/main/php_ini.h
+++ b/main/php_ini.h
@@ -10,6 +10,7 @@
typedef struct _php_ini_entry php_ini_entry;
#define PHP_INI_MH(name) int name(php_ini_entry *entry, char *new_value, uint new_value_length, void *mh_arg1, void *mh_arg2, void *mh_arg3)
+#define PHP_INI_DISP(name) void name(php_ini_entry *ini_entry, int type)
struct _php_ini_entry {
int module_number;
@@ -27,6 +28,8 @@ struct _php_ini_entry {
char *orig_value;
uint orig_value_length;
int modified;
+
+ void (*displayer)(php_ini_entry *ini_entry, int type);
};
@@ -34,36 +37,57 @@ int php_ini_mstartup();
int php_ini_mshutdown();
int php_ini_rshutdown();
-int php_register_ini_entries(php_ini_entry *ini_entry, int module_number);
-void php_unregister_ini_entries(int module_number);
-int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type);
-int php_restore_ini_entry(char *name, uint name_length);
+PHPAPI int php_register_ini_entries(php_ini_entry *ini_entry, int module_number);
+PHPAPI void php_unregister_ini_entries(int module_number);
+PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type);
+PHPAPI int php_restore_ini_entry(char *name, uint name_length);
+PHPAPI void display_ini_entries(zend_module_entry *module);
+
+PHPAPI long php_ini_long(char *name, uint name_length, int orig);
+PHPAPI double php_ini_double(char *name, uint name_length, int orig);
+PHPAPI char *php_ini_string(char *name, uint name_length, int orig);
-long php_ini_long(char *name, uint name_length, int orig);
-double php_ini_double(char *name, uint name_length, int orig);
-char *php_ini_string(char *name, uint name_length, int orig);
+PHPAPI int php_ini_register_displayer(char *name, uint name_length, void (*displayer)(php_ini_entry *ini_entry, int type));
+PHPAPI PHP_INI_DISP(php_ini_boolean_displayer_cb);
+PHPAPI PHP_INI_DISP(php_ini_color_displayer_cb);
#define PHP_INI_BEGIN() static php_ini_entry ini_entries[] = {
-#define PHP_INI_END() { 0, 0, NULL, 0, NULL, NULL, NULL, 0, NULL, 0, 0 } };
+#define PHP_INI_END() { 0, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, NULL } };
+
+#define PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, arg2, arg3, displayer) \
+ { 0, modifyable, name, sizeof(name), on_modify, arg1, arg2, arg3, default_value, sizeof(default_value)-1, NULL, 0, 0, displayer },
#define PHP_INI_ENTRY3(name, default_value, modifyable, on_modify, arg1, arg2, arg3) \
- { 0, modifyable, name, sizeof(name), on_modify, arg1, arg2, arg3, default_value, sizeof(default_value)-1, NULL, 0, 0 },
+ PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, arg2, arg3, NULL)
+
+#define PHP_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, arg1, arg2, displayer) \
+ PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, arg2, NULL, displayer)
#define PHP_INI_ENTRY2(name, default_value, modifyable, on_modify, arg1, arg2) \
- PHP_INI_ENTRY3(name, default_value, modifyable, on_modify, arg1, arg2, NULL)
+ PHP_INI_ENTRY2_EX(name, default_value, modifyable, on_modify, arg1, arg2, NULL)
+
+#define PHP_INI_ENTRY1_EX(name, default_value, modifyable, on_modify, arg1, displayer) \
+ PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, arg1, NULL, NULL, displayer)
#define PHP_INI_ENTRY1(name, default_value, modifyable, on_modify, arg1) \
- PHP_INI_ENTRY3(name, default_value, modifyable, on_modify, arg1, NULL, NULL)
+ PHP_INI_ENTRY1_EX(name, default_value, modifyable, on_modify, arg1, NULL)
+#define PHP_INI_ENTRY_EX(name, default_value, modifyable, on_modify, displayer) \
+ PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, NULL, NULL, NULL, displayer)
+
#define PHP_INI_ENTRY(name, default_value, modifyable, on_modify) \
- PHP_INI_ENTRY3(name, default_value, modifyable, on_modify, NULL, NULL, NULL)
+ PHP_INI_ENTRY_EX(name, default_value, modifyable, on_modify, NULL)
#ifdef ZTS
#define STD_PHP_INI_ENTRY(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
PHP_INI_ENTRY2(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id)
+#define STD_PHP_INI_BOOLEAN(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
+ PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, NULL, php_ini_boolean_displayer_cb)
#else
#define STD_PHP_INI_ENTRY(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
PHP_INI_ENTRY2(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr)
+#define STD_PHP_INI_BOOLEAN(name, default_value, modifyable, on_modify, property_name, struct_type, struct_ptr) \
+ PHP_INI_ENTRY3_EX(name, default_value, modifyable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, NULL, php_ini_boolean_displayer_cb)
#endif
#define INI_INT(name) php_ini_long((name), sizeof(name), 0)
@@ -78,6 +102,10 @@ char *php_ini_string(char *name, uint name_length, int orig);
#define REGISTER_INI_ENTRIES() php_register_ini_entries(ini_entries, module_number)
#define UNREGISTER_INI_ENTRIES() php_unregister_ini_entries(module_number)
+#define DISPLAY_INI_ENTRIES() display_ini_entries(module)
+
+#define REGISTER_INI_DISPLAYER(name, displayer) php_ini_register_displayer((name), sizeof(name), displayer)
+#define REGISTER_INI_BOOLEAN(name) REGISTER_INI_DISPLAYER(name, php_ini_boolean_displayer_cb)
pval *cfg_get_entry(char *name, uint name_length);
@@ -88,4 +116,8 @@ PHP_INI_MH(OnUpdateReal);
PHP_INI_MH(OnUpdateString);
PHP_INI_MH(OnUpdateStringUnempty);
+
+#define PHP_INI_DISPLAY_ORIG 1
+#define PHP_INI_DISPLAY_ACTIVE 2
+
#endif /* _PHP_INI_H */
diff --git a/mod_php3.c b/mod_php3.c
index a102fe8f5f..01bdd8d73d 100644
--- a/mod_php3.c
+++ b/mod_php3.c
@@ -64,6 +64,8 @@ void php_module_shutdown();
void php_module_shutdown_for_exec();
int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals);
+int php3_error(int type, const char *format, ...);
+
#include "util_script.h"
#include "php_version.h"
@@ -118,6 +120,56 @@ static int zend_apache_ub_write(const char *str, uint str_length)
}
+char *sapi_apache_read_post(SLS_D)
+{
+ return NULL;
+}
+
+
+char *sapi_apache_read_cookies(SLS_D)
+{
+ return table_get(r->subprocess_env, "HTTP_COOKIE");
+}
+
+
+int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC)
+{
+ char *header_name, *header_content, *p;
+ request_rec *r = (request_rec *) SG(server_context);
+
+ header_name = sapi_header->header;
+
+ header_content = p = strchr(header_name, ':');
+ if (!p) {
+ return 0;
+ }
+
+ *p = 0;
+ do {
+ header_content++
+ } while (*header_content==' ');
+
+ if (!strcasecmp(header_name, "Content-Type")) {
+ r->content_type = pstrdup(header_content);
+ } else if (!strcasecmp(header_name, "Location")) {
+ r->status = REDIRECT;
+ } else {
+ table_set(r->headers_out, header_name, header_content);
+ }
+
+ *p = ':'; /* a well behaved header handler shouldn't change its original arguments */
+
+ return 0; /* don't use the default SAPI mechanism, Apache duplicates this functionality */
+}
+
+
+void sapi_apache_send_headers(sapi_headers_struct *sapi_headers SLS_DC)
+{
+ send_http_header((request_rec *) SG(server_context));
+ return SAPI_HEADER_SENT_SUCCESSFULLY;
+}
+
+
sapi_module_struct sapi_module = {
"PHP Language", /* name */
@@ -125,6 +177,15 @@ sapi_module_struct sapi_module = {
php_module_shutdown_wrapper, /* shutdown */
zend_apache_ub_write, /* unbuffered write */
+
+ php3_error, /* error handler */
+
+ sapi_apache_header_handler, /* header handler */
+ sapi_apache_send_headers, /* send headers handler */
+ NULL, /* send header handler */
+
+ sapi_apache_read_post, /* read POST data */
+ sapi_apache_read_cookies /* read Cookies */
};
diff --git a/request_info.c b/request_info.c
index ef8482772a..86a56f7c30 100644
--- a/request_info.c
+++ b/request_info.c
@@ -37,17 +37,11 @@ PHPAPI php3_request_info request_info;
#if CGI_BINARY
int php3_init_request_info(void *conf)
{
- char *buf; /* temporary buffers */
SLS_FETCH();
request_info.current_user = NULL;
request_info.current_user_length = 0;
- request_info.request_method = getenv("REQUEST_METHOD");
request_info.script_name = getenv("SCRIPT_NAME");
- buf = getenv("CONTENT_LENGTH");
- request_info.content_length = (buf ? atoi(buf) : 0);
- request_info.content_type = getenv("CONTENT_TYPE");
- request_info.cookies = getenv("HTTP_COOKIE");
request_info.script_filename = getenv("SCRIPT_FILENAME");
/* Hack for annoying servers that do not set SCRIPT_FILENAME for us */
if (!request_info.script_filename) {
@@ -110,13 +104,11 @@ int php3_init_request_info(void *conf)
request_info.current_user_length = 0;
request_info.filename = r->filename;
- request_info.request_method = r->method;
+ SG(request_info).request_method = r->method;
request_info.content_type = table_get(r->subprocess_env, "CONTENT_TYPE");
buf = table_get(r->subprocess_env, "CONTENT_LENGTH");
- request_info.content_length = (buf ? atoi(buf) : 0);
-
- request_info.cookies = table_get(r->subprocess_env, "HTTP_COOKIE");
+ SG(request_info).content_length = (buf ? atoi(buf) : 0);
return SUCCESS;
}
diff --git a/request_info.h b/request_info.h
index 2bcbfa7d77..51ff6606d2 100644
--- a/request_info.h
+++ b/request_info.h
@@ -32,14 +32,9 @@
typedef struct {
char *filename;
- char *path_info;
- const char *request_method;
char *script_name;
char *current_user;
int current_user_length;
- unsigned int content_length;
- const char *content_type;
- const char *cookies;
const char *script_filename;
char *php_argv0;
} php3_request_info;
--
cgit v1.2.1