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 | * Android System Class |
||
4 | * |
||
5 | * PHP version 5 |
||
6 | * |
||
7 | * @category PHP |
||
8 | * @package PSI Android 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.Linux.inc.php 712 2012-12-05 14:09:18Z namiltd $ |
||
13 | * @link http://phpsysinfo.sourceforge.net |
||
14 | */ |
||
15 | /** |
||
16 | * Android sysinfo class |
||
17 | * get all the required information from Android system |
||
18 | * |
||
19 | * @category PHP |
||
20 | * @package PSI Android 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 Android extends Linux |
||
0 ignored issues
–
show
|
|||
28 | { |
||
29 | /** |
||
30 | * call parent constructor |
||
31 | */ |
||
32 | public function __construct() |
||
33 | { |
||
34 | parent::__construct(); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Kernel Version |
||
39 | * |
||
40 | * @return void |
||
41 | */ |
||
42 | private function _kernel() |
||
0 ignored issues
–
show
|
|||
43 | { |
||
44 | if (CommonFunctions::rfts('/proc/version', $strBuf, 1)) { |
||
45 | if (preg_match('/version (.*?) /', $strBuf, $ar_buf)) { |
||
46 | $result = $ar_buf[1]; |
||
47 | if (preg_match('/SMP/', $strBuf)) { |
||
48 | $result .= ' (SMP)'; |
||
49 | } |
||
50 | $this->sys->setKernel($result); |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Number of Users |
||
57 | * |
||
58 | * @return void |
||
59 | */ |
||
60 | protected function _users() |
||
61 | { |
||
62 | $this->sys->setUsers(1); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * filesystem information |
||
67 | * |
||
68 | * @return void |
||
69 | */ |
||
70 | private function _filesystems() |
||
0 ignored issues
–
show
|
|||
71 | { |
||
72 | if (CommonFunctions::executeProgram('df', '2>/dev/null ', $df, PSI_DEBUG)) { |
||
73 | $df = preg_split("/\n/", $df, -1, PREG_SPLIT_NO_EMPTY); |
||
74 | if (CommonFunctions::executeProgram('mount', '', $mount, PSI_DEBUG)) { |
||
75 | $mount = preg_split("/\n/", $mount, -1, PREG_SPLIT_NO_EMPTY); |
||
76 | foreach ($mount as $mount_line) { |
||
77 | $mount_buf = preg_split('/\s+/', $mount_line); |
||
78 | if (count($mount_buf) == 6) { |
||
79 | $mount_parm[$mount_buf[1]]['fstype'] = $mount_buf[2]; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$mount_parm was never initialized. Although not strictly required by PHP, it is generally a good practice to add $mount_parm = 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. ![]() |
|||
80 | if (PSI_SHOW_MOUNT_OPTION) $mount_parm[$mount_buf[1]]['options'] = $mount_buf[3]; |
||
81 | $mount_parm[$mount_buf[1]]['mountdev'] = $mount_buf[0]; |
||
82 | } |
||
83 | } |
||
84 | foreach ($df as $df_line) { |
||
85 | if ((preg_match("/^(\/\S+)(\s+)(([0-9\.]+)([KMGT])(\s+)([0-9\.]+)([KMGT])(\s+)([0-9\.]+)([KMGT])(\s+))/", $df_line, $df_buf) |
||
86 | || preg_match("/^(\/[^\s\:]+)\:(\s+)(([0-9\.]+)([KMGT])(\s+total\,\s+)([0-9\.]+)([KMGT])(\s+used\,\s+)([0-9\.]+)([KMGT])(\s+available))/", $df_line, $df_buf)) |
||
87 | && !preg_match('/^\/mnt\/asec\/com\./', $df_buf[1])) { |
||
88 | $dev = new DiskDevice(); |
||
89 | if (PSI_SHOW_MOUNT_POINT) $dev->setMountPoint($df_buf[1]); |
||
90 | |||
91 | View Code Duplication | if ($df_buf[5] == 'K') $dev->setTotal($df_buf[4] * 1024); |
|
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. ![]() |
|||
92 | elseif ($df_buf[5] == 'M') $dev->setTotal($df_buf[4] * 1024*1024); |
||
93 | elseif ($df_buf[5] == 'G') $dev->setTotal($df_buf[4] * 1024*1024*1024); |
||
94 | elseif ($df_buf[5] == 'T') $dev->setTotal($df_buf[4] * 1024*1024*1024*1024); |
||
95 | |||
96 | View Code Duplication | if ($df_buf[8] == 'K') $dev->setUsed($df_buf[7] * 1024); |
|
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. ![]() |
|||
97 | elseif ($df_buf[8] == 'M') $dev->setUsed($df_buf[7] * 1024*1024); |
||
98 | elseif ($df_buf[8] == 'G') $dev->setUsed($df_buf[7] * 1024*1024*1024); |
||
99 | elseif ($df_buf[8] == 'T') $dev->setUsed($df_buf[7] * 1024*1024*1024*1024); |
||
100 | |||
101 | View Code Duplication | if ($df_buf[11] == 'K') $dev->setFree($df_buf[10] * 1024); |
|
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. ![]() |
|||
102 | elseif ($df_buf[11] == 'M') $dev->setFree($df_buf[10] * 1024*1024); |
||
103 | elseif ($df_buf[11] == 'G') $dev->setFree($df_buf[10] * 1024*1024*1024); |
||
104 | elseif ($df_buf[11] == 'T') $dev->setFree($df_buf[10] * 1024*1024*1024*1024); |
||
105 | |||
106 | if (isset($mount_parm[$df_buf[1]])) { |
||
107 | $dev->setFsType($mount_parm[$df_buf[1]]['fstype']); |
||
108 | $dev->setName($mount_parm[$df_buf[1]]['mountdev']); |
||
109 | |||
110 | if (PSI_SHOW_MOUNT_OPTION) { |
||
111 | if (PSI_SHOW_MOUNT_CREDENTIALS) { |
||
112 | $dev->setOptions($mount_parm[$df_buf[1]]['options']); |
||
113 | View Code Duplication | } else { |
|
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. ![]() |
|||
114 | $mpo=$mount_parm[$df_buf[1]]['options']; |
||
115 | |||
116 | $mpo=preg_replace('/(^guest,)|(^guest$)|(,guest$)/i', '', $mpo); |
||
117 | $mpo=preg_replace('/,guest,/i', ',', $mpo); |
||
118 | |||
119 | $mpo=preg_replace('/(^user=[^,]*,)|(^user=[^,]*$)|(,user=[^,]*$)/i', '', $mpo); |
||
120 | $mpo=preg_replace('/,user=[^,]*,/i', ',', $mpo); |
||
121 | |||
122 | $mpo=preg_replace('/(^username=[^,]*,)|(^username=[^,]*$)|(,username=[^,]*$)/i', '', $mpo); |
||
123 | $mpo=preg_replace('/,username=[^,]*,/i', ',', $mpo); |
||
124 | |||
125 | $mpo=preg_replace('/(^password=[^,]*,)|(^password=[^,]*$)|(,password=[^,]*$)/i', '', $mpo); |
||
126 | $mpo=preg_replace('/,password=[^,]*,/i', ',', $mpo); |
||
127 | |||
128 | $dev->setOptions($mpo); |
||
129 | } |
||
130 | } |
||
131 | } |
||
132 | $this->sys->setDiskDevices($dev); |
||
133 | } |
||
134 | } |
||
135 | } |
||
136 | } |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * Distribution |
||
141 | * |
||
142 | * @return void |
||
143 | */ |
||
144 | protected function _distro() |
||
145 | { |
||
146 | $buf = ""; |
||
147 | View Code Duplication | if (CommonFunctions::rfts('/system/build.prop', $lines, 0, 4096, false) |
|
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. ![]() |
|||
148 | && preg_match('/^ro\.build\.version\.release=([^\n]+)/m', $lines, $ar_buf)) { |
||
149 | $buf = trim($ar_buf[1]); |
||
150 | } |
||
151 | if (is_null($buf) || ($buf == "")) { |
||
152 | $this->sys->setDistribution('Android'); |
||
153 | View Code Duplication | } else { |
|
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. ![]() |
|||
154 | if (preg_match('/^(\d+\.\d+)/', $buf, $ver) |
||
155 | && ($list = @parse_ini_file(APP_ROOT."/data/osnames.ini", true)) |
||
156 | && isset($list['Android'][$ver[1]])) { |
||
157 | $buf.=' '.$list['Android'][$ver[1]]; |
||
158 | } |
||
159 | $this->sys->setDistribution('Android '.$buf); |
||
160 | } |
||
161 | $this->sys->setDistributionIcon('Android.png'); |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * Machine |
||
166 | * |
||
167 | * @return void |
||
168 | */ |
||
169 | private function _machine() |
||
0 ignored issues
–
show
|
|||
170 | { |
||
171 | if (CommonFunctions::rfts('/system/build.prop', $lines, 0, 4096, false)) { |
||
172 | $buf = ""; |
||
173 | if (preg_match('/^ro\.product\.manufacturer=([^\n]+)/m', $lines, $ar_buf)) { |
||
174 | $buf .= ' '.trim($ar_buf[1]); |
||
175 | } |
||
176 | if (preg_match('/^ro\.product\.model=([^\n]+)/m', $lines, $ar_buf) && (trim($buf) !== trim($ar_buf[1]))) { |
||
177 | $buf .= ' '.trim($ar_buf[1]); |
||
178 | } |
||
179 | if (preg_match('/^ro\.semc\.product\.name=([^\n]+)/m', $lines, $ar_buf)) { |
||
180 | $buf .= ' '.trim($ar_buf[1]); |
||
181 | } |
||
182 | if (trim($buf) != "") { |
||
183 | $this->sys->setMachine(trim($buf)); |
||
0 ignored issues
–
show
trim($buf) is of type string , 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);
![]() |
|||
184 | } |
||
185 | } |
||
186 | } |
||
187 | |||
188 | /** |
||
189 | * PCI devices |
||
190 | * |
||
191 | * @return array |
||
0 ignored issues
–
show
|
|||
192 | */ |
||
193 | private function _pci() |
||
0 ignored issues
–
show
|
|||
194 | { |
||
195 | if (CommonFunctions::executeProgram('lspci', '', $bufr, false)) { |
||
196 | $bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); |
||
197 | foreach ($bufe as $buf) { |
||
198 | $device = preg_split("/ /", $buf, 4); |
||
199 | if (isset($device[3]) && trim($device[3]) != "") { |
||
200 | $dev = new HWDevice(); |
||
201 | $dev->setName('Class '.trim($device[2]).' Device '.trim($device[3])); |
||
202 | $this->sys->setPciDevices($dev); |
||
203 | } |
||
204 | } |
||
205 | } |
||
206 | } |
||
207 | |||
208 | /** |
||
209 | * USB devices |
||
210 | * |
||
211 | * @return array |
||
0 ignored issues
–
show
|
|||
212 | */ |
||
213 | private function _usb() |
||
0 ignored issues
–
show
|
|||
214 | { |
||
215 | if (file_exists('/dev/bus/usb') && CommonFunctions::executeProgram('lsusb', '', $bufr, false)) { |
||
216 | $bufe = preg_split("/\n/", $bufr, -1, PREG_SPLIT_NO_EMPTY); |
||
217 | foreach ($bufe as $buf) { |
||
218 | $device = preg_split("/ /", $buf, 6); |
||
219 | if (isset($device[5]) && trim($device[5]) != "") { |
||
220 | $dev = new HWDevice(); |
||
221 | $dev->setName(trim($device[5])); |
||
222 | $this->sys->setUsbDevices($dev); |
||
223 | } |
||
224 | } |
||
225 | } |
||
226 | } |
||
227 | |||
228 | /** |
||
229 | * get the information |
||
230 | * |
||
231 | * @see PSI_Interface_OS::build() |
||
232 | * |
||
233 | * @return Void |
||
234 | */ |
||
235 | 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. ![]() |
|||
236 | { |
||
237 | $this->_distro(); |
||
238 | $this->_hostname(); |
||
239 | $this->_kernel(); |
||
240 | $this->_machine(); |
||
241 | $this->_uptime(); |
||
242 | $this->_users(); |
||
243 | $this->_cpuinfo(); |
||
244 | $this->_pci(); |
||
245 | $this->_usb(); |
||
246 | $this->_i2c(); |
||
247 | $this->_network(); |
||
248 | $this->_memory(); |
||
249 | $this->_filesystems(); |
||
250 | $this->_loadavg(); |
||
251 | $this->_processes(); |
||
252 | } |
||
253 | } |
||
254 |
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.