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
PHTML
52 lines
1.1 KiB
PHTML
8 years ago
|
<?php
|
||
|
|
||
|
namespace BusinessLogic\Security;
|
||
|
|
||
|
|
||
|
use DataAccess\Security\BanGateway;
|
||
|
|
||
|
class BanRetriever {
|
||
8 years ago
|
/**
|
||
|
* @var BanGateway
|
||
|
*/
|
||
|
private $banGateway;
|
||
|
|
||
|
function __construct($banGateway) {
|
||
|
$this->banGateway = $banGateway;
|
||
|
}
|
||
|
|
||
8 years ago
|
/**
|
||
|
* @param $email
|
||
|
* @param $heskSettings
|
||
|
* @return bool
|
||
|
*/
|
||
8 years ago
|
function isEmailBanned($email, $heskSettings) {
|
||
8 years ago
|
|
||
8 years ago
|
$bannedEmails = $this->banGateway->getEmailBans($heskSettings);
|
||
8 years ago
|
|
||
|
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
|
||
|
*/
|
||
8 years ago
|
function isIpAddressBanned($ip, $heskSettings) {
|
||
|
$bannedIps = $this->banGateway->getIpBans($heskSettings);
|
||
8 years ago
|
|
||
|
foreach ($bannedIps as $bannedIp) {
|
||
|
if ($bannedIp->ipFrom <= $ip && $bannedIp->ipTo >= $ip) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
}
|