You are here

login_security.install in Login Security 5

File

login_security.install
View source
<?php

function login_security_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {login_security_track} (" . "id int unsigned NOT NULL auto_increment, " . "host varchar(39) NOT NULL, " . "name varchar(64) NOT NULL, " . "timestamp int(11) unsigned NOT NULL, " . "PRIMARY KEY (id,name,host), " . "INDEX (timestamp) " . ") /*!40100 DEFAULT CHARACTER SET utf8 */;");
      drupal_set_message(t('Created security table'));
      break;
    case 'pgsql':
      db_query("CREATE TABLE {login_security_track} (" . "id serial NOT NULL, " . "host varchar(39) NOT NULL, " . "name varchar(64) NOT NULL, " . "timestamp int_unsigned NOT NULL, " . "PRIMARY KEY (id,name,host) " . ")");
      db_query("CREATE INDEX {login_security_track}_timestamp_idx " . "ON {login_security_track} " . "USING btree " . "(timestamp)");
      drupal_set_message(t('Created security table'));
      break;
  }
}

/**
 * Support IPv6 length addresses.
 *
 * @return array
 */
function login_security_update_5000() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {login_security_track} CHANGE host host VARCHAR(39) NOT NULL");
      break;
  }
  return $ret;
}
function login_security_uninstall() {
  drupal_set_message(t('Removing security options'));
  variable_del('login_security_track_time');
  variable_del('login_security_user_wrong_count');
  variable_del('login_security_host_wrong_count');
  variable_del('login_security_host_wrong_count_hard');
  variable_del('login_security_notice_attempts_available');
  variable_del('login_security_notice_attempts_message');
  variable_del('login_security_host_soft_banned');
  variable_del('login_security_host_hard_banned');
  variable_del('login_security_user_blocked');
  variable_del('login_security_user_blocked_email');
  variable_del('login_security_user_blocked_email_subject');
  variable_del('login_security_user_blocked_email_body');
  variable_del('login_security_last_login_timestamp');
  variable_del('login_security_last_access_timestamp');
  db_query("DROP TABLE {login_security_track}");
}

/**
 * Remove the option to have a login punishment for login failures for DoS.
 */
function login_security_update_5001() {
  variable_del('login_security_delay_base_time');
  variable_del('login_security_delay_increase');
}

Functions

Namesort descending Description
login_security_install
login_security_uninstall
login_security_update_5000 Support IPv6 length addresses.
login_security_update_5001 Remove the option to have a login punishment for login failures for DoS.