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