static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type) { if (ini_entry->displayer) { ini_entry->displayer(ini_entry, type); } else { char *display_string; uint display_string_length, esc_html=0; if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) { if (ini_entry->orig_value) { display_string = ini_entry->orig_value; display_string_length = ini_entry->orig_value_length; esc_html=1; } else { display_string = "<i>no value</i>"; display_string_length = sizeof("<i>no value</i>")-1; } } else if (ini_entry->value && ini_entry->value[0]) { display_string = ini_entry->value; display_string_length = ini_entry->value_length; esc_html=1; } else { display_string = "<i>no value</i>"; display_string_length = sizeof("<i>no value</i>")-1; } if(esc_html) { zend_html_puts(display_string, display_string_length); } else { PHPWRITE(display_string, display_string_length); } } }
PHPAPI void php_info_print_table_row(int num_cols, ...) { int i; va_list row_elements; char *row_element; va_start(row_elements, num_cols); php_printf("<TR VALIGN=\"baseline\" BGCOLOR=\"" PHP_CONTENTS_COLOR "\">"); for (i=0; i<num_cols; i++) { php_printf("<TD %s>%s", (i==0?"BGCOLOR=\"" PHP_ENTRY_NAME_COLOR "\" ":"ALIGN=\"left\""), (i==0?"<B>":"")); row_element = va_arg(row_elements, char *); if (!row_element || !*row_element) { php_printf(" "); } else { zend_html_puts(row_element, strlen(row_element)); } php_printf("%s</td>", (i==0?"</B>":"")); } php_printf("</TR>\n"); va_end(row_elements); }
static void php_print_gpcse_array(char *name, uint name_length ELS_DC) { zval **data, **tmp, tmp2; char *string_key; ulong num_key; if (zend_hash_find(&EG(symbol_table), name, name_length+1, (void **) &data)!=FAILURE && ((*data)->type==IS_ARRAY)) { zend_hash_internal_pointer_reset((*data)->value.ht); while (zend_hash_get_current_data((*data)->value.ht, (void **) &tmp) == SUCCESS) { PUTS("<TR VALIGN=\"baseline\" BGCOLOR=\"" PHP_CONTENTS_COLOR "\">"); PUTS("<TD BGCOLOR=\"" PHP_ENTRY_NAME_COLOR "\"><B>"); PUTS(name); PUTS("[\""); switch (zend_hash_get_current_key((*data)->value.ht, &string_key, &num_key, 0)) { case HASH_KEY_IS_STRING: zend_html_puts(string_key, strlen(string_key)); break; case HASH_KEY_IS_LONG: php_printf("%ld",num_key); break; } PUTS("\"]</B></TD><TD>"); if ((*tmp)->type == IS_ARRAY) { PUTS("<PRE>"); zend_print_zval_r(*tmp, 0); PUTS("</PRE>"); } else if ((*tmp)->type != IS_STRING) { tmp2 = **tmp; zval_copy_ctor(&tmp2); convert_to_string(&tmp2); zend_html_puts(tmp2.value.str.val, tmp2.value.str.len); zval_dtor(&tmp2); } else { zend_html_puts((*tmp)->value.str.val, (*tmp)->value.str.len); } PUTS(" </TD></TR>\n"); zend_hash_move_forward((*data)->value.ht); } } }
ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini) { zval token; int token_type; char *last_color = syntax_highlighter_ini->highlight_html; char *next_color; zend_printf("<code>"); zend_printf("<span style=\"color: %s\">\n", last_color); /* highlight stuff coming back from zendlex() */ ZVAL_UNDEF(&token); while ((token_type=lex_scan(&token))) { switch (token_type) { case T_INLINE_HTML: next_color = syntax_highlighter_ini->highlight_html; break; case T_COMMENT: case T_DOC_COMMENT: next_color = syntax_highlighter_ini->highlight_comment; break; case T_OPEN_TAG: case T_OPEN_TAG_WITH_ECHO: case T_CLOSE_TAG: case T_LINE: case T_FILE: case T_DIR: case T_TRAIT_C: case T_METHOD_C: case T_FUNC_C: case T_NS_C: case T_CLASS_C: next_color = syntax_highlighter_ini->highlight_default; break; case '"': case T_ENCAPSED_AND_WHITESPACE: case T_CONSTANT_ENCAPSED_STRING: next_color = syntax_highlighter_ini->highlight_string; break; case T_WHITESPACE: zend_html_puts((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); /* no color needed */ ZVAL_UNDEF(&token); continue; break; default: if (Z_TYPE(token) == IS_UNDEF) { next_color = syntax_highlighter_ini->highlight_keyword; } else { next_color = syntax_highlighter_ini->highlight_default; } break; } if (last_color != next_color) { if (last_color != syntax_highlighter_ini->highlight_html) { zend_printf("</span>"); } last_color = next_color; if (last_color != syntax_highlighter_ini->highlight_html) { zend_printf("<span style=\"color: %s\">", last_color); } } zend_html_puts((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); if (Z_TYPE(token) == IS_STRING) { switch (token_type) { case T_OPEN_TAG: case T_OPEN_TAG_WITH_ECHO: case T_CLOSE_TAG: case T_WHITESPACE: case T_COMMENT: case T_DOC_COMMENT: break; default: zend_string_release(Z_STR(token)); break; } } ZVAL_UNDEF(&token); } if (last_color != syntax_highlighter_ini->highlight_html) { zend_printf("</span>\n"); } zend_printf("</span>\n"); zend_printf("</code>"); /* Discard parse errors thrown during tokenization */ zend_clear_exception(); }
PHPAPI void php_print_info(int flag) { char **env,*tmp1,*tmp2; char *php_uname; int expose_php = INI_INT("expose_php"); time_t the_time; struct tm *ta, tmbuf; ELS_FETCH(); SLS_FETCH(); the_time = time(NULL); ta = php_localtime_r(&the_time, &tmbuf); PUTS("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n<html>\n"); if (flag & PHP_INFO_GENERAL) { char *zend_version = get_zend_version(); php_uname = php_get_uname(); PUTS("<head>"); php_info_print_style(); PUTS("<title>phpinfo()</title></head><body>"); php_info_print_box_start(1); if (expose_php) { PUTS("<a href=\"http://www.php.net/\"><img src=\""); if (SG(request_info).request_uri) { PUTS(SG(request_info).request_uri); } if ((ta->tm_mon==3) && (ta->tm_mday==1)) { PUTS("?="PHP_EGG_LOGO_GUID"\" border=0 align=\"right\" alt=\"Thies!\"></a>"); } else { PUTS("?="PHP_LOGO_GUID"\" border=0 align=\"right\" alt=\"PHP Logo\"></a>"); } } php_printf("<H1>PHP Version %s</H1>\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_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 ZEND_DEBUG php_info_print_table_row(2, "ZEND_DEBUG", "enabled" ); #else php_info_print_table_row(2, "ZEND_DEBUG", "disabled" ); #endif #ifdef ZTS php_info_print_table_row(2, "Thread Safety", "enabled" ); #else php_info_print_table_row(2, "Thread Safety", "disabled" ); #endif #if HAVE_PHP_STREAM php_info_print_table_row(2, "Experimental PHP Streams", "enabled"); #endif php_info_print_table_end(); /* Zend Engine */ php_info_print_box_start(0); if (expose_php) { PUTS("<a href=\"http://www.zend.com/\"><img src=\""); if (SG(request_info).request_uri) { PUTS(SG(request_info).request_uri); } PUTS("?="ZEND_LOGO_GUID"\" border=\"0\" align=\"right\" alt=\"Zend logo\"></a>\n"); } php_printf("This program makes use of the Zend scripting language engine:<BR>"); zend_html_puts(zend_version, strlen(zend_version)); php_printf("</BR>\n"); php_info_print_box_end(); efree(php_uname); } if ((flag & PHP_INFO_CREDITS) && expose_php) { php_info_print_hr(); PUTS("<h1 align=\"center\"><a href=\""); if (SG(request_info).request_uri) { PUTS(SG(request_info).request_uri); } PUTS("?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000\">"); PUTS("PHP 4.0 Credits"); PUTS("</a></h1>\n"); } zend_ini_sort_entries(ELS_C); if (flag & PHP_INFO_CONFIGURATION) { php_info_print_hr(); PUTS("<h1 align=\"center\">Configuration</h1>\n"); SECTION("PHP Core\n"); display_ini_entries(NULL); } if (flag & PHP_INFO_MODULES) { int show_info_func; show_info_func = 1; zend_hash_apply_with_argument(&module_registry, (int (*)(void *, void *)) _display_module_info, &show_info_func); SECTION("Additional Modules"); 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); php_info_print_table_end(); } if (flag & PHP_INFO_ENVIRONMENT) { SECTION("Environment"); php_info_print_table_start(); php_info_print_table_header(2, "Variable", "Value"); for (env=environ; env!=NULL && *env !=NULL; env++) { tmp1 = estrdup(*env); if (!(tmp2=strchr(tmp1,'='))) { /* malformed entry? */ efree(tmp1); continue; } *tmp2 = 0; tmp2++; php_info_print_table_row(2, tmp1, tmp2); efree(tmp1); } php_info_print_table_end(); } if (flag & PHP_INFO_VARIABLES) { pval **data; SECTION("PHP Variables"); 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); } if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_TYPE", sizeof("PHP_AUTH_TYPE"), (void **) &data) != FAILURE) { php_info_print_table_row(2, "PHP_AUTH_TYPE", (*data)->value.str.val); } if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_USER", sizeof("PHP_AUTH_USER"), (void **) &data) != FAILURE) { php_info_print_table_row(2, "PHP_AUTH_USER", (*data)->value.str.val); } if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_PW", sizeof("PHP_AUTH_PW"), (void **) &data) != FAILURE) { php_info_print_table_row(2, "PHP_AUTH_PW", (*data)->value.str.val); } php_print_gpcse_array("HTTP_GET_VARS", sizeof("HTTP_GET_VARS")-1 ELS_CC); php_print_gpcse_array("HTTP_POST_VARS", sizeof("HTTP_POST_VARS")-1 ELS_CC); php_print_gpcse_array("HTTP_POST_FILES", sizeof("HTTP_POST_FILES")-1 ELS_CC); 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); php_info_print_table_end(); } if (flag & PHP_INFO_LICENSE) { SECTION("PHP License"); php_info_print_box_start(0); PUTS("<P>\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("</P>\n"); PUTS("<P>"); 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("</P>\n"); PUTS("<P>"); PUTS("If you did not receive a copy of the PHP license, or have any questions about "); PUTS("PHP licensing, please contact [email protected].\n"); PUTS("</P>\n"); php_info_print_box_end(); } PUTS("</BODY></HTML>"); }