These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace SilverStripe\Auditor; |
||
4 | |||
5 | class RealIPProcessor |
||
6 | { |
||
7 | |||
8 | public function __invoke(array $record) |
||
9 | { |
||
10 | $record['extra']['real_ip'] = $this->getClientIP(); |
||
11 | return $record; |
||
12 | } |
||
13 | |||
14 | private function getClientIP() |
||
15 | { |
||
16 | $ipaddress = ''; |
||
0 ignored issues
–
show
|
|||
17 | if (@$_SERVER['HTTP_CLIENT_IP']) { |
||
18 | $ipaddress = $_SERVER['HTTP_CLIENT_IP']; |
||
19 | } elseif (@$_SERVER['HTTP_X_FORWARDED_FOR']) { |
||
20 | $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; |
||
21 | } elseif (@$_SERVER['HTTP_X_FORWARDED']) { |
||
22 | $ipaddress = $_SERVER['HTTP_X_FORWARDED']; |
||
23 | } elseif (@$_SERVER['HTTP_FORWARDED_FOR']) { |
||
24 | $ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; |
||
25 | } elseif (@$_SERVER['HTTP_FORWARDED']) { |
||
26 | $ipaddress = $_SERVER['HTTP_FORWARDED']; |
||
27 | } elseif (@$_SERVER['REMOTE_ADDR']) { |
||
28 | $ipaddress = $_SERVER['REMOTE_ADDR']; |
||
29 | } else { |
||
30 | $ipaddress = 'UNKNOWN'; |
||
31 | } |
||
32 | |||
33 | return $ipaddress; |
||
34 | } |
||
35 | |||
36 | } |
||
37 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.