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