Subversion Repositories ALCASAR

Rev

Rev 2976 | Rev 3100 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2976 Rev 3037
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.4');
6
    define('PSI_VERSION', '3.4.1');
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 98... Line 98...
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_ROOTFS') && is_string(PSI_ROOTFS) && (PSI_ROOTFS !== '') && (PSI_ROOTFS !== '/')) {
-
 
104
        $rootfs = PSI_ROOTFS;
-
 
105
        if ($rootfs[0] === '/') {
-
 
106
            define('PSI_ROOT_FILESYSTEM', $rootfs);
-
 
107
        } else {
-
 
108
            define('PSI_ROOT_FILESYSTEM', '');
-
 
109
        }
-
 
110
    } else {
-
 
111
        define('PSI_ROOT_FILESYSTEM', '');
-
 
112
    }
-
 
113
 
103
    if (!defined('PSI_OS')) { //if not overloaded in phpsysinfo.ini
114
    if (!defined('PSI_OS')) { //if not overloaded in phpsysinfo.ini
104
        /* get Linux code page */
115
        /* get Linux code page */
105
        if (PHP_OS == 'Linux') {
116
        if (PHP_OS == 'Linux') {
106
            if (file_exists($fname = '/etc/sysconfig/i18n')
117
            if (file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/sysconfig/i18n')
107
               || file_exists($fname = '/etc/default/locale')
118
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/default/locale')
108
               || file_exists($fname = '/etc/locale.conf')
119
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/locale.conf')
109
               || file_exists($fname = '/etc/sysconfig/language')
120
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/sysconfig/language')
110
               || file_exists($fname = '/etc/profile.d/lang.sh')
121
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/profile.d/lang.sh')
111
               || file_exists($fname = '/etc/profile.d/i18n.sh')
122
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/profile.d/i18n.sh')
112
               || file_exists($fname = '/etc/profile')) {
123
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/profile')) {
113
                $contents = @file_get_contents($fname);
124
                $contents = @file_get_contents($fname);
114
            } else {
125
            } else {
115
                $contents = false;
126
                $contents = false;
116
                if (file_exists('/system/build.prop')) { //Android
127
                if (file_exists(PSI_ROOT_FILESYSTEM.'/system/build.prop')) { //Android
117
                    define('PSI_OS', 'Android');
128
                    define('PSI_OS', 'Android');
118
                    if (function_exists('exec') && @exec('uname -o 2>/dev/null', $unameo) && (sizeof($unameo)>0) && (($unameo0 = trim($unameo[0])) != "")) {
129
                    if ((PSI_ROOT_FILESYSTEM === '') && function_exists('exec') && @exec('uname -o 2>/dev/null', $unameo) && (sizeof($unameo)>0) && (($unameo0 = trim($unameo[0])) != "")) {
119
                        define('PSI_UNAMEO', $unameo0); // is Android on Termux
130
                        define('PSI_UNAMEO', $unameo0); // is Android on Termux
120
                    }
131
                    }
121
                    if (!defined('PSI_MODE_POPEN')) { //if not overloaded in phpsysinfo.ini
132
                    if ((PSI_ROOT_FILESYSTEM === '') && !defined('PSI_MODE_POPEN')) { //if not overloaded in phpsysinfo.ini
122
                        if (!function_exists("proc_open")) { //proc_open function test by executing 'pwd' command
133
                        if (!function_exists("proc_open")) { //proc_open function test by executing 'pwd' bbbmand
123
                            define('PSI_MODE_POPEN', true); //use popen() function - no stderr error handling (but with problems with timeout)
134
                            define('PSI_MODE_POPEN', true); //use popen() function - no stderr error handling (but with problems with timeout)
124
                        } else {
135
                        } else {
125
                            $out = '';
136
                            $out = '';
126
                            $err = '';
137
                            $err = '';
127
                            $pipes = array();
138
                            $pipes = array();
Line 149... Line 160...
149
                                            $err .= fread($r, 4096);
160
                                            $err .= fread($r, 4096);
150
                                        }
161
                                        }
151
                                    }
162
                                    }
152
                                }
163
                                }
153
 
164
 
154
                                if (is_null($out) || (trim($out) == "") || (substr(trim($out), 0, 1) != "/")) {
165
                                if (($out === null) || (trim($out) == "") || (substr(trim($out), 0, 1) != "/")) {
155
                                    define('PSI_MODE_POPEN', true);
166
                                    define('PSI_MODE_POPEN', true);
156
                                }
167
                                }
157
                                fclose($pipes[0]);
168
                                fclose($pipes[0]);
158
                                fclose($pipes[1]);
169
                                fclose($pipes[1]);
159
                                fclose($pipes[2]);
170
                                fclose($pipes[2]);
Line 168... Line 179...
168
            if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
179
            if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
169
               && $contents && (preg_match('/^(LANG="?[^"\n]*"?)/m', $contents, $matches)
180
               && $contents && (preg_match('/^(LANG="?[^"\n]*"?)/m', $contents, $matches)
170
               || preg_match('/^RC_(LANG="?[^"\n]*"?)/m', $contents, $matches)
181
               || preg_match('/^RC_(LANG="?[^"\n]*"?)/m', $contents, $matches)
171
               || preg_match('/^\s*export (LANG="?[^"\n]*"?)/m', $contents, $matches))) {
182
               || preg_match('/^\s*export (LANG="?[^"\n]*"?)/m', $contents, $matches))) {
172
                if (!defined('PSI_SYSTEM_CODEPAGE')) {
183
                if (!defined('PSI_SYSTEM_CODEPAGE')) {
173
                    if (file_exists($vtfname = '/sys/module/vt/parameters/default_utf8')
184
                    if (file_exists($vtfname = PSI_ROOT_FILESYSTEM.'/sys/module/vt/parameters/default_utf8')
174
                       && (trim(@file_get_contents($vtfname)) === "1")) {
185
                       && (trim(@file_get_contents($vtfname)) === "1")) {
175
                            define('PSI_SYSTEM_CODEPAGE', 'UTF-8');
186
                            define('PSI_SYSTEM_CODEPAGE', 'UTF-8');
176
                    } elseif (function_exists('exec') && @exec($matches[1].' locale -k LC_CTYPE 2>/dev/null', $lines)) { //if not overloaded in phpsysinfo.ini
187
                    } elseif ((PSI_ROOT_FILESYSTEM === '') && function_exists('exec') && @exec($matches[1].' locale -k LC_CTYPE 2>/dev/null', $lines)) { //if not overloaded in phpsysinfo.ini
177
                        foreach ($lines as $line) {
188
                        foreach ($lines as $line) {
178
                            if (preg_match('/^charmap="?([^"]*)/', $line, $matches2)) {
189
                            if (preg_match('/^charmap="?([^"]*)/', $line, $matches2)) {
179
                                define('PSI_SYSTEM_CODEPAGE', $matches2[1]);
190
                                define('PSI_SYSTEM_CODEPAGE', $matches2[1]);
180
                                break;
191
                                break;
181
                            }
192
                            }
182
                        }
193
                        }
183
                    }
194
                    }
184
                }
195
                }
185
                if (!defined('PSI_SYSTEM_LANG') && function_exists('exec') && @exec($matches[1].' locale 2>/dev/null', $lines2)) { //also if not overloaded in phpsysinfo.ini
196
                if ((PSI_ROOT_FILESYSTEM === '') && !defined('PSI_SYSTEM_LANG') && function_exists('exec') && @exec($matches[1].' locale 2>/dev/null', $lines2)) { //also if not overloaded in phpsysinfo.ini
186
                    foreach ($lines2 as $line) {
197
                    foreach ($lines2 as $line) {
187
                        if (preg_match('/^LC_MESSAGES="?([^\."@]*)/', $line, $matches2)) {
198
                        if (preg_match('/^LC_MESSAGES="?([^\."@]*)/', $line, $matches2)) {
188
                            $lang = "";
199
                            $lang = "";
189
                            if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
200
                            if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
190
                                if (isset($langdata['Linux']['_'.$matches2[1]])) {
201
                                if (isset($langdata['Linux']['_'.$matches2[1]])) {
Line 200... Line 211...
200
                    }
211
                    }
201
                }
212
                }
202
            }
213
            }
203
        } elseif (PHP_OS == 'Haiku') {
214
        } elseif (PHP_OS == 'Haiku') {
204
            if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
215
            if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
205
                && function_exists('exec') && @exec('locale --message 2>/dev/null', $lines)) {
216
                && (PSI_ROOT_FILESYSTEM === '') && function_exists('exec') && @exec('locale --message 2>/dev/null', $lines)) {
206
                foreach ($lines as $line) {
217
                foreach ($lines as $line) {
207
                    if (preg_match('/^"?([^\."]*)\.?([^"]*)/', $line, $matches2)) {
218
                    if (preg_match('/^"?([^\."]*)\.?([^"]*)/', $line, $matches2)) {
208
 
219
 
209
                        if (!defined('PSI_SYSTEM_CODEPAGE') && isset($matches2[2]) && !is_null($matches2[2]) && (trim($matches2[2]) != "")) { //also if not overloaded in phpsysinfo.ini
220
                        if (!defined('PSI_SYSTEM_CODEPAGE') && isset($matches2[2]) && ($matches2[2] !== null) && (trim($matches2[2]) != "")) { //also if not overloaded in phpsysinfo.ini
210
                            define('PSI_SYSTEM_CODEPAGE', $matches2[2]);
221
                            define('PSI_SYSTEM_CODEPAGE', $matches2[2]);
211
                        }
222
                        }
212
 
223
 
213
                        if (!defined('PSI_SYSTEM_LANG')) { //if not overloaded in phpsysinfo.ini
224
                        if (!defined('PSI_SYSTEM_LANG')) { //if not overloaded in phpsysinfo.ini
214
                            $lang = "";
225
                            $lang = "";
Line 226... Line 237...
226
                    }
237
                    }
227
                }
238
                }
228
            }
239
            }
229
        } elseif (PHP_OS == 'Darwin') {
240
        } elseif (PHP_OS == 'Darwin') {
230
            if (!defined('PSI_SYSTEM_LANG') //if not overloaded in phpsysinfo.ini
241
            if (!defined('PSI_SYSTEM_LANG') //if not overloaded in phpsysinfo.ini
231
                && function_exists('exec') && @exec('defaults read /Library/Preferences/.GlobalPreferences AppleLocale 2>/dev/null', $lines)) {
242
                && (PSI_ROOT_FILESYSTEM === '') && function_exists('exec') && @exec('defaults read /Library/Preferences/.GlobalPreferences AppleLocale 2>/dev/null', $lines)) {
232
                $lang = "";
243
                $lang = "";
233
                if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
244
                if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
234
                    if (isset($langdata['Linux']['_'.$lines[0]])) {
245
                    if (isset($langdata['Linux']['_'.$lines[0]])) {
235
                        $lang = $langdata['Linux']['_'.$lines[0]];
246
                        $lang = $langdata['Linux']['_'.$lines[0]];
236
                    }
247
                    }