1 | <?php |
||
2 | |||
3 | namespace App\Traits; |
||
4 | |||
5 | class CaptureIpTrait |
||
6 | { |
||
7 | private $ipAddress = null; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
8 | |||
9 | public function getClientIp() |
||
10 | { |
||
11 | if (getenv('HTTP_CLIENT_IP')) { |
||
12 | $ipAddress = getenv('HTTP_CLIENT_IP'); |
||
13 | } elseif (getenv('HTTP_X_FORWARDED_FOR')) { |
||
14 | $ipAddress = getenv('HTTP_X_FORWARDED_FOR'); |
||
15 | } elseif (getenv('HTTP_X_FORWARDED')) { |
||
16 | $ipAddress = getenv('HTTP_X_FORWARDED'); |
||
17 | } elseif (getenv('HTTP_FORWARDED_FOR')) { |
||
18 | $ipAddress = getenv('HTTP_FORWARDED_FOR'); |
||
19 | } elseif (getenv('HTTP_FORWARDED')) { |
||
20 | $ipAddress = getenv('HTTP_FORWARDED'); |
||
21 | } elseif (getenv('REMOTE_ADDR')) { |
||
22 | $ipAddress = getenv('REMOTE_ADDR'); |
||
23 | } else { |
||
24 | $ipAddress = config('settings.nullIpAddress'); |
||
25 | } |
||
26 | |||
27 | return $ipAddress; |
||
28 | } |
||
29 | } |
||
30 |