From ec0fa107001054ec867443141f50cc227e1b65e3 Mon Sep 17 00:00:00 2001 From: Matthew Hunt Date: Sat, 20 Oct 2018 00:53:50 -0400 Subject: [PATCH] Handle X-Forwarded-For with multiple hosts (#169) --- getIP.php | 1 + 1 file changed, 1 insertion(+) diff --git a/getIP.php b/getIP.php index 79f620a..0b67d3e 100644 --- a/getIP.php +++ b/getIP.php @@ -13,6 +13,7 @@ if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['X-Real-IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; + $ip = preg_replace("/,.*/", "", $ip); # hosts are comma-separated, client is first } else { $ip = $_SERVER['REMOTE_ADDR']; }