PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/standard - info.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 415 450 92.2 %
Date: 2015-05-21 Functions: 30 32 93.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10

Generated at Thu, 21 May 2015 19:59:05 +0000 (4 days ago)

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