From a2cb1ca1186908f205e49d2cd82184ef8dc8bc4b Mon Sep 17 00:00:00 2001 From: Carl Bennett Date: Wed, 1 Jan 2020 19:12:02 +0000 Subject: [PATCH] Simplify getPartialIP() --- src/libraries/Authentication.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libraries/Authentication.php b/src/libraries/Authentication.php index 9e8eec53..a5816579 100644 --- a/src/libraries/Authentication.php +++ b/src/libraries/Authentication.php @@ -101,15 +101,12 @@ protected static function getFingerprint(User &$user) { */ protected static function getPartialIP(string $ip) { if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { - $r = long2ip(ip2long($ip) & 0xFFFFFF00); + return long2ip(ip2long($ip) & 0xFFFFFF00); } else if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { - $r = inet_ntop( - substr(unpack('A16', inet_pton($ip))[1], 0, 8) . str_repeat(chr(0), 8) - ); + return inet_ntop(substr(inet_pton($ip), 0, 8) . str_repeat(chr(0), 8)); } else { throw new InvalidArgumentException('$ip is not a valid IP address'); } - return $r; } /**