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: 0 449 0.0 %
Date: 2014-04-06 Functions: 0 32 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10

Generated at Sun, 06 Apr 2014 17:31:11 +0000 (9 days ago)

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