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