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

Generated by: LCOV version 1.10

Generated at Sun, 31 Aug 2014 02:21:55 +0000 (2 days ago)

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