LTP GCOV extension - code coverage report
Current view: directory - ext/standard - info.c
Test: PHP Code Coverage
Date: 2007-04-10 Instrumented lines: 510
Code covered: 7.5 % Executed lines: 38
Legend: not executed executed

       1                 : /* 
       2                 :    +----------------------------------------------------------------------+
       3                 :    | PHP Version 5                                                        |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | Copyright (c) 1997-2007 The PHP Group                                |
       6                 :    +----------------------------------------------------------------------+
       7                 :    | This source file is subject to version 3.01 of the PHP license,      |
       8                 :    | that is bundled with this package in the file LICENSE, and is        |
       9                 :    | available through the world-wide-web at the following url:           |
      10                 :    | http://www.php.net/license/3_01.txt                                  |
      11                 :    | If you did not receive a copy of the PHP license and are unable to   |
      12                 :    | obtain it through the world-wide-web, please send a note to          |
      13                 :    | license@php.net so we can mail you a copy immediately.               |
      14                 :    +----------------------------------------------------------------------+
      15                 :    | Authors: Rasmus Lerdorf <rasmus@php.net>                             |
      16                 :    |          Zeev Suraski <zeev@zend.com>                                |
      17                 :    |          Colin Viebrock <colin@easydns.com>                          |
      18                 :    +----------------------------------------------------------------------+
      19                 : */
      20                 : 
      21                 : /* $Id: info.c,v 1.249.2.10.2.11 2007/04/02 12:41:07 sniper Exp $ */
      22                 : 
      23                 : #include "php.h"
      24                 : #include "php_ini.h"
      25                 : #include "php_globals.h"
      26                 : #include "ext/standard/head.h"
      27                 : #include "ext/standard/html.h"
      28                 : #include "info.h"
      29                 : #include "credits.h"
      30                 : #include "css.h"
      31                 : #include "SAPI.h"
      32                 : #include <time.h>
      33                 : #include "php_main.h"
      34                 : #include "zend_globals.h"             /* needs ELS */
      35                 : #include "zend_extensions.h"
      36                 : #include "zend_highlight.h"
      37                 : #ifdef HAVE_SYS_UTSNAME_H
      38                 : #include <sys/utsname.h>
      39                 : #endif
      40                 : 
      41                 : #if HAVE_MBSTRING
      42                 : #include "ext/mbstring/mbstring.h"
      43                 : ZEND_EXTERN_MODULE_GLOBALS(mbstring)
      44                 : #endif
      45                 : 
      46                 : #if HAVE_ICONV
      47                 : #include "ext/iconv/php_iconv.h"
      48                 : ZEND_EXTERN_MODULE_GLOBALS(iconv)
      49                 : #endif
      50                 : 
      51                 : #define SECTION(name)   if (!sapi_module.phpinfo_as_text) { \
      52                 :                                                         PUTS("<h2>" name "</h2>\n"); \
      53                 :                                                 } else { \
      54                 :                                                         php_info_print_table_start(); \
      55                 :                                                         php_info_print_table_header(1, name); \
      56                 :                                                         php_info_print_table_end(); \
      57                 :                                                 } \
      58                 : 
      59                 : PHPAPI extern char *php_ini_opened_path;
      60                 : PHPAPI extern char *php_ini_scanned_files;
      61                 :         
      62                 : static int php_info_write_wrapper(const char *str, uint str_length)
      63               0 : {
      64                 :         int new_len, written;
      65                 :         char *elem_esc;
      66                 : 
      67                 :         TSRMLS_FETCH();
      68                 : 
      69               0 :         elem_esc = php_escape_html_entities((unsigned char *)str, str_length, &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
      70                 : 
      71               0 :         written = php_body_write(elem_esc, new_len TSRMLS_CC);
      72                 : 
      73               0 :         efree(elem_esc);
      74                 : 
      75               0 :         return written;
      76                 : }
      77                 : 
      78                 : 
      79                 : PHPAPI void php_info_print_module(zend_module_entry *module TSRMLS_DC) /* {{{ */
      80               0 : {
      81               0 :         if (module->info_func) {
      82               0 :                 if (!sapi_module.phpinfo_as_text) {
      83               0 :                         php_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", module->name, module->name);
      84                 :                 } else {
      85               0 :                         php_info_print_table_start();
      86               0 :                         php_info_print_table_header(1, module->name);
      87               0 :                         php_info_print_table_end();
      88                 :                 }
      89               0 :                 module->info_func(module TSRMLS_CC);
      90                 :         } else {
      91               0 :                 if (!sapi_module.phpinfo_as_text) {
      92               0 :                         php_printf("<tr>");
      93               0 :                         php_printf("<td>");
      94               0 :                         php_printf("%s", module->name);
      95               0 :                         php_printf("</td></tr>\n");
      96                 :                 } else {
      97               0 :                         php_printf("%s", module->name);
      98               0 :                         php_printf("\n");
      99                 :                 }       
     100                 :         }
     101               0 : }
     102                 : /* }}} */
     103                 : 
     104                 : static int _display_module_info_func(zend_module_entry *module TSRMLS_DC) /* {{{ */
     105               0 : {
     106               0 :         if (module->info_func) {
     107               0 :                 php_info_print_module(module TSRMLS_CC);
     108                 :         }
     109               0 :         return ZEND_HASH_APPLY_KEEP;
     110                 : }
     111                 : /* }}} */
     112                 : 
     113                 : static int _display_module_info_def(zend_module_entry *module TSRMLS_DC) /* {{{ */
     114               0 : {
     115               0 :         if (!module->info_func) {
     116               0 :                 php_info_print_module(module TSRMLS_CC);
     117                 :         }
     118               0 :         return ZEND_HASH_APPLY_KEEP;
     119                 : }
     120                 : /* }}} */
     121                 : 
     122                 : /* {{{ php_print_gpcse_array
     123                 :  */
     124                 : static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
     125               0 : {
     126                 :         zval **data, **tmp, tmp2;
     127                 :         char *string_key;
     128                 :         uint string_len;
     129                 :         ulong num_key;
     130                 : 
     131               0 :         zend_is_auto_global(name, name_length TSRMLS_CC);
     132                 : 
     133               0 :         if (zend_hash_find(&EG(symbol_table), name, name_length+1, (void **) &data)!=FAILURE
     134                 :                 && (Z_TYPE_PP(data)==IS_ARRAY)) {
     135               0 :                 zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data));
     136               0 :                 while (zend_hash_get_current_data(Z_ARRVAL_PP(data), (void **) &tmp) == SUCCESS) {
     137               0 :                         if (!sapi_module.phpinfo_as_text) {
     138               0 :                                 PUTS("<tr>");
     139               0 :                                 PUTS("<td class=\"e\">");
     140                 : 
     141                 :                         }
     142                 : 
     143               0 :                         PUTS(name);
     144               0 :                         PUTS("[\"");
     145                 :                         
     146               0 :                         switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL)) {
     147                 :                                 case HASH_KEY_IS_STRING:
     148               0 :                                         if (!sapi_module.phpinfo_as_text) {
     149               0 :                                                 php_info_html_esc_write(string_key, string_len - 1 TSRMLS_CC);
     150                 :                                         } else {
     151               0 :                                                 PHPWRITE(string_key, string_len - 1);
     152                 :                                         }       
     153               0 :                                         break;
     154                 :                                 case HASH_KEY_IS_LONG:
     155               0 :                                         php_printf("%ld", num_key);
     156                 :                                         break;
     157                 :                         }
     158               0 :                         PUTS("\"]");
     159               0 :                         if (!sapi_module.phpinfo_as_text) {
     160               0 :                                 PUTS("</td><td class=\"v\">");
     161                 :                         } else {
     162               0 :                                 PUTS(" => ");
     163                 :                         }
     164               0 :                         if (Z_TYPE_PP(tmp) == IS_ARRAY) {
     165               0 :                                 if (!sapi_module.phpinfo_as_text) {
     166               0 :                                         PUTS("<pre>");
     167               0 :                                         zend_print_zval_r_ex((zend_write_func_t) php_info_write_wrapper, *tmp, 0 TSRMLS_CC);
     168               0 :                                         PUTS("</pre>");
     169                 :                                 } else {
     170               0 :                                         zend_print_zval_r(*tmp, 0 TSRMLS_CC);
     171                 :                                 }
     172               0 :                         } else if (Z_TYPE_PP(tmp) != IS_STRING) {
     173               0 :                                 tmp2 = **tmp;
     174               0 :                                 zval_copy_ctor(&tmp2);
     175               0 :                                 convert_to_string(&tmp2);
     176               0 :                                 if (!sapi_module.phpinfo_as_text) {
     177               0 :                                         if (Z_STRLEN(tmp2) == 0) {
     178               0 :                                                 PUTS("<i>no value</i>");
     179                 :                                         } else {
     180               0 :                                                 php_info_html_esc_write(Z_STRVAL(tmp2), Z_STRLEN(tmp2) TSRMLS_CC);
     181                 :                                         } 
     182                 :                                 } else {
     183               0 :                                         PHPWRITE(Z_STRVAL(tmp2), Z_STRLEN(tmp2));
     184                 :                                 }       
     185               0 :                                 zval_dtor(&tmp2);
     186                 :                         } else {
     187               0 :                                 if (!sapi_module.phpinfo_as_text) {
     188               0 :                                         if (Z_STRLEN_PP(tmp) == 0) {
     189               0 :                                                 PUTS("<i>no value</i>");
     190                 :                                         } else {
     191               0 :                                                 php_info_html_esc_write(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp) TSRMLS_CC);
     192                 :                                         }
     193                 :                                 } else {
     194               0 :                                         PHPWRITE(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
     195                 :                                 }       
     196                 :                         }
     197               0 :                         if (!sapi_module.phpinfo_as_text) {
     198               0 :                                 PUTS("</td></tr>\n");
     199                 :                         } else {
     200               0 :                                 PUTS("\n");
     201                 :                         }       
     202               0 :                         zend_hash_move_forward(Z_ARRVAL_PP(data));
     203                 :                 }
     204                 :         }
     205               0 : }
     206                 : /* }}} */
     207                 : 
     208                 : /* {{{ php_info_print_style
     209                 :  */
     210                 : void php_info_print_style(TSRMLS_D)
     211               0 : {
     212               0 :         php_printf("<style type=\"text/css\">\n");
     213               0 :         php_info_print_css(TSRMLS_C);
     214               0 :         php_printf("</style>\n");
     215               0 : }
     216                 : /* }}} */
     217                 : 
     218                 : /* {{{ php_info_html_esc_write
     219                 :  */
     220                 : PHPAPI void php_info_html_esc_write(char *string, int str_len TSRMLS_DC)
     221               0 : {
     222                 :         int new_len;
     223               0 :         char *ret = php_escape_html_entities((unsigned char *)string, str_len, &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
     224                 : 
     225               0 :         PHPWRITE(ret, new_len);
     226               0 :         efree(ret);
     227               0 : }
     228                 : /* }}} */
     229                 : 
     230                 : /* {{{ php_info_html_esc
     231                 :  */
     232                 : PHPAPI char *php_info_html_esc(char *string TSRMLS_DC)
     233               0 : {
     234                 :         int new_len;
     235               0 :         return php_escape_html_entities((unsigned char *)string, strlen(string), &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
     236                 : }
     237                 : /* }}} */
     238                 : 
     239                 : 
     240                 : /* {{{ php_get_uname
     241                 :  */
     242                 : PHPAPI char *php_get_uname(char mode)
     243               1 : {
     244                 :         char *php_uname;
     245                 :         char tmp_uname[256];
     246                 : #ifdef PHP_WIN32
     247                 :         DWORD dwBuild=0;
     248                 :         DWORD dwVersion = GetVersion();
     249                 :         DWORD dwWindowsMajorVersion =  (DWORD)(LOBYTE(LOWORD(dwVersion)));
     250                 :         DWORD dwWindowsMinorVersion =  (DWORD)(HIBYTE(LOWORD(dwVersion)));
     251                 :         DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
     252                 :         char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
     253                 :         SYSTEM_INFO SysInfo;
     254                 : 
     255                 :         GetComputerName(ComputerName, &dwSize);
     256                 :         GetSystemInfo(&SysInfo);
     257                 : 
     258                 :         if (mode == 's') {
     259                 :                 if (dwVersion < 0x80000000) {
     260                 :                         php_uname = "Windows NT";
     261                 :                 } else {
     262                 :                         php_uname = "Windows 9x";
     263                 :                 }
     264                 :         } else if (mode == 'r') {
     265                 :                 snprintf(tmp_uname, sizeof(tmp_uname), "%d.%d", dwWindowsMajorVersion, dwWindowsMinorVersion);
     266                 :                 php_uname = tmp_uname;
     267                 :         } else if (mode == 'n') {
     268                 :                 php_uname = ComputerName;
     269                 :         } else if (mode == 'v') {
     270                 :                 dwBuild = (DWORD)(HIWORD(dwVersion));
     271                 :                 snprintf(tmp_uname, sizeof(tmp_uname), "build %d", dwBuild);
     272                 :                 php_uname = tmp_uname;
     273                 :         } else if (mode == 'm') {
     274                 :                 switch (SysInfo.wProcessorArchitecture) {
     275                 :                         case PROCESSOR_ARCHITECTURE_INTEL :
     276                 :                                 snprintf(tmp_uname, sizeof(tmp_uname), "i%d", SysInfo.dwProcessorType);
     277                 :                                 php_uname = tmp_uname;
     278                 :                                 break;
     279                 :                         case PROCESSOR_ARCHITECTURE_MIPS :
     280                 :                                 php_uname = "MIPS R4000";
     281                 :                                 php_uname = tmp_uname;
     282                 :                                 break;
     283                 :                         case PROCESSOR_ARCHITECTURE_ALPHA :
     284                 :                                 snprintf(tmp_uname, sizeof(tmp_uname), "Alpha %d", SysInfo.wProcessorLevel);
     285                 :                                 php_uname = tmp_uname;
     286                 :                                 break;
     287                 :                         case PROCESSOR_ARCHITECTURE_PPC :
     288                 :                                 snprintf(tmp_uname, sizeof(tmp_uname), "PPC 6%02d", SysInfo.wProcessorLevel);
     289                 :                                 php_uname = tmp_uname;
     290                 :                                 break;
     291                 :                         case PROCESSOR_ARCHITECTURE_IA64 :
     292                 :                                 php_uname = "IA64";
     293                 :                                 break;
     294                 : #if defined(PROCESSOR_ARCHITECTURE_IA32_ON_WIN64)
     295                 :                         case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 :
     296                 :                                 php_uname = "IA32";
     297                 :                                 break;
     298                 : #endif
     299                 : #if defined(PROCESSOR_ARCHITECTURE_AMD64)
     300                 :                         case PROCESSOR_ARCHITECTURE_AMD64 :
     301                 :                                 php_uname = "AMD64";
     302                 :                                 break;
     303                 : #endif
     304                 :                         case PROCESSOR_ARCHITECTURE_UNKNOWN :
     305                 :                         default :
     306                 :                                 php_uname = "Unknown";
     307                 :                                 break;
     308                 :                 }
     309                 :         } else { /* assume mode == 'a' */
     310                 :                 /* Get build numbers for Windows NT or Win95 */
     311                 :                 if (dwVersion < 0x80000000){
     312                 :                         dwBuild = (DWORD)(HIWORD(dwVersion));
     313                 :                         snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %d.%d build %d",
     314                 :                                          "Windows NT", ComputerName,
     315                 :                                          dwWindowsMajorVersion, dwWindowsMinorVersion, dwBuild);
     316                 :                 } else {
     317                 :                         snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %d.%d",
     318                 :                                          "Windows 9x", ComputerName,
     319                 :                                          dwWindowsMajorVersion, dwWindowsMinorVersion);
     320                 :                 }
     321                 :                 php_uname = tmp_uname;
     322                 :         }
     323                 : #else
     324                 : #ifdef HAVE_SYS_UTSNAME_H
     325                 :         struct utsname buf;
     326               1 :         if (uname((struct utsname *)&buf) == -1) {
     327               0 :                 php_uname = PHP_UNAME;
     328                 :         } else {
     329               1 :                 if (mode == 's') {
     330               0 :                         php_uname = buf.sysname;
     331               1 :                 } else if (mode == 'r') {
     332               0 :                         php_uname = buf.release;
     333               1 :                 } else if (mode == 'n') {
     334               0 :                         php_uname = buf.nodename;
     335               1 :                 } else if (mode == 'v') {
     336               0 :                         php_uname = buf.version;
     337               1 :                 } else if (mode == 'm') {
     338               0 :                         php_uname = buf.machine;
     339                 :                 } else { /* assume mode == 'a' */
     340               1 :                         snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %s %s %s",
     341                 :                                          buf.sysname, buf.nodename, buf.release, buf.version,
     342                 :                                          buf.machine);
     343               1 :                         php_uname = tmp_uname;
     344                 :                 }
     345                 :         }
     346                 : #else
     347                 :         php_uname = PHP_UNAME;
     348                 : #endif
     349                 : #endif
     350               1 :         return estrdup(php_uname);
     351                 : }
     352                 : /* }}} */
     353                 : 
     354                 : 
     355                 : /* {{{ php_print_info_htmlhead
     356                 :  */
     357                 : PHPAPI void php_print_info_htmlhead(TSRMLS_D)
     358               0 : {
     359                 : 
     360                 : /*** none of this is needed now ***
     361                 : 
     362                 :         const char *charset = NULL;
     363                 : 
     364                 :         if (SG(default_charset)) {
     365                 :                 charset = SG(default_charset);
     366                 :         }
     367                 : 
     368                 : #if HAVE_MBSTRING
     369                 :         if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) {
     370                 :                 if (MBSTRG(current_http_output_encoding) == mbfl_no_encoding_pass) {
     371                 :                         charset = "US-ASCII";
     372                 :                 } else {
     373                 :                         charset = mbfl_no2preferred_mime_name(MBSTRG(current_http_output_encoding));
     374                 :                 }
     375                 :         }
     376                 : #endif   
     377                 : 
     378                 : #if HAVE_ICONV
     379                 :         if (php_ob_handler_used("ob_iconv_handler" TSRMLS_CC)) {
     380                 :                 charset = ICONVG(output_encoding);
     381                 :         }
     382                 : #endif
     383                 : 
     384                 :         if (!charset || !charset[0]) {
     385                 :                 charset = "US-ASCII";
     386                 :         }
     387                 : 
     388                 : *** none of that is needed now ***/
     389                 : 
     390                 : 
     391               0 :         PUTS("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n");
     392               0 :         PUTS("<html>");
     393               0 :         PUTS("<head>\n");
     394               0 :         php_info_print_style(TSRMLS_C);
     395               0 :         PUTS("<title>phpinfo()</title>");
     396               0 :         PUTS("<meta name=\"ROBOTS\" content=\"NOINDEX,NOFOLLOW,NOARCHIVE\" />");
     397                 : /*
     398                 :         php_printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\" />\n", charset);
     399                 : */
     400               0 :         PUTS("</head>\n");
     401               0 :         PUTS("<body><div class=\"center\">\n");
     402               0 : }
     403                 : /* }}} */
     404                 : 
     405                 : /* {{{ module_name_cmp */
     406                 : static int module_name_cmp(const void *a, const void *b TSRMLS_DC)
     407               0 : {
     408               0 :         Bucket *f = *((Bucket **) a);
     409               0 :         Bucket *s = *((Bucket **) b);
     410                 : 
     411               0 :         return strcasecmp(((zend_module_entry *)f->pData)->name,
     412                 :                                   ((zend_module_entry *)s->pData)->name);
     413                 : }
     414                 : /* }}} */
     415                 : 
     416                 : /* {{{ php_print_info
     417                 :  */
     418                 : PHPAPI void php_print_info(int flag TSRMLS_DC)
     419               0 : {
     420                 :         char **env, *tmp1, *tmp2;
     421                 :         char *php_uname;
     422               0 :         int expose_php = INI_INT("expose_php");
     423                 : 
     424               0 :         if (!sapi_module.phpinfo_as_text) {
     425               0 :                 php_print_info_htmlhead(TSRMLS_C);
     426                 :         } else {
     427               0 :                 PUTS("phpinfo()\n");
     428                 :         }       
     429                 : 
     430               0 :         if (flag & PHP_INFO_GENERAL) {
     431               0 :                 char *zend_version = get_zend_version();
     432                 :                 char temp_api[10];
     433                 :                 char *logo_guid;
     434                 : 
     435               0 :                 php_uname = php_get_uname('a');
     436                 :                 
     437               0 :                 if (!sapi_module.phpinfo_as_text) {
     438               0 :                         php_info_print_box_start(1);
     439                 :                 }
     440                 : 
     441               0 :                 if (expose_php && !sapi_module.phpinfo_as_text) {
     442               0 :                         PUTS("<a href=\"http://www.php.net/\"><img border=\"0\" src=\"");
     443               0 :                         if (SG(request_info).request_uri) {
     444               0 :                                 char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
     445               0 :                                 PUTS(elem_esc);
     446               0 :                                 efree(elem_esc);
     447                 :                         }
     448               0 :                         PUTS("?=");
     449               0 :                         logo_guid = php_logo_guid();
     450               0 :                         PUTS(logo_guid);
     451               0 :                         efree(logo_guid);
     452               0 :                         PUTS("\" alt=\"PHP Logo\" /></a>");
     453                 :                 }
     454                 : 
     455               0 :                 if (!sapi_module.phpinfo_as_text) {
     456               0 :                         php_printf("<h1 class=\"p\">PHP Version %s</h1>\n", PHP_VERSION);
     457                 :                 } else {
     458               0 :                         php_info_print_table_row(2, "PHP Version", PHP_VERSION);
     459                 :                 }       
     460               0 :                 php_info_print_box_end();
     461               0 :                 php_info_print_table_start();
     462               0 :                 php_info_print_table_row(2, "System", php_uname );
     463               0 :                 php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__ );
     464                 : #ifdef CONFIGURE_COMMAND
     465               0 :                 php_info_print_table_row(2, "Configure Command", CONFIGURE_COMMAND );
     466                 : #endif
     467               0 :                 if (sapi_module.pretty_name) {
     468               0 :                         php_info_print_table_row(2, "Server API", sapi_module.pretty_name );
     469                 :                 }
     470                 : 
     471                 : #ifdef VIRTUAL_DIR
     472                 :                 php_info_print_table_row(2, "Virtual Directory Support", "enabled" );
     473                 : #else
     474               0 :                 php_info_print_table_row(2, "Virtual Directory Support", "disabled" );
     475                 : #endif
     476                 : 
     477               0 :                 php_info_print_table_row(2, "Configuration File (php.ini) Path", PHP_CONFIG_FILE_PATH);
     478               0 :                 php_info_print_table_row(2, "Loaded Configuration File", php_ini_opened_path ? php_ini_opened_path : "(none)");
     479                 : 
     480                 :                 if (strlen(PHP_CONFIG_FILE_SCAN_DIR)) {
     481                 :                         php_info_print_table_row(2, "Scan this dir for additional .ini files", PHP_CONFIG_FILE_SCAN_DIR);
     482                 :                         if (php_ini_scanned_files) {
     483                 :                                 php_info_print_table_row(2, "additional .ini files parsed", php_ini_scanned_files);
     484                 :                         }
     485                 :                 }
     486                 :                 
     487               0 :                 snprintf(temp_api, sizeof(temp_api), "%d", PHP_API_VERSION);
     488               0 :                 php_info_print_table_row(2, "PHP API", temp_api);
     489                 : 
     490               0 :                 snprintf(temp_api, sizeof(temp_api), "%d", ZEND_MODULE_API_NO);
     491               0 :                 php_info_print_table_row(2, "PHP Extension", temp_api);
     492                 : 
     493               0 :                 snprintf(temp_api, sizeof(temp_api), "%d", ZEND_EXTENSION_API_NO);
     494               0 :                 php_info_print_table_row(2, "Zend Extension", temp_api);
     495                 : 
     496                 : #if ZEND_DEBUG
     497                 :                 php_info_print_table_row(2, "Debug Build", "yes" );
     498                 : #else
     499               0 :                 php_info_print_table_row(2, "Debug Build", "no" );
     500                 : #endif
     501                 : 
     502                 : #ifdef ZTS
     503                 :                 php_info_print_table_row(2, "Thread Safety", "enabled" );
     504                 : #else
     505               0 :                 php_info_print_table_row(2, "Thread Safety", "disabled" );
     506                 : #endif
     507                 : 
     508               0 :                 php_info_print_table_row(2, "Zend Memory Manager", is_zend_mm(TSRMLS_C) ? "enabled" : "disabled" );
     509                 : 
     510                 : #if HAVE_IPV6
     511               0 :                 php_info_print_table_row(2, "IPv6 Support", "enabled" );
     512                 : #else
     513                 :                 php_info_print_table_row(2, "IPv6 Support", "disabled" );
     514                 : #endif
     515                 :                 {
     516                 :                         HashTable *url_stream_wrappers_hash;
     517               0 :                         char *stream_protocol, *stream_protocols_buf = NULL;
     518               0 :                         int stream_protocol_len, stream_protocols_buf_len = 0;
     519                 :                         ulong num_key;
     520                 : 
     521               0 :                         if ((url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash())) {
     522               0 :                                 for (zend_hash_internal_pointer_reset(url_stream_wrappers_hash);
     523               0 :                                                 zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, (uint *)&stream_protocol_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING;
     524               0 :                                                 zend_hash_move_forward(url_stream_wrappers_hash)) {
     525               0 :                                         stream_protocols_buf = erealloc(stream_protocols_buf, stream_protocols_buf_len + stream_protocol_len + 2 + 1);
     526               0 :                                         memcpy(stream_protocols_buf + stream_protocols_buf_len, stream_protocol, stream_protocol_len - 1);
     527               0 :                                         stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len - 1] = ',';
     528               0 :                                         stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len] = ' ';
     529               0 :                                         stream_protocols_buf_len += stream_protocol_len + 1;
     530                 :                                 }
     531               0 :                                 if (stream_protocols_buf) {
     532               0 :                                         stream_protocols_buf[stream_protocols_buf_len - 2] = ' ';
     533               0 :                                         stream_protocols_buf[stream_protocols_buf_len] = 0;
     534               0 :                                         php_info_print_table_row(2, "Registered PHP Streams", stream_protocols_buf);
     535               0 :                                         efree(stream_protocols_buf);
     536                 :                                 } else {
     537                 :                                         /* Any chances we will ever hit this? */
     538               0 :                                         php_info_print_table_row(2, "Registered PHP Streams", "no streams registered");
     539                 :                                 }
     540                 :                         } else {
     541                 :                                 /* Any chances we will ever hit this? */
     542               0 :                                 php_info_print_table_row(2, "PHP Streams", "disabled"); /* ?? */
     543                 :                         }
     544                 :                 }
     545                 : 
     546                 :                 {
     547                 :                         HashTable *stream_xport_hash;
     548               0 :                         char *xport_name, *xport_buf = NULL;
     549               0 :                         int xport_name_len, xport_buf_len = 0, xport_buf_size = 0;
     550                 :                         ulong num_key;
     551                 : 
     552               0 :                         if ((stream_xport_hash = php_stream_xport_get_hash())) {
     553               0 :                                 for(zend_hash_internal_pointer_reset(stream_xport_hash);
     554               0 :                                         zend_hash_get_current_key_ex(stream_xport_hash, &xport_name, (uint *)&xport_name_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING;
     555               0 :                                         zend_hash_move_forward(stream_xport_hash)) {
     556               0 :                                         if (xport_buf_len + xport_name_len + 2 > xport_buf_size) {
     557               0 :                                                 while (xport_buf_len + xport_name_len + 2 > xport_buf_size) {
     558               0 :                                                         xport_buf_size += 256;
     559                 :                                                 }
     560               0 :                                                 if (xport_buf) {
     561               0 :                                                         xport_buf = erealloc(xport_buf, xport_buf_size);
     562                 :                                                 } else {
     563               0 :                                                         xport_buf = emalloc(xport_buf_size);
     564                 :                                                 }
     565                 :                                         }
     566               0 :                                         if (xport_buf_len > 0) {
     567               0 :                                                 xport_buf[xport_buf_len++] = ',';
     568               0 :                                                 xport_buf[xport_buf_len++] = ' ';
     569                 :                                         }
     570               0 :                                         memcpy(xport_buf + xport_buf_len, xport_name, xport_name_len - 1);
     571               0 :                                         xport_buf_len += xport_name_len - 1;
     572               0 :                                         xport_buf[xport_buf_len] = '\0';
     573                 :                                 }
     574               0 :                                 if (xport_buf) {
     575               0 :                                         php_info_print_table_row(2, "Registered Stream Socket Transports", xport_buf);
     576               0 :                                         efree(xport_buf);
     577                 :                                 } else {
     578                 :                                         /* Any chances we will ever hit this? */
     579               0 :                                         php_info_print_table_row(2, "Registered Stream Socket Transports", "no transports registered");
     580                 :                                 }
     581                 :                         } else {
     582                 :                                 /* Any chances we will ever hit this? */
     583               0 :                                 php_info_print_table_row(2, "Stream Socket Transports", "disabled"); /* ?? */
     584                 :                         }
     585                 :                 }
     586                 : 
     587                 :                 {
     588                 :                         HashTable *stream_filter_hash;
     589               0 :                         char *filter_name, *filter_buf = NULL;
     590               0 :                         int filter_name_len, filter_buf_len = 0, filter_buf_size = 0;
     591                 :                         ulong num_key;
     592                 : 
     593               0 :                         if ((stream_filter_hash = php_get_stream_filters_hash())) {
     594               0 :                                 for(zend_hash_internal_pointer_reset(stream_filter_hash);
     595               0 :                                         zend_hash_get_current_key_ex(stream_filter_hash, &filter_name, (uint *)&filter_name_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING;
     596               0 :                                         zend_hash_move_forward(stream_filter_hash)) {
     597               0 :                                         if (filter_buf_len + filter_name_len + 2 > filter_buf_size) {
     598               0 :                                                 while (filter_buf_len + filter_name_len + 2 > filter_buf_size) {
     599               0 :                                                         filter_buf_size += 256;
     600                 :                                                 }
     601               0 :                                                 if (filter_buf) {
     602               0 :                                                         filter_buf = erealloc(filter_buf, filter_buf_size);
     603                 :                                                 } else {
     604               0 :                                                         filter_buf = emalloc(filter_buf_size);
     605                 :                                                 }
     606                 :                                         }
     607               0 :                                         if (filter_buf_len > 0) {
     608               0 :                                                 filter_buf[filter_buf_len++] = ',';
     609               0 :                                                 filter_buf[filter_buf_len++] = ' ';
     610                 :                                         }
     611               0 :                                         memcpy(filter_buf + filter_buf_len, filter_name, filter_name_len - 1);
     612               0 :                                         filter_buf_len += filter_name_len - 1;
     613               0 :                                         filter_buf[filter_buf_len] = '\0';
     614                 :                                 }
     615               0 :                                 if (filter_buf) {
     616               0 :                                         php_info_print_table_row(2, "Registered Stream Filters", filter_buf);
     617               0 :                                         efree(filter_buf);
     618                 :                                 } else {
     619                 :                                         /* Any chances we will ever hit this? */
     620               0 :                                         php_info_print_table_row(2, "Registered Stream Filters", "no filters registered");
     621                 :                                 }
     622                 :                         } else {
     623                 :                                 /* Any chances we will ever hit this? */
     624               0 :                                 php_info_print_table_row(2, "Stream Filters", "disabled"); /* ?? */
     625                 :                         }
     626                 :                 }
     627                 :                 
     628               0 :                 php_info_print_table_end();
     629                 : 
     630                 :                 /* Zend Engine */
     631               0 :                 php_info_print_box_start(0);
     632               0 :                 if (expose_php && !sapi_module.phpinfo_as_text) {
     633               0 :                         PUTS("<a href=\"http://www.zend.com/\"><img border=\"0\" src=\"");
     634               0 :                         if (SG(request_info).request_uri) {
     635               0 :                                 char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
     636               0 :                                 PUTS(elem_esc);
     637               0 :                                 efree(elem_esc);
     638                 :                         }
     639               0 :                         PUTS("?="ZEND_LOGO_GUID"\" alt=\"Zend logo\" /></a>\n");
     640                 :                 }
     641               0 :                 PUTS("This program makes use of the Zend Scripting Language Engine:");
     642               0 :                 PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n");
     643               0 :                 if (sapi_module.phpinfo_as_text) {
     644               0 :                         PUTS(zend_version);
     645                 :                 } else {
     646               0 :                         zend_html_puts(zend_version, strlen(zend_version) TSRMLS_CC);
     647                 :                 }
     648               0 :                 php_info_print_box_end();
     649               0 :                 efree(php_uname);
     650                 :         }
     651                 : 
     652               0 :         if ((flag & PHP_INFO_CREDITS) && expose_php && !sapi_module.phpinfo_as_text) {      
     653               0 :                 php_info_print_hr();
     654               0 :                 PUTS("<h1><a href=\"");
     655               0 :                 if (SG(request_info).request_uri) {
     656               0 :                         char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
     657               0 :                         PUTS(elem_esc);
     658               0 :                         efree(elem_esc);
     659                 :                 }
     660               0 :                 PUTS("?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000\">");
     661               0 :                 PUTS("PHP Credits");
     662               0 :                 PUTS("</a></h1>\n");
     663                 :         }
     664                 : 
     665               0 :         zend_ini_sort_entries(TSRMLS_C);
     666                 : 
     667               0 :         if (flag & PHP_INFO_CONFIGURATION) {
     668               0 :                 php_info_print_hr();
     669               0 :                 if (!sapi_module.phpinfo_as_text) {
     670               0 :                         PUTS("<h1>Configuration</h1>\n");
     671                 :                 } else {
     672               0 :                         SECTION("Configuration");
     673                 :                 }       
     674               0 :                 SECTION("PHP Core");
     675               0 :                 display_ini_entries(NULL);
     676                 :         }
     677                 : 
     678               0 :         if (flag & PHP_INFO_MODULES) {
     679                 :                 HashTable sorted_registry;
     680                 :                 zend_module_entry tmp;
     681                 : 
     682               0 :                 zend_hash_init(&sorted_registry, zend_hash_num_elements(&module_registry), NULL, NULL, 1);
     683               0 :                 zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry));
     684               0 :                 zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC);
     685                 : 
     686               0 :                 zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_func TSRMLS_CC);
     687                 : 
     688               0 :                 SECTION("Additional Modules");
     689               0 :                 php_info_print_table_start();
     690               0 :                 php_info_print_table_header(1, "Module Name");
     691               0 :                 zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_def TSRMLS_CC);
     692               0 :                 php_info_print_table_end();
     693                 : 
     694               0 :                 zend_hash_destroy(&sorted_registry);
     695                 :         }
     696                 : 
     697               0 :         if (flag & PHP_INFO_ENVIRONMENT) {
     698               0 :                 SECTION("Environment");
     699               0 :                 php_info_print_table_start();
     700               0 :                 php_info_print_table_header(2, "Variable", "Value");
     701               0 :                 for (env=environ; env!=NULL && *env !=NULL; env++) {
     702               0 :                         tmp1 = estrdup(*env);
     703               0 :                         if (!(tmp2=strchr(tmp1,'='))) { /* malformed entry? */
     704               0 :                                 efree(tmp1);
     705               0 :                                 continue;
     706                 :                         }
     707               0 :                         *tmp2 = 0;
     708               0 :                         tmp2++;
     709               0 :                         php_info_print_table_row(2, tmp1, tmp2);
     710               0 :                         efree(tmp1);
     711                 :                 }
     712               0 :                 php_info_print_table_end();
     713                 :         }
     714                 : 
     715               0 :         if (flag & PHP_INFO_VARIABLES) {
     716                 :                 zval **data;
     717                 : 
     718               0 :                 SECTION("PHP Variables");
     719                 : 
     720               0 :                 php_info_print_table_start();
     721               0 :                 php_info_print_table_header(2, "Variable", "Value");
     722               0 :                 if (zend_hash_find(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void **) &data) != FAILURE) {
     723               0 :                         php_info_print_table_row(2, "PHP_SELF", Z_STRVAL_PP(data));
     724                 :                 }
     725               0 :                 if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_TYPE", sizeof("PHP_AUTH_TYPE"), (void **) &data) != FAILURE) {
     726               0 :                         php_info_print_table_row(2, "PHP_AUTH_TYPE", Z_STRVAL_PP(data));
     727                 :                 }
     728               0 :                 if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_USER", sizeof("PHP_AUTH_USER"), (void **) &data) != FAILURE) {
     729               0 :                         php_info_print_table_row(2, "PHP_AUTH_USER", Z_STRVAL_PP(data));
     730                 :                 }
     731               0 :                 if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_PW", sizeof("PHP_AUTH_PW"), (void **) &data) != FAILURE) {
     732               0 :                         php_info_print_table_row(2, "PHP_AUTH_PW", Z_STRVAL_PP(data));
     733                 :                 }
     734               0 :                 php_print_gpcse_array("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC);
     735               0 :                 php_print_gpcse_array("_GET", sizeof("_GET")-1 TSRMLS_CC);
     736               0 :                 php_print_gpcse_array("_POST", sizeof("_POST")-1 TSRMLS_CC);
     737               0 :                 php_print_gpcse_array("_FILES", sizeof("_FILES")-1 TSRMLS_CC);
     738               0 :                 php_print_gpcse_array("_COOKIE", sizeof("_COOKIE")-1 TSRMLS_CC);
     739               0 :                 php_print_gpcse_array("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
     740               0 :                 php_print_gpcse_array("_ENV", sizeof("_ENV")-1 TSRMLS_CC);
     741               0 :                 php_info_print_table_end();
     742                 :         }
     743                 : 
     744               0 :         if (flag & PHP_INFO_LICENSE) {
     745               0 :                 if (!sapi_module.phpinfo_as_text) {
     746               0 :                         SECTION("PHP License");
     747               0 :                         php_info_print_box_start(0);
     748               0 :                         PUTS("<p>\n");
     749               0 :                         PUTS("This program is free software; you can redistribute it and/or modify ");
     750               0 :                         PUTS("it under the terms of the PHP License as published by the PHP Group ");
     751               0 :                         PUTS("and included in the distribution in the file:  LICENSE\n");
     752               0 :                         PUTS("</p>\n");
     753               0 :                         PUTS("<p>");
     754               0 :                         PUTS("This program is distributed in the hope that it will be useful, ");
     755               0 :                         PUTS("but WITHOUT ANY WARRANTY; without even the implied warranty of ");
     756               0 :                         PUTS("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
     757               0 :                         PUTS("</p>\n");
     758               0 :                         PUTS("<p>");
     759               0 :                         PUTS("If you did not receive a copy of the PHP license, or have any questions about ");
     760               0 :                         PUTS("PHP licensing, please contact license@php.net.\n");
     761               0 :                         PUTS("</p>\n");
     762               0 :                         php_info_print_box_end();
     763                 :                 } else {
     764               0 :                         PUTS("\nPHP License\n");
     765               0 :                         PUTS("This program is free software; you can redistribute it and/or modify\n");
     766               0 :                         PUTS("it under the terms of the PHP License as published by the PHP Group\n");
     767               0 :                         PUTS("and included in the distribution in the file:  LICENSE\n");
     768               0 :                         PUTS("\n");
     769               0 :                         PUTS("This program is distributed in the hope that it will be useful,\n");
     770               0 :                         PUTS("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
     771               0 :                         PUTS("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
     772               0 :                         PUTS("\n");
     773               0 :                         PUTS("If you did not receive a copy of the PHP license, or have any\n");
     774               0 :                         PUTS("questions about PHP licensing, please contact license@php.net.\n");
     775                 :                 }
     776                 :         }
     777               0 :         if (!sapi_module.phpinfo_as_text) {
     778               0 :                 PUTS("</div></body></html>");
     779                 :         }       
     780               0 : }
     781                 : /* }}} */
     782                 : 
     783                 : 
     784                 : PHPAPI void php_info_print_table_start()
     785               0 : {
     786               0 :         if (!sapi_module.phpinfo_as_text) {
     787               0 :                 php_printf("<table border=\"0\" cellpadding=\"3\" width=\"600\">\n");
     788                 :         } else {
     789               0 :                 php_printf("\n");
     790                 :         }       
     791               0 : }
     792                 : 
     793                 : PHPAPI void php_info_print_table_end()
     794               0 : {
     795               0 :         if (!sapi_module.phpinfo_as_text) {
     796               0 :                 php_printf("</table><br />\n");
     797                 :         }
     798                 : 
     799               0 : }
     800                 : 
     801                 : PHPAPI void php_info_print_box_start(int flag)
     802               0 : {
     803               0 :         php_info_print_table_start();
     804               0 :         if (flag) {
     805               0 :                 if (!sapi_module.phpinfo_as_text) {
     806               0 :                         php_printf("<tr class=\"h\"><td>\n");
     807                 :                 }
     808                 :         } else {
     809               0 :                 if (!sapi_module.phpinfo_as_text) {
     810               0 :                         php_printf("<tr class=\"v\"><td>\n");
     811                 :                 } else {
     812               0 :                         php_printf("\n");
     813                 :                 }       
     814                 :         }
     815               0 : }
     816                 : 
     817                 : PHPAPI void php_info_print_box_end()
     818               0 : {
     819               0 :         if (!sapi_module.phpinfo_as_text) {
     820               0 :                 php_printf("</td></tr>\n");
     821                 :         }
     822               0 :         php_info_print_table_end();
     823               0 : }
     824                 : 
     825                 : PHPAPI void php_info_print_hr()
     826               0 : {
     827               0 :         if (!sapi_module.phpinfo_as_text) {
     828               0 :                 php_printf("<hr />\n");
     829                 :         } else {
     830               0 :                 php_printf("\n\n _______________________________________________________________________\n\n");
     831                 :         }
     832               0 : }
     833                 : 
     834                 : PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header)
     835               0 : {
     836                 :         int spaces;
     837                 : 
     838               0 :         if (!sapi_module.phpinfo_as_text) {
     839               0 :                 php_printf("<tr class=\"h\"><th colspan=\"%d\">%s</th></tr>\n", num_cols, header );
     840                 :         } else {
     841               0 :                 spaces = (74 - strlen(header));
     842               0 :                 php_printf("%*s%s%*s\n", (int)(spaces/2), " ", header, (int)(spaces/2), " ");
     843                 :         }       
     844               0 : }
     845                 : 
     846                 : /* {{{ php_info_print_table_header
     847                 :  */
     848                 : PHPAPI void php_info_print_table_header(int num_cols, ...)
     849               0 : {
     850                 :         int i;
     851                 :         va_list row_elements;
     852                 :         char *row_element;
     853                 : 
     854                 :         TSRMLS_FETCH();
     855                 : 
     856               0 :         va_start(row_elements, num_cols);
     857               0 :         if (!sapi_module.phpinfo_as_text) {
     858               0 :                 php_printf("<tr class=\"h\">");
     859                 :         }       
     860               0 :         for (i=0; i<num_cols; i++) {
     861               0 :                 row_element = va_arg(row_elements, char *);
     862               0 :                 if (!row_element || !*row_element) {
     863               0 :                         row_element = " ";
     864                 :                 }
     865               0 :                 if (!sapi_module.phpinfo_as_text) {
     866               0 :                         PUTS("<th>");
     867               0 :                         PUTS(row_element);
     868               0 :                         PUTS("</th>");
     869                 :                 } else {
     870               0 :                         PUTS(row_element);
     871               0 :                         if (i < num_cols-1) {
     872               0 :                                 PUTS(" => ");
     873                 :                         } else {
     874               0 :                                 PUTS("\n");
     875                 :                         }       
     876                 :                 }       
     877                 :         }
     878               0 :         if (!sapi_module.phpinfo_as_text) {
     879               0 :                 php_printf("</tr>\n");
     880                 :         }       
     881                 : 
     882               0 :         va_end(row_elements);
     883               0 : }
     884                 : /* }}} */
     885                 : 
     886                 : /* {{{ php_info_print_table_row_internal
     887                 :  */
     888                 : static void php_info_print_table_row_internal(int num_cols, 
     889                 :                 const char *value_class, va_list row_elements)
     890               0 : {
     891                 :         int i;
     892                 :         char *row_element;
     893               0 :         char *elem_esc = NULL;
     894                 : /*
     895                 :         int elem_esc_len;
     896                 : */
     897                 : 
     898                 :         TSRMLS_FETCH();
     899                 : 
     900               0 :         if (!sapi_module.phpinfo_as_text) {
     901               0 :                 php_printf("<tr>");
     902                 :         }       
     903               0 :         for (i=0; i<num_cols; i++) {
     904               0 :                 if (!sapi_module.phpinfo_as_text) {
     905               0 :                         php_printf("<td class=\"%s\">",
     906                 :                            (i==0 ? "e" : value_class )
     907                 :                         );
     908                 :                 }       
     909               0 :                 row_element = va_arg(row_elements, char *);
     910               0 :                 if (!row_element || !*row_element) {
     911               0 :                         if (!sapi_module.phpinfo_as_text) {
     912               0 :                                 PUTS( "<i>no value</i>" );
     913                 :                         } else {
     914               0 :                                 PUTS( " " );
     915                 :                         }
     916                 :                 } else {
     917               0 :                         if (!sapi_module.phpinfo_as_text) {
     918               0 :                                 elem_esc = php_info_html_esc(row_element TSRMLS_CC);
     919               0 :                                 PUTS(elem_esc);
     920               0 :                                 efree(elem_esc);
     921                 :                         } else {
     922               0 :                                 PUTS(row_element);
     923               0 :                                 if (i < num_cols-1) {
     924               0 :                                         PUTS(" => ");
     925                 :                                 }       
     926                 :                         }
     927                 :                 }
     928               0 :                 if (!sapi_module.phpinfo_as_text) {
     929               0 :                         php_printf(" </td>");
     930               0 :                 } else if (i == (num_cols - 1)) {
     931               0 :                         PUTS("\n");
     932                 :                 }
     933                 :         }
     934               0 :         if (!sapi_module.phpinfo_as_text) {
     935               0 :                 php_printf("</tr>\n");
     936                 :         }
     937               0 : }
     938                 : /* }}} */
     939                 : 
     940                 : /* {{{ php_info_print_table_row
     941                 :  */
     942                 : PHPAPI void php_info_print_table_row(int num_cols, ...)
     943               0 : {
     944                 :         va_list row_elements;
     945                 :         
     946               0 :         va_start(row_elements, num_cols);
     947               0 :         php_info_print_table_row_internal(num_cols, "v", row_elements);
     948               0 :         va_end(row_elements);
     949               0 : }
     950                 : /* }}} */
     951                 : 
     952                 : /* {{{ php_info_print_table_row_ex
     953                 :  */
     954                 : PHPAPI void php_info_print_table_row_ex(int num_cols, const char *value_class, 
     955                 :                 ...)
     956               0 : {
     957                 :         va_list row_elements;
     958                 :         
     959               0 :         va_start(row_elements, value_class);
     960               0 :         php_info_print_table_row_internal(num_cols, value_class, row_elements);
     961               0 :         va_end(row_elements);
     962               0 : }
     963                 : /* }}} */
     964                 : 
     965                 : /* {{{ register_phpinfo_constants
     966                 :  */
     967                 : void register_phpinfo_constants(INIT_FUNC_ARGS)
     968             220 : {
     969             220 :         REGISTER_LONG_CONSTANT("INFO_GENERAL", PHP_INFO_GENERAL, CONST_PERSISTENT|CONST_CS);
     970             220 :         REGISTER_LONG_CONSTANT("INFO_CREDITS", PHP_INFO_CREDITS, CONST_PERSISTENT|CONST_CS);
     971             220 :         REGISTER_LONG_CONSTANT("INFO_CONFIGURATION", PHP_INFO_CONFIGURATION, CONST_PERSISTENT|CONST_CS);
     972             220 :         REGISTER_LONG_CONSTANT("INFO_MODULES", PHP_INFO_MODULES, CONST_PERSISTENT|CONST_CS);
     973             220 :         REGISTER_LONG_CONSTANT("INFO_ENVIRONMENT", PHP_INFO_ENVIRONMENT, CONST_PERSISTENT|CONST_CS);
     974             220 :         REGISTER_LONG_CONSTANT("INFO_VARIABLES", PHP_INFO_VARIABLES, CONST_PERSISTENT|CONST_CS);
     975             220 :         REGISTER_LONG_CONSTANT("INFO_LICENSE", PHP_INFO_LICENSE, CONST_PERSISTENT|CONST_CS);
     976             220 :         REGISTER_LONG_CONSTANT("INFO_ALL", PHP_INFO_ALL, CONST_PERSISTENT|CONST_CS);
     977             220 :         REGISTER_LONG_CONSTANT("CREDITS_GROUP",       PHP_CREDITS_GROUP, CONST_PERSISTENT|CONST_CS);
     978             220 :         REGISTER_LONG_CONSTANT("CREDITS_GENERAL",     PHP_CREDITS_GENERAL, CONST_PERSISTENT|CONST_CS);
     979             220 :         REGISTER_LONG_CONSTANT("CREDITS_SAPI",        PHP_CREDITS_SAPI, CONST_PERSISTENT|CONST_CS);
     980             220 :         REGISTER_LONG_CONSTANT("CREDITS_MODULES",     PHP_CREDITS_MODULES, CONST_PERSISTENT|CONST_CS);
     981             220 :         REGISTER_LONG_CONSTANT("CREDITS_DOCS",        PHP_CREDITS_DOCS, CONST_PERSISTENT|CONST_CS);
     982             220 :         REGISTER_LONG_CONSTANT("CREDITS_FULLPAGE",    PHP_CREDITS_FULLPAGE, CONST_PERSISTENT|CONST_CS);
     983             220 :         REGISTER_LONG_CONSTANT("CREDITS_QA",  PHP_CREDITS_QA, CONST_PERSISTENT|CONST_CS);
     984             220 :         REGISTER_LONG_CONSTANT("CREDITS_ALL", PHP_CREDITS_ALL, CONST_PERSISTENT|CONST_CS);
     985             220 : }
     986                 : /* }}} */
     987                 : 
     988                 : /* {{{ proto void phpinfo([int what])
     989                 :    Output a page of useful information about PHP and the current request */
     990                 : PHP_FUNCTION(phpinfo)
     991               0 : {
     992               0 :         int argc = ZEND_NUM_ARGS();
     993                 :         long flag;
     994                 : 
     995               0 :         if (zend_parse_parameters(argc TSRMLS_CC, "|l", &flag) == FAILURE) {
     996               0 :                 return;
     997                 :         }
     998                 : 
     999               0 :         if(!argc) {
    1000               0 :                 flag = PHP_INFO_ALL;
    1001                 :         }
    1002                 : 
    1003                 :         /* Andale!  Andale!  Yee-Hah! */
    1004               0 :         php_start_ob_buffer(NULL, 4096, 0 TSRMLS_CC);
    1005               0 :         php_print_info(flag TSRMLS_CC);
    1006               0 :         php_end_ob_buffer(1, 0 TSRMLS_CC);
    1007                 : 
    1008               0 :         RETURN_TRUE;
    1009                 : }
    1010                 : 
    1011                 : /* }}} */
    1012                 : 
    1013                 : /* {{{ proto string phpversion([string extension])
    1014                 :    Return the current PHP version */
    1015                 : PHP_FUNCTION(phpversion)
    1016               1 : {
    1017                 :         zval **arg;
    1018               1 :         int argc = ZEND_NUM_ARGS();
    1019                 : 
    1020               1 :         if (argc == 0) {
    1021               1 :                 RETURN_STRING(PHP_VERSION, 1);
    1022               0 :         } else if (argc == 1 && zend_get_parameters_ex(1, &arg) == SUCCESS) {
    1023                 :                 char *version;
    1024               0 :                 convert_to_string_ex(arg);
    1025               0 :                 version = zend_get_module_version(Z_STRVAL_PP(arg));
    1026               0 :                 if (version == NULL) {
    1027               0 :                         RETURN_FALSE;
    1028                 :                 }
    1029               0 :                 RETURN_STRING(version, 1);
    1030                 :         } else {
    1031               0 :                 WRONG_PARAM_COUNT;
    1032                 :         }
    1033                 : }
    1034                 : /* }}} */
    1035                 : 
    1036                 : /* {{{ proto void phpcredits([int flag])
    1037                 :    Prints the list of people who've contributed to the PHP project */
    1038                 : PHP_FUNCTION(phpcredits)
    1039               0 : {
    1040               0 :         int argc = ZEND_NUM_ARGS();
    1041                 :         long flag;
    1042                 : 
    1043               0 :         if (zend_parse_parameters(argc TSRMLS_CC, "|l", &flag) == FAILURE) {
    1044               0 :                 return;
    1045                 :         }
    1046                 : 
    1047               0 :         if(!argc) {
    1048               0 :                 flag = PHP_CREDITS_ALL;
    1049                 :         } 
    1050                 : 
    1051               0 :         php_print_credits(flag TSRMLS_CC);
    1052               0 :         RETURN_TRUE;
    1053                 : }
    1054                 : /* }}} */
    1055                 : 
    1056                 : 
    1057                 : /* {{{ php_logo_guid
    1058                 :  */
    1059                 : PHPAPI char *php_logo_guid()
    1060               0 : {
    1061                 :         char *logo_guid;
    1062                 : 
    1063                 :         time_t the_time;
    1064                 :         struct tm *ta, tmbuf;
    1065                 : 
    1066               0 :         the_time = time(NULL);
    1067               0 :         ta = php_localtime_r(&the_time, &tmbuf);
    1068                 : 
    1069               0 :         if ((ta->tm_mon==3) && (ta->tm_mday==1)) {
    1070               0 :                 logo_guid = PHP_EGG_LOGO_GUID;
    1071                 :         } else {
    1072               0 :                 logo_guid = PHP_LOGO_GUID;
    1073                 :         }
    1074                 : 
    1075               0 :         return estrdup(logo_guid);
    1076                 : 
    1077                 : }
    1078                 : /* }}} */
    1079                 : 
    1080                 : /* {{{ proto string php_logo_guid(void)
    1081                 :    Return the special ID used to request the PHP logo in phpinfo screens*/
    1082                 : PHP_FUNCTION(php_logo_guid)
    1083               0 : {
    1084                 : 
    1085               0 :         if (ZEND_NUM_ARGS() != 0) {
    1086               0 :                 WRONG_PARAM_COUNT;
    1087                 :         }
    1088                 : 
    1089               0 :         RETURN_STRING(php_logo_guid(), 0);
    1090                 : }
    1091                 : /* }}} */
    1092                 : 
    1093                 : /* {{{ proto string php_real_logo_guid(void)
    1094                 :    Return the special ID used to request the PHP logo in phpinfo screens*/
    1095                 : PHP_FUNCTION(php_real_logo_guid)
    1096               0 : {
    1097                 : 
    1098               0 :         if (ZEND_NUM_ARGS() != 0) {
    1099               0 :                 WRONG_PARAM_COUNT;
    1100                 :         }
    1101                 : 
    1102               0 :         RETURN_STRINGL(PHP_LOGO_GUID, sizeof(PHP_LOGO_GUID)-1, 1);
    1103                 : }
    1104                 : /* }}} */
    1105                 : 
    1106                 : /* {{{ proto string php_egg_logo_guid(void)
    1107                 :    Return the special ID used to request the PHP logo in phpinfo screens*/
    1108                 : PHP_FUNCTION(php_egg_logo_guid)
    1109               0 : {
    1110               0 :         if (ZEND_NUM_ARGS() != 0) {
    1111               0 :                 WRONG_PARAM_COUNT;
    1112                 :         }
    1113                 : 
    1114               0 :         RETURN_STRINGL(PHP_EGG_LOGO_GUID, sizeof(PHP_EGG_LOGO_GUID)-1, 1);
    1115                 : }
    1116                 : /* }}} */
    1117                 : 
    1118                 : /* {{{ proto string zend_logo_guid(void)
    1119                 :    Return the special ID used to request the Zend logo in phpinfo screens*/
    1120                 : PHP_FUNCTION(zend_logo_guid)
    1121               0 : {
    1122               0 :         if (ZEND_NUM_ARGS() != 0) {
    1123               0 :                 WRONG_PARAM_COUNT;
    1124                 :         }
    1125                 : 
    1126               0 :         RETURN_STRINGL(ZEND_LOGO_GUID, sizeof(ZEND_LOGO_GUID)-1, 1);
    1127                 : }
    1128                 : /* }}} */
    1129                 : 
    1130                 : /* {{{ proto string php_sapi_name(void)
    1131                 :    Return the current SAPI module name */
    1132                 : PHP_FUNCTION(php_sapi_name)
    1133               0 : {
    1134               0 :         if (ZEND_NUM_ARGS() != 0) {
    1135               0 :                 WRONG_PARAM_COUNT;
    1136                 :         }
    1137                 : 
    1138               0 :         if (sapi_module.name) {
    1139               0 :                 RETURN_STRING(sapi_module.name, 1);
    1140                 :         } else {
    1141               0 :                 RETURN_FALSE;
    1142                 :         }
    1143                 : }
    1144                 : 
    1145                 : /* }}} */
    1146                 : 
    1147                 : /* {{{ proto string php_uname(void)
    1148                 :    Return information about the system PHP was built on */
    1149                 : PHP_FUNCTION(php_uname)
    1150               1 : {
    1151               1 :         char *mode = "a";
    1152                 :         int modelen;
    1153               1 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &mode, &modelen) == FAILURE) {
    1154               0 :                 return;
    1155                 :         }
    1156               1 :         RETURN_STRING(php_get_uname(*mode), 0);
    1157                 : }
    1158                 : 
    1159                 : /* }}} */
    1160                 : 
    1161                 : /* {{{ proto string php_ini_scanned_files(void)
    1162                 :    Return comma-separated string of .ini files parsed from the additional ini dir */
    1163                 : PHP_FUNCTION(php_ini_scanned_files)
    1164               1 : {
    1165                 :         if (strlen(PHP_CONFIG_FILE_SCAN_DIR) && php_ini_scanned_files) {
    1166                 :                 RETURN_STRING(php_ini_scanned_files, 1);
    1167                 :         } else {
    1168               1 :                 RETURN_FALSE;
    1169                 :         }
    1170                 : }
    1171                 : /* }}} */
    1172                 : 
    1173                 : /*
    1174                 :  * Local variables:
    1175                 :  * tab-width: 4
    1176                 :  * c-basic-offset: 4
    1177                 :  * End:
    1178                 :  * vim600: sw=4 ts=4 fdm=marker
    1179                 :  * vim<600: sw=4 ts=4
    1180                 :  */

Generated by: LTP GCOV extension version 1.5