1 | <?php |
---|
2 | // +----------------------------------------------------------------------+ |
---|
3 | // | PHP Version 4 | |
---|
4 | // +----------------------------------------------------------------------+ |
---|
5 | // | Copyright (c) 1997-2004 The PHP Group | |
---|
6 | // +----------------------------------------------------------------------+ |
---|
7 | // | This source file is subject to version 3.0 of the PHP license, | |
---|
8 | // | that is bundled with this package in the file LICENSE, and is | |
---|
9 | // | available at through the world-wide-web at | |
---|
10 | // | http://www.php.net/license/3_0.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: Aidan Lister <aidan@php.net> | |
---|
16 | // +----------------------------------------------------------------------+ |
---|
17 | // |
---|
18 | // $Id$ |
---|
19 | |
---|
20 | |
---|
21 | /** |
---|
22 | * Replace ini_get_all() |
---|
23 | * |
---|
24 | * @category PHP |
---|
25 | * @package PHP_Compat |
---|
26 | * @link http://php.net/function.ini_get_all |
---|
27 | * @author Aidan Lister <aidan@php.net> |
---|
28 | * @version $Revision: 1.3 $ |
---|
29 | * @since PHP 4.2.0 |
---|
30 | * @require PHP 4.0.0 (user_error) |
---|
31 | */ |
---|
32 | if (!function_exists('ini_get_all')) { |
---|
33 | function ini_get_all($extension = null) |
---|
34 | { |
---|
35 | // Sanity check |
---|
36 | if (!is_scalar($extension)) { |
---|
37 | user_error('ini_get_all() expects parameter 1 to be string, ' . |
---|
38 | gettype($extension) . ' given', E_USER_WARNING); |
---|
39 | return false; |
---|
40 | } |
---|
41 | |
---|
42 | // Get the location of php.ini |
---|
43 | ob_start(); |
---|
44 | phpinfo(INFO_GENERAL); |
---|
45 | $info = ob_get_contents(); |
---|
46 | ob_clean(); |
---|
47 | $info = explode("\n", $info); |
---|
48 | $line = array_values(preg_grep('#php.ini#', $info)); |
---|
49 | list (, $value) = explode('<td class="v">', $line[0]); |
---|
50 | $inifile = trim(strip_tags($value)); |
---|
51 | |
---|
52 | // Parse |
---|
53 | if ($extension !== null) { |
---|
54 | $ini_all = parse_ini_file($inifile, true); |
---|
55 | |
---|
56 | // Lowercase extension keys |
---|
57 | foreach ($ini_all as $key => $value) { |
---|
58 | $ini_arr[strtolower($key)] = $value; |
---|
59 | } |
---|
60 | |
---|
61 | $ini = $ini_arr[$extension]; |
---|
62 | } else { |
---|
63 | $ini = parse_ini_file($inifile); |
---|
64 | } |
---|
65 | |
---|
66 | // Order |
---|
67 | $ini_lc = array_map('strtolower', array_keys($ini)); |
---|
68 | array_multisort($ini_lc, SORT_ASC, SORT_STRING, $ini); |
---|
69 | |
---|
70 | // Format |
---|
71 | $info = array(); |
---|
72 | foreach ($ini as $key => $value) { |
---|
73 | $info[$key] = array( |
---|
74 | 'global_value' => $value, |
---|
75 | 'local_value' => ini_get($key), |
---|
76 | // No way to know this |
---|
77 | 'access' => -1 |
---|
78 | ); |
---|
79 | } |
---|
80 | |
---|
81 | return $info; |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | ?> |
---|