You are here

function autoban_ban_manual in Automatic IP ban (Autoban) 7

Ban IP manually.

Parameters

string $ip: IP for ban.

int $ip_type: Single IP or range.

2 calls to autoban_ban_manual()
autoban_vbo_comment_ban_range_action in autoban_vbo/autoban_vbo.module
autoban_vbo_comment_ban_single_action in autoban_vbo/autoban_vbo.module
1 string reference to 'autoban_ban_manual'
autoban_menu in ./autoban.module
Implements hook_menu().

File

./autoban.module, line 759
Main file for autoban module.

Code

function autoban_ban_manual($ip, $ip_type) {
  if (autoban_can_banned($ip)) {

    // IP ban function.
    $ip = autoban_make_ip_style($ip, $ip_type);
    $res = autoban_insert_banned_table($ip, $ip_type);
    $msg = $res ? t('added') : t('has already');
    drupal_set_message(t('@ip has been banned (@msg).', array(
      '@ip' => $ip,
      '@msg' => $msg,
    )));

    //Real ban.
    if ($res) {
      watchdog('autoban', 'Banned @ip manually', array(
        '@ip' => $ip,
      ));
    }
  }
  else {
    drupal_set_message(t('@ip was NOT banned.', array(
      '@ip' => $ip,
    )));
  }
  if (isset($_GET['destination'])) {
    drupal_goto($_GET['destination']);
  }
}