You are here

function login_user_block_ip in Login Security 6

Same name and namespace in other branches
  1. 8 login_security.module \login_user_block_ip()
  2. 5 login_security.module \login_user_block_ip()
  3. 7 login_security.module \login_user_block_ip()
  4. 2.x login_security.module \login_user_block_ip()

Create a Deny entry for the IP address. If IP address is not especified then block current IP.

Parameters

$ip: Optional. Add a deny rule in the access control to this IP Address.

1 call to login_user_block_ip()
login_security_validate in ./login_security.module
Implementation of form validate. This functions does more than just validating, but it's main Intention is to break the login form flow.

File

./login_security.module, line 297
Login Security

Code

function login_user_block_ip($variables) {

  // There is no need to check if the host has been banned, we can't get here twice.
  $block = new stdClass();
  $block->mask = $variables['%ip'];
  $block->type = 'host';
  $block->status = 0;
  drupal_write_record('access', $block);
  watchdog('login_security', 'Banned IP address %ip due to security configuration.', $variables, WATCHDOG_NOTICE, l(t('edit rule'), "admin/user/rules/edit/{$block->aid}", array(
    'query' => array(
      'destination' => 'admin/user/rules',
    ),
  )));

  //Using form_set_error because it may disrupt current form submission.
  form_set_error('void', login_security_t(variable_get('login_security_host_hard_banned', LOGIN_SECURITY_HOST_HARD_BANNED), $variables));
}