Subversion Repositories ALCASAR

Rev

Rev 3037 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log

Rev 3037 Rev 3100
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.4.1');
6
    define('PSI_VERSION', '3.4.2');
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 30... Line 30...
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 ((($paramup = strtoupper($param)) !== 'WMI_PASSWORD') && ($paramup !== 'SSH_PASSWORD') && 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.$paramup, '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.$paramup, trim($value));
39
                    }
39
                    }
40
                }
40
                }
41
            }
41
            }
42
        }
42
        }
43
    }
43
    }
Line 58... Line 58...
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
        $ip_decimal = ip2long($ip);
63
        if (!in_array($ip, $allowed, true)) {
64
        if ($ip_decimal === false) {
-
 
65
            echo "Client IP wrong address (".$ip."). Client not allowed.";
-
 
66
            die();
-
 
67
        }
-
 
68
 
-
 
69
        // code based on https://gist.github.com/tott/7684443
-
 
70
        $was = false;
-
 
71
        foreach ($allowed as $allow) {
-
 
72
            if (strpos($allow, '/') === false) {
-
 
73
                    $was = ($allow === $ip);
-
 
74
            } else {
-
 
75
                  list($allow, $netmask) = explode('/', $allow, 2);
-
 
76
                  $allow_decimal = ip2long($allow);
-
 
77
                  $wildcard_decimal = pow(2, (32 - $netmask)) - 1;
-
 
78
                  $netmask_decimal = ~$wildcard_decimal;
-
 
79
                $was = (($ip_decimal & $netmask_decimal) === ($allow_decimal & $netmask_decimal));
-
 
80
            }
-
 
81
            if ($was) {
-
 
82
               break;
-
 
83
            }
-
 
84
        }
-
 
85
 
-
 
86
        if (!$was) {
64
            echo "Client IP address not allowed";
87
            echo "Client IP address (".$ip.") not allowed.";
65
            die();
88
            die();
66
        }
89
        }
67
    }
90
    }
68
 
91
 
69
    /* default error handler */
92
    /* default error handler */
Line 111... Line 134...
111
        define('PSI_ROOT_FILESYSTEM', '');
134
        define('PSI_ROOT_FILESYSTEM', '');
112
    }
135
    }
113
 
136
 
114
    if (!defined('PSI_OS')) { //if not overloaded in phpsysinfo.ini
137
    if (!defined('PSI_OS')) { //if not overloaded in phpsysinfo.ini
115
        /* get Linux code page */
138
        /* get Linux code page */
116
        if (PHP_OS == 'Linux') {
139
        if ((PHP_OS == 'Linux') || (PHP_OS == 'GNU')) {
117
            if (file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/sysconfig/i18n')
140
            if (file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/sysconfig/i18n')
118
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/default/locale')
141
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/default/locale')
119
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/locale.conf')
142
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/locale.conf')
120
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/sysconfig/language')
143
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/sysconfig/language')
121
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/profile.d/lang.sh')
144
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/profile.d/lang.sh')
122
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/profile.d/i18n.sh')
145
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/profile.d/i18n.sh')
123
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/profile')) {
146
               || file_exists($fname = PSI_ROOT_FILESYSTEM.'/etc/profile')) {
124
                $contents = @file_get_contents($fname);
147
                $contents = @file_get_contents($fname);
125
            } else {
148
            } else {
126
                $contents = false;
149
                $contents = false;
-
 
150
                if (PHP_OS == 'Linux') {
127
                if (file_exists(PSI_ROOT_FILESYSTEM.'/system/build.prop')) { //Android
151
                    if (file_exists(PSI_ROOT_FILESYSTEM.'/system/build.prop')) { //Android
128
                    define('PSI_OS', 'Android');
152
                        define('PSI_OS', 'Android');
129
                    if ((PSI_ROOT_FILESYSTEM === '') && function_exists('exec') && @exec('uname -o 2>/dev/null', $unameo) && (sizeof($unameo)>0) && (($unameo0 = trim($unameo[0])) != "")) {
153
                        if ((PSI_ROOT_FILESYSTEM === '') && function_exists('exec') && @exec('uname -o 2>/dev/null', $unameo) && (sizeof($unameo)>0) && (($unameo0 = trim($unameo[0])) != "")) {
130
                        define('PSI_UNAMEO', $unameo0); // is Android on Termux
154
                            define('PSI_UNAMEO', $unameo0); // is Android on Termux
131
                    }
155
                        }
Line 172... Line 196...
172
                                // proc_close in order to avoid a deadlock
196
                                    // proc_close in order to avoid a deadlock
173
                                proc_close($process);
197
                                    proc_close($process);
174
                            }
198
                                }
175
                        }
199
                            }
176
                    }
200
                        }
-
 
201
                    } elseif (file_exists(PSI_ROOT_FILESYSTEM.'/var/mobile/Library/Cydia/metadata.cb0')) { //jailbroken iOS with Cydia
-
 
202
                        define('PSI_OS', 'Darwin');
-
 
203
                    }
177
                }
204
                }
178
            }
205
            }
179
            if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
206
            if (!(defined('PSI_SYSTEM_CODEPAGE') && defined('PSI_SYSTEM_LANG')) //also if both not overloaded in phpsysinfo.ini
180
               && $contents && (preg_match('/^(LANG="?[^"\n]*"?)/m', $contents, $matches)
207
               && $contents && (preg_match('/^(LANG="?[^"\n]*"?)/m', $contents, $matches)
181
               || preg_match('/^RC_(LANG="?[^"\n]*"?)/m', $contents, $matches)
208
               || preg_match('/^RC_(LANG="?[^"\n]*"?)/m', $contents, $matches)
Line 235... Line 262...
235
                        }
262
                        }
236
                        break;
263
                        break;
237
                    }
264
                    }
238
                }
265
                }
239
            }
266
            }
240
        } elseif (PHP_OS == 'Darwin') {
267
        } elseif ((PHP_OS == 'Darwin') || (defined('PSI_OS') && (PSI_OS == 'Darwin'))){
241
            if (!defined('PSI_SYSTEM_LANG') //if not overloaded in phpsysinfo.ini
268
            if (!defined('PSI_SYSTEM_LANG') //if not overloaded in phpsysinfo.ini
242
                && (PSI_ROOT_FILESYSTEM === '') && function_exists('exec') && @exec('defaults read /Library/Preferences/.GlobalPreferences AppleLocale 2>/dev/null', $lines)) {
269
                && (PSI_ROOT_FILESYSTEM === '') && function_exists('exec') && @exec('defaults read /Library/Preferences/.GlobalPreferences AppleLocale 2>/dev/null', $lines)) {
243
                $lang = "";
270
                $lang = "";
244
                if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
271
                if (is_readable(PSI_APP_ROOT.'/data/languages.ini') && ($langdata = @parse_ini_file(PSI_APP_ROOT.'/data/languages.ini', true))) {
245
                    if (isset($langdata['Linux']['_'.$lines[0]])) {
272
                    if (isset($langdata['Linux']['_'.$lines[0]])) {