📄 info.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@php.net> | | Zeev Suraski <zeev@zend.com> | | Colin Viebrock <colin@easydns.com> | +----------------------------------------------------------------------+*//* $Id: info.c,v 1.218.2.18.2.9 2007/01/01 09:46:48 sebastian Exp $ */#include "php.h"#include "php_ini.h"#include "php_globals.h"#include "ext/standard/head.h"#include "ext/standard/html.h"#include "info.h"#include "credits.h"#include "css.h"#include "SAPI.h"#include <time.h>#include "php_main.h"#include "zend_globals.h" /* needs ELS */#include "zend_extensions.h"#include "zend_highlight.h"#ifdef HAVE_SYS_UTSNAME_H#include <sys/utsname.h>#endif#if HAVE_MBSTRING#include "ext/mbstring/mbstring.h"ZEND_EXTERN_MODULE_GLOBALS(mbstring)#endif#if HAVE_ICONV#include "ext/iconv/php_iconv.h"ZEND_EXTERN_MODULE_GLOBALS(iconv)#endif#define SECTION(name) if (!sapi_module.phpinfo_as_text) { \ PUTS("<h2>" name "</h2>\n"); \ } else { \ php_info_print_table_start(); \ php_info_print_table_header(1, name); \ php_info_print_table_end(); \ } \PHPAPI extern char *php_ini_opened_path;PHPAPI extern char *php_ini_scanned_files; static int php_info_write_wrapper(const char *str, uint str_length){ int new_len, written; char *elem_esc; TSRMLS_FETCH(); elem_esc = php_escape_html_entities((char *)str, str_length, &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC); written = php_body_write(elem_esc, new_len TSRMLS_CC); efree(elem_esc); return written;}/* {{{ _display_module_info */static int _display_module_info(zend_module_entry *module, void *arg TSRMLS_DC){ int show_info_func = *((int *) arg); if (show_info_func && module->info_func) { if (!sapi_module.phpinfo_as_text) { php_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", module->name, module->name); } else { php_info_print_table_start(); php_info_print_table_header(1, module->name); php_info_print_table_end(); } module->info_func(module TSRMLS_CC); } else if (!show_info_func && !module->info_func) { if (!sapi_module.phpinfo_as_text) { php_printf("<tr>"); php_printf("<td>"); php_printf("%s", module->name); php_printf("</td></tr>\n"); } else { php_printf("%s", module->name); php_printf("\n"); } } return 0;}/* }}} *//* {{{ php_print_gpcse_array */static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC){ zval **data, **tmp, tmp2; char *string_key; uint string_len; ulong num_key; char *elem_esc = NULL; if (zend_hash_find(&EG(symbol_table), name, name_length+1, (void **) &data)!=FAILURE && (Z_TYPE_PP(data)==IS_ARRAY)) { zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data)); while (zend_hash_get_current_data(Z_ARRVAL_PP(data), (void **) &tmp) == SUCCESS) { if (!sapi_module.phpinfo_as_text) { PUTS("<tr>"); PUTS("<td class=\"e\">"); } PUTS(name); PUTS("[\""); switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL)) { case HASH_KEY_IS_STRING: if (!sapi_module.phpinfo_as_text) { elem_esc = php_info_html_esc(string_key TSRMLS_CC); PUTS(elem_esc); efree(elem_esc); } else { PUTS(string_key); } break; case HASH_KEY_IS_LONG: php_printf("%ld", num_key); break; } PUTS("\"]"); if (!sapi_module.phpinfo_as_text) { PUTS("</td><td class=\"v\">"); } else { PUTS(" => "); } if (Z_TYPE_PP(tmp) == IS_ARRAY) { if (!sapi_module.phpinfo_as_text) { PUTS("<pre>"); zend_print_zval_r_ex((zend_write_func_t) php_info_write_wrapper, *tmp, 0); PUTS("</pre>"); } else { zend_print_zval_r(*tmp, 0); } } else if (Z_TYPE_PP(tmp) != IS_STRING) { tmp2 = **tmp; zval_copy_ctor(&tmp2); convert_to_string(&tmp2); if (!sapi_module.phpinfo_as_text) { if (Z_STRLEN(tmp2) == 0) { PUTS("<i>no value</i>"); } else { elem_esc = php_info_html_esc(Z_STRVAL(tmp2) TSRMLS_CC); PUTS(elem_esc); efree(elem_esc); } } else { PUTS(Z_STRVAL(tmp2)); } zval_dtor(&tmp2); } else { if (!sapi_module.phpinfo_as_text) { if (Z_STRLEN_PP(tmp) == 0) { PUTS("<i>no value</i>"); } else { elem_esc = php_info_html_esc(Z_STRVAL_PP(tmp) TSRMLS_CC); PUTS(elem_esc); efree(elem_esc); } } else { PUTS(Z_STRVAL_PP(tmp)); } } if (!sapi_module.phpinfo_as_text) { PUTS("</td></tr>\n"); } else { PUTS("\n"); } zend_hash_move_forward(Z_ARRVAL_PP(data)); } }}/* }}} *//* {{{ php_info_print_style */void php_info_print_style(){ php_printf("<style type=\"text/css\">\n"); php_info_print_css(); php_printf("</style>\n");}/* }}} *//* {{{ php_info_html_esc */PHPAPI char *php_info_html_esc(char *string TSRMLS_DC){ int new_len; return php_escape_html_entities(string, strlen(string), &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);}/* }}} *//* {{{ php_get_uname */PHPAPI char *php_get_uname(char mode){ char *php_uname; char tmp_uname[256];#ifdef PHP_WIN32 DWORD dwBuild=0; DWORD dwVersion = GetVersion(); DWORD dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1; char ComputerName[MAX_COMPUTERNAME_LENGTH + 1]; SYSTEM_INFO SysInfo; GetComputerName(ComputerName, &dwSize); GetSystemInfo(&SysInfo); if (mode == 's') { if (dwVersion < 0x80000000) { php_uname = "Windows NT"; } else { php_uname = "Windows 9x"; } } else if (mode == 'r') { snprintf(tmp_uname, sizeof(tmp_uname), "%d.%d", dwWindowsMajorVersion, dwWindowsMinorVersion); php_uname = tmp_uname; } else if (mode == 'n') { php_uname = ComputerName; } else if (mode == 'v') { dwBuild = (DWORD)(HIWORD(dwVersion)); snprintf(tmp_uname, sizeof(tmp_uname), "build %d", dwBuild); php_uname = tmp_uname; } else if (mode == 'm') { switch (SysInfo.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_INTEL : snprintf(tmp_uname, sizeof(tmp_uname), "i%d", SysInfo.dwProcessorType); php_uname = tmp_uname; break; case PROCESSOR_ARCHITECTURE_MIPS : php_uname = "MIPS R4000"; php_uname = tmp_uname; break; case PROCESSOR_ARCHITECTURE_ALPHA : snprintf(tmp_uname, sizeof(tmp_uname), "Alpha %d", SysInfo.wProcessorLevel); php_uname = tmp_uname; break; case PROCESSOR_ARCHITECTURE_PPC : snprintf(tmp_uname, sizeof(tmp_uname), "PPC 6%02d", SysInfo.wProcessorLevel); php_uname = tmp_uname; break; case PROCESSOR_ARCHITECTURE_IA64 : php_uname = "IA64"; break;#if defined(PROCESSOR_ARCHITECTURE_IA32_ON_WIN64) case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 : php_uname = "IA32"; break;#endif#if defined(PROCESSOR_ARCHITECTURE_AMD64) case PROCESSOR_ARCHITECTURE_AMD64 : php_uname = "AMD64"; break;#endif case PROCESSOR_ARCHITECTURE_UNKNOWN : default : php_uname = "Unknown"; break; } } else { /* assume mode == 'a' */ /* Get build numbers for Windows NT or Win95 */ if (dwVersion < 0x80000000){ dwBuild = (DWORD)(HIWORD(dwVersion)); snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %d.%d build %d", "Windows NT", ComputerName, dwWindowsMajorVersion, dwWindowsMinorVersion, dwBuild); } else { snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %d.%d", "Windows 9x", ComputerName, dwWindowsMajorVersion, dwWindowsMinorVersion); } php_uname = tmp_uname; }#else#ifdef HAVE_SYS_UTSNAME_H struct utsname buf; if (uname((struct utsname *)&buf) == -1) { php_uname = PHP_UNAME; } else { if (mode == 's') { php_uname = buf.sysname; } else if (mode == 'r') { php_uname = buf.release; } else if (mode == 'n') { php_uname = buf.nodename; } else if (mode == 'v') { php_uname = buf.version; } else if (mode == 'm') { php_uname = buf.machine; } else { /* assume mode == 'a' */ snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %s %s %s", buf.sysname, buf.nodename, buf.release, buf.version, buf.machine); php_uname = tmp_uname; } }#else php_uname = PHP_UNAME;#endif#endif return estrdup(php_uname);}/* }}} *//* {{{ php_print_info_htmlhead */PHPAPI void php_print_info_htmlhead(TSRMLS_D){/*** none of this is needed now *** const char *charset = NULL; if (SG(default_charset)) { charset = SG(default_charset); }#if HAVE_MBSTRING if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) { if (MBSTRG(current_http_output_encoding) == mbfl_no_encoding_pass) { charset = "US-ASCII"; } else { charset = mbfl_no2preferred_mime_name(MBSTRG(current_http_output_encoding)); } }#endif#if HAVE_ICONV if (php_ob_handler_used("ob_iconv_handler" TSRMLS_CC)) { charset = ICONVG(output_encoding); }#endif if (!charset || !charset[0]) { charset = "US-ASCII"; }*** none of that is needed now ***/ PUTS("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n"); PUTS("<html>"); PUTS("<head>\n"); php_info_print_style(); PUTS("<title>phpinfo()</title>"); PUTS("<meta name=\"ROBOTS\" content=\"NOINDEX,NOFOLLOW,NOARCHIVE\" />");/* php_printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\" />\n", charset);*/ PUTS("</head>\n"); PUTS("<body><div class=\"center\">\n");}/* }}} *//* {{{ module_name_cmp */static int module_name_cmp(const void *a, const void *b TSRMLS_DC){ Bucket *f = *((Bucket **) a); Bucket *s = *((Bucket **) b); return strcmp(((zend_module_entry *)f->pData)->name, ((zend_module_entry *)s->pData)->name);}/* }}} *//* {{{ php_print_info */PHPAPI void php_print_info(int flag TSRMLS_DC){ char **env, *tmp1, *tmp2; char *php_uname; int expose_php = INI_INT("expose_php"); time_t the_time; struct tm *ta, tmbuf; the_time = time(NULL); ta = php_localtime_r(&the_time, &tmbuf); if (!sapi_module.phpinfo_as_text) { php_print_info_htmlhead(TSRMLS_C); } else { PUTS("phpinfo()\n"); } if (flag & PHP_INFO_GENERAL) { char *zend_version = get_zend_version(); char temp_api[9]; php_uname = php_get_uname('a'); if (!sapi_module.phpinfo_as_text) { php_info_print_box_start(1); } if (expose_php && !sapi_module.phpinfo_as_text) { PUTS("<a href=\"http://www.php.net/\"><img border=\"0\" src=\""); if (SG(request_info).request_uri) { char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC); PUTS(elem_esc); efree(elem_esc); } if ((ta->tm_mon==3) && (ta->tm_mday==1)) { PUTS("?="PHP_EGG_LOGO_GUID"\" alt=\"Nadia!\" /></a>"); } else { PUTS("?="PHP_LOGO_GUID"\" alt=\"PHP Logo\" /></a>"); } } if (!sapi_module.phpinfo_as_text) { php_printf("<h1 class=\"p\">PHP Version %s</h1>\n", PHP_VERSION); } else { php_info_print_table_row(2, "PHP Version", PHP_VERSION); } php_info_print_box_end(); php_info_print_table_start(); php_info_print_table_row(2, "System", php_uname ); php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__ );#ifdef CONFIGURE_COMMAND php_info_print_table_row(2, "Configure Command", CONFIGURE_COMMAND );#endif if (sapi_module.pretty_name) { php_info_print_table_row(2, "Server API", sapi_module.pretty_name ); }#ifdef VIRTUAL_DIR php_info_print_table_row(2, "Virtual Directory Support", "enabled" );#else php_info_print_table_row(2, "Virtual Directory Support", "disabled" );#endif php_info_print_table_row(2, "Configuration File (php.ini) Path", php_ini_opened_path?php_ini_opened_path:PHP_CONFIG_FILE_PATH); if(strlen(PHP_CONFIG_FILE_SCAN_DIR)) { php_info_print_table_row(2, "Scan this dir for additional .ini files", PHP_CONFIG_FILE_SCAN_DIR); if(php_ini_scanned_files) { php_info_print_table_row(2, "additional .ini files parsed", php_ini_scanned_files); } } snprintf(temp_api, sizeof(temp_api), "%d", PHP_API_VERSION); php_info_print_table_row(2, "PHP API", temp_api); snprintf(temp_api, sizeof(temp_api), "%d", ZEND_MODULE_API_NO); php_info_print_table_row(2, "PHP Extension", temp_api); snprintf(temp_api, sizeof(temp_api), "%d", ZEND_EXTENSION_API_NO); php_info_print_table_row(2, "Zend Extension", temp_api);#if ZEND_DEBUG php_info_print_table_row(2, "Debug Build", "yes" );#else php_info_print_table_row(2, "Debug Build", "no" );#endif#if USE_ZEND_ALLOC php_info_print_table_row(2, "Zend Memory Manager", "enabled" );#else php_info_print_table_row(2, "Zend Memory Manager", "disabled" );#endif#ifdef ZTS php_info_print_table_row(2, "Thread Safety", "enabled" );#else php_info_print_table_row(2, "Thread Safety", "disabled" );#endif { HashTable *url_stream_wrappers_hash; char *stream_protocol, *stream_protocols_buf = NULL; int stream_protocol_len, stream_protocols_buf_len = 0; ulong num_key; if ((url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash())) { for (zend_hash_internal_pointer_reset(url_stream_wrappers_hash); zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING; zend_hash_move_forward(url_stream_wrappers_hash)) { if (NULL == (stream_protocols_buf = erealloc(stream_protocols_buf, stream_protocols_buf_len + stream_protocol_len + 2 /* ", " */ + 1 /* 0 byte at end */))) { break; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -