You are here

function _login_security_get_variables_by_name in Login Security 5

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

Helper function to get the variable array for the messages.

2 calls to _login_security_get_variables_by_name()
login_security_form_alter in ./login_security.module
Implementation of hook_form_alter().
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 366
Login Security

Code

function _login_security_get_variables_by_name($name) {
  $account = user_load(array(
    "name" => $name,
  ));
  $ipaddress = mip_address();
  global $base_url;
  $variables = array(
    '%date' => format_date(time()),
    '%ip' => $ipaddress,
    '%username' => $account->name,
    '%email' => $account->mail,
    '%uid' => $account->uid,
    '%site' => variable_get('site_name', 'drupal'),
    '%uri' => $base_url,
    '%edit_uri' => url('user/' . $account->uid . '/edit', NULL, NULL, TRUE),
    '%hard_block_attempts' => variable_get('login_security_host_wrong_count_hard', LOGIN_SECURITY_HOST_WRONG_COUNT_HARD),
    '%soft_block_attempts' => variable_get('login_security_host_wrong_count', LOGIN_SECURITY_USER_WRONG_COUNT),
    '%user_block_attempts' => variable_get('login_security_user_wrong_count', LOGIN_SECURITY_USER_WRONG_COUNT),
    '%user_ip_current_count' => db_result(db_query("SELECT COUNT(id) FROM {login_security_track} WHERE name = '%s' and host = '%s'", $name, $ipaddress)),
    '%ip_current_count' => db_result(db_query("SELECT COUNT(id) FROM {login_security_track} WHERE host = '%s'", $ipaddress)),
    '%user_current_count' => db_result(db_query("SELECT COUNT(id) FROM {login_security_track} WHERE name = '%s'", $name)),
    '%tracking_time' => variable_get('login_security_track_time', LOGIN_SECURITY_TRACK_TIME),
  );
  return $variables;
}