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

Generated by: LCOV version 1.10

Generated at Tue, 14 Oct 2014 07:25:50 +0000 (7 days ago)

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