Subversion Repositories ALCASAR

Rev

Rev 2770 | Rev 3037 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2770 Rev 2976
1
<?php
1
<?php
2
if (!defined('PSI_CONFIG_FILE')) {
2
if (!defined('PSI_CONFIG_FILE')) {
3
    /**
3
    /**
4
     * phpSysInfo version
4
     * phpSysInfo version
5
     */
5
     */
6
    define('PSI_VERSION', '3.3.2');
6
    define('PSI_VERSION', '3.3.4');
7
    /**
7
    /**
8
     * phpSysInfo configuration
8
     * phpSysInfo configuration
9
     */
9
     */
10
    define('PSI_CONFIG_FILE', PSI_APP_ROOT.'/phpsysinfo.ini');
10
    define('PSI_CONFIG_FILE', PSI_APP_ROOT.'/phpsysinfo.ini');
11
 
11
 
12
    define('ARRAY_EXP', '/^return array \([^;]*\);$/'); //array expression search
12
    define('ARRAY_EXP', '/^return array \([^;]*\);$/'); //array expression search
13
 
13
 
14
    if (!is_readable(PSI_CONFIG_FILE)) {
14
    if (!is_readable(PSI_CONFIG_FILE)) {
15
        echo "ERROR: phpsysinfo.ini does not exist or is not readable by the webserver in the phpsysinfo directory";
15
        echo "ERROR: phpsysinfo.ini does not exist or is not readable by the webserver in the phpsysinfo directory";
16
        die();
16
        die();
17
    } elseif (!($config = @parse_ini_file(PSI_CONFIG_FILE, true))) {
17
    } elseif (!($config = @parse_ini_file(PSI_CONFIG_FILE, true))) {
18
        echo "ERROR: phpsysinfo.ini file is not parsable";
18
        echo "ERROR: phpsysinfo.ini file is not parsable";
19
        die();
19
        die();
20
    } else {
20
    } else {
21
        foreach ($config as $name=>$group) {
21
        foreach ($config as $name=>$group) {
22
            if (strtoupper($name)=="MAIN") {
22
            if (strtoupper($name)=="MAIN") {
23
                $name_prefix='PSI_';
23
                $name_prefix='PSI_';
24
            } elseif (strtoupper(substr($name, 0, 7))=="SENSOR_") {
24
            } elseif (strtoupper(substr($name, 0, 7))=="SENSOR_") {
25
                $name_prefix='PSI_'.strtoupper($name).'_';
25
                $name_prefix='PSI_'.strtoupper($name).'_';
26
            } else {
26
            } else {
27
                $name_prefix='PSI_PLUGIN_'.strtoupper($name).'_';
27
                $name_prefix='PSI_PLUGIN_'.strtoupper($name).'_';
28
            }
28
            }
29
            foreach ($group as $param=>$value) {
29
            foreach ($group as $param=>$value) {
30
                if ((trim($value)==="") || (trim($value)==="0")) {
30
                if ((trim($value)==="") || (trim($value)==="0")) {
31
                    define($name_prefix.strtoupper($param), false);
31
                    define($name_prefix.strtoupper($param), false);
32
                } elseif (trim($value)==="1") {
32
                } elseif (trim($value)==="1") {
33
                    define($name_prefix.strtoupper($param), true);
33
                    define($name_prefix.strtoupper($param), true);
34
                } else {
34
                } else {
35
                    if (strstr($value, ',')) {
35
                    if (strstr($value, ',')) {
36
                        define($name_prefix.strtoupper($param), 'return '.var_export(preg_split('/\s*,\s*/', trim($value), -1, PREG_SPLIT_NO_EMPTY), 1).';');
36
                        define($name_prefix.strtoupper($param), 'return '.var_export(preg_split('/\s*,\s*/', trim($value), -1, PREG_SPLIT_NO_EMPTY), 1).';');
37
                    } else {
37
                    } else {
38
                        define($name_prefix.strtoupper($param), trim($value));
38
                        define($name_prefix.strtoupper($param), trim($value));
39
                    }
39
                    }
40
                }
40
                }
41
            }
41
            }
42
        }
42
        }
43
    }
43
    }
44
 
44
 
45
    if (defined('PSI_ALLOWED') && is_string(PSI_ALLOWED)) {
45
    if (defined('PSI_ALLOWED') && is_string(PSI_ALLOWED)) {
46
        if (preg_match(ARRAY_EXP, PSI_ALLOWED)) {
46
        if (preg_match(ARRAY_EXP, PSI_ALLOWED)) {
47
            $allowed = eval(strtolower(PSI_ALLOWED));
47
            $allowed = eval(strtolower(PSI_ALLOWED));
48
        } else {
48
        } else {
49
            $allowed = array(strtolower(PSI_ALLOWED));
49
            $allowed = array(strtolower(PSI_ALLOWED));
50
        }
50
        }
51
 
51
 
52
        if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
52
        if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
53
            $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
53
            $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
54
        } else {
54
        } else {
55
            if (isset($_SERVER["HTTP_CLIENT_IP"])) {
55
            if (isset($_SERVER["HTTP_CLIENT_IP"])) {
56
                $ip = $_SERVER["HTTP_CLIENT_IP"];
56
                $ip = $_SERVER["HTTP_CLIENT_IP"];
57
            } else {
57
            } else {
58
                $ip = $_SERVER["REMOTE_ADDR"];
58
                $ip = $_SERVER["REMOTE_ADDR"];
59
            }
59
            }
60
        }
60
        }
61
        $ip = preg_replace("/^::ffff:/", "", strtolower($ip));
61
        $ip = preg_replace("/^::ffff:/", "", strtolower($ip));
62
 
62
 
63
        if (!in_array($ip, $allowed, true)) {
63
        if (!in_array($ip, $allowed, true)) {
64
            echo "Client IP address not allowed";
64
            echo "Client IP address not allowed";
65
            die();
65
            die();
66
        }
66
        }
67
    }
67
    }
68
 
68
 
69
    /* default error handler */
69
    /* default error handler */
70
    if (function_exists('errorHandlerPsi')) {
70
    if (function_exists('errorHandlerPsi')) {
71
        restore_error_handler();
71
        restore_error_handler();
72
    }
72
    }
73
 
73
 
74
    /* fatal errors only */
74
    /* fatal errors only */
75
    $old_err_rep = error_reporting();
75
    $old_err_rep = error_reporting();
76
    error_reporting(E_ERROR);
76
    error_reporting(E_ERROR);
77
 
77
 
78
    /* get git revision */
78
    /* get git revision */
79
    if (file_exists(PSI_APP_ROOT.'/.git/HEAD')) {
79
    if (file_exists(PSI_APP_ROOT.'/.git/HEAD')) {
80
        $contents = @file_get_contents(PSI_APP_ROOT.'/.git/HEAD');
80
        $contents = @file_get_contents(PSI_APP_ROOT.'/.git/HEAD');
81
        if ($contents && preg_match("/^ref:\s+(.*)\/([^\/\s]*)/m", $contents, $matches)) {
81
        if ($contents && preg_match("/^ref:\s+(.*)\/([^\/\s]*)/m", $contents, $matches)) {
82
            $contents = @file_get_contents(PSI_APP_ROOT.'/.git/'.$matches[1]."/".$matches[2]);
82
            $contents = @file_get_contents(PSI_APP_ROOT.'/.git/'.$matches[1]."/".$matches[2]);
83
            if ($contents && preg_match("/^([^\s]*)/m", $contents, $revision)) {
83
            if ($contents && preg_match("/^([^\s]*)/m", $contents, $revision)) {
84
                define('PSI_VERSION_STRING', PSI_VERSION ."-".$matches[2]."-".substr($revision[1], 0, 7));
84
                define('PSI_VERSION_STRING', PSI_VERSION ."-".$matches[2]."-".substr($revision[1], 0, 7));
85
            } else {
85
            } else {
86
                define('PSI_VERSION_STRING', PSI_VERSION ."-".$matches[2]);
86
                define('PSI_VERSION_STRING', PSI_VERSION ."-".$matches[2]);
87
            }
87
            }
88
        }
88
        }
89
    }
89
    }
90
    /* get svn revision */
90
    /* get svn revision */
91
    if (!defined('PSI_VERSION_STRING') && file_exists(PSI_APP_ROOT.'/.svn/entries')) {
91
    if (!defined('PSI_VERSION_STRING') && file_exists(PSI_APP_ROOT.'/.svn/entries')) {
92
        $contents = @file_get_contents(PSI_APP_ROOT.'/.svn/entries');
92
        $contents = @file_get_contents(PSI_APP_ROOT.'/.svn/entries');
93
        if ($contents && preg_match("/dir\n(.+)/", $contents, $matches)) {
93
        if ($contents && preg_match("/dir\n(.+)/", $contents, $matches)) {
94
            define('PSI_VERSION_STRING', PSI_VERSION."-r".$matches[1]);
94
            define('PSI_VERSION_STRING', PSI_VERSION."-r".$matches[1]);
95
        } else {
95
        } else {
96
            define('PSI_VERSION_STRING', PSI_VERSION);
96
            define('PSI_VERSION_STRING', PSI_VERSION);
97
        }
97
        }
98
    }
98
    }
99
    if (!defined('PSI_VERSION_STRING')) {
99
    if (!defined('PSI_VERSION_STRING')) {
100
        define('PSI_VERSION_STRING', PSI_VERSION);
100
        define('PSI_VERSION_STRING', PSI_VERSION);
101
    }
101
    }
102
 
102
 
103
    if (!defined('PSI_OS')) { //if not overloaded in phpsysinfo.ini
103
    if (!defined('PSI_OS')) { //if not overloaded in phpsysinfo.ini
104
        /* get Linux code page */
104
        /* get Linux code page */
105
        if (PHP_OS == 'Linux') {
105
        if (PHP_OS == 'Linux') {
106
            if (file_exists($fname = '/etc/sysconfig/i18n')
106
            if (file_exists($fname = '/etc/sysconfig/i18n')
107
               || file_exists($fname = '/etc/default/locale')
107
               || file_exists($fname = '/etc/default/locale')
108
               || file_exists($fname = '/etc/locale.conf')
108
               || file_exists($fname = '/etc/locale.conf')
109
               || file_exists($fname = '/etc/sysconfig/language')
109
               || file_exists($fname = '/etc/sysconfig/language')
110
               || file_exists($fname = '/etc/profile.d/lang.sh')
110
               || file_exists($fname = '/etc/profile.d/lang.sh')
-
 
111
               || file_exists($fname = '/etc/profile.d/i18n.sh')
111
               || file_exists($fname = '/etc/profile')) {
112
               || file_exists($fname = '/etc/profile')) {
112
                $contents = @file_get_contents($fname);
113
                $contents = @file_get_contents($fname);
113
            } else {
114
            } else {
114
                $contents = false;
115
                $contents = false;
115
                if (file_exists('/system/build.prop')) { //Android
116
                if (file_exists('/system/build.prop')) { //Android
116
                    define('PSI_OS', 'Android');
117
                    define('PSI_OS', 'Android');
117
                    if (@exec('uname -o 2>/dev/null', $unameo) && (sizeof($unameo)>0) && (($unameo0 = trim($unameo[0])) != "")) {
118
                    if (function_exists('exec') && @exec('uname -o 2>/dev/null', $unameo) && (sizeof($unameo)>0) && (($unameo0 = trim($unameo[0])) != "")) {
118
                        define('PSI_UNAMEO', $unameo0);
119
                        define('PSI_UNAMEO', $unameo0); // is Android on Termux
119
                    }
120
                    }
120
                    if (!defined('PSI_MODE_POPEN')) { //if not overloaded in phpsysinfo.ini
121
                    if (!defined('PSI_MODE_POPEN')) { //if not overloaded in phpsysinfo.ini
121
                        if (!function_exists("proc_open")) { //proc_open function test by executing 'pwd' command
122
                        if (!function_exists("proc_open")) { //proc_open function test by executing 'pwd' command
122
                            define('PSI_MODE_POPEN', true); //use popen() function - no stderr error handling (but with problems with timeout)
123
                            define('PSI_MODE_POPEN', true); //use popen() function - no stderr error handling (but with problems with timeout)
123
                        } else {
124
                        } else {
124
                            $out = '';
125
                            $out = '';
125
                            $err = '';
126
                            $err = '';
126
                            $pipes = array();
127
                            $pipes = array();
127
                            $descriptorspec = array(0=>array("pipe", "r"), 1=>array("pipe", "w"), 2=>array("pipe", "w"));
128
                            $descriptorspec = array(0=>array("pipe", "r"), 1=>array("pipe", "w"), 2=>array("pipe", "w"));
128
                            $process = proc_open("pwd 2>/dev/null ", $descriptorspec, $pipes);
129
                            $process = proc_open("pwd 2>/dev/null ", $descriptorspec, $pipes);
129
                            if (!is_resource($process)) {
130
                            if (!is_resource($process)) {
130
                                define('PSI_MODE_POPEN', true);
131
                                define('PSI_MODE_POPEN', true);
131
                            } else {
132
                            } else {
132
                                $w = null;
133
                                $w = null;
133
                                $e = null;
134
                                $e = null;
134
 
135
 
135
                                while (!(feof($pipes[1]) && feof($pipes[2]))) {
136
                                while (!(feof($pipes[1]) && feof($pipes[2]))) {
136
                                    $read = array($pipes[1], $pipes[2]);
137
                                    $read = array($pipes[1], $pipes[2]);
137
 
138
 
138
                                    $n = stream_select($read, $w, $e, 5);
139
                                    $n = stream_select($read, $w, $e, 5);
139
 
140
 
140
                                    if (($n === false) || ($n === 0)) {
141
                                    if (($n === false) || ($n === 0)) {
141
                                        break;
142
                                        break;
142
                                    }
143
                                    }
143
 
144
 
144
                                    foreach ($read as $r) {
145
                                    foreach ($read as $r) {
145
                                        if ($r == $pipes[1]) {
146
                                        if ($r == $pipes[1]) {
146
                                            $out .= fread($r, 4096);
147
                                            $out .= fread($r, 4096);
147
                                        } elseif (feof($pipes[1]) && ($r == $pipes[2])) {//read STDERR after STDOUT
148
                                        } elseif (feof($pipes[1]) && ($r == $pipes[2])) {//read STDERR after STDOUT
148
                                            $err .= fread($r, 4096);
149
                                            $err .= fread($r, 4096);
149
                                        }
150
                                        }
150
                                    }
151
                                    }
151
                                }
152
                                }
152
 
153
 
153
                                if (is_null($out) || (trim($out) == "") || (substr(trim($out), 0, 1) != "/")) {
154
                                if (is_null($out) || (trim($out) == "") || (substr(trim($out), 0, 1) != "/")) {
154
                                    define('PSI_MODE_POPEN', true);
155
                                    define('PSI_MODE_POPEN', true);
155
                                }
156
                                }
156
                                fclose($pipes[0]);
157
                                fclose($pipes[0]);
157
                                fclose($pipes[1]);
158
                                fclose($pipes[1]);
158
                                fclose($pipes[2]);
159
                                fclose($pipes[2]);
159
                                // It is important that you close any pipes before calling
160
                                // It is important that you close any pipes before calling
160
                                // proc_close in order to avoid a deadlock
161
                                // proc_close in order to avoid a deadlock
161
                                proc_close($process);
162
                                proc_close($process);
162
                            }
163
                            }
163
                        }
164
                        }
164
                    }
165
                    }
165
                }
166
                }
166
            }
167
            }
167
            if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
168
            if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
168
               && $contents && (preg_match('/^(LANG="?[^"\n]*"?)/m', $contents, $matches)
169
               && $contents && (preg_match('/^(LANG="?[^"\n]*"?)/m', $contents, $matches)
169
               || preg_match('/^RC_(LANG="?[^"\n]*"?)/m', $contents, $matches)
170
               || preg_match('/^RC_(LANG="?[^"\n]*"?)/m', $contents, $matches)
170
               || preg_match('/^\s*export (LANG="?[^"\n]*"?)/m', $contents, $matches))) {
171
               || preg_match('/^\s*export (LANG="?[^"\n]*"?)/m', $contents, $matches))) {
171
                if (!defined('PSI_SYSTEM_CODEPAGE')) {
172
                if (!defined('PSI_SYSTEM_CODEPAGE')) {
172
                    if (file_exists($vtfname = '/sys/module/vt/parameters/default_utf8')
173
                    if (file_exists($vtfname = '/sys/module/vt/parameters/default_utf8')
173
                       && (trim(@file_get_contents($vtfname)) === "1")) {
174
                       && (trim(@file_get_contents($vtfname)) === "1")) {
174
                            define('PSI_SYSTEM_CODEPAGE', 'UTF-8');
175
                            define('PSI_SYSTEM_CODEPAGE', 'UTF-8');
175
                    } elseif (@exec($matches[1].' locale -k LC_CTYPE 2>/dev/null', $lines)) { //if not overloaded in phpsysinfo.ini
176
                    } elseif (function_exists('exec') && @exec($matches[1].' locale -k LC_CTYPE 2>/dev/null', $lines)) { //if not overloaded in phpsysinfo.ini
176
                        foreach ($lines as $line) {
177
                        foreach ($lines as $line) {
177
                            if (preg_match('/^charmap="?([^"]*)/', $line, $matches2)) {
178
                            if (preg_match('/^charmap="?([^"]*)/', $line, $matches2)) {
178
                                define('PSI_SYSTEM_CODEPAGE', $matches2[1]);
179
                                define('PSI_SYSTEM_CODEPAGE', $matches2[1]);
179
                                break;
180
                                break;
180
                            }
181
                            }
181
                        }
182
                        }
182
                    }
183
                    }
183
                }
184
                }
184
                if (!defined('PSI_SYSTEM_LANG') && @exec($matches[1].' locale 2>/dev/null', $lines2)) { //also if not overloaded in phpsysinfo.ini
185
                if (!defined('PSI_SYSTEM_LANG') && function_exists('exec') && @exec($matches[1].' locale 2>/dev/null', $lines2)) { //also if not overloaded in phpsysinfo.ini
185
                    foreach ($lines2 as $line) {
186
                    foreach ($lines2 as $line) {
186
                        if (preg_match('/^LC_MESSAGES="?([^\."@]*)/', $line, $matches2)) {
187
                        if (preg_match('/^LC_MESSAGES="?([^\."@]*)/', $line, $matches2)) {
187
                            $lang = "";
188
                            $lang = "";
188
                            if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
189
                            if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
189
                                if (isset($langdata['Linux']['_'.$matches2[1]])) {
190
                                if (isset($langdata['Linux']['_'.$matches2[1]])) {
190
                                    $lang = $langdata['Linux']['_'.$matches2[1]];
191
                                    $lang = $langdata['Linux']['_'.$matches2[1]];
191
                                }
192
                                }
192
                            }
193
                            }
193
                            if ($lang == "") {
194
                            if ($lang == "") {
194
                                $lang = 'Unknown';
195
                                $lang = 'Unknown';
195
                            }
196
                            }
196
                            define('PSI_SYSTEM_LANG', $lang.' ('.$matches2[1].')');
197
                            define('PSI_SYSTEM_LANG', $lang.' ('.$matches2[1].')');
197
                            break;
198
                            break;
198
                        }
199
                        }
199
                    }
200
                    }
200
                }
201
                }
201
            }
202
            }
202
        } elseif (PHP_OS == 'Haiku') {
203
        } elseif (PHP_OS == 'Haiku') {
203
            if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
204
            if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
204
                && @exec('locale -m 2>/dev/null', $lines)) {
205
                && function_exists('exec') && @exec('locale --message 2>/dev/null', $lines)) {
205
                foreach ($lines as $line) {
206
                foreach ($lines as $line) {
206
                    if (preg_match('/^"?([^\."]*)\.?([^"]*)/', $line, $matches2)) {
207
                    if (preg_match('/^"?([^\."]*)\.?([^"]*)/', $line, $matches2)) {
207
 
208
 
208
                        if (!defined('PSI_SYSTEM_CODEPAGE') && isset($matches2[2]) && !is_null($matches2[2]) && (trim($matches2[2]) != "")) { //also if not overloaded in phpsysinfo.ini
209
                        if (!defined('PSI_SYSTEM_CODEPAGE') && isset($matches2[2]) && !is_null($matches2[2]) && (trim($matches2[2]) != "")) { //also if not overloaded in phpsysinfo.ini
209
                            define('PSI_SYSTEM_CODEPAGE', $matches2[2]);
210
                            define('PSI_SYSTEM_CODEPAGE', $matches2[2]);
210
                        }
211
                        }
211
 
212
 
212
                        if (!defined('PSI_SYSTEM_LANG')) { //if not overloaded in phpsysinfo.ini
213
                        if (!defined('PSI_SYSTEM_LANG')) { //if not overloaded in phpsysinfo.ini
213
                            $lang = "";
214
                            $lang = "";
214
                            if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
215
                            if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
215
                                if (isset($langdata['Linux']['_'.$matches2[1]])) {
216
                                if (isset($langdata['Linux']['_'.$matches2[1]])) {
216
                                    $lang = $langdata['Linux']['_'.$matches2[1]];
217
                                    $lang = $langdata['Linux']['_'.$matches2[1]];
217
                                }
218
                                }
218
                            }
219
                            }
219
                            if ($lang == "") {
220
                            if ($lang == "") {
220
                                $lang = 'Unknown';
221
                                $lang = 'Unknown';
221
                            }
222
                            }
222
                            define('PSI_SYSTEM_LANG', $lang.' ('.$matches2[1].')');
223
                            define('PSI_SYSTEM_LANG', $lang.' ('.$matches2[1].')');
223
                        }
224
                        }
224
                        break;
225
                        break;
225
                    }
226
                    }
226
                }
227
                }
227
            }
228
            }
228
        } elseif (PHP_OS == 'Darwin') {
229
        } elseif (PHP_OS == 'Darwin') {
229
            if (!defined('PSI_SYSTEM_LANG') //if not overloaded in phpsysinfo.ini
230
            if (!defined('PSI_SYSTEM_LANG') //if not overloaded in phpsysinfo.ini
230
                && @exec('defaults read /Library/Preferences/.GlobalPreferences AppleLocale 2>/dev/null', $lines)) {
231
                && function_exists('exec') && @exec('defaults read /Library/Preferences/.GlobalPreferences AppleLocale 2>/dev/null', $lines)) {
231
                $lang = "";
232
                $lang = "";
232
                if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
233
                if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
233
                    if (isset($langdata['Linux']['_'.$lines[0]])) {
234
                    if (isset($langdata['Linux']['_'.$lines[0]])) {
234
                        $lang = $langdata['Linux']['_'.$lines[0]];
235
                        $lang = $langdata['Linux']['_'.$lines[0]];
235
                    }
236
                    }
236
                }
237
                }
237
                if ($lang == "") {
238
                if ($lang == "") {
238
                    $lang = 'Unknown';
239
                    $lang = 'Unknown';
239
                }
240
                }
240
                define('PSI_SYSTEM_LANG', $lang.' ('.$lines[0].')');
241
                define('PSI_SYSTEM_LANG', $lang.' ('.$lines[0].')');
241
            }
242
            }
242
        }
243
        }
243
    }
244
    }
244
 
245
 
-
 
246
    /* maximum time in seconds a script is allowed to run before it is terminated by the parser */
-
 
247
    if (defined('PSI_MAX_TIMEOUT')) {
-
 
248
        ini_set('max_execution_time', max(intval(PSI_MAX_TIMEOUT), 0));
-
 
249
    } else {
-
 
250
        ini_set('max_execution_time', 30);
-
 
251
    }
-
 
252
 
245
    /* executeProgram() timeout value in seconds */
253
    /* executeProgram() timeout value in seconds */
246
    if (defined('PSI_EXEC_TIMEOUT')) {
254
    if (defined('PSI_EXEC_TIMEOUT')) {
247
        define('PSI_EXEC_TIMEOUT_INT', max(intval(PSI_EXEC_TIMEOUT), 1));
255
        define('PSI_EXEC_TIMEOUT_INT', max(intval(PSI_EXEC_TIMEOUT), 1));
248
    } else {
256
    } else {
249
        define('PSI_EXEC_TIMEOUT_INT', 30);
257
        define('PSI_EXEC_TIMEOUT_INT', 30);
250
    }
258
    }
251
 
259
 
252
    /* snmprealwalk() and executeProgram("snmpwalk") number of seconds until the first timeout */
260
    /* snmprealwalk() and executeProgram("snmpwalk") number of seconds until the first timeout */
253
    if (defined('PSI_SNMP_TIMEOUT')) {
261
    if (defined('PSI_SNMP_TIMEOUT')) {
254
        define('PSI_SNMP_TIMEOUT_INT', max(intval(PSI_SNMP_TIMEOUT), 1));
262
        define('PSI_SNMP_TIMEOUT_INT', max(intval(PSI_SNMP_TIMEOUT), 1));
255
    } else {
263
    } else {
256
        define('PSI_SNMP_TIMEOUT_INT', 3);
264
        define('PSI_SNMP_TIMEOUT_INT', 3);
257
    }
265
    }
258
 
266
 
259
    /* snmprealwalk() and executeProgram("snmpwalk") number of times to retry if timeouts occur */
267
    /* snmprealwalk() and executeProgram("snmpwalk") number of times to retry if timeouts occur */
260
    if (defined('PSI_SNMP_RETRY')) {
268
    if (defined('PSI_SNMP_RETRY')) {
261
        define('PSI_SNMP_RETRY_INT', max(intval(PSI_SNMP_RETRY), 0));
269
        define('PSI_SNMP_RETRY_INT', max(intval(PSI_SNMP_RETRY), 0));
262
    } else {
270
    } else {
263
        define('PSI_SNMP_RETRY_INT', 0);
271
        define('PSI_SNMP_RETRY_INT', 0);
264
    }
272
    }
265
 
273
 
266
    if (!defined('PSI_OS')) {
274
    if (!defined('PSI_OS')) {
267
        define('PSI_OS', PHP_OS);
275
        define('PSI_OS', PHP_OS);
268
    }
276
    }
269
 
277
 
270
    if (!defined('PSI_SYSTEM_LANG')) {
278
    if (!defined('PSI_SYSTEM_LANG')) {
271
        define('PSI_SYSTEM_LANG', null);
279
        define('PSI_SYSTEM_LANG', null);
272
    }
280
    }
273
    if (!defined('PSI_SYSTEM_CODEPAGE')) { //if not overloaded in phpsysinfo.ini
281
    if (!defined('PSI_SYSTEM_CODEPAGE')) { //if not overloaded in phpsysinfo.ini
274
        if ((PSI_OS=='Android') || (PSI_OS=='Darwin')) {
282
        if ((PSI_OS=='Android') || (PSI_OS=='Darwin')) {
275
            define('PSI_SYSTEM_CODEPAGE', 'UTF-8');
283
            define('PSI_SYSTEM_CODEPAGE', 'UTF-8');
276
        } elseif (PSI_OS=='Minix') {
284
        } elseif (PSI_OS=='Minix') {
277
            define('PSI_SYSTEM_CODEPAGE', 'CP437');
285
            define('PSI_SYSTEM_CODEPAGE', 'CP437');
278
        } else {
286
        } elseif (PSI_OS!='WINNT') {
279
            define('PSI_SYSTEM_CODEPAGE', null);
287
            define('PSI_SYSTEM_CODEPAGE', null);
280
        }
288
        }
281
    }
289
    }
282
 
290
 
283
    if (!defined('PSI_JSON_ISSUE')) { //if not overloaded in phpsysinfo.ini
291
    if (!defined('PSI_JSON_ISSUE')) { //if not overloaded in phpsysinfo.ini
284
        if (!extension_loaded("xml")) {
292
        if (!extension_loaded("xml")) {
285
            die("phpSysInfo requires the xml extension to php in order to work properly.");
293
            die("phpSysInfo requires the xml extension to php in order to work properly.");
286
        }
294
        }
287
        if (simplexml_load_string("<A><B><C/></B>\n</A>") !== simplexml_load_string("<A><B><C/></B></A>")) { // json_encode issue test
295
        if (simplexml_load_string("<A><B><C/></B>\n</A>") !== simplexml_load_string("<A><B><C/></B></A>")) { // json_encode issue test
288
            define('PSI_JSON_ISSUE', true); // Problem must be solved
296
            define('PSI_JSON_ISSUE', true); // Problem must be solved
289
        }
297
        }
290
    }
298
    }
291
 
299
 
292
    /* restore error level */
300
    /* restore error level */
293
    error_reporting($old_err_rep);
301
    error_reporting($old_err_rep);
294
 
302
 
295
    /* restore error handler */
303
    /* restore error handler */
296
    if (function_exists('errorHandlerPsi')) {
304
    if (function_exists('errorHandlerPsi')) {
297
        set_error_handler('errorHandlerPsi');
305
        set_error_handler('errorHandlerPsi');
298
    }
306
    }
299
}
307
}
300
 
308