You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace BusinessLogic\Security;
|
|
|
|
|
|
use DataAccess\Security\BanGateway;
|
|
|
|
class BanRetriever {
|
|
/**
|
|
* @var BanGateway
|
|
*/
|
|
private $banGateway;
|
|
|
|
function __construct($banGateway) {
|
|
$this->banGateway = $banGateway;
|
|
}
|
|
|
|
/**
|
|
* @param $email
|
|
* @param $heskSettings
|
|
* @return bool
|
|
*/
|
|
function isEmailBanned($email, $heskSettings) {
|
|
|
|
$bannedEmails = $this->banGateway->getEmailBans($heskSettings);
|
|
|
|
foreach ($bannedEmails as $bannedEmail) {
|
|
if ($bannedEmail->email === $email) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* @param $ip int the IP address, converted beforehand using ip2long()
|
|
* @param $heskSettings
|
|
* @return bool
|
|
*/
|
|
function isIpAddressBanned($ip, $heskSettings) {
|
|
$bannedIps = $this->banGateway->getIpBans($heskSettings);
|
|
|
|
foreach ($bannedIps as $bannedIp) {
|
|
if ($bannedIp->ipFrom <= $ip && $bannedIp->ipTo >= $ip) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
} |