From dc5ed5a3fb392333e3bee899f84fe832fc5aae68 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Tue, 11 May 1999 00:43:46 +0000 Subject: [PATCH] beatify Apache's info func --- ext/apache/apache.c | 36 ++++++++++++++++++++++++------------ ext/standard/info.c | 30 +++++++++++++----------------- ext/standard/info.h | 4 ++++ main/main.c | 1 - main/php_ini.c | 9 +++------ 5 files changed, 44 insertions(+), 36 deletions(-) diff --git a/ext/apache/apache.c b/ext/apache/apache.c index b174262060..8a1b29bd2c 100644 --- a/ext/apache/apache.c +++ b/ext/apache/apache.c @@ -36,6 +36,7 @@ #include "php_ini.h" #include "SAPI.h" #include "mod_php3.h" +#include "ext/standard/info.h" #include #if HAVE_UNISTD_H @@ -157,6 +158,7 @@ void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS) void php3_info_apache(ZEND_MODULE_INFO_FUNC_ARGS) { module *modp = NULL; + char output_buf[128]; #if !defined(WIN32) && !defined(WINNT) char name[64]; char *p; @@ -171,27 +173,36 @@ void php3_info_apache(ZEND_MODULE_INFO_FUNC_ARGS) serv = ((request_rec *) SG(server_context))->server; + PUTS("\n"); + php_info_print_table_header(2, "Entry", "Value"); #if WIN32|WINNT PUTS("Apache for Windows 95/NT
"); #else - php3_printf("APACHE_INCLUDE=%s
\n", PHP_APACHE_INCLUDE); - php3_printf("APACHE_TARGET=%s
\n", PHP_APACHE_TARGET); + php_info_print_table_row(2, "APACHE_INCLUDE", PHP_APACHE_INCLUDE); + php_info_print_table_row(2, "APACHE_TARGET", PHP_APACHE_TARGET); #endif - php3_printf("Apache Version: %s
",SERVER_VERSION); + php_info_print_table_row(2, "Apache Version", SERVER_VERSION); #ifdef APACHE_RELEASE - php3_printf("Apache Release: %d
",APACHE_RELEASE); + sprintf(output_buf, "%d", APACHE_RELEASE); + php_info_print_table_row(2, "Apache Release", output_buf); #endif - php3_printf("Apache API Version: %d
",MODULE_MAGIC_NUMBER); - php3_printf("Hostname/port: %s:%u
\n",serv->server_hostname,serv->port); + sprintf(output_buf, "%d", MODULE_MAGIC_NUMBER); + php_info_print_table_row(2, "Apache API Version", output_buf); + sprintf(output_buf, "%s:%u", serv->server_hostname,serv->port); + php_info_print_table_row(2, "Hostname/Port", output_buf); #if !defined(WIN32) && !defined(WINNT) - php3_printf("User/Group: %s(%d)/%d
\n",user_name,(int)user_id,(int)group_id); - php3_printf("Max Requests: per child: %d    keep alive: %s    max per connection: %d
\n",max_requests_per_child,serv->keep_alive ? "on":"off", serv->keep_alive_max); + sprintf(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 - php3_printf("Timeouts: connection: %d    keep-alive: %d
",serv->timeout,serv->keep_alive_timeout); + 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) - php3_printf("Server Root: %s
\n",server_root); + php_info_print_table_row(2, "Server Root", server_root); - PUTS("Loaded modules: "); + + PUTS("\n"); + PUTS("
Loaded modules"); for(modp = top_module; modp; modp = modp->next) { strncpy(name, modp->name, sizeof(name) - 1); if ((p = strrchr(name, '.'))) { @@ -203,7 +214,8 @@ void php3_info_apache(ZEND_MODULE_INFO_FUNC_ARGS) } } #endif - PUTS("
\n"); + PUTS("
\n"); } /* This function is equivalent to diff --git a/ext/standard/info.c b/ext/standard/info.c index 70b3a05457..bb09033794 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -41,14 +41,10 @@ #define PHP3_CONF_LONG(directive,value1,value2) \ - php3_printf("%s%ld%ld\n",directive,value1,value2); + php3_printf("%s%ld%ld\n",directive,value1,value2); #define SECTION(name) PUTS("

" name "

\n") -#define ENTRY_NAME_COLOR "#999999" -#define CONTENTS_COLOR "#DDDDDD" -#define HEADER_COLOR "#00DDDD" - #define CREDIT_LINE(module, authors) php_info_print_table_row(2, module, authors) @@ -115,7 +111,7 @@ PHPAPI void _php3_info(void) PUTS("

Credits

\n"); PUTS("\n"); - PUTS("\n"); + PUTS("\n"); php_info_print_table_header(2, "Module", "Authors"); CREDIT_LINE("Scripting Language Engine", "Andi Gutmans, Zeev Suraski"); CREDIT_LINE("Extension Module API", "Andi Gutmans, Zeev Suraski"); @@ -182,7 +178,7 @@ PHPAPI void _php3_info(void) _php3_hash_internal_pointer_reset((*data)->value.ht); while (_php3_hash_get_current_data((*data)->value.ht, (void **) &tmp) == SUCCESS) { convert_to_string(*tmp); - PUTS("\n"); _php3_hash_move_forward((*data)->value.ht); @@ -202,7 +198,7 @@ PHPAPI void _php3_info(void) _php3_hash_internal_pointer_reset((*data)->value.ht); while (_php3_hash_get_current_data((*data)->value.ht, (void **) &tmp) == SUCCESS) { convert_to_string(*tmp); - PUTS("\n"); _php3_hash_move_forward((*data)->value.ht); @@ -222,7 +218,7 @@ PHPAPI void _php3_info(void) _php3_hash_internal_pointer_reset((*data)->value.ht); while (_php3_hash_get_current_data((*data)->value.ht, (void **) &tmp) == SUCCESS) { convert_to_string(*tmp); - PUTS("\n"); _php3_hash_move_forward((*data)->value.ht); @@ -274,7 +270,7 @@ PHPAPI void _php3_info(void) r = ((request_rec *) SG(server_context)); SECTION("HTTP Headers Information"); PUTS("
PHP 4.0 Authors
PHP 4.0 Authors
HTTP_GET_VARS[\""); + PUTS("
HTTP_GET_VARS[\""); switch (_php3_hash_get_current_key((*data)->value.ht, &string_key, &num_key)) { case HASH_KEY_IS_STRING: PUTS(string_key); @@ -192,7 +188,7 @@ PHPAPI void _php3_info(void) php3_printf("%ld",num_key); break; } - PUTS("\"]"); + PUTS("\"]"); PUTS((*tmp)->value.str.val); /* This could be "Array" - too ugly to expand that for now */ PUTS("
HTTP_POST_VARS[\""); + PUTS("
HTTP_POST_VARS[\""); switch (_php3_hash_get_current_key((*data)->value.ht, &string_key, &num_key)) { case HASH_KEY_IS_STRING: PUTS(string_key); @@ -212,7 +208,7 @@ PHPAPI void _php3_info(void) php3_printf("%ld",num_key); break; } - PUTS("\"]"); + PUTS("\"]"); PUTS((*tmp)->value.str.val); PUTS("
HTTP_COOKIE_VARS[\""); + PUTS("
HTTP_COOKIE_VARS[\""); switch (_php3_hash_get_current_key((*data)->value.ht, &string_key, &num_key)) { case HASH_KEY_IS_STRING: PUTS(string_key); @@ -232,7 +228,7 @@ PHPAPI void _php3_info(void) php3_printf("%ld",num_key); break; } - PUTS("\"]"); + PUTS("\"]"); PUTS((*tmp)->value.str.val); PUTS("
\n"); - PUTS(" \n"); + 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; @@ -283,7 +279,7 @@ PHPAPI void _php3_info(void) php_info_print_table_row(2, env[i].key, env[i].val); } } - PUTS(" \n"); + PUTS(" \n"); env_arr = table_elts(r->headers_out); env = (table_entry *)env_arr->elts; for(i = 0; i < env_arr->nelts; ++i) { @@ -335,7 +331,7 @@ PHPAPI void php_info_print_table_header(int num_cols, ...) if (!row_element || !*row_element) { row_element = " "; } - php3_printf("", row_element); + php3_printf("", row_element); } php3_printf("\n"); @@ -347,7 +343,7 @@ PHPAPI void php_info_print_table_row(int num_cols, ...) { int i; va_list row_elements; - char *color = ENTRY_NAME_COLOR; + char *color = PHP_ENTRY_NAME_COLOR; char *row_element; va_start(row_elements, num_cols); @@ -359,7 +355,7 @@ PHPAPI void php_info_print_table_row(int num_cols, ...) row_element = " "; } php3_printf("", color, row_element); - color = CONTENTS_COLOR; + color = PHP_CONTENTS_COLOR; } php3_printf("\n"); diff --git a/ext/standard/info.h b/ext/standard/info.h index 73db458108..3384f0155a 100644 --- a/ext/standard/info.h +++ b/ext/standard/info.h @@ -32,6 +32,10 @@ #ifndef _INFO_H #define _INFO_H +#define PHP_ENTRY_NAME_COLOR "#999999" +#define PHP_CONTENTS_COLOR "#DDDDDD" +#define PHP_HEADER_COLOR "#00DDDD" + void php3_version(INTERNAL_FUNCTION_PARAMETERS); void php3_info(INTERNAL_FUNCTION_PARAMETERS); PHPAPI void _php3_info(void); diff --git a/main/main.c b/main/main.c index 006032f498..831d3431f2 100644 --- a/main/main.c +++ b/main/main.c @@ -921,7 +921,6 @@ int _php3_hash_environment(PLS_D ELS_DC) case 'g': case 'G': if (!_gpc_flags[2]) { - printf("Parsing GET data: '%s'\n", SG(request_info).query_string); php3_treat_data(PARSE_GET, NULL); /* GET Data */ _gpc_flags[2]=1; } diff --git a/main/php_ini.c b/main/php_ini.c index fbe1ad0dab..56f48f1c66 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -36,9 +36,6 @@ #include "php_globals.h" #include "ext/standard/info.h" -#define ENTRY_NAME_COLOR "#999999" -#define CONTENTS_COLOR "#DDDDDD" - static HashTable known_directives; @@ -320,11 +317,11 @@ static int php_ini_displayer(php_ini_entry *ini_entry, int module_number) return 0; } - PUTS("\n"); return 0; -- 2.40.0
HTTP Request Headers
HTTP Request Headers
HTTP Response Headers
HTTP Response Headers
%s%s
%s
"); + PUTS("
"); PHPWRITE(ini_entry->name, ini_entry->name_length-1); - PUTS(""); + PUTS(""); php_ini_displayer_cb(ini_entry, PHP_INI_DISPLAY_ACTIVE); - PUTS(""); + PUTS(""); php_ini_displayer_cb(ini_entry, PHP_INI_DISPLAY_ORIG); PUTS("