1 | <?php |
||
7 | class PHPClientAddr |
||
8 | { |
||
9 | /** |
||
10 | * Arreglod e expreciones regulres para validar una IP privada. |
||
11 | * @var array |
||
12 | */ |
||
13 | private $privateIp = array( |
||
14 | '/^0\./','/^127\.0\.0\.1/', |
||
15 | '/^192\.168\..*/','/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/', |
||
16 | '/^10\..*/' |
||
17 | ); |
||
18 | |||
19 | /** |
||
20 | * Ip del cliente. |
||
21 | * @var string |
||
22 | */ |
||
23 | public $ip; |
||
24 | |||
25 | /** |
||
26 | * Hostname del Cliente. |
||
27 | * @var string |
||
28 | */ |
||
29 | public $hostname; |
||
30 | |||
31 | /** |
||
32 | * Arreglo de parametros del servidor. |
||
33 | * @var array |
||
34 | */ |
||
35 | private $server; |
||
36 | |||
37 | /** |
||
38 | * Arreglo de parametros del entorno. |
||
39 | * @var array |
||
40 | */ |
||
41 | private $env; |
||
42 | |||
43 | /** |
||
44 | * Thr constructor. |
||
45 | */ |
||
46 | public function __construct() |
||
54 | |||
55 | /** |
||
56 | * Permite obtener el hostname de la IP |
||
57 | * @return string |
||
58 | */ |
||
59 | private function getRemoteHostname() |
||
68 | |||
69 | /** |
||
70 | * Permite obtener la IP proveniente de un servidor proxy |
||
71 | * @return void |
||
72 | */ |
||
73 | private function getIpForwarded() |
||
80 | |||
81 | /** |
||
82 | * Permite saber si la peticion proviene de un servidor proxy. |
||
83 | * @return boolean |
||
84 | */ |
||
85 | private function isHttpXForwardedFor() |
||
89 | |||
90 | /** |
||
91 | * Permite obtener todas las entidades enviadas por un servidor proxy. |
||
92 | * @return array |
||
93 | */ |
||
94 | private function getHttpXForwardedForEntities() |
||
100 | |||
101 | /** |
||
102 | * Permite obtener la IP real proveniente de un servidor proxy. |
||
103 | * @param array $entries Arreglo de entidades enviadas por un servidor proxy |
||
104 | * @return string |
||
105 | */ |
||
106 | private function getXForwardedIp($entries) |
||
122 | |||
123 | /** |
||
124 | * Permite obtener la IP real del cliente. |
||
125 | * @return string |
||
126 | */ |
||
127 | private function getRemodeAddr() |
||
139 | |||
140 | /** |
||
141 | * Check if the remote Ip is in the glocal variable $_SERVER |
||
142 | * @return boolean |
||
143 | */ |
||
144 | private function hasServerRemoteAddr() |
||
150 | |||
151 | /** |
||
152 | * Check if the remote Ip is in the glocal variable $_ENV |
||
153 | * @return boolean |
||
154 | */ |
||
155 | private function hasEnvRemoteAddr() |
||
161 | } |
||
162 |