function autoban_is_banned in Automatic IP ban (Autoban) 7
Check IP for ban.
Parameters
string $ip: Checked IP.
int $ip_type: Single IP or range.
Return value
bool Already banned: TRUE or FALSE.
3 calls to autoban_is_banned()
- autoban_insert_banned_table in ./
autoban.module - Insert IP to table for banned IP.
- autoban_test in ./
autoban.admin.inc - Menu callback. Test autoban rule page.
- _autoban_watchdog_event_extras_event_rows in autoban_watchdog_event_extras/
autoban_watchdog_event_extras.module - Implements hook_watchdog_event_extras_alter().
File
- ./
autoban.module, line 271 - Main file for autoban module.
Code
function autoban_is_banned($ip, $ip_type) {
$ip_type = _autoban_ip_type_verification($ip_type);
$count = 0;
switch ($ip_type) {
case AUTOBAN_SINGLE_IP:
$count = db_select('blocked_ips', 't')
->condition('t.ip', $ip)
->countQuery()
->execute()
->fetchField();
break;
case AUTOBAN_RANGE_IP:
$ip = str_replace(' - ', '-', $ip);
$count = db_select('ip_ranges', 't')
->condition('t.ip', $ip)
->condition('t.type', 'blacklist')
->countQuery()
->execute()
->fetchField();
}
return $count > 0;
}