Handle X-Forwarded-For with multiple hosts (#169)

This commit is contained in:
Matthew Hunt 2018-10-20 00:53:50 -04:00 committed by Federico Dossena
parent 3a631e2888
commit ec0fa10700

View file

@ -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'];
}