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

LCOV - code coverage report
Current view: top level - ext/standard - info.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 419 451 92.9 %
Date: 2016-09-27 Functions: 30 32 93.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10

Generated at Tue, 27 Sep 2016 10:26:08 +0000 (35 hours ago)

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