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