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: 414 449 92.2 %
Date: 2014-07-21 Functions: 30 32 93.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10

Generated at Tue, 22 Jul 2014 01:33:20 +0000 (7 days ago)

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