PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - standard - info.c
Test: PHP Code Coverage
Date: 2009-11-19 Instrumented lines: 516
Code covered: 90.9 % Executed lines: 469
Legend: not executed executed

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

Generated by: LTP GCOV extension version 1.5

Generated at Thu, 19 Nov 2009 08:20:22 +0000 (5 days ago)

Copyright © 2005-2009 The PHP Group
All rights reserved.