From: Colin Viebrock Date: Wed, 5 Apr 2000 20:17:02 +0000 (+0000) Subject: Prettying up the output of phpinfo(). Someone has to tell me how X-Git-Tag: php-4.0RC2~480 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ddc9ff852b8698fd395ff771c6aa214d9543d9a;p=php Prettying up the output of phpinfo(). Someone has to tell me how to get a new .gif logo in there, and why the ZEND_DEBUG output is causing seg faults. I also need to go through all the modules and fix up the output they create. --- diff --git a/ext/standard/info.c b/ext/standard/info.c index ce240fc96a..8ced2aefbb 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -30,9 +30,9 @@ #define PHP_CONF_LONG(directive,value1,value2) \ - php_printf("%s%ld%ld\n",directive,value1,value2); + php_printf("%s
%ld
%ld
\n",directive,value1,value2); -#define SECTION(name) PUTS("

" name "

\n") +#define SECTION(name) PUTS("

" name "

\n") #define CREDIT_LINE(module, authors) php_info_print_table_row(2, module, authors) @@ -42,12 +42,13 @@ static int _display_module_info(zend_module_entry *module, void *arg) int show_info_func = *((int *) arg); if (show_info_func && module->info_func) { - php_printf("

%s

\n", module->name, module->name); + php_printf("

%s

\n", module->name, module->name); module->info_func(module); } else if (!show_info_func && !module->info_func) { - php_printf(""); + php_printf(""); + php_printf(""); php_printf(module->name); - php_printf("\n"); + php_printf("\n"); } return 0; } @@ -73,7 +74,8 @@ static void php_print_gpcse_array(char *name, uint name_length ELS_DC) } else { value_ptr = *tmp; } - PUTS(""); + PUTS(""); + PUTS(""); PUTS(name); PUTS("[\""); switch (zend_hash_get_current_key((*data)->value.ht, &string_key, &num_key)) { @@ -85,15 +87,15 @@ static void php_print_gpcse_array(char *name, uint name_length ELS_DC) php_printf("%ld",num_key); break; } - PUTS("\"]"); + PUTS("\"]"); if ((*tmp)->type == IS_ARRAY) { - PUTS("
");
+				PUTS("
");
 				zend_print_zval_r(*tmp, 0);
-				PUTS("
"); + PUTS("
"); } else { PUTS(value_ptr->value.str.val); } - PUTS("\n"); + PUTS("\n"); zend_hash_move_forward((*data)->value.ht); if (value_ptr==&tmp2) { zval_dtor(value_ptr); @@ -102,12 +104,25 @@ static void php_print_gpcse_array(char *name, uint name_length ELS_DC) } } +void php_info_print_style() +{ + php_printf("\n"); +} + PHPAPI void php_print_info(int flag) { char **env,*tmp1,*tmp2; char *php_uname; int expose_php = INI_INT("expose_php"); + #ifdef PHP_WIN32 char php_windows_uname[256]; DWORD dwBuild=0; @@ -133,32 +148,40 @@ PHPAPI void php_print_info(int flag) php_uname=PHP_UNAME; #endif + php_info_print_style(); - php_printf("

PHP Version %s

\n", PHP_VERSION); - - PUTS("
"); + php_info_print_box_start(1); if (expose_php) { PUTS("
\n"); + PUTS("?=PHPE9568F34-D428-11d2-A769-00AA001ACF42\" border=0 align=\"right\">"); } - php_printf("System: %s
Build Date: %s\n
", php_uname, __DATE__); + php_printf("

PHP Version %s

\n", 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__ ); #ifdef CONFIGURE_COMMAND - php_printf("Configure command: %s
\n", CONFIGURE_COMMAND); + php_info_print_table_row(2, "Configure Command", CONFIGURE_COMMAND ); #endif - php_printf("php.ini path: %s
\n", CONFIGURATION_FILE_PATH); - php_printf("ZEND_DEBUG=%d
\n", ZEND_DEBUG); + php_info_print_table_row(2, "php.ini Path", CONFIGURATION_FILE_PATH ); +/* why does this cause seg faults? + php_info_print_table_row(2, "ZEND_DEBUG", ZEND_DEBUG ); +*/ if (sapi_module.name) - php_printf("SAPI=%s
\n", sapi_module.name); + php_info_print_table_row(2, "SAPI", sapi_module.name ); #ifdef ZTS - php_printf("ZTS is defined"); + php_info_print_table_row(2, "ZTS", "defined" ); #else - php_printf("ZTS is undefined"); + php_info_print_table_row(2, "ZTS", "undefined" ); #endif + php_info_print_table_end(); + /* Zend Engine */ - PUTS("
"); + php_info_print_box_start(0); if (expose_php) { PUTS("\n"); } php_printf("This program makes use of the Zend scripting language engine:
%s
", get_zend_version()); + php_info_print_box_end(); } - PUTS("
"); - if ((flag & PHP_INFO_CREDITS) && expose_php) { - PUTS("
"); + php_info_print_hr(); PUTS(""); - PUTS("

PHP 4.0 Credits

\n"); + PUTS("

PHP 4.0 Credits

"); PUTS("
\n"); } if (flag & PHP_INFO_CONFIGURATION) { - PUTS("

Configuration

\n"); - PUTS("

PHP Core

\n"); + php_info_print_hr(); + PUTS("

Configuration

\n"); + SECTION("PHP Core\n"); display_ini_entries(NULL); } @@ -196,15 +219,15 @@ PHPAPI void php_print_info(int flag) zend_hash_apply_with_argument(&module_registry, (int (*)(void *, void *)) _display_module_info, &show_info_func); SECTION("Additional Modules"); - PUTS("\n"); + php_info_print_table_start(); show_info_func = 0; zend_hash_apply_with_argument(&module_registry, (int (*)(void *, void *)) _display_module_info, &show_info_func); - PUTS("
\n"); + php_info_print_table_end(); } if (flag & PHP_INFO_ENVIRONMENT) { SECTION("Environment"); - PUTS("\n"); + php_info_print_table_start(); php_info_print_table_header(2, "Variable", "Value"); for (env=environ; env!=NULL && *env !=NULL; env++) { tmp1 = estrdup(*env); @@ -217,7 +240,7 @@ PHPAPI void php_print_info(int flag) php_info_print_table_row(2, tmp1, tmp2); efree(tmp1); } - PUTS("
\n"); + php_info_print_table_end(); } if (flag & PHP_INFO_VARIABLES) { @@ -225,7 +248,7 @@ PHPAPI void php_print_info(int flag) SECTION("PHP Variables"); - PUTS("\n"); + php_info_print_table_start(); php_info_print_table_header(2, "Variable", "Value"); if (zend_hash_find(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void **) &data) != FAILURE) { php_info_print_table_row(2, "PHP_SELF", (*data)->value.str.val); @@ -245,7 +268,7 @@ PHPAPI void php_print_info(int flag) php_print_gpcse_array("HTTP_COOKIE_VARS", sizeof("HTTP_COOKIE_VARS")-1 ELS_CC); php_print_gpcse_array("HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS")-1 ELS_CC); php_print_gpcse_array("HTTP_ENV_VARS", sizeof("HTTP_ENV_VARS")-1 ELS_CC); - PUTS("
\n"); + php_info_print_table_end(); } PUTS("
"); @@ -253,16 +276,22 @@ PHPAPI void php_print_info(int flag) if (flag & PHP_INFO_LICENSE) { SECTION("PHP License"); - PUTS("
This program is free software; you can redistribute it and/or modify\n");
-		PUTS("it under the terms of the PHP License as published by the PHP Group\n");
+		php_info_print_box_start(0);
+		PUTS("

\n"); + PUTS("This program is free software; you can redistribute it and/or modify "); + PUTS("it under the terms of the PHP License as published by the PHP Group "); PUTS("and included in the distribution in the file: LICENSE\n"); - PUTS("\n"); - PUTS("This program is distributed in the hope that it will be useful,\n"); - PUTS("but WITHOUT ANY WARRANTY; without even the implied warranty of\n"); + PUTS("

\n"); + PUTS("

"); + PUTS("This program is distributed in the hope that it will be useful, "); + PUTS("but WITHOUT ANY WARRANTY; without even the implied warranty of "); PUTS("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"); - PUTS("\n"); - PUTS("If you did not receive a copy of the PHP license, or have any questions about\n"); - PUTS("PHP licensing, please contact license@php.net.

\n"); + PUTS("

\n"); + PUTS("

"); + PUTS("If you did not receive a copy of the PHP license, or have any questions about "); + PUTS("PHP licensing, please contact license@php.net.\n"); + PUTS("

\n"); + php_info_print_box_end(); } } @@ -273,37 +302,41 @@ void php_print_credits(int flag) PUTS("PHP Credits
\n"); } + php_info_print_style(); + PUTS("

PHP 4.0 Credits

\n"); if (flag & PHP_CREDITS_GROUP) { /* Group */ - PUTS("\n"); + php_info_print_table_start(); php_info_print_table_header(1, "PHP Group"); php_info_print_table_row(1, "Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, \ Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski"); - PUTS("
\n"); + php_info_print_table_end(); } if (flag & PHP_CREDITS_GENERAL) { /* Language */ - PUTS("\n"); - PUTS("\n"); + php_info_print_table_start(); + PUTS(""); + PUTS("\n"); php_info_print_table_header(2, "Contribution", "Authors"); CREDIT_LINE("Zend Scripting Language Engine", "Andi Gutmans, Zeev Suraski"); CREDIT_LINE("Extension Module API", "Andi Gutmans, Zeev Suraski"); CREDIT_LINE("UNIX Build and Modularization", "Stig Bakken, Sascha Schumann"); CREDIT_LINE("Win32 Port", "Shane Caraveo, Zeev Suraski"); CREDIT_LINE("Server API (SAPI) Abstraction Layer", "Andi Gutmans, Shane Caraveo, Zeev Suraski"); - PUTS("
PHP 4.0 Authors
PHP 4.0 Authors
\n"); + php_info_print_table_end(); } if (flag & PHP_CREDITS_GENERAL) { /* SAPI Modules */ - PUTS("\n"); - PUTS("\n"); + php_info_print_table_start(); + PUTS(""); + PUTS("\n"); php_info_print_table_header(2, "Contribution", "Authors"); CREDIT_LINE("Apache", "Rasmus Lerdorf, Zeev Suraski"); CREDIT_LINE("ISAPI", "Andi Gutmans, Zeev Suraski"); @@ -312,14 +345,15 @@ void php_print_credits(int flag) CREDIT_LINE("Java Servlet", "Sam Ruby"); CREDIT_LINE("Roxen", "David Hedbor"); CREDIT_LINE("thttpd", "Sascha Schumann"); - PUTS("
SAPI Modules
SAPI Module
\n"); + php_info_print_table_end(); } if (flag & PHP_CREDITS_MODULES) { /* Modules */ - PUTS("\n"); - PUTS("\n"); + php_info_print_table_start(); + PUTS(""); + PUTS("\n"); php_info_print_table_header(2, "Module", "Authors"); CREDIT_LINE("Apache", "Rasmus Lerdorf, Stig Bakken, David Sklar"); CREDIT_LINE("Assert", "Thies C. Arntzen"); @@ -363,7 +397,7 @@ void php_print_credits(int flag) CREDIT_LINE("XML", "Stig Bakken, Thies C. Arntzen"); CREDIT_LINE("Yellow Pages", "Stephanie Wehner"); CREDIT_LINE("Zlib", "Rasmus Lerdorf, Stefan Roehrich"); - PUTS("
Module Authors
Module Authors
\n"); + php_info_print_table_end(); } if (flag & PHP_CREDITS_DOCS) { @@ -375,6 +409,41 @@ void php_print_credits(int flag) } } +PHPAPI void php_info_print_table_start() +{ + php_printf("
\n"); + php_printf("\n"); +} + +PHPAPI void php_info_print_table_end() +{ + php_printf("

\n"); + php_printf("
\n"); + +} + +PHPAPI void php_info_print_box_start(int flag) +{ + php_info_print_table_start(); + if (flag) { + php_printf("\n"); + } else { + php_printf("\n"); + } +} + +PHPAPI void php_info_print_box_end() +{ + php_printf("\n"); + php_info_print_table_end(); +} + +PHPAPI void php_info_print_hr() +{ + php_printf("
\n"); +} + + PHPAPI void php_info_print_table_header(int num_cols, ...) { @@ -384,15 +453,15 @@ PHPAPI void php_info_print_table_header(int num_cols, ...) va_start(row_elements, num_cols); - php_printf(""); + php_printf(""); for (i=0; i%s", row_element); + php_printf("%s", row_element); } - php_printf("\n"); + php_printf("\n"); va_end(row_elements); } @@ -402,22 +471,23 @@ PHPAPI void php_info_print_table_row(int num_cols, ...) { int i; va_list row_elements; - char *color = PHP_ENTRY_NAME_COLOR; char *row_element; va_start(row_elements, num_cols); - php_printf(""); + php_printf(""); for (i=0; i%s%s%s", - color, (i==0?"":""), row_element, (i==0?"":"")); - color = PHP_CONTENTS_COLOR; + php_printf("%s%s%s", + (i==0?" BGCOLOR=\"" PHP_ENTRY_NAME_COLOR "\" ":""), + (i==0?"":""), + row_element, + (i==0?"":"")); } - php_printf("\n"); + php_printf("\n"); va_end(row_elements); } diff --git a/ext/standard/info.h b/ext/standard/info.h index eaf7f38c6d..3094585b1a 100644 --- a/ext/standard/info.h +++ b/ext/standard/info.h @@ -32,9 +32,9 @@ #ifndef _INFO_H #define _INFO_H -#define PHP_ENTRY_NAME_COLOR "#FFFFFF" -#define PHP_CONTENTS_COLOR "#DDDDDD" -#define PHP_HEADER_COLOR "#FFFF99" +#define PHP_ENTRY_NAME_COLOR "#CCCCFF" +#define PHP_CONTENTS_COLOR "#CCCCCC" +#define PHP_HEADER_COLOR "#9999CC" #define PHP_INFO_GENERAL (1<<0) #define PHP_INFO_CREDITS (1<<1) @@ -64,10 +64,14 @@ PHP_FUNCTION(php_logo_guid); PHP_FUNCTION(zend_logo_guid); PHPAPI void php_print_info(int flag); PHPAPI void php_print_credits(int flag); - - +PHPAPI void php_print_style(void); PHPAPI void php_info_print_table_header(int num_cols, ...); PHPAPI void php_info_print_table_row(int num_cols, ...); +PHPAPI void php_info_print_table_start(void); +PHPAPI void php_info_print_table_end(void); +PHPAPI void php_info_print_box_start(int bg); +PHPAPI void php_info_print_box_end(void); +PHPAPI void php_info_print_hr(void); void register_phpinfo_constants(INIT_FUNC_ARGS); diff --git a/main/php_ini.c b/main/php_ini.c index a49a3c9e28..55c51a357b 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -359,13 +359,14 @@ static int php_ini_displayer(php_ini_entry *ini_entry, int module_number) return 0; } - PUTS(""); + PUTS(""); + 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("\n"); + PUTS("\n"); return 0; } @@ -379,10 +380,10 @@ PHPAPI void display_ini_entries(zend_module_entry *module) } else { module_number = 0; } - PUTS("\n"); + php_info_print_table_start(); php_info_print_table_header(3, "Directive", "Local Value", "Master Value"); zend_hash_apply_with_argument(&known_directives, (int (*)(void *, void *)) php_ini_displayer, (void *) (long) module_number); - PUTS("
\n"); + php_info_print_table_end(); }