| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | 5 | public function getRealIpAddr() |
|
| 13 | { |
||
| 14 | 5 | if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 15 | // Check IP from internet. |
||
| 16 | 3 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
|
| 17 | 3 | } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 18 | // Check IP is passed from proxy. |
||
| 19 | 1 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 20 | 3 | } elseif (!empty($_SERVER['REMOTE_ADDR'])) { |
|
| 21 | // Get IP address from remote address. |
||
| 22 | 1 | $ip = $_SERVER['REMOTE_ADDR']; |
|
| 23 | } else { |
||
| 24 | 2 | $ip = "94.21.49.200"; |
|
| 25 | } |
||
| 26 | 5 | return $ip; |
|
| 27 | } |
||
| 29 |