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