Subversion Repositories ALCASAR

Rev

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

Rev 1764 Rev 2770
Line 1... Line 1...
1
<?php 
1
<?php
-
 
2
/**
-
 
3
 * Linux System Class
-
 
4
 *
-
 
5
 * PHP version 5
-
 
6
 *
-
 
7
 * @category  PHP
2
// phpSysInfo - A PHP System Information Script
8
 * @package   PSI Linux OS class
-
 
9
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
-
 
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
-
 
12
 * @version   SVN: $Id: class.Linux.inc.php 712 2012-12-05 14:09:18Z namiltd $
3
// http://phpsysinfo.sourceforge.net/
13
 * @link      http://phpsysinfo.sourceforge.net
-
 
14
 */
-
 
15
 /**
-
 
16
 * Linux sysinfo class
4
// This program is free software; you can redistribute it and/or
17
 * get all the required information from Linux system
-
 
18
 *
-
 
19
 * @category  PHP
-
 
20
 * @package   PSI Linux OS class
5
// modify it under the terms of the GNU General Public License
21
 * @author    Michael Cramer <BigMichi1@users.sourceforge.net>
-
 
22
 * @copyright 2009 phpSysInfo
-
 
23
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
-
 
24
 * @version   Release: 3.0
6
// as published by the Free Software Foundation; either version 2
25
 * @link      http://phpsysinfo.sourceforge.net
-
 
26
 */
-
 
27
class Linux extends OS
-
 
28
{
-
 
29
    /**
7
// of the License, or (at your option) any later version.
30
     * Assoc array of all CPUs loads.
-
 
31
     */
-
 
32
    protected $_cpu_loads;
-
 
33
 
-
 
34
    /**
-
 
35
     * Machine
-
 
36
     *
-
 
37
     * @return void
-
 
38
     */
-
 
39
    private function _machine()
-
 
40
    {
-
 
41
        $machine = "";
8
// This program is distributed in the hope that it will be useful,
42
        if ((CommonFunctions::rfts('/var/log/dmesg', $result, 0, 4096, false)
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
43
              && preg_match('/^[\s\[\]\.\d]*DMI:\s*(.*)/m', $result, $ar_buf))
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
44
           ||(CommonFunctions::executeProgram('dmesg', '', $result, false)
-
 
45
              && preg_match('/^[\s\[\]\.\d]*DMI:\s*(.*)/m', $result, $ar_buf))) {
11
// GNU General Public License for more details.
46
            $machine = trim($ar_buf[1]);
12
// You should have received a copy of the GNU General Public License
47
        } else { //data from /sys/devices/virtual/dmi/id/
-
 
48
            $product = "";
-
 
49
            $board = "";
-
 
50
            $bios = "";
-
 
51
            if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_vendor', $buf, 1, 4096, false) && (trim($buf)!="")) {
-
 
52
                $machine = trim($buf);
-
 
53
            }
-
 
54
            if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/product_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
13
// along with this program; if not, write to the Free Software
55
                $product = trim($buf);
-
 
56
            }
-
 
57
            if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/board_name', $buf, 1, 4096, false) && (trim($buf)!="")) {
-
 
58
                $board = trim($buf);
-
 
59
            }
-
 
60
            if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_version', $buf, 1, 4096, false) && (trim($buf)!="")) {
-
 
61
                $bios = trim($buf);
-
 
62
            }
14
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
63
            if (CommonFunctions::rfts('/sys/devices/virtual/dmi/id/bios_date', $buf, 1, 4096, false) && (trim($buf)!="")) {
15
// $Id: class.Linux.inc.php,v 1.88 2007/02/25 20:50:52 bigmichi1 Exp $
64
                $bios = trim($bios." ".trim($buf));
-
 
65
            }
-
 
66
            if ($product != "") {
-
 
67
                $machine .= " ".$product;
-
 
68
            }
-
 
69
            if ($board != "") {
-
 
70
                $machine .= "/".$board;
-
 
71
            }
-
 
72
            if ($bios != "") {
-
 
73
                $machine .= ", BIOS ".$bios;
-
 
74
            }
-
 
75
        }
16
 
76
 
-
 
77
        if ($machine != "") {
-
 
78
            $machine = trim(preg_replace("/^\/,?/", "", preg_replace("/ ?(To be filled by O\.E\.M\.|System manufacturer|System Product Name|Not Specified) ?/i", "", $machine)));
-
 
79
        }
-
 
80
 
-
 
81
        if (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf") // QNAP detection
-
 
82
           && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
-
 
83
           && preg_match("/^Rsync\sModel\s*=\s*QNAP/m", $buf)
-
 
84
           && CommonFunctions::fileexists($filename="/etc/platform.conf") // Platform detection
-
 
85
           && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
-
 
86
           && preg_match("/^DISPLAY_NAME\s*=\s*(\S+)/m", $buf, $mach_buf) && ($mach_buf[1]!=="")) {
-
 
87
            if ($machine != "") {
-
 
88
                $machine = "QNAP ".$mach_buf[1].' - '.$machine;
-
 
89
            } else {
-
 
90
                $machine = "QNAP ".$mach_buf[1];
-
 
91
            }
-
 
92
        }
-
 
93
 
-
 
94
        if ($machine != "") {
-
 
95
            $this->sys->setMachine($machine);
-
 
96
        }
-
 
97
    }
-
 
98
 
-
 
99
    /**
-
 
100
     * Hostname
-
 
101
     *
-
 
102
     * @return void
-
 
103
     */
-
 
104
    protected function _hostname()
-
 
105
    {
17
if (!defined('IN_PHPSYSINFO')) {
106
        if (PSI_USE_VHOST === true) {
-
 
107
            if (CommonFunctions::readenv('SERVER_NAME', $hnm)) $this->sys->setHostname($hnm);
-
 
108
        } else {
-
 
109
            if (CommonFunctions::rfts('/proc/sys/kernel/hostname', $result, 1, 4096, PSI_DEBUG && (PSI_OS != 'Android'))) {
-
 
110
                $result = trim($result);
-
 
111
                $ip = gethostbyname($result);
-
 
112
                if ($ip != $result) {
-
 
113
                    $this->sys->setHostname(gethostbyaddr($ip));
-
 
114
                }
-
 
115
            } elseif (CommonFunctions::executeProgram('hostname', '', $ret)) {
-
 
116
                $this->sys->setHostname($ret);
-
 
117
            }
-
 
118
 
-
 
119
        }
-
 
120
    }
-
 
121
 
-
 
122
    /**
-
 
123
     * Kernel Version
-
 
124
     *
-
 
125
     * @return void
-
 
126
     */
-
 
127
    private function _kernel()
-
 
128
    {
-
 
129
        $result = "";
-
 
130
        if (CommonFunctions::executeProgram($uname="uptrack-uname", '-r', $strBuf, false) || // show effective kernel if ksplice uptrack is installed
-
 
131
            CommonFunctions::executeProgram($uname="uname", '-r', $strBuf, PSI_DEBUG)) {
-
 
132
            $result = $strBuf;
-
 
133
            if (CommonFunctions::executeProgram($uname, '-v', $strBuf, PSI_DEBUG)) {
-
 
134
                if (preg_match('/SMP/', $strBuf)) {
-
 
135
                    $result .= ' (SMP)';
-
 
136
                }
-
 
137
            }
-
 
138
            if (CommonFunctions::executeProgram($uname, '-m', $strBuf, PSI_DEBUG)) {
-
 
139
                $result .= ' '.$strBuf;
-
 
140
            }
-
 
141
        } elseif (CommonFunctions::rfts('/proc/version', $strBuf, 1) &&  preg_match('/version\s+(\S+)/', $strBuf, $ar_buf)) {
-
 
142
            $result = $ar_buf[1];
-
 
143
            if (preg_match('/SMP/', $strBuf)) {
-
 
144
                $result .= ' (SMP)';
-
 
145
            }
-
 
146
        }
-
 
147
        if ($result != "") {
-
 
148
            if (CommonFunctions::rfts('/proc/self/cgroup', $strBuf2, 0, 4096, false)) {
-
 
149
                if (preg_match('/:\/lxc\//m', $strBuf2)) {
-
 
150
                    $result .= ' [lxc]';
-
 
151
                } elseif (preg_match('/:\/docker\//m', $strBuf2)) {
-
 
152
                    $result .= ' [docker]';
-
 
153
                } elseif (preg_match('/:\/system\.slice\/docker\-/m', $strBuf2)) {
-
 
154
                    $result .= ' [docker]';
-
 
155
                }
-
 
156
            }
-
 
157
            if (CommonFunctions::rfts('/proc/version', $strBuf2, 1, 4096, false)
-
 
158
                && preg_match('/^Linux version [\d\.-]+-Microsoft/', $strBuf2)) {
-
 
159
                    $result .= ' [lxss]';
-
 
160
            }
-
 
161
            $this->sys->setKernel($result);
-
 
162
        }
-
 
163
    }
-
 
164
 
-
 
165
    /**
-
 
166
     * UpTime
-
 
167
     * time the system is running
-
 
168
     *
-
 
169
     * @return void
-
 
170
     */
-
 
171
    protected function _uptime()
-
 
172
    {
-
 
173
        if (CommonFunctions::rfts('/proc/uptime', $buf, 1, 4096, PSI_OS != 'Android')) {
-
 
174
            $ar_buf = preg_split('/ /', $buf);
-
 
175
            $this->sys->setUptime(trim($ar_buf[0]));
-
 
176
        } elseif (CommonFunctions::executeProgram('uptime', '', $buf)) {
-
 
177
            if (preg_match("/up (\d+) day[s]?,[ ]+(\d+):(\d+),/", $buf, $ar_buf)) {
-
 
178
                $min = $ar_buf[3];
-
 
179
                $hours = $ar_buf[2];
-
 
180
                $days = $ar_buf[1];
-
 
181
                $this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
-
 
182
            } elseif (preg_match("/up (\d+) day[s]?,[ ]+(\d+) min,/", $buf, $ar_buf)) {
-
 
183
                $min = $ar_buf[2];
-
 
184
                $days = $ar_buf[1];
-
 
185
                $this->sys->setUptime($days * 86400 + $min * 60);
-
 
186
            } elseif (preg_match("/up[ ]+(\d+):(\d+),/", $buf, $ar_buf)) {
-
 
187
                $min = $ar_buf[2];
-
 
188
                $hours = $ar_buf[1];
-
 
189
                $this->sys->setUptime($hours * 3600 + $min * 60);
-
 
190
            } elseif (preg_match("/up[ ]+(\d+) min,/", $buf, $ar_buf)) {
-
 
191
                $min = $ar_buf[1];
-
 
192
                $this->sys->setUptime($min * 60);
-
 
193
            }
-
 
194
        }
-
 
195
    }
-
 
196
 
-
 
197
    /**
-
 
198
     * Processor Load
-
 
199
     * optionally create a loadbar
-
 
200
     *
-
 
201
     * @return void
-
 
202
     */
-
 
203
    protected function _loadavg()
-
 
204
    {
-
 
205
        if (CommonFunctions::rfts('/proc/loadavg', $buf, 1, 4096, PSI_OS != 'Android')) {
-
 
206
            $result = preg_split("/\s/", $buf, 4);
-
 
207
            // don't need the extra values, only first three
-
 
208
            unset($result[3]);
-
 
209
            $this->sys->setLoad(implode(' ', $result));
-
 
210
        } elseif (CommonFunctions::executeProgram('uptime', '', $buf) && preg_match("/load average: (.*), (.*), (.*)$/", $buf, $ar_buf)) {
-
 
211
            $this->sys->setLoad($ar_buf[1].' '.$ar_buf[2].' '.$ar_buf[3]);
-
 
212
        }
-
 
213
        if (PSI_LOAD_BAR) {
-
 
214
            $this->sys->setLoadPercent($this->_parseProcStat('cpu'));
-
 
215
        }
-
 
216
    }
-
 
217
 
-
 
218
    /**
-
 
219
     * fill the load for a individual cpu, through parsing /proc/stat for the specified cpu
-
 
220
     *
-
 
221
     * @param String $cpuline cpu for which load should be meassured
-
 
222
     *
-
 
223
     * @return Integer
-
 
224
     */
-
 
225
    protected function _parseProcStat($cpuline)
-
 
226
    {
-
 
227
        if (is_null($this->_cpu_loads)) {
-
 
228
            $this->_cpu_loads = array();
-
 
229
 
-
 
230
            $cpu_tmp = array();
-
 
231
            if (CommonFunctions::rfts('/proc/stat', $buf)) {
-
 
232
                if (preg_match_all('/^(cpu[0-9]*) (.*)/m', $buf, $matches, PREG_SET_ORDER)) {
-
 
233
                    foreach ($matches as $line) {
-
 
234
                        $cpu = $line[1];
-
 
235
                        $buf2 = $line[2];
-
 
236
 
-
 
237
                        $cpu_tmp[$cpu] = array();
-
 
238
 
-
 
239
                        $ab = 0;
-
 
240
                        $ac = 0;
-
 
241
                        $ad = 0;
-
 
242
                        $ae = 0;
-
 
243
                        sscanf($buf2, "%Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae);
-
 
244
                        $cpu_tmp[$cpu]['load'] = $ab + $ac + $ad; // cpu.user + cpu.sys
-
 
245
                        $cpu_tmp[$cpu]['total'] = $ab + $ac + $ad + $ae; // cpu.total
-
 
246
                    }
-
 
247
                }
-
 
248
 
-
 
249
                // we need a second value, wait 1 second befor getting (< 1 second no good value will occour)
-
 
250
                sleep(1);
-
 
251
 
-
 
252
                if (CommonFunctions::rfts('/proc/stat', $buf)) {
-
 
253
                    if (preg_match_all('/^(cpu[0-9]*) (.*)/m', $buf, $matches, PREG_SET_ORDER)) {
-
 
254
                        foreach ($matches as $line) {
-
 
255
                            $cpu = $line[1];
-
 
256
                            if (isset($cpu_tmp[$cpu])) {
-
 
257
                                $buf2 = $line[2];
-
 
258
 
-
 
259
                                $ab = 0;
-
 
260
                                $ac = 0;
-
 
261
                                $ad = 0;
-
 
262
                                $ae = 0;
-
 
263
                                sscanf($buf2, "%Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae);
-
 
264
                                $load2 = $ab + $ac + $ad; // cpu.user + cpu.sys
-
 
265
                                $total2 = $ab + $ac + $ad + $ae; // cpu.total
-
 
266
                                $total = $cpu_tmp[$cpu]['total'];
-
 
267
                                $load = $cpu_tmp[$cpu]['load'];
-
 
268
                                $this->_cpu_loads[$cpu] = 0;
-
 
269
                                if ($total > 0 && $total2 > 0 && $load > 0 && $load2 > 0 && $total2 != $total && $load2 != $load) {
-
 
270
                                    $this->_cpu_loads[$cpu] = (100 * ($load2 - $load)) / ($total2 - $total);
-
 
271
                                }
-
 
272
                            }
-
 
273
                        }
-
 
274
                    }
-
 
275
                }
-
 
276
            }
-
 
277
        }
-
 
278
 
-
 
279
        if (isset($this->_cpu_loads[$cpuline])) {
-
 
280
            return $this->_cpu_loads[$cpuline];
-
 
281
        } else {
18
    die("No Hacking");
282
            return 0;
-
 
283
        }
-
 
284
    }
-
 
285
 
-
 
286
    /**
-
 
287
     * CPU information
-
 
288
     * All of the tags here are highly architecture dependant.
-
 
289
     *
-
 
290
     * @return void
-
 
291
     */
-
 
292
    protected function _cpuinfo()
-
 
293
    {
-
 
294
        if (CommonFunctions::rfts('/proc/cpuinfo', $bufr)) {
-
 
295
            $cpulist = null;
-
 
296
            $raslist = null;
-
 
297
 
-
 
298
            // sparc
-
 
299
            if (preg_match('/\nCpu(\d+)Bogo\s*:/i', $bufr)) {
-
 
300
                $bufr = preg_replace('/\nCpu(\d+)ClkTck\s*:/i', "\nCpu0ClkTck:", preg_replace('/\nCpu(\d+)Bogo\s*:/i', "\n\nprocessor: $1\nCpu0Bogo:", $bufr));
-
 
301
            } else {
-
 
302
                $bufr = preg_replace('/\nCpu(\d+)ClkTck\s*:/i', "\n\nprocessor: $1\nCpu0ClkTck:", $bufr);
-
 
303
            }
-
 
304
 
-
 
305
            if (preg_match('/\nprocessor\s*:\s*\d+\r?\nprocessor\s*:\s*\d+/', $bufr)) {
-
 
306
                $bufr = preg_replace('/^(processor\s*:\s*\d+)\r?$/m', "$1\n", $bufr);
-
 
307
            }
-
 
308
 
-
 
309
            // IBM/S390
-
 
310
            $bufr = preg_replace('/\ncpu number\s*:\s*(\d+)\r?\ncpu MHz dynamic\s*:\s*(\d+)/m', "\nprocessor:$1\nclock:$2", $bufr);
-
 
311
 
-
 
312
            $processors = preg_split('/\s?\n\s?\n/', trim($bufr));
-
 
313
 
-
 
314
            //first stage
-
 
315
            $_arch = null;
-
 
316
            $_impl = null;
-
 
317
            $_part = null;
-
 
318
            $_hard = null;
-
 
319
            $_revi = null;
-
 
320
            $_cpus = null;
-
 
321
            $_buss = null;
-
 
322
            $_bogo = null;
-
 
323
            $_vend = null;
-
 
324
            $procname = null;
-
 
325
            foreach ($processors as $processor) if (!preg_match('/^\s*processor\s*:/mi', $processor)) {
-
 
326
                $details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
-
 
327
                foreach ($details as $detail) {
-
 
328
                    $arrBuff = preg_split('/\s*:\s*/', trim($detail));
-
 
329
                    if ((count($arrBuff) == 2) && (($arrBuff1 = trim($arrBuff[1])) !== '')) {
-
 
330
                        switch (strtolower($arrBuff[0])) {
-
 
331
                        case 'cpu architecture':
-
 
332
                            $_arch = $arrBuff1;
-
 
333
                            break;
-
 
334
                        case 'cpu implementer':
-
 
335
                            $_impl = $arrBuff1;
-
 
336
                            break;
-
 
337
                        case 'cpu part':
-
 
338
                            $_part = $arrBuff1;
-
 
339
                            break;
-
 
340
                        case 'hardware':
-
 
341
                            $_hard = $arrBuff1;
-
 
342
                            break;
-
 
343
                        case 'revision':
-
 
344
                            $_revi = $arrBuff1;
-
 
345
                            break;
-
 
346
                        case 'cpu frequency':
-
 
347
                            if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
-
 
348
                                $_cpus = round($bufr2[1]/1000000);
-
 
349
                            }
-
 
350
                            break;
-
 
351
                        case 'system bus frequency':
-
 
352
                            if (preg_match('/^(\d+)\s+Hz/i', $arrBuff1, $bufr2)) {
-
 
353
                                $_buss = round($bufr2[1]/1000000);
-
 
354
                            }
-
 
355
                            break;
-
 
356
                        case 'bogomips per cpu':
-
 
357
                            $_bogo = round($arrBuff1);
-
 
358
                            break;
-
 
359
                        case 'vendor_id':
-
 
360
                            $_vend = $arrBuff1;
-
 
361
                        case 'cpu':
-
 
362
                            $procname = $arrBuff1;
-
 
363
                            break;
-
 
364
                        }
-
 
365
                    }
-
 
366
                }
-
 
367
            }
-
 
368
 
-
 
369
            //second stage
-
 
370
            $cpucount = 0;
-
 
371
            $speedset = false;
-
 
372
            foreach ($processors as $processor) if (preg_match('/^\s*processor\s*:/mi', $processor)) {
-
 
373
                $proc = null;
-
 
374
                $arch = null;
-
 
375
                $impl = null;
-
 
376
                $part = null;
-
 
377
                $dev = new CpuDevice();
-
 
378
                $details = preg_split("/\n/", $processor, -1, PREG_SPLIT_NO_EMPTY);
-
 
379
                foreach ($details as $detail) {
-
 
380
                    $arrBuff = preg_split('/\s*:\s*/', trim($detail));
-
 
381
                    if ((count($arrBuff) == 2) && (($arrBuff1 = trim($arrBuff[1])) !== '')) {
-
 
382
                        switch (strtolower($arrBuff[0])) {
-
 
383
                        case 'processor':
-
 
384
                            $proc = $arrBuff1;
-
 
385
                            if (is_numeric($proc)) {
-
 
386
                                if (strlen($procname)>0) {
-
 
387
                                    $dev->setModel($procname);
-
 
388
                                }
-
 
389
                            } else {
-
 
390
                                $procname = $proc;
-
 
391
                                $dev->setModel($procname);
-
 
392
                            }
-
 
393
                            break;
-
 
394
                        case 'model name':
-
 
395
                        case 'cpu model':
-
 
396
                        case 'cpu type':
-
 
397
                        case 'cpu':
-
 
398
                            $dev->setModel($arrBuff1);
-
 
399
                            break;
-
 
400
                        case 'cpu mhz':
-
 
401
                        case 'clock':
-
 
402
                            if ($arrBuff1 > 0) { //openSUSE fix
-
 
403
                                $dev->setCpuSpeed($arrBuff1);
-
 
404
                                $speedset = true;
-
 
405
                            }
-
 
406
                            break;
-
 
407
                        case 'cpu mhz static':
-
 
408
                            if ($arrBuff1 > 0) { //openSUSE fix
-
 
409
                                $dev->setCpuSpeedMax($arrBuff1);
-
 
410
                            }
-
 
411
                            break;
-
 
412
                        case 'cycle frequency [hz]':
-
 
413
                            $dev->setCpuSpeed($arrBuff1 / 1000000);
-
 
414
                            $speedset = true;
-
 
415
                            break;
-
 
416
                        case 'cpu0clktck':
-
 
417
                            $dev->setCpuSpeed(hexdec($arrBuff1) / 1000000); // Linux sparc64
-
 
418
                            $speedset = true;
-
 
419
                            break;
-
 
420
                        case 'l3 cache':
-
 
421
                        case 'cache size':
-
 
422
                            $dev->setCache(trim(preg_replace("/[a-zA-Z]/", "", $arrBuff1)) * 1024);
-
 
423
                            break;
-
 
424
                        case 'initial bogomips':
-
 
425
                        case 'bogomips':
-
 
426
                        case 'cpu0bogo':
-
 
427
                            $dev->setBogomips(round($arrBuff1));
-
 
428
                            break;
-
 
429
                        case 'flags':
-
 
430
                            if (preg_match("/ vmx/", $arrBuff1)) {
-
 
431
                                $dev->setVirt("vmx");
-
 
432
                            } elseif (preg_match("/ svm/", $arrBuff1)) {
-
 
433
                                $dev->setVirt("svm");
-
 
434
                            } elseif (preg_match("/ hypervisor/", $arrBuff1)) {
-
 
435
                                $dev->setVirt("hypervisor");
-
 
436
                            }
-
 
437
                            break;
-
 
438
                        case 'i size':
-
 
439
                        case 'd size':
-
 
440
                            if ($dev->getCache() === null) {
-
 
441
                                $dev->setCache($arrBuff1 * 1024);
-
 
442
                            } else {
-
 
443
                                $dev->setCache($dev->getCache() + ($arrBuff1 * 1024));
-
 
444
                            }
-
 
445
                            break;
-
 
446
                        case 'cpu architecture':
-
 
447
                            $arch = $arrBuff1;
-
 
448
                            break;
-
 
449
                        case 'cpu implementer':
-
 
450
                            $impl = $arrBuff1;
-
 
451
                            break;
-
 
452
                        case 'cpu part':
-
 
453
                            $part = $arrBuff1;
-
 
454
                            break;
-
 
455
                        case 'vendor_id':
-
 
456
                            $dev->setVendorId($arrBuff1);
-
 
457
                            break;
-
 
458
                        }
-
 
459
                    }
-
 
460
                }
-
 
461
                if ($arch === null) $arch = $_arch;
-
 
462
                if ($impl === null) $impl = $_impl;
-
 
463
                if ($part === null) $part = $_part;
-
 
464
 
-
 
465
                // sparc64 specific code follows
-
 
466
                // This adds the ability to display the cache that a CPU has
-
 
467
                // Originally made by Sven Blumenstein <bazik@gentoo.org> in 2004
-
 
468
                // Modified by Tom Weustink <freshy98@gmx.net> in 2004
-
 
469
                $sparclist = array('SUNW,UltraSPARC@0,0', 'SUNW,UltraSPARC-II@0,0', 'SUNW,UltraSPARC@1c,0', 'SUNW,UltraSPARC-IIi@1c,0', 'SUNW,UltraSPARC-II@1c,0', 'SUNW,UltraSPARC-IIe@0,0');
-
 
470
                foreach ($sparclist as $name) {
-
 
471
                    if (CommonFunctions::rfts('/proc/openprom/'.$name.'/ecache-size', $buf, 1, 32, false)) {
-
 
472
                        $dev->setCache(base_convert(trim($buf), 16, 10));
-
 
473
                    }
-
 
474
                }
-
 
475
                // sparc64 specific code ends
-
 
476
 
-
 
477
                // XScale detection code
-
 
478
                if (($arch === "5TE") && ($dev->getBogomips() != null)) {
-
 
479
                    $dev->setCpuSpeed($dev->getBogomips()); //BogoMIPS are not BogoMIPS on this CPU, it's the speed
-
 
480
                    $speedset = true;
-
 
481
                    $dev->setBogomips(null); // no BogoMIPS available, unset previously set BogoMIPS
-
 
482
                }
-
 
483
 
-
 
484
                if (($dev->getBusSpeed() == 0) && ($_buss !== null)) {
-
 
485
                    $dev->setBusSpeed($_buss);
-
 
486
                }
-
 
487
                if (($dev->getCpuSpeed() == 0) && ($_cpus !== null)) {
-
 
488
                    $dev->setCpuSpeed($_cpus);
-
 
489
                    $speedset = true;
-
 
490
                }
-
 
491
                if (($dev->getBogomips() == 0) && ($_bogo !== null)) {
-
 
492
                    $dev->setBogomips($_bogo);
-
 
493
                }
-
 
494
                if (($dev->getVendorId() === null) && ($_vend !== null)) {
-
 
495
                    $dev->setVendorId($_vend);
-
 
496
                }
-
 
497
 
-
 
498
                if ($proc != null) {
-
 
499
                    if (!is_numeric($proc)) {
-
 
500
                        $proc = 0;
-
 
501
                    }
-
 
502
                    // variable speed processors specific code follows
-
 
503
                    if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_cur_freq', $buf, 1, 4096, false)) {
-
 
504
                        $dev->setCpuSpeed(trim($buf) / 1000);
-
 
505
                        $speedset = true;
-
 
506
                    } elseif (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/scaling_cur_freq', $buf, 1, 4096, false)) {
-
 
507
                        $dev->setCpuSpeed(trim($buf) / 1000);
-
 
508
                        $speedset = true;
-
 
509
                    }
-
 
510
                    if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_max_freq', $buf, 1, 4096, false)) {
-
 
511
                        $dev->setCpuSpeedMax(trim($buf) / 1000);
-
 
512
                    }
-
 
513
                    if (CommonFunctions::rfts('/sys/devices/system/cpu/cpu'.$proc.'/cpufreq/cpuinfo_min_freq', $buf, 1, 4096, false)) {
-
 
514
                        $dev->setCpuSpeedMin(trim($buf) / 1000);
-
 
515
                    }
-
 
516
                    // variable speed processors specific code ends
-
 
517
                    if (PSI_LOAD_BAR) {
-
 
518
                            $dev->setLoad($this->_parseProcStat('cpu'.$proc));
-
 
519
                    }
-
 
520
/*
-
 
521
                    if (CommonFunctions::rfts('/proc/acpi/thermal_zone/THRM/temperature', $buf, 1, 4096, false)
-
 
522
                       &&  preg_match("/(\S+)\sC$/", $buf, $value)) {
-
 
523
                        $dev->setTemp(value[1]);
-
 
524
                    }
-
 
525
*/
-
 
526
                    if (($arch !== null) && ($impl !== null) && ($part !== null)) {
-
 
527
                        if (($impl === '0x41')
-
 
528
                           && (($_hard === 'BCM2708') || ($_hard === 'BCM2835') || ($_hard === 'BCM2709') || ($_hard === 'BCM2836') || ($_hard === 'BCM2710') || ($_hard === 'BCM2837') || ($_hard === 'BCM2711') || ($_hard === 'BCM2838'))
-
 
529
                           && ($_revi !== null)) { // Raspberry Pi detection (instead of 'cat /proc/device-tree/model')
-
 
530
                            if ($raslist === null) $raslist = @parse_ini_file(PSI_APP_ROOT."/data/raspberry.ini", true);
-
 
531
                            if ($raslist && !preg_match('/[^0-9a-f]/', $_revi)) {
-
 
532
                                if (($revidec = hexdec($_revi)) & 0x800000) {
-
 
533
                                    if ($this->sys->getMachine() === '') {
-
 
534
                                        $manufacturer = ($revidec >> 16) & 15;
-
 
535
                                        if (isset($raslist['manufacturer'][$manufacturer])) {
-
 
536
                                            $manuf = ' '.$raslist['manufacturer'][$manufacturer];
-
 
537
                                        } else {
-
 
538
                                            $manuf = '';
-
 
539
                                        }
-
 
540
                                        $model = ($revidec >> 4) & 255;
-
 
541
                                        if (isset($raslist['model'][$model])) {
-
 
542
                                            $this->sys->setMachine('Raspberry Pi '.$raslist['model'][$model].' (PCB 1.'.($revidec & 15).$manuf.')');
-
 
543
                                        } else {
-
 
544
                                            $this->sys->setMachine('Raspberry Pi (PCB 1.'.($revidec & 15).$manuf.')');
-
 
545
                                        }
-
 
546
                                    }
-
 
547
                                } else {
-
 
548
                                    if ($this->sys->getMachine() === '') {
-
 
549
                                        if (isset($raslist['old'][$revidec & 0x7fffff])) {
-
 
550
                                            $this->sys->setMachine('Raspberry Pi '.$raslist['old'][$revidec & 0x7fffff]);
-
 
551
                                        } else {
-
 
552
                                            $this->sys->setMachine('Raspberry Pi');
-
 
553
                                        }
-
 
554
                                    }
-
 
555
                                }
-
 
556
                            }
-
 
557
                        } elseif (($_hard !== null) && ($this->sys->getMachine() === '')) { // other ARM hardware
-
 
558
                            $this->sys->setMachine($_hard);
-
 
559
                        }
-
 
560
                        if ($cpulist === null) $cpulist = @parse_ini_file(PSI_APP_ROOT."/data/cpus.ini", true);
-
 
561
                        if ($cpulist && (isset($cpulist['cpu'][$cpuimplpart = strtolower($impl.','.$part)]))) {
-
 
562
                            if (($cpumodel = $dev->getModel()) !== '') {
-
 
563
                                $dev->setModel($cpumodel.' - '.$cpulist['cpu'][$cpuimplpart]);
-
 
564
                            } else {
-
 
565
                                $dev->setModel($cpulist['cpu'][$cpuimplpart]);
-
 
566
                            }
-
 
567
                        }
-
 
568
                    } elseif (($_hard !== null) && ($this->sys->getMachine() === '')) { // other hardware
-
 
569
                        $this->sys->setMachine($_hard);
-
 
570
                    }
-
 
571
 
-
 
572
                    if ($dev->getModel() === "") {
-
 
573
                        $dev->setModel("unknown");
-
 
574
                    }
-
 
575
                    $cpucount++;
-
 
576
                    $this->sys->setCpus($dev);
-
 
577
                }
-
 
578
            }
-
 
579
 
-
 
580
            $cpudevices = glob('/sys/devices/system/cpu/cpu*/uevent', GLOB_NOSORT);
-
 
581
            if (is_array($cpudevices) && (($cpustopped = count($cpudevices)-$cpucount) > 0)) {
-
 
582
                for (; $cpustopped > 0; $cpustopped--) {
-
 
583
                    $dev = new CpuDevice();
-
 
584
                    $dev->setModel("stopped");
-
 
585
                    if ($speedset) {
-
 
586
                        $dev->setCpuSpeed(-1);
-
 
587
                    }
-
 
588
                    $this->sys->setCpus($dev);
-
 
589
                }
-
 
590
            }
-
 
591
        }
-
 
592
    }
-
 
593
 
-
 
594
    /**
-
 
595
     * PCI devices
-
 
596
     *
-
 
597
     * @return void
-
 
598
     */
-
 
599
    private function _pci()
-
 
600
    {
-
 
601
        if ($arrResults = Parser::lspci()) {
-
 
602
            foreach ($arrResults as $dev) {
-
 
603
                $this->sys->setPciDevices($dev);
-
 
604
            }
-
 
605
        } elseif (CommonFunctions::rfts('/proc/pci', $strBuf, 0, 4096, false)) {
-
 
606
            $booDevice = false;
-
 
607
            $arrBuf = preg_split("/\n/", $strBuf, -1, PREG_SPLIT_NO_EMPTY);
-
 
608
            foreach ($arrBuf as $strLine) {
-
 
609
                if (preg_match('/^\s*Bus\s/', $strLine)) {
-
 
610
                    $booDevice = true;
-
 
611
                    continue;
-
 
612
                }
-
 
613
                if ($booDevice) {
-
 
614
                    $dev = new HWDevice();
-
 
615
                    $dev->setName(preg_replace('/\([^\)]+\)\.$/', '', trim($strLine)));
-
 
616
                    $this->sys->setPciDevices($dev);
-
 
617
/*
-
 
618
                    list($strKey, $strValue) = preg_split('/: /', $strLine, 2);
-
 
619
                    if (!preg_match('/bridge/i', $strKey) && !preg_match('/USB/i ', $strKey)) {
-
 
620
                        $dev = new HWDevice();
-
 
621
                        $dev->setName(preg_replace('/\([^\)]+\)\.$/', '', trim($strValue)));
-
 
622
                        $this->sys->setPciDevices($dev);
-
 
623
                    }
-
 
624
*/
-
 
625
                    $booDevice = false;
-
 
626
                }
-
 
627
            }
-
 
628
        } else {
-
 
629
            $pcidevices = glob('/sys/bus/pci/devices/*/uevent', GLOB_NOSORT);
-
 
630
            if (is_array($pcidevices) && (($total = count($pcidevices)) > 0)) {
-
 
631
                $buf = "";
-
 
632
                for ($i = 0; $i < $total; $i++) {
-
 
633
                    if (CommonFunctions::rfts($pcidevices[$i], $buf, 0, 4096, false) && (trim($buf) != "")) {
-
 
634
                        $pcibuf = "";
-
 
635
                        if (preg_match("/^PCI_CLASS=(\S+)/m", trim($buf), $subbuf)) {
-
 
636
                            $pcibuf = "Class ".$subbuf[1].":";
-
 
637
                        }
-
 
638
                        if (preg_match("/^PCI_ID=(\S+)/m", trim($buf), $subbuf)) {
-
 
639
                            $pcibuf .= " Device ".$subbuf[1];
-
 
640
                        }
-
 
641
                        if (preg_match("/^DRIVER=(\S+)/m", trim($buf), $subbuf)) {
-
 
642
                            $pcibuf .= " Driver ".$subbuf[1];
-
 
643
                        }
-
 
644
                        $dev = new HWDevice();
-
 
645
                        if (trim($pcibuf) != "") {
-
 
646
                            $dev->setName(trim($pcibuf));
-
 
647
                        } else {
-
 
648
                            $dev->setName("unknown");
-
 
649
                        }
-
 
650
                        $this->sys->setPciDevices($dev);
-
 
651
                    }
-
 
652
                }
-
 
653
            }
-
 
654
        }
-
 
655
    }
-
 
656
 
-
 
657
    /**
-
 
658
     * IDE devices
-
 
659
     *
-
 
660
     * @return void
-
 
661
     */
-
 
662
    private function _ide()
-
 
663
    {
-
 
664
        $bufd = CommonFunctions::gdc('/proc/ide', false);
-
 
665
        foreach ($bufd as $file) {
-
 
666
            if (preg_match('/^hd/', $file)) {
-
 
667
                $dev = new HWDevice();
-
 
668
                $dev->setName(trim($file));
-
 
669
                if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS && CommonFunctions::rfts("/proc/ide/".$file."/media", $buf, 1)) {
-
 
670
                    if (trim($buf) == 'disk') {
-
 
671
                        if (CommonFunctions::rfts("/proc/ide/".$file."/capacity", $buf, 1, 4096, false) || CommonFunctions::rfts("/sys/block/".$file."/size", $buf, 1, 4096, false)) {
-
 
672
                            $dev->setCapacity(trim($buf) * 512);
-
 
673
                        }
-
 
674
                    }
-
 
675
                }
-
 
676
                if (CommonFunctions::rfts("/proc/ide/".$file."/model", $buf, 1)) {
-
 
677
                    $dev->setName($dev->getName().": ".trim($buf));
-
 
678
                }
-
 
679
                $this->sys->setIdeDevices($dev);
-
 
680
            }
-
 
681
        }
-
 
682
    }
-
 
683
 
-
 
684
    /**
-
 
685
     * SCSI devices
-
 
686
     *
-
 
687
     * @return void
-
 
688
     */
-
 
689
    private function _scsi()
-
 
690
    {
-
 
691
        $getline = 0;
-
 
692
        $device = null;
-
 
693
        $scsiid = null;
-
 
694
        if (CommonFunctions::executeProgram('lsscsi', '-c', $bufr, PSI_DEBUG) || CommonFunctions::rfts('/proc/scsi/scsi', $bufr, 0, 4096, PSI_DEBUG)) {
-
 
695
            $bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
-
 
696
            foreach ($bufe as $buf) {
-
 
697
                if (preg_match('/Host: scsi(\d+) Channel: (\d+) Target: (\d+) Lun: (\d+)/i', $buf, $scsiids)
-
 
698
                   || preg_match('/Host: scsi(\d+) Channel: (\d+) Id: (\d+) Lun: (\d+)/i', $buf, $scsiids)) {
-
 
699
                    $scsiid = $scsiids;
-
 
700
                    $getline = 1;
-
 
701
                    continue;
-
 
702
                }
-
 
703
                if ($getline == 1) {
-
 
704
                    preg_match('/Vendor: (.*) Model: (.*) Rev: (.*)/i', $buf, $devices);
-
 
705
                    $getline = 2;
-
 
706
                    $device = $devices;
-
 
707
                    continue;
-
 
708
                }
-
 
709
                if ($getline == 2) {
-
 
710
                    preg_match('/Type:\s+(\S+)/i', $buf, $dev_type);
-
 
711
 
-
 
712
                    $dev = new HWDevice();
-
 
713
                    $dev->setName($device[1].' '.$device[2].' ('.$dev_type[1].')');
-
 
714
 
-
 
715
                    if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
-
 
716
                       && ($dev_type[1]==='Direct-Access')) {
-
 
717
                       $sizelist = glob('/sys/bus/scsi/devices/'.intval($scsiid[1]).':'.intval($scsiid[2]).':'.intval($scsiid[3]).':'.intval($scsiid[4]).'/*/*/size', GLOB_NOSORT);
-
 
718
                       if (is_array($sizelist) && (($total = count($sizelist)) > 0)) {
-
 
719
                           $buf = "";
-
 
720
                           for ($i = 0; $i < $total; $i++) {
-
 
721
                               if (CommonFunctions::rfts($sizelist[$i], $buf, 1, 4096, false) && (($buf=trim($buf)) != "") && ($buf > 0)) {
-
 
722
                                   $dev->setCapacity($buf * 512);
-
 
723
                                   break;
-
 
724
                               }
-
 
725
                           }
-
 
726
                       }
-
 
727
                    }
-
 
728
                    $this->sys->setScsiDevices($dev);
-
 
729
                    $getline = 0;
-
 
730
                }
-
 
731
            }
-
 
732
        }
-
 
733
    }
-
 
734
 
-
 
735
    /**
-
 
736
     * USB devices
-
 
737
     *
-
 
738
     * @return void
-
 
739
     */
-
 
740
    protected function _usb()
-
 
741
    {
-
 
742
        $usbarray = array();
-
 
743
        if (CommonFunctions::executeProgram('lsusb', (PSI_OS != 'Android')?'':'2>/dev/null', $bufr, PSI_DEBUG && (PSI_OS != 'Android'), 5) && ($bufr !== "")) {
-
 
744
            $bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
-
 
745
            foreach ($bufe as $buf) {
-
 
746
                $device = preg_split("/ /", $buf, 7);
-
 
747
                if (((isset($device[6]) && trim($device[6]) != "")) ||
-
 
748
                    ((isset($device[5]) && trim($device[5]) != ""))) {
-
 
749
                    $usbid = intval($device[1]).'-'.intval(trim($device[3],':')).' '.$device[5];
-
 
750
                    if ((isset($device[6]) && trim($device[6]) != "")) {
-
 
751
                        $usbarray[$usbid]['name'] = trim($device[6]);
-
 
752
                    } else {
-
 
753
                        $usbarray[$usbid]['name'] = 'unknown';
-
 
754
                    }
-
 
755
                }
-
 
756
            }
-
 
757
        }
-
 
758
 
-
 
759
        $usbdevices = glob('/sys/bus/usb/devices/*/idProduct', GLOB_NOSORT);
-
 
760
        if (is_array($usbdevices) && (($total = count($usbdevices)) > 0)) {
-
 
761
            for ($i = 0; $i < $total; $i++) {
-
 
762
                if (CommonFunctions::rfts($usbdevices[$i], $idproduct, 1, 4096, false) && (($idproduct=trim($idproduct)) != "")) { //is readable
-
 
763
                    $busnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/busnum');
-
 
764
                    $devnum = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/devnum');
-
 
765
                    $idvendor = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/idVendor');
-
 
766
                    if (($busnum!==null) && ($devnum!==null) && ($idvendor!==null)) {
-
 
767
                        $usbid = intval($busnum).'-'.intval($devnum).' '.$idvendor.':'.$idproduct;
-
 
768
                        $manufacturer = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/manufacturer');
-
 
769
                        if ($manufacturer!==null) {
-
 
770
                            $usbarray[$usbid]['manufacturer'] = $manufacturer;
-
 
771
                        }
-
 
772
                        $product = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/product');
-
 
773
                        if ($product!==null) {
-
 
774
                            $usbarray[$usbid]['product'] = $product;
-
 
775
                        }
-
 
776
                        if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
-
 
777
                           && defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
-
 
778
                            $serial = CommonFunctions::rolv($usbdevices[$i], '/\/idProduct$/', '/serial');
-
 
779
                            if (($serial!==null) && !preg_match('/\W/', $serial)) {
-
 
780
                                $usbarray[$usbid]['serial'] = $serial;
-
 
781
                            }
-
 
782
                        }
-
 
783
                    }
-
 
784
                }
-
 
785
            }
-
 
786
        }
-
 
787
 
-
 
788
        if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/usb/devices', $bufr, 0, 4096, false)) {
-
 
789
            $devnum = -1;
-
 
790
            $bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
-
 
791
            foreach ($bufe as $buf) {
-
 
792
                if (preg_match('/^T/', $buf)) {
-
 
793
                    $devnum++;
-
 
794
                } elseif (preg_match('/^S:/', $buf)) {
-
 
795
                    list($key, $value) = preg_split('/: /', $buf, 2);
-
 
796
                    list($key, $value2) = preg_split('/=/', $value, 2);
-
 
797
                    switch (trim($key)) {
-
 
798
                    case 'Manufacturer':
-
 
799
                        $usbarray[$devnum]['manufacturer'] = trim($value2);
-
 
800
                        break;
-
 
801
                    case 'Product':
-
 
802
                        $usbarray[$devnum]['product'] = trim($value2);
-
 
803
                        break;
-
 
804
                    case 'SerialNumber':
-
 
805
                        if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
-
 
806
                           && defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL
-
 
807
                           && !preg_match('/\W/', trim($value2))) {
-
 
808
                            $usbarray[$devnum]['serial'] = trim($value2);
-
 
809
                         }
-
 
810
                         break;
-
 
811
                    }
-
 
812
                }
-
 
813
            }
-
 
814
        }
-
 
815
 
-
 
816
        if ((count($usbarray) == 0) && CommonFunctions::rfts('/proc/bus/input/devices', $bufr, 0, 4096, false)) {
-
 
817
            $devnam = "unknown";
-
 
818
            $bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
-
 
819
            foreach ($bufe as $buf) {
-
 
820
                if (preg_match('/^I:\s+(.+)/', $buf, $bufr)
-
 
821
                   && isset($bufr[1]) && (trim($bufr[1])!=="")) {
-
 
822
                    $devnam = trim($bufr[1]);
-
 
823
                    $usbarray[$devnam]['phys'] = 'unknown';
-
 
824
                } elseif (preg_match('/^N:\s+Name="([^"]+)"/', $buf, $bufr2)
-
 
825
                   && isset($bufr2[1]) && (trim($bufr2[1])!=="")) {
-
 
826
                    $usbarray[$devnam]['name'] = trim($bufr2[1]);
-
 
827
                } elseif (preg_match('/^P:\s+Phys=(.*)/', $buf, $bufr2)
-
 
828
                   && isset($bufr2[1]) && (trim($bufr2[1])!=="")) {
-
 
829
                    $usbarray[$devnam]['phys'] = trim($bufr2[1]);
-
 
830
                } elseif (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
-
 
831
                   && defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL
-
 
832
                   && preg_match('/^U:\s+Uniq=(.+)/', $buf, $bufr2)
-
 
833
                   && isset($bufr2[1]) && (trim($bufr2[1])!=="")) {
-
 
834
                    $usbarray[$devnam]['serial'] = trim($bufr2[1]);
-
 
835
                }
-
 
836
            }
-
 
837
        }
-
 
838
 
-
 
839
        foreach ($usbarray as $usbdev) if (!isset($usbdev['phys']) || preg_match('/^usb-/', $usbdev['phys'])) {
-
 
840
            $dev = new HWDevice();
-
 
841
 
-
 
842
            if (isset($usbdev['manufacturer']) && (($manufacturer=$usbdev['manufacturer']) !== 'no manufacturer')) {
-
 
843
                if (preg_match("/^linux\s/i", $manufacturer)) {
-
 
844
                    $manufacturer = 'Linux Foundation';
-
 
845
                }
-
 
846
                if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
-
 
847
                    $dev->setManufacturer($manufacturer);
-
 
848
                }
-
 
849
            } else {
-
 
850
                $manufacturer = '';
-
 
851
            }
-
 
852
 
-
 
853
            if (isset($usbdev['product'])) {
-
 
854
                $product = $usbdev['product'];
-
 
855
                if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS) {
-
 
856
                    $dev->setProduct($product);
-
 
857
                }
-
 
858
            } else {
-
 
859
                $product = '';
-
 
860
            }
-
 
861
 
-
 
862
            if (defined('PSI_SHOW_DEVICES_INFOS') && PSI_SHOW_DEVICES_INFOS
-
 
863
                && defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL
-
 
864
                && isset($usbdev['serial'])) {
-
 
865
                $dev->setSerial($usbdev['serial']);
-
 
866
            }
19
}
867
 
-
 
868
            if (isset($usbdev['name']) && (($name=$usbdev['name']) !== 'unknown')) {
-
 
869
                $dev->setName($name);
-
 
870
            } else {
-
 
871
                if (($newname = trim($manufacturer.' '.$product)) !== '') {
-
 
872
                    $dev->setName($newname);
-
 
873
                } else {
-
 
874
                    $dev->setName('unknown');
-
 
875
                }
-
 
876
            }
20
 
877
 
-
 
878
            $this->sys->setUsbDevices($dev);
-
 
879
        }
-
 
880
    }
-
 
881
 
-
 
882
    /**
-
 
883
     * I2C devices
-
 
884
     *
-
 
885
     * @return void
-
 
886
     */
-
 
887
    protected function _i2c()
-
 
888
    {
21
require_once(APP_ROOT . '/includes/os/class.BSD.common.inc.php');
889
        $i2cdevices = glob('/sys/bus/i2c/devices/*/name', GLOB_NOSORT);
-
 
890
        if (is_array($i2cdevices) && (($total = count($i2cdevices)) > 0)) {
-
 
891
            $buf = "";
-
 
892
            for ($i = 0; $i < $total; $i++) {
-
 
893
                if (CommonFunctions::rfts($i2cdevices[$i], $buf, 1, 4096, false) && (trim($buf) != "")) {
-
 
894
                    $dev = new HWDevice();
-
 
895
                    $dev->setName(trim($buf));
-
 
896
                    $this->sys->setI2cDevices($dev);
-
 
897
                }
-
 
898
            }
-
 
899
        }
-
 
900
    }
-
 
901
 
-
 
902
    /**
-
 
903
     * NVMe devices
-
 
904
     *
-
 
905
     * @return void
-
 
906
     */
-
 
907
    protected function _nvme()
-
 
908
    {
-
 
909
        if (CommonFunctions::executeProgram('nvme', 'list', $bufr, PSI_DEBUG) && ($bufr!="")) {
-
 
910
            $bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
-
 
911
            $count = 0;
-
 
912
            $nlocate = array();
-
 
913
            $nsize = array();
-
 
914
            foreach ($bufe as $buf) {
-
 
915
                if ($count == 1) {
-
 
916
                    $locid = 0;
-
 
917
                    $nlocate[0] = 0;
-
 
918
                    $total = strlen($buf);
-
 
919
                    $begin = true;
-
 
920
                    for ($i = 0; $i < $total; $i++) {
-
 
921
                        if ($begin) {
-
 
922
                            if ($buf[$i] !== '-') {
-
 
923
                                $nsize[$locid] = $i - $nlocate[$locid];
-
 
924
                                $locid++;
-
 
925
                                $begin = false;
-
 
926
                            }
-
 
927
                        } else {
-
 
928
                            if ($buf[$i] === '-') {
-
 
929
                                $nlocate[$locid] = $i;
-
 
930
                                $begin = true;
-
 
931
                            }
-
 
932
                        }
-
 
933
                    }
-
 
934
                    if ($begin) {
-
 
935
                        $nsize[$locid] = $i - $nlocate[$locid];
-
 
936
                    }
-
 
937
                } elseif ($count > 1) {
-
 
938
                    if (isset($nlocate[2]) && isset($nsize[2])) {
-
 
939
                        $dev = new HWDevice();
-
 
940
                        $dev->setName(trim(substr($buf, $nlocate[2], $nsize[2])));
-
 
941
                        if (defined('PSI_SHOW_DEVICES_INFOS') && (PSI_SHOW_DEVICES_INFOS)) {
-
 
942
                            if (isset($nlocate[4]) && isset($nsize[4])) {
-
 
943
                                if (preg_match('/\/\s*([0-9\.]+)\s*(B|KB|MB|GB|TB|PB)$/', str_replace(',', '.', trim(substr($buf, $nlocate[4], $nsize[4]))), $tmpbuf)) {
-
 
944
                                    switch ($tmpbuf[2]) {
-
 
945
                                        case 'B':
-
 
946
                                            $dev->setCapacity($tmpbuf[1]);
-
 
947
                                            break;
-
 
948
                                        case 'KB':
-
 
949
                                            $dev->setCapacity(1000*$tmpbuf[1]);
-
 
950
                                            break;
-
 
951
                                        case 'MB':
-
 
952
                                            $dev->setCapacity(1000*1000*$tmpbuf[1]);
-
 
953
                                            break;
-
 
954
                                        case 'GB':
-
 
955
                                            $dev->setCapacity(1000*1000*1000*$tmpbuf[1]);
-
 
956
                                            break;
-
 
957
                                        case 'TB':
-
 
958
                                            $dev->setCapacity(1000*1000*1000*1000*$tmpbuf[1]);
-
 
959
                                            break;
-
 
960
                                        case 'PB':
-
 
961
                                            $dev->setCapacity(1000*1000*1000*1000*1000*$tmpbuf[1]);
-
 
962
                                            break;
-
 
963
                                    }
-
 
964
                                }
-
 
965
                            }
-
 
966
                            if (defined('PSI_SHOW_DEVICES_SERIAL') && PSI_SHOW_DEVICES_SERIAL) {
-
 
967
                                if (isset($nlocate[1]) && isset($nsize[1])) {
-
 
968
                                    $dev->setSerial(trim(substr($buf, $nlocate[1], $nsize[1])));
-
 
969
                                }
-
 
970
                            }
-
 
971
                        }
-
 
972
                        $this->sys->setNvmeDevices($dev);
-
 
973
                    }
-
 
974
                }
-
 
975
                $count++;
-
 
976
            }
-
 
977
        }
-
 
978
    }
22
 
979
 
23
class sysinfo {
980
    /**
24
	var $inifile = "distros.ini";
981
     * Network devices
25
	var $icon = "unknown.png";
982
     * includes also rx/tx bytes
26
	var $distro = "unknown";
983
     *
27
	var $parser;
984
     * @return void
28
	
985
     */
29
	// get the distro name and icon when create the sysinfo object
986
    protected function _network()
30
	function sysinfo() {
987
    {
31
  		$this->parser = new Parser();
988
        if (CommonFunctions::rfts('/proc/net/dev', $bufr, 0, 4096, PSI_DEBUG)) {
32
		$this->parser->df_param = 'P';
989
            $bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
33
		
990
            foreach ($bufe as $buf) {
34
		$list = @parse_ini_file(APP_ROOT . "/" . $this->inifile, true);
991
                if (preg_match('/:/', $buf)) {
35
		if (!$list) {
992
                    list($dev_name, $stats_list) = preg_split('/:/', $buf, 2);
36
			return;
993
                    $stats = preg_split('/\s+/', trim($stats_list));
37
		}
994
                    $dev = new NetDevice();
38
		
995
                    $dev->setName(trim($dev_name));
39
		$distro_info = execute_program('lsb_release','-a 2> /dev/null', false);  // We have the '2> /dev/null' because Ubuntu gives an error on this command which causes the distro to be unknown
996
                    $dev->setRxBytes($stats[0]);
40
		if ( $distro_info != 'ERROR') {
997
                    $dev->setTxBytes($stats[8]);
41
			$distro_tmp = explode("\n",$distro_info);
998
                    $dev->setErrors($stats[2] + $stats[10]);
42
			foreach( $distro_tmp as $info ) {
999
                    $dev->setDrops($stats[3] + $stats[11]);
43
				$info_tmp = explode(':', $info, 2);
1000
                    if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
44
				$distro[ $info_tmp[0] ] = trim($info_tmp[1]);
1001
                        $macaddr = "";
45
			}
1002
                        if ((CommonFunctions::executeProgram('ip', 'addr show '.trim($dev_name), $bufr2, PSI_DEBUG) && ($bufr2!=""))
46
			if( !isset( $list[$distro['Distributor ID']] ) ){
1003
                           || CommonFunctions::executeProgram('ifconfig', trim($dev_name).' 2>/dev/null', $bufr2, PSI_DEBUG)) {
47
				return;
1004
                            $bufe2 = preg_split("/\n/", $bufr2, -1, PREG_SPLIT_NO_EMPTY);
48
			}
1005
                            foreach ($bufe2 as $buf2) {
49
			$this->icon = isset($list[$distro['Distributor ID']]["Image"]) ? $list[$distro['Distributor ID']]["Image"] : $this->icon;
1006
//                                if (preg_match('/^'.trim($dev_name).'\s+Link\sencap:Ethernet\s+HWaddr\s(\S+)/i', $buf2, $ar_buf2)
50
			$this->distro = $distro['Description'];
1007
                                if (preg_match('/\s+encap:Ethernet\s+HWaddr\s(\S+)/i', $buf2, $ar_buf2)
51
		} else {  // Fall back in case 'lsb_release' does not exist ;)
1008
                                   || preg_match('/\s+encap:UNSPEC\s+HWaddr\s(\S+)-00-00-00-00-00-00-00-00-00-00\s*$/i', $buf2, $ar_buf2)
52
			foreach ($list as $section => $distribution) {
1009
                                   || preg_match('/^\s+ether\s+(\S+)\s+txqueuelen/i', $buf2, $ar_buf2)
53
				if (!isset($distribution["Files"])) {
1010
                                   || preg_match('/^\s+link\/ether\s+(\S+)\s+brd/i', $buf2, $ar_buf2)
54
					continue;
1011
                                   || preg_match('/^\s+link\/ether\s+(\S+)$/i', $buf2, $ar_buf2)
55
				} else {
1012
                                   || preg_match('/^\s+link\/ieee802.11\s+(\S+)$/i', $buf2, $ar_buf2)) {
56
					foreach (explode(";", $distribution["Files"]) as $filename) {
1013
                                    if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) {
57
						if (file_exists($filename)) {
1014
                                        $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
58
							$buf = rfts( $filename );
1015
                                        if ($macaddr === '00-00-00-00-00-00') { // empty
59
							$this->icon = isset($distribution["Image"]) ? $distribution["Image"] : $this->icon;
1016
                                            $macaddr = "";
60
							$this->distro = isset($distribution["Name"]) ? $distribution["Name"] . " " . trim($buf) : trim($buf);
1017
                                        }
61
							break 2;
1018
                                    }
62
						}
1019
                                } elseif (preg_match('/^\s+inet\saddr:(\S+)\s+P-t-P:(\S+)/i', $buf2, $ar_buf2)
63
					}
1020
                                       || preg_match('/^\s+inet\s+(\S+)\s+netmask.+destination\s+(\S+)/i', $buf2, $ar_buf2)
64
				}
1021
                                       || preg_match('/^\s+inet\s+([^\/\s]+).*peer\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $buf2, $ar_buf2)) {
65
			}
1022
                                    if ($ar_buf2[1] != $ar_buf2[2]) {
66
		}
1023
                                        $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
67
	}
1024
                                    } else {
68
  
1025
                                        $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
69
  // get our apache SERVER_NAME or vhost
1026
                                    }
70
  function vhostname () {
1027
                                } elseif ((preg_match('/^\s+inet\saddr:(\S+)/i', $buf2, $ar_buf2)
71
    if (! ($result = getenv('SERVER_NAME'))) {
1028
                                   || preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $buf2, $ar_buf2)
72
      $result = 'N.A.';
1029
                                   || preg_match('/^'.trim($dev_name).':\s+ip\s+(\S+)\s+mask/i', $buf2, $ar_buf2)
73
    } 
1030
                                   || preg_match('/^\s+inet6\saddr:\s([^\/\s]+)(.+)\s+Scope:[GH]/i', $buf2, $ar_buf2)
74
    return $result;
1031
                                   || preg_match('/^\s+inet6\s+(\S+)\s+prefixlen(.+)((<global>)|(<host>))/i', $buf2, $ar_buf2)
75
  } 
1032
                                   || preg_match('/^\s+inet6?\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $buf2, $ar_buf2))
76
  // get the IP address of our vhost name
1033
                                   && ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
77
  function vip_addr () {
1034
                                    $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
78
    return gethostbyname($this->vhostname());
1035
                                }
79
  }
1036
                            }
80
  // get our canonical hostname
1037
                        }
81
  function chostname () {
1038
                        if ($macaddr != "") {
82
    $result = rfts( '/proc/sys/kernel/hostname', 1 );
1039
                            $dev->setInfo($macaddr.($dev->getInfo()?';'.$dev->getInfo():''));
83
    if ( $result == "ERROR" ) {
1040
                        }
84
      $result = "N.A.";
1041
                        if (CommonFunctions::rfts('/sys/class/net/'.trim($dev_name).'/speed', $buf, 1, 4096, false) && (($speed=trim($buf))!="") && ($buf > 0) && ($buf < 65535)) {
85
    }
1042
                            if ($speed > 1000) {
86
    //else {
1043
                                $speed = $speed/1000;
87
    //  $result = gethostbyaddr( gethostbyname( trim( $result ) ) );
1044
                                $unit = "G";
88
    //} 
1045
                            } else {
89
    return $result;
1046
                                $unit = "M";
90
  } 
1047
                            }
91
  // get the IP address of our canonical hostname
1048
                            if (CommonFunctions::rfts('/sys/class/net/'.trim($dev_name).'/duplex', $buf, 1, 4096, false) && (($duplex=strtolower(trim($buf)))!="") && ($duplex!='unknown')) {
92
  function ip_addr () {
1049
                                $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$speed.$unit.'b/s '.$duplex);
93
    if (!($result = getenv('SERVER_ADDR'))) {
1050
                            } else {
94
      $result = gethostbyname($this->chostname());
1051
                                $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$speed.$unit.'b/s');
95
    } 
1052
                            }
96
    return $result;
1053
                        }
97
  } 
1054
                    }
98
 
1055
                    $this->sys->setNetDevices($dev);
99
  function kernel () {
1056
                }
100
    $buf = rfts( '/proc/version', 1 );
1057
            }
101
    if ( $buf == "ERROR" ) {
1058
        } elseif (CommonFunctions::executeProgram('ip', 'addr show', $bufr, PSI_DEBUG) && ($bufr!="")) {
102
      $result = "N.A.";
1059
            $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
103
    } else {
1060
            $was = false;
104
      if (preg_match('/version (.*?) /', $buf, $ar_buf)) {
1061
            $macaddr = "";
105
        $result = $ar_buf[1];
1062
            $speedinfo = "";
106
 
1063
            $dev = null;
107
        if (preg_match('/SMP/', $buf)) {
1064
            foreach ($lines as $line) {
108
          $result .= ' (SMP)';
1065
                if (preg_match("/^\d+:\s+([^\s:]+)/", $line, $ar_buf)) {
109
        } 
1066
                    if ($was) {
110
      } 
1067
                        if ($macaddr != "") {
111
    } 
1068
                            $dev->setInfo($macaddr.($dev->getInfo()?';'.$dev->getInfo():''));
112
    return $result;
1069
                        }
113
  } 
1070
                        if ($speedinfo != "") {
114
  
1071
                            $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$speedinfo);
115
  function uptime () {
1072
                        }
116
    $buf = rfts( '/proc/uptime', 1 );
1073
                        $this->sys->setNetDevices($dev);
117
    $ar_buf = explode( ' ', $buf );
1074
                    }
118
    $result = trim( $ar_buf[0] );
1075
                    $speedinfo = "";
119
 
1076
                    $macaddr = "";
120
    return $result;
1077
                    $dev = new NetDevice();
121
  } 
1078
                    $dev->setName($ar_buf[1]);
122
 
1079
                    if (CommonFunctions::executeProgram('ip', '-s link show '.$ar_buf[1], $bufr2, PSI_DEBUG) && ($bufr2!="")
123
  function users () {
1080
                       && preg_match("/\n\s+RX:\s[^\n]+\n\s+(\d+)\s+\d+\s+(\d+)\s+(\d+)[^\n]+\n\s+TX:\s[^\n]+\n\s+(\d+)\s+\d+\s+(\d+)\s+(\d+)/m", $bufr2, $ar_buf2)) {
124
		$strResult = 0;
1081
                        $dev->setRxBytes($ar_buf2[1]);
125
  		$strBuf = execute_program('who', '-q');
1082
                        $dev->setTxBytes($ar_buf2[4]);
126
		if( $strBuf != "ERROR" ) {
1083
                        $dev->setErrors($ar_buf2[2]+$ar_buf2[5]);
127
			$arrWho = explode( '=', $strBuf );
1084
                        $dev->setDrops($ar_buf2[3]+$ar_buf2[6]);
128
    			$strResult = $arrWho[1];
1085
                    }
129
		}
1086
                    $was = true;
130
		return $strResult;
1087
                    if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
131
  }
1088
                        if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/speed', $buf, 1, 4096, false) && (trim($buf)!="")) {
132
  
1089
                            $speed = trim($buf);
133
  function loadavg ($bar = false) {
1090
                            if ($speed > 1000) {
134
    $buf = rfts( '/proc/loadavg' );
1091
                                $speed = $speed/1000;
135
    if( $buf == "ERROR" ) {
1092
                                $unit = "G";
136
      $results['avg'] = array('N.A.', 'N.A.', 'N.A.');
1093
                            } else {
137
    } else {
1094
                                $unit = "M";
138
      $results['avg'] = preg_split("/\s/", $buf, 4);
1095
                            }
139
      unset($results['avg'][3]);	// don't need the extra values, only first three
1096
                            if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/duplex', $buf, 1, 4096, false) && (trim($buf)!="")) {
140
    } 
1097
                                $speedinfo = $speed.$unit.'b/s '.strtolower(trim($buf));
141
    if ($bar) {
1098
                            } else {
142
      $buf = rfts( '/proc/stat', 1 );
1099
                                $speedinfo = $speed.$unit.'b/s';
143
      if( $buf != "ERROR" ) {
1100
                            }
144
	sscanf($buf, "%*s %Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae);
1101
                        }
145
	// Find out the CPU load
1102
                    }
146
	// user + sys = load 
1103
                } else {
147
	// total = total
1104
                    if ($was) {
148
	$load = $ab + $ac + $ad;	// cpu.user + cpu.sys
1105
                        if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
149
	$total = $ab + $ac + $ad + $ae;	// cpu.total
1106
                            if (preg_match('/^\s+link\/ether\s+(\S+)\s+brd/i', $line, $ar_buf2)) {
150
 
1107
                                if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
151
	// we need a second value, wait 1 second befor getting (< 1 second no good value will occour)
1108
                            } elseif (preg_match('/^\s+inet\s+([^\/\s]+).*peer\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $line, $ar_buf2)) {
152
	sleep(1);
1109
                                if ($ar_buf2[1] != $ar_buf2[2]) {
153
	$buf = rfts( '/proc/stat', 1 );
1110
                                     $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
154
	sscanf($buf, "%*s %Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae);
1111
                                } else {
155
	$load2 = $ab + $ac + $ad;
1112
                                     $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
156
	$total2 = $ab + $ac + $ad + $ae;
1113
                                }
157
	$results['cpupercent'] = (100*($load2 - $load)) / ($total2 - $total);
1114
                            } elseif (preg_match('/^\s+inet6?\s+([^\/\s]+).*\s+scope\s((global)|(host))/i', $line, $ar_buf2)
158
      }
1115
                                     && ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
159
    }
1116
                                $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
160
    return $results;
1117
                            }
161
  } 
1118
                        }
162
 
1119
                    }
163
	function cpu_info () {
1120
                }
164
		$bufr = rfts( '/proc/cpuinfo' );
1121
            }
165
		$results = array("cpus" => 0);
1122
            if ($was) {
166
		
1123
                if ($macaddr != "") {
167
		if ( $bufr != "ERROR" ) {
1124
                    $dev->setInfo($macaddr.($dev->getInfo()?';'.$dev->getInfo():''));
168
			$bufe = explode("\n", $bufr);
1125
                }
169
			
1126
                if ($speedinfo != "") {
170
			$results = array('cpus' => 0, 'bogomips' => 0);
1127
                    $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$speedinfo);
171
			$ar_buf = array();
1128
                }
172
			
1129
                $this->sys->setNetDevices($dev);
173
			foreach( $bufe as $buf ) {
1130
            }
174
				$arrBuff = preg_split('/\s+:\s+/', trim($buf));
1131
        } elseif (CommonFunctions::executeProgram('ifconfig', '-a', $bufr, PSI_DEBUG)) {
175
				if( count( $arrBuff ) == 2 ) {
1132
            $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
176
					$key = $arrBuff[0];
1133
            $was = false;
177
					$value = $arrBuff[1];
1134
            $errors = 0;
178
					// All of the tags here are highly architecture dependant.
1135
            $drops = 0;
179
					// the only way I could reconstruct them for machines I don't
1136
            $macaddr = "";
180
					// have is to browse the kernel source.  So if your arch isn't
1137
            $speedinfo = "";
181
					// supported, tell me you want it written in.
1138
            $dev = null;
182
					switch ($key) {
1139
            foreach ($lines as $line) {
183
						case 'model name':
1140
                if (preg_match("/^([^\s:]+)/", $line, $ar_buf)) {
184
							$results['model'] = $value;
1141
                    if ($was) {
185
							break;
1142
                        $dev->setErrors($errors);
186
						case 'cpu MHz':
1143
                        $dev->setDrops($drops);
187
							$results['cpuspeed'] = sprintf('%.2f', $value);
1144
                        if ($macaddr != "") {
188
							break;
1145
                            $dev->setInfo($macaddr.($dev->getInfo()?';'.$dev->getInfo():''));
189
						case 'cycle frequency [Hz]': // For Alpha arch - 2.2.x
1146
                        }
190
							$results['cpuspeed'] = sprintf('%.2f', $value / 1000000);
1147
                        if ($speedinfo != "") {
191
							break;
1148
                            $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$speedinfo);
192
						case 'clock': // For PPC arch (damn borked POS)
1149
                        }
193
							$results['cpuspeed'] = sprintf('%.2f', $value);
1150
                        $this->sys->setNetDevices($dev);
194
							break;
1151
                    }
195
						case 'cpu': // For PPC arch (damn borked POS)
1152
                    $errors = 0;
196
							$results['model'] = $value;
1153
                    $drops = 0;
197
							break;
1154
                    $speedinfo = "";
198
						case 'L2 cache': // More for PPC
1155
                    $macaddr = "";
199
							$results['cache'] = $value;
1156
                    $dev = new NetDevice();
200
							break;
1157
                    $dev->setName($ar_buf[1]);
201
						case 'revision': // For PPC arch (damn borked POS)
1158
                    $was = true;
202
							$results['model'] .= ' ( rev: ' . $value . ')';
1159
                    if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
203
							break;
1160
                        if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/speed', $buf, 1, 4096, false) && (trim($buf)!="")) {
204
						case 'cpu model': // For Alpha arch - 2.2.x
1161
                            $speed = trim($buf);
205
							$results['model'] .= ' (' . $value . ')';
1162
                            if ($speed > 1000) {
206
							break;
1163
                                $speed = $speed/1000;
207
						case 'cache size':
1164
                                $unit = "G";
208
							$results['cache'] = $value;
1165
                            } else {
209
							break;
1166
                                $unit = "M";
210
						case 'bogomips':
1167
                            }
211
							$results['bogomips'] += $value;
1168
                            if (CommonFunctions::rfts('/sys/class/net/'.$ar_buf[1].'/duplex', $buf, 1, 4096, false) && (trim($buf)!="")) {
212
							break;
1169
                                $speedinfo = $speed.$unit.'b/s '.strtolower(trim($buf));
213
						case 'BogoMIPS': // For alpha arch - 2.2.x
1170
                            } else {
214
							$results['bogomips'] += $value;
1171
                                $speedinfo = $speed.$unit.'b/s';
215
							break;
1172
                            }
216
						case 'BogoMips': // For sparc arch
1173
                        }
217
							$results['bogomips'] += $value;
1174
                        if (preg_match('/^'.$ar_buf[1].'\s+Link\sencap:Ethernet\s+HWaddr\s(\S+)/i', $line, $ar_buf2))
218
							break;
1175
                            if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
219
						case 'cpus detected': // For Alpha arch - 2.2.x
1176
                        elseif (preg_match('/^'.$ar_buf[1].':\s+ip\s+(\S+)\s+mask/i', $line, $ar_buf2))
220
							$results['cpus'] += $value;
1177
                            $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
221
							break;
1178
                    }
222
						case 'system type': // Alpha arch - 2.2.x
1179
                } else {
223
							$results['model'] .= ', ' . $value . ' ';
1180
                    if ($was) {
224
							break;
1181
                        if (preg_match('/\sRX bytes:(\d+)\s/i', $line, $ar_buf2)) {
225
						case 'platform string': // Alpha arch - 2.2.x
1182
                            $dev->setRxBytes($ar_buf2[1]);
226
							$results['model'] .= ' (' . $value . ')';
1183
                        }
227
							break;
1184
                        if (preg_match('/\sTX bytes:(\d+)\s/i', $line, $ar_buf2)) {
228
						case 'processor':
1185
                            $dev->setTxBytes($ar_buf2[1]);
229
							$results['cpus'] += 1;
1186
                        }
230
							break;
1187
 
231
						case 'Cpu0ClkTck': // Linux sparc64
1188
                        if (preg_match('/\sRX packets:\d+\serrors:(\d+)\sdropped:(\d+)/i', $line, $ar_buf2)) {
232
							$results['cpuspeed'] = sprintf('%.2f', hexdec($value) / 1000000);
1189
                            $errors +=$ar_buf2[1];
233
							break;
1190
                            $drops +=$ar_buf2[2];
234
						case 'Cpu0Bogo': // Linux sparc64 & sparc32
1191
                        } elseif (preg_match('/\sTX packets:\d+\serrors:(\d+)\sdropped:(\d+)/i', $line, $ar_buf2)) {
235
							$results['bogomips'] = $value;
1192
                            $errors +=$ar_buf2[1];
236
							break;
1193
                            $drops +=$ar_buf2[2];
237
						case 'ncpus probed': // Linux sparc64 & sparc32
1194
                        }
238
							$results['cpus'] = $value;
1195
 
239
							break;
1196
                        if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
240
		 			}
1197
                            if (preg_match('/\s+encap:Ethernet\s+HWaddr\s(\S+)/i', $line, $ar_buf2)
241
				}
1198
                             || preg_match('/^\s+ether\s+(\S+)\s+txqueuelen/i', $line, $ar_buf2)) {
242
			}
1199
                                if (!defined('PSI_HIDE_NETWORK_MACADDR') || !PSI_HIDE_NETWORK_MACADDR) $macaddr = preg_replace('/:/', '-', strtoupper($ar_buf2[1]));
243
		
1200
                            } elseif (preg_match('/^\s+inet\saddr:(\S+)\s+P-t-P:(\S+)/i', $line, $ar_buf2)
244
			// sparc64 specific code follows
1201
                                  || preg_match('/^\s+inet\s+(\S+)\s+netmask.+destination\s+(\S+)/i', $line, $ar_buf2)) {
245
			// This adds the ability to display the cache that a CPU has
1202
                                if ($ar_buf2[1] != $ar_buf2[2]) {
246
			// Originally made by Sven Blumenstein <bazik@gentoo.org> in 2004
1203
                                     $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1].";:".$ar_buf2[2]);
247
			// Modified by Tom Weustink <freshy98@gmx.net> in 2004
1204
                                } else {
248
			$sparclist = array('SUNW,UltraSPARC@0,0', 'SUNW,UltraSPARC-II@0,0', 'SUNW,UltraSPARC@1c,0', 'SUNW,UltraSPARC-IIi@1c,0', 'SUNW,UltraSPARC-II@1c,0', 'SUNW,UltraSPARC-IIe@0,0');
1205
                                     $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
249
			foreach ($sparclist as $name) {
1206
                                }
250
				$buf = rfts( '/proc/openprom/' . $name . '/ecache-size',1 , 32, false );
1207
                            } elseif ((preg_match('/^\s+inet\saddr:(\S+)/i', $line, $ar_buf2)
251
				if( $buf != "ERROR" ) {
1208
                                  || preg_match('/^\s+inet\s+(\S+)\s+netmask/i', $line, $ar_buf2)
252
					$results['cache'] = base_convert($buf, 16, 10)/1024 . ' KB';
1209
                                  || preg_match('/^\s+inet6\saddr:\s([^\/\s]+)(.+)\s+Scope:[GH]/i', $line, $ar_buf2)
253
				}
1210
                                  || preg_match('/^\s+inet6\s+(\S+)\s+prefixlen(.+)((<global>)|(<host>))/i', $line, $ar_buf2))
254
			}
1211
                                  && ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1])) {
255
			// sparc64 specific code ends
1212
                                $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
256
	
1213
                            }
257
			// XScale detection code
1214
                        }
258
			if ( $results['cpus'] == 0 ) {
1215
                    }
259
				foreach( $bufe as $buf ) {
1216
                }
260
					$fields = preg_split('/\s*:\s*/', trim($buf), 2);
1217
            }
261
					if (sizeof($fields) == 2) {
1218
            if ($was) {
262
						list($key, $value) = $fields;
1219
                $dev->setErrors($errors);
263
						switch($key) {
1220
                $dev->setDrops($drops);
264
							case 'Processor':
1221
                if ($macaddr != "") {
265
								$results['cpus'] += 1;
1222
                    $dev->setInfo($macaddr.($dev->getInfo()?';'.$dev->getInfo():''));
266
								$results['model'] = $value;
1223
                }
267
								break;
1224
                if ($speedinfo != "") {
268
							case 'BogoMIPS': //BogoMIPS are not BogoMIPS on this CPU, it's the speed, no BogoMIPS available
1225
                    $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$speedinfo);
269
								$results['cpuspeed'] = $value;
1226
                }
270
								break;
1227
                $this->sys->setNetDevices($dev);
271
							case 'I size':
1228
            }
272
								$results['cache'] = $value;
1229
        }
273
								break;
1230
    }
274
							case 'D size':
1231
 
275
								$results['cache'] += $value;
1232
    /**
276
								break;
1233
     * Physical memory information and Swap Space information
277
						}
1234
     *
278
					}
1235
     * @return void
279
				}
1236
     */
280
				$results['cache'] = $results['cache'] / 1024 . " KB";
1237
    protected function _memory()
281
			}
1238
    {
282
		}		
1239
        if (CommonFunctions::rfts('/proc/meminfo', $mbuf)) {
283
		$keys = array_keys($results);
1240
            $bufe = preg_split("/\n/", $mbuf, -1, PREG_SPLIT_NO_EMPTY);
284
		$keys2be = array('model', 'cpuspeed', 'cache', 'bogomips', 'cpus');
1241
            foreach ($bufe as $buf) {
285
		
1242
                if (preg_match('/^MemTotal:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
286
		while ($ar_buf = each($keys2be)) {
1243
                    $this->sys->setMemTotal($ar_buf[1] * 1024);
287
			if (! in_array($ar_buf[1], $keys)) {
1244
                } elseif (preg_match('/^MemFree:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
288
				$results[$ar_buf[1]] = 'N.A.';
1245
                    $this->sys->setMemFree($ar_buf[1] * 1024);
289
			} 
1246
                } elseif (preg_match('/^Cached:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
290
		}
1247
                    $this->sys->setMemCache($ar_buf[1] * 1024);
291
		
1248
                } elseif (preg_match('/^Buffers:\s+(\d+)\s*kB/i', $buf, $ar_buf)) {
292
		$buf = rfts( '/proc/acpi/thermal_zone/THRM/temperature', 1, 4096, false );
1249
                    $this->sys->setMemBuffer($ar_buf[1] * 1024);
293
		if ( $buf != "ERROR" ) {
1250
                }
294
			$results['temp'] = substr( $buf, 25, 2 );
1251
            }
295
		}
1252
            $this->sys->setMemUsed($this->sys->getMemTotal() - $this->sys->getMemFree());
296
		
1253
            // values for splitting memory usage
297
		return $results;
1254
            if ($this->sys->getMemCache() !== null && $this->sys->getMemBuffer() !== null) {
298
	}
1255
                $this->sys->setMemApplication($this->sys->getMemUsed() - $this->sys->getMemCache() - $this->sys->getMemBuffer());
299
 
1256
            }
300
	function pci () {
1257
            if (CommonFunctions::rfts('/proc/swaps', $sbuf, 0, 4096, false)) {
301
		$arrResults = array();
1258
                $swaps = preg_split("/\n/", $sbuf, -1, PREG_SPLIT_NO_EMPTY);
302
		$booDevice = false;
1259
                unset($swaps[0]);
303
		
1260
                foreach ($swaps as $swap) {
304
		if( ! $arrResults = $this->parser->parse_lspci() ) {
1261
                    $ar_buf = preg_split('/\s+/', $swap, 5);
305
			$strBuf = rfts( '/proc/pci', 0, 4096, false );
1262
                    $dev = new DiskDevice();
306
			if( $strBuf != "ERROR" ) {
1263
                    $dev->setMountPoint($ar_buf[0]);
307
				$arrBuf = explode( "\n", $strBuf );
1264
                    $dev->setName("SWAP");
308
				foreach( $arrBuf as $strLine ) {
1265
                    $dev->setTotal($ar_buf[2] * 1024);
309
					if( preg_match( '/Bus/', $strLine ) ) {
1266
                    $dev->setUsed($ar_buf[3] * 1024);
310
						$booDevice = true;
1267
                    $dev->setFree($dev->getTotal() - $dev->getUsed());
311
						continue;
1268
                    $this->sys->setSwapDevices($dev);
312
					}
1269
                }
313
					if( $booDevice ) {
1270
            }
314
						list( $strKey, $strValue ) = explode( ': ', $strLine, 2 );
1271
        }
315
						if( ! preg_match( '/bridge/i', $strKey ) && ! preg_match( '/USB/i ', $strKey ) ) {
1272
    }
316
							$arrResults[] = preg_replace( '/\([^\)]+\)\.$/', '', trim( $strValue ) );
1273
 
317
						}
1274
    /**
318
						$booDevice = false;
1275
     * filesystem information
319
					}
1276
     *
320
				}
1277
     * @return void
321
				asort( $arrResults );
1278
     */
322
			}
1279
    private function _filesystems()
323
		}
1280
    {
324
		return $arrResults;
1281
        $df_args = "";
325
	} 
1282
        $hideFstypes = array();
326
 
1283
        if (defined('PSI_HIDE_FS_TYPES') && is_string(PSI_HIDE_FS_TYPES)) {
327
  function ide () {
1284
            if (preg_match(ARRAY_EXP, PSI_HIDE_FS_TYPES)) {
328
    $results = array();
1285
                $hideFstypes = eval(PSI_HIDE_FS_TYPES);
329
    $bufd = gdc( '/proc/ide', false );
1286
            } else {
330
 
1287
                $hideFstypes = array(PSI_HIDE_FS_TYPES);
331
    foreach( $bufd as $file ) {
1288
            }
332
      if (preg_match('/^hd/', $file)) {
1289
        }
333
        $results[$file] = array(); 
1290
        foreach ($hideFstypes as $Fstype) {
334
	$buf = rfts("/proc/ide/" . $file . "/media", 1 );
1291
            $df_args .= "-x $Fstype ";
335
        if ( $buf != "ERROR" ) {
1292
        }
336
          $results[$file]['media'] = trim($buf);
1293
        if ($df_args !== "") {
337
          if ($results[$file]['media'] == 'disk') {
1294
            $df_args = trim($df_args); //trim spaces
338
            $results[$file]['media'] = 'Hard Disk';
1295
            $arrResult = Parser::df("-P $df_args 2>/dev/null");
339
	    $buf = rfts( "/proc/ide/" . $file . "/capacity", 1, 4096, false);
-
 
340
	    if( $buf == "ERROR" ) {
-
 
341
		$buf = rfts( "/sys/block/" . $file . "/size", 1, 4096, false);
-
 
342
	    }
-
 
343
	    if ( $buf != "ERROR" ) {
-
 
344
    	        $results[$file]['capacity'] = trim( $buf );
-
 
345
    	    } 
-
 
346
          } elseif ($results[$file]['media'] == 'cdrom') {
-
 
347
            $results[$file]['media'] = 'CD-ROM';
-
 
348
	    unset($results[$file]['capacity']);
-
 
349
          } 
-
 
350
        } else {
1296
        } else {
-
 
1297
            $arrResult = Parser::df("-P 2>/dev/null");
-
 
1298
        }
351
		unset($results[$file]);
1299
        foreach ($arrResult as $dev) {
-
 
1300
            $this->sys->setDiskDevices($dev);
-
 
1301
        }
352
	} 
1302
    }
353
 
1303
 
354
	$buf = rfts( "/proc/ide/" . $file . "/model", 1 );
1304
    /**
355
        if ( $buf != "ERROR" ) {
1305
     * Distribution
356
          $results[$file]['model'] = trim( $buf );
1306
     *
357
          if (preg_match('/WDC/', $results[$file]['model'])) {
1307
     * @return void
358
            $results[$file]['manufacture'] = 'Western Digital';
1308
     */
359
          } elseif (preg_match('/IBM/', $results[$file]['model'])) {
1309
    protected function _distro()
360
            $results[$file]['manufacture'] = 'IBM';
1310
    {
361
          } elseif (preg_match('/FUJITSU/', $results[$file]['model'])) {
1311
        $this->sys->setDistribution("Linux");
362
            $results[$file]['manufacture'] = 'Fujitsu';
1312
        $list = @parse_ini_file(PSI_APP_ROOT."/data/distros.ini", true);
363
          } else {
1313
        if (!$list) {
364
            $results[$file]['manufacture'] = 'Unknown';
1314
            return;
365
          } 
1315
        }
366
        } 
1316
        // We have the '2>/dev/null' because Ubuntu gives an error on this command which causes the distro to be unknown
367
	
1317
        if (CommonFunctions::executeProgram('lsb_release', '-a 2>/dev/null', $distro_info, PSI_DEBUG) && (strlen($distro_info) > 0)) {
368
      } 
1318
            $distro_tmp = preg_split("/\n/", $distro_info, -1, PREG_SPLIT_NO_EMPTY);
369
    } 
1319
            foreach ($distro_tmp as $info) {
370
 
1320
                $info_tmp = preg_split('/:/', $info, 2);
371
    asort($results);
1321
                if (isset($distro_tmp[0]) && !is_null($distro_tmp[0]) && (trim($distro_tmp[0]) != "") &&
372
    return $results;
1322
                     isset($distro_tmp[1]) && !is_null($distro_tmp[1]) && (trim($distro_tmp[1]) != "")) {
373
  } 
1323
                    $distro[trim($info_tmp[0])] = trim($info_tmp[1]);
374
 
1324
                }
375
  function scsi () {
1325
            }
376
    $results = array();
1326
            if (!isset($distro['Distributor ID']) && !isset($distro['Description'])) { // Systems like StartOS
377
    $dev_vendor = '';
1327
                if (isset($distro_tmp[0]) && !is_null($distro_tmp[0]) && (trim($distro_tmp[0]) != "")) {
378
    $dev_model = '';
1328
                    $this->sys->setDistribution(trim($distro_tmp[0]));
379
    $dev_rev = '';
1329
                    if (preg_match('/^(\S+)\s*/', $distro_tmp[0], $id_buf)
380
    $dev_type = '';
1330
                        && isset($list[trim($id_buf[1])]['Image'])) {
381
    $s = 1;
1331
                            $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
382
    $get_type = 0;
1332
                    }
383
 
1333
                }
384
    $bufr = execute_program('lsscsi', '-c', false);
1334
            } else {
385
    if( $bufr == "ERROR" ) {
1335
                if (isset($distro['Description'])
386
    	$bufr = rfts( '/proc/scsi/scsi', 0, 4096, false);
1336
                   && preg_match('/^NAME=\s*"?([^"\n]+)"?\s*$/', $distro['Description'], $name_tmp)) {
387
    }
1337
                   $distro['Description'] = $name_tmp[1];
388
    if ( $bufr != "ERROR" ) {
1338
                }
389
      $bufe = explode("\n", $bufr);
1339
                if (isset($distro['Description'])
390
      foreach( $bufe as $buf ) {
1340
                   && ($distro['Description'] != "n/a")
391
        if (preg_match('/Vendor/', $buf)) {
1341
                   && (!isset($distro['Distributor ID'])
392
          preg_match('/Vendor: (.*) Model: (.*) Rev: (.*)/i', $buf, $dev);
1342
                   || (($distro['Distributor ID'] != "n/a")
393
          list($key, $value) = explode(': ', $buf, 2);
1343
                   && ($distro['Description'] != $distro['Distributor ID'])))) {
394
          $dev_str = $value;
1344
                    $this->sys->setDistribution($distro['Description']);
395
          $get_type = true;
1345
                    if (isset($distro['Release']) && ($distro['Release'] != "n/a")
396
          continue;
1346
                       && ($distro['Release'] != $distro['Description']) && strstr($distro['Release'], ".")){
397
        } 
1347
                        if (preg_match("/^(\d+)\.[0]+$/", $distro['Release'], $match_buf)) {
398
 
1348
                            $tofind = $match_buf[1];
399
        if ($get_type) {
1349
                        } else {
400
          preg_match('/Type:\s+(\S+)/i', $buf, $dev_type);
1350
                            $tofind = $distro['Release'];
401
          $results[$s]['model'] = "$dev[1] $dev[2] ($dev_type[1])";
1351
                        }
402
          $results[$s]['media'] = "Hard Disk";
1352
                        if (!preg_match("/^".$tofind."[\s\.]|[\(\[]".$tofind."[\.\)\]]|\s".$tofind."$|\s".$tofind."[\s\.]/", $distro['Description'])) {
403
          $s++;
1353
                            $this->sys->setDistribution($this->sys->getDistribution()." ".$distro['Release']);
404
          $get_type = false;
1354
                        }
405
        } 
1355
                    }
406
      } 
1356
                } elseif (isset($distro['Distributor ID']) && ($distro['Distributor ID'] != "n/a")) {
407
    } 
1357
                    $this->sys->setDistribution($distro['Distributor ID']);
408
    asort($results);
1358
                    if (isset($distro['Release']) && ($distro['Release'] != "n/a")) {
409
    return $results;
1359
                        $this->sys->setDistribution($this->sys->getDistribution()." ".$distro['Release']);
410
  } 
1360
                    }
411
 
1361
                    if (isset($distro['Codename']) && ($distro['Codename'] != "n/a")) {
412
  function usb () {
1362
                        $this->sys->setDistribution($this->sys->getDistribution()." (".$distro['Codename'].")");
413
    $results = array();
1363
                    }
414
    $devnum = -1;
1364
                }
415
 
1365
                if (isset($distro['Distributor ID']) && ($distro['Distributor ID'] != "n/a") && isset($list[$distro['Distributor ID']]['Image'])) {
416
    $bufr = execute_program('lsusb', '', false);
1366
                    $this->sys->setDistributionIcon($list[$distro['Distributor ID']]['Image']);
417
    if( $bufr == "ERROR" ) {
1367
                } elseif (isset($distro['Description']) && ($distro['Description'] != "n/a")) {
418
	$bufr = rfts( '/proc/bus/usb/devices', 0, 4096, false );
1368
                    $this->sys->setDistribution($distro['Description']);
419
        if ( $bufr != "ERROR" ) {
1369
                    if (isset($list[$distro['Description']]['Image'])) {
420
    	    $bufe = explode("\n", $bufr);
1370
                        $this->sys->setDistributionIcon($list[$distro['Description']]['Image']);
421
	    foreach( $bufe as $buf ) {
1371
                    }
422
        	if (preg_match('/^T/', $buf)) {
1372
                }
423
            	    $devnum += 1;
1373
            }
424
    		    $results[$devnum] = "";
1374
        } else {
425
        	} elseif (preg_match('/^S:/', $buf)) {
1375
            /* default error handler */
426
            	    list($key, $value) = explode(': ', $buf, 2);
1376
            if (function_exists('errorHandlerPsi')) {
427
            	    list($key, $value2) = explode('=', $value, 2);
1377
                restore_error_handler();
428
    		    if (trim($key) != "SerialNumber") {
1378
            }
429
            		$results[$devnum] .= " " . trim($value2);
1379
            /* fatal errors only */
430
            		$devstring = 0;
1380
            $old_err_rep = error_reporting();
431
    		    }
1381
            error_reporting(E_ERROR);
432
        	} 
1382
 
433
            }
1383
            // Fall back in case 'lsb_release' does not exist but exist /etc/lsb-release
434
        } 
1384
            if (CommonFunctions::fileexists($filename="/etc/lsb-release")
435
    } else {
1385
               && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
436
	$bufe = explode( "\n", $bufr );
1386
               && preg_match('/^DISTRIB_ID="?([^"\n]+)"?/m', $buf, $id_buf)) {
437
	foreach( $bufe as $buf ) {
1387
                if (preg_match('/^DISTRIB_DESCRIPTION="?([^"\n]+)"?/m', $buf, $desc_buf)
438
	    $device = preg_split("/ /", $buf, 7);
1388
                   && (trim($desc_buf[1])!=trim($id_buf[1]))) {
439
	    if( isset( $device[6] ) && trim( $device[6] ) != "" ) {
1389
                    $this->sys->setDistribution(trim($desc_buf[1]));
440
		$results[$devnum++] = trim( $device[6] );
1390
                    if (preg_match('/^DISTRIB_RELEASE="?([^"\n]+)"?/m', $buf, $vers_buf)
441
	    }
1391
                       && (trim($vers_buf[1])!=trim($desc_buf[1])) && strstr($vers_buf[1], ".")){
442
	}
1392
                        if (preg_match("/^(\d+)\.[0]+$/", trim($vers_buf[1]), $match_buf)) {
443
    }
1393
                            $tofind = $match_buf[1];
444
    return $results;
1394
                        } else {
445
  } 
1395
                            $tofind = trim($vers_buf[1]);
446
 
1396
                        }
447
  function sbus () {
1397
                        if (!preg_match("/^".$tofind."[\s\.]|[\(\[]".$tofind."[\.\)\]]|\s".$tofind."$|\s".$tofind."[\s\.]/", trim($desc_buf[1]))) {
448
    $results = array();
1398
                            $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
449
    $_results[0] = ""; 
1399
                        }
450
    // TODO. Nothing here yet. Move along.
1400
                    }
451
    $results = $_results;
1401
                } else {
452
    return $results;
1402
                    if (isset($list[trim($id_buf[1])]['Name'])) {
453
  } 
1403
                        $this->sys->setDistribution(trim($list[trim($id_buf[1])]['Name']));
454
 
1404
                    } else {
455
  function network () {
1405
                        $this->sys->setDistribution(trim($id_buf[1]));
456
    $results = array();
1406
                    }
457
 
1407
                    if (preg_match('/^DISTRIB_RELEASE="?([^"\n]+)"?/m', $buf, $vers_buf)) {
458
    $bufr = rfts( '/proc/net/dev' );
1408
                        $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
459
    if ( $bufr != "ERROR" ) {
1409
                    }
460
      $bufe = explode("\n", $bufr);
1410
                    if (preg_match('/^DISTRIB_CODENAME="?([^"\n]+)"?/m', $buf, $vers_buf)) {
461
      foreach( $bufe as $buf ) {
1411
                        $this->sys->setDistribution($this->sys->getDistribution()." (".trim($vers_buf[1]).")");
462
        if (preg_match('/:/', $buf)) {
1412
                    }
463
          list($dev_name, $stats_list) = preg_split('/:/', $buf, 2);
1413
                }
464
          $stats = preg_split('/\s+/', trim($stats_list));
1414
                if (isset($list[trim($id_buf[1])]['Image'])) {
465
          $results[$dev_name] = array();
1415
                    $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
466
 
1416
                }
467
          $results[$dev_name]['rx_bytes'] = $stats[0];
1417
            } else { // otherwise find files specific for distribution
468
          $results[$dev_name]['rx_packets'] = $stats[1];
1418
                foreach ($list as $section=>$distribution) {
469
          $results[$dev_name]['rx_errs'] = $stats[2];
1419
                    if (!isset($distribution['Files'])) {
470
          $results[$dev_name]['rx_drop'] = $stats[3];
1420
                        continue;
471
 
1421
                    } else {
472
          $results[$dev_name]['tx_bytes'] = $stats[8];
1422
                        foreach (preg_split("/;/", $distribution['Files'], -1, PREG_SPLIT_NO_EMPTY) as $filename) {
473
          $results[$dev_name]['tx_packets'] = $stats[9];
1423
                            if (CommonFunctions::fileexists($filename)) {
474
          $results[$dev_name]['tx_errs'] = $stats[10];
1424
                                $distro = $distribution;
475
          $results[$dev_name]['tx_drop'] = $stats[11];
1425
                                if (isset($distribution['Mode'])&&(strtolower($distribution['Mode'])=="detection")) {
476
 
1426
                                    $buf = "";
477
          $results[$dev_name]['errs'] = $stats[2] + $stats[10];
1427
                                } elseif (isset($distribution['Mode'])&&(strtolower($distribution['Mode'])=="execute")) {
478
          $results[$dev_name]['drop'] = $stats[3] + $stats[11];
1428
                                    if (!CommonFunctions::executeProgram($filename, '2>/dev/null', $buf, PSI_DEBUG)) {
479
        } 
1429
                                        $buf = "";
480
      }
1430
                                    }
481
    }
1431
                                } else {
482
    return $results;
1432
                                    if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) {
483
  } 
1433
                                        $buf = "";
484
 
1434
                                    } elseif (isset($distribution['Mode'])&&(strtolower($distribution['Mode'])=="analyse")) {
485
  function memory () {
1435
                                        if (preg_match('/^(\S+)\s*/', preg_replace('/^Red\s+/', 'Red', $buf), $id_buf)
486
    $results['ram'] = array('total' => 0, 'free' => 0, 'used' => 0, 'percent' => 0);
1436
                                           && isset($list[trim($id_buf[1])]['Image'])) {
487
    $results['swap'] = array('total' => 0, 'free' => 0, 'used' => 0, 'percent' => 0);
1437
                                            $distro = $list[trim($id_buf[1])];
488
    $results['devswap'] = array();
1438
                                        }
489
 
1439
                                    }
490
    $bufr = rfts( '/proc/meminfo' );
1440
                                }
491
    if ( $bufr != "ERROR" ) {
1441
                                if (isset($distro['Image'])) {
492
      $bufe = explode("\n", $bufr);
1442
                                    $this->sys->setDistributionIcon($distro['Image']);
493
      foreach( $bufe as $buf ) {
1443
                                }
494
        if (preg_match('/^MemTotal:\s+(.*)\s*kB/i', $buf, $ar_buf)) {
1444
                                if (isset($distribution['Name'])) {
495
          $results['ram']['total'] = $ar_buf[1];
1445
                                    if (is_null($buf) || (trim($buf) == "")) {
496
        } else if (preg_match('/^MemFree:\s+(.*)\s*kB/i', $buf, $ar_buf)) {
1446
                                        $this->sys->setDistribution($distribution['Name']);
497
          $results['ram']['free'] = $ar_buf[1];
1447
                                    } else {
498
        } else if (preg_match('/^Cached:\s+(.*)\s*kB/i', $buf, $ar_buf)) {
1448
                                        $this->sys->setDistribution($distribution['Name']." ".trim($buf));
499
          $results['ram']['cached'] = $ar_buf[1];
1449
                                    }
500
        } else if (preg_match('/^Buffers:\s+(.*)\s*kB/i', $buf, $ar_buf)) {
1450
                                } else {
501
          $results['ram']['buffers'] = $ar_buf[1];
1451
                                    if (is_null($buf) || (trim($buf) == "")) {
502
        } 
1452
                                        $this->sys->setDistribution($section);
503
      } 
1453
                                    } else {
504
 
1454
                                        $this->sys->setDistribution(trim($buf));
505
      $results['ram']['used'] = $results['ram']['total'] - $results['ram']['free'];
1455
                                    }
506
      $results['ram']['percent'] = round(($results['ram']['used'] * 100) / $results['ram']['total']);
1456
                                }
507
      
1457
                                if (isset($distribution['Files2'])) {
508
      // values for splitting memory usage
1458
                                    foreach (preg_split("/;/", $distribution['Files2'], -1, PREG_SPLIT_NO_EMPTY) as $filename2) {
509
      if (isset($results['ram']['cached']) && isset($results['ram']['buffers'])) {
1459
                                        if (CommonFunctions::fileexists($filename2) && CommonFunctions::rfts($filename2, $buf, 0, 4096, false)) {
510
        $results['ram']['app'] = $results['ram']['used'] - $results['ram']['cached'] - $results['ram']['buffers'];
1460
                                            if (preg_match('/^majorversion="?([^"\n]+)"?/m', $buf, $maj_buf)
511
	$results['ram']['app_percent'] = round(($results['ram']['app'] * 100) / $results['ram']['total']);
1461
                                               && preg_match('/^minorversion="?([^"\n]+)"?/m', $buf, $min_buf)) {
512
	$results['ram']['buffers_percent'] = round(($results['ram']['buffers'] * 100) / $results['ram']['total']);
1462
                                                $distr2=$maj_buf[1].'.'.$min_buf[1];
513
	$results['ram']['cached_percent'] = round(($results['ram']['cached'] * 100) / $results['ram']['total']);
1463
                                                if (preg_match('/^buildphase="?([^"\n]+)"?/m', $buf, $pha_buf) && ($pha_buf[1]!=="0")) {
514
      }
1464
                                                    $distr2.='.'.$pha_buf[1];
515
 
1465
                                                }
516
      $bufr = rfts( '/proc/swaps' );
1466
                                                if (preg_match('/^buildnumber="?([^"\n]+)"?/m', $buf, $num_buf)) {
517
      if ( $bufr != "ERROR" ) {
1467
                                                    $distr2.='-'.$num_buf[1];
518
        $swaps = explode("\n", $bufr);
1468
                                                }
519
        for ($i = 1; $i < (sizeof($swaps)); $i++) {
1469
                                                if (preg_match('/^builddate="?([^"\n]+)"?/m', $buf, $dat_buf)) {
520
	  if( trim( $swaps[$i] ) != "" ) {
1470
                                                    $distr2.=' ('.$dat_buf[1].')';
521
            $ar_buf = preg_split('/\s+/', $swaps[$i], 6);
1471
                                                }
522
            $results['devswap'][$i - 1] = array();
1472
                                                $this->sys->setDistribution($this->sys->getDistribution()." ".$distr2);
523
            $results['devswap'][$i - 1]['dev'] = $ar_buf[0];
1473
                                            } else {
524
            $results['devswap'][$i - 1]['total'] = $ar_buf[2];
1474
                                                $distr2=trim(substr($buf, 0, strpos($buf, "\n")));
525
            $results['devswap'][$i - 1]['used'] = $ar_buf[3];
1475
                                                if (!is_null($distr2) && ($distr2 != "")) {
526
            $results['devswap'][$i - 1]['free'] = ($results['devswap'][$i - 1]['total'] - $results['devswap'][$i - 1]['used']);
1476
                                                    $this->sys->setDistribution($this->sys->getDistribution()." ".$distr2);
527
            $results['devswap'][$i - 1]['percent'] = round(($ar_buf[3] * 100) / $ar_buf[2]);
1477
                                                }
528
	    $results['swap']['total'] += $ar_buf[2];
1478
                                            }
529
	    $results['swap']['used'] += $ar_buf[3];
1479
                                            break;
530
	    $results['swap']['free'] = $results['swap']['total'] - $results['swap']['used'];
1480
                                        }
531
	    $results['swap']['percent'] = round(($results['swap']['used'] * 100) / $results['swap']['total']);
1481
                                    }
532
	  }
1482
                                }
533
        } 
1483
                                break 2;
534
      }
1484
                            }
535
    }
1485
                        }
536
    return $results;
1486
                    }
537
  } 
1487
                }
538
  
1488
            }
539
  function filesystems () {
1489
            // if the distribution is still unknown
540
    return $this->parser->parse_filesystems();
1490
            if ($this->sys->getDistribution() == "Linux") {
541
  } 
1491
                if (CommonFunctions::fileexists($filename="/etc/DISTRO_SPECS")
542
 
1492
                   && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
543
  function distro () {
1493
                   && preg_match('/^DISTRO_NAME=\'(.+)\'/m', $buf, $id_buf)) {
544
   return $this->distro;
1494
                    if (isset($list[trim($id_buf[1])]['Name'])) {
545
  }
1495
                        $dist = trim($list[trim($id_buf[1])]['Name']);
546
 
1496
                    } else {
547
  function distroicon () {   
1497
                        $dist = trim($id_buf[1]);
548
   return $this->icon;
1498
                    }
549
  }
1499
                    if (preg_match('/^DISTRO_VERSION=([^#\n\r]+)/m', $buf, $vers_buf)) {
-
 
1500
                        $this->sys->setDistribution(trim($dist." ".trim($vers_buf[1])));
-
 
1501
                    } else {
-
 
1502
                        $this->sys->setDistribution($dist);
-
 
1503
                    }
-
 
1504
                    if (isset($list[trim($id_buf[1])]['Image'])) {
-
 
1505
                        $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
-
 
1506
                    } else {
-
 
1507
                        if (isset($list['Puppy']['Image'])) {
-
 
1508
                            $this->sys->setDistributionIcon($list['Puppy']['Image']);
-
 
1509
                        }
-
 
1510
                    }
-
 
1511
                } elseif ((CommonFunctions::fileexists($filename="/etc/distro-release")
-
 
1512
                        && CommonFunctions::rfts($filename, $buf, 1, 4096, false)
-
 
1513
                        && !is_null($buf) && (trim($buf) != ""))
-
 
1514
                    || (CommonFunctions::fileexists($filename="/etc/system-release")
-
 
1515
                        && CommonFunctions::rfts($filename, $buf, 1, 4096, false)
-
 
1516
                        && !is_null($buf) && (trim($buf) != ""))) {
-
 
1517
                    $this->sys->setDistribution(trim($buf));
-
 
1518
                    if (preg_match('/^(\S+)\s*/', preg_replace('/^Red\s+/', 'Red', $buf), $id_buf)
-
 
1519
                        && isset($list[trim($id_buf[1])]['Image'])) {
-
 
1520
                            $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
-
 
1521
                    }
-
 
1522
                } elseif (CommonFunctions::fileexists($filename="/etc/solydxk/info")
-
 
1523
                   && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
-
 
1524
                   && preg_match('/^DISTRIB_ID="?([^"\n]+)"?/m', $buf, $id_buf)) {
-
 
1525
                    if (preg_match('/^DESCRIPTION="?([^"\n]+)"?/m', $buf, $desc_buf)
-
 
1526
                       && (trim($desc_buf[1])!=trim($id_buf[1]))) {
-
 
1527
                        $this->sys->setDistribution(trim($desc_buf[1]));
-
 
1528
                    } else {
-
 
1529
                        if (isset($list[trim($id_buf[1])]['Name'])) {
-
 
1530
                            $this->sys->setDistribution(trim($list[trim($id_buf[1])]['Name']));
-
 
1531
                        } else {
-
 
1532
                            $this->sys->setDistribution(trim($id_buf[1]));
-
 
1533
                        }
-
 
1534
                        if (preg_match('/^RELEASE="?([^"\n]+)"?/m', $buf, $vers_buf)) {
-
 
1535
                            $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
-
 
1536
                        }
-
 
1537
                        if (preg_match('/^CODENAME="?([^"\n]+)"?/m', $buf, $vers_buf)) {
-
 
1538
                            $this->sys->setDistribution($this->sys->getDistribution()." (".trim($vers_buf[1]).")");
-
 
1539
                        }
-
 
1540
                    }
-
 
1541
                    if (isset($list[trim($id_buf[1])]['Image'])) {
-
 
1542
                        $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
-
 
1543
                    } else {
-
 
1544
                        $this->sys->setDistributionIcon($list['SolydXK']['Image']);
-
 
1545
                    }
-
 
1546
                } elseif (CommonFunctions::fileexists($filename="/etc/os-release")
-
 
1547
                   && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
-
 
1548
                   && (preg_match('/^TAILS_VERSION_ID="?([^"\n]+)"?/m', $buf, $tid_buf)
-
 
1549
                   || preg_match('/^NAME="?([^"\n]+)"?/m', $buf, $id_buf))) {
-
 
1550
                    if (preg_match('/^TAILS_VERSION_ID="?([^"\n]+)"?/m', $buf, $tid_buf)) {
-
 
1551
                        if (preg_match('/^TAILS_PRODUCT_NAME="?([^"\n]+)"?/m', $buf, $desc_buf)) {
-
 
1552
                            $this->sys->setDistribution(trim($desc_buf[1])." ".trim($tid_buf[1]));
-
 
1553
                        } else {
-
 
1554
                            if (isset($list['Tails']['Name'])) {
-
 
1555
                                $this->sys->setDistribution(trim($list['Tails']['Name'])." ".trim($tid_buf[1]));
-
 
1556
                            } else {
-
 
1557
                                $this->sys->setDistribution('Tails'." ".trim($tid_buf[1]));
-
 
1558
                            }
-
 
1559
                        }
-
 
1560
                        $this->sys->setDistributionIcon($list['Tails']['Image']);
-
 
1561
                    } else {
-
 
1562
                        if (preg_match('/^PRETTY_NAME="?([^"\n]+)"?/m', $buf, $desc_buf)
-
 
1563
                           && !preg_match('/\$/', $desc_buf[1])) { //if is not defined by variable
-
 
1564
                            $this->sys->setDistribution(trim($desc_buf[1]));
-
 
1565
                        } else {
-
 
1566
                            if (isset($list[trim($id_buf[1])]['Name'])) {
-
 
1567
                                $this->sys->setDistribution(trim($list[trim($id_buf[1])]['Name']));
-
 
1568
                            } else {
-
 
1569
                                $this->sys->setDistribution(trim($id_buf[1]));
-
 
1570
                            }
-
 
1571
                            if (preg_match('/^VERSION="?([^"\n]+)"?/m', $buf, $vers_buf)) {
-
 
1572
                                $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
-
 
1573
                            } elseif (preg_match('/^VERSION_ID="?([^"\n]+)"?/m', $buf, $vers_buf)) {
-
 
1574
                                $this->sys->setDistribution($this->sys->getDistribution()." ".trim($vers_buf[1]));
-
 
1575
                            }
-
 
1576
                        }
-
 
1577
                        if (isset($list[trim($id_buf[1])]['Image'])) {
-
 
1578
                            $this->sys->setDistributionIcon($list[trim($id_buf[1])]['Image']);
-
 
1579
                        }
-
 
1580
                    }
-
 
1581
                } elseif (CommonFunctions::fileexists($filename="/etc/debian_version")) {
-
 
1582
                    if (!CommonFunctions::rfts($filename, $buf, 1, 4096, false)) {
-
 
1583
                        $buf = "";
-
 
1584
                    }
-
 
1585
                    if (isset($list['Debian']['Image'])) {
-
 
1586
                        $this->sys->setDistributionIcon($list['Debian']['Image']);
-
 
1587
                    }
-
 
1588
                    if (isset($list['Debian']['Name'])) {
-
 
1589
                        if (is_null($buf) || (trim($buf) == "")) {
-
 
1590
                            $this->sys->setDistribution($list['Debian']['Name']);
-
 
1591
                        } else {
-
 
1592
                            $this->sys->setDistribution($list['Debian']['Name']." ".trim($buf));
-
 
1593
                        }
-
 
1594
                    } else {
-
 
1595
                        if (is_null($buf) || (trim($buf) == "")) {
-
 
1596
                            $this->sys->setDistribution('Debian');
-
 
1597
                        } else {
-
 
1598
                            $this->sys->setDistribution(trim($buf));
-
 
1599
                        }
-
 
1600
                    }
-
 
1601
                } elseif (CommonFunctions::fileexists($filename="/etc/config/uLinux.conf")
-
 
1602
                   && CommonFunctions::rfts($filename, $buf, 0, 4096, false)
-
 
1603
                   && preg_match("/^Rsync\sModel\s*=\s*QNAP/m", $buf)
-
 
1604
                   && preg_match("/^Version\s*=\s*([\d\.]+)\r?\nBuild\sNumber\s*=\s*(\S+)/m", $buf, $ver_buf)) {
-
 
1605
                    $buf = $ver_buf[1]."-".$ver_buf[2];
-
 
1606
                    if (isset($list['QTS']['Image'])) {
-
 
1607
                        $this->sys->setDistributionIcon($list['QTS']['Image']);
-
 
1608
                    }
-
 
1609
                    if (isset($list['QTS']['Name'])) {
-
 
1610
                        $this->sys->setDistribution($list['QTS']['Name']." ".trim($buf));
-
 
1611
                    } else {
-
 
1612
                        $this->sys->setDistribution(trim($buf));
-
 
1613
                    }
-
 
1614
                }
-
 
1615
            }
-
 
1616
            /* restore error level */
-
 
1617
            error_reporting($old_err_rep);
-
 
1618
            /* restore error handler */
-
 
1619
            if (function_exists('errorHandlerPsi')) {
-
 
1620
                set_error_handler('errorHandlerPsi');
-
 
1621
            }
-
 
1622
        }
-
 
1623
    }
550
 
1624
 
-
 
1625
    /**
-
 
1626
     * Processes
-
 
1627
     *
-
 
1628
     * @return void
-
 
1629
     */
-
 
1630
    protected function _processes()
551
} 
1631
    {
-
 
1632
        $process = glob('/proc/*/status', GLOB_NOSORT);
-
 
1633
        if (is_array($process) && (($total = count($process)) > 0)) {
-
 
1634
            $processes['*'] = 0;
-
 
1635
            $buf = "";
-
 
1636
            for ($i = 0; $i < $total; $i++) {
-
 
1637
                if (CommonFunctions::rfts($process[$i], $buf, 0, 4096, false)) {
-
 
1638
                    $processes['*']++; //current total
-
 
1639
                    if (preg_match('/^State:\s+(\w)/m', $buf, $state)) {
-
 
1640
                        if (isset($processes[$state[1]])) {
-
 
1641
                            $processes[$state[1]]++;
-
 
1642
                        } else {
-
 
1643
                            $processes[$state[1]] = 1;
-
 
1644
                        }
-
 
1645
                    }
-
 
1646
                }
-
 
1647
            }
-
 
1648
            if (!($processes['*'] > 0)) {
-
 
1649
                $processes['*'] = $processes[' '] = $total; //all unknown
-
 
1650
            }
-
 
1651
            $this->sys->setProcesses($processes);
-
 
1652
        }
-
 
1653
    }
552
 
1654
 
-
 
1655
    /**
-
 
1656
     * get the information
-
 
1657
     *
-
 
1658
     * @see PSI_Interface_OS::build()
-
 
1659
     *
-
 
1660
     * @return Void
-
 
1661
     */
-
 
1662
    public function build()
-
 
1663
    {
-
 
1664
        if (!$this->blockname || $this->blockname==='vitals') {
-
 
1665
            $this->_distro();
-
 
1666
            $this->_hostname();
-
 
1667
            $this->_kernel();
-
 
1668
            $this->_uptime();
-
 
1669
            $this->_users();
-
 
1670
            $this->_loadavg();
-
 
1671
            $this->_processes();
-
 
1672
        }
-
 
1673
        if (!$this->blockname || $this->blockname==='hardware') {
-
 
1674
            $this->_machine();
-
 
1675
            $this->_cpuinfo();
-
 
1676
            $this->_pci();
-
 
1677
            $this->_ide();
-
 
1678
            $this->_scsi();
-
 
1679
            $this->_nvme();
-
 
1680
            $this->_usb();
-
 
1681
            $this->_i2c();
-
 
1682
        }
-
 
1683
        if (!$this->blockname || $this->blockname==='network') {
-
 
1684
            $this->_network();
-
 
1685
        }
-
 
1686
        if (!$this->blockname || $this->blockname==='memory') {
-
 
1687
            $this->_memory();
-
 
1688
        }
-
 
1689
        if (!$this->blockname || $this->blockname==='filesystem') {
-
 
1690
            $this->_filesystems();
-
 
1691
        }
-
 
1692
    }
553
?>
1693
}