Code Duplication    Length = 22-22 lines in 2 locations

core/request_stack/EE_Request.core.php 1 location

@@ 318-339 (lines=22) @@
315
     * @access public
316
     * @return string
317
     */
318
    private function _visitor_ip()
319
    {
320
        $visitor_ip  = '0.0.0.0';
321
        $server_keys = array(
322
            'HTTP_CLIENT_IP',
323
            'HTTP_X_FORWARDED_FOR',
324
            'HTTP_X_FORWARDED',
325
            'HTTP_X_CLUSTER_CLIENT_IP',
326
            'HTTP_FORWARDED_FOR',
327
            'HTTP_FORWARDED',
328
            'REMOTE_ADDR',
329
        );
330
        foreach ($server_keys as $key) {
331
            if (isset($_SERVER[$key])) {
332
                foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
333
                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
334
                        $visitor_ip = $ip;
335
                    }
336
                }
337
            }
338
        }
339
        return $visitor_ip;
340
    }
341
342

core/EE_Session.core.php 1 location

@@ 893-914 (lines=22) @@
890
     * @access public
891
     * @return string
892
     */
893
    private function _visitor_ip()
894
    {
895
        $visitor_ip  = '0.0.0.0';
896
        $server_keys = array(
897
            'HTTP_CLIENT_IP',
898
            'HTTP_X_FORWARDED_FOR',
899
            'HTTP_X_FORWARDED',
900
            'HTTP_X_CLUSTER_CLIENT_IP',
901
            'HTTP_FORWARDED_FOR',
902
            'HTTP_FORWARDED',
903
            'REMOTE_ADDR',
904
        );
905
        foreach ($server_keys as $key) {
906
            if (isset($_SERVER[ $key ])) {
907
                foreach (array_map('trim', explode(',', $_SERVER[ $key ])) as $ip) {
908
                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
909
                        $visitor_ip = $ip;
910
                    }
911
                }
912
            }
913
        }
914
        return $visitor_ip;
915
    }
916
917