* [MOD] Improved regex for retrieving ip addresses through reverse proxy.

This commit is contained in:
nuxsmin
2017-09-18 12:53:44 +02:00
parent c20568581a
commit 54beb511c0
2 changed files with 9 additions and 5 deletions

View File

@@ -113,14 +113,18 @@ class HttpUtil
*/
public static function getForwardedFor()
{
if (preg_match_all('/for=([0-9\.]+)[,;]+/i',
if (preg_match_all('/for=["\[]*([\w.:]+)["\]]*[,;]?/i',
Request::getRequestHeaders('HTTP_FORWARDED'), $matchesFor)) {
return $matchesFor[1];
}
if (preg_match_all('/([\w.:]+)(,|$)/',
Request::getRequestHeaders('HTTP_X_FORWARDED_FOR'), $matchesFor)) {
return $matchesFor[1];
$matchesFor = preg_split('/(?<=[\w])+,/i',
Request::getRequestHeaders('HTTP_X_FORWARDED_FOR'),
-1,
PREG_SPLIT_NO_EMPTY);
if (count($matchesFor) > 0) {
return $matchesFor;
}
return $_SERVER['REMOTE_ADDR'];

View File

@@ -386,7 +386,7 @@ class Util
*/
public static function getVersion($retBuild = false, $normalized = false)
{
$build = 17091802;
$build = 17091803;
$version = [2, 1, 15];
if ($normalized === true) {