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 | * freeipmi sensor class |
||
4 | * |
||
5 | * PHP version 5 |
||
6 | * |
||
7 | * @category PHP |
||
8 | * @package PSI_Sensor |
||
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.freeipmi.inc.php 661 2012-08-27 11:26:39Z namiltd $ |
||
13 | * @link http://phpsysinfo.sourceforge.net |
||
14 | */ |
||
15 | /** |
||
16 | * getting information from ipmi-sensors |
||
17 | * |
||
18 | * @category PHP |
||
19 | * @package PSI_Sensor |
||
20 | * @author Michael Cramer <[email protected]> |
||
21 | * @copyright 2009 phpSysInfo |
||
22 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
||
23 | * @version Release: 3.0 |
||
24 | * @link http://phpsysinfo.sourceforge.net |
||
25 | */ |
||
26 | class FreeIPMI extends Sensors |
||
0 ignored issues
–
show
|
|||
27 | { |
||
28 | /** |
||
29 | * content to parse |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | private $_lines = array(); |
||
34 | |||
35 | /** |
||
36 | * fill the private content var through command or data access |
||
37 | */ |
||
38 | 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. ![]() |
|||
39 | { |
||
40 | parent::__construct(); |
||
41 | switch (defined('PSI_SENSOR_FREEIPMI_ACCESS')?strtolower(PSI_SENSOR_FREEIPMI_ACCESS):'command') { |
||
42 | case 'command': |
||
43 | CommonFunctions::executeProgram('ipmi-sensors', '--output-sensor-thresholds', $lines); |
||
44 | $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); |
||
45 | break; |
||
46 | case 'data': |
||
47 | if (CommonFunctions::rfts(APP_ROOT.'/data/freeipmi.txt', $lines)) { |
||
48 | $this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY); |
||
49 | } |
||
50 | break; |
||
51 | default: |
||
52 | $this->error->addConfigError('__construct()', 'PSI_SENSOR_FREEIPMI_ACCESS'); |
||
53 | break; |
||
54 | } |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * get temperature information |
||
59 | * |
||
60 | * @return void |
||
61 | */ |
||
62 | View Code Duplication | private function _temperature() |
|
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. ![]() |
|||
63 | { |
||
64 | foreach ($this->_lines as $line) { |
||
65 | $buffer = preg_split("/\s*\|\s*/", $line); |
||
66 | if ($buffer[2] == "Temperature" && $buffer[11] != "N/A" && $buffer[4] == "C") { |
||
67 | $dev = new SensorDevice(); |
||
68 | $dev->setName($buffer[1]); |
||
69 | $dev->setValue($buffer[3]); |
||
70 | if ($buffer[9] != "N/A") $dev->setMax($buffer[9]); |
||
71 | if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11], "'")); |
||
72 | $this->mbinfo->setMbTemp($dev); |
||
0 ignored issues
–
show
$dev is of type object<SensorDevice> , but the function expects a object<Sensor> .
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);
![]() |
|||
73 | } |
||
74 | } |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * get voltage information |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | private function _voltage() |
||
83 | { |
||
84 | foreach ($this->_lines as $line) { |
||
85 | $buffer = preg_split("/\s*\|\s*/", $line); |
||
86 | if ($buffer[2] == "Voltage" && $buffer[11] != "N/A" && $buffer[4] == "V") { |
||
87 | $dev = new SensorDevice(); |
||
88 | $dev->setName($buffer[1]); |
||
89 | $dev->setValue($buffer[3]); |
||
90 | if ($buffer[6] != "N/A") $dev->setMin($buffer[6]); |
||
91 | if ($buffer[9] != "N/A") $dev->setMax($buffer[9]); |
||
92 | if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11], "'")); |
||
93 | $this->mbinfo->setMbVolt($dev); |
||
0 ignored issues
–
show
$dev is of type object<SensorDevice> , but the function expects a object<Sensor> .
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);
![]() |
|||
94 | } |
||
95 | } |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * get fan information |
||
100 | * |
||
101 | * @return void |
||
102 | */ |
||
103 | private function _fans() |
||
104 | { |
||
105 | foreach ($this->_lines as $line) { |
||
106 | $buffer = preg_split("/\s*\|\s*/", $line); |
||
107 | if ($buffer[2] == "Fan" && $buffer[11] != "N/A" && $buffer[4] == "RPM") { |
||
108 | $dev = new SensorDevice(); |
||
109 | $dev->setName($buffer[1]); |
||
110 | $dev->setValue($buffer[3]); |
||
111 | View Code Duplication | if ($buffer[6] != "N/A") { |
|
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. ![]() |
|||
112 | $dev->setMin($buffer[6]); |
||
113 | } elseif (($buffer[9] != "N/A") && ($buffer[9]<$buffer[3])) { //max instead min issue |
||
114 | $dev->setMin($buffer[9]); |
||
115 | } |
||
116 | if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11], "'")); |
||
117 | $this->mbinfo->setMbFan($dev); |
||
118 | } |
||
119 | } |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * get power information |
||
124 | * |
||
125 | * @return void |
||
126 | */ |
||
127 | View Code Duplication | private function _power() |
|
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. ![]() |
|||
128 | { |
||
129 | foreach ($this->_lines as $line) { |
||
130 | $buffer = preg_split("/\s*\|\s*/", $line); |
||
131 | if ($buffer[2] == "Current" && $buffer[11] != "N/A" && $buffer[4] == "W") { |
||
132 | $dev = new SensorDevice(); |
||
133 | $dev->setName($buffer[1]); |
||
134 | $dev->setValue($buffer[3]); |
||
135 | if ($buffer[9] != "N/A") $dev->setMax($buffer[9]); |
||
136 | if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11], "'")); |
||
137 | $this->mbinfo->setMbPower($dev); |
||
0 ignored issues
–
show
$dev is of type object<SensorDevice> , but the function expects a object<Sensor> .
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);
![]() |
|||
138 | } |
||
139 | } |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * get current information |
||
144 | * |
||
145 | * @return void |
||
146 | */ |
||
147 | View Code Duplication | private function _current() |
|
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. ![]() |
|||
148 | { |
||
149 | foreach ($this->_lines as $line) { |
||
150 | $buffer = preg_split("/\s*\|\s*/", $line); |
||
151 | if ($buffer[2] == "Current" && $buffer[11] != "N/A" && $buffer[4] == "A") { |
||
152 | $dev = new SensorDevice(); |
||
153 | $dev->setName($buffer[1]); |
||
154 | $dev->setValue($buffer[3]); |
||
155 | if ($buffer[9] != "N/A") $dev->setMax($buffer[9]); |
||
156 | if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11], "'")); |
||
157 | $this->mbinfo->setMbCurrent($dev); |
||
0 ignored issues
–
show
$dev is of type object<SensorDevice> , but the function expects a object<Sensor> .
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);
![]() |
|||
158 | } |
||
159 | } |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * get the information |
||
164 | * |
||
165 | * @see PSI_Interface_Sensor::build() |
||
166 | * |
||
167 | * @return Void |
||
168 | */ |
||
169 | public function build() |
||
170 | { |
||
171 | $this->_temperature(); |
||
172 | $this->_voltage(); |
||
173 | $this->_fans(); |
||
174 | $this->_power(); |
||
175 | $this->_current(); |
||
176 | } |
||
177 | } |
||
178 |
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.