Back to index

php5  5.3.10
info.c
Go to the documentation of this file.
00001 /* 
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Authors: Rasmus Lerdorf <rasmus@php.net>                             |
00016    |          Zeev Suraski <zeev@zend.com>                                |
00017    |          Colin Viebrock <colin@easydns.com>                          |
00018    +----------------------------------------------------------------------+
00019 */
00020 
00021 /* $Id: info.c 321634 2012-01-01 13:15:04Z felipe $ */
00022 
00023 #include "php.h"
00024 #include "php_ini.h"
00025 #include "php_globals.h"
00026 #include "ext/standard/head.h"
00027 #include "ext/standard/html.h"
00028 #include "info.h"
00029 #include "credits.h"
00030 #include "css.h"
00031 #include "SAPI.h"
00032 #include <time.h>
00033 #include "php_main.h"
00034 #include "zend_globals.h"          /* needs ELS */
00035 #include "zend_extensions.h"
00036 #include "zend_highlight.h"
00037 #ifdef HAVE_SYS_UTSNAME_H
00038 #include <sys/utsname.h>
00039 #endif
00040 
00041 #ifdef PHP_WIN32
00042 typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
00043 typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
00044 
00045 # include "winver.h"
00046 
00047 #if _MSC_VER < 1300
00048 # define OSVERSIONINFOEX php_win_OSVERSIONINFOEX
00049 #endif
00050 
00051 #endif
00052 
00053 #if HAVE_MBSTRING
00054 #include "ext/mbstring/mbstring.h"
00055 ZEND_EXTERN_MODULE_GLOBALS(mbstring)
00056 #endif
00057 
00058 #if HAVE_ICONV
00059 #include "ext/iconv/php_iconv.h"
00060 ZEND_EXTERN_MODULE_GLOBALS(iconv)
00061 #endif
00062 
00063 #define SECTION(name)       if (!sapi_module.phpinfo_as_text) { \
00064                                                  PUTS("<h2>" name "</h2>\n"); \
00065                                           } else { \
00066                                                  php_info_print_table_start(); \
00067                                                  php_info_print_table_header(1, name); \
00068                                                  php_info_print_table_end(); \
00069                                           } \
00070 
00071 PHPAPI extern char *php_ini_opened_path;
00072 PHPAPI extern char *php_ini_scanned_path;
00073 PHPAPI extern char *php_ini_scanned_files;
00074        
00075 static int php_info_write_wrapper(const char *str, uint str_length)
00076 {
00077        int new_len, written;
00078        char *elem_esc;
00079 
00080        TSRMLS_FETCH();
00081 
00082        elem_esc = php_escape_html_entities((unsigned char *)str, str_length, &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
00083 
00084        written = php_body_write(elem_esc, new_len TSRMLS_CC);
00085 
00086        efree(elem_esc);
00087 
00088        return written;
00089 }
00090 
00091 
00092 PHPAPI void php_info_print_module(zend_module_entry *zend_module TSRMLS_DC) /* {{{ */
00093 {
00094        if (zend_module->info_func || zend_module->version) {
00095               if (!sapi_module.phpinfo_as_text) {
00096                      php_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", zend_module->name, zend_module->name);
00097               } else {
00098                      php_info_print_table_start();
00099                      php_info_print_table_header(1, zend_module->name);
00100                      php_info_print_table_end();
00101               }
00102               if (zend_module->info_func) {
00103                      zend_module->info_func(zend_module TSRMLS_CC);
00104               } else {
00105                      php_info_print_table_start();
00106                      php_info_print_table_row(2, "Version", zend_module->version);
00107                      php_info_print_table_end();
00108                      DISPLAY_INI_ENTRIES();
00109               }
00110        } else {
00111               if (!sapi_module.phpinfo_as_text) {
00112                      php_printf("<tr><td>%s</td></tr>\n", zend_module->name);
00113               } else {
00114                      php_printf("%s\n", zend_module->name);
00115               }      
00116        }
00117 }
00118 /* }}} */
00119 
00120 static int _display_module_info_func(zend_module_entry *module TSRMLS_DC) /* {{{ */
00121 {
00122        if (module->info_func || module->version) {
00123               php_info_print_module(module TSRMLS_CC);
00124        }
00125        return ZEND_HASH_APPLY_KEEP;
00126 }
00127 /* }}} */
00128 
00129 static int _display_module_info_def(zend_module_entry *module TSRMLS_DC) /* {{{ */
00130 {
00131        if (!module->info_func && !module->version) {
00132               php_info_print_module(module TSRMLS_CC);
00133        }
00134        return ZEND_HASH_APPLY_KEEP;
00135 }
00136 /* }}} */
00137 
00138 /* {{{ php_print_gpcse_array
00139  */
00140 static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
00141 {
00142        zval **data, **tmp, tmp2;
00143        char *string_key;
00144        uint string_len;
00145        ulong num_key;
00146 
00147        zend_is_auto_global(name, name_length TSRMLS_CC);
00148 
00149        if (zend_hash_find(&EG(symbol_table), name, name_length+1, (void **) &data)!=FAILURE
00150               && (Z_TYPE_PP(data)==IS_ARRAY)) {
00151               zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data));
00152               while (zend_hash_get_current_data(Z_ARRVAL_PP(data), (void **) &tmp) == SUCCESS) {
00153                      if (!sapi_module.phpinfo_as_text) {
00154                             PUTS("<tr>");
00155                             PUTS("<td class=\"e\">");
00156 
00157                      }
00158 
00159                      PUTS(name);
00160                      PUTS("[\"");
00161                      
00162                      switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL)) {
00163                             case HASH_KEY_IS_STRING:
00164                                    if (!sapi_module.phpinfo_as_text) {
00165                                           php_info_html_esc_write(string_key, string_len - 1 TSRMLS_CC);
00166                                    } else {
00167                                           PHPWRITE(string_key, string_len - 1);
00168                                    }      
00169                                    break;
00170                             case HASH_KEY_IS_LONG:
00171                                    php_printf("%ld", num_key);
00172                                    break;
00173                      }
00174                      PUTS("\"]");
00175                      if (!sapi_module.phpinfo_as_text) {
00176                             PUTS("</td><td class=\"v\">");
00177                      } else {
00178                             PUTS(" => ");
00179                      }
00180                      if (Z_TYPE_PP(tmp) == IS_ARRAY) {
00181                             if (!sapi_module.phpinfo_as_text) {
00182                                    PUTS("<pre>");
00183                                    zend_print_zval_r_ex((zend_write_func_t) php_info_write_wrapper, *tmp, 0 TSRMLS_CC);
00184                                    PUTS("</pre>");
00185                             } else {
00186                                    zend_print_zval_r(*tmp, 0 TSRMLS_CC);
00187                             }
00188                      } else if (Z_TYPE_PP(tmp) != IS_STRING) {
00189                             tmp2 = **tmp;
00190                             zval_copy_ctor(&tmp2);
00191                             convert_to_string(&tmp2);
00192                             if (!sapi_module.phpinfo_as_text) {
00193                                    if (Z_STRLEN(tmp2) == 0) {
00194                                           PUTS("<i>no value</i>");
00195                                    } else {
00196                                           php_info_html_esc_write(Z_STRVAL(tmp2), Z_STRLEN(tmp2) TSRMLS_CC);
00197                                    } 
00198                             } else {
00199                                    PHPWRITE(Z_STRVAL(tmp2), Z_STRLEN(tmp2));
00200                             }      
00201                             zval_dtor(&tmp2);
00202                      } else {
00203                             if (!sapi_module.phpinfo_as_text) {
00204                                    if (Z_STRLEN_PP(tmp) == 0) {
00205                                           PUTS("<i>no value</i>");
00206                                    } else {
00207                                           php_info_html_esc_write(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp) TSRMLS_CC);
00208                                    }
00209                             } else {
00210                                    PHPWRITE(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
00211                             }      
00212                      }
00213                      if (!sapi_module.phpinfo_as_text) {
00214                             PUTS("</td></tr>\n");
00215                      } else {
00216                             PUTS("\n");
00217                      }      
00218                      zend_hash_move_forward(Z_ARRVAL_PP(data));
00219               }
00220        }
00221 }
00222 /* }}} */
00223 
00224 /* {{{ php_info_print_style
00225  */
00226 void php_info_print_style(TSRMLS_D)
00227 {
00228        php_printf("<style type=\"text/css\">\n");
00229        php_info_print_css(TSRMLS_C);
00230        php_printf("</style>\n");
00231 }
00232 /* }}} */
00233 
00234 /* {{{ php_info_html_esc_write
00235  */
00236 PHPAPI void php_info_html_esc_write(char *string, int str_len TSRMLS_DC)
00237 {
00238        int new_len;
00239        char *ret = php_escape_html_entities((unsigned char *)string, str_len, &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
00240 
00241        PHPWRITE(ret, new_len);
00242        efree(ret);
00243 }
00244 /* }}} */
00245 
00246 /* {{{ php_info_html_esc
00247  */
00248 PHPAPI char *php_info_html_esc(char *string TSRMLS_DC)
00249 {
00250        int new_len;
00251        return php_escape_html_entities((unsigned char *)string, strlen(string), &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
00252 }
00253 /* }}} */
00254 
00255 
00256 #ifdef PHP_WIN32
00257 /* {{{  */
00258 char* php_get_windows_name()
00259 {
00260        OSVERSIONINFOEX osvi;
00261        SYSTEM_INFO si;
00262        PGNSI pGNSI;
00263        PGPI pGPI;
00264        BOOL bOsVersionInfoEx;
00265        DWORD dwType;
00266        char *major = NULL, *sub = NULL, *retval;
00267 
00268        ZeroMemory(&si, sizeof(SYSTEM_INFO));
00269        ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
00270        osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
00271 
00272        if (!(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi))) {
00273               return NULL;
00274        }
00275 
00276        pGNSI = (PGNSI) GetProcAddress(GetModuleHandle("kernel32.dll"), "GetNativeSystemInfo");
00277        if(NULL != pGNSI) {
00278               pGNSI(&si);
00279        } else {
00280               GetSystemInfo(&si);
00281        }
00282 
00283        if (VER_PLATFORM_WIN32_NT==osvi.dwPlatformId && osvi.dwMajorVersion > 4 ) {
00284               if (osvi.dwMajorVersion == 6) {
00285                      if( osvi.dwMinorVersion == 0 ) {
00286                             if( osvi.wProductType == VER_NT_WORKSTATION ) {
00287                                    major = "Windows Vista";
00288                             } else {
00289                                    major = "Windows Server 2008";
00290                             }
00291                      } else
00292                      if ( osvi.dwMinorVersion == 1 ) {
00293                             if( osvi.wProductType == VER_NT_WORKSTATION )  {
00294                                    major = "Windows 7";
00295                             } else {
00296                                    major = "Windows Server 2008 R2";
00297                             }
00298                      } else {
00299                             major = "Unknow Windows version";
00300                      }
00301 
00302                      pGPI = (PGPI) GetProcAddress(GetModuleHandle("kernel32.dll"), "GetProductInfo");
00303                      pGPI(6, 0, 0, 0, &dwType);
00304 
00305                      switch (dwType) {
00306                             case PRODUCT_ULTIMATE:
00307                                    sub = "Ultimate Edition";
00308                                    break;
00309                             case PRODUCT_HOME_PREMIUM:
00310                                    sub = "Home Premium Edition";
00311                                    break;
00312                             case PRODUCT_HOME_BASIC:
00313                                    sub = "Home Basic Edition";
00314                                    break;
00315                             case PRODUCT_ENTERPRISE:
00316                                    sub = "Enterprise Edition";
00317                                    break;
00318                             case PRODUCT_BUSINESS:
00319                                    sub = "Business Edition";
00320                                    break;
00321                             case PRODUCT_STARTER:
00322                                    sub = "Starter Edition";
00323                                    break;
00324                             case PRODUCT_CLUSTER_SERVER:
00325                                    sub = "Cluster Server Edition";
00326                                    break;
00327                             case PRODUCT_DATACENTER_SERVER:
00328                                    sub = "Datacenter Edition";
00329                                    break;
00330                             case PRODUCT_DATACENTER_SERVER_CORE:
00331                                    sub = "Datacenter Edition (core installation)";
00332                                    break;
00333                             case PRODUCT_ENTERPRISE_SERVER:
00334                                    sub = "Enterprise Edition";
00335                                    break;
00336                             case PRODUCT_ENTERPRISE_SERVER_CORE:
00337                                    sub = "Enterprise Edition (core installation)";
00338                                    break;
00339                             case PRODUCT_ENTERPRISE_SERVER_IA64:
00340                                    sub = "Enterprise Edition for Itanium-based Systems";
00341                                    break;
00342                             case PRODUCT_SMALLBUSINESS_SERVER:
00343                                    sub = "Small Business Server";
00344                                    break;
00345                             case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
00346                                    sub = "Small Business Server Premium Edition";
00347                                    break;
00348                             case PRODUCT_STANDARD_SERVER:
00349                                    sub = "Standard Edition";
00350                                    break;
00351                             case PRODUCT_STANDARD_SERVER_CORE:
00352                                    sub = "Standard Edition (core installation)";
00353                                    break;
00354                             case PRODUCT_WEB_SERVER:
00355                                    sub = "Web Server Edition";
00356                                    break;
00357                      }
00358               }
00359 
00360               if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )    {
00361                      if (GetSystemMetrics(SM_SERVERR2))
00362                             major = "Windows Server 2003 R2";
00363                      else if (osvi.wSuiteMask == VER_SUITE_STORAGE_SERVER)
00364                             major = "Windows Storage Server 2003";
00365                      else if (osvi.wSuiteMask == VER_SUITE_WH_SERVER)
00366                             major = "Windows Home Server";
00367                      else if (osvi.wProductType == VER_NT_WORKSTATION &&
00368                             si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) {
00369                             major = "Windows XP Professional x64 Edition";
00370                      } else {
00371                             major = "Windows Server 2003";
00372                      }
00373 
00374                      /* Test for the server type. */
00375                      if ( osvi.wProductType != VER_NT_WORKSTATION ) {
00376                             if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 ) {
00377                                    if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
00378                                           sub = "Datacenter Edition for Itanium-based Systems";
00379                                    else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
00380                                           sub = "Enterprise Edition for Itanium-based Systems";
00381                             }
00382 
00383                             else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 ) {
00384                                    if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
00385                                           sub = "Datacenter x64 Edition";
00386                                    else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
00387                                           sub = "Enterprise x64 Edition";
00388                                    else sub = "Standard x64 Edition";
00389                             } else {
00390                                    if ( osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER )
00391                                           sub = "Compute Cluster Edition";
00392                                    else if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
00393                                           sub = "Datacenter Edition";
00394                                    else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
00395                                           sub = "Enterprise Edition";
00396                                    else if ( osvi.wSuiteMask & VER_SUITE_BLADE )
00397                                           sub = "Web Edition";
00398                                    else sub = "Standard Edition";
00399                             }
00400                      } 
00401               }
00402 
00403               if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )    {
00404                      major = "Windows XP";
00405                      if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
00406                             sub = "Home Edition";
00407                      else sub = "Professional";
00408               }
00409 
00410               if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 ) {
00411                      major = "Windows 2000";
00412 
00413                      if (osvi.wProductType == VER_NT_WORKSTATION ) {
00414                             sub = "Professional";
00415                      } else {
00416                             if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
00417                                    sub = "Datacenter Server";
00418                             else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
00419                                    sub = "Advanced Server";
00420                             else sub = "Server";
00421                      }
00422               }
00423        } else {
00424               return NULL;
00425        }
00426 
00427        spprintf(&retval, 0, "%s%s%s%s%s", major, sub?" ":"", sub?sub:"", osvi.szCSDVersion[0] != '\0'?" ":"", osvi.szCSDVersion);
00428        return retval;
00429 }
00430 /* }}}  */
00431 
00432 /* {{{  */
00433 void php_get_windows_cpu(char *buf, int bufsize)
00434 {
00435        SYSTEM_INFO SysInfo;
00436        GetSystemInfo(&SysInfo);
00437        switch (SysInfo.wProcessorArchitecture) {
00438               case PROCESSOR_ARCHITECTURE_INTEL :
00439                      snprintf(buf, bufsize, "i%d", SysInfo.dwProcessorType);
00440                      break;
00441               case PROCESSOR_ARCHITECTURE_MIPS :
00442                      snprintf(buf, bufsize, "MIPS R%d000", SysInfo.wProcessorLevel);
00443                      break;
00444               case PROCESSOR_ARCHITECTURE_ALPHA :
00445                      snprintf(buf, bufsize, "Alpha %d", SysInfo.wProcessorLevel);
00446                      break;
00447               case PROCESSOR_ARCHITECTURE_PPC :
00448                      snprintf(buf, bufsize, "PPC 6%02d", SysInfo.wProcessorLevel);
00449                      break;
00450               case PROCESSOR_ARCHITECTURE_IA64 :
00451                      snprintf(buf, bufsize,  "IA64");
00452                      break;
00453 #if defined(PROCESSOR_ARCHITECTURE_IA32_ON_WIN64)
00454               case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 :
00455                      snprintf(buf, bufsize, "IA32");
00456                      break;
00457 #endif
00458 #if defined(PROCESSOR_ARCHITECTURE_AMD64)
00459               case PROCESSOR_ARCHITECTURE_AMD64 :
00460                      snprintf(buf, bufsize, "AMD64");
00461                      break;
00462 #endif
00463               case PROCESSOR_ARCHITECTURE_UNKNOWN :
00464               default:
00465                      snprintf(buf, bufsize, "Unknown");
00466                      break;
00467        }
00468 }
00469 /* }}}  */
00470 #endif
00471 
00472 /* {{{ php_get_uname
00473  */
00474 PHPAPI char *php_get_uname(char mode)
00475 {
00476        char *php_uname;
00477        char tmp_uname[256];
00478 #ifdef PHP_WIN32
00479        DWORD dwBuild=0;
00480        DWORD dwVersion = GetVersion();
00481        DWORD dwWindowsMajorVersion =  (DWORD)(LOBYTE(LOWORD(dwVersion)));
00482        DWORD dwWindowsMinorVersion =  (DWORD)(HIBYTE(LOWORD(dwVersion)));
00483        DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
00484        char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
00485        
00486        GetComputerName(ComputerName, &dwSize);
00487 
00488        if (mode == 's') {
00489               if (dwVersion < 0x80000000) {
00490                      php_uname = "Windows NT";
00491               } else {
00492                      php_uname = "Windows 9x";
00493               }
00494        } else if (mode == 'r') {
00495               snprintf(tmp_uname, sizeof(tmp_uname), "%d.%d", dwWindowsMajorVersion, dwWindowsMinorVersion);
00496               php_uname = tmp_uname;
00497        } else if (mode == 'n') {
00498               php_uname = ComputerName;
00499        } else if (mode == 'v') {
00500               char *winver = php_get_windows_name();
00501               dwBuild = (DWORD)(HIWORD(dwVersion));
00502               if(winver == NULL) {
00503                      snprintf(tmp_uname, sizeof(tmp_uname), "build %d", dwBuild);
00504               } else {
00505                      snprintf(tmp_uname, sizeof(tmp_uname), "build %d (%s)", dwBuild, winver);
00506               }
00507               php_uname = tmp_uname;
00508               if(winver) {
00509                      efree(winver);
00510               }
00511        } else if (mode == 'm') {
00512               php_get_windows_cpu(tmp_uname, sizeof(tmp_uname));
00513               php_uname = tmp_uname;
00514        } else { /* assume mode == 'a' */
00515               /* Get build numbers for Windows NT or Win95 */
00516               if (dwVersion < 0x80000000){
00517                      char *winver = php_get_windows_name();
00518                      char wincpu[20];
00519 
00520                      php_get_windows_cpu(wincpu, sizeof(wincpu));
00521                      dwBuild = (DWORD)(HIWORD(dwVersion));
00522                      snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %d.%d build %d (%s) %s",
00523                                     "Windows NT", ComputerName,
00524                                     dwWindowsMajorVersion, dwWindowsMinorVersion, dwBuild, winver?winver:"unknown", wincpu);
00525                      if(winver) {
00526                             efree(winver);
00527                      }
00528               } else {
00529                      snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %d.%d",
00530                                     "Windows 9x", ComputerName,
00531                                     dwWindowsMajorVersion, dwWindowsMinorVersion);
00532               }
00533               php_uname = tmp_uname;
00534        }
00535 #else
00536 #ifdef HAVE_SYS_UTSNAME_H
00537        struct utsname buf;
00538        if (uname((struct utsname *)&buf) == -1) {
00539               php_uname = PHP_UNAME;
00540        } else {
00541 #ifdef NETWARE
00542               if (mode == 's') {
00543                      php_uname = buf.sysname;
00544               } else if (mode == 'r') {
00545                      snprintf(tmp_uname, sizeof(tmp_uname), "%d.%d.%d", 
00546                                     buf.netware_major, buf.netware_minor, buf.netware_revision);
00547                      php_uname = tmp_uname;
00548               } else if (mode == 'n') {
00549                      php_uname = buf.servername;
00550               } else if (mode == 'v') {
00551                      snprintf(tmp_uname, sizeof(tmp_uname), "libc-%d.%d.%d #%d",
00552                                     buf.libmajor, buf.libminor, buf.librevision, buf.libthreshold);
00553                      php_uname = tmp_uname;
00554               } else if (mode == 'm') {
00555                      php_uname = buf.machine;
00556               } else { /* assume mode == 'a' */
00557                      snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %d.%d.%d libc-%d.%d.%d #%d %s",
00558                                     buf.sysname, buf.servername,
00559                                     buf.netware_major, buf.netware_minor, buf.netware_revision,
00560                                     buf.libmajor, buf.libminor, buf.librevision, buf.libthreshold,
00561                                     buf.machine);
00562                      php_uname = tmp_uname;
00563               }
00564 #else
00565               if (mode == 's') {
00566                      php_uname = buf.sysname;
00567               } else if (mode == 'r') {
00568                      php_uname = buf.release;
00569               } else if (mode == 'n') {
00570                      php_uname = buf.nodename;
00571               } else if (mode == 'v') {
00572                      php_uname = buf.version;
00573               } else if (mode == 'm') {
00574                      php_uname = buf.machine;
00575               } else { /* assume mode == 'a' */
00576                      snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %s %s %s",
00577                                     buf.sysname, buf.nodename, buf.release, buf.version,
00578                                     buf.machine);
00579                      php_uname = tmp_uname;
00580               }
00581 #endif /* NETWARE */
00582        }
00583 #else
00584        php_uname = PHP_UNAME;
00585 #endif
00586 #endif
00587        return estrdup(php_uname);
00588 }
00589 /* }}} */
00590 
00591 
00592 /* {{{ php_print_info_htmlhead
00593  */
00594 PHPAPI void php_print_info_htmlhead(TSRMLS_D)
00595 {
00596 
00597 /*** none of this is needed now ***
00598 
00599        const char *charset = NULL;
00600 
00601        if (SG(default_charset)) {
00602               charset = SG(default_charset);
00603        }
00604 
00605 #if HAVE_MBSTRING
00606        if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) {
00607               if (MBSTRG(current_http_output_encoding) == mbfl_no_encoding_pass) {
00608                      charset = "US-ASCII";
00609               } else {
00610                      charset = mbfl_no2preferred_mime_name(MBSTRG(current_http_output_encoding));
00611               }
00612        }
00613 #endif   
00614 
00615 #if HAVE_ICONV
00616        if (php_ob_handler_used("ob_iconv_handler" TSRMLS_CC)) {
00617               charset = ICONVG(output_encoding);
00618        }
00619 #endif
00620 
00621        if (!charset || !charset[0]) {
00622               charset = "US-ASCII";
00623        }
00624 
00625 *** none of that is needed now ***/
00626 
00627 
00628        PUTS("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n");
00629        PUTS("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
00630        PUTS("<head>\n");
00631        php_info_print_style(TSRMLS_C);
00632        PUTS("<title>phpinfo()</title>");
00633        PUTS("<meta name=\"ROBOTS\" content=\"NOINDEX,NOFOLLOW,NOARCHIVE\" />");
00634 /*
00635        php_printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\" />\n", charset);
00636 */
00637        PUTS("</head>\n");
00638        PUTS("<body><div class=\"center\">\n");
00639 }
00640 /* }}} */
00641 
00642 /* {{{ module_name_cmp */
00643 static int module_name_cmp(const void *a, const void *b TSRMLS_DC)
00644 {
00645        Bucket *f = *((Bucket **) a);
00646        Bucket *s = *((Bucket **) b);
00647 
00648        return strcasecmp(((zend_module_entry *)f->pData)->name,
00649                               ((zend_module_entry *)s->pData)->name);
00650 }
00651 /* }}} */
00652 
00653 /* {{{ php_print_info
00654  */
00655 PHPAPI void php_print_info(int flag TSRMLS_DC)
00656 {
00657        char **env, *tmp1, *tmp2;
00658        char *php_uname;
00659        int expose_php = INI_INT("expose_php");
00660 
00661        if (!sapi_module.phpinfo_as_text) {
00662               php_print_info_htmlhead(TSRMLS_C);
00663        } else {
00664               PUTS("phpinfo()\n");
00665        }      
00666 
00667        if (flag & PHP_INFO_GENERAL) {
00668               char *zend_version = get_zend_version();
00669               char temp_api[10];
00670               char *logo_guid;
00671 
00672               php_uname = php_get_uname('a');
00673               
00674               if (!sapi_module.phpinfo_as_text) {
00675                      php_info_print_box_start(1);
00676               }
00677 
00678               if (expose_php && !sapi_module.phpinfo_as_text) {
00679                      PUTS("<a href=\"http://www.php.net/\"><img border=\"0\" src=\"");
00680                      if (SG(request_info).request_uri) {
00681                             char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
00682                             PUTS(elem_esc);
00683                             efree(elem_esc);
00684                      }
00685                      PUTS("?=");
00686                      logo_guid = php_logo_guid();
00687                      PUTS(logo_guid);
00688                      efree(logo_guid);
00689                      PUTS("\" alt=\"PHP Logo\" /></a>");
00690               }
00691 
00692               if (!sapi_module.phpinfo_as_text) {
00693                      php_printf("<h1 class=\"p\">PHP Version %s</h1>\n", PHP_VERSION);
00694               } else {
00695                      php_info_print_table_row(2, "PHP Version", PHP_VERSION);
00696               }      
00697               php_info_print_box_end();
00698               php_info_print_table_start();
00699               php_info_print_table_row(2, "System", php_uname );
00700               php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__ );
00701 #ifdef COMPILER
00702               php_info_print_table_row(2, "Compiler", COMPILER);
00703 #endif
00704 #ifdef ARCHITECTURE
00705               php_info_print_table_row(2, "Architecture", ARCHITECTURE);
00706 #endif
00707 #ifdef CONFIGURE_COMMAND
00708               php_info_print_table_row(2, "Configure Command", CONFIGURE_COMMAND );
00709 #endif
00710 
00711               if (sapi_module.pretty_name) {
00712                      php_info_print_table_row(2, "Server API", sapi_module.pretty_name );
00713               }
00714 
00715 #ifdef VIRTUAL_DIR
00716               php_info_print_table_row(2, "Virtual Directory Support", "enabled" );
00717 #else
00718               php_info_print_table_row(2, "Virtual Directory Support", "disabled" );
00719 #endif
00720 
00721               php_info_print_table_row(2, "Configuration File (php.ini) Path", PHP_CONFIG_FILE_PATH);
00722               php_info_print_table_row(2, "Loaded Configuration File", php_ini_opened_path ? php_ini_opened_path : "(none)");
00723               php_info_print_table_row(2, "Scan this dir for additional .ini files", php_ini_scanned_path ? php_ini_scanned_path : "(none)");
00724               php_info_print_table_row(2, "Additional .ini files parsed", php_ini_scanned_files ? php_ini_scanned_files : "(none)");
00725 
00726               snprintf(temp_api, sizeof(temp_api), "%d", PHP_API_VERSION);
00727               php_info_print_table_row(2, "PHP API", temp_api);
00728 
00729               snprintf(temp_api, sizeof(temp_api), "%d", ZEND_MODULE_API_NO);
00730               php_info_print_table_row(2, "PHP Extension", temp_api);
00731 
00732               snprintf(temp_api, sizeof(temp_api), "%d", ZEND_EXTENSION_API_NO);
00733               php_info_print_table_row(2, "Zend Extension", temp_api);
00734 
00735               php_info_print_table_row(2, "Zend Extension Build", ZEND_EXTENSION_BUILD_ID);
00736               php_info_print_table_row(2, "PHP Extension Build", ZEND_MODULE_BUILD_ID);
00737 
00738 #if ZEND_DEBUG
00739               php_info_print_table_row(2, "Debug Build", "yes" );
00740 #else
00741               php_info_print_table_row(2, "Debug Build", "no" );
00742 #endif
00743 
00744 #ifdef ZTS
00745               php_info_print_table_row(2, "Thread Safety", "enabled" );
00746 #else
00747               php_info_print_table_row(2, "Thread Safety", "disabled" );
00748 #endif
00749 
00750               php_info_print_table_row(2, "Zend Memory Manager", is_zend_mm(TSRMLS_C) ? "enabled" : "disabled" );
00751 
00752 #ifdef ZEND_MULTIBYTE
00753               php_info_print_table_row(2, "Zend Multibyte Support", "enabled");
00754 #else
00755               php_info_print_table_row(2, "Zend Multibyte Support", "disabled");
00756 #endif
00757 
00758 #if HAVE_IPV6
00759               php_info_print_table_row(2, "IPv6 Support", "enabled" );
00760 #else
00761               php_info_print_table_row(2, "IPv6 Support", "disabled" );
00762 #endif
00763               {
00764                      HashTable *url_stream_wrappers_hash;
00765                      char *stream_protocol, *stream_protocols_buf = NULL;
00766                      int stream_protocol_len, stream_protocols_buf_len = 0;
00767                      ulong num_key;
00768 
00769                      if ((url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash())) {
00770                             HashPosition pos;
00771                             for (zend_hash_internal_pointer_reset_ex(url_stream_wrappers_hash, &pos);
00772                                           zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, (uint *)&stream_protocol_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING;
00773                                           zend_hash_move_forward_ex(url_stream_wrappers_hash, &pos)) {
00774                                    stream_protocols_buf = erealloc(stream_protocols_buf, stream_protocols_buf_len + stream_protocol_len + 2 + 1);
00775                                    memcpy(stream_protocols_buf + stream_protocols_buf_len, stream_protocol, stream_protocol_len - 1);
00776                                    stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len - 1] = ',';
00777                                    stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len] = ' ';
00778                                    stream_protocols_buf_len += stream_protocol_len + 1;
00779                             }
00780                             if (stream_protocols_buf) {
00781                                    stream_protocols_buf[stream_protocols_buf_len - 2] = ' ';
00782                                    stream_protocols_buf[stream_protocols_buf_len] = 0;
00783                                    php_info_print_table_row(2, "Registered PHP Streams", stream_protocols_buf);
00784                                    efree(stream_protocols_buf);
00785                             } else {
00786                                    /* Any chances we will ever hit this? */
00787                                    php_info_print_table_row(2, "Registered PHP Streams", "no streams registered");
00788                             }
00789                      } else {
00790                             /* Any chances we will ever hit this? */
00791                             php_info_print_table_row(2, "PHP Streams", "disabled"); /* ?? */
00792                      }
00793               }
00794 
00795               {
00796                      HashTable *stream_xport_hash;
00797                      char *xport_name, *xport_buf = NULL;
00798                      int xport_name_len, xport_buf_len = 0, xport_buf_size = 0;
00799                      ulong num_key;
00800 
00801                      if ((stream_xport_hash = php_stream_xport_get_hash())) {
00802                             HashPosition pos;
00803                             for(zend_hash_internal_pointer_reset_ex(stream_xport_hash, &pos);
00804                                    zend_hash_get_current_key_ex(stream_xport_hash, &xport_name, (uint *)&xport_name_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING;
00805                                    zend_hash_move_forward_ex(stream_xport_hash, &pos)) {
00806                                    if (xport_buf_len + xport_name_len + 2 > xport_buf_size) {
00807                                           while (xport_buf_len + xport_name_len + 2 > xport_buf_size) {
00808                                                  xport_buf_size += 256;
00809                                           }
00810                                           if (xport_buf) {
00811                                                  xport_buf = erealloc(xport_buf, xport_buf_size);
00812                                           } else {
00813                                                  xport_buf = emalloc(xport_buf_size);
00814                                           }
00815                                    }
00816                                    if (xport_buf_len > 0) {
00817                                           xport_buf[xport_buf_len++] = ',';
00818                                           xport_buf[xport_buf_len++] = ' ';
00819                                    }
00820                                    memcpy(xport_buf + xport_buf_len, xport_name, xport_name_len - 1);
00821                                    xport_buf_len += xport_name_len - 1;
00822                                    xport_buf[xport_buf_len] = '\0';
00823                             }
00824                             if (xport_buf) {
00825                                    php_info_print_table_row(2, "Registered Stream Socket Transports", xport_buf);
00826                                    efree(xport_buf);
00827                             } else {
00828                                    /* Any chances we will ever hit this? */
00829                                    php_info_print_table_row(2, "Registered Stream Socket Transports", "no transports registered");
00830                             }
00831                      } else {
00832                             /* Any chances we will ever hit this? */
00833                             php_info_print_table_row(2, "Stream Socket Transports", "disabled"); /* ?? */
00834                      }
00835               }
00836 
00837               {
00838                      HashTable *stream_filter_hash;
00839                      char *filter_name, *filter_buf = NULL;
00840                      int filter_name_len, filter_buf_len = 0, filter_buf_size = 0;
00841                      ulong num_key;
00842 
00843                      if ((stream_filter_hash = php_get_stream_filters_hash())) {
00844                             HashPosition pos;
00845                             for(zend_hash_internal_pointer_reset_ex(stream_filter_hash, &pos);
00846                                    zend_hash_get_current_key_ex(stream_filter_hash, &filter_name, (uint *)&filter_name_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING;
00847                                    zend_hash_move_forward_ex(stream_filter_hash, &pos)) {
00848                                    if (filter_buf_len + filter_name_len + 2 > filter_buf_size) {
00849                                           while (filter_buf_len + filter_name_len + 2 > filter_buf_size) {
00850                                                  filter_buf_size += 256;
00851                                           }
00852                                           if (filter_buf) {
00853                                                  filter_buf = erealloc(filter_buf, filter_buf_size);
00854                                           } else {
00855                                                  filter_buf = emalloc(filter_buf_size);
00856                                           }
00857                                    }
00858                                    if (filter_buf_len > 0) {
00859                                           filter_buf[filter_buf_len++] = ',';
00860                                           filter_buf[filter_buf_len++] = ' ';
00861                                    }
00862                                    memcpy(filter_buf + filter_buf_len, filter_name, filter_name_len - 1);
00863                                    filter_buf_len += filter_name_len - 1;
00864                                    filter_buf[filter_buf_len] = '\0';
00865                             }
00866                             if (filter_buf) {
00867                                    php_info_print_table_row(2, "Registered Stream Filters", filter_buf);
00868                                    efree(filter_buf);
00869                             } else {
00870                                    /* Any chances we will ever hit this? */
00871                                    php_info_print_table_row(2, "Registered Stream Filters", "no filters registered");
00872                             }
00873                      } else {
00874                             /* Any chances we will ever hit this? */
00875                             php_info_print_table_row(2, "Stream Filters", "disabled"); /* ?? */
00876                      }
00877               }
00878               
00879               php_info_print_table_end();
00880 
00881               /* Zend Engine */
00882               php_info_print_box_start(0);
00883               if (expose_php && !sapi_module.phpinfo_as_text) {
00884                      PUTS("<a href=\"http://www.zend.com/\"><img border=\"0\" src=\"");
00885                      if (SG(request_info).request_uri) {
00886                             char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
00887                             PUTS(elem_esc);
00888                             efree(elem_esc);
00889                      }
00890                      PUTS("?="ZEND_LOGO_GUID"\" alt=\"Zend logo\" /></a>\n");
00891               }
00892               PUTS("This program makes use of the Zend Scripting Language Engine:");
00893               PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n");
00894               if (sapi_module.phpinfo_as_text) {
00895                      PUTS(zend_version);
00896               } else {
00897                      zend_html_puts(zend_version, strlen(zend_version) TSRMLS_CC);
00898               }
00899               php_info_print_box_end();
00900               efree(php_uname);
00901        }
00902 
00903        if ((flag & PHP_INFO_CREDITS) && expose_php && !sapi_module.phpinfo_as_text) {      
00904               php_info_print_hr();
00905               PUTS("<h1><a href=\"");
00906               if (SG(request_info).request_uri) {
00907                      char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
00908                      PUTS(elem_esc);
00909                      efree(elem_esc);
00910               }
00911               PUTS("?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000\">");
00912               PUTS("PHP Credits");
00913               PUTS("</a></h1>\n");
00914        }
00915 
00916        zend_ini_sort_entries(TSRMLS_C);
00917 
00918        if (flag & PHP_INFO_CONFIGURATION) {
00919               php_info_print_hr();
00920               if (!sapi_module.phpinfo_as_text) {
00921                      PUTS("<h1>Configuration</h1>\n");
00922               } else {
00923                      SECTION("Configuration");
00924               }      
00925               if (!(flag & PHP_INFO_MODULES)) {
00926                      SECTION("PHP Core");
00927                      display_ini_entries(NULL);
00928               }
00929        }
00930 
00931        if (flag & PHP_INFO_MODULES) {
00932               HashTable sorted_registry;
00933               zend_module_entry tmp;
00934 
00935               zend_hash_init(&sorted_registry, zend_hash_num_elements(&module_registry), NULL, NULL, 1);
00936               zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry));
00937               zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC);
00938 
00939               zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_func TSRMLS_CC);
00940 
00941               SECTION("Additional Modules");
00942               php_info_print_table_start();
00943               php_info_print_table_header(1, "Module Name");
00944               zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_def TSRMLS_CC);
00945               php_info_print_table_end();
00946 
00947               zend_hash_destroy(&sorted_registry);
00948        }
00949 
00950        if (flag & PHP_INFO_ENVIRONMENT) {
00951               SECTION("Environment");
00952               php_info_print_table_start();
00953               php_info_print_table_header(2, "Variable", "Value");
00954               for (env=environ; env!=NULL && *env !=NULL; env++) {
00955                      tmp1 = estrdup(*env);
00956                      if (!(tmp2=strchr(tmp1,'='))) { /* malformed entry? */
00957                             efree(tmp1);
00958                             continue;
00959                      }
00960                      *tmp2 = 0;
00961                      tmp2++;
00962                      php_info_print_table_row(2, tmp1, tmp2);
00963                      efree(tmp1);
00964               }
00965               php_info_print_table_end();
00966        }
00967 
00968        if (flag & PHP_INFO_VARIABLES) {
00969               zval **data;
00970 
00971               SECTION("PHP Variables");
00972 
00973               php_info_print_table_start();
00974               php_info_print_table_header(2, "Variable", "Value");
00975               if (zend_hash_find(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void **) &data) != FAILURE) {
00976                      php_info_print_table_row(2, "PHP_SELF", Z_STRVAL_PP(data));
00977               }
00978               if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_TYPE", sizeof("PHP_AUTH_TYPE"), (void **) &data) != FAILURE) {
00979                      php_info_print_table_row(2, "PHP_AUTH_TYPE", Z_STRVAL_PP(data));
00980               }
00981               if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_USER", sizeof("PHP_AUTH_USER"), (void **) &data) != FAILURE) {
00982                      php_info_print_table_row(2, "PHP_AUTH_USER", Z_STRVAL_PP(data));
00983               }
00984               if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_PW", sizeof("PHP_AUTH_PW"), (void **) &data) != FAILURE) {
00985                      php_info_print_table_row(2, "PHP_AUTH_PW", Z_STRVAL_PP(data));
00986               }
00987               php_print_gpcse_array("_REQUEST", sizeof("_REQUEST")-1 TSRMLS_CC);
00988               php_print_gpcse_array("_GET", sizeof("_GET")-1 TSRMLS_CC);
00989               php_print_gpcse_array("_POST", sizeof("_POST")-1 TSRMLS_CC);
00990               php_print_gpcse_array("_FILES", sizeof("_FILES")-1 TSRMLS_CC);
00991               php_print_gpcse_array("_COOKIE", sizeof("_COOKIE")-1 TSRMLS_CC);
00992               php_print_gpcse_array("_SERVER", sizeof("_SERVER")-1 TSRMLS_CC);
00993               php_print_gpcse_array("_ENV", sizeof("_ENV")-1 TSRMLS_CC);
00994               php_info_print_table_end();
00995        }
00996 
00997        if (flag & PHP_INFO_LICENSE) {
00998               if (!sapi_module.phpinfo_as_text) {
00999                      SECTION("PHP License");
01000                      php_info_print_box_start(0);
01001                      PUTS("<p>\n");
01002                      PUTS("This program is free software; you can redistribute it and/or modify ");
01003                      PUTS("it under the terms of the PHP License as published by the PHP Group ");
01004                      PUTS("and included in the distribution in the file:  LICENSE\n");
01005                      PUTS("</p>\n");
01006                      PUTS("<p>");
01007                      PUTS("This program is distributed in the hope that it will be useful, ");
01008                      PUTS("but WITHOUT ANY WARRANTY; without even the implied warranty of ");
01009                      PUTS("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
01010                      PUTS("</p>\n");
01011                      PUTS("<p>");
01012                      PUTS("If you did not receive a copy of the PHP license, or have any questions about ");
01013                      PUTS("PHP licensing, please contact license@php.net.\n");
01014                      PUTS("</p>\n");
01015                      php_info_print_box_end();
01016               } else {
01017                      PUTS("\nPHP License\n");
01018                      PUTS("This program is free software; you can redistribute it and/or modify\n");
01019                      PUTS("it under the terms of the PHP License as published by the PHP Group\n");
01020                      PUTS("and included in the distribution in the file:  LICENSE\n");
01021                      PUTS("\n");
01022                      PUTS("This program is distributed in the hope that it will be useful,\n");
01023                      PUTS("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
01024                      PUTS("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
01025                      PUTS("\n");
01026                      PUTS("If you did not receive a copy of the PHP license, or have any\n");
01027                      PUTS("questions about PHP licensing, please contact license@php.net.\n");
01028               }
01029        }
01030        if (!sapi_module.phpinfo_as_text) {
01031               PUTS("</div></body></html>");
01032        }      
01033 }
01034 /* }}} */
01035 
01036 
01037 PHPAPI void php_info_print_table_start(void)
01038 {
01039        if (!sapi_module.phpinfo_as_text) {
01040               php_printf("<table border=\"0\" cellpadding=\"3\" width=\"600\">\n");
01041        } else {
01042               php_printf("\n");
01043        }      
01044 }
01045 
01046 PHPAPI void php_info_print_table_end(void)
01047 {
01048        if (!sapi_module.phpinfo_as_text) {
01049               php_printf("</table><br />\n");
01050        }
01051 
01052 }
01053 
01054 PHPAPI void php_info_print_box_start(int flag)
01055 {
01056        php_info_print_table_start();
01057        if (flag) {
01058               if (!sapi_module.phpinfo_as_text) {
01059                      php_printf("<tr class=\"h\"><td>\n");
01060               }
01061        } else {
01062               if (!sapi_module.phpinfo_as_text) {
01063                      php_printf("<tr class=\"v\"><td>\n");
01064               } else {
01065                      php_printf("\n");
01066               }      
01067        }
01068 }
01069 
01070 PHPAPI void php_info_print_box_end(void)
01071 {
01072        if (!sapi_module.phpinfo_as_text) {
01073               php_printf("</td></tr>\n");
01074        }
01075        php_info_print_table_end();
01076 }
01077 
01078 PHPAPI void php_info_print_hr(void)
01079 {
01080        if (!sapi_module.phpinfo_as_text) {
01081               php_printf("<hr />\n");
01082        } else {
01083               php_printf("\n\n _______________________________________________________________________\n\n");
01084        }
01085 }
01086 
01087 PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header)
01088 {
01089        int spaces;
01090 
01091        if (!sapi_module.phpinfo_as_text) {
01092               php_printf("<tr class=\"h\"><th colspan=\"%d\">%s</th></tr>\n", num_cols, header );
01093        } else {
01094               spaces = (74 - strlen(header));
01095               php_printf("%*s%s%*s\n", (int)(spaces/2), " ", header, (int)(spaces/2), " ");
01096        }      
01097 }
01098 
01099 /* {{{ php_info_print_table_header
01100  */
01101 PHPAPI void php_info_print_table_header(int num_cols, ...)
01102 {
01103        int i;
01104        va_list row_elements;
01105        char *row_element;
01106 
01107        TSRMLS_FETCH();
01108 
01109        va_start(row_elements, num_cols);
01110        if (!sapi_module.phpinfo_as_text) {
01111               php_printf("<tr class=\"h\">");
01112        }      
01113        for (i=0; i<num_cols; i++) {
01114               row_element = va_arg(row_elements, char *);
01115               if (!row_element || !*row_element) {
01116                      row_element = " ";
01117               }
01118               if (!sapi_module.phpinfo_as_text) {
01119                      PUTS("<th>");
01120                      PUTS(row_element);
01121                      PUTS("</th>");
01122               } else {
01123                      PUTS(row_element);
01124                      if (i < num_cols-1) {
01125                             PUTS(" => ");
01126                      } else {
01127                             PUTS("\n");
01128                      }      
01129               }      
01130        }
01131        if (!sapi_module.phpinfo_as_text) {
01132               php_printf("</tr>\n");
01133        }      
01134 
01135        va_end(row_elements);
01136 }
01137 /* }}} */
01138 
01139 /* {{{ php_info_print_table_row_internal
01140  */
01141 static void php_info_print_table_row_internal(int num_cols, 
01142               const char *value_class, va_list row_elements)
01143 {
01144        int i;
01145        char *row_element;
01146        char *elem_esc = NULL;
01147 /*
01148        int elem_esc_len;
01149 */
01150 
01151        TSRMLS_FETCH();
01152 
01153        if (!sapi_module.phpinfo_as_text) {
01154               php_printf("<tr>");
01155        }      
01156        for (i=0; i<num_cols; i++) {
01157               if (!sapi_module.phpinfo_as_text) {
01158                      php_printf("<td class=\"%s\">",
01159                         (i==0 ? "e" : value_class )
01160                      );
01161               }      
01162               row_element = va_arg(row_elements, char *);
01163               if (!row_element || !*row_element) {
01164                      if (!sapi_module.phpinfo_as_text) {
01165                             PUTS( "<i>no value</i>" );
01166                      } else {
01167                             PUTS( " " );
01168                      }
01169               } else {
01170                      if (!sapi_module.phpinfo_as_text) {
01171                             elem_esc = php_info_html_esc(row_element TSRMLS_CC);
01172                             PUTS(elem_esc);
01173                             efree(elem_esc);
01174                      } else {
01175                             PUTS(row_element);
01176                             if (i < num_cols-1) {
01177                                    PUTS(" => ");
01178                             }      
01179                      }
01180               }
01181               if (!sapi_module.phpinfo_as_text) {
01182                      php_printf(" </td>");
01183               } else if (i == (num_cols - 1)) {
01184                      PUTS("\n");
01185               }
01186        }
01187        if (!sapi_module.phpinfo_as_text) {
01188               php_printf("</tr>\n");
01189        }
01190 }
01191 /* }}} */
01192 
01193 /* {{{ php_info_print_table_row
01194  */
01195 PHPAPI void php_info_print_table_row(int num_cols, ...)
01196 {
01197        va_list row_elements;
01198        
01199        va_start(row_elements, num_cols);
01200        php_info_print_table_row_internal(num_cols, "v", row_elements);
01201        va_end(row_elements);
01202 }
01203 /* }}} */
01204 
01205 /* {{{ php_info_print_table_row_ex
01206  */
01207 PHPAPI void php_info_print_table_row_ex(int num_cols, const char *value_class, 
01208               ...)
01209 {
01210        va_list row_elements;
01211        
01212        va_start(row_elements, value_class);
01213        php_info_print_table_row_internal(num_cols, value_class, row_elements);
01214        va_end(row_elements);
01215 }
01216 /* }}} */
01217 
01218 /* {{{ register_phpinfo_constants
01219  */
01220 void register_phpinfo_constants(INIT_FUNC_ARGS)
01221 {
01222        REGISTER_LONG_CONSTANT("INFO_GENERAL", PHP_INFO_GENERAL, CONST_PERSISTENT|CONST_CS);
01223        REGISTER_LONG_CONSTANT("INFO_CREDITS", PHP_INFO_CREDITS, CONST_PERSISTENT|CONST_CS);
01224        REGISTER_LONG_CONSTANT("INFO_CONFIGURATION", PHP_INFO_CONFIGURATION, CONST_PERSISTENT|CONST_CS);
01225        REGISTER_LONG_CONSTANT("INFO_MODULES", PHP_INFO_MODULES, CONST_PERSISTENT|CONST_CS);
01226        REGISTER_LONG_CONSTANT("INFO_ENVIRONMENT", PHP_INFO_ENVIRONMENT, CONST_PERSISTENT|CONST_CS);
01227        REGISTER_LONG_CONSTANT("INFO_VARIABLES", PHP_INFO_VARIABLES, CONST_PERSISTENT|CONST_CS);
01228        REGISTER_LONG_CONSTANT("INFO_LICENSE", PHP_INFO_LICENSE, CONST_PERSISTENT|CONST_CS);
01229        REGISTER_LONG_CONSTANT("INFO_ALL", PHP_INFO_ALL, CONST_PERSISTENT|CONST_CS);
01230        REGISTER_LONG_CONSTANT("CREDITS_GROUP",   PHP_CREDITS_GROUP, CONST_PERSISTENT|CONST_CS);
01231        REGISTER_LONG_CONSTANT("CREDITS_GENERAL", PHP_CREDITS_GENERAL, CONST_PERSISTENT|CONST_CS);
01232        REGISTER_LONG_CONSTANT("CREDITS_SAPI",    PHP_CREDITS_SAPI, CONST_PERSISTENT|CONST_CS);
01233        REGISTER_LONG_CONSTANT("CREDITS_MODULES", PHP_CREDITS_MODULES, CONST_PERSISTENT|CONST_CS);
01234        REGISTER_LONG_CONSTANT("CREDITS_DOCS",    PHP_CREDITS_DOCS, CONST_PERSISTENT|CONST_CS);
01235        REGISTER_LONG_CONSTANT("CREDITS_FULLPAGE",       PHP_CREDITS_FULLPAGE, CONST_PERSISTENT|CONST_CS);
01236        REGISTER_LONG_CONSTANT("CREDITS_QA",      PHP_CREDITS_QA, CONST_PERSISTENT|CONST_CS);
01237        REGISTER_LONG_CONSTANT("CREDITS_ALL",     PHP_CREDITS_ALL, CONST_PERSISTENT|CONST_CS);
01238 }
01239 /* }}} */
01240 
01241 /* {{{ proto void phpinfo([int what])
01242    Output a page of useful information about PHP and the current request */
01243 PHP_FUNCTION(phpinfo)
01244 {
01245        long flag = PHP_INFO_ALL;
01246 
01247        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) {
01248               return;
01249        }
01250 
01251        /* Andale!  Andale!  Yee-Hah! */
01252        php_start_ob_buffer(NULL, 4096, 0 TSRMLS_CC);
01253        php_print_info(flag TSRMLS_CC);
01254        php_end_ob_buffer(1, 0 TSRMLS_CC);
01255 
01256        RETURN_TRUE;
01257 }
01258 
01259 /* }}} */
01260 
01261 /* {{{ proto string phpversion([string extension])
01262    Return the current PHP version */
01263 PHP_FUNCTION(phpversion)
01264 {
01265        zval **arg;
01266        const char *version;
01267        int argc = ZEND_NUM_ARGS();
01268 
01269        if (argc == 0) {
01270               RETURN_STRING(PHP_VERSION, 1);
01271        } else {
01272               if (zend_parse_parameters(argc TSRMLS_CC, "Z", &arg) == FAILURE) {
01273                      return;
01274               }
01275                      
01276               convert_to_string_ex(arg);
01277               version = zend_get_module_version(Z_STRVAL_PP(arg));
01278               
01279               if (version == NULL) {
01280                      RETURN_FALSE;
01281               }
01282               RETURN_STRING(version, 1);
01283        }
01284 }
01285 /* }}} */
01286 
01287 /* {{{ proto void phpcredits([int flag])
01288    Prints the list of people who've contributed to the PHP project */
01289 PHP_FUNCTION(phpcredits)
01290 {
01291        long flag = PHP_CREDITS_ALL;
01292 
01293        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) {
01294               return;
01295        }
01296 
01297        php_print_credits(flag TSRMLS_CC);
01298        RETURN_TRUE;
01299 }
01300 /* }}} */
01301 
01302 
01303 /* {{{ php_logo_guid
01304  */
01305 PHPAPI char *php_logo_guid(void)
01306 {
01307        char *logo_guid;
01308 
01309        time_t the_time;
01310        struct tm *ta, tmbuf;
01311 
01312        the_time = time(NULL);
01313        ta = php_localtime_r(&the_time, &tmbuf);
01314 
01315        if (ta && (ta->tm_mon==3) && (ta->tm_mday==1)) {
01316               logo_guid = PHP_EGG_LOGO_GUID;
01317        } else {
01318               logo_guid = PHP_LOGO_GUID;
01319        }
01320 
01321        return estrdup(logo_guid);
01322 
01323 }
01324 /* }}} */
01325 
01326 /* {{{ proto string php_logo_guid(void)
01327    Return the special ID used to request the PHP logo in phpinfo screens*/
01328 PHP_FUNCTION(php_logo_guid)
01329 {
01330 
01331        if (zend_parse_parameters_none() == FAILURE) {
01332               return;
01333        }
01334 
01335        RETURN_STRING(php_logo_guid(), 0);
01336 }
01337 /* }}} */
01338 
01339 /* {{{ proto string php_real_logo_guid(void)
01340    Return the special ID used to request the PHP logo in phpinfo screens*/
01341 PHP_FUNCTION(php_real_logo_guid)
01342 {
01343 
01344        if (zend_parse_parameters_none() == FAILURE) {
01345               return;
01346        }
01347 
01348        RETURN_STRINGL(PHP_LOGO_GUID, sizeof(PHP_LOGO_GUID)-1, 1);
01349 }
01350 /* }}} */
01351 
01352 /* {{{ proto string php_egg_logo_guid(void)
01353    Return the special ID used to request the PHP logo in phpinfo screens*/
01354 PHP_FUNCTION(php_egg_logo_guid)
01355 {
01356        if (zend_parse_parameters_none() == FAILURE) {
01357               return;
01358        }
01359 
01360        RETURN_STRINGL(PHP_EGG_LOGO_GUID, sizeof(PHP_EGG_LOGO_GUID)-1, 1);
01361 }
01362 /* }}} */
01363 
01364 /* {{{ proto string zend_logo_guid(void)
01365    Return the special ID used to request the Zend logo in phpinfo screens*/
01366 PHP_FUNCTION(zend_logo_guid)
01367 {
01368        if (zend_parse_parameters_none() == FAILURE) {
01369               return;
01370        }
01371 
01372        RETURN_STRINGL(ZEND_LOGO_GUID, sizeof(ZEND_LOGO_GUID)-1, 1);
01373 }
01374 /* }}} */
01375 
01376 /* {{{ proto string php_sapi_name(void)
01377    Return the current SAPI module name */
01378 PHP_FUNCTION(php_sapi_name)
01379 {
01380        if (zend_parse_parameters_none() == FAILURE) {
01381               return;
01382        }
01383 
01384        if (sapi_module.name) {
01385               RETURN_STRING(sapi_module.name, 1);
01386        } else {
01387               RETURN_FALSE;
01388        }
01389 }
01390 
01391 /* }}} */
01392 
01393 /* {{{ proto string php_uname(void)
01394    Return information about the system PHP was built on */
01395 PHP_FUNCTION(php_uname)
01396 {
01397        char *mode = "a";
01398        int modelen = sizeof("a")-1;
01399        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &mode, &modelen) == FAILURE) {
01400               return;
01401        }
01402        RETURN_STRING(php_get_uname(*mode), 0);
01403 }
01404 
01405 /* }}} */
01406 
01407 /* {{{ proto string php_ini_scanned_files(void)
01408    Return comma-separated string of .ini files parsed from the additional ini dir */
01409 PHP_FUNCTION(php_ini_scanned_files)
01410 {
01411        if (zend_parse_parameters_none() == FAILURE) {
01412               return;
01413        }
01414        
01415        if (strlen(PHP_CONFIG_FILE_SCAN_DIR) && php_ini_scanned_files) {
01416               RETURN_STRING(php_ini_scanned_files, 1);
01417        } else {
01418               RETURN_FALSE;
01419        }
01420 }
01421 /* }}} */
01422 
01423 /* {{{ proto string php_ini_loaded_file(void)
01424    Return the actual loaded ini filename */
01425 PHP_FUNCTION(php_ini_loaded_file)
01426 {
01427        if (zend_parse_parameters_none() == FAILURE) {
01428               return;
01429        }
01430        
01431        if (php_ini_opened_path) {
01432               RETURN_STRING(php_ini_opened_path, 1);
01433        } else {
01434               RETURN_FALSE;
01435        }
01436 }
01437 /* }}} */
01438 
01439 /*
01440  * Local variables:
01441  * tab-width: 4
01442  * c-basic-offset: 4
01443  * End:
01444  * vim600: sw=4 ts=4 fdm=marker
01445  * vim<600: sw=4 ts=4
01446  */