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-23 Instrumented lines: 499
Code covered: 91.2 % Executed lines: 455
Legend: not executed executed

       1                 : /* 
       2                 :    +----------------------------------------------------------------------+
       3                 :    | PHP Version 6                                                        |
       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 284606 2009-07-22 13:57:34Z dsp $ */
      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                 : 
      42                 : #ifdef PHP_WIN32
      43                 : typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
      44                 : typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
      45                 : # include "winver.h"
      46                 : 
      47                 : # if _MSC_VER < 1300
      48                 : #  define OSVERSIONINFOEX php_win_OSVERSIONINFOEX
      49                 : # endif
      50                 : #endif
      51                 : 
      52                 : #if HAVE_MBSTRING
      53                 : #include "ext/mbstring/mbstring.h"
      54                 : ZEND_EXTERN_MODULE_GLOBALS(mbstring)
      55                 : #endif
      56                 : 
      57                 : #if HAVE_ICONV
      58                 : #include "ext/iconv/php_iconv.h"
      59                 : ZEND_EXTERN_MODULE_GLOBALS(iconv)
      60                 : #endif
      61                 : 
      62                 : #include <unicode/uversion.h>
      63                 : 
      64                 : #define SECTION(name)   if (!sapi_module.phpinfo_as_text) { \
      65                 :                                                         php_info_print("<h2>" name "</h2>\n"); \
      66                 :                                                 } else { \
      67                 :                                                         php_info_print_table_start(); \
      68                 :                                                         php_info_print_table_header(1, name); \
      69                 :                                                         php_info_print_table_end(); \
      70                 :                                                 } \
      71                 : 
      72                 : PHPAPI extern char *php_ini_opened_path;
      73                 : PHPAPI extern char *php_ini_scanned_path;
      74                 : PHPAPI extern char *php_ini_scanned_files;
      75                 : 
      76                 : static int php_info_print_html_esc(const char *str, int len) /* {{{ */
      77            1323 : {
      78                 :         int new_len, written;
      79                 :         char *new_str;
      80                 :         TSRMLS_FETCH();
      81                 :         
      82            1323 :         new_str = php_escape_html_entities((char *) str, len, &new_len, 0, ENT_QUOTES, "utf-8" TSRMLS_CC);
      83            1323 :         written = php_output_write_utf8(new_str, new_len TSRMLS_CC);
      84            1323 :         efree(new_str);
      85            1323 :         return written;
      86                 : }
      87                 : /* }}} */
      88                 : 
      89                 : static int php_info_uprint_html_esc(const UChar *str, int len) /* {{{ */
      90               3 : {
      91               3 :         UErrorCode status = U_ZERO_ERROR;
      92               3 :         char *new_str = NULL;
      93                 :         int new_len, written;
      94                 :         TSRMLS_FETCH();
      95                 :         
      96               3 :         zend_unicode_to_string_ex(UG(utf8_conv), &new_str, &new_len, str, len, &status);
      97               3 :         if (U_FAILURE(status)) {
      98               0 :                 return 0;
      99                 :         }
     100               3 :         written = php_info_print_html_esc(new_str, new_len);
     101               3 :         efree(new_str);
     102               3 :         return written;
     103                 : }
     104                 : /* }}} */
     105                 : 
     106                 : static int php_info_printf(const char *fmt, ...) /* {{{ */
     107            1417 : {
     108                 :         char *buf;
     109                 :         int len, written;
     110                 :         va_list argv;
     111                 :         TSRMLS_FETCH();
     112                 :         
     113            1417 :         va_start(argv, fmt);
     114            1417 :         len = vspprintf(&buf, 0, fmt, argv);
     115            1417 :         va_end(argv);
     116                 :         
     117            1417 :         written = php_output_write_utf8(buf, len TSRMLS_CC);
     118            1417 :         efree(buf);
     119            1417 :         return written;
     120                 : }
     121                 : /* }}} */
     122                 : 
     123                 : static void php_info_print_request_uri(TSRMLS_D) /* {{{ */
     124               3 : {
     125               3 :         if (SG(request_info).request_uri) {
     126               0 :                 php_info_print_html_esc(SG(request_info).request_uri, strlen(SG(request_info).request_uri));
     127                 :         }
     128               3 : }
     129                 : /* }}} */
     130                 : 
     131                 : static int php_info_print(const char *str) /* {{{ */
     132          118779 : {
     133                 :         TSRMLS_FETCH();
     134          118779 :         return php_output_write_utf8(str, strlen(str) TSRMLS_CC);
     135                 : }
     136                 : /* }}} */
     137                 : 
     138                 : static int php_info_uprint(const UChar *str, int len) /* {{{ */
     139              52 : {
     140                 :         TSRMLS_FETCH();
     141              52 :         return php_output_write_unicode(str, len TSRMLS_CC);
     142                 : }
     143                 : /* }}} */
     144                 : 
     145                 : static void php_info_print_stream_hash(const char *name, HashTable *ht TSRMLS_DC) /* {{{ */
     146              81 : {
     147                 :         zstr key;
     148                 :         uint len;
     149                 :         int type;
     150                 :         
     151              81 :         if (ht) {
     152              81 :                 if (zend_hash_num_elements(ht)) {
     153                 :                         HashPosition pos;
     154                 : 
     155              81 :                         if (!sapi_module.phpinfo_as_text) {
     156               3 :                                 php_info_printf("<tr class=\"v\"><td>Registered %s</td><td>", name);
     157                 :                         } else {
     158              78 :                                 php_info_printf("\nRegistered %s => ", name);
     159                 :                         }
     160                 :                         
     161              81 :                         zend_hash_internal_pointer_reset_ex(ht, &pos);
     162              81 :                         type = zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos);
     163                 :                         do {
     164             918 :                                 switch (type) {
     165                 :                                         case IS_STRING:
     166             918 :                                                 php_info_print(key.s);
     167             918 :                                                 break;
     168                 :                                         case IS_UNICODE:
     169               0 :                                                 php_info_uprint(key.u, len);
     170                 :                                                 break;
     171                 :                                 }
     172                 :                                 
     173             918 :                                 zend_hash_move_forward_ex(ht, &pos);
     174             918 :                                 type = zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos);
     175                 :                                 
     176             918 :                                 if (type == IS_STRING || type == IS_UNICODE) {
     177             837 :                                         php_info_print(", ");
     178                 :                                 } else {
     179                 :                                         break;
     180                 :                                 }
     181             837 :                         } while (1);
     182                 :                         
     183              81 :                         if (!sapi_module.phpinfo_as_text) {
     184               3 :                                 php_info_print("</td></tr>\n");
     185                 :                         }
     186                 :                 } else {
     187                 :                         char reg_name[128];
     188               0 :                         snprintf(reg_name, sizeof(reg_name), "Registered %s", name);
     189               0 :                         php_info_print_table_row(2, reg_name, "none registered");
     190                 :                 }
     191                 :         } else {
     192               0 :                 php_info_print_table_row(2, name, "disabled");
     193                 :         }
     194              81 : }
     195                 : /* }}} */
     196                 : 
     197                 : PHPAPI void php_info_print_module(zend_module_entry *zend_module TSRMLS_DC) /* {{{ */
     198            2972 : {
     199            5815 :         if (zend_module->info_func || zend_module->version) {
     200            2843 :                 if (!sapi_module.phpinfo_as_text) {
     201              67 :                         php_info_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", zend_module->name, zend_module->name);
     202                 :                 } else {
     203            2776 :                         php_info_print_table_start();
     204            2776 :                         php_info_print_table_header(1, zend_module->name);
     205            2776 :                         php_info_print_table_end();
     206                 :                 }
     207            2843 :                 if (zend_module->info_func) {
     208            2843 :                         zend_module->info_func(zend_module TSRMLS_CC);
     209                 :                 } else {
     210               0 :                         php_info_print_table_start();
     211               0 :                         php_info_print_table_row(2, "Version", zend_module->version);
     212               0 :                         php_info_print_table_end();
     213               0 :                         DISPLAY_INI_ENTRIES();
     214                 :                 }
     215                 :         } else {
     216             129 :                 if (!sapi_module.phpinfo_as_text) {
     217               3 :                         php_info_printf("<tr><td>%s</td></tr>\n", zend_module->name);
     218                 :                 } else {
     219             126 :                         php_info_printf("%s\n", zend_module->name);
     220                 :                 }       
     221                 :         }
     222            2972 : }
     223                 : /* }}} */
     224                 : 
     225                 : static int _display_module_info_func(zend_module_entry *module TSRMLS_DC) /* {{{ */
     226            2968 : {
     227            2968 :         if (module->info_func || module->version) {
     228            2839 :                 php_info_print_module(module TSRMLS_CC);
     229                 :         }
     230            2968 :         return ZEND_HASH_APPLY_KEEP;
     231                 : }
     232                 : /* }}} */
     233                 : 
     234                 : static int _display_module_info_def(zend_module_entry *module TSRMLS_DC) /* {{{ */
     235            2968 : {
     236            2968 :         if (!module->info_func && !module->version) {
     237             129 :                 php_info_print_module(module TSRMLS_CC);
     238                 :         }
     239            2968 :         return ZEND_HASH_APPLY_KEEP;
     240                 : }
     241                 : /* }}} */
     242                 : 
     243                 : /* {{{ php_print_gpcse_array
     244                 :  */
     245                 : static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
     246             189 : {
     247                 :         zval **data, **tmp, tmp2;
     248                 :         zstr string_key;
     249                 :         uint string_len;
     250                 :         ulong num_key;
     251                 : 
     252             189 :         zend_is_auto_global(name, name_length TSRMLS_CC);
     253                 : 
     254             189 :         if (zend_hash_find(&EG(symbol_table), name, name_length+1, (void **) &data)!=FAILURE
     255                 :                 && (Z_TYPE_PP(data)==IS_ARRAY)) {
     256             162 :                 zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data));
     257            2998 :                 while (zend_hash_get_current_data(Z_ARRVAL_PP(data), (void **) &tmp) == SUCCESS) {
     258            2674 :                         if (!sapi_module.phpinfo_as_text) {
     259             102 :                                 php_info_print("<tr>");
     260             102 :                                 php_info_print("<td class=\"e\">");
     261                 :                         }
     262                 : 
     263            2674 :                         php_info_print(name);
     264            2674 :                         php_info_print("[\"");
     265                 :                         
     266            2674 :                         switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL)) {
     267                 :                                 case HASH_KEY_IS_UNICODE:
     268              55 :                                         if (!sapi_module.phpinfo_as_text) {
     269               3 :                                                 php_info_uprint_html_esc(string_key.u, string_len-1);
     270                 :                                         } else {
     271              52 :                                                 php_info_uprint(string_key.u, string_len);
     272                 :                                         }
     273              55 :                                         break;
     274                 :                                 case HASH_KEY_IS_STRING:
     275            2619 :                                         if (!sapi_module.phpinfo_as_text) {
     276              99 :                                                 php_info_print_html_esc(string_key.s, string_len-1);
     277                 :                                         } else {
     278            2520 :                                                 php_info_print(string_key.s);
     279                 :                                         }
     280            2619 :                                         break;
     281                 :                                 case HASH_KEY_IS_LONG:
     282               0 :                                         php_info_printf("%ld", num_key);
     283                 :                                         break;
     284                 :                         }
     285            2674 :                         php_info_print("\"]");
     286            2674 :                         if (!sapi_module.phpinfo_as_text) {
     287             102 :                                 php_info_print("</td><td class=\"v\">");
     288                 :                         } else {
     289            2572 :                                 php_info_print(" => ");
     290                 :                         }
     291            2674 :                         if (Z_TYPE_PP(tmp) == IS_ARRAY) {
     292              27 :                                 if (!sapi_module.phpinfo_as_text) {
     293               1 :                                         php_info_print("<pre>");
     294               1 :                                         zend_print_zval_r_ex((zend_write_func_t) php_info_print_html_esc, *tmp, 0 TSRMLS_CC);
     295               1 :                                         php_info_print("</pre>");
     296                 :                                 } else {
     297              26 :                                         zend_print_zval_r(*tmp, 0 TSRMLS_CC);
     298                 :                                 }
     299                 :                         } else {
     300            2647 :                                 tmp2 = **tmp;
     301            2647 :                                 switch (Z_TYPE_PP(tmp)) {
     302                 :                                         default:
     303              54 :                                                 tmp = NULL;
     304              54 :                                                 zval_copy_ctor(&tmp2);
     305              54 :                                                 convert_to_string(&tmp2);
     306                 :                                         case IS_STRING:
     307                 :                                         case IS_UNICODE:
     308            2647 :                                                 if (!sapi_module.phpinfo_as_text) {
     309             101 :                                                         if (Z_UNILEN(tmp2) == 0) {
     310               1 :                                                                 php_info_print("<i>no value</i>");
     311             100 :                                                         } else if (Z_TYPE(tmp2) == IS_UNICODE){
     312               0 :                                                                 php_info_uprint_html_esc(Z_USTRVAL(tmp2), Z_USTRLEN(tmp2));
     313                 :                                                         } else {
     314             100 :                                                                 php_info_print_html_esc(Z_STRVAL(tmp2), Z_STRLEN(tmp2));
     315                 :                                                         }
     316            2546 :                                                 } else if(Z_TYPE(tmp2) == IS_UNICODE) {
     317               0 :                                                         php_info_uprint(Z_USTRVAL(tmp2), Z_USTRLEN(tmp2));
     318                 :                                                 } else {
     319            2546 :                                                         php_info_print(Z_STRVAL(tmp2));
     320                 :                                                 }
     321                 :                                 }
     322            2647 :                                 if (!tmp) {
     323              54 :                                         zval_dtor(&tmp2);
     324                 :                                 }
     325                 :                         }
     326            2674 :                         if (!sapi_module.phpinfo_as_text) {
     327             102 :                                 php_info_print("</td></tr>\n");
     328                 :                         } else {
     329            2572 :                                 php_info_print("\n");
     330                 :                         }
     331            2674 :                         zend_hash_move_forward(Z_ARRVAL_PP(data));
     332                 :                 }
     333                 :         }
     334             189 : }
     335                 : /* }}} */
     336                 : 
     337                 : /* {{{ php_info_print_style
     338                 :  */
     339                 : void php_info_print_style(TSRMLS_D)
     340               4 : {
     341               4 :         php_info_printf("<style type=\"text/css\">\n");
     342               4 :         php_info_print_css(TSRMLS_C);
     343               4 :         php_info_printf("</style>\n");
     344               4 : }
     345                 : /* }}} */
     346                 : 
     347                 : /* {{{ php_info_html_esc
     348                 :  */
     349                 : PHPAPI char *php_info_html_esc(char *string TSRMLS_DC)
     350               0 : {
     351                 :         int new_len;
     352               0 :         return php_escape_html_entities(string, strlen(string), &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
     353                 : }
     354                 : /* }}} */
     355                 : 
     356                 : #ifdef PHP_WIN32
     357                 : /* {{{  */
     358                 : 
     359                 : char* php_get_windows_name()
     360                 : {
     361                 :         OSVERSIONINFOEX osvi;
     362                 :         SYSTEM_INFO si;
     363                 :         PGNSI pGNSI;
     364                 :         PGPI pGPI;
     365                 :         BOOL bOsVersionInfoEx;
     366                 :         DWORD dwType;
     367                 :         char *major = NULL, *sub = NULL, *retval;
     368                 : 
     369                 :         ZeroMemory(&si, sizeof(SYSTEM_INFO));
     370                 :         ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
     371                 :         osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
     372                 : 
     373                 :         if (!(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi))) {
     374                 :                 return NULL;
     375                 :         }
     376                 : 
     377                 :         pGNSI = (PGNSI) GetProcAddress(GetModuleHandle("kernel32.dll"), "GetNativeSystemInfo");
     378                 :         if(NULL != pGNSI) {
     379                 :                 pGNSI(&si);
     380                 :         } else {
     381                 :                 GetSystemInfo(&si);
     382                 :         }
     383                 : 
     384                 :         if (VER_PLATFORM_WIN32_NT==osvi.dwPlatformId && osvi.dwMajorVersion > 4 ) {
     385                 :                 if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )      {
     386                 :                         if (osvi.wProductType == VER_NT_WORKSTATION) {
     387                 :                                 major = "Windows Vista";
     388                 :                         } else {
     389                 :                                 major = "Windows Server 2008";
     390                 :                         }
     391                 : 
     392                 :                         pGPI = (PGPI) GetProcAddress(GetModuleHandle("kernel32.dll"), "GetProductInfo");
     393                 :                         pGPI(6, 0, 0, 0, &dwType);
     394                 : 
     395                 :                         switch (dwType) {
     396                 :                                 case PRODUCT_ULTIMATE:
     397                 :                                         sub = "Ultimate Edition";
     398                 :                                         break;
     399                 :                                 case PRODUCT_HOME_PREMIUM:
     400                 :                                         sub = "Home Premium Edition";
     401                 :                                         break;
     402                 :                                 case PRODUCT_HOME_BASIC:
     403                 :                                         sub = "Home Basic Edition";
     404                 :                                         break;
     405                 :                                 case PRODUCT_ENTERPRISE:
     406                 :                                         sub = "Enterprise Edition";
     407                 :                                         break;
     408                 :                                 case PRODUCT_BUSINESS:
     409                 :                                         sub = "Business Edition";
     410                 :                                         break;
     411                 :                                 case PRODUCT_STARTER:
     412                 :                                         sub = "Starter Edition";
     413                 :                                         break;
     414                 :                                 case PRODUCT_CLUSTER_SERVER:
     415                 :                                         sub = "Cluster Server Edition";
     416                 :                                         break;
     417                 :                                 case PRODUCT_DATACENTER_SERVER:
     418                 :                                         sub = "Datacenter Edition";
     419                 :                                         break;
     420                 :                                 case PRODUCT_DATACENTER_SERVER_CORE:
     421                 :                                         sub = "Datacenter Edition (core installation)";
     422                 :                                         break;
     423                 :                                 case PRODUCT_ENTERPRISE_SERVER:
     424                 :                                         sub = "Enterprise Edition";
     425                 :                                         break;
     426                 :                                 case PRODUCT_ENTERPRISE_SERVER_CORE:
     427                 :                                         sub = "Enterprise Edition (core installation)";
     428                 :                                         break;
     429                 :                                 case PRODUCT_ENTERPRISE_SERVER_IA64:
     430                 :                                         sub = "Enterprise Edition for Itanium-based Systems";
     431                 :                                         break;
     432                 :                                 case PRODUCT_SMALLBUSINESS_SERVER:
     433                 :                                         sub = "Small Business Server";
     434                 :                                         break;
     435                 :                                 case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
     436                 :                                         sub = "Small Business Server Premium Edition";
     437                 :                                         break;
     438                 :                                 case PRODUCT_STANDARD_SERVER:
     439                 :                                         sub = "Standard Edition";
     440                 :                                         break;
     441                 :                                 case PRODUCT_STANDARD_SERVER_CORE:
     442                 :                                         sub = "Standard Edition (core installation)";
     443                 :                                         break;
     444                 :                                 case PRODUCT_WEB_SERVER:
     445                 :                                         sub = "Web Server Edition";
     446                 :                                         break;
     447                 :                         }
     448                 :                 }
     449                 : 
     450                 :                 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )     {
     451                 :                         if (GetSystemMetrics(SM_SERVERR2))
     452                 :                                 major = "Windows Server 2003 R2";
     453                 :                         else if (osvi.wSuiteMask==VER_SUITE_STORAGE_SERVER)
     454                 :                                 major = "Windows Storage Server 2003";
     455                 :                         else if (osvi.wSuiteMask==VER_SUITE_WH_SERVER)
     456                 :                                 major = "Windows Home Server";
     457                 :                         else if (osvi.wProductType == VER_NT_WORKSTATION &&
     458                 :                                 si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) {
     459                 :                                 major = "Windows XP Professional x64 Edition";
     460                 :                         } else {
     461                 :                                 major = "Windows Server 2003";
     462                 :                         }
     463                 : 
     464                 :                         /* Test for the server type. */
     465                 :                         if ( osvi.wProductType != VER_NT_WORKSTATION ) {
     466                 :                                 if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 ) {
     467                 :                                         if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
     468                 :                                                 sub = "Datacenter Edition for Itanium-based Systems";
     469                 :                                         else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
     470                 :                                                 sub = "Enterprise Edition for Itanium-based Systems";
     471                 :                                 }
     472                 : 
     473                 :                                 else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 ) {
     474                 :                                         if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
     475                 :                                                 sub = "Datacenter x64 Edition";
     476                 :                                         else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
     477                 :                                                 sub = "Enterprise x64 Edition";
     478                 :                                         else sub = "Standard x64 Edition";
     479                 :                                 } else {
     480                 :                                         if ( osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER )
     481                 :                                                 sub = "Compute Cluster Edition";
     482                 :                                         else if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
     483                 :                                                 sub = "Datacenter Edition";
     484                 :                                         else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
     485                 :                                                 sub = "Enterprise Edition";
     486                 :                                         else if ( osvi.wSuiteMask & VER_SUITE_BLADE )
     487                 :                                                 sub = "Web Edition";
     488                 :                                         else sub = "Standard Edition";
     489                 :                                 }
     490                 :                         } 
     491                 :                 }
     492                 : 
     493                 :                 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )     {
     494                 :                         major = "Windows XP";
     495                 :                         if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
     496                 :                                 sub = "Home Edition";
     497                 :                         else sub = "Professional";
     498                 :                 }
     499                 : 
     500                 :                 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 ) {
     501                 :                         major = "Windows 2000";
     502                 : 
     503                 :                         if (osvi.wProductType == VER_NT_WORKSTATION ) {
     504                 :                                 sub = "Professional";
     505                 :                         } else {
     506                 :                                 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
     507                 :                                         sub = "Datacenter Server";
     508                 :                                 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
     509                 :                                         sub = "Advanced Server";
     510                 :                                 else sub = "Server";
     511                 :                         }
     512                 :                 }
     513                 :         } else {
     514                 :                 return NULL;
     515                 :         }
     516                 : 
     517                 :         spprintf(&retval, 0, "%s%s%s%s%s", major, sub?" ":"", sub?sub:"", osvi.szCSDVersion[0] != '\0'?" ":"", osvi.szCSDVersion);
     518                 :         return retval;
     519                 : }
     520                 : /* }}}  */
     521                 : 
     522                 : /* {{{  */
     523                 : void php_get_windows_cpu(char *buf, int bufsize)
     524                 : {
     525                 :         SYSTEM_INFO SysInfo;
     526                 :         GetSystemInfo(&SysInfo);
     527                 :         switch (SysInfo.wProcessorArchitecture) {
     528                 :                 case PROCESSOR_ARCHITECTURE_INTEL :
     529                 :                         snprintf(buf, bufsize, "i%d", SysInfo.dwProcessorType);
     530                 :                         break;
     531                 :                 case PROCESSOR_ARCHITECTURE_MIPS :
     532                 :                         snprintf(buf, bufsize, "MIPS R%d000", SysInfo.wProcessorLevel);
     533                 :                         break;
     534                 :                 case PROCESSOR_ARCHITECTURE_ALPHA :
     535                 :                         snprintf(buf, bufsize, "Alpha %d", SysInfo.wProcessorLevel);
     536                 :                         break;
     537                 :                 case PROCESSOR_ARCHITECTURE_PPC :
     538                 :                         snprintf(buf, bufsize, "PPC 6%02d", SysInfo.wProcessorLevel);
     539                 :                         break;
     540                 :                 case PROCESSOR_ARCHITECTURE_IA64 :
     541                 :                         snprintf(buf, bufsize,  "IA64");
     542                 :                         break;
     543                 : #if defined(PROCESSOR_ARCHITECTURE_IA32_ON_WIN64)
     544                 :                 case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 :
     545                 :                         snprintf(buf, bufsize, "IA32");
     546                 :                         break;
     547                 : #endif
     548                 : #if defined(PROCESSOR_ARCHITECTURE_AMD64)
     549                 :                 case PROCESSOR_ARCHITECTURE_AMD64 :
     550                 :                         snprintf(buf, bufsize, "AMD64");
     551                 :                         break;
     552                 : #endif
     553                 :                 case PROCESSOR_ARCHITECTURE_UNKNOWN :
     554                 :                 default:
     555                 :                         snprintf(buf, bufsize, "Unknown");
     556                 :                         break;
     557                 :         }
     558                 : }
     559                 : /* }}}  */
     560                 : #endif
     561                 : 
     562                 : /* {{{ php_get_uname
     563                 :  */
     564                 : PHPAPI char *php_get_uname(char mode)
     565             580 : {
     566                 :         char *php_uname;
     567                 :         char tmp_uname[256];
     568                 : #ifdef PHP_WIN32
     569                 :         DWORD dwBuild=0;
     570                 :         DWORD dwVersion = GetVersion();
     571                 :         DWORD dwWindowsMajorVersion =  (DWORD)(LOBYTE(LOWORD(dwVersion)));
     572                 :         DWORD dwWindowsMinorVersion =  (DWORD)(HIBYTE(LOWORD(dwVersion)));
     573                 :         DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
     574                 :         char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
     575                 :         
     576                 :         GetComputerName(ComputerName, &dwSize);
     577                 : 
     578                 :         if (mode == 's') {
     579                 :                 if (dwVersion < 0x80000000) {
     580                 :                         php_uname = "Windows NT";
     581                 :                 } else {
     582                 :                         php_uname = "Windows 9x";
     583                 :                 }
     584                 :         } else if (mode == 'r') {
     585                 :                 snprintf(tmp_uname, sizeof(tmp_uname), "%d.%d", dwWindowsMajorVersion, dwWindowsMinorVersion);
     586                 :                 php_uname = tmp_uname;
     587                 :         } else if (mode == 'n') {
     588                 :                 php_uname = ComputerName;
     589                 :         } else if (mode == 'v') {
     590                 :                 char *winver = php_get_windows_name();
     591                 :                 dwBuild = (DWORD)(HIWORD(dwVersion));
     592                 :                 if(winver == NULL) {
     593                 :                         snprintf(tmp_uname, sizeof(tmp_uname), "build %d", dwBuild);
     594                 :                 } else {
     595                 :                         snprintf(tmp_uname, sizeof(tmp_uname), "build %d (%s)", dwBuild, winver);
     596                 :                 }
     597                 :                 php_uname = tmp_uname;
     598                 :                 if(winver) {
     599                 :                         efree(winver);
     600                 :                 }
     601                 :         } else if (mode == 'm') {
     602                 :                 php_get_windows_cpu(tmp_uname, sizeof(tmp_uname));
     603                 :                 php_uname = tmp_uname;
     604                 :         } else { /* assume mode == 'a' */
     605                 :                 /* Get build numbers for Windows NT or Win95 */
     606                 :                 if (dwVersion < 0x80000000){
     607                 :                         char *winver = php_get_windows_name();
     608                 :                         char wincpu[20];
     609                 : 
     610                 :                         php_get_windows_cpu(wincpu, sizeof(wincpu));
     611                 :                         dwBuild = (DWORD)(HIWORD(dwVersion));
     612                 :                         snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %d.%d build %d (%s) %s",
     613                 :                                          "Windows NT", ComputerName,
     614                 :                                          dwWindowsMajorVersion, dwWindowsMinorVersion, dwBuild, winver?winver:"unknown", wincpu);
     615                 :                         if(winver) {
     616                 :                                 efree(winver);
     617                 :                         }
     618                 :                 } else {
     619                 :                         snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %d.%d",
     620                 :                                          "Windows 9x", ComputerName,
     621                 :                                          dwWindowsMajorVersion, dwWindowsMinorVersion);
     622                 :                 }
     623                 :                 php_uname = tmp_uname;
     624                 :         }
     625                 : #else
     626                 : #ifdef HAVE_SYS_UTSNAME_H
     627                 :         struct utsname buf;
     628             580 :         if (uname((struct utsname *)&buf) == -1) {
     629               0 :                 php_uname = PHP_UNAME;
     630                 :         } else {
     631                 : #ifdef NETWARE
     632                 :                 if (mode == 's') {
     633                 :                         php_uname = buf.sysname;
     634                 :                 } else if (mode == 'r') {
     635                 :                         snprintf(tmp_uname, sizeof(tmp_uname), "%d.%d.%d", 
     636                 :                                          buf.netware_major, buf.netware_minor, buf.netware_revision);
     637                 :                         php_uname = tmp_uname;
     638                 :                 } else if (mode == 'n') {
     639                 :                         php_uname = buf.servername;
     640                 :                 } else if (mode == 'v') {
     641                 :                         snprintf(tmp_uname, sizeof(tmp_uname), "libc-%d.%d.%d #%d",
     642                 :                                          buf.libmajor, buf.libminor, buf.librevision, buf.libthreshold);
     643                 :                         php_uname = tmp_uname;
     644                 :                 } else if (mode == 'm') {
     645                 :                         php_uname = buf.machine;
     646                 :                 } else { /* assume mode == 'a' */
     647                 :                         snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %d.%d.%d libc-%d.%d.%d #%d %s",
     648                 :                                          buf.sysname, buf.servername,
     649                 :                                          buf.netware_major, buf.netware_minor, buf.netware_revision,
     650                 :                                          buf.libmajor, buf.libminor, buf.librevision, buf.libthreshold,
     651                 :                                          buf.machine);
     652                 :                         php_uname = tmp_uname;
     653                 :                 }
     654                 : #else
     655             580 :                 if (mode == 's') {
     656               2 :                         php_uname = buf.sysname;
     657             578 :                 } else if (mode == 'r') {
     658               1 :                         php_uname = buf.release;
     659             577 :                 } else if (mode == 'n') {
     660             523 :                         php_uname = buf.nodename;
     661              54 :                 } else if (mode == 'v') {
     662               1 :                         php_uname = buf.version;
     663              53 :                 } else if (mode == 'm') {
     664               2 :                         php_uname = buf.machine;
     665                 :                 } else { /* assume mode == 'a' */
     666              51 :                         snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %s %s %s",
     667                 :                                          buf.sysname, buf.nodename, buf.release, buf.version,
     668                 :                                          buf.machine);
     669              51 :                         php_uname = tmp_uname;
     670                 :                 }
     671                 : #endif /* NETWARE */
     672                 :         }
     673                 : #else
     674                 :         php_uname = PHP_UNAME;
     675                 : #endif
     676                 : #endif
     677             580 :         return estrdup(php_uname);
     678                 : }
     679                 : /* }}} */
     680                 : 
     681                 : /* {{{ php_print_info_htmlhead
     682                 :  */
     683                 : PHPAPI void php_print_info_htmlhead(TSRMLS_D)
     684               4 : {
     685               4 :         php_info_print("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n");
     686               4 :         php_info_print("<html>");
     687               4 :         php_info_print("<head>\n");
     688               4 :         php_info_print_style(TSRMLS_C);
     689               4 :         php_info_print("<title>phpinfo()</title>");
     690               4 :         php_info_print("<meta name=\"ROBOTS\" content=\"NOINDEX,NOFOLLOW,NOARCHIVE\" />");
     691               4 :         php_info_print("</head>\n");
     692               4 :         php_info_print("<body><div class=\"center\">\n");
     693               4 : }
     694                 : /* }}} */
     695                 : 
     696                 : /* {{{ module_name_cmp */
     697                 : static int module_name_cmp(const void *a, const void *b TSRMLS_DC)
     698           15980 : {
     699           15980 :         Bucket *f = *((Bucket **) a);
     700           15980 :         Bucket *s = *((Bucket **) b);
     701                 : 
     702           15980 :         return strcasecmp(((zend_module_entry *)f->pData)->name,
     703                 :                                   ((zend_module_entry *)s->pData)->name);
     704                 : }
     705                 : /* }}} */
     706                 : 
     707                 : /* {{{ php_print_info
     708                 :  */
     709                 : PHPAPI void php_print_info(int flag TSRMLS_DC)
     710              47 : {
     711                 :         char **env, *tmp1, *tmp2;
     712                 :         char *php_uname;
     713              47 :         int expose_php = INI_INT("expose_php");
     714                 : 
     715              47 :         if (!sapi_module.phpinfo_as_text) {
     716               3 :                 php_print_info_htmlhead(TSRMLS_C);
     717                 :         } else {
     718              44 :                 php_info_print("phpinfo()\n");
     719                 :         }
     720                 : 
     721              47 :         if (flag & PHP_INFO_GENERAL) {
     722              27 :                 char *zend_version = get_zend_version();
     723                 :                 char temp_api[10];
     724                 :                 char *logo_guid;
     725                 : 
     726              27 :                 php_uname = php_get_uname('a');
     727                 :                 
     728              27 :                 if (!sapi_module.phpinfo_as_text) {
     729               1 :                         php_info_print_box_start(1);
     730                 :                 }
     731                 : 
     732              27 :                 if (expose_php && !sapi_module.phpinfo_as_text) {
     733               1 :                         php_info_print("<a href=\"http://www.php.net/\"><img border=\"0\" src=\"");
     734               1 :                         php_info_print_request_uri(TSRMLS_C);
     735               1 :                         php_info_print("?=");
     736               1 :                         logo_guid = php_logo_guid();
     737               1 :                         php_info_print(logo_guid);
     738               1 :                         efree(logo_guid);
     739               1 :                         php_info_print("\" alt=\"PHP Logo\" /></a>");
     740                 :                 }
     741                 : 
     742              27 :                 if (!sapi_module.phpinfo_as_text) {
     743               1 :                         php_info_printf("<h1 class=\"p\">PHP Version %s</h1>\n", PHP_VERSION);
     744                 :                 } else {
     745              26 :                         php_info_print_table_row(2, "PHP Version", PHP_VERSION);
     746                 :                 }       
     747              27 :                 php_info_print_box_end();
     748              27 :                 php_info_print_table_start();
     749              27 :                 php_info_print_table_row(2, "System", php_uname );
     750              27 :                 php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__ );
     751                 : #ifdef COMPILER
     752                 :                 php_info_print_table_row(2, "Compiler", COMPILER);
     753                 : #endif
     754                 : #ifdef ARCHITECTURE
     755                 :                 php_info_print_table_row(2, "Architecture", ARCHITECTURE);
     756                 : #endif
     757                 : #ifdef CONFIGURE_COMMAND
     758              27 :                 php_info_print_table_row(2, "Configure Command", CONFIGURE_COMMAND );
     759                 : #endif
     760                 : 
     761              27 :                 if (sapi_module.pretty_name) {
     762              27 :                         php_info_print_table_row(2, "Server API", sapi_module.pretty_name );
     763                 :                 }
     764                 : 
     765                 : #ifdef VIRTUAL_DIR
     766                 :                 php_info_print_table_row(2, "Virtual Directory Support", "enabled" );
     767                 : #else
     768              27 :                 php_info_print_table_row(2, "Virtual Directory Support", "disabled" );
     769                 : #endif
     770                 : 
     771              27 :                 php_info_print_table_row(2, "Configuration File (php.ini) Path", PHP_CONFIG_FILE_PATH);
     772              27 :                 php_info_print_table_row(2, "Loaded Configuration File", php_ini_opened_path ? php_ini_opened_path : "(none)");
     773              27 :                 php_info_print_table_row(2, "Scan this dir for additional .ini files", php_ini_scanned_path ? php_ini_scanned_path : "(none)");
     774              27 :                 php_info_print_table_row(2, "Additional .ini files parsed", php_ini_scanned_files ? php_ini_scanned_files : "(none)");
     775                 : 
     776              27 :                 snprintf(temp_api, sizeof(temp_api), "%d", PHP_API_VERSION);
     777              27 :                 php_info_print_table_row(2, "PHP API", temp_api);
     778                 : 
     779              27 :                 snprintf(temp_api, sizeof(temp_api), "%d", ZEND_MODULE_API_NO);
     780              27 :                 php_info_print_table_row(2, "PHP Extension", temp_api);
     781                 : 
     782              27 :                 snprintf(temp_api, sizeof(temp_api), "%d", ZEND_EXTENSION_API_NO);
     783              27 :                 php_info_print_table_row(2, "Zend Extension", temp_api);
     784                 : 
     785              27 :                 php_info_print_table_row(2, "Zend Extension Build", ZEND_EXTENSION_BUILD_ID);
     786              27 :                 php_info_print_table_row(2, "PHP Extension Build", ZEND_MODULE_BUILD_ID);
     787                 : 
     788                 : #if ZEND_DEBUG
     789                 :                 php_info_print_table_row(2, "Debug Build", "yes" );
     790                 : #else
     791              27 :                 php_info_print_table_row(2, "Debug Build", "no" );
     792                 : #endif
     793                 : 
     794                 : #ifdef ZTS
     795                 :                 php_info_print_table_row(2, "Thread Safety", "enabled" );
     796                 : #else
     797              27 :                 php_info_print_table_row(2, "Thread Safety", "disabled" );
     798                 : #endif
     799                 : 
     800              27 :                 php_info_print_table_row(2, "Zend Memory Manager", is_zend_mm(TSRMLS_C) ? "enabled" : "disabled" );
     801                 : 
     802                 :                 {
     803                 :                         char buf[1024];
     804              27 :                         snprintf(buf, sizeof(buf), "Based on%s. ICU Version %s.", U_COPYRIGHT_STRING, U_ICU_VERSION);
     805              27 :                         php_info_print_table_row(2, "Unicode Support", buf);
     806                 :                 }
     807                 : #if HAVE_IPV6
     808              27 :                 php_info_print_table_row(2, "IPv6 Support", "enabled" );
     809                 : #else
     810                 :                 php_info_print_table_row(2, "IPv6 Support", "disabled" );
     811                 : #endif
     812                 : #if HAVE_DTRACE
     813                 :                 php_info_print_table_row(2, "DTrace Support", "enabled" );
     814                 : #else
     815              27 :                 php_info_print_table_row(2, "DTrace Support", "disabled" );
     816                 : #endif
     817                 :                 
     818              27 :                 php_info_print_stream_hash("PHP Streams",  php_stream_get_url_stream_wrappers_hash() TSRMLS_CC);
     819              27 :                 php_info_print_stream_hash("Stream Socket Transports", php_stream_xport_get_hash() TSRMLS_CC);
     820              27 :                 php_info_print_stream_hash("Stream Filters", php_get_stream_filters_hash() TSRMLS_CC);
     821                 : 
     822              27 :                 php_info_print_table_end();
     823                 : 
     824                 :                 /* Zend Engine */
     825              27 :                 php_info_print_box_start(0);
     826              27 :                 if (expose_php && !sapi_module.phpinfo_as_text) {
     827               1 :                         php_info_print("<a href=\"http://www.zend.com/\"><img border=\"0\" src=\"");
     828               1 :                         php_info_print_request_uri(TSRMLS_C);
     829               1 :                         php_info_print("?="ZEND_LOGO_GUID"\" alt=\"Zend logo\" /></a>\n");
     830                 :                 }
     831              27 :                 php_info_print("This program makes use of the Zend Scripting Language Engine:");
     832              27 :                 php_info_print(!sapi_module.phpinfo_as_text?"<br />":"\n");
     833              27 :                 if (sapi_module.phpinfo_as_text) {
     834              26 :                         php_info_print(zend_version);
     835                 :                 } else {
     836               1 :                         zend_html_puts(zend_version, strlen(zend_version) TSRMLS_CC);
     837                 :                 }
     838              27 :                 php_info_print_box_end();
     839              27 :                 efree(php_uname);
     840                 :         }
     841                 : 
     842              47 :         if ((flag & PHP_INFO_CREDITS) && expose_php && !sapi_module.phpinfo_as_text) {      
     843               1 :                 php_info_print_hr();
     844               1 :                 php_info_print("<h1><a href=\"");
     845               1 :                 php_info_print_request_uri(TSRMLS_C);
     846               1 :                 php_info_print("?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000\">");
     847               1 :                 php_info_print("PHP Credits");
     848               1 :                 php_info_print("</a></h1>\n");
     849                 :         }
     850                 : 
     851              47 :         zend_ini_sort_entries(TSRMLS_C);
     852                 : 
     853              47 :         if (flag & PHP_INFO_CONFIGURATION) {
     854              27 :                 php_info_print_hr();
     855              27 :                 if (!sapi_module.phpinfo_as_text) {
     856               1 :                         php_info_print("<h1>Configuration</h1>\n");
     857                 :                 } else {
     858              26 :                         SECTION("Configuration");
     859                 :                 }       
     860              27 :                 if (!(flag & PHP_INFO_MODULES)) {
     861               0 :                         SECTION("PHP Core");
     862               0 :                         display_ini_entries(NULL);
     863                 :                 }
     864                 :         }
     865                 : 
     866              47 :         if (flag & PHP_INFO_MODULES) {
     867                 :                 HashTable sorted_registry;
     868                 :                 zend_module_entry tmp;
     869                 : 
     870              43 :                 zend_hash_init(&sorted_registry, zend_hash_num_elements(&module_registry), NULL, NULL, 1);
     871              43 :                 zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry));
     872              43 :                 zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC);
     873                 : 
     874              43 :                 zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_func TSRMLS_CC);
     875                 : 
     876              43 :                 SECTION("Additional Modules");
     877              43 :                 php_info_print_table_start();
     878              43 :                 php_info_print_table_header(1, "Module Name");
     879              43 :                 zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_def TSRMLS_CC);
     880              43 :                 php_info_print_table_end();
     881                 : 
     882              43 :                 zend_hash_destroy(&sorted_registry);
     883                 :         }
     884                 : 
     885              47 :         if (flag & PHP_INFO_ENVIRONMENT) {
     886              27 :                 SECTION("Environment");
     887              27 :                 php_info_print_table_start();
     888              27 :                 php_info_print_table_header(2, "Variable", "Value");
     889            1337 :                 for (env=environ; env!=NULL && *env !=NULL; env++) {
     890            1310 :                         tmp1 = estrdup(*env);
     891            1310 :                         if (!(tmp2=strchr(tmp1,'='))) { /* malformed entry? */
     892               0 :                                 efree(tmp1);
     893               0 :                                 continue;
     894                 :                         }
     895            1310 :                         *tmp2 = 0;
     896            1310 :                         tmp2++;
     897            1310 :                         php_info_print_table_row(2, tmp1, tmp2);
     898            1310 :                         efree(tmp1);
     899                 :                 }
     900              27 :                 php_info_print_table_end();
     901                 :         }
     902                 : 
     903              47 :         if (flag & PHP_INFO_VARIABLES) {
     904                 :                 zval **data;
     905                 : 
     906              27 :                 SECTION("PHP Variables");
     907                 : 
     908              27 :                 php_info_print_table_start();
     909              27 :                 php_info_print_table_header(2, "Variable", "Value");
     910              27 :                 if (zend_ascii_hash_find(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void **) &data) != FAILURE) {
     911               0 :                         php_info_print_table_row(2, "PHP_SELF", Z_STRVAL_PP(data));
     912                 :                 }
     913              27 :                 if (zend_ascii_hash_find(&EG(symbol_table), "PHP_AUTH_TYPE", sizeof("PHP_AUTH_TYPE"), (void **) &data) != FAILURE) {
     914               0 :                         php_info_print_table_row(2, "PHP_AUTH_TYPE", Z_STRVAL_PP(data));
     915                 :                 }
     916              27 :                 if (zend_ascii_hash_find(&EG(symbol_table), "PHP_AUTH_USER", sizeof("PHP_AUTH_USER"), (void **) &data) != FAILURE) {
     917               0 :                         php_info_print_table_row(2, "PHP_AUTH_USER", Z_STRVAL_PP(data));
     918                 :                 }
     919              27 :                 if (zend_ascii_hash_find(&EG(symbol_table), "PHP_AUTH_PW", sizeof("PHP_AUTH_PW"), (void **) &data) != FAILURE) {
     920               0 :                         php_info_print_table_row(2, "PHP_AUTH_PW", Z_STRVAL_PP(data));
     921                 :                 }
     922              27 :                 php_print_gpcse_array("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC);
     923              27 :                 php_print_gpcse_array("_GET", sizeof("_GET")-1 TSRMLS_CC);
     924              27 :                 php_print_gpcse_array("_POST", sizeof("_POST")-1 TSRMLS_CC);
     925              27 :                 php_print_gpcse_array("_FILES", sizeof("_FILES")-1 TSRMLS_CC);
     926              27 :                 php_print_gpcse_array("_COOKIE", sizeof("_COOKIE")-1 TSRMLS_CC);
     927              27 :                 php_print_gpcse_array("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
     928              27 :                 php_print_gpcse_array("_ENV", sizeof("_ENV")-1 TSRMLS_CC);
     929              27 :                 php_info_print_table_end();
     930                 :         }
     931                 : 
     932              47 :         if (flag & PHP_INFO_LICENSE) {
     933              29 :                 if (!sapi_module.phpinfo_as_text) {
     934               2 :                         SECTION("PHP License");
     935               2 :                         php_info_print_box_start(0);
     936               2 :                         php_info_print("<p>\n");
     937               2 :                         php_info_print("This program is free software; you can redistribute it and/or modify ");
     938               2 :                         php_info_print("it under the terms of the PHP License as published by the PHP Group ");
     939               2 :                         php_info_print("and included in the distribution in the file:  LICENSE\n");
     940               2 :                         php_info_print("</p>\n");
     941               2 :                         php_info_print("<p>");
     942               2 :                         php_info_print("This program is distributed in the hope that it will be useful, ");
     943               2 :                         php_info_print("but WITHOUT ANY WARRANTY; without even the implied warranty of ");
     944               2 :                         php_info_print("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
     945               2 :                         php_info_print("</p>\n");
     946               2 :                         php_info_print("<p>");
     947               2 :                         php_info_print("If you did not receive a copy of the PHP license, or have any questions about ");
     948               2 :                         php_info_print("PHP licensing, please contact license@php.net.\n");
     949               2 :                         php_info_print("</p>\n");
     950               2 :                         php_info_print_box_end();
     951                 :                 } else {
     952              27 :                         php_info_print("\nPHP License\n");
     953              27 :                         php_info_print("This program is free software; you can redistribute it and/or modify\n");
     954              27 :                         php_info_print("it under the terms of the PHP License as published by the PHP Group\n");
     955              27 :                         php_info_print("and included in the distribution in the file:  LICENSE\n");
     956              27 :                         php_info_print("\n");
     957              27 :                         php_info_print("This program is distributed in the hope that it will be useful,\n");
     958              27 :                         php_info_print("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
     959              27 :                         php_info_print("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
     960              27 :                         php_info_print("\n");
     961              27 :                         php_info_print("If you did not receive a copy of the PHP license, or have any\n");
     962              27 :                         php_info_print("questions about PHP licensing, please contact license@php.net.\n");
     963                 :                 }
     964                 :         }
     965              47 :         if (!sapi_module.phpinfo_as_text) {
     966               3 :                 php_info_print("</div></body></html>");
     967                 :         }       
     968              47 : }
     969                 : /* }}} */
     970                 : 
     971                 : PHPAPI void php_info_print_table_start(void) /* {{{ */
     972            7119 : {
     973            7119 :         if (!sapi_module.phpinfo_as_text) {
     974             113 :                 php_info_print("<table border=\"0\" cellpadding=\"3\" width=\"600\">\n");
     975                 :         } else {
     976            7006 :                 php_info_print("\n");
     977                 :         }       
     978            7119 : }
     979                 : /* }}} */
     980                 : 
     981                 : PHPAPI void php_info_print_table_end(void) /* {{{ */
     982            7145 : {
     983            7145 :         if (!sapi_module.phpinfo_as_text) {
     984             113 :                 php_info_print("</table><br />\n");
     985                 :         }
     986                 : 
     987            7145 : }
     988                 : /* }}} */
     989                 : 
     990                 : PHPAPI void php_info_print_box_start(int flag) /* {{{ */
     991             116 : {
     992             116 :         php_info_print_table_start();
     993             116 :         if (flag) {
     994               1 :                 if (!sapi_module.phpinfo_as_text) {
     995               1 :                         php_info_print("<tr class=\"h\"><td>\n");
     996                 :                 }
     997                 :         } else {
     998             115 :                 if (!sapi_module.phpinfo_as_text) {
     999               5 :                         php_info_print("<tr class=\"v\"><td>\n");
    1000                 :                 } else {
    1001             110 :                         php_info_print("\n");
    1002                 :                 }       
    1003                 :         }
    1004             116 : }
    1005                 : /* }}} */
    1006                 : 
    1007                 : PHPAPI void php_info_print_box_end(void) /* {{{ */
    1008             142 : {
    1009             142 :         if (!sapi_module.phpinfo_as_text) {
    1010               6 :                 php_info_print("</td></tr>\n");
    1011                 :         }
    1012             142 :         php_info_print_table_end();
    1013             142 : }
    1014                 : /* }}} */
    1015                 : 
    1016                 : PHPAPI void php_info_print_hr(void) /* {{{ */
    1017              28 : {
    1018              28 :         if (!sapi_module.phpinfo_as_text) {
    1019               2 :                 php_info_print("<hr />\n");
    1020                 :         } else {
    1021              26 :                 php_info_print("\n\n _______________________________________________________________________\n\n");
    1022                 :         }
    1023              28 : }
    1024                 : /* }}} */
    1025                 : 
    1026                 : PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header) /* {{{ */
    1027              12 : {
    1028                 :         int spaces;
    1029                 : 
    1030              12 :         if (!sapi_module.phpinfo_as_text) {
    1031               6 :                 php_info_printf("<tr class=\"h\"><th colspan=\"%d\">%s</th></tr>\n", num_cols, header );
    1032                 :         } else {
    1033               6 :                 spaces = (74 - strlen(header));
    1034               6 :                 php_info_printf("%*s%s%*s\n", (int)(spaces/2), " ", header, (int)(spaces/2), " ");
    1035                 :         }       
    1036              12 : }
    1037                 : /* }}} */
    1038                 : 
    1039                 : /* {{{ php_info_print_table_header
    1040                 :  */
    1041                 : PHPAPI void php_info_print_table_header(int num_cols, ...)
    1042            5250 : {
    1043                 :         int i;
    1044                 :         va_list row_elements;
    1045                 :         char *row_element;
    1046                 : 
    1047            5250 :         va_start(row_elements, num_cols);
    1048            5250 :         if (!sapi_module.phpinfo_as_text) {
    1049              64 :                 php_info_print("<tr class=\"h\">");
    1050                 :         }       
    1051           13838 :         for (i=0; i<num_cols; i++) {
    1052            8588 :                 row_element = va_arg(row_elements, char *);
    1053            8588 :                 if (!row_element || !*row_element) {
    1054              43 :                         row_element = " ";
    1055                 :                 }
    1056            8588 :                 if (!sapi_module.phpinfo_as_text) {
    1057             148 :                         php_info_print("<th>");
    1058             148 :                         php_info_print(row_element);
    1059             148 :                         php_info_print("</th>");
    1060                 :                 } else {
    1061            8440 :                         php_info_print(row_element);
    1062            8440 :                         if (i < num_cols-1) {
    1063            3254 :                                 php_info_print(" => ");
    1064                 :                         } else {
    1065            5186 :                                 php_info_print("\n");
    1066                 :                         }
    1067                 :                 }
    1068                 :         }
    1069            5250 :         if (!sapi_module.phpinfo_as_text) {
    1070              64 :                 php_info_print("</tr>\n");
    1071                 :         }
    1072                 : 
    1073            5250 :         va_end(row_elements);
    1074            5250 : }
    1075                 : /* }}} */
    1076                 : 
    1077                 : /* {{{ php_info_print_table_row_internal
    1078                 :  */
    1079                 : static void php_info_print_table_row_internal(int num_cols, 
    1080                 :                 const char *value_class, va_list row_elements)
    1081           18286 : {
    1082                 :         int i;
    1083                 :         char *row_element;
    1084                 : 
    1085           18286 :         if (!sapi_module.phpinfo_as_text) {
    1086             562 :                 php_info_print("<tr>");
    1087                 :         }       
    1088           54807 :         for (i=0; i<num_cols; i++) {
    1089           36521 :                 if (!sapi_module.phpinfo_as_text) {
    1090            1119 :                         php_info_printf("<td class=\"%s\">",
    1091                 :                            (i==0 ? "e" : value_class )
    1092                 :                         );
    1093                 :                 }       
    1094           36521 :                 row_element = va_arg(row_elements, char *);
    1095           36564 :                 if (!row_element || !*row_element) {
    1096              43 :                         if (!sapi_module.phpinfo_as_text) {
    1097               1 :                                 php_info_print( "<i>no value</i>" );
    1098                 :                         } else {
    1099              42 :                                 php_info_print( " " );
    1100                 :                         }
    1101                 :                 } else {
    1102           36478 :                         if (!sapi_module.phpinfo_as_text) {
    1103            1118 :                                 php_info_print_html_esc(row_element, strlen(row_element));
    1104                 :                         } else {
    1105           35360 :                                 php_info_print(row_element);
    1106           35360 :                                 if (i < num_cols-1) {
    1107           17678 :                                         php_info_print(" => ");
    1108                 :                                 }       
    1109                 :                         }
    1110                 :                 }
    1111           36521 :                 if (!sapi_module.phpinfo_as_text) {
    1112            1119 :                         php_info_print(" </td>");
    1113           35402 :                 } else if (i == (num_cols - 1)) {
    1114           17724 :                         php_info_print("\n");
    1115                 :                 }
    1116                 :         }
    1117           18286 :         if (!sapi_module.phpinfo_as_text) {
    1118             562 :                 php_info_print("</tr>\n");
    1119                 :         }
    1120           18286 : }
    1121                 : /* }}} */
    1122                 : 
    1123                 : /* {{{ php_info_print_table_row
    1124                 :  */
    1125                 : PHPAPI void php_info_print_table_row(int num_cols, ...)
    1126           18286 : {
    1127                 :         va_list row_elements;
    1128                 :         
    1129           18286 :         va_start(row_elements, num_cols);
    1130           18286 :         php_info_print_table_row_internal(num_cols, "v", row_elements);
    1131           18286 :         va_end(row_elements);
    1132           18286 : }
    1133                 : /* }}} */
    1134                 : 
    1135                 : /* {{{ php_info_print_table_row_ex
    1136                 :  */
    1137                 : PHPAPI void php_info_print_table_row_ex(int num_cols, const char *value_class, 
    1138                 :                 ...)
    1139               0 : {
    1140                 :         va_list row_elements;
    1141                 :         
    1142               0 :         va_start(row_elements, value_class);
    1143               0 :         php_info_print_table_row_internal(num_cols, value_class, row_elements);
    1144               0 :         va_end(row_elements);
    1145               0 : }
    1146                 : /* }}} */
    1147                 : 
    1148                 : /* {{{ register_phpinfo_constants
    1149                 :  */
    1150                 : void register_phpinfo_constants(INIT_FUNC_ARGS)
    1151           17007 : {
    1152           17007 :         REGISTER_LONG_CONSTANT("INFO_GENERAL", PHP_INFO_GENERAL, CONST_PERSISTENT|CONST_CS);
    1153           17007 :         REGISTER_LONG_CONSTANT("INFO_CREDITS", PHP_INFO_CREDITS, CONST_PERSISTENT|CONST_CS);
    1154           17007 :         REGISTER_LONG_CONSTANT("INFO_CONFIGURATION", PHP_INFO_CONFIGURATION, CONST_PERSISTENT|CONST_CS);
    1155           17007 :         REGISTER_LONG_CONSTANT("INFO_MODULES", PHP_INFO_MODULES, CONST_PERSISTENT|CONST_CS);
    1156           17007 :         REGISTER_LONG_CONSTANT("INFO_ENVIRONMENT", PHP_INFO_ENVIRONMENT, CONST_PERSISTENT|CONST_CS);
    1157           17007 :         REGISTER_LONG_CONSTANT("INFO_VARIABLES", PHP_INFO_VARIABLES, CONST_PERSISTENT|CONST_CS);
    1158           17007 :         REGISTER_LONG_CONSTANT("INFO_LICENSE", PHP_INFO_LICENSE, CONST_PERSISTENT|CONST_CS);
    1159           17007 :         REGISTER_LONG_CONSTANT("INFO_ALL", PHP_INFO_ALL, CONST_PERSISTENT|CONST_CS);
    1160           17007 :         REGISTER_LONG_CONSTANT("CREDITS_GROUP",       PHP_CREDITS_GROUP, CONST_PERSISTENT|CONST_CS);
    1161           17007 :         REGISTER_LONG_CONSTANT("CREDITS_GENERAL",     PHP_CREDITS_GENERAL, CONST_PERSISTENT|CONST_CS);
    1162           17007 :         REGISTER_LONG_CONSTANT("CREDITS_SAPI",        PHP_CREDITS_SAPI, CONST_PERSISTENT|CONST_CS);
    1163           17007 :         REGISTER_LONG_CONSTANT("CREDITS_MODULES",     PHP_CREDITS_MODULES, CONST_PERSISTENT|CONST_CS);
    1164           17007 :         REGISTER_LONG_CONSTANT("CREDITS_DOCS",        PHP_CREDITS_DOCS, CONST_PERSISTENT|CONST_CS);
    1165           17007 :         REGISTER_LONG_CONSTANT("CREDITS_FULLPAGE",    PHP_CREDITS_FULLPAGE, CONST_PERSISTENT|CONST_CS);
    1166           17007 :         REGISTER_LONG_CONSTANT("CREDITS_QA",  PHP_CREDITS_QA, CONST_PERSISTENT|CONST_CS);
    1167           17007 :         REGISTER_LONG_CONSTANT("CREDITS_ALL", PHP_CREDITS_ALL, CONST_PERSISTENT|CONST_CS);
    1168           17007 : }
    1169                 : /* }}} */
    1170                 : 
    1171                 : /* {{{ proto void phpinfo([int what]) U
    1172                 :    Output a page of useful information about PHP and the current request */
    1173                 : PHP_FUNCTION(phpinfo)
    1174              47 : {
    1175              47 :         long flag = PHP_INFO_ALL;
    1176                 : 
    1177              47 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) {
    1178               2 :                 return;
    1179                 :         }
    1180                 : 
    1181                 :         /* Andale!  Andale!  Yee-Hah! */
    1182              45 :         php_output_start_default(TSRMLS_C);
    1183              45 :         php_print_info(flag TSRMLS_CC);
    1184              45 :         php_output_end(TSRMLS_C);
    1185                 : 
    1186              45 :         RETURN_TRUE;
    1187                 : }
    1188                 : 
    1189                 : /* }}} */
    1190                 : 
    1191                 : /* {{{ proto string phpversion([string extension]) U
    1192                 :    Return the current PHP version */
    1193                 : PHP_FUNCTION(phpversion)
    1194               8 : {
    1195               8 :         char *ext_name = NULL;
    1196               8 :         int ext_name_len = 0;
    1197                 : 
    1198               8 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &ext_name, &ext_name_len) == FAILURE) {
    1199               0 :                 return;
    1200                 :         }
    1201                 : 
    1202               8 :         if (!ext_name) {
    1203               8 :                 RETURN_ASCII_STRING(PHP_VERSION, 1);
    1204                 :         } else {
    1205                 :                 const char *version;
    1206               0 :                 version = zend_get_module_version(ext_name);
    1207               0 :                 if (version == NULL) {
    1208               0 :                         RETURN_FALSE;
    1209                 :                 }
    1210               0 :                 RETURN_ASCII_STRING(version, 1);
    1211                 :         }
    1212                 : }
    1213                 : /* }}} */
    1214                 : 
    1215                 : /* {{{ proto void phpcredits([int flag]) U
    1216                 :    Prints the list of people who've contributed to the PHP project */
    1217                 : PHP_FUNCTION(phpcredits)
    1218               8 : {
    1219               8 :         long flag = PHP_CREDITS_ALL;
    1220                 : 
    1221               8 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) {
    1222               2 :                 return;
    1223                 :         }
    1224                 : 
    1225               6 :         php_print_credits(flag TSRMLS_CC);
    1226               6 :         RETURN_TRUE;
    1227                 : }
    1228                 : /* }}} */
    1229                 : 
    1230                 : /* {{{ php_logo_guid
    1231                 :  */
    1232                 : PHPAPI char *php_logo_guid(void)
    1233               3 : {
    1234                 :         char *logo_guid;
    1235                 : 
    1236                 :         time_t the_time;
    1237                 :         struct tm *ta, tmbuf;
    1238                 : 
    1239               3 :         the_time = time(NULL);
    1240               3 :         ta = php_localtime_r(&the_time, &tmbuf);
    1241                 : 
    1242               3 :         if (ta && (ta->tm_mon==3) && (ta->tm_mday==1)) {
    1243               0 :                 logo_guid = PHP_EGG_LOGO_GUID;
    1244                 :         } else {
    1245               3 :                 logo_guid = PHP_LOGO_GUID;
    1246                 :         }
    1247                 : 
    1248               3 :         return estrdup(logo_guid);
    1249                 : 
    1250                 : }
    1251                 : /* }}} */
    1252                 : 
    1253                 : /* {{{ proto string php_logo_guid(void) U
    1254                 :    Return the special ID used to request the PHP logo in phpinfo screens*/
    1255                 : PHP_FUNCTION(php_logo_guid)
    1256               2 : {
    1257               2 :         if (zend_parse_parameters_none() == FAILURE) {
    1258               0 :                 return;
    1259                 :         }
    1260                 : 
    1261               2 :         RETURN_ASCII_STRING(php_logo_guid(), ZSTR_AUTOFREE);
    1262                 : }
    1263                 : /* }}} */
    1264                 : 
    1265                 : /* {{{ proto string php_real_logo_guid(void) U
    1266                 :    Return the special ID used to request the PHP logo in phpinfo screens*/
    1267                 : PHP_FUNCTION(php_real_logo_guid)
    1268               2 : {
    1269               2 :         if (zend_parse_parameters_none() == FAILURE) {
    1270               0 :                 return;
    1271                 :         }
    1272                 : 
    1273               2 :         RETURN_ASCII_STRINGL(PHP_LOGO_GUID, sizeof(PHP_LOGO_GUID)-1, 1);
    1274                 : }
    1275                 : /* }}} */
    1276                 : 
    1277                 : /* {{{ proto string php_egg_logo_guid(void) U
    1278                 :    Return the special ID used to request the PHP logo in phpinfo screens*/
    1279                 : PHP_FUNCTION(php_egg_logo_guid)
    1280               1 : {
    1281               1 :         if (zend_parse_parameters_none() == FAILURE) {
    1282               0 :                 return;
    1283                 :         }
    1284                 : 
    1285               1 :         RETURN_ASCII_STRINGL(PHP_EGG_LOGO_GUID, sizeof(PHP_EGG_LOGO_GUID)-1, 1);
    1286                 : }
    1287                 : /* }}} */
    1288                 : 
    1289                 : /* {{{ proto string zend_logo_guid(void) U
    1290                 :    Return the special ID used to request the Zend logo in phpinfo screens*/
    1291                 : PHP_FUNCTION(zend_logo_guid)
    1292               2 : {
    1293               2 :         if (zend_parse_parameters_none() == FAILURE) {
    1294               0 :                 return;
    1295                 :         }
    1296                 : 
    1297               2 :         RETURN_ASCII_STRINGL(ZEND_LOGO_GUID, sizeof(ZEND_LOGO_GUID)-1, 1);
    1298                 : }
    1299                 : /* }}} */
    1300                 : 
    1301                 : /* {{{ proto string php_sapi_name(void) U
    1302                 :    Return the current SAPI module name */
    1303                 : PHP_FUNCTION(php_sapi_name)
    1304              40 : {
    1305              40 :         if (zend_parse_parameters_none() == FAILURE) {
    1306               0 :                 return;
    1307                 :         }
    1308                 : 
    1309              40 :         if (sapi_module.name) {
    1310              40 :                 RETURN_ASCII_STRING(sapi_module.name, 1);
    1311                 :         } else {
    1312               0 :                 RETURN_FALSE;
    1313                 :         }
    1314                 : }
    1315                 : 
    1316                 : /* }}} */
    1317                 : 
    1318                 : /* {{{ proto string php_uname(void) U
    1319                 :    Return information about the system PHP was built on */
    1320                 : PHP_FUNCTION(php_uname)
    1321             558 : {
    1322             558 :         char *mode = "a";
    1323             558 :         int modelen = sizeof("a")-1;
    1324                 :         char *tmp;
    1325                 : 
    1326             558 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &mode, &modelen) == FAILURE) {
    1327               5 :                 return;
    1328                 :         }
    1329             553 :         tmp = php_get_uname(*mode);
    1330             553 :         RETVAL_RT_STRING(tmp, ZSTR_AUTOFREE);
    1331                 : }
    1332                 : 
    1333                 : /* }}} */
    1334                 : 
    1335                 : /* {{{ proto string php_ini_scanned_files(void) U
    1336                 :    Return comma-separated string of .ini files parsed from the additional ini dir */
    1337                 : PHP_FUNCTION(php_ini_scanned_files)
    1338               1 : {
    1339               1 :         if (zend_parse_parameters_none() == FAILURE) {
    1340               0 :                 return;
    1341                 :         }
    1342                 :         
    1343                 :         if (strlen(PHP_CONFIG_FILE_SCAN_DIR) && php_ini_scanned_files) {
    1344                 :                 RETURN_RT_STRING(php_ini_scanned_files, ZSTR_DUPLICATE);
    1345                 :         } else {
    1346               1 :                 RETURN_FALSE;
    1347                 :         }
    1348                 : }
    1349                 : /* }}} */
    1350                 : 
    1351                 : /* {{{ proto string php_ini_loaded_file(void)
    1352                 :    Return the actual loaded ini filename */
    1353                 : PHP_FUNCTION(php_ini_loaded_file)
    1354               1 : {
    1355               1 :         if (zend_parse_parameters_none() == FAILURE) {
    1356               0 :                 return;
    1357                 :         }
    1358                 :         
    1359               1 :         if (php_ini_opened_path) {
    1360               1 :                 RETURN_STRING(php_ini_opened_path, 1);
    1361                 :         } else {
    1362               0 :                 RETURN_FALSE;
    1363                 :         }
    1364                 : }
    1365                 : /* }}} */
    1366                 : 
    1367                 : /*
    1368                 :  * Local variables:
    1369                 :  * tab-width: 4
    1370                 :  * c-basic-offset: 4
    1371                 :  * End:
    1372                 :  * vim600: sw=4 ts=4 fdm=marker
    1373                 :  * vim<600: sw=4 ts=4
    1374                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Mon, 23 Nov 2009 17:39:42 +0000 (35 hours ago)

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