public function RestrictIpService::testForBlock in Restrict IP 8
Same name and namespace in other branches
- 8.2 src/Service/RestrictIpService.php \Drupal\restrict_ip\Service\RestrictIpService::testForBlock()
- 3.x src/Service/RestrictIpService.php \Drupal\restrict_ip\Service\RestrictIpService::testForBlock()
*
Overrides RestrictIpServiceInterface::testForBlock
File
- src/
Service/ RestrictIpService.php, line 106
Class
Namespace
Drupal\restrict_ip\ServiceCode
public function testForBlock($runInCli = FALSE) {
$this->blocked = FALSE;
if ($this->config
->get('enable')) {
$this->blocked = TRUE;
// We don't want to check IP on CLI (likely drush) requests
// unless explicitly declared to check by the $runInCli argument
if (PHP_SAPI != 'cli' || $runInCli) {
$access_denied = TRUE;
if ($this
->allowAccessWhitelistedPath()) {
$access_denied = FALSE;
}
elseif ($this
->allowAccessBlacklistedPath()) {
$access_denied = FALSE;
}
elseif ($this
->allowAccessWhitelistedIp()) {
$access_denied = FALSE;
}
// If the user has been denied access
if ($access_denied) {
if (PHP_SAPI != 'cli') {
$_SESSION['restrict_ip'] = TRUE;
}
}
else {
$this->blocked = FALSE;
}
}
}
}