]> granicus.if.org Git - php/commitdiff
make phpinfo() depend on executed sapi
authorMarcus Boerger <helly@php.net>
Tue, 18 Mar 2003 20:52:52 +0000 (20:52 +0000)
committerMarcus Boerger <helly@php.net>
Tue, 18 Mar 2003 20:52:52 +0000 (20:52 +0000)
ext/standard/info.c
main/SAPI.h
sapi/cli/php_cli.c

index bfafc1d558cf95bb043d7cd6a707a72c68877c7c..0b0a2b36de8049aefb097b3dfe85dabbbe9daee9 100644 (file)
@@ -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("<h2>" name "</h2>\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("<h2><a name=\"module_%s\">%s</a></h2>\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("<tr>");
                        php_printf("<td>");
                        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("<tr>");
                                PUTS("<td class=\"e\">");
 
@@ -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("</td><td class=\"v\">");
                        } else {
                                PUTS(" => ");
                        }
                        if (Z_TYPE_PP(tmp) == IS_ARRAY) {
-                               if (PG(html_errors)) {
+                               if (!sapi_module.phpinfo_as_text) {
                                        PUTS("<pre>");
                                }
                                zend_print_zval_r(*tmp, 0 TSRMLS_CC);
-                               if (PG(html_errors)) {
+                               if (!sapi_module.phpinfo_as_text) {
                                        PUTS("</pre>");
                                }
                        } 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("<i>no value</i>");
                                        } 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("<i>no value</i>");
                                        } 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("</td></tr>\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("<a href=\"http://www.php.net/\"><img border=\"0\" src=\"");
                        if (SG(request_info).request_uri) {
                                PUTS(SG(request_info).request_uri);
@@ -419,7 +419,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
                        }
                }
 
-               if (PG(html_errors)) {
+               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);
@@ -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("<a href=\"http://www.zend.com/\"><img border=\"0\" src=\"");
                        if (SG(request_info).request_uri) {
                                PUTS(SG(request_info).request_uri);
@@ -513,13 +513,13 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
                        PUTS("?="ZEND_LOGO_GUID"\" alt=\"Zend logo\" /></a>\n");
                }
                PUTS("This program makes use of the Zend Scripting Language Engine:");
-               PUTS(PG(html_errors)?"<br />":"\n");
+               PUTS(!sapi_module.phpinfo_as_text?"<br />":"\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("<h1><a href=\"");
                if (SG(request_info).request_uri) {
@@ -534,7 +534,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
 
        if (flag & PHP_INFO_CONFIGURATION) {
                php_info_print_hr();
-               if (PG(html_errors)) {
+               if (!sapi_module.phpinfo_as_text) {
                        PUTS("<h1>Configuration</h1>\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("<p>\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("</div></body></html>");
        }       
 }
@@ -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("<table border=\"0\" cellpadding=\"3\" width=\"600\">\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("</table><br />\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("<tr class=\"h\"><td>\n");
                }
        } else {
-               if (PG(html_errors)) {
+               if (!sapi_module.phpinfo_as_text) {
                        php_printf("<tr class=\"v\"><td>\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("</td></tr>\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("<hr />\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("<tr class=\"h\"><th colspan=\"%d\">%s</th></tr>\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("<tr class=\"h\">");
        }       
        for (i=0; i<num_cols; i++) {
@@ -745,7 +733,7 @@ PHPAPI void php_info_print_table_header(int num_cols, ...)
                if (!row_element || !*row_element) {
                        row_element = " ";
                }
-               if (PG(html_errors)) {
+               if (!sapi_module.phpinfo_as_text) {
                        PUTS("<th>");
                        PUTS(row_element);
                        PUTS("</th>");
@@ -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("</tr>\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("<tr>");
        }       
        for (i=0; i<num_cols; i++) {
-               if (PG(html_errors)) {
+               if (!sapi_module.phpinfo_as_text) {
                        php_printf("<td class=\"%s\">",
                           (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( "<i>no value</i>" );
                        } 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(" </td>");
                } else if (i == (num_cols - 1)) {
                        PUTS("\n");
                }
        }
-       if (PG(html_errors)) {
+       if (!sapi_module.phpinfo_as_text) {
                php_printf("</tr>\n");
        }
        
index 865ab752a7192091d9170d8629cb4720eb25c784..63e3534b06ee82fc94b7083ca7558776ecf7ed9f 100644 (file)
@@ -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;
 };
 
 
index 2a8c7b5468834f7b07d49113778b306ba192efac..9b1c64c8ea16642f1006f2c1806dea8fa0a4aec0 100644 (file)
@@ -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