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

Generated by: LCOV version 1.10

Generated at Sun, 18 Jan 2015 09:00:49 +0000 (7 days ago)

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