summaryrefslogtreecommitdiff
path: root/sapi/apache2handler/php_functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'sapi/apache2handler/php_functions.c')
-rw-r--r--sapi/apache2handler/php_functions.c125
1 files changed, 115 insertions, 10 deletions
diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c
index 20547424be..6015d2ba77 100644
--- a/sapi/apache2handler/php_functions.c
+++ b/sapi/apache2handler/php_functions.c
@@ -21,6 +21,8 @@
#include "php.h"
#include "ext/standard/php_smart_str.h"
#include "ext/standard/info.h"
+#include "ext/standard/head.h"
+#include "php_ini.h"
#include "SAPI.h"
#define CORE_PRIVATE
@@ -37,9 +39,20 @@
#include "http_main.h"
#include "util_script.h"
#include "http_core.h"
+#if !defined(WIN32) && !defined(WINNT)
+#include "unixd.h"
+#endif
#include "php_apache.h"
+#ifdef ZTS
+int php_apache2_info_id;
+#else
+php_apache2_info_struct php_apache2_info;
+#endif
+
+#define SECTION(name) PUTS("<h2>" name "</h2>\n")
+
static request_rec *php_apache_lookup_uri(char *filename TSRMLS_DC)
{
php_struct *ctx;
@@ -52,7 +65,7 @@ static request_rec *php_apache_lookup_uri(char *filename TSRMLS_DC)
return ap_sub_req_lookup_uri(filename, ctx->r, ctx->r->output_filters);
}
-/* proto bool virtual(string uri)
+/* {{{ proto bool virtual(string uri)
Perform an apache sub-request */
PHP_FUNCTION(virtual)
{
@@ -89,7 +102,7 @@ PHP_FUNCTION(virtual)
ap_destroy_sub_req(rr);
RETURN_TRUE;
}
-/* */
+/* }}} */
#define ADD_LONG(name) \
add_property_long(return_value, #name, rr->name)
@@ -153,7 +166,7 @@ PHP_FUNCTION(apache_lookup_uri)
RETURN_FALSE;
}
-/* proto array getallheaders(void)
+/* {{{ proto array getallheaders(void)
Fetch all HTTP request headers */
PHP_FUNCTION(apache_request_headers)
{
@@ -171,7 +184,7 @@ PHP_FUNCTION(apache_request_headers)
add_assoc_string(return_value, key, val, 1);
APR_ARRAY_FOREACH_CLOSE()
}
-/* */
+/* }}} */
/* {{{ proto array apache_response_headers(void)
Fetch all HTTP response headers */
@@ -236,7 +249,7 @@ PHP_FUNCTION(apache_setenv)
php_struct *ctx;
zval **variable=NULL, **string_val=NULL, **walk_to_top=NULL;
int arg_count = ZEND_NUM_ARGS();
- request_rec *r;
+ request_rec *r;
if (arg_count<1 || arg_count>3 ||
zend_get_parameters_ex(arg_count, &variable, &string_val, &walk_to_top) == FAILURE) {
@@ -272,7 +285,7 @@ PHP_FUNCTION(apache_getenv)
zval **variable=NULL, **walk_to_top=NULL;
int arg_count = ZEND_NUM_ARGS();
char *env_val=NULL;
- request_rec *r;
+ request_rec *r;
if (arg_count<1 || arg_count>2 ||
zend_get_parameters_ex(arg_count, &variable, &walk_to_top) == FAILURE) {
@@ -281,7 +294,7 @@ PHP_FUNCTION(apache_getenv)
ctx = SG(server_context);
- r = ctx->r;
+ r = ctx->r;
if (arg_count == 2 && Z_STRVAL_PP(walk_to_top)) {
while(r->prev) {
r = r->prev;
@@ -342,8 +355,15 @@ PHP_MINFO_FUNCTION(apache)
{
char *apv = php_apache_get_version();
smart_str tmp1 = {0};
+ char tmp[1024];
int n;
char *p;
+ server_rec *serv = ((php_struct *) SG(server_context))->r->server;
+#if !defined(WIN32) && !defined(WINNT)
+ AP_DECLARE_DATA extern unixd_config_rec unixd_config;
+#endif
+ extern int ap_max_requests_per_child;
+ AP_DECLARE_DATA extern const char *ap_server_root;
for (n = 0; ap_loaded_modules[n]; ++n) {
char *s = (char *) ap_loaded_modules[n]->name;
@@ -362,9 +382,76 @@ PHP_MINFO_FUNCTION(apache)
if (apv && *apv) {
php_info_print_table_row(2, "Apache Version", apv);
}
+ sprintf(tmp, "%d", MODULE_MAGIC_NUMBER);
+ php_info_print_table_row(2, "Apache API Version", tmp);
+
+ if (serv->server_admin && *(serv->server_admin)) {
+ php_info_print_table_row(2, "Servert Administrator", serv->server_admin);
+ }
+
+ sprintf(tmp, "%s:%u", serv->server_hostname, serv->port);
+ php_info_print_table_row(2, "Hostname:Port", tmp);
+
+#if !defined(WIN32) && !defined(WINNT)
+ sprintf(tmp, "%s(%d)/%d", unixd_config.user_name, unixd_config.user_id, unixd_config.group_id);
+ php_info_print_table_row(2, "User/Group", tmp);
+#endif
+
+ sprintf(tmp, "Per Child: %d - Keep Alive: %s - Max Per Connection: %d", ap_max_requests_per_child, (serv->keep_alive ? "on":"off"), serv->keep_alive_max);
+ php_info_print_table_row(2, "Max Requests", tmp);
+
+ sprintf(tmp, "Connection: %lld - Keep-Alive: %lld", (serv->timeout / 1000000), (serv->keep_alive_timeout / 1000000));
+ php_info_print_table_row(2, "Timeouts", tmp);
+
+ php_info_print_table_row(2, "Virtual Server", (serv->is_virtual ? "Yes" : "No"));
+ php_info_print_table_row(2, "Server Root", ap_server_root);
php_info_print_table_row(2, "Loaded Modules", tmp1.c);
+
smart_str_free(&tmp1);
php_info_print_table_end();
+
+ DISPLAY_INI_ENTRIES();
+
+ {
+ const apr_array_header_t *arr = apr_table_elts(((php_struct *) SG(server_context))->r->subprocess_env);
+ char *key, *val;
+
+ SECTION("Apache Environment");
+ php_info_print_table_start();
+ php_info_print_table_header(2, "Variable", "Value");
+ APR_ARRAY_FOREACH_OPEN(arr, key, val)
+ if (!val) {
+ val = empty_string;
+ }
+ php_info_print_table_row(2, key, val);
+ APR_ARRAY_FOREACH_CLOSE()
+
+ php_info_print_table_end();
+
+ SECTION("HTTP Headers Information");
+ php_info_print_table_start();
+ php_info_print_table_colspan_header(2, "HTTP Request Headers");
+ php_info_print_table_row(2, "HTTP Request", ((php_struct *) SG(server_context))->r->the_request);
+
+ arr = apr_table_elts(((php_struct *) SG(server_context))->r->headers_in);
+ APR_ARRAY_FOREACH_OPEN(arr, key, val)
+ if (!val) {
+ val = empty_string;
+ }
+ php_info_print_table_row(2, key, val);
+ APR_ARRAY_FOREACH_CLOSE()
+
+ php_info_print_table_colspan_header(2, "HTTP Response Headers");
+ arr = apr_table_elts(((php_struct *) SG(server_context))->r->headers_out);
+ APR_ARRAY_FOREACH_OPEN(arr, key, val)
+ if (!val) {
+ val = empty_string;
+ }
+ php_info_print_table_row(2, key, val);
+ APR_ARRAY_FOREACH_CLOSE()
+
+ php_info_print_table_end();
+ }
}
static function_entry apache_functions[] = {
@@ -381,14 +468,32 @@ static function_entry apache_functions[] = {
{NULL, NULL, NULL}
};
+PHP_INI_BEGIN()
+ STD_PHP_INI_ENTRY("xbithack", "0", PHP_INI_ALL, OnUpdateInt, xbithack, php_apache2_info_struct, php_apache2_info)
+ STD_PHP_INI_ENTRY("engine", "1", PHP_INI_ALL, OnUpdateInt, engine, php_apache2_info_struct, php_apache2_info)
+ STD_PHP_INI_ENTRY("last_modified", "0", PHP_INI_ALL, OnUpdateInt, last_modified, php_apache2_info_struct, php_apache2_info)
+PHP_INI_END()
+
+static PHP_MINIT_FUNCTION(apache)
+{
+ REGISTER_INI_ENTRIES();
+ return SUCCESS;
+}
+
+static PHP_MSHUTDOWN_FUNCTION(apache)
+{
+ UNREGISTER_INI_ENTRIES();
+ return SUCCESS;
+}
+
zend_module_entry php_apache_module = {
STANDARD_MODULE_HEADER,
"Apache 2.0",
apache_functions,
+ PHP_MINIT(apache),
+ PHP_MSHUTDOWN(apache),
NULL,
- NULL,
- NULL,
- NULL,
+ NULL,
PHP_MINFO(apache),
NULL,
STANDARD_MODULE_PROPERTIES