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 |
||
0 ignored issues
–
show
|
|||
2 | echo "<!DOCTYPE html>"; |
||
3 | echo "<meta charset=\"UTF-8\">"; |
||
4 | echo "<title> </title>"; |
||
5 | echo "<body>"; |
||
6 | |||
7 | define('APP_ROOT', dirname(__FILE__).'/..'); |
||
8 | require_once APP_ROOT.'/includes/interface/class.PSI_Interface_OS.inc.php'; |
||
9 | require_once APP_ROOT.'/includes/os/class.OS.inc.php'; |
||
10 | require_once APP_ROOT.'/includes/to/class.System.inc.php'; |
||
11 | require_once APP_ROOT.'/includes/os/class.Linux.inc.php'; |
||
12 | define('PSI_USE_VHOST', false); |
||
13 | define('PSI_DEBUG', false); |
||
14 | define('PSI_LOAD_BAR', false); |
||
15 | |||
16 | $log_file = ""; |
||
17 | $lsb = true; //enable detection lsb_release -a |
||
18 | $lsbfile = true; //enable detection /etc/lsb-release |
||
19 | |||
20 | class PSI_Error |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
The type
PSI_Error has been defined more than once; this definition is ignored, only the first definition in phpsysinfo/includes/error/class.PSI_Error.inc.php (L26-290) is considered.
This check looks for classes that have been defined more than once. If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface. This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP. ![]() 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. ![]() |
|||
21 | { |
||
22 | public static function singleton() |
||
23 | { |
||
24 | } |
||
25 | } |
||
26 | |||
27 | class Parser |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
The type
Parser has been defined more than once; this definition is ignored, only the first definition in phpsysinfo/includes/class.Parser.inc.php (L26-271) is considered.
This check looks for classes that have been defined more than once. If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface. This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP. ![]() 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. ![]() |
|||
28 | { |
||
29 | public static function lspci() |
||
30 | { |
||
31 | return array(); |
||
32 | } |
||
33 | public static function df() |
||
34 | { |
||
35 | return array(); |
||
36 | } |
||
37 | } |
||
38 | |||
39 | class CommonFunctions |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
The type
CommonFunctions has been defined more than once; this definition is ignored, only the first definition in phpsysinfo/includes/class.CommonFunctions.inc.php (L26-563) is considered.
This check looks for classes that have been defined more than once. If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface. This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP. ![]() 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. ![]() |
|||
40 | { |
||
41 | private static function _parse_log_file($string) |
||
42 | { |
||
43 | global $log_file; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
44 | if (file_exists($log_file)) { |
||
45 | $contents = @file_get_contents($log_file); |
||
46 | $contents = preg_replace("/\r\n/", "\n", $contents); |
||
47 | View Code Duplication | if ($contents && preg_match("/^\-\-\-\-\-\-\-\-\-\-".preg_quote($string, '/')."\-\-\-\-\-\-\-\-\-\-\n/m", $contents, $matches, PREG_OFFSET_CAPTURE)) { |
|
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. ![]() |
|||
48 | $findIndex = $matches[0][1]; |
||
49 | if (preg_match("/\n/m", $contents, $matches, PREG_OFFSET_CAPTURE, $findIndex)) { |
||
50 | $startIndex = $matches[0][1]+1; |
||
51 | if (preg_match("/^\-\-\-\-\-\-\-\-\-\-/m", $contents, $matches, PREG_OFFSET_CAPTURE, $startIndex)) { |
||
52 | $stopIndex = $matches[0][1]; |
||
53 | |||
54 | return substr($contents, $startIndex, $stopIndex-$startIndex); |
||
55 | } else { |
||
56 | return substr($contents, $startIndex); |
||
57 | } |
||
58 | } |
||
59 | } |
||
60 | } |
||
61 | |||
62 | return false; |
||
63 | } |
||
64 | |||
65 | public static function rfts($strFileName, &$strRet, $intLines = 0, $intBytes = 4096, $booErrorRep = true) |
||
0 ignored issues
–
show
|
|||
66 | { |
||
67 | global $lsb; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
68 | global $lsbfile; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
69 | if ($lsb || $lsbfile || ($strFileName != "/etc/lsb-release")) { |
||
70 | $strRet=self::_parse_log_file($strFileName); |
||
71 | if ($strRet && ($intLines == 1) && (strpos($strRet, "\n") !== false)) { |
||
0 ignored issues
–
show
The expression
$strRet of type string|false is loosely compared to true ; this is ambiguous if the string can be empty. You might want to explicitly use !== false instead.
In PHP, under loose comparison (like For '' == false // true
'' == null // true
'ab' == false // false
'ab' == null // false
// It is often better to use strict comparison
'' === false // false
'' === null // false
![]() |
|||
72 | $strRet=trim(substr($strRet, 0, strpos($strRet, "\n"))); |
||
73 | } |
||
74 | |||
75 | return $strRet; |
||
76 | } else { |
||
77 | return false; |
||
78 | } |
||
79 | } |
||
80 | |||
81 | public static function executeProgram($strProgramname, $strArgs, &$strBuffer, $booErrorRep = true) |
||
0 ignored issues
–
show
|
|||
82 | { |
||
83 | global $lsb; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
84 | $strBuffer = ''; |
||
85 | if ($strProgramname=='lsb_release') { |
||
86 | return $lsb && ($strBuffer = self::_parse_log_file('lsb_release -a')); |
||
87 | } else { |
||
88 | return $strBuffer = self::_parse_log_file($strProgramname); |
||
89 | } |
||
90 | } |
||
91 | |||
92 | public static function fileexists($strFileName) |
||
93 | { |
||
94 | global $log_file; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
95 | global $lsb; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
96 | global $lsbfile; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
97 | if (file_exists($log_file) |
||
98 | && ($lsb || $lsbfile || ($strFileName != "/etc/lsb-release")) |
||
99 | && ($contents = @file_get_contents($log_file)) |
||
100 | && preg_match("/^\-\-\-\-\-\-\-\-\-\-".preg_quote($strFileName, '/')."\-\-\-\-\-\-\-\-\-\-\r?\n/m", $contents)) { |
||
101 | return true; |
||
102 | } |
||
103 | |||
104 | return false; |
||
105 | } |
||
106 | |||
107 | public static function gdc() |
||
108 | { |
||
109 | return array(); |
||
110 | } |
||
111 | } |
||
112 | |||
113 | class _Linux extends Linux |
||
0 ignored issues
–
show
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. ![]() |
|||
114 | { |
||
115 | public function build() |
||
116 | { |
||
117 | parent::_distro(); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
_distro() instead of build() ). Are you sure this is correct? If so, you might want to change this to $this->_distro() .
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
118 | } |
||
119 | } |
||
120 | |||
121 | $system = new _Linux(); |
||
122 | if ($handle = opendir(APP_ROOT.'/sample/distrotest')) { |
||
123 | echo "<table cellpadding=\"2\" border=\"1\" CELLSPACING=\"0\""; |
||
124 | echo "<tr>"; |
||
125 | echo "<td>Distrotest sample</td>"; |
||
126 | echo "<td>Distro Name</td>"; |
||
127 | echo "<td>Distro Icon</td>"; |
||
128 | echo "<td>Distro Name (no lsb_release)</td>"; |
||
129 | echo "<td>Distro Icon (no lsb_release)</td>"; |
||
130 | echo "<td>Distro Name (no lsb_release and no /etc/lsb-release)</td>"; |
||
131 | echo "<td>Distro Icon (no lsb_release and no /etc/lsb-release)</td>"; |
||
132 | echo "</tr>"; |
||
133 | while (false !== ($entry = readdir($handle))) { |
||
134 | if (($entry!=".")&&($entry!="..")) { |
||
135 | if ($shandle = opendir(APP_ROOT."/sample/distrotest/$entry")) { |
||
136 | while (false !== ($sentry = readdir($shandle))) { |
||
137 | if (($sentry!=".")&&($sentry!="..")) { |
||
138 | $log_file=APP_ROOT.'/sample/distrotest/'.$entry.'/'.$sentry; |
||
139 | echo "<tr>"; |
||
140 | echo "<td>".$entry.'/'.$sentry."</td>"; |
||
141 | |||
142 | $lsb = true; |
||
143 | $lsbfile = true; |
||
144 | $sys=$system->getSys(); |
||
145 | $distro=$sys->getDistribution(); |
||
146 | $icon=$sys->getDistributionIcon(); |
||
147 | if ($icon == '') $icon="unknown.png"; |
||
148 | if ($icon != $entry.'.png') |
||
149 | echo "<td style='color:red'>"; |
||
150 | else |
||
151 | echo "<td>"; |
||
152 | echo $distro."</td>"; |
||
153 | if ($icon != $entry.'.png') |
||
154 | echo "<td style='color:red'>"; |
||
155 | else |
||
156 | echo "<td>"; |
||
157 | echo "<img src=\"../gfx/images/".$icon."\" height=\"16\" width=\"16\">"; |
||
158 | echo $icon."</td>"; |
||
159 | $sys->setDistribution(""); |
||
160 | $sys->setDistributionIcon(""); |
||
161 | |||
162 | $lsb = false; |
||
163 | $lsbfile = true; |
||
164 | $sys=$system->getSys(); |
||
165 | $distro=$sys->getDistribution(); |
||
166 | $icon=$sys->getDistributionIcon(); |
||
167 | if ($icon == '') $icon="unknown.png"; |
||
168 | if ($icon != $entry.'.png') |
||
169 | echo "<td style='color:red'>"; |
||
170 | else |
||
171 | echo "<td>"; |
||
172 | echo $distro."</td>"; |
||
173 | if ($icon != $entry.'.png') |
||
174 | echo "<td style='color:red'>"; |
||
175 | else |
||
176 | echo "<td>"; |
||
177 | echo "<img src=\"../gfx/images/".$icon."\" height=\"16\" width=\"16\">"; |
||
178 | echo $icon."</td>"; |
||
179 | $sys->setDistribution(""); |
||
180 | $sys->setDistributionIcon(""); |
||
181 | |||
182 | $lsb = false; |
||
183 | $lsbfile = false; |
||
184 | $sys=$system->getSys(); |
||
185 | $distro=$sys->getDistribution(); |
||
186 | $icon=$sys->getDistributionIcon(); |
||
187 | if ($icon == '') $icon="unknown.png"; |
||
188 | if ($icon != $entry.'.png') |
||
189 | echo "<td style='color:red'>"; |
||
190 | else |
||
191 | echo "<td>"; |
||
192 | echo $distro."</td>"; |
||
193 | if ($icon != $entry.'.png') |
||
194 | echo "<td style='color:red'>"; |
||
195 | else |
||
196 | echo "<td>"; |
||
197 | echo "<img src=\"../gfx/images/".$icon."\" height=\"16\" width=\"16\">"; |
||
198 | echo $icon."</td>"; |
||
199 | $sys->setDistribution(""); |
||
200 | $sys->setDistributionIcon(""); |
||
201 | |||
202 | echo "</tr>"; |
||
203 | } |
||
204 | } |
||
205 | closedir($shandle); |
||
206 | } |
||
207 | } |
||
208 | } |
||
209 | echo "</table>"; |
||
210 | closedir($handle); |
||
211 | } |
||
212 | echo "</body>"; |
||
213 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.