Subversion Repositories ALCASAR

Rev

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

Rev 2976 Rev 3037
1
<?php
1
<?php
2
/**
2
/**
3
 * common Functions class
3
 * common Functions class
4
 *
4
 *
5
 * PHP version 5
5
 * PHP version 5
6
 *
6
 *
7
 * @category  PHP
7
 * @category  PHP
8
 * @package   PSI
8
 * @package   PSI
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
10
 * @copyright 2009 phpSysInfo
10
 * @copyright 2009 phpSysInfo
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
12
 * @version   SVN: $Id: class.CommonFunctions.inc.php 699 2012-09-15 11:57:13Z namiltd $
12
 * @version   SVN: $Id: class.CommonFunctions.inc.php 699 2012-09-15 11:57:13Z namiltd $
13
 * @link      http://phpsysinfo.sourceforge.net
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
14
 */
15
 /**
15
 /**
16
 * class with common functions used in all places
16
 * class with common functions used in all places
17
 *
17
 *
18
 * @category  PHP
18
 * @category  PHP
19
 * @package   PSI
19
 * @package   PSI
20
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
20
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
21
 * @copyright 2009 phpSysInfo
21
 * @copyright 2009 phpSysInfo
22
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
22
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
23
 * @version   Release: 3.0
23
 * @version   Release: 3.0
24
 * @link      http://phpsysinfo.sourceforge.net
24
 * @link      http://phpsysinfo.sourceforge.net
25
 */
25
 */
26
class CommonFunctions
26
class CommonFunctions
27
{
27
{
28
    /**
28
    /**
29
     * holds codepage for chcp
29
     * holds dmi memory data
30
     *
30
     *
31
     * @var integer
31
     * @var array
32
     */
32
     */
33
    private static $_cp = null;
-
 
34
 
-
 
35
    /**
-
 
36
     * value of checking run as administrator
-
 
37
     *
-
 
38
     * @var boolean
-
 
39
     */
-
 
40
    private static $_asadmin = null;
33
    private static $_dmimd = null;
41
 
-
 
42
    public static function setcp($cp)
-
 
43
    {
-
 
44
        self::$_cp = $cp;
-
 
45
    }
-
 
46
 
-
 
47
    public static function getcp()
-
 
48
    {
-
 
49
        return self::$_cp;
-
 
50
    }
-
 
51
 
-
 
52
    public static function isAdmin()
-
 
53
    {
-
 
54
        if (self::$_asadmin == null) {
-
 
55
            if (PSI_OS == 'WINNT') {
-
 
56
                $strBuf = '';
-
 
57
                self::executeProgram('sfc', '2>&1', $strBuf, false); // 'net session' for detection does not work if "Server" (LanmanServer) service is stopped
-
 
58
                if (preg_match('/^\/SCANNOW\s/m', preg_replace('/(\x00)/', '', $strBuf))) { // SCANNOW checking - also if Unicode
-
 
59
                    self::$_asadmin = true;
-
 
60
                } else {
-
 
61
                    self::$_asadmin = false;
-
 
62
                }
-
 
63
            } else {
-
 
64
                self::$_asadmin = false;
-
 
65
            }
-
 
66
        }
-
 
67
 
-
 
68
        return self::$_asadmin;
-
 
69
    }
-
 
70
 
34
 
71
    private static function _parse_log_file($string)
35
    private static function _parse_log_file($string)
72
    {
36
    {
73
        if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && ((substr(PSI_LOG, 0, 1)=="-") || (substr(PSI_LOG, 0, 1)=="+"))) {
37
        if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && ((substr(PSI_LOG, 0, 1)=="-") || (substr(PSI_LOG, 0, 1)=="+"))) {
74
            $log_file = substr(PSI_LOG, 1);
38
            $log_file = substr(PSI_LOG, 1);
75
            if (file_exists($log_file)) {
39
            if (file_exists($log_file)) {
76
                $contents = @file_get_contents($log_file);
40
                $contents = @file_get_contents($log_file);
77
                if ($contents && preg_match("/^\-\-\-[^-\r\n]+\-\-\- ".preg_quote($string, '/')."\r?\n/m", $contents, $matches, PREG_OFFSET_CAPTURE)) {
41
                if ($contents && preg_match("/^\-\-\-[^-\r\n]+\-\-\- ".preg_quote($string, '/')."\r?\n/m", $contents, $matches, PREG_OFFSET_CAPTURE)) {
78
                    $findIndex = $matches[0][1];
42
                    $findIndex = $matches[0][1];
79
                    if (preg_match("/\r?\n/m", $contents, $matches, PREG_OFFSET_CAPTURE, $findIndex)) {
43
                    if (preg_match("/\r?\n/m", $contents, $matches, PREG_OFFSET_CAPTURE, $findIndex)) {
80
                        $startIndex = $matches[0][1]+1;
44
                        $startIndex = $matches[0][1]+1;
81
                        if (preg_match("/^\-\-\-[^-\r\n]+\-\-\- /m", $contents, $matches, PREG_OFFSET_CAPTURE, $startIndex)) {
45
                        if (preg_match("/^\-\-\-[^-\r\n]+\-\-\- /m", $contents, $matches, PREG_OFFSET_CAPTURE, $startIndex)) {
82
                            $stopIndex = $matches[0][1];
46
                            $stopIndex = $matches[0][1];
83
 
47
 
84
                            return substr($contents, $startIndex, $stopIndex-$startIndex);
48
                            return substr($contents, $startIndex, $stopIndex-$startIndex);
85
                        } else {
49
                        } else {
86
                            return substr($contents, $startIndex);
50
                            return substr($contents, $startIndex);
87
                        }
51
                        }
88
                    }
52
                    }
89
                }
53
                }
90
            }
54
            }
91
        }
55
        }
92
 
56
 
93
        return false;
57
        return false;
94
    }
58
    }
95
 
59
 
96
    /**
60
    /**
97
     * Find a system program, do also path checking when not running on WINNT
61
     * Find a system program, do also path checking when not running on WINNT
98
     * on WINNT we simply return the name with the exe extension to the program name
62
     * on WINNT we simply return the name with the exe extension to the program name
99
     *
63
     *
100
     * @param string $strProgram name of the program
64
     * @param string $strProgram name of the program
101
     *
65
     *
102
     * @return string|null complete path and name of the program
66
     * @return string|null complete path and name of the program
103
     */
67
     */
104
    public static function _findProgram($strProgram)
68
    public static function _findProgram($strProgram)
105
    {
69
    {
106
        $path_parts = pathinfo($strProgram);
70
        $path_parts = pathinfo($strProgram);
107
        if (empty($path_parts['basename'])) {
71
        if (empty($path_parts['basename'])) {
108
            return null;
72
            return null;
109
        }
73
        }
110
        $arrPath = array();
74
        $arrPath = array();
111
 
75
 
112
        if (empty($path_parts['dirname']) || ($path_parts['dirname'] == '.')) {
76
        if (empty($path_parts['dirname']) || ($path_parts['dirname'] == '.')) {
113
            if ((PSI_OS == 'WINNT') && empty($path_parts['extension'])) {
77
            if ((PSI_OS == 'WINNT') && empty($path_parts['extension'])) {
114
                $strProgram .= '.exe';
78
                $strProgram .= '.exe';
115
                $path_parts = pathinfo($strProgram);
79
                $path_parts = pathinfo($strProgram);
116
            }
80
            }
117
            if (PSI_OS == 'WINNT') {
81
            if (PSI_OS == 'WINNT') {
118
                if (self::readenv('Path', $serverpath)) {
82
                if (self::readenv('Path', $serverpath)) {
119
                    $arrPath = preg_split('/;/', $serverpath, -1, PREG_SPLIT_NO_EMPTY);
83
                    $arrPath = preg_split('/;/', $serverpath, -1, PREG_SPLIT_NO_EMPTY);
120
                }
84
                }
121
            } else {
85
            } else {
122
                if (self::readenv('PATH', $serverpath)) {
86
                if (self::readenv('PATH', $serverpath)) {
123
                    $arrPath = preg_split('/:/', $serverpath, -1, PREG_SPLIT_NO_EMPTY);
87
                    $arrPath = preg_split('/:/', $serverpath, -1, PREG_SPLIT_NO_EMPTY);
124
                }
88
                }
125
            }
89
            }
126
            if (defined('PSI_UNAMEO') && (PSI_UNAMEO === 'Android') && !empty($arrPath)) {
90
            if (defined('PSI_UNAMEO') && (PSI_UNAMEO === 'Android') && !empty($arrPath)) {
127
                array_push($arrPath, '/system/bin'); // Termux patch
91
                array_push($arrPath, '/system/bin'); // Termux patch
128
            }
92
            }
129
            if (defined('PSI_ADD_PATHS') && is_string(PSI_ADD_PATHS)) {
93
            if (defined('PSI_ADD_PATHS') && is_string(PSI_ADD_PATHS)) {
130
                if (preg_match(ARRAY_EXP, PSI_ADD_PATHS)) {
94
                if (preg_match(ARRAY_EXP, PSI_ADD_PATHS)) {
131
                    $arrPath = array_merge(eval(PSI_ADD_PATHS), $arrPath); // In this order so $addpaths is before $arrPath when looking for a program
95
                    $arrPath = array_merge(eval(PSI_ADD_PATHS), $arrPath); // In this order so $addpaths is before $arrPath when looking for a program
132
                } else {
96
                } else {
133
                    $arrPath = array_merge(array(PSI_ADD_PATHS), $arrPath); // In this order so $addpaths is before $arrPath when looking for a program
97
                    $arrPath = array_merge(array(PSI_ADD_PATHS), $arrPath); // In this order so $addpaths is before $arrPath when looking for a program
134
                }
98
                }
135
            }
99
            }
136
        } else { //directory defined
100
        } else { //directory defined
137
            array_push($arrPath, $path_parts['dirname']);
101
            array_push($arrPath, $path_parts['dirname']);
138
            $strProgram = $path_parts['basename'];
102
            $strProgram = $path_parts['basename'];
139
        }
103
        }
140
 
104
 
141
        //add some default paths if we still have no paths here
105
        //add some default paths if we still have no paths here
142
        if (empty($arrPath) && (PSI_OS != 'WINNT')) {
106
        if (empty($arrPath) && (PSI_OS != 'WINNT')) {
143
            if (PSI_OS == 'Android') {
107
            if (PSI_OS == 'Android') {
144
                array_push($arrPath, '/system/bin');
108
                array_push($arrPath, '/system/bin');
145
            } else {
109
            } else {
146
                array_push($arrPath, '/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin');
110
                array_push($arrPath, '/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin');
147
            }
111
            }
148
        }
112
        }
149
 
113
 
150
        $exceptPath = "";
114
        $exceptPath = "";
151
        if ((PSI_OS == 'WINNT') && self::readenv('WinDir', $windir)) {
115
        if ((PSI_OS == 'WINNT') && self::readenv('WinDir', $windir)) {
152
            foreach ($arrPath as $strPath) {
116
            foreach ($arrPath as $strPath) {
153
                if ((strtolower($strPath) == strtolower($windir)."\\system32") && is_dir($windir."\\SysWOW64")) {
117
                if ((strtolower($strPath) == strtolower($windir)."\\system32") && is_dir($windir."\\SysWOW64")) {
154
                    if (is_dir($windir."\\sysnative\\drivers")) { // or strlen(decbin(~0)) == 32; is_dir($windir."\\sysnative") sometimes does not work
118
                    if (is_dir($windir."\\sysnative\\drivers")) { // or strlen(decbin(~0)) == 32; is_dir($windir."\\sysnative") sometimes does not work
155
                        $exceptPath = $windir."\\sysnative"; //32-bit PHP on 64-bit Windows
119
                        $exceptPath = $windir."\\sysnative"; //32-bit PHP on 64-bit Windows
156
                    } else {
120
                    } else {
157
                        $exceptPath = $windir."\\SysWOW64"; //64-bit PHP on 64-bit Windows
121
                        $exceptPath = $windir."\\SysWOW64"; //64-bit PHP on 64-bit Windows
158
                    }
122
                    }
159
                    array_push($arrPath, $exceptPath);
123
                    array_push($arrPath, $exceptPath);
160
                    break;
124
                    break;
161
                }
125
                }
162
            }
126
            }
163
        } elseif (PSI_OS == 'Android') {
127
        } elseif (PSI_OS == 'Android') {
164
            $exceptPath = '/system/bin';
128
            $exceptPath = '/system/bin';
165
        }
129
        }
166
 
130
 
167
        foreach ($arrPath as $strPath) {
131
        foreach ($arrPath as $strPath) {
168
            // Path with and without trailing slash
132
            // Path with and without trailing slash
169
            if (PSI_OS == 'WINNT') {
133
            if (PSI_OS == 'WINNT') {
170
                $strPath = rtrim($strPath, "\\");
134
                $strPath = rtrim($strPath, "\\");
171
                $strPathS = $strPath."\\";
135
                $strPathS = $strPath."\\";
172
            } else {
136
            } else {
173
                $strPath = rtrim($strPath, "/");
137
                $strPath = rtrim($strPath, "/");
174
                $strPathS = $strPath."/";
138
                $strPathS = $strPath."/";
175
            }
139
            }
176
            if (($strPath !== $exceptPath) && !is_dir($strPath)) {
140
            if (($strPath !== $exceptPath) && !is_dir($strPath)) {
177
                continue;
141
                continue;
178
            }
142
            }
179
            $strProgrammpath = $strPathS.$strProgram;
143
            $strProgrammpath = $strPathS.$strProgram;
180
            if (is_executable($strProgrammpath) || ((PSI_OS == 'WINNT') && (strtolower($path_parts['extension']) == 'py'))) {
144
            if (is_executable($strProgrammpath) || ((PSI_OS == 'WINNT') && (strtolower($path_parts['extension']) == 'py') && is_file($strProgrammpath))) {
181
                return $strProgrammpath;
145
                return $strProgrammpath;
182
            }
146
            }
183
        }
147
        }
184
 
148
 
185
        return null;
149
        return null;
186
    }
150
    }
187
 
151
 
188
    /**
152
    /**
189
     * Execute a system program. return a trim()'d result.
153
     * Execute a system program. return a trim()'d result.
190
     * does very crude pipe and multiple commands (on WinNT) checking.  you need ' | ' or ' & ' for it to work
154
     * does very crude pipe and multiple commands (on WinNT) checking.  you need ' | ' or ' & ' for it to work
191
     * ie $program = CommonFunctions::executeProgram('netstat', '-anp | grep LIST');
155
     * ie $program = CommonFunctions::executeProgram('netstat', '-anp | grep LIST');
192
     * NOT $program = CommonFunctions::executeProgram('netstat', '-anp|grep LIST');
156
     * NOT $program = CommonFunctions::executeProgram('netstat', '-anp|grep LIST');
193
     *
157
     *
194
     * @param string  $strProgramname name of the program
158
     * @param string  $strProgramname name of the program
195
     * @param string  $strArgs        arguments to the program
159
     * @param string  $strArgs        arguments to the program
196
     * @param string  &$strBuffer     output of the command
160
     * @param string  &$strBuffer     output of the command
197
     * @param boolean $booErrorRep    en- or disables the reporting of errors which should be logged
161
     * @param boolean $booErrorRep    en- or disables the reporting of errors which should be logged
198
     * @param integer $timeout        timeout value in seconds (default value is PSI_EXEC_TIMEOUT_INT)
162
     * @param int     $timeout        timeout value in seconds (default value is PSI_EXEC_TIMEOUT_INT)
199
     *
163
     *
200
     * @return boolean command successfull or not
164
     * @return boolean command successfull or not
201
     */
165
     */
202
    public static function executeProgram($strProgramname, $strArgs, &$strBuffer, $booErrorRep = true, $timeout = PSI_EXEC_TIMEOUT_INT)
166
    public static function executeProgram($strProgramname, $strArgs, &$strBuffer, $booErrorRep = true, $timeout = PSI_EXEC_TIMEOUT_INT)
203
    {
167
    {
204
        if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && ((substr(PSI_LOG, 0, 1)=="-") || (substr(PSI_LOG, 0, 1)=="+"))) {
168
        if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && ((substr(PSI_LOG, 0, 1)=="-") || (substr(PSI_LOG, 0, 1)=="+"))) {
205
            $out = self::_parse_log_file("Executing: ".trim($strProgramname.' '.$strArgs));
169
            $out = self::_parse_log_file("Executing: ".trim($strProgramname.' '.$strArgs));
206
            if ($out == false) {
170
            if ($out == false) {
207
                if (substr(PSI_LOG, 0, 1)=="-") {
171
                if (substr(PSI_LOG, 0, 1)=="-") {
208
                    $strBuffer = '';
172
                    $strBuffer = '';
209
 
173
 
210
                    return false;
174
                    return false;
211
                }
175
                }
212
            } else {
176
            } else {
213
                $strBuffer = $out;
177
                $strBuffer = $out;
214
 
178
 
215
                return true;
179
                return true;
216
            }
180
            }
217
        }
181
        }
218
 
182
 
-
 
183
        if (PSI_ROOT_FILESYSTEM !== '') { // disabled if ROOTFS defined
-
 
184
 
-
 
185
            return false;
-
 
186
        }
-
 
187
 
219
        if ((PSI_OS != 'WINNT') && preg_match('/^([^=]+=[^ \t]+)[ \t]+(.*)$/', $strProgramname, $strmatch)) {
188
        if ((PSI_OS != 'WINNT') && preg_match('/^([^=]+=[^ \t]+)[ \t]+(.*)$/', $strProgramname, $strmatch)) {
220
            $strSet = $strmatch[1].' ';
189
            $strSet = $strmatch[1].' ';
221
            $strProgramname = $strmatch[2];
190
            $strProgramname = $strmatch[2];
222
        } else {
191
        } else {
223
            $strSet = '';
192
            $strSet = '';
224
        }
193
        }
225
        $strProgram = self::_findProgram($strProgramname);
194
        $strProgram = self::_findProgram($strProgramname);
226
        $error = PSI_Error::singleton();
195
        $error = PSI_Error::singleton();
227
        if (!$strProgram) {
196
        if (!$strProgram) {
228
            if ($booErrorRep) {
197
            if ($booErrorRep) {
229
                $error->addError('find_program("'.$strProgramname.'")', 'program not found on the machine');
198
                $error->addError('find_program("'.$strProgramname.'")', 'program not found on the machine');
230
            }
199
            }
231
 
200
 
232
            return false;
201
            return false;
233
        } else {
202
        } else {
234
            if (preg_match('/\s/', $strProgram)) {
203
            if (preg_match('/\s/', $strProgram)) {
235
                $strProgram = '"'.$strProgram.'"';
204
                $strProgram = '"'.$strProgram.'"';
236
            }
205
            }
237
        }
206
        }
238
 
207
 
239
        if ((PSI_OS != 'WINNT') && defined('PSI_SUDO_COMMANDS') && is_string(PSI_SUDO_COMMANDS)) {
208
        if ((PSI_OS != 'WINNT') && defined('PSI_SUDO_COMMANDS') && is_string(PSI_SUDO_COMMANDS)) {
240
            if (preg_match(ARRAY_EXP, PSI_SUDO_COMMANDS)) {
209
            if (preg_match(ARRAY_EXP, PSI_SUDO_COMMANDS)) {
241
                $sudocommands = eval(PSI_SUDO_COMMANDS);
210
                $sudocommands = eval(PSI_SUDO_COMMANDS);
242
            } else {
211
            } else {
243
                $sudocommands = array(PSI_SUDO_COMMANDS);
212
                $sudocommands = array(PSI_SUDO_COMMANDS);
244
            }
213
            }
245
            if (in_array($strProgramname, $sudocommands)) {
214
            if (in_array($strProgramname, $sudocommands)) {
246
                $sudoProgram = self::_findProgram("sudo");
215
                $sudoProgram = self::_findProgram("sudo");
247
                if (!$sudoProgram) {
216
                if (!$sudoProgram) {
248
                    if ($booErrorRep) {
217
                    if ($booErrorRep) {
249
                        $error->addError('find_program("sudo")', 'program not found on the machine');
218
                        $error->addError('find_program("sudo")', 'program not found on the machine');
250
                    }
219
                    }
251
 
220
 
252
                    return false;
221
                    return false;
253
                } else {
222
                } else {
254
                    if (preg_match('/\s/', $sudoProgram)) {
223
                    if (preg_match('/\s/', $sudoProgram)) {
255
                        $strProgram = '"'.$sudoProgram.'" '.$strProgram;
224
                        $strProgram = '"'.$sudoProgram.'" '.$strProgram;
256
                    } else {
225
                    } else {
257
                        $strProgram = $sudoProgram.' '.$strProgram;
226
                        $strProgram = $sudoProgram.' '.$strProgram;
258
                    }
227
                    }
259
                }
228
                }
260
            }
229
            }
261
        }
230
        }
262
 
231
 
263
        // see if we've gotten a | or &, if we have we need to do path checking on the cmd
232
        // see if we've gotten a | or &, if we have we need to do path checking on the cmd
264
        if ($strArgs) {
233
        if ($strArgs) {
265
            $arrArgs = preg_split('/ /', $strArgs, -1, PREG_SPLIT_NO_EMPTY);
234
            $arrArgs = preg_split('/ /', $strArgs, -1, PREG_SPLIT_NO_EMPTY);
266
            for ($i = 0, $cnt_args = count($arrArgs); $i < $cnt_args; $i++) {
235
            for ($i = 0, $cnt_args = count($arrArgs); $i < $cnt_args; $i++) {
267
                if (($arrArgs[$i] == '|') || ($arrArgs[$i] == '&')) {
236
                if (($arrArgs[$i] == '|') || ($arrArgs[$i] == '&')) {
268
                    $strCmd = $arrArgs[$i + 1];
237
                    $strCmd = $arrArgs[$i + 1];
269
                    $strNewcmd = self::_findProgram($strCmd);
238
                    $strNewcmd = self::_findProgram($strCmd);
270
                    if ($arrArgs[$i] == '|') {
239
                    if ($arrArgs[$i] == '|') {
271
                        $strArgs = preg_replace('/\| '.$strCmd.'/', '| "'.$strNewcmd.'"', $strArgs);
240
                        $strArgs = preg_replace('/\| '.$strCmd.'/', '| "'.$strNewcmd.'"', $strArgs);
272
                    } else {
241
                    } else {
273
                        $strArgs = preg_replace('/& '.$strCmd.'/', '& "'.$strNewcmd.'"', $strArgs);
242
                        $strArgs = preg_replace('/& '.$strCmd.'/', '& "'.$strNewcmd.'"', $strArgs);
274
                    }
243
                    }
275
                }
244
                }
276
            }
245
            }
277
            $strArgs = ' '.$strArgs;
246
            $strArgs = ' '.$strArgs;
278
        }
247
        }
279
 
248
 
280
        $strBuffer = '';
249
        $strBuffer = '';
281
        $strError = '';
250
        $strError = '';
282
        $pipes = array();
251
        $pipes = array();
283
        $descriptorspec = array(0=>array("pipe", "r"), 1=>array("pipe", "w"), 2=>array("pipe", "w"));
252
        $descriptorspec = array(0=>array("pipe", "r"), 1=>array("pipe", "w"), 2=>array("pipe", "w"));
284
        if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN === true) {
253
        if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN) {
285
            if (PSI_OS == 'WINNT') {
254
            if (PSI_OS == 'WINNT') {
286
                $process = $pipes[1] = popen($strSet.$strProgram.$strArgs." 2>nul", "r");
255
                $process = $pipes[1] = popen($strSet.$strProgram.$strArgs." 2>nul", "r");
287
            } else {
256
            } else {
288
                $process = $pipes[1] = popen($strSet.$strProgram.$strArgs." 2>/dev/null", "r");
257
                $process = $pipes[1] = popen($strSet.$strProgram.$strArgs." 2>/dev/null", "r");
289
            }
258
            }
290
        } else {
259
        } else {
291
            $process = proc_open($strSet.$strProgram.$strArgs, $descriptorspec, $pipes);
260
            $process = proc_open($strSet.$strProgram.$strArgs, $descriptorspec, $pipes);
292
        }
261
        }
293
        if (is_resource($process)) {
262
        if (is_resource($process)) {
294
            $te = self::_timeoutfgets($pipes, $strBuffer, $strError, $timeout);
263
            $te = self::_timeoutfgets($pipes, $strBuffer, $strError, $timeout);
295
            if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN === true) {
264
            if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN) {
296
                $return_value = pclose($pipes[1]);
265
                $return_value = pclose($pipes[1]);
297
            } else {
266
            } else {
298
                fclose($pipes[0]);
267
                fclose($pipes[0]);
299
                fclose($pipes[1]);
268
                fclose($pipes[1]);
300
                fclose($pipes[2]);
269
                fclose($pipes[2]);
301
                // It is important that you close any pipes before calling
270
                // It is important that you close any pipes before calling
302
                // proc_close in order to avoid a deadlock
271
                // proc_close in order to avoid a deadlock
303
                if ($te) {
272
                if ($te) {
304
                    proc_terminate($process); // proc_close tends to hang if the process is timing out
273
                    proc_terminate($process); // proc_close tends to hang if the process is timing out
305
                    $return_value = 0;
274
                    $return_value = 0;
306
                } else {
275
                } else {
307
                    $return_value = proc_close($process);
276
                    $return_value = proc_close($process);
308
                }
277
                }
309
            }
278
            }
310
        } else {
279
        } else {
311
            if ($booErrorRep) {
280
            if ($booErrorRep) {
312
                $error->addError($strProgram, "\nOpen process error");
281
                $error->addError($strProgram, "\nOpen process error");
313
            }
282
            }
314
 
283
 
315
            return false;
284
            return false;
316
        }
285
        }
317
        $strError = trim($strError);
286
        $strError = trim($strError);
318
        $strBuffer = trim($strBuffer);
287
        $strBuffer = trim($strBuffer);
319
        if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && (substr(PSI_LOG, 0, 1)!="-") && (substr(PSI_LOG, 0, 1)!="+")) {
288
        if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && (substr(PSI_LOG, 0, 1)!="-") && (substr(PSI_LOG, 0, 1)!="+")) {
320
            error_log("---".gmdate('r T')."--- Executing: ".trim($strProgramname.$strArgs)."\n".$strBuffer."\n", 3, PSI_LOG);
289
            error_log("---".gmdate('r T')."--- Executing: ".trim($strProgramname.$strArgs)."\n".$strBuffer."\n", 3, PSI_LOG);
321
        }
290
        }
322
        if (! empty($strError)) {
291
        if (! empty($strError)) {
323
            if ($booErrorRep) {
292
            if ($booErrorRep) {
324
                $error->addError($strProgram, $strError."\nReturn value: ".$return_value);
293
                $error->addError($strProgram, $strError."\nReturn value: ".$return_value);
325
            }
294
            }
326
 
295
 
327
            return $return_value == 0;
296
            return $return_value == 0;
328
        }
297
        }
329
 
298
 
330
        return true;
299
        return true;
331
    }
300
    }
332
 
301
 
333
    /**
302
    /**
334
     * read a one-line value from a file with a similar name
303
     * read a one-line value from a file with a similar name
335
     *
304
     *
336
     * @return value if successfull or null if not
305
     * @return value if successfull or null if not
337
     */
306
     */
338
    public static function rolv($similarFileName, $match = "//", $replace = "")
307
    public static function rolv($similarFileName, $match = "//", $replace = "")
339
    {
308
    {
340
        $filename = preg_replace($match, $replace, $similarFileName);
309
        $filename = preg_replace($match, $replace, $similarFileName);
341
        if (self::fileexists($filename) && self::rfts($filename, $buf, 1, 4096, false) && (($buf=trim($buf)) != "")) {
310
        if (self::fileexists($filename) && self::rfts($filename, $buf, 1, 4096, false) && (($buf=trim($buf)) != "")) {
342
            return $buf;
311
            return $buf;
343
        } else {
312
        } else {
344
            return null;
313
            return null;
345
        }
314
        }
346
    }
315
    }
347
 
316
 
348
    /**
317
    /**
349
     * read data from array $_SERVER
318
     * read data from array $_SERVER
350
     *
319
     *
351
     * @param string $strElem    element of array
320
     * @param string $strElem    element of array
352
     * @param string &$strBuffer output of the command
321
     * @param string &$strBuffer output of the command
353
     *
322
     *
354
     * @return string
323
     * @return string
355
     */
324
     */
356
    public static function readenv($strElem, &$strBuffer)
325
    public static function readenv($strElem, &$strBuffer)
357
    {
326
    {
358
        $strBuffer = '';
327
        $strBuffer = '';
359
        if (PSI_OS == 'WINNT') { //case insensitive
328
        if (PSI_OS == 'WINNT') { //case insensitive
360
            if (isset($_SERVER)) {
329
            if (isset($_SERVER)) {
361
                foreach ($_SERVER as $index=>$value) {
330
                foreach ($_SERVER as $index=>$value) {
362
                    if (is_string($value) && (trim($value) !== '') && (strtolower($index) === strtolower($strElem))) {
331
                    if (is_string($value) && (trim($value) !== '') && (strtolower($index) === strtolower($strElem))) {
363
                        $strBuffer = $value;
332
                        $strBuffer = $value;
364
 
333
 
365
                        return true;
334
                        return true;
366
                    }
335
                    }
367
                }
336
                }
368
            }
337
            }
369
        } else {
338
        } else {
370
            if (isset($_SERVER[$strElem]) && is_string($value = $_SERVER[$strElem]) && (trim($value) !== '')) {
339
            if (isset($_SERVER[$strElem]) && is_string($value = $_SERVER[$strElem]) && (trim($value) !== '')) {
371
                $strBuffer = $value;
340
                $strBuffer = $value;
372
 
341
 
373
                return true;
342
                return true;
374
            }
343
            }
375
        }
344
        }
376
 
345
 
377
        return false;
346
        return false;
378
    }
347
    }
379
 
348
 
380
    /**
349
    /**
381
     * read a file and return the content as a string
350
     * read a file and return the content as a string
382
     *
351
     *
383
     * @param string  $strFileName name of the file which should be read
352
     * @param string  $strFileName name of the file which should be read
384
     * @param string  &$strRet     content of the file (reference)
353
     * @param string  &$strRet     content of the file (reference)
385
     * @param integer $intLines    control how many lines should be read
354
     * @param int     $intLines    control how many lines should be read
386
     * @param integer $intBytes    control how many bytes of each line should be read
355
     * @param int     $intBytes    control how many bytes of each line should be read
387
     * @param boolean $booErrorRep en- or disables the reporting of errors which should be logged
356
     * @param boolean $booErrorRep en- or disables the reporting of errors which should be logged
388
     *
357
     *
389
     * @return boolean command successfull or not
358
     * @return boolean command successfull or not
390
     */
359
     */
391
    public static function rfts($strFileName, &$strRet, $intLines = 0, $intBytes = 4096, $booErrorRep = true)
360
    public static function rfts($strFileName, &$strRet, $intLines = 0, $intBytes = 4096, $booErrorRep = true)
392
    {
361
    {
393
        if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && ((substr(PSI_LOG, 0, 1)=="-") || (substr(PSI_LOG, 0, 1)=="+"))) {
362
        if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && ((substr(PSI_LOG, 0, 1)=="-") || (substr(PSI_LOG, 0, 1)=="+"))) {
394
            $out = self::_parse_log_file("Reading: ".$strFileName);
363
            $out = self::_parse_log_file("Reading: ".$strFileName);
395
            if ($out == false) {
364
            if ($out == false) {
396
                if (substr(PSI_LOG, 0, 1)=="-") {
365
                if (substr(PSI_LOG, 0, 1)=="-") {
397
                    $strRet = '';
366
                    $strRet = '';
398
 
367
 
399
                    return false;
368
                    return false;
400
                }
369
                }
401
            } else {
370
            } else {
402
                $strRet = $out;
371
                $strRet = $out;
403
 
372
 
404
                return true;
373
                return true;
405
            }
374
            }
406
        }
375
        }
407
 
376
 
-
 
377
        if (PSI_ROOT_FILESYSTEM !== '') {
-
 
378
            $rfsinfo = "[".PSI_ROOT_FILESYSTEM."]";
-
 
379
        } else {
-
 
380
            $rfsinfo = '';
-
 
381
        }
-
 
382
 
408
        $strFile = "";
383
        $strFile = "";
409
        $intCurLine = 1;
384
        $intCurLine = 1;
410
        $error = PSI_Error::singleton();
385
        $error = PSI_Error::singleton();
411
        if (file_exists($strFileName)) {
386
        if (file_exists(PSI_ROOT_FILESYSTEM.$strFileName)) {
412
            if (is_readable($strFileName)) {
387
            if (is_readable(PSI_ROOT_FILESYSTEM.$strFileName)) {
413
                if ($fd = fopen($strFileName, 'r')) {
388
                if ($fd = fopen(PSI_ROOT_FILESYSTEM.$strFileName, 'r')) {
414
                    while (!feof($fd)) {
389
                    while (!feof($fd)) {
415
                        $strFile .= fgets($fd, $intBytes);
390
                        $strFile .= fgets($fd, $intBytes);
416
                        if ($intLines <= $intCurLine && $intLines != 0) {
391
                        if ($intLines <= $intCurLine && $intLines != 0) {
417
                            break;
392
                            break;
418
                        } else {
393
                        } else {
419
                            $intCurLine++;
394
                            $intCurLine++;
420
                        }
395
                        }
421
                    }
396
                    }
422
                    fclose($fd);
397
                    fclose($fd);
423
                    $strRet = $strFile;
398
                    $strRet = $strFile;
424
                    if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && (substr(PSI_LOG, 0, 1)!="-") && (substr(PSI_LOG, 0, 1)!="+")) {
399
                    if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && (substr(PSI_LOG, 0, 1)!="-") && (substr(PSI_LOG, 0, 1)!="+")) {
425
                        if ((strlen($strRet)>0)&&(substr($strRet, -1)!="\n")) {
400
                        if ((strlen($strRet)>0)&&(substr($strRet, -1)!="\n")) {
426
                            error_log("---".gmdate('r T')."--- Reading: ".$strFileName."\n".$strRet."\n", 3, PSI_LOG);
401
                            error_log("---".gmdate('r T')."--- Reading: ".$strFileName."\n".$strRet."\n", 3, PSI_LOG);
427
                        } else {
402
                        } else {
428
                            error_log("---".gmdate('r T')."--- Reading: ".$strFileName."\n".$strRet, 3, PSI_LOG);
403
                            error_log("---".gmdate('r T')."--- Reading: ".$strFileName."\n".$strRet, 3, PSI_LOG);
429
                        }
404
                        }
430
                    }
405
                    }
431
                } else {
406
                } else {
432
                    if ($booErrorRep) {
407
                    if ($booErrorRep) {
433
                        $error->addError('fopen('.$strFileName.')', 'file can not read by phpsysinfo');
408
                        $error->addError('fopen('.$rfsinfo.$strFileName.')', 'file can not read by phpsysinfo');
434
                    }
409
                    }
435
 
410
 
436
                    return false;
411
                    return false;
437
                }
412
                }
438
            } else {
413
            } else {
439
                if ($booErrorRep) {
414
                if ($booErrorRep) {
440
                    $error->addError('fopen('.$strFileName.')', 'file permission error');
415
                    $error->addError('fopen('.$rfsinfo.$strFileName.')', 'file permission error');
441
                }
416
                }
442
 
417
 
443
                return false;
418
                return false;
444
            }
419
            }
445
        } else {
420
        } else {
446
            if ($booErrorRep) {
421
            if ($booErrorRep) {
447
                $error->addError('file_exists('.$strFileName.')', 'the file does not exist on your machine');
422
                $error->addError('file_exists('.$rfsinfo.$strFileName.')', 'the file does not exist on your machine');
448
            }
423
            }
449
 
424
 
450
            return false;
425
            return false;
451
        }
426
        }
452
 
427
 
453
        return true;
428
        return true;
454
    }
429
    }
455
 
430
 
456
    /**
431
    /**
-
 
432
     * read a data file and return the content as a string
-
 
433
     *
-
 
434
     * @param string $strDataFileName name of the data file which should be read
-
 
435
     * @param string &$strRet         content of the data file (reference)
-
 
436
     *
-
 
437
     * @return boolean command successfull or not
-
 
438
     */
-
 
439
    public static function rftsdata($strDataFileName, &$strRet)
-
 
440
    {
-
 
441
        $strFile = "";
-
 
442
        $strFileName = PSI_APP_ROOT."/data/".$strDataFileName;
-
 
443
        $error = PSI_Error::singleton();
-
 
444
        if (file_exists($strFileName)) {
-
 
445
            if (is_readable($strFileName)) {
-
 
446
                if ($fd = fopen($strFileName, 'r')) {
-
 
447
                    while (!feof($fd)) {
-
 
448
                        $strFile .= fgets($fd, 4096);
-
 
449
                    }
-
 
450
                    fclose($fd);
-
 
451
                    $strRet = $strFile;
-
 
452
                } else {
-
 
453
                    $error->addError('fopen('.$strFileName.')', 'file can not read by phpsysinfo');
-
 
454
 
-
 
455
                    return false;
-
 
456
                }
-
 
457
            } else {
-
 
458
                $error->addError('fopen('.$strFileName.')', 'file permission error');
-
 
459
 
-
 
460
                return false;
-
 
461
            }
-
 
462
        } else {
-
 
463
            $error->addError('file_exists('.$strFileName.')', 'the file does not exist on your machine');
-
 
464
 
-
 
465
            return false;
-
 
466
        }
-
 
467
 
-
 
468
        return true;
-
 
469
    }
-
 
470
 
-
 
471
    /**
-
 
472
     * Find pathnames matching a pattern
-
 
473
     *
-
 
474
     * @param string $pattern the pattern. No tilde expansion or parameter substitution is done.
-
 
475
     * @param int    $flags
-
 
476
     *
-
 
477
     * @return an array containing the matched files/directories, an empty array if no file matched or false on error
-
 
478
     */
-
 
479
    public static function findglob($pattern, $flags = 0)
-
 
480
    {
-
 
481
        $outarr = glob(PSI_ROOT_FILESYSTEM.$pattern, $flags);
-
 
482
        if (PSI_ROOT_FILESYSTEM == '') {
-
 
483
            return $outarr;
-
 
484
        } elseif ($outarr === false) {
-
 
485
            return false;
-
 
486
        } else {
-
 
487
            $len = strlen(PSI_ROOT_FILESYSTEM);
-
 
488
            $newoutarr = array();
-
 
489
            foreach ($outarr as $out) {
-
 
490
                $newoutarr[] = substr($out, $len); // path without ROOTFS
-
 
491
            }
-
 
492
 
-
 
493
            return $newoutarr;
-
 
494
        }
-
 
495
    }
-
 
496
 
-
 
497
    /**
457
     * file exists
498
     * file exists
458
     *
499
     *
459
     * @param string $strFileName name of the file which should be check
500
     * @param string $strFileName name of the file which should be check
460
     *
501
     *
461
     * @return boolean command successfull or not
502
     * @return boolean command successfull or not
462
     */
503
     */
463
    public static function fileexists($strFileName)
504
    public static function fileexists($strFileName)
464
    {
505
    {
465
        if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && ((substr(PSI_LOG, 0, 1)=="-") || (substr(PSI_LOG, 0, 1)=="+"))) {
506
        if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && ((substr(PSI_LOG, 0, 1)=="-") || (substr(PSI_LOG, 0, 1)=="+"))) {
466
            $log_file = substr(PSI_LOG, 1);
507
            $log_file = substr(PSI_LOG, 1);
467
            if (file_exists($log_file)
508
            if (file_exists($log_file)
468
                && ($contents = @file_get_contents($log_file))
509
                && ($contents = @file_get_contents($log_file))
469
                && preg_match("/^\-\-\-[^-\n]+\-\-\- ".preg_quote("Reading: ".$strFileName, '/')."\n/m", $contents)) {
510
                && preg_match("/^\-\-\-[^-\n]+\-\-\- ".preg_quote("Reading: ".$strFileName, '/')."\n/m", $contents)) {
470
                return true;
511
                return true;
471
            } else {
512
            } else {
472
                if (substr(PSI_LOG, 0, 1)=="-") {
513
                if (substr(PSI_LOG, 0, 1)=="-") {
473
                    return false;
514
                    return false;
474
                }
515
                }
475
            }
516
            }
476
        }
517
        }
477
 
518
 
478
        $exists =  file_exists($strFileName);
519
        $exists =  file_exists(PSI_ROOT_FILESYSTEM.$strFileName);
479
        if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && (substr(PSI_LOG, 0, 1)!="-") && (substr(PSI_LOG, 0, 1)!="+")) {
520
        if (defined('PSI_LOG') && is_string(PSI_LOG) && (strlen(PSI_LOG)>0) && (substr(PSI_LOG, 0, 1)!="-") && (substr(PSI_LOG, 0, 1)!="+")) {
480
            if ((substr($strFileName, 0, 5) === "/dev/") && $exists) {
521
            if ((substr($strFileName, 0, 5) === "/dev/") && $exists) {
481
                error_log("---".gmdate('r T')."--- Reading: ".$strFileName."\ndevice exists\n", 3, PSI_LOG);
522
                error_log("---".gmdate('r T')."--- Reading: ".$strFileName."\ndevice exists\n", 3, PSI_LOG);
482
            }
523
            }
483
        }
524
        }
484
 
525
 
485
        return $exists;
526
        return $exists;
486
    }
527
    }
487
 
528
 
488
    /**
529
    /**
489
     * reads a directory and return the name of the files and directorys in it
530
     * reads a directory and return the name of the files and directorys in it
490
     *
531
     *
491
     * @param string  $strPath     path of the directory which should be read
532
     * @param string  $strPath     path of the directory which should be read
492
     * @param boolean $booErrorRep en- or disables the reporting of errors which should be logged
533
     * @param boolean $booErrorRep en- or disables the reporting of errors which should be logged
493
     *
534
     *
494
     * @return array content of the directory excluding . and ..
535
     * @return array content of the directory excluding . and ..
495
     */
536
     */
496
    public static function gdc($strPath, $booErrorRep = true)
537
    public static function gdc($strPath, $booErrorRep = true)
497
    {
538
    {
498
        $arrDirectoryContent = array();
539
        $arrDirectoryContent = array();
499
        $error = PSI_Error::singleton();
540
        $error = PSI_Error::singleton();
500
        if (is_dir($strPath)) {
541
        if (is_dir($strPath)) {
501
            if ($handle = opendir($strPath)) {
542
            if ($handle = opendir($strPath)) {
502
                while (($strFile = readdir($handle)) !== false) {
543
                while (($strFile = readdir($handle)) !== false) {
503
                    if ($strFile != "." && $strFile != "..") {
544
                    if ($strFile != "." && $strFile != "..") {
504
                        $arrDirectoryContent[] = $strFile;
545
                        $arrDirectoryContent[] = $strFile;
505
                    }
546
                    }
506
                }
547
                }
507
                closedir($handle);
548
                closedir($handle);
508
            } else {
549
            } else {
509
                if ($booErrorRep) {
550
                if ($booErrorRep) {
510
                    $error->addError('opendir('.$strPath.')', 'directory can not be read by phpsysinfo');
551
                    $error->addError('opendir('.$strPath.')', 'directory can not be read by phpsysinfo');
511
                }
552
                }
512
            }
553
            }
513
        } else {
554
        } else {
514
            if ($booErrorRep) {
555
            if ($booErrorRep) {
515
                $error->addError('is_dir('.$strPath.')', 'directory does not exist on your machine');
556
                $error->addError('is_dir('.$strPath.')', 'directory does not exist on your machine');
516
            }
557
            }
517
        }
558
        }
518
 
559
 
519
        return $arrDirectoryContent;
560
        return $arrDirectoryContent;
520
    }
561
    }
521
 
562
 
522
    /**
563
    /**
523
     * Check for needed php extensions
564
     * Check for needed php extensions
524
     *
565
     *
525
     * We need that extensions for almost everything
566
     * We need that extensions for almost everything
526
     * This function will return a hard coded
567
     * This function will return a hard coded
527
     * XML string (with headers) if the SimpleXML extension isn't loaded.
568
     * XML string (with headers) if the SimpleXML extension isn't loaded.
528
     * Then it will terminate the script.
569
     * Then it will terminate the script.
529
     * See bug #1787137
570
     * See bug #1787137
530
     *
571
     *
531
     * @param array $arrExt additional extensions for which a check should run
572
     * @param array $arrExt additional extensions for which a check should run
532
     *
573
     *
533
     * @return void
574
     * @return void
534
     */
575
     */
535
    public static function checkForExtensions($arrExt = array())
576
    public static function checkForExtensions($arrExt = array())
536
    {
577
    {
537
        if (defined('PSI_SYSTEM_CODEPAGE') && ((strcasecmp(PSI_SYSTEM_CODEPAGE, "UTF-8") == 0) || (strcasecmp(PSI_SYSTEM_CODEPAGE, "CP437") == 0)))
578
        if (defined('PSI_SYSTEM_CODEPAGE') && (PSI_SYSTEM_CODEPAGE !== null) && ((strcasecmp(PSI_SYSTEM_CODEPAGE, "UTF-8") == 0) || (strcasecmp(PSI_SYSTEM_CODEPAGE, "CP437") == 0)))
538
            $arrReq = array('simplexml', 'pcre', 'xml', 'dom');
579
            $arrReq = array('simplexml', 'pcre', 'xml', 'dom');
539
        elseif (PSI_OS == 'WINNT')
580
        elseif (PSI_OS == 'WINNT')
540
            $arrReq = array('simplexml', 'pcre', 'xml', 'dom', 'mbstring', 'com_dotnet');
581
            $arrReq = array('simplexml', 'pcre', 'xml', 'dom', 'mbstring', 'com_dotnet');
541
        else
582
        else
542
            $arrReq = array('simplexml', 'pcre', 'xml', 'dom', 'mbstring');
583
            $arrReq = array('simplexml', 'pcre', 'xml', 'dom', 'mbstring');
543
        $extensions = array_merge($arrExt, $arrReq);
584
        $extensions = array_merge($arrExt, $arrReq);
544
        $text = "";
585
        $text = "";
545
        $error = false;
586
        $error = false;
546
        $text .= "<?xml version='1.0'?>\n";
587
        $text .= "<?xml version='1.0'?>\n";
547
        $text .= "<phpsysinfo>\n";
588
        $text .= "<phpsysinfo>\n";
548
        $text .= "  <Error>\n";
589
        $text .= "  <Error>\n";
549
        foreach ($extensions as $extension) {
590
        foreach ($extensions as $extension) {
550
            if (!extension_loaded($extension)) {
591
            if (!extension_loaded($extension)) {
551
                $text .= "    <Function>checkForExtensions</Function>\n";
592
                $text .= "    <Function>checkForExtensions</Function>\n";
552
                $text .= "    <Message>phpSysInfo requires the ".$extension." extension to php in order to work properly.</Message>\n";
593
                $text .= "    <Message>phpSysInfo requires the ".$extension." extension to php in order to work properly.</Message>\n";
553
                $error = true;
594
                $error = true;
554
            }
595
            }
555
        }
596
        }
556
        $text .= "  </Error>\n";
597
        $text .= "  </Error>\n";
557
        $text .= "</phpsysinfo>";
598
        $text .= "</phpsysinfo>";
558
        if ($error) {
599
        if ($error) {
559
            header("Content-Type: text/xml\n\n");
600
            header('Content-Type: text/xml');
560
            echo $text;
601
            echo $text;
561
            die();
602
            die();
562
        }
603
        }
563
    }
604
    }
564
 
605
 
565
    /**
606
    /**
566
     * get the content of stdout/stderr with the option to set a timeout for reading
607
     * get the content of stdout/stderr with the option to set a timeout for reading
567
     *
608
     *
568
     * @param array   $pipes   array of file pointers for stdin, stdout, stderr (proc_open())
609
     * @param array  $pipes   array of file pointers for stdin, stdout, stderr (proc_open())
569
     * @param string  &$out    target string for the output message (reference)
610
     * @param string &$out    target string for the output message (reference)
570
     * @param string  &$err    target string for the error message (reference)
611
     * @param string &$err    target string for the error message (reference)
571
     * @param integer $timeout timeout value in seconds
612
     * @param int    $timeout timeout value in seconds
572
     *
613
     *
573
     * @return boolean timeout expired or not
614
     * @return boolean timeout expired or not
574
     */
615
     */
575
    private static function _timeoutfgets($pipes, &$out, &$err, $timeout)
616
    private static function _timeoutfgets($pipes, &$out, &$err, $timeout)
576
    {
617
    {
577
        $w = null;
618
        $w = null;
578
        $e = null;
619
        $e = null;
579
        $te = false;
620
        $te = false;
580
 
621
 
581
        if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN === true) {
622
        if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN) {
582
            $pipe2 = false;
623
            $pipe2 = false;
583
        } else {
624
        } else {
584
            $pipe2 = true;
625
            $pipe2 = true;
585
        }
626
        }
586
        while (!(feof($pipes[1]) && (!$pipe2 || feof($pipes[2])))) {
627
        while (!(feof($pipes[1]) && (!$pipe2 || feof($pipes[2])))) {
587
            if ($pipe2) {
628
            if ($pipe2) {
588
                $read = array($pipes[1], $pipes[2]);
629
                $read = array($pipes[1], $pipes[2]);
589
            } else {
630
            } else {
590
                $read = array($pipes[1]);
631
                $read = array($pipes[1]);
591
            }
632
            }
592
 
633
 
593
            $n = stream_select($read, $w, $e, $timeout);
634
            $n = stream_select($read, $w, $e, $timeout);
594
 
635
 
595
            if ($n === false) {
636
            if ($n === false) {
596
                error_log('stream_select: failed !');
637
                error_log('stream_select: failed !');
597
                break;
638
                break;
598
            } elseif ($n === 0) {
639
            } elseif ($n === 0) {
599
                error_log('stream_select: timeout expired !');
640
                error_log('stream_select: timeout expired !');
600
                $te = true;
641
                $te = true;
601
                break;
642
                break;
602
            }
643
            }
603
 
644
 
604
            foreach ($read as $r) {
645
            foreach ($read as $r) {
605
                if ($r == $pipes[1]) {
646
                if ($r == $pipes[1]) {
606
                    $out .= fread($r, 4096);
647
                    $out .= fread($r, 4096);
607
                } elseif (feof($pipes[1]) && $pipe2 && ($r == $pipes[2])) {//read STDERR after STDOUT
648
                } elseif (feof($pipes[1]) && $pipe2 && ($r == $pipes[2])) {//read STDERR after STDOUT
608
                    $err .= fread($r, 4096);
649
                    $err .= fread($r, 4096);
609
                }
650
                }
610
            }
651
            }
611
        }
652
        }
612
 
653
 
613
        return $te;
654
        return $te;
614
    }
655
    }
615
 
656
 
616
    /**
657
    /**
617
     * function for getting a list of values in the specified context
-
 
618
     * optionally filter this list, based on the list from third parameter
-
 
619
     *
-
 
620
     * @param $wmi object holds the COM object that we pull the WMI data from
-
 
621
     * @param string $strClass name of the class where the values are stored
-
 
622
     * @param array  $strValue filter out only needed values, if not set all values of the class are returned
-
 
623
     *
-
 
624
     * @return array content of the class stored in an array
-
 
625
     */
-
 
626
    public static function getWMI($wmi, $strClass, $strValue = array())
-
 
627
    {
-
 
628
        $arrData = array();
-
 
629
        if (gettype($wmi) === "object") {
-
 
630
            $value = "";
-
 
631
            try {
-
 
632
                $objWEBM = $wmi->Get($strClass);
-
 
633
                $arrProp = $objWEBM->Properties_;
-
 
634
                $arrWEBMCol = $objWEBM->Instances_();
-
 
635
                foreach ($arrWEBMCol as $objItem) {
-
 
636
                    if (is_array($arrProp)) {
-
 
637
                        reset($arrProp);
-
 
638
                    }
-
 
639
                    $arrInstance = array();
-
 
640
                    foreach ($arrProp as $propItem) {
-
 
641
                        $value = $objItem->{$propItem->Name}; //instead exploitable eval("\$value = \$objItem->".$propItem->Name.";");
-
 
642
                        if (empty($strValue)) {
-
 
643
                            if (is_string($value)) $arrInstance[$propItem->Name] = trim($value);
-
 
644
                            else $arrInstance[$propItem->Name] = $value;
-
 
645
                        } else {
-
 
646
                            if (in_array($propItem->Name, $strValue)) {
-
 
647
                                if (is_string($value)) $arrInstance[$propItem->Name] = trim($value);
-
 
648
                                else $arrInstance[$propItem->Name] = $value;
-
 
649
                            }
-
 
650
                        }
-
 
651
                    }
-
 
652
                    $arrData[] = $arrInstance;
-
 
653
                }
-
 
654
            } catch (Exception $e) {
-
 
655
                if (PSI_DEBUG) {
-
 
656
                    $error = PSI_Error::singleton();
-
 
657
                    $error->addError("getWMI()", preg_replace('/<br\/>/', "\n", preg_replace('/<b>|<\/b>/', '', $e->getMessage())));
-
 
658
                }
-
 
659
            }
-
 
660
        } elseif ((gettype($wmi) === "string") && (PSI_OS == 'Linux')) {
-
 
661
            $delimeter = '@@@DELIM@@@';
-
 
662
            if (self::executeProgram('wmic', '--delimiter="'.$delimeter.'" '.$wmi.' '.$strClass.'" 2>/dev/null', $strBuf, true) && preg_match("/^CLASS:\s/", $strBuf)) {
-
 
663
                if (self::$_cp) {
-
 
664
                    if (self::$_cp == 932) {
-
 
665
                        $codename = ' (SJIS)';
-
 
666
                    } elseif (self::$_cp == 949) {
-
 
667
                        $codename = ' (EUC-KR)';
-
 
668
                    } elseif (self::$_cp == 950) {
-
 
669
                        $codename = ' (BIG-5)';
-
 
670
                    } else {
-
 
671
                        $codename = '';
-
 
672
                    }
-
 
673
                    self::convertCP($strBuf, 'windows-'.self::$_cp.$codename);
-
 
674
                }
-
 
675
                $lines = preg_split('/\n/', $strBuf, -1, PREG_SPLIT_NO_EMPTY);
-
 
676
                if (count($lines) >=3) {
-
 
677
                    unset($lines[0]);
-
 
678
                    $names = preg_split('/'.$delimeter.'/', $lines[1], -1, PREG_SPLIT_NO_EMPTY);
-
 
679
                    $namesc = count($names);
-
 
680
                    unset($lines[1]);
-
 
681
                    foreach ($lines as $line) {
-
 
682
                        $arrInstance = array();
-
 
683
                        $values = preg_split('/'.$delimeter.'/', $line, -1);
-
 
684
                        if (count($values) == $namesc) {
-
 
685
                            foreach ($values as $id=>$value) {
-
 
686
                                if (empty($strValue)) {
-
 
687
                                    if ($value !== "(null)") $arrInstance[$names[$id]] = trim($value);
-
 
688
                                    else $arrInstance[$names[$id]] = null;
-
 
689
                                } else {
-
 
690
                                    if (in_array($names[$id], $strValue)) {
-
 
691
                                        if ($value !== "(null)") $arrInstance[$names[$id]] = trim($value);
-
 
692
                                        else $arrInstance[$names[$id]] = null;
-
 
693
                                    }
-
 
694
                                }
-
 
695
                            }
-
 
696
                            $arrData[] = $arrInstance;
-
 
697
                        }
-
 
698
                    }
-
 
699
                }
-
 
700
            }
-
 
701
        }
-
 
702
 
-
 
703
        return $arrData;
-
 
704
    }
-
 
705
 
-
 
706
    /**
-
 
707
     * get all configured plugins from phpsysinfo.ini (file must be included and processed before calling this function)
658
     * get all configured plugins from phpsysinfo.ini (file must be included and processed before calling this function)
708
     *
659
     *
709
     * @return array
660
     * @return array
710
     */
661
     */
711
    public static function getPlugins()
662
    public static function getPlugins()
712
    {
663
    {
713
        if (defined('PSI_PLUGINS') && is_string(PSI_PLUGINS)) {
664
        if (defined('PSI_PLUGINS') && is_string(PSI_PLUGINS)) {
714
            if (preg_match(ARRAY_EXP, PSI_PLUGINS)) {
665
            if (preg_match(ARRAY_EXP, PSI_PLUGINS)) {
715
                return eval(strtolower(PSI_PLUGINS));
666
                return eval(strtolower(PSI_PLUGINS));
716
            } else {
667
            } else {
717
                return array(strtolower(PSI_PLUGINS));
668
                return array(strtolower(PSI_PLUGINS));
718
            }
669
            }
719
        } else {
670
        } else {
720
            return array();
671
            return array();
721
        }
672
        }
722
    }
673
    }
723
 
674
 
724
    /**
675
    /**
725
     * name natural compare function
676
     * name natural compare function
726
     *
677
     *
727
     * @return comprasion result
678
     * @return comprasion result
728
     */
679
     */
729
    public static function name_natural_compare($a, $b)
680
    public static function name_natural_compare($a, $b)
730
    {
681
    {
731
        return strnatcmp($a->getName(), $b->getName());
682
        return strnatcmp($a->getName(), $b->getName());
732
    }
683
    }
733
 
684
 
734
    /**
685
    /**
735
     * readReg function
686
     * get virtualizer from dmi data
736
     *
687
     *
737
     * @return boolean command successfull or not
688
     * @return string|null
738
     */
689
     */
739
    public static function readReg($reg, $strName, &$strBuffer, $booErrorRep = true)
690
    public static function decodevirtualizer($vendor_data)
740
    {
691
    {
741
        $arrBuffer = array();
692
        if (gettype($vendor_data) === "array") {
742
        $_hkey = array('HKEY_CLASSES_ROOT'=>0x80000000, 'HKEY_CURRENT_USER'=>0x80000001, 'HKEY_LOCAL_MACHINE'=>0x80000002, 'HKEY_USERS'=>0x80000003, 'HKEY_PERFORMANCE_DATA'=>0x80000004, 'HKEY_PERFORMANCE_TEXT'=>0x80000050, 'HKEY_PERFORMANCE_NLSTEXT'=>0x80000060, 'HKEY_CURRENT_CONFIG'=>0x80000005, 'HKEY_DYN_DATA'=>0x80000006);
693
            $vendarray = array(
743
 
-
 
744
        if ($reg === false) {
694
                'KVM' => 'kvm', // KVM
745
            if (defined('PSI_EMU_HOSTNAME')) {
695
                'Amazon EC2' => 'amazon', // Amazon EC2 Nitro using Linux KVM
746
                return false;
696
                'QEMU' => 'qemu', // QEMU
747
            }
-
 
748
            $last = strrpos($strName, "\\");
-
 
749
            $keyname = substr($strName, $last + 1);
697
                'VMware' => 'vmware', // VMware https://kb.vmware.com/s/article/1009458
750
            if (self::$_cp) {
698
                'VMW' => 'vmware',
751
                if (self::executeProgram('cmd', '/c chcp '.self::$_cp.' >nul & reg query "'.substr($strName, 0, $last).'" /v '.$keyname.' 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match("/^\s*".$keyname."\s+REG_\S+\s+(.+)\s*$/mi", $strBuf, $buffer2)) {
699
                'innotek GmbH' => 'oracle', // Oracle VM VirtualBox
752
                    $strBuffer = $buffer2[1];
700
                'VirtualBox' => 'oracle',
753
                } else {
701
                'Xen' => 'xen', // Xen hypervisor
754
                    return false;
702
                'Bochs' => 'bochs', // Bochs
755
                }
-
 
756
            } else {
703
                'Parallels' => 'parallels', // Parallels
757
                if (self::executeProgram('reg', 'query "'.substr($strName, 0, $last).'" /v '.$keyname.' 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match("/^\s*".$keyname."\s+REG_\S+\s+(.+)\s*$/mi", $strBuf, $buffer2)) {
-
 
758
                    $strBuffer = $buffer2[1];
704
                // https://wiki.freebsd.org/bhyve
759
                } else {
705
                'BHYVE' => 'bhyve', // bhyve
760
                    return false;
706
                'Hyper-V' => 'microsoft', // Hyper-V
761
                }
707
                'Microsoft Corporation Virtual Machine' => 'microsoft' // Hyper-V
762
            }
708
            );
763
        } elseif (gettype($reg) === "object") {
-
 
764
            $first = strpos($strName, "\\");
709
            for ($i = 0; $i < count($vendor_data); $i++) {
765
            $last = strrpos($strName, "\\");
-
 
766
            $hkey = substr($strName, 0, $first);
710
                foreach ($vendarray as $vend=>$virt) {
767
            if (isset($_hkey[$hkey])) {
-
 
768
                $sub_keys = new VARIANT();
-
 
769
                try {
-
 
770
                    $reg->Get("StdRegProv")->GetStringValue(strval($_hkey[$hkey]), substr($strName, $first+1, $last-$first-1), substr($strName, $last+1), $sub_keys);
-
 
771
                } catch (Exception $e) {
711
                    if (preg_match('/^'.$vend.'/', $vendor_data[$i])) {
772
                    if ($booErrorRep) {
712
                        return $virt;
773
                        $error = PSI_Error::singleton();
-
 
774
                        $error->addError("GetStringValue()", preg_replace('/<br\/>/', "\n", preg_replace('/<b>|<\/b>/', '', $e->getMessage())));
-
 
775
                    }
713
                    }
776
 
-
 
777
                    return false;
-
 
778
                }
714
                }
-
 
715
            }
779
                if (variant_get_type($sub_keys) !== VT_NULL) {
716
        } elseif (gettype($vendor_data) === "string") {
-
 
717
            $vidarray = array(
780
                    $strBuffer = strval($sub_keys);
718
                'bhyvebhyve' => 'bhyve', // bhyve
781
                } else {
719
                'KVMKVMKVM' => 'kvm', // KVM
-
 
720
                'MicrosoftHv' => 'microsoft', // Hyper-V
782
                    return false;
721
                'lrpepyhvr' => 'parallels', // Parallels
-
 
722
                'UnisysSpar64' => 'spar', // Unisys sPar
-
 
723
                'VMwareVMware' => 'vmware', // VMware
-
 
724
                'XenVMMXenVMM' => 'xen', // Xen hypervisor
-
 
725
                'ACRNACRNACRN' => 'acrn', // ACRN hypervisor
783
                }
726
                'TCGTCGTCGTCG' => 'qemu', // QEMU
-
 
727
                'QNXQVMBSQG' => 'qnx', // QNX hypervisor
-
 
728
                'VBoxVBoxVBox' => 'oracle' // Oracle VM VirtualBox
784
            } else {
729
            );
-
 
730
            $shortvendorid = trim(preg_replace('/[\s!\.]/', '', $vendor_data));
-
 
731
            if (($shortvendorid !== "") && isset($vidarray[$shortvendorid])) {
785
               return false;
732
                return $vidarray[$shortvendorid];
786
            }
733
            }
787
        }
734
        }
788
 
735
 
789
        return true;
736
        return null;
790
    }
737
    }
791
 
738
 
-
 
739
 
792
    /**
740
    /**
793
     * enumKey function
741
     * readdmimemdata function
794
     *
742
     *
795
     * @return boolean command successfull or not
743
     * @return array
796
     */
744
     */
797
    public static function enumKey($reg, $strName, &$arrBuffer, $booErrorRep = true)
745
    public static function readdmimemdata()
798
    {
746
    {
-
 
747
        if ((PSI_OS != 'WINNT') && !defined('PSI_EMU_HOSTNAME') && (self::$_dmimd === null)) {
-
 
748
            self::$_dmimd = array();
799
        $arrBuffer = array();
749
            $buffer = '';
800
        $_hkey = array('HKEY_CLASSES_ROOT'=>0x80000000, 'HKEY_CURRENT_USER'=>0x80000001, 'HKEY_LOCAL_MACHINE'=>0x80000002, 'HKEY_USERS'=>0x80000003, 'HKEY_PERFORMANCE_DATA'=>0x80000004, 'HKEY_PERFORMANCE_TEXT'=>0x80000050, 'HKEY_PERFORMANCE_NLSTEXT'=>0x80000060, 'HKEY_CURRENT_CONFIG'=>0x80000005, 'HKEY_DYN_DATA'=>0x80000006);
750
            if (defined('PSI_DMIDECODE_ACCESS') && (strtolower(PSI_DMIDECODE_ACCESS)==='data')) {
801
 
-
 
802
        if ($reg === false) {
751
                self::rftsdata('dmidecode.tmp', $buffer);
803
            if (defined('PSI_EMU_HOSTNAME')) {
752
            } elseif (self::_findProgram('dmidecode')) {
804
                return false;
753
                self::executeProgram('dmidecode', '-t 17', $buffer, PSI_DEBUG);
805
            }
754
            }
806
            if (self::$_cp) {
755
            if (!empty($buffer)) {
807
                if (self::executeProgram('cmd', '/c chcp '.self::$_cp.' >nul & reg query "'.$strName.'" 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match_all("/^".preg_replace("/\\\\/", "\\\\\\\\", $strName)."\\\\(.*)/mi", $strBuf, $buffer2)) {
756
                $banks = preg_split('/^(?=Handle\s)/m', $buffer, -1, PREG_SPLIT_NO_EMPTY);
808
                    foreach ($buffer2[1] as $sub_key) {
757
                foreach ($banks as $bank) if (preg_match('/^Handle\s/', $bank)) {
809
                        $arrBuffer[] = trim($sub_key);
758
                    $lines = preg_split("/\n/", $bank, -1, PREG_SPLIT_NO_EMPTY);
810
                    }
759
                    $mem = array();
811
                } else {
760
                    foreach ($lines as $line) if (preg_match('/^\s+([^:]+):(.+)/', $line, $params)) {
812
                    return false;
761
                        if (preg_match('/^0x([A-F\d]+)/', $params2 = trim($params[2]), $buff)) {
813
                }
762
                            $mem[trim($params[1])] = trim($buff[1]);
814
            } else {
763
                        } elseif ($params2 != '') {
815
                if (self::executeProgram('reg', 'query "'.$strName.'" 2>&1', $strBuf, $booErrorRep) && (strlen($strBuf) > 0) && preg_match_all("/^".preg_replace("/\\\\/", "\\\\\\\\", $strName)."\\\\(.*)/mi", $strBuf, $buffer2)) {
-
 
816
                    foreach ($buffer2[1] as $sub_key) {
764
                            $mem[trim($params[1])] = $params2;
817
                        $arrBuffer[] = trim($sub_key);
765
                        }
818
                    }
766
                    }
819
                } else {
-
 
820
                    return false;
-
 
821
                }
-
 
822
            }
-
 
823
        } elseif (gettype($reg) === "object") {
-
 
824
            $first = strpos($strName, "\\");
-
 
825
            $hkey = substr($strName, 0, $first);
-
 
826
            if (isset($_hkey[$hkey])) {
-
 
827
                $sub_keys = new VARIANT();
-
 
828
                try {
-
 
829
                   $reg->Get("StdRegProv")->EnumKey(strval($_hkey[$hkey]), substr($strName, $first+1), $sub_keys);
-
 
830
                } catch (Exception $e) {
-
 
831
                    if ($booErrorRep) {
767
                    if (!empty($mem)) {
832
                        $error = PSI_Error::singleton();
768
                        self::$_dmimd[] = $mem;
833
                        $error->addError("enumKey()", preg_replace('/<br\/>/', "\n", preg_replace('/<b>|<\/b>/', '', $e->getMessage())));;
-
 
834
                    }
769
                    }
835
 
-
 
836
                    return false;
-
 
837
                }
-
 
838
                if (variant_get_type($sub_keys) !== VT_NULL) foreach ($sub_keys as $sub_key) {
-
 
839
                    $arrBuffer[] = $sub_key;
-
 
840
                } else {
-
 
841
                    return false;
-
 
842
                }
770
                }
843
            } else {
-
 
844
               return false;
-
 
845
            }
771
            }
846
        }
772
        }
847
 
773
 
848
        return true;
-
 
849
    }
-
 
850
 
-
 
851
 
-
 
852
    /**
-
 
853
     * initWMI function
-
 
854
     *
-
 
855
     * @return string, object or false
-
 
856
     */
-
 
857
    public static function initWMI($namespace, $booErrorRep = false)
-
 
858
    {
-
 
859
        $wmi = false;
-
 
860
        try {
-
 
861
            if (PSI_OS == 'Linux') {
-
 
862
                if (defined('PSI_EMU_HOSTNAME'))
-
 
863
                    $wmi = '--namespace="'.$namespace.'" -U '.PSI_EMU_USER.'%'.PSI_EMU_PASSWORD.' //'.PSI_EMU_HOSTNAME.' "select * from';
-
 
864
            } elseif (PSI_OS == 'WINNT') {
-
 
865
                $objLocator = new COM('WbemScripting.SWbemLocator');
-
 
866
                if (defined('PSI_EMU_HOSTNAME'))
-
 
867
                    $wmi = $objLocator->ConnectServer(PSI_EMU_HOSTNAME, $namespace, PSI_EMU_USER, PSI_EMU_PASSWORD);
-
 
868
                else
-
 
869
                    $wmi = $objLocator->ConnectServer('', $namespace);
-
 
870
            }
-
 
871
        } catch (Exception $e) {
-
 
872
            if ($booErrorRep) {
-
 
873
                $error = PSI_Error::singleton();
-
 
874
                $error->addError("WMI connect ".$namespace." error", "PhpSysInfo can not connect to the WMI interface for security reasons.\nCheck an authentication mechanism for the directory where phpSysInfo is installed or credentials.");
-
 
875
            }
-
 
876
        }
-
 
877
 
-
 
878
        return $wmi;
774
        return self::$_dmimd;
879
    }
-
 
880
 
-
 
881
    /**
-
 
882
     * convertCP function
-
 
883
     *
-
 
884
     * @return void
-
 
885
     */
-
 
886
    public static function convertCP(&$strBuf, $encoding)
-
 
887
    {
-
 
888
        if (defined('PSI_SYSTEM_CODEPAGE') && ($encoding != null) && ($encoding != PSI_SYSTEM_CODEPAGE)) {
-
 
889
            $systemcp = PSI_SYSTEM_CODEPAGE;
-
 
890
            if (preg_match("/^windows-\d+ \((.+)\)$/", $systemcp, $buf)) {
-
 
891
                $systemcp = $buf[1];
-
 
892
            }
-
 
893
            if (preg_match("/^windows-\d+ \((.+)\)$/", $encoding, $buf)) {
-
 
894
                $encoding = $buf[1];
-
 
895
            }
-
 
896
            $enclist = mb_list_encodings();
-
 
897
            if (in_array($encoding, $enclist) && in_array($systemcp, $enclist)) {
-
 
898
                $strBuf = mb_convert_encoding($strBuf, $encoding, $systemcp);
-
 
899
            } elseif (function_exists("iconv")) {
-
 
900
                if (($iconvout=iconv($systemcp, $encoding.'//IGNORE', $strBuf))!==false) {
-
 
901
                    $strBuf = $iconvout;
-
 
902
                }
-
 
903
            } elseif (function_exists("libiconv") && (($iconvout=libiconv($systemcp, $encoding, $strBuf))!==false)) {
-
 
904
                $strBuf = $iconvout;
-
 
905
            }
-
 
906
        }
-
 
907
    }
775
    }
908
}
776
}
909
 
777