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

@@ 916-937 (lines=22) @@
913
     * @access public
914
     * @return string
915
     */
916
    private function _visitor_ip()
917
    {
918
        $visitor_ip  = '0.0.0.0';
919
        $server_keys = array(
920
            'HTTP_CLIENT_IP',
921
            'HTTP_X_FORWARDED_FOR',
922
            'HTTP_X_FORWARDED',
923
            'HTTP_X_CLUSTER_CLIENT_IP',
924
            'HTTP_FORWARDED_FOR',
925
            'HTTP_FORWARDED',
926
            'REMOTE_ADDR',
927
        );
928
        foreach ($server_keys as $key) {
929
            if (isset($_SERVER[ $key ])) {
930
                foreach (array_map('trim', explode(',', $_SERVER[ $key ])) as $ip) {
931
                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
932
                        $visitor_ip = $ip;
933
                    }
934
                }
935
            }
936
        }
937
        return $visitor_ip;
938
    }
939
940