Fixes #3222 -- Handle multiple IPs split by commas.

This commit is contained in:
Buster "Silver Eagle" Neece 2020-10-01 22:21:05 -05:00
parent adec893a93
commit 28fd48c218
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
1 changed files with 8 additions and 2 deletions

View File

@ -149,12 +149,18 @@ final class ServerRequest extends \Slim\Http\ServerRequest
{
$params = $this->serverRequest->getServerParams();
return $params['HTTP_CLIENT_IP']
$ip = $params['HTTP_CLIENT_IP']
?? $params['HTTP_X_FORWARDED_FOR']
?? $params['HTTP_X_FORWARDED']
?? $params['HTTP_FORWARDED_FOR']
?? $params['HTTP_FORWARDED']
?? $params['REMOTE_ADDR']
?? null;
?? '';
// Handle the IP being separated by commas.
$ipParts = explode(',', $ip);
$ip = array_shift($ipParts);
return trim($ip);
}
}