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