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

Generated by: LCOV version 1.10

Generated at Fri, 20 Mar 2015 23:40:36 +0000 (7 days ago)

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