Line 1... |
Line 1... |
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 |
|
Line 106... |
Line 106... |
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 {
|
Line 170... |
Line 171... |
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]])) {
|
Line 199... |
Line 200... |
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]);
|
Line 225... |
Line 226... |
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 |
}
|
Line 240... |
Line 241... |
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);
|
Line 273... |
Line 281... |
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
|