From: Marcus Boerger Date: Tue, 18 Mar 2003 20:52:52 +0000 (+0000) Subject: make phpinfo() depend on executed sapi X-Git-Tag: RELEASE_0_5~421 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e621fac945a519f6c4b19bb2cd4a4618df8eb1f;p=php make phpinfo() depend on executed sapi --- diff --git a/ext/standard/info.c b/ext/standard/info.c index bfafc1d558..0b0a2b36de 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -48,7 +48,7 @@ ZEND_EXTERN_MODULE_GLOBALS(mbstring) ZEND_EXTERN_MODULE_GLOBALS(iconv) #endif -#define SECTION(name) if (PG(html_errors)) { \ +#define SECTION(name) if (!sapi_module.phpinfo_as_text) { \ PUTS("

" name "

\n"); \ } else { \ php_info_print_table_start(); \ @@ -66,7 +66,7 @@ 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 (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf("

%s

\n", module->name, module->name); } else { php_info_print_table_start(); @@ -75,7 +75,7 @@ static int _display_module_info(zend_module_entry *module, void *arg TSRMLS_DC) } module->info_func(module TSRMLS_CC); } else if (!show_info_func && !module->info_func) { - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf(""); php_printf(""); php_printf("%s", module->name); @@ -105,7 +105,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC) && (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 (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { PUTS(""); PUTS(""); @@ -116,7 +116,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC) 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 (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { elem_esc = php_info_html_esc(string_key TSRMLS_CC); PUTS(elem_esc); efree(elem_esc); @@ -129,24 +129,24 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC) break; } PUTS("\"]"); - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { PUTS(""); } else { PUTS(" => "); } if (Z_TYPE_PP(tmp) == IS_ARRAY) { - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { PUTS("
");
 				}
 				zend_print_zval_r(*tmp, 0 TSRMLS_CC);
-				if (PG(html_errors)) {
+				if (!sapi_module.phpinfo_as_text) {
 					PUTS("
"); } } else if (Z_TYPE_PP(tmp) != IS_STRING) { tmp2 = **tmp; zval_copy_ctor(&tmp2); convert_to_string(&tmp2); - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { if (Z_STRLEN(tmp2) == 0) { PUTS("no value"); } else { @@ -159,7 +159,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC) } zval_dtor(&tmp2); } else { - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { if (Z_STRLEN_PP(tmp) == 0) { PUTS("no value"); } else { @@ -171,7 +171,7 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC) PUTS(Z_STRVAL_PP(tmp)); } } - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { PUTS("\n"); } else { PUTS("\n"); @@ -391,7 +391,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) the_time = time(NULL); ta = php_localtime_r(&the_time, &tmbuf); - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_print_info_htmlhead(TSRMLS_C); } else { PUTS("phpinfo()\n"); @@ -403,11 +403,11 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) php_uname = php_get_uname('a'); - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_info_print_box_start(1); } - if (expose_php && PG(html_errors)) { + if (expose_php && !sapi_module.phpinfo_as_text) { PUTS("PHP Version %s\n", PHP_VERSION); } else { php_info_print_table_row(2, "PHP Version", PHP_VERSION); @@ -505,7 +505,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) /* Zend Engine */ php_info_print_box_start(0); - if (expose_php && PG(html_errors)) { + if (expose_php && !sapi_module.phpinfo_as_text) { PUTS("\"Zend\n"); } PUTS("This program makes use of the Zend Scripting Language Engine:"); - PUTS(PG(html_errors)?"
":"\n"); + PUTS(!sapi_module.phpinfo_as_text?"
":"\n"); zend_html_puts(zend_version, strlen(zend_version) TSRMLS_CC); php_info_print_box_end(); efree(php_uname); } - if ((flag & PHP_INFO_CREDITS) && expose_php && PG(html_errors)) { + if ((flag & PHP_INFO_CREDITS) && expose_php && !sapi_module.phpinfo_as_text) { php_info_print_hr(); PUTS("

Configuration

\n"); } else { SECTION("Configuration"); @@ -613,7 +613,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) } if (flag & PHP_INFO_LICENSE) { - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { SECTION("PHP License"); php_info_print_box_start(0); PUTS("

\n"); @@ -645,7 +645,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) PUTS("questions about PHP licensing, please contact license@php.net.\n"); } } - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { PUTS(""); } } @@ -654,9 +654,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) PHPAPI void php_info_print_table_start() { - TSRMLS_FETCH(); - - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf("\n"); } else { php_printf("\n"); @@ -665,9 +663,7 @@ PHPAPI void php_info_print_table_start() PHPAPI void php_info_print_table_end() { - TSRMLS_FETCH(); - - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf("

\n"); } @@ -675,15 +671,13 @@ PHPAPI void php_info_print_table_end() PHPAPI void php_info_print_box_start(int flag) { - TSRMLS_FETCH(); - php_info_print_table_start(); if (flag) { - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf("\n"); } } else { - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf("\n"); } else { php_printf("\n"); @@ -693,9 +687,7 @@ PHPAPI void php_info_print_box_start(int flag) PHPAPI void php_info_print_box_end() { - TSRMLS_FETCH(); - - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf("\n"); } php_info_print_table_end(); @@ -703,9 +695,7 @@ PHPAPI void php_info_print_box_end() PHPAPI void php_info_print_hr() { - TSRMLS_FETCH(); - - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf("


\n"); } else { php_printf("\n\n _______________________________________________________________________\n\n"); @@ -716,9 +706,7 @@ PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header) { int spaces; - TSRMLS_FETCH(); - - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf("%s\n", num_cols, header ); } else { spaces = (74 - strlen(header)); @@ -737,7 +725,7 @@ PHPAPI void php_info_print_table_header(int num_cols, ...) TSRMLS_FETCH(); va_start(row_elements, num_cols); - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf(""); } for (i=0; i"); PUTS(row_element); PUTS(""); @@ -758,7 +746,7 @@ PHPAPI void php_info_print_table_header(int num_cols, ...) } } } - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf("\n"); } @@ -781,24 +769,24 @@ PHPAPI void php_info_print_table_row(int num_cols, ...) TSRMLS_FETCH(); va_start(row_elements, num_cols); - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf(""); } for (i=0; i", (i==0 ? "e" : "v" ) ); } row_element = va_arg(row_elements, char *); if (!row_element || !*row_element) { - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { PUTS( "no value" ); } else { PUTS( " " ); } } else { - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { elem_esc = php_info_html_esc(row_element TSRMLS_CC); PUTS(elem_esc); efree(elem_esc); @@ -809,13 +797,13 @@ PHPAPI void php_info_print_table_row(int num_cols, ...) } } } - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf(" "); } else if (i == (num_cols - 1)) { PUTS("\n"); } } - if (PG(html_errors)) { + if (!sapi_module.phpinfo_as_text) { php_printf("\n"); } diff --git a/main/SAPI.h b/main/SAPI.h index 865ab752a7..63e3534b06 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -243,6 +243,7 @@ struct _sapi_module_struct { unsigned int (*input_filter)(int arg, char *var, char **val, unsigned int val_len TSRMLS_DC); void (*ini_defaults)(HashTable *configuration_hash); + int phpinfo_as_text; }; diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 2a8c7b5468..9b1c64c8ea 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -549,6 +549,7 @@ int main(int argc, char *argv[]) #endif cli_sapi_module.ini_defaults = sapi_cli_ini_defaults; + cli_sapi_module.phpinfo_as_text = 1; sapi_startup(&cli_sapi_module); #ifdef PHP_WIN32