private function AutobanController::createIpRange in Automatic IP ban (Autoban) 8
Create IP range from single IP.
Parameters
string $hostname: IP address for ban.
Return value
array IP range string for insert to ban table.
1 call to AutobanController::createIpRange()
- AutobanController::banIp in src/
Controller/ AutobanController.php - Ban address.
File
- src/
Controller/ AutobanController.php, line 451
Class
- AutobanController
- Provides an Autoban functional.
Namespace
Drupal\autoban\ControllerCode
private function createIpRange($hostname) {
// Make range IP from aaa.bbb.ccc.ddd to aaa.bbb.ccc.0 - aaa.bbb.ccc.255 .
if (!ip2long($hostname)) {
// Only IPV4 is available for IP range.
return NULL;
}
$parts = explode('.', $hostname);
if (count($parts) == 4) {
$parts[3] = '0';
$ip_start = implode('.', $parts);
$parts[3] = '255';
$ip_end = implode('.', $parts);
return [
'ip_start' => $ip_start,
'ip_end' => $ip_end,
];
}
return NULL;
}