Issues (1626)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

phpsysinfo/includes/os/class.Haiku.inc.php (17 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Haiku System Class
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PSI Haiku OS class
9
 * @author    Mieczyslaw Nalewaj <[email protected]>
10
 * @copyright 2012 phpSysInfo
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License
12
 * @version   SVN: $Id: class.Haiku.inc.php 687 2012-09-06 20:54:49Z namiltd $
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
15
 /**
16
 * Haiku sysinfo class
17
 * get all the required information from Haiku system
18
 *
19
 * @category  PHP
20
 * @package   PSI Haiku OS class
21
 * @author    Mieczyslaw Nalewaj <[email protected]>
22
 * @copyright 2012 phpSysInfo
23
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License
24
 * @version   Release: 3.0
25
 * @link      http://phpsysinfo.sourceforge.net
26
 */
27
class Haiku extends OS
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
28
{
29
    /**
30
     * call parent constructor
31
     */
32
    public function __construct()
33
    {
34
        parent::__construct();
35
    }
36
37
    /**
38
     * get the cpu information
39
     *
40
     * @return array
0 ignored issues
show
Should the return type not be array|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
41
     */
42
    protected function _cpuinfo()
43
    {
44
45
        if (CommonFunctions::executeProgram('sysinfo', '-cpu', $bufr, PSI_DEBUG)) {
46
            $cpus = preg_split("/\nCPU #\d+/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
47
            $cpuspeed = "";
48
            foreach ($cpus as $cpu) {
49
                if (preg_match("/^.*running at (\d+)MHz/", $cpu, $ar_buf)) {
50
                    $cpuspeed = $ar_buf[1];
51
                } elseif (preg_match("/^: \"(.*)\"/", $cpu, $ar_buf)) {
52
                    $dev = new CpuDevice();
53
                    $dev->setModel($ar_buf[1]);
54
                    $arrLines = preg_split("/\n/", $cpu, -1, PREG_SPLIT_NO_EMPTY);
55
                    foreach ($arrLines as $Line) {
56
                        if (preg_match("/^\s+Data TLB:\s+(.*)K-byte/", $Line, $Line_buf)) {
57
                            $dev->setCache(max($Line_buf[1]*1024, $dev->getCache()));
58
                        } elseif (preg_match("/^\s+Data TLB:\s+(.*)M-byte/", $Line, $Line_buf)) {
59
                            $dev->setCache(max($Line_buf[1]*1024*1024, $dev->getCache()));
60
                        } elseif (preg_match("/^\s+Data TLB:\s+(.*)G-byte/", $Line, $Line_buf)) {
61
                            $dev->setCache(max($Line_buf[1]*1024*1024*1024, $dev->getCache()));
62
                        } elseif (preg_match("/\s+VMX/", $Line, $Line_buf)) {
63
                            $dev->setVirt("vmx");
64
                        } elseif (preg_match("/\s+SVM/", $Line, $Line_buf)) {
65
                            $dev->setVirt("svm");
66
                        }
67
                    }
68
                    if ($cpuspeed != "")$dev->setCpuSpeed($cpuspeed);
69
                    $this->sys->setCpus($dev);
0 ignored issues
show
$dev is of type object<CpuDevice>, but the function expects a object<Cpu>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
70
                  //echo ">>>>>".$cpu;
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
71
                }
72
            }
73
        }
74
    }
75
76
    /**
77
     * PCI devices
78
     * get the pci device information
79
     *
80
     * @return void
81
     */
82
    protected function _pci()
83
    {
84
        if (CommonFunctions::executeProgram('listdev', '', $bufr, PSI_DEBUG)) {
85
//            $devices = preg_split("/^device |\ndevice /", $bufr, -1, PREG_SPLIT_NO_EMPTY);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
86
            $devices = preg_split("/^device /m", $bufr, -1, PREG_SPLIT_NO_EMPTY);
87
            foreach ($devices as $device) {
88
                $ar_buf = preg_split("/\n/", $device);
89
                if (count($ar_buf) >= 3) {
90
                    if (preg_match("/^([^\(\[\n]*)/", $device, $ar_buf2)) {
91
                        if (preg_match("/^[^\(]*\((.*)\)/", $device, $ar_buf3)) {
92
                            $ar_buf2[1] = $ar_buf3[1];
93
                        }
94
                        $name = trim($ar_buf2[1]).": ";
95
96
                        if (preg_match("/^\s+vendor\s+[0-9a-fA-F]{4}:\s+(.*)/", $ar_buf[1], $ar_buf3)) {
97
                            $name .=$ar_buf3[1]." ";
98
                        }
99
                        if (preg_match("/^\s+device\s+[0-9a-fA-F]{4}:\s+(.*)/", $ar_buf[2], $ar_buf3)) {
100
                            $name .=$ar_buf3[1]." ";
101
                        }
102
                        $dev = new HWDevice();
103
                        $dev->setName(trim($name));
104
                        $this->sys->setPciDevices($dev);
105
                    }
106
                }
107
            }
108
        }
109
    }
110
111
    /**
112
     * USB devices
113
     * get the usb device information
114
     *
115
     * @return void
116
     */
117 View Code Duplication
    protected function _usb()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
118
    {
119
        if (CommonFunctions::executeProgram('listusb', '', $bufr, PSI_DEBUG)) {
120
            $devices = preg_split("/\n/", $bufr);
121
            foreach ($devices as $device) {
122
                if (preg_match("/^\S+\s+\S+\s+\"(.*)\"\s+\"(.*)\"/", $device, $ar_buf)) {
123
                    $dev = new HWDevice();
124
                    $dev->setName(trim($ar_buf[1]." ".$ar_buf[2]));
125
                    $this->sys->setUSBDevices($dev);
126
                }
127
            }
128
        }
129
    }
130
131
    /**
132
     * Haiku Version
133
     *
134
     * @return void
135
     */
136
    private function _kernel()
137
    {
138
        if (CommonFunctions::executeProgram('uname', '-rvm', $ret)) {
139
               $this->sys->setKernel($ret);
140
        }
141
    }
142
143
    /**
144
     * Distribution
145
     *
146
     * @return void
147
     */
148
    protected function _distro()
149
    {
150
        if (CommonFunctions::executeProgram('uname', '-sr', $ret))
151
            $this->sys->setDistribution($ret);
152
        else
153
            $this->sys->setDistribution('Haiku');
154
155
        $this->sys->setDistributionIcon('Haiku.png');
156
    }
157
158
    /**
159
     * UpTime
160
     * time the system is running
161
     *
162
     * @return void
163
     */
164
    private function _uptime()
165
    {
166
        if (CommonFunctions::executeProgram('uptime', '-u', $buf)) {
167
            if (preg_match("/^up (\d+) minute[s]?/", $buf, $ar_buf)) {
168
                $min = $ar_buf[1];
169
                $this->sys->setUptime($min * 60);
0 ignored issues
show
$min * 60 is of type integer|double, but the function expects a object<Interger>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
170
            } elseif (preg_match("/^up (\d+) hour[s]?, (\d+) minute[s]?/", $buf, $ar_buf)) {
171
                $min = $ar_buf[2];
172
                $hours = $ar_buf[1];
173
                $this->sys->setUptime($hours * 3600 + $min * 60);
0 ignored issues
show
$hours * 3600 + $min * 60 is of type double, but the function expects a object<Interger>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
174
            } elseif (preg_match("/^up (\d+) day[s]?, (\d+) hour[s]?, (\d+) minute[s]?/", $buf, $ar_buf)) {
175
                $min = $ar_buf[3];
176
                $hours = $ar_buf[2];
177
                $days = $ar_buf[1];
178
                $this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
0 ignored issues
show
$days * 86400 + $hours * 3600 + $min * 60 is of type double, but the function expects a object<Interger>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
179
            }
180
        }
181
    }
182
183
    /**
184
     * Processor Load
185
     * optionally create a loadbar
186
     *
187
     * @return void
188
     */
189
    private function _loadavg()
190
    {
191
        if (CommonFunctions::executeProgram('top', '-n 1 -i 1', $buf)) {
192
            if (preg_match("/\s+(\S+)%\s+TOTAL\s+\(\S+%\s+idle time/", $buf, $ar_buf)) {
193
                $this->sys->setLoad($ar_buf[1]);
194
                if (PSI_LOAD_BAR) {
195
                    $this->sys->setLoadPercent(round($ar_buf[1]));
196
                }
197
            }
198
        }
199
    }
200
201
    /**
202
     * Number of Users
203
     *
204
     * @return void
205
     */
206
    protected function _users()
207
    {
208
        $this->sys->setUsers(1);
209
    }
210
211
    /**
212
     * Virtual Host Name
213
     *
214
     * @return void
215
     */
216 View Code Duplication
    private function _hostname()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
217
    {
218
        if (PSI_USE_VHOST === true) {
219
            $this->sys->setHostname(getenv('SERVER_NAME'));
220
        } else {
221
            if (CommonFunctions::executeProgram('uname', '-n', $result, PSI_DEBUG)) {
222
                $ip = gethostbyname($result);
223
                if ($ip != $result) {
224
                    $this->sys->setHostname(gethostbyaddr($ip));
225
                }
226
            }
227
        }
228
    }
229
230
    /**
231
     *  Physical memory information and Swap Space information
232
     *
233
     *  @return void
234
     */
235
    private function _memory()
236
    {
237
        if (CommonFunctions::executeProgram('sysinfo', '-mem', $bufr, PSI_DEBUG)) {
238
            if (preg_match("/(.*)bytes free\s+\(used\/max\s+(.*)\s+\/\s+(.*)\)\s*\n\s+\(cached\s+(.*)\)/", $bufr, $ar_buf)) {
239
                $this->sys->setMemTotal($ar_buf[3]);
240
                $this->sys->setMemFree($ar_buf[1]);
241
                $this->sys->setMemCache($ar_buf[4]);
242
                $this->sys->setMemUsed($ar_buf[2]);
243
            }
244
        }
245
        if (CommonFunctions::executeProgram('vmstat', '', $bufr, PSI_DEBUG)) {
246
            if (preg_match("/max swap space:\s+(.*)\nfree swap space:\s+(.*)\n/", $bufr, $ar_buf)) {
247
                if ($ar_buf[1]>0) {
248
                    $dev = new DiskDevice();
249
                    $dev->setMountPoint("/boot/common/var/swap");
250
                    $dev->setName("SWAP");
251
                    $dev->setTotal($ar_buf[1]);
252
                    $dev->setFree($ar_buf[2]);
253
                    $dev->setUSed($ar_buf[1]-$ar_buf[2]);
254
                    $this->sys->setSwapDevices($dev);
255
                }
256
            }
257
        }
258
    }
259
260
    /**
261
     * filesystem information
262
     *
263
     * @return void
264
     */
265
    private function _filesystems()
266
    {
267
        if (CommonFunctions::executeProgram('df', '-b', $df, PSI_DEBUG)) {
268
        $df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY);
269
            foreach ($df as $df_line) {
270
                $ar_buf = preg_split("/\s+/", $df_line);
271
                if ((substr($df_line, 0, 1) == "/") && (count($ar_buf) == 6)) {
272
                    $dev = new DiskDevice();
273
                    $dev->setMountPoint($ar_buf[0]);
274
                    $dev->setName($ar_buf[5]);
275
                    $dev->setFsType($ar_buf[1]);
276
                    $dev->setOptions($ar_buf[4]);
277
                    $dev->setTotal($ar_buf[2] * 1024);
278
                    $dev->setFree($ar_buf[3] * 1024);
279
                    $dev->setUsed($dev->getTotal() - $dev->getFree());
280
                    $this->sys->setDiskDevices($dev);
281
                }
282
            }
283
        }
284
    }
285
286
    /**
287
     * network information
288
     *
289
     * @return void
290
     */
291
    private function _network()
292
    {
293
        if (CommonFunctions::executeProgram('ifconfig', '', $bufr, PSI_DEBUG)) {
294
            $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
295
            $was = false;
296
            foreach ($lines as $line) {
297
                if (preg_match("/^(\S+)/", $line, $ar_buf)) {
298
                    if ($was) {
299
                        $dev->setErrors($errors);
0 ignored issues
show
The variable $dev does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
The variable $errors does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
300
                        $dev->setDrops($drops);
0 ignored issues
show
The variable $drops does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
301
                        $this->sys->setNetDevices($dev);
302
                    }
303
                    $errors = 0;
304
                    $drops = 0;
305
                    $dev = new NetDevice();
306
                    $dev->setName($ar_buf[1]);
307
                    $was = true;
308
                } else {
309
                    if ($was) {
310
                        if (preg_match('/\sReceive:\s\d+\spackets,\s(\d+)\serrors,\s(\d+)\sbytes,\s\d+\smcasts,\s(\d+)\sdropped/i', $line, $ar_buf2)) {
311
                            $errors +=$ar_buf2[1];
312
                            $drops +=$ar_buf2[3];
313
                            $dev->setRxBytes($ar_buf2[2]);
314 View Code Duplication
                        } elseif (preg_match('/\sTransmit:\s\d+\spackets,\s(\d+)\serrors,\s(\d+)\sbytes,\s\d+\smcasts,\s(\d+)\sdropped/i', $line, $ar_buf2)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
315
                            $errors +=$ar_buf2[1];
316
                            $drops +=$ar_buf2[3];
317
                            $dev->setTxBytes($ar_buf2[2]);
318
                        }
319
320
                        if (defined('PSI_SHOW_NETWORK_INFOS') && (PSI_SHOW_NETWORK_INFOS)) {
321
                            if (preg_match('/\sEthernet,\s+Address:\s(\S*)/i', $line, $ar_buf2))
322
                                    $dev->setInfo(preg_replace('/:/', '-', strtoupper($ar_buf2[1])));
323
                            elseif (preg_match('/^\s+inet\saddr:\s(\S*),/i', $line, $ar_buf2))
324
                                     $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').$ar_buf2[1]);
325 View Code Duplication
                                 elseif (preg_match('/^\s+inet6\saddr:\s(\S*),/i', $line, $ar_buf2)
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
326
                                          && ($ar_buf2[1]!="::") && !preg_match('/^fe80::/i', $ar_buf2[1]))
327
                                            $dev->setInfo(($dev->getInfo()?$dev->getInfo().';':'').strtolower($ar_buf2[1]));
328
                        }
329
                    }
330
                }
331
            }
332
            if ($was) {
333
                $dev->setErrors($errors);
334
                $dev->setDrops($drops);
335
                $this->sys->setNetDevices($dev);
336
            }
337
        }
338
    }
339
340
    /**
341
     * Processes
342
     *
343
     * @return void
344
     */
345
    protected function _processes()
346
    {
347
        if (CommonFunctions::executeProgram('ps', '', $bufr, PSI_DEBUG)) {
348
            $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY);
349
            $processes['*'] = 0;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$processes was never initialized. Although not strictly required by PHP, it is generally a good practice to add $processes = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
350
            foreach ($lines as $line) {
351
                if (preg_match("/^(kernel_team|\/)/", $line, $ar_buf)) {
352
                    $processes['*']++;
353
                }
354
            }
355
            if ($processes['*'] > 0) {
356
                $processes[' '] = $processes['*'];
357
                $this->sys->setProcesses($processes);
358
            }
359
        }
360
    }
361
362
    /**
363
     * get the information
364
     *
365
     * @return Void
366
     */
367 View Code Duplication
    public function build()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
368
    {
369
        $this->error->addError("WARN", "The Haiku version of phpSysInfo is a work in progress, some things currently don't work");
370
        $this->_distro();
371
        $this->_hostname();
372
        $this->_kernel();
373
        $this->_uptime();
374
        $this->_users();
375
        $this->_loadavg();
376
        $this->_pci();
377
        $this->_usb();
378
        $this->_cpuinfo();
379
        $this->_memory();
380
        $this->_filesystems();
381
        $this->_network();
382
        $this->_processes();
383
    }
384
}
385