@@ 223-244 (lines=22) @@ | ||
220 | * @access public |
|
221 | * @return string |
|
222 | */ |
|
223 | private function _visitor_ip() |
|
224 | { |
|
225 | $visitor_ip = '0.0.0.0'; |
|
226 | $server_keys = array( |
|
227 | 'HTTP_CLIENT_IP', |
|
228 | 'HTTP_X_FORWARDED_FOR', |
|
229 | 'HTTP_X_FORWARDED', |
|
230 | 'HTTP_X_CLUSTER_CLIENT_IP', |
|
231 | 'HTTP_FORWARDED_FOR', |
|
232 | 'HTTP_FORWARDED', |
|
233 | 'REMOTE_ADDR', |
|
234 | ); |
|
235 | foreach ($server_keys as $key) { |
|
236 | if (isset($_SERVER[$key])) { |
|
237 | foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
238 | if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) { |
|
239 | $visitor_ip = $ip; |
|
240 | } |
|
241 | } |
|
242 | } |
|
243 | } |
|
244 | return $visitor_ip; |
|
245 | } |
|
246 | ||
247 |
@@ 856-877 (lines=22) @@ | ||
853 | * @access public |
|
854 | * @return string |
|
855 | */ |
|
856 | private function _visitor_ip() { |
|
857 | $visitor_ip = '0.0.0.0'; |
|
858 | $server_keys = array( |
|
859 | 'HTTP_CLIENT_IP', |
|
860 | 'HTTP_X_FORWARDED_FOR', |
|
861 | 'HTTP_X_FORWARDED', |
|
862 | 'HTTP_X_CLUSTER_CLIENT_IP', |
|
863 | 'HTTP_FORWARDED_FOR', |
|
864 | 'HTTP_FORWARDED', |
|
865 | 'REMOTE_ADDR' |
|
866 | ); |
|
867 | foreach ( $server_keys as $key ){ |
|
868 | if ( isset( $_SERVER[ $key ] )) { |
|
869 | foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
870 | if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
871 | $visitor_ip = $ip; |
|
872 | } |
|
873 | } |
|
874 | } |
|
875 | } |
|
876 | return $visitor_ip; |
|
877 | } |
|
878 | ||
879 | ||
880 |