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