📄 php_apache.c
字号:
/* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2007 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | | Stig S鎡her Bakken <ssb@fast.no> | | David Sklar <sklar@student.net> | +----------------------------------------------------------------------+ *//* $Id: php_apache.c,v 1.69.2.5.4.4 2007/03/05 21:59:02 stas Exp $ */#include "php_apache_http.h"#if defined(PHP_WIN32) || defined(NETWARE)#include "zend.h"#include "ap_compat.h"#endif#ifdef ZTSint php_apache_info_id;#elsephp_apache_info_struct php_apache_info;#endif#define SECTION(name) PUTS("<h2>" name "</h2>\n")extern module *top_module;PHP_FUNCTION(virtual);PHP_FUNCTION(apache_request_headers);PHP_FUNCTION(apache_response_headers);PHP_FUNCTION(apachelog);PHP_FUNCTION(apache_note);PHP_FUNCTION(apache_lookup_uri);PHP_FUNCTION(apache_child_terminate);PHP_FUNCTION(apache_setenv);PHP_FUNCTION(apache_get_version);PHP_MINFO_FUNCTION(apache);function_entry apache_functions[] = { PHP_FE(virtual, NULL) PHP_FE(apache_request_headers, NULL) PHP_FE(apache_note, NULL) PHP_FE(apache_lookup_uri, NULL) PHP_FE(apache_child_terminate, NULL) PHP_FE(apache_setenv, NULL) PHP_FE(apache_response_headers, NULL) PHP_FE(apache_get_version, NULL) PHP_FALIAS(getallheaders, apache_request_headers, NULL) {NULL, NULL, NULL}};PHP_INI_BEGIN() STD_PHP_INI_ENTRY("xbithack", "0", PHP_INI_ALL, OnUpdateInt, xbithack, php_apache_info_struct, php_apache_info) STD_PHP_INI_ENTRY("engine", "1", PHP_INI_ALL, OnUpdateInt, engine, php_apache_info_struct, php_apache_info) STD_PHP_INI_ENTRY("last_modified", "0", PHP_INI_ALL, OnUpdateInt, last_modified, php_apache_info_struct, php_apache_info) STD_PHP_INI_ENTRY("child_terminate", "0", PHP_INI_ALL, OnUpdateInt, terminate_child, php_apache_info_struct, php_apache_info)PHP_INI_END()static void php_apache_globals_ctor(php_apache_info_struct *apache_globals TSRMLS_DC){ apache_globals->in_request = 0;}static PHP_MINIT_FUNCTION(apache){#ifdef ZTS ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL);#else php_apache_globals_ctor(&php_apache_info TSRMLS_CC);#endif REGISTER_INI_ENTRIES(); return SUCCESS;}static PHP_MSHUTDOWN_FUNCTION(apache){ UNREGISTER_INI_ENTRIES(); return SUCCESS;}zend_module_entry apache_module_entry = { STANDARD_MODULE_HEADER, "apache", apache_functions, PHP_MINIT(apache), PHP_MSHUTDOWN(apache), NULL, NULL, PHP_MINFO(apache), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES};/* {{{ proto bool apache_child_terminate(void) Terminate apache process after this request */PHP_FUNCTION(apache_child_terminate){#ifndef MULTITHREAD if (AP(terminate_child)) { ap_child_terminate( ((request_rec *)SG(server_context)) ); RETURN_TRUE; } else { /* tell them to get lost! */ php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function is disabled"); RETURN_FALSE; }#else php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function is not supported in this build"); RETURN_FALSE;#endif}/* }}} *//* {{{ proto string apache_note(string note_name [, string note_value]) Get and set Apache request notes */PHP_FUNCTION(apache_note){ pval **arg_name, **arg_val; char *note_val; int arg_count = ARG_COUNT(ht); if (arg_count<1 || arg_count>2 || zend_get_parameters_ex(arg_count, &arg_name, &arg_val) ==FAILURE ) { WRONG_PARAM_COUNT; } convert_to_string_ex(arg_name); note_val = (char *) table_get(((request_rec *)SG(server_context))->notes, (*arg_name)->value.str.val); if (arg_count == 2) { convert_to_string_ex(arg_val); table_set(((request_rec *)SG(server_context))->notes, (*arg_name)->value.str.val, (*arg_val)->value.str.val); } if (note_val) { RETURN_STRING(note_val, 1); } else { RETURN_FALSE; }}/* }}} *//* {{{ PHP_MINFO_FUNCTION */PHP_MINFO_FUNCTION(apache){ char *apv = (char *) ap_get_server_version(); module *modp = NULL; char output_buf[128];#if !defined(WIN32) && !defined(WINNT) char name[64]; char modulenames[1024]; char *p;#endif server_rec *serv; extern char server_root[MAX_STRING_LEN]; extern uid_t user_id; extern char *user_name; extern gid_t group_id; extern int max_requests_per_child; serv = ((request_rec *) SG(server_context))->server; php_info_print_table_start();#ifdef PHP_WIN32 php_info_print_table_row(1, "Apache for Windows 95/NT"); php_info_print_table_end(); php_info_print_table_start();#elif defined(NETWARE) php_info_print_table_row(1, "Apache for NetWare"); php_info_print_table_end(); php_info_print_table_start();#else php_info_print_table_row(2, "APACHE_INCLUDE", PHP_APACHE_INCLUDE); php_info_print_table_row(2, "APACHE_TARGET", PHP_APACHE_TARGET);#endif if (apv && *apv) { php_info_print_table_row(2, "Apache Version", apv); } #ifdef APACHE_RELEASE sprintf(output_buf, "%d", APACHE_RELEASE); php_info_print_table_row(2, "Apache Release", output_buf);#endif sprintf(output_buf, "%d", MODULE_MAGIC_NUMBER); php_info_print_table_row(2, "Apache API Version", output_buf); snprintf(output_buf, sizeof(output_buf), "%s:%u", serv->server_hostname, serv->port); php_info_print_table_row(2, "Hostname:Port", output_buf);#if !defined(WIN32) && !defined(WINNT) snprintf(output_buf, sizeof(output_buf), "%s(%d)/%d", user_name, (int)user_id, (int)group_id); php_info_print_table_row(2, "User/Group", output_buf); sprintf(output_buf, "Per Child: %d - Keep Alive: %s - Max Per Connection: %d", max_requests_per_child, serv->keep_alive ? "on":"off", serv->keep_alive_max); php_info_print_table_row(2, "Max Requests", output_buf);#endif sprintf(output_buf, "Connection: %d - Keep-Alive: %d", serv->timeout, serv->keep_alive_timeout); php_info_print_table_row(2, "Timeouts", output_buf);#if !defined(WIN32) && !defined(WINNT)/* This block seems to be working on NetWare; But it seems to be showing all modules instead of just the loaded ones*/ php_info_print_table_row(2, "Server Root", server_root); strcpy(modulenames, ""); for(modp = top_module; modp; modp = modp->next) { strlcpy(name, modp->name, sizeof(name)); if ((p = strrchr(name, '.'))) { *p='\0'; /* Cut off ugly .c extensions on module names */ } strlcat(modulenames, name, sizeof(modulenames)); if (modp->next) { strlcat(modulenames, ", ", sizeof(modulenames)); } } php_info_print_table_row(2, "Loaded Modules", modulenames);#endif php_info_print_table_end(); DISPLAY_INI_ENTRIES(); { register int i; array_header *arr; table_entry *elts; request_rec *r; r = ((request_rec *) SG(server_context)); arr = table_elts(r->subprocess_env); elts = (table_entry *)arr->elts; SECTION("Apache Environment"); php_info_print_table_start(); php_info_print_table_header(2, "Variable", "Value"); for (i=0; i < arr->nelts; i++) { php_info_print_table_row(2, elts[i].key, elts[i].val); } php_info_print_table_end(); } { array_header *env_arr; table_entry *env; int i; request_rec *r;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -