use namespaces

pull/795/head
El RIDO 2021-05-22 11:02:54 +02:00
parent 84771d7167
commit 91c8f9f23c
No known key found for this signature in database
GPG Key ID: 0F5C940A6BD81F92
1 changed files with 5 additions and 3 deletions

View File

@ -13,6 +13,8 @@
namespace PrivateBin\Persistence;
use Exception;
use IPLib\Factory;
use PrivateBin\Configuration;
/**
@ -118,8 +120,8 @@ class TrafficLimiter extends AbstractPersistence
private static function matchIp($ipRange = null)
{
// Match $_ipKey to $ipRange and if it matches it will return with a true
$address = \IPLib\Factory::addressFromString($_SERVER[self::$_ipKey]);
$range = \IPLib\Factory::rangeFromString(trim($ipRange));
$address = Factory::addressFromString($_SERVER[self::$_ipKey]);
$range = Factory::rangeFromString(trim($ipRange));
// address could not be parsed, we might not be in IP space and try a string comparison instead
if ($address == null) {
@ -133,7 +135,7 @@ class TrafficLimiter extends AbstractPersistence
// Ip-lib throws an exception when something goes wrong, if so we want to catch it and set contained to false
try {
return $address->matches($range);
} catch (\Exception $e) {
} catch (Exception $e) {
// If something is wrong with matching the ip, we assume it doesn't match
return false;
}