This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * DragonFly System Class |
||
4 | * |
||
5 | * PHP version 5 |
||
6 | * |
||
7 | * @category PHP |
||
8 | * @package PSI DragonFly OS class |
||
9 | * @author Michael Cramer <[email protected]> |
||
10 | * @copyright 2009 phpSysInfo |
||
11 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
||
12 | * @version SVN: $Id: class.DragonFly.inc.php 287 2009-06-26 12:11:59Z bigmichi1 $ |
||
13 | * @link http://phpsysinfo.sourceforge.net |
||
14 | */ |
||
15 | /** |
||
16 | * DragonFly sysinfo class |
||
17 | * get all the required information from DragonFly system |
||
18 | * |
||
19 | * @category PHP |
||
20 | * @package PSI DragonFly OS class |
||
21 | * @author Michael Cramer <[email protected]> |
||
22 | * @copyright 2009 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 DragonFly extends BSDCommon |
||
0 ignored issues
–
show
|
|||
28 | { |
||
29 | /** |
||
30 | * define the regexp for log parser |
||
31 | */ |
||
32 | View Code Duplication | public function __construct() |
|
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. ![]() |
|||
33 | { |
||
34 | parent::__construct(); |
||
35 | $this->setCPURegExp1("/^cpu(.*)\, (.*) MHz/"); |
||
36 | $this->setCPURegExp2("/^(.*) at scsibus.*: <(.*)> .*/"); |
||
37 | $this->setSCSIRegExp2("/^(da[0-9]+): (.*)MB /"); |
||
38 | $this->setPCIRegExp1("/(.*): <(.*)>(.*) (pci|legacypci)[0-9]+$/"); |
||
39 | $this->setPCIRegExp2("/(.*): <(.*)>.* at [0-9\.]+$/"); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * UpTime |
||
44 | * time the system is running |
||
45 | * |
||
46 | * @return void |
||
47 | */ |
||
48 | private function _uptime() |
||
49 | { |
||
50 | $a = $this->grab_key('kern.boottime'); |
||
0 ignored issues
–
show
|
|||
51 | preg_match("/sec = ([0-9]+)/", $a, $buf); |
||
52 | $this->sys->setUptime(time() - $buf[1]); |
||
0 ignored issues
–
show
time() - $buf[1] 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);
![]() |
|||
53 | } |
||
54 | |||
55 | /** |
||
56 | * get network information |
||
57 | * |
||
58 | * @return array |
||
0 ignored issues
–
show
|
|||
59 | */ |
||
60 | private function _network() |
||
61 | { |
||
62 | CommonFunctions::executeProgram('netstat', '-nbdi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \t].*Link"', $netstat_b); |
||
63 | CommonFunctions::executeProgram('netstat', '-ndi | cut -c1-25,44- | grep "^[a-z]*[0-9][ \t].*Link"', $netstat_n); |
||
64 | $lines_b = preg_split("/\n/", $netstat_b, -1, PREG_SPLIT_NO_EMPTY); |
||
65 | $lines_n = preg_split("/\n/", $netstat_n, -1, PREG_SPLIT_NO_EMPTY); |
||
66 | for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) { |
||
67 | $ar_buf_b = preg_split("/\s+/", $lines_b[$i]); |
||
68 | $ar_buf_n = preg_split("/\s+/", $lines_n[$i]); |
||
69 | if (!empty($ar_buf_b[0]) && (!empty($ar_buf_n[5]) || ($ar_buf_n[5] === "0"))) { |
||
70 | $dev = new NetDevice(); |
||
71 | $dev->setName($ar_buf_b[0]); |
||
72 | $dev->setTxBytes($ar_buf_b[8]); |
||
73 | $dev->setRxBytes($ar_buf_b[5]); |
||
74 | $dev->setErrors($ar_buf_n[4] + $ar_buf_n[6]); |
||
75 | $dev->setDrops($ar_buf_n[8]); |
||
76 | $this->sys->setNetDevices($dev); |
||
77 | } |
||
78 | } |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * get the ide information |
||
83 | * |
||
84 | * @return array |
||
0 ignored issues
–
show
|
|||
85 | */ |
||
86 | protected function ide() |
||
87 | { |
||
88 | foreach ($this->readdmesg() as $line) { |
||
89 | if (preg_match('/^(.*): (.*) <(.*)> at (ata[0-9]+\-(.*)) (.*)/', $line, $ar_buf)) { |
||
90 | $dev = new HWDevice(); |
||
91 | $dev->setName($ar_buf[1]); |
||
92 | if (!preg_match("/^acd[0-9]+(.*)/", $ar_buf[1])) { |
||
93 | $dev->setCapacity($ar_buf[2] * 1024); |
||
94 | } |
||
95 | $this->sys->setIdeDevices($dev); |
||
96 | } |
||
97 | } |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * get icon name |
||
102 | * |
||
103 | * @return void |
||
104 | */ |
||
105 | private function _distroicon() |
||
106 | { |
||
107 | $this->sys->setDistributionIcon('DragonFly.png'); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * Processes |
||
112 | * |
||
113 | * @return void |
||
114 | */ |
||
115 | View Code Duplication | protected function _processes() |
|
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. ![]() |
|||
116 | { |
||
117 | if (CommonFunctions::executeProgram('ps', 'aux', $bufr, PSI_DEBUG)) { |
||
118 | $lines = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); |
||
119 | $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 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. ![]() |
|||
120 | foreach ($lines as $line) { |
||
121 | if (preg_match("/^\S+\s+\d+\s+\S+\s+\S+\s+\d+\s+\d+\s+\S+\s+(\w)/", $line, $ar_buf)) { |
||
122 | $processes['*']++; |
||
123 | $state = $ar_buf[1]; |
||
124 | if ($state == 'I') $state = 'S'; //linux format |
||
125 | if (isset($processes[$state])) { |
||
126 | $processes[$state]++; |
||
127 | } else { |
||
128 | $processes[$state] = 1; |
||
129 | } |
||
130 | } |
||
131 | } |
||
132 | if ($processes['*'] > 0) { |
||
133 | $this->sys->setProcesses($processes); |
||
134 | } |
||
135 | } |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * get the information |
||
140 | * |
||
141 | * @see BSDCommon::build() |
||
142 | * |
||
143 | * @return Void |
||
144 | */ |
||
145 | public function build() |
||
146 | { |
||
147 | parent::build(); |
||
148 | $this->_distroicon(); |
||
149 | $this->_network(); |
||
150 | $this->_uptime(); |
||
151 | $this->_processes(); |
||
152 | } |
||
153 | } |
||
154 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.