function _autoban_is_own_ip in Automatic IP ban (Autoban) 7
Check own IP to prevent from ban.
Parameters
string $hostname: IP address for ban.
Return value
bool IP address is your own or include in the IP range.
2 calls to _autoban_is_own_ip()
- autoban_can_banned in ./
autoban.module - May IP address can be banned
- autoban_test in ./
autoban.admin.inc - Menu callback. Test autoban rule page.
File
- ./
autoban.module, line 617 - Main file for autoban module.
Code
function _autoban_is_own_ip($hostname) {
// Own IP.
$my_ip = ip_address();
$parts = explode(' - ', $hostname);
if (count($parts) > 1) {
// Range IP.
$my_ip = ip2long($my_ip);
return $my_ip <= ip2long($parts[1]) && $my_ip >= ip2long($parts[0]);
}
else {
// Single IP.
return $hostname === $my_ip;
}
}