File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / info.c
Revision 1.1.1.5 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Sun Jun 15 20:03:57 2014 UTC (10 years, 1 month ago) by misho
Branches: php, MAIN
CVS tags: v5_4_29, HEAD
php 5.4.29

    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: info.c,v 1.1.1.5 2014/06/15 20:03:57 misho Exp $ */
   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: 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: 	new_str = php_escape_html_entities((unsigned char *) str, len, &new_len, 0, ENT_QUOTES, "utf-8" TSRMLS_CC);
   72: 	written = php_output_write(new_str, new_len TSRMLS_CC);
   73: 	efree(new_str);
   74: 	return written;
   75: }
   76: /* }}} */
   77: 
   78: 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: 	va_start(argv, fmt);
   86: 	len = vspprintf(&buf, 0, fmt, argv);
   87: 	va_end(argv);
   88: 	
   89: 	written = php_output_write(buf, len TSRMLS_CC);
   90: 	efree(buf);
   91: 	return written;
   92: }
   93: /* }}} */
   94: 
   95: static void php_info_print_request_uri(TSRMLS_D) /* {{{ */
   96: {
   97: 	if (SG(request_info).request_uri) {
   98: 		php_info_print_html_esc(SG(request_info).request_uri, strlen(SG(request_info).request_uri));
   99: 	}
  100: }
  101: /* }}} */
  102: 
  103: static int php_info_print(const char *str) /* {{{ */
  104: {
  105: 	TSRMLS_FETCH();
  106: 	return php_output_write(str, strlen(str) TSRMLS_CC);
  107: }
  108: /* }}} */
  109: 
  110: static void php_info_print_stream_hash(const char *name, HashTable *ht TSRMLS_DC) /* {{{ */
  111: {
  112: 	char *key;
  113: 	uint len;
  114: 	
  115: 	if (ht) {
  116: 		if (zend_hash_num_elements(ht)) {
  117: 			HashPosition pos;
  118: 
  119: 			if (!sapi_module.phpinfo_as_text) {
  120: 				php_info_printf("<tr><td class=\"e\">Registered %s</td><td class=\"v\">", name);
  121: 			} else {
  122: 				php_info_printf("\nRegistered %s => ", name);
  123: 			}
  124: 			
  125: 			zend_hash_internal_pointer_reset_ex(ht, &pos);
  126: 			while (zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos) == HASH_KEY_IS_STRING)
  127: 			{
  128: 				if (!sapi_module.phpinfo_as_text) {
  129: 					php_info_print_html_esc(key, len-1);
  130: 				} else {
  131: 					php_info_print(key);
  132: 				}
  133: 				zend_hash_move_forward_ex(ht, &pos);
  134: 				if (zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
  135: 					php_info_print(", ");
  136: 				} else {
  137: 					break;
  138: 				}
  139: 			}
  140: 			
  141: 			if (!sapi_module.phpinfo_as_text) {
  142: 				php_info_print("</td></tr>\n");
  143: 			}
  144: 		} else {
  145: 			char reg_name[128];
  146: 			snprintf(reg_name, sizeof(reg_name), "Registered %s", name);
  147: 			php_info_print_table_row(2, reg_name, "none registered");
  148: 		}
  149: 	} else {
  150: 		php_info_print_table_row(2, name, "disabled");
  151: 	}
  152: }
  153: /* }}} */
  154: 
  155: PHPAPI void php_info_print_module(zend_module_entry *zend_module TSRMLS_DC) /* {{{ */
  156: {
  157: 	if (zend_module->info_func || zend_module->version) {
  158: 		if (!sapi_module.phpinfo_as_text) {
  159: 			php_info_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", zend_module->name, zend_module->name);
  160: 		} else {
  161: 			php_info_print_table_start();
  162: 			php_info_print_table_header(1, zend_module->name);
  163: 			php_info_print_table_end();
  164: 		}
  165: 		if (zend_module->info_func) {
  166: 			zend_module->info_func(zend_module TSRMLS_CC);
  167: 		} else {
  168: 			php_info_print_table_start();
  169: 			php_info_print_table_row(2, "Version", zend_module->version);
  170: 			php_info_print_table_end();
  171: 			DISPLAY_INI_ENTRIES();
  172: 		}
  173: 	} else {
  174: 		if (!sapi_module.phpinfo_as_text) {
  175: 			php_info_printf("<tr><td>%s</td></tr>\n", zend_module->name);
  176: 		} else {
  177: 			php_info_printf("%s\n", zend_module->name);
  178: 		}	
  179: 	}
  180: }
  181: /* }}} */
  182: 
  183: static int _display_module_info_func(zend_module_entry *module TSRMLS_DC) /* {{{ */
  184: {
  185: 	if (module->info_func || module->version) {
  186: 		php_info_print_module(module TSRMLS_CC);
  187: 	}
  188: 	return ZEND_HASH_APPLY_KEEP;
  189: }
  190: /* }}} */
  191: 
  192: static int _display_module_info_def(zend_module_entry *module TSRMLS_DC) /* {{{ */
  193: {
  194: 	if (!module->info_func && !module->version) {
  195: 		php_info_print_module(module TSRMLS_CC);
  196: 	}
  197: 	return ZEND_HASH_APPLY_KEEP;
  198: }
  199: /* }}} */
  200: 
  201: /* {{{ php_print_gpcse_array
  202:  */
  203: 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: 	zend_is_auto_global(name, name_length TSRMLS_CC);
  211: 
  212: 	if (zend_hash_find(&EG(symbol_table), name, name_length+1, (void **) &data)!=FAILURE
  213: 		&& (Z_TYPE_PP(data)==IS_ARRAY)) {
  214: 		zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data));
  215: 		while (zend_hash_get_current_data(Z_ARRVAL_PP(data), (void **) &tmp) == SUCCESS) {
  216: 			if (!sapi_module.phpinfo_as_text) {
  217: 				php_info_print("<tr>");
  218: 				php_info_print("<td class=\"e\">");
  219: 			}
  220: 
  221: 			php_info_print(name);
  222: 			php_info_print("[\"");
  223: 			
  224: 			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: 					if (!sapi_module.phpinfo_as_text) {
  227: 						php_info_print_html_esc(string_key, string_len-1);
  228: 					} else {
  229: 						php_info_print(string_key);
  230: 					}
  231: 					break;
  232: 				case HASH_KEY_IS_LONG:
  233: 					php_info_printf("%ld", num_key);
  234: 					break;
  235: 			}
  236: 			php_info_print("\"]");
  237: 			if (!sapi_module.phpinfo_as_text) {
  238: 				php_info_print("</td><td class=\"v\">");
  239: 			} else {
  240: 				php_info_print(" => ");
  241: 			}
  242: 			if (Z_TYPE_PP(tmp) == IS_ARRAY) {
  243: 				if (!sapi_module.phpinfo_as_text) {
  244: 					php_info_print("<pre>");
  245: 					zend_print_zval_r_ex((zend_write_func_t) php_info_print_html_esc, *tmp, 0 TSRMLS_CC);
  246: 					php_info_print("</pre>");
  247: 				} else {
  248: 					zend_print_zval_r(*tmp, 0 TSRMLS_CC);
  249: 				}
  250: 			} else {
  251: 				tmp2 = **tmp;
  252: 				if (Z_TYPE_PP(tmp) != IS_STRING) {
  253: 					tmp = NULL;
  254: 					zval_copy_ctor(&tmp2);
  255: 					convert_to_string(&tmp2);
  256: 				}
  257: 
  258: 				if (!sapi_module.phpinfo_as_text) {
  259: 					if (Z_STRLEN(tmp2) == 0) {
  260: 						php_info_print("<i>no value</i>");
  261: 					} else {
  262: 						php_info_print_html_esc(Z_STRVAL(tmp2), Z_STRLEN(tmp2));
  263: 					}
  264: 				} else {
  265: 					php_info_print(Z_STRVAL(tmp2));
  266: 				}
  267: 
  268: 				if (!tmp) {
  269: 					zval_dtor(&tmp2);
  270: 				}
  271: 			}
  272: 			if (!sapi_module.phpinfo_as_text) {
  273: 				php_info_print("</td></tr>\n");
  274: 			} else {
  275: 				php_info_print("\n");
  276: 			}
  277: 			zend_hash_move_forward(Z_ARRVAL_PP(data));
  278: 		}
  279: 	}
  280: }
  281: /* }}} */
  282: 
  283: /* {{{ php_info_print_style
  284:  */
  285: void php_info_print_style(TSRMLS_D)
  286: {
  287: 	php_info_printf("<style type=\"text/css\">\n");
  288: 	php_info_print_css(TSRMLS_C);
  289: 	php_info_printf("</style>\n");
  290: }
  291: /* }}} */
  292: 
  293: /* {{{ php_info_html_esc
  294:  */
  295: PHPAPI char *php_info_html_esc(char *string TSRMLS_DC)
  296: {
  297: 	size_t new_len;
  298: 	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: 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: 	if (uname((struct utsname *)&buf) == -1) {
  583: 		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: 		if (mode == 's') {
  610: 			php_uname = buf.sysname;
  611: 		} else if (mode == 'r') {
  612: 			php_uname = buf.release;
  613: 		} else if (mode == 'n') {
  614: 			php_uname = buf.nodename;
  615: 		} else if (mode == 'v') {
  616: 			php_uname = buf.version;
  617: 		} else if (mode == 'm') {
  618: 			php_uname = buf.machine;
  619: 		} else { /* assume mode == 'a' */
  620: 			snprintf(tmp_uname, sizeof(tmp_uname), "%s %s %s %s %s",
  621: 					 buf.sysname, buf.nodename, buf.release, buf.version,
  622: 					 buf.machine);
  623: 			php_uname = tmp_uname;
  624: 		}
  625: #endif /* NETWARE */
  626: 	}
  627: #else
  628: 	php_uname = PHP_UNAME;
  629: #endif
  630: #endif
  631: 	return estrdup(php_uname);
  632: }
  633: /* }}} */
  634: 
  635: /* {{{ php_print_info_htmlhead
  636:  */
  637: PHPAPI void php_print_info_htmlhead(TSRMLS_D)
  638: {
  639: 	php_info_print("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n");
  640: 	php_info_print("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
  641: 	php_info_print("<head>\n");
  642: 	php_info_print_style(TSRMLS_C);
  643: 	php_info_print("<title>phpinfo()</title>");
  644: 	php_info_print("<meta name=\"ROBOTS\" content=\"NOINDEX,NOFOLLOW,NOARCHIVE\" />");
  645: 	php_info_print("</head>\n");
  646: 	php_info_print("<body><div class=\"center\">\n");
  647: }
  648: /* }}} */
  649: 
  650: /* {{{ module_name_cmp */
  651: static int module_name_cmp(const void *a, const void *b TSRMLS_DC)
  652: {
  653: 	Bucket *f = *((Bucket **) a);
  654: 	Bucket *s = *((Bucket **) b);
  655: 
  656: 	return strcasecmp(((zend_module_entry *)f->pData)->name,
  657: 				  ((zend_module_entry *)s->pData)->name);
  658: }
  659: /* }}} */
  660: 
  661: /* {{{ php_print_info
  662:  */
  663: PHPAPI void php_print_info(int flag TSRMLS_DC)
  664: {
  665: 	char **env, *tmp1, *tmp2;
  666: 	char *php_uname;
  667: 	int expose_php = INI_INT("expose_php");
  668: 
  669: 	if (!sapi_module.phpinfo_as_text) {
  670: 		php_print_info_htmlhead(TSRMLS_C);
  671: 	} else {
  672: 		php_info_print("phpinfo()\n");
  673: 	}
  674: 
  675: 	if (flag & PHP_INFO_GENERAL) {
  676: 		char *zend_version = get_zend_version();
  677: 		char temp_api[10];
  678: 		char *logo_guid;
  679: 
  680: 		php_uname = php_get_uname('a');
  681: 		
  682: 		if (!sapi_module.phpinfo_as_text) {
  683: 			php_info_print_box_start(1);
  684: 		}
  685: 
  686: 		if (expose_php && !sapi_module.phpinfo_as_text) {
  687: 			php_info_print("<a href=\"http://www.php.net/\"><img border=\"0\" src=\"");
  688: 			php_info_print_request_uri(TSRMLS_C);
  689: 			php_info_print("?=");
  690: 			logo_guid = php_logo_guid();
  691: 			php_info_print(logo_guid);
  692: 			efree(logo_guid);
  693: 			php_info_print("\" alt=\"PHP Logo\" /></a>");
  694: 		}
  695: 
  696: 		if (!sapi_module.phpinfo_as_text) {
  697: 			php_info_printf("<h1 class=\"p\">PHP Version %s</h1>\n", PHP_VERSION);
  698: 		} else {
  699: 			php_info_print_table_row(2, "PHP Version", PHP_VERSION);
  700: 		}	
  701: 		php_info_print_box_end();
  702: 		php_info_print_table_start();
  703: 		php_info_print_table_row(2, "System", php_uname );
  704: 		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: 		php_info_print_table_row(2, "Configure Command", CONFIGURE_COMMAND );
  713: #endif
  714: 
  715: 		if (sapi_module.pretty_name) {
  716: 			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: 		php_info_print_table_row(2, "Virtual Directory Support", "disabled" );
  723: #endif
  724: 
  725: 		php_info_print_table_row(2, "Configuration File (php.ini) Path", PHP_CONFIG_FILE_PATH);
  726: 		php_info_print_table_row(2, "Loaded Configuration File", php_ini_opened_path ? php_ini_opened_path : "(none)");
  727: 		php_info_print_table_row(2, "Scan this dir for additional .ini files", php_ini_scanned_path ? php_ini_scanned_path : "(none)");
  728: 		php_info_print_table_row(2, "Additional .ini files parsed", php_ini_scanned_files ? php_ini_scanned_files : "(none)");
  729: 
  730: 		snprintf(temp_api, sizeof(temp_api), "%d", PHP_API_VERSION);
  731: 		php_info_print_table_row(2, "PHP API", temp_api);
  732: 
  733: 		snprintf(temp_api, sizeof(temp_api), "%d", ZEND_MODULE_API_NO);
  734: 		php_info_print_table_row(2, "PHP Extension", temp_api);
  735: 
  736: 		snprintf(temp_api, sizeof(temp_api), "%d", ZEND_EXTENSION_API_NO);
  737: 		php_info_print_table_row(2, "Zend Extension", temp_api);
  738: 
  739: 		php_info_print_table_row(2, "Zend Extension Build", ZEND_EXTENSION_BUILD_ID);
  740: 		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: 		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: 		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: 		php_info_print_table_row(2, "Zend Signal Handling", "disabled" );
  758: #endif
  759: 
  760: 		php_info_print_table_row(2, "Zend Memory Manager", is_zend_mm(TSRMLS_C) ? "enabled" : "disabled" );
  761: 
  762: 		{
  763: 			const zend_multibyte_functions *functions = zend_multibyte_get_functions(TSRMLS_C);
  764: 			char *descr;
  765: 			if (functions) {
  766: 				spprintf(&descr, 0, "provided by %s", functions->provider_name);
  767: 			} else {
  768: 				descr = estrdup("disabled");
  769: 			}
  770:             php_info_print_table_row(2, "Zend Multibyte Support", descr);
  771: 			efree(descr);
  772: 		}
  773: 
  774: #if HAVE_IPV6
  775: 		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: 		php_info_print_table_row(2, "DTrace Support", "disabled" );
  784: #endif
  785: 		
  786: 		php_info_print_stream_hash("PHP Streams",  php_stream_get_url_stream_wrappers_hash() TSRMLS_CC);
  787: 		php_info_print_stream_hash("Stream Socket Transports", php_stream_xport_get_hash() TSRMLS_CC);
  788: 		php_info_print_stream_hash("Stream Filters", php_get_stream_filters_hash() TSRMLS_CC);
  789: 
  790: 		php_info_print_table_end();
  791: 
  792: 		/* Zend Engine */
  793: 		php_info_print_box_start(0);
  794: 		if (expose_php && !sapi_module.phpinfo_as_text) {
  795: 			php_info_print("<a href=\"http://www.zend.com/\"><img border=\"0\" src=\"");
  796: 			php_info_print_request_uri(TSRMLS_C);
  797: 			php_info_print("?="ZEND_LOGO_GUID"\" alt=\"Zend logo\" /></a>\n");
  798: 		}
  799: 		php_info_print("This program makes use of the Zend Scripting Language Engine:");
  800: 		php_info_print(!sapi_module.phpinfo_as_text?"<br />":"\n");
  801: 		if (sapi_module.phpinfo_as_text) {
  802: 			php_info_print(zend_version);
  803: 		} else {
  804: 			zend_html_puts(zend_version, strlen(zend_version) TSRMLS_CC);
  805: 		}
  806: 		php_info_print_box_end();
  807: 		efree(php_uname);
  808: 	}
  809: 
  810: 	if ((flag & PHP_INFO_CREDITS) && expose_php && !sapi_module.phpinfo_as_text) {	
  811: 		php_info_print_hr();
  812: 		php_info_print("<h1><a href=\"");
  813: 		php_info_print_request_uri(TSRMLS_C);
  814: 		php_info_print("?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000\">");
  815: 		php_info_print("PHP Credits");
  816: 		php_info_print("</a></h1>\n");
  817: 	}
  818: 
  819: 	zend_ini_sort_entries(TSRMLS_C);
  820: 
  821: 	if (flag & PHP_INFO_CONFIGURATION) {
  822: 		php_info_print_hr();
  823: 		if (!sapi_module.phpinfo_as_text) {
  824: 			php_info_print("<h1>Configuration</h1>\n");
  825: 		} else {
  826: 			SECTION("Configuration");
  827: 		}	
  828: 		if (!(flag & PHP_INFO_MODULES)) {
  829: 			SECTION("PHP Core");
  830: 			display_ini_entries(NULL);
  831: 		}
  832: 	}
  833: 
  834: 	if (flag & PHP_INFO_MODULES) {
  835: 		HashTable sorted_registry;
  836: 		zend_module_entry tmp;
  837: 
  838: 		zend_hash_init(&sorted_registry, zend_hash_num_elements(&module_registry), NULL, NULL, 1);
  839: 		zend_hash_copy(&sorted_registry, &module_registry, NULL, &tmp, sizeof(zend_module_entry));
  840: 		zend_hash_sort(&sorted_registry, zend_qsort, module_name_cmp, 0 TSRMLS_CC);
  841: 
  842: 		zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_func TSRMLS_CC);
  843: 
  844: 		SECTION("Additional Modules");
  845: 		php_info_print_table_start();
  846: 		php_info_print_table_header(1, "Module Name");
  847: 		zend_hash_apply(&sorted_registry, (apply_func_t) _display_module_info_def TSRMLS_CC);
  848: 		php_info_print_table_end();
  849: 
  850: 		zend_hash_destroy(&sorted_registry);
  851: 	}
  852: 
  853: 	if (flag & PHP_INFO_ENVIRONMENT) {
  854: 		SECTION("Environment");
  855: 		php_info_print_table_start();
  856: 		php_info_print_table_header(2, "Variable", "Value");
  857: 		for (env=environ; env!=NULL && *env !=NULL; env++) {
  858: 			tmp1 = estrdup(*env);
  859: 			if (!(tmp2=strchr(tmp1,'='))) { /* malformed entry? */
  860: 				efree(tmp1);
  861: 				continue;
  862: 			}
  863: 			*tmp2 = 0;
  864: 			tmp2++;
  865: 			php_info_print_table_row(2, tmp1, tmp2);
  866: 			efree(tmp1);
  867: 		}
  868: 		php_info_print_table_end();
  869: 	}
  870: 
  871: 	if (flag & PHP_INFO_VARIABLES) {
  872: 		zval **data;
  873: 
  874: 		SECTION("PHP Variables");
  875: 
  876: 		php_info_print_table_start();
  877: 		php_info_print_table_header(2, "Variable", "Value");
  878: 		if (zend_hash_find(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void **) &data) != FAILURE) {
  879: 			php_info_print_table_row(2, "PHP_SELF", Z_STRVAL_PP(data));
  880: 		}
  881: 		if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_TYPE", sizeof("PHP_AUTH_TYPE"), (void **) &data) != FAILURE) {
  882: 			php_info_print_table_row(2, "PHP_AUTH_TYPE", Z_STRVAL_PP(data));
  883: 		}
  884: 		if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_USER", sizeof("PHP_AUTH_USER"), (void **) &data) != FAILURE) {
  885: 			php_info_print_table_row(2, "PHP_AUTH_USER", Z_STRVAL_PP(data));
  886: 		}
  887: 		if (zend_hash_find(&EG(symbol_table), "PHP_AUTH_PW", sizeof("PHP_AUTH_PW"), (void **) &data) != FAILURE) {
  888: 			php_info_print_table_row(2, "PHP_AUTH_PW", Z_STRVAL_PP(data));
  889: 		}
  890: 		php_print_gpcse_array(ZEND_STRL("_REQUEST") TSRMLS_CC);
  891: 		php_print_gpcse_array(ZEND_STRL("_GET") TSRMLS_CC);
  892: 		php_print_gpcse_array(ZEND_STRL("_POST") TSRMLS_CC);
  893: 		php_print_gpcse_array(ZEND_STRL("_FILES") TSRMLS_CC);
  894: 		php_print_gpcse_array(ZEND_STRL("_COOKIE") TSRMLS_CC);
  895: 		php_print_gpcse_array(ZEND_STRL("_SERVER") TSRMLS_CC);
  896: 		php_print_gpcse_array(ZEND_STRL("_ENV") TSRMLS_CC);
  897: 		php_info_print_table_end();
  898: 	}
  899: 
  900: 	if (flag & PHP_INFO_LICENSE) {
  901: 		if (!sapi_module.phpinfo_as_text) {
  902: 			SECTION("PHP License");
  903: 			php_info_print_box_start(0);
  904: 			php_info_print("<p>\n");
  905: 			php_info_print("This program is free software; you can redistribute it and/or modify ");
  906: 			php_info_print("it under the terms of the PHP License as published by the PHP Group ");
  907: 			php_info_print("and included in the distribution in the file:  LICENSE\n");
  908: 			php_info_print("</p>\n");
  909: 			php_info_print("<p>");
  910: 			php_info_print("This program is distributed in the hope that it will be useful, ");
  911: 			php_info_print("but WITHOUT ANY WARRANTY; without even the implied warranty of ");
  912: 			php_info_print("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
  913: 			php_info_print("</p>\n");
  914: 			php_info_print("<p>");
  915: 			php_info_print("If you did not receive a copy of the PHP license, or have any questions about ");
  916: 			php_info_print("PHP licensing, please contact license@php.net.\n");
  917: 			php_info_print("</p>\n");
  918: 			php_info_print_box_end();
  919: 		} else {
  920: 			php_info_print("\nPHP License\n");
  921: 			php_info_print("This program is free software; you can redistribute it and/or modify\n");
  922: 			php_info_print("it under the terms of the PHP License as published by the PHP Group\n");
  923: 			php_info_print("and included in the distribution in the file:  LICENSE\n");
  924: 			php_info_print("\n");
  925: 			php_info_print("This program is distributed in the hope that it will be useful,\n");
  926: 			php_info_print("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
  927: 			php_info_print("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
  928: 			php_info_print("\n");
  929: 			php_info_print("If you did not receive a copy of the PHP license, or have any\n");
  930: 			php_info_print("questions about PHP licensing, please contact license@php.net.\n");
  931: 		}
  932: 	}
  933: 	if (!sapi_module.phpinfo_as_text) {
  934: 		php_info_print("</div></body></html>");
  935: 	}	
  936: }
  937: /* }}} */
  938: 
  939: PHPAPI void php_info_print_table_start(void) /* {{{ */
  940: {
  941: 	if (!sapi_module.phpinfo_as_text) {
  942: 		php_info_print("<table border=\"0\" cellpadding=\"3\" width=\"600\">\n");
  943: 	} else {
  944: 		php_info_print("\n");
  945: 	}	
  946: }
  947: /* }}} */
  948: 
  949: PHPAPI void php_info_print_table_end(void) /* {{{ */
  950: {
  951: 	if (!sapi_module.phpinfo_as_text) {
  952: 		php_info_print("</table><br />\n");
  953: 	}
  954: 
  955: }
  956: /* }}} */
  957: 
  958: PHPAPI void php_info_print_box_start(int flag) /* {{{ */
  959: {
  960: 	php_info_print_table_start();
  961: 	if (flag) {
  962: 		if (!sapi_module.phpinfo_as_text) {
  963: 			php_info_print("<tr class=\"h\"><td>\n");
  964: 		}
  965: 	} else {
  966: 		if (!sapi_module.phpinfo_as_text) {
  967: 			php_info_print("<tr class=\"v\"><td>\n");
  968: 		} else {
  969: 			php_info_print("\n");
  970: 		}	
  971: 	}
  972: }
  973: /* }}} */
  974: 
  975: PHPAPI void php_info_print_box_end(void) /* {{{ */
  976: {
  977: 	if (!sapi_module.phpinfo_as_text) {
  978: 		php_info_print("</td></tr>\n");
  979: 	}
  980: 	php_info_print_table_end();
  981: }
  982: /* }}} */
  983: 
  984: PHPAPI void php_info_print_hr(void) /* {{{ */
  985: {
  986: 	if (!sapi_module.phpinfo_as_text) {
  987: 		php_info_print("<hr />\n");
  988: 	} else {
  989: 		php_info_print("\n\n _______________________________________________________________________\n\n");
  990: 	}
  991: }
  992: /* }}} */
  993: 
  994: PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header) /* {{{ */
  995: {
  996: 	int spaces;
  997: 
  998: 	if (!sapi_module.phpinfo_as_text) {
  999: 		php_info_printf("<tr class=\"h\"><th colspan=\"%d\">%s</th></tr>\n", num_cols, header );
 1000: 	} else {
 1001: 		spaces = (74 - strlen(header));
 1002: 		php_info_printf("%*s%s%*s\n", (int)(spaces/2), " ", header, (int)(spaces/2), " ");
 1003: 	}	
 1004: }
 1005: /* }}} */
 1006: 
 1007: /* {{{ php_info_print_table_header
 1008:  */
 1009: 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: 	va_start(row_elements, num_cols);
 1016: 	if (!sapi_module.phpinfo_as_text) {
 1017: 		php_info_print("<tr class=\"h\">");
 1018: 	}	
 1019: 	for (i=0; i<num_cols; i++) {
 1020: 		row_element = va_arg(row_elements, char *);
 1021: 		if (!row_element || !*row_element) {
 1022: 			row_element = " ";
 1023: 		}
 1024: 		if (!sapi_module.phpinfo_as_text) {
 1025: 			php_info_print("<th>");
 1026: 			php_info_print(row_element);
 1027: 			php_info_print("</th>");
 1028: 		} else {
 1029: 			php_info_print(row_element);
 1030: 			if (i < num_cols-1) {
 1031: 				php_info_print(" => ");
 1032: 			} else {
 1033: 				php_info_print("\n");
 1034: 			}
 1035: 		}
 1036: 	}
 1037: 	if (!sapi_module.phpinfo_as_text) {
 1038: 		php_info_print("</tr>\n");
 1039: 	}
 1040: 
 1041: 	va_end(row_elements);
 1042: }
 1043: /* }}} */
 1044: 
 1045: /* {{{ php_info_print_table_row_internal
 1046:  */
 1047: 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: 	if (!sapi_module.phpinfo_as_text) {
 1054: 		php_info_print("<tr>");
 1055: 	}	
 1056: 	for (i=0; i<num_cols; i++) {
 1057: 		if (!sapi_module.phpinfo_as_text) {
 1058: 			php_info_printf("<td class=\"%s\">",
 1059: 			   (i==0 ? "e" : value_class )
 1060: 			);
 1061: 		}	
 1062: 		row_element = va_arg(row_elements, char *);
 1063: 		if (!row_element || !*row_element) {
 1064: 			if (!sapi_module.phpinfo_as_text) {
 1065: 				php_info_print( "<i>no value</i>" );
 1066: 			} else {
 1067: 				php_info_print( " " );
 1068: 			}
 1069: 		} else {
 1070: 			if (!sapi_module.phpinfo_as_text) {
 1071: 				php_info_print_html_esc(row_element, strlen(row_element));
 1072: 			} else {
 1073: 				php_info_print(row_element);
 1074: 				if (i < num_cols-1) {
 1075: 					php_info_print(" => ");
 1076: 				}	
 1077: 			}
 1078: 		}
 1079: 		if (!sapi_module.phpinfo_as_text) {
 1080: 			php_info_print(" </td>");
 1081: 		} else if (i == (num_cols - 1)) {
 1082: 			php_info_print("\n");
 1083: 		}
 1084: 	}
 1085: 	if (!sapi_module.phpinfo_as_text) {
 1086: 		php_info_print("</tr>\n");
 1087: 	}
 1088: }
 1089: /* }}} */
 1090: 
 1091: /* {{{ php_info_print_table_row
 1092:  */
 1093: PHPAPI void php_info_print_table_row(int num_cols, ...)
 1094: {
 1095: 	va_list row_elements;
 1096: 	
 1097: 	va_start(row_elements, num_cols);
 1098: 	php_info_print_table_row_internal(num_cols, "v", row_elements);
 1099: 	va_end(row_elements);
 1100: }
 1101: /* }}} */
 1102: 
 1103: /* {{{ php_info_print_table_row_ex
 1104:  */
 1105: PHPAPI void php_info_print_table_row_ex(int num_cols, const char *value_class, 
 1106: 		...)
 1107: {
 1108: 	va_list row_elements;
 1109: 	
 1110: 	va_start(row_elements, value_class);
 1111: 	php_info_print_table_row_internal(num_cols, value_class, row_elements);
 1112: 	va_end(row_elements);
 1113: }
 1114: /* }}} */
 1115: 
 1116: /* {{{ register_phpinfo_constants
 1117:  */
 1118: void register_phpinfo_constants(INIT_FUNC_ARGS)
 1119: {
 1120: 	REGISTER_LONG_CONSTANT("INFO_GENERAL", PHP_INFO_GENERAL, CONST_PERSISTENT|CONST_CS);
 1121: 	REGISTER_LONG_CONSTANT("INFO_CREDITS", PHP_INFO_CREDITS, CONST_PERSISTENT|CONST_CS);
 1122: 	REGISTER_LONG_CONSTANT("INFO_CONFIGURATION", PHP_INFO_CONFIGURATION, CONST_PERSISTENT|CONST_CS);
 1123: 	REGISTER_LONG_CONSTANT("INFO_MODULES", PHP_INFO_MODULES, CONST_PERSISTENT|CONST_CS);
 1124: 	REGISTER_LONG_CONSTANT("INFO_ENVIRONMENT", PHP_INFO_ENVIRONMENT, CONST_PERSISTENT|CONST_CS);
 1125: 	REGISTER_LONG_CONSTANT("INFO_VARIABLES", PHP_INFO_VARIABLES, CONST_PERSISTENT|CONST_CS);
 1126: 	REGISTER_LONG_CONSTANT("INFO_LICENSE", PHP_INFO_LICENSE, CONST_PERSISTENT|CONST_CS);
 1127: 	REGISTER_LONG_CONSTANT("INFO_ALL", PHP_INFO_ALL, CONST_PERSISTENT|CONST_CS);
 1128: 	REGISTER_LONG_CONSTANT("CREDITS_GROUP",	PHP_CREDITS_GROUP, CONST_PERSISTENT|CONST_CS);
 1129: 	REGISTER_LONG_CONSTANT("CREDITS_GENERAL",	PHP_CREDITS_GENERAL, CONST_PERSISTENT|CONST_CS);
 1130: 	REGISTER_LONG_CONSTANT("CREDITS_SAPI",	PHP_CREDITS_SAPI, CONST_PERSISTENT|CONST_CS);
 1131: 	REGISTER_LONG_CONSTANT("CREDITS_MODULES",	PHP_CREDITS_MODULES, CONST_PERSISTENT|CONST_CS);
 1132: 	REGISTER_LONG_CONSTANT("CREDITS_DOCS",	PHP_CREDITS_DOCS, CONST_PERSISTENT|CONST_CS);
 1133: 	REGISTER_LONG_CONSTANT("CREDITS_FULLPAGE",	PHP_CREDITS_FULLPAGE, CONST_PERSISTENT|CONST_CS);
 1134: 	REGISTER_LONG_CONSTANT("CREDITS_QA",	PHP_CREDITS_QA, CONST_PERSISTENT|CONST_CS);
 1135: 	REGISTER_LONG_CONSTANT("CREDITS_ALL",	PHP_CREDITS_ALL, CONST_PERSISTENT|CONST_CS);
 1136: }
 1137: /* }}} */
 1138: 
 1139: /* {{{ proto void phpinfo([int what])
 1140:    Output a page of useful information about PHP and the current request */
 1141: PHP_FUNCTION(phpinfo)
 1142: {
 1143: 	long flag = PHP_INFO_ALL;
 1144: 
 1145: 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) {
 1146: 		return;
 1147: 	}
 1148: 
 1149: 	/* Andale!  Andale!  Yee-Hah! */
 1150: 	php_output_start_default(TSRMLS_C);
 1151: 	php_print_info(flag TSRMLS_CC);
 1152: 	php_output_end(TSRMLS_C);
 1153: 
 1154: 	RETURN_TRUE;
 1155: }
 1156: 
 1157: /* }}} */
 1158: 
 1159: /* {{{ proto string phpversion([string extension])
 1160:    Return the current PHP version */
 1161: PHP_FUNCTION(phpversion)
 1162: {
 1163: 	char *ext_name = NULL;
 1164: 	int ext_name_len = 0;
 1165: 
 1166: 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &ext_name, &ext_name_len) == FAILURE) {
 1167: 		return;
 1168: 	}
 1169: 
 1170: 	if (!ext_name) {
 1171: 		RETURN_STRING(PHP_VERSION, 1);
 1172: 	} else {
 1173: 		const char *version;
 1174: 		version = zend_get_module_version(ext_name);
 1175: 		if (version == NULL) {
 1176: 			RETURN_FALSE;
 1177: 		}
 1178: 		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: PHP_FUNCTION(phpcredits)
 1186: {
 1187: 	long flag = PHP_CREDITS_ALL;
 1188: 
 1189: 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) {
 1190: 		return;
 1191: 	}
 1192: 
 1193: 	php_print_credits(flag TSRMLS_CC);
 1194: 	RETURN_TRUE;
 1195: }
 1196: /* }}} */
 1197: 
 1198: /* {{{ php_logo_guid
 1199:  */
 1200: PHPAPI char *php_logo_guid(void)
 1201: {
 1202: 	char *logo_guid;
 1203: 
 1204: 	time_t the_time;
 1205: 	struct tm *ta, tmbuf;
 1206: 
 1207: 	the_time = time(NULL);
 1208: 	ta = php_localtime_r(&the_time, &tmbuf);
 1209: 
 1210: 	if (ta && (ta->tm_mon==3) && (ta->tm_mday==1)) {
 1211: 		logo_guid = PHP_EGG_LOGO_GUID;
 1212: 	} else {
 1213: 		logo_guid = PHP_LOGO_GUID;
 1214: 	}
 1215: 
 1216: 	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: PHP_FUNCTION(php_logo_guid)
 1224: {
 1225: 	if (zend_parse_parameters_none() == FAILURE) {
 1226: 		return;
 1227: 	}
 1228: 
 1229: 	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: PHP_FUNCTION(php_real_logo_guid)
 1236: {
 1237: 	if (zend_parse_parameters_none() == FAILURE) {
 1238: 		return;
 1239: 	}
 1240: 
 1241: 	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: PHP_FUNCTION(php_egg_logo_guid)
 1248: {
 1249: 	if (zend_parse_parameters_none() == FAILURE) {
 1250: 		return;
 1251: 	}
 1252: 
 1253: 	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: PHP_FUNCTION(zend_logo_guid)
 1260: {
 1261: 	if (zend_parse_parameters_none() == FAILURE) {
 1262: 		return;
 1263: 	}
 1264: 
 1265: 	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: PHP_FUNCTION(php_sapi_name)
 1272: {
 1273: 	if (zend_parse_parameters_none() == FAILURE) {
 1274: 		return;
 1275: 	}
 1276: 
 1277: 	if (sapi_module.name) {
 1278: 		RETURN_STRING(sapi_module.name, 1);
 1279: 	} else {
 1280: 		RETURN_FALSE;
 1281: 	}
 1282: }
 1283: 
 1284: /* }}} */
 1285: 
 1286: /* {{{ proto string php_uname(void)
 1287:    Return information about the system PHP was built on */
 1288: PHP_FUNCTION(php_uname)
 1289: {
 1290: 	char *mode = "a";
 1291: 	int modelen = sizeof("a")-1;
 1292: 
 1293: 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &mode, &modelen) == FAILURE) {
 1294: 		return;
 1295: 	}
 1296: 	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: PHP_FUNCTION(php_ini_scanned_files)
 1304: {
 1305: 	if (zend_parse_parameters_none() == FAILURE) {
 1306: 		return;
 1307: 	}
 1308: 	
 1309: 	if (strlen(PHP_CONFIG_FILE_SCAN_DIR) && php_ini_scanned_files) {
 1310: 		RETURN_STRING(php_ini_scanned_files, 1);
 1311: 	} else {
 1312: 		RETURN_FALSE;
 1313: 	}
 1314: }
 1315: /* }}} */
 1316: 
 1317: /* {{{ proto string php_ini_loaded_file(void)
 1318:    Return the actual loaded ini filename */
 1319: PHP_FUNCTION(php_ini_loaded_file)
 1320: {
 1321: 	if (zend_parse_parameters_none() == FAILURE) {
 1322: 		return;
 1323: 	}
 1324: 	
 1325: 	if (php_ini_opened_path) {
 1326: 		RETURN_STRING(php_ini_opened_path, 1);
 1327: 	} else {
 1328: 		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:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>