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

LCOV - code coverage report
Current view: top level - ext/standard - info.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 443 483 91.7 %
Date: 2014-04-10 Functions: 36 38 94.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10

Generated at Thu, 10 Apr 2014 08:53:58 +0000 (8 days ago)

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