From: Jerome Jutteau Date: Tue, 29 Sep 2015 14:43:32 +0000 (+0200) Subject: better checks in ip listing X-Git-Tag: 1.1~10^2~2 X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/commitdiff_plain/218767ef1f78a6ba2ae62039f3a65d296d361930?ds=sidebyside;hp=-c better checks in ip listing Signed-off-by: Jerome Jutteau --- 218767ef1f78a6ba2ae62039f3a65d296d361930 diff --git a/lib/functions.php b/lib/functions.php index 83fdaf1..aaa0daf 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1121,6 +1121,8 @@ get_ip_list_http_forwarded() if (!empty ($_SERVER['HTTP_X_FORWARDED_FOR'])) { $l = explode (',', $_SERVER['HTTP_X_FORWARDED_FOR']); + if ($l === FALSE) + return array(); foreach ($l as $ip) array_push ($ip_list, preg_replace ('/\s+/', '', $ip)); } @@ -1130,7 +1132,10 @@ get_ip_list_http_forwarded() foreach ($l as $ip) { // Separate IP from port - $ip = explode (':', $ip)[0]; + $ipa = explode (':', $ip); + if ($ipa === FALSE) + continue; + $ip = $ipa[0]; array_push ($ip_list, preg_replace ('/\s+/', '', $ip)); } }