/[drupal]/contributions/modules/login_security/login_security.install
ViewVC logotype

Contents of /contributions/modules/login_security/login_security.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.14 - (show annotations) (download) (as text)
Wed Jun 24 10:45:03 2009 UTC (5 months ago) by ilo
Branch: MAIN
CVS Tags: HEAD
Changes since 1.13: +0 -0 lines
File MIME type: text/x-php
#500358 fixed the variable %name to populate into watchdog messages
#496448 new extended readme.txt file
1 <?php
2 // $Id: login_security.install,v 1.6.2.6 2009/06/18 14:00:27 deekayen Exp $
3
4 /**
5 * @file
6 * Login Security installation routines
7 */
8
9 /**
10 * Implementation of hook_schema().
11 */
12 function login_security_schema() {
13 $schema['login_security_track'] = array(
14 'description' => t('Keeps track of failed login attempts and the associated IP address and user name.'),
15 'fields' => array(
16 'id' => array(
17 'type' => 'serial',
18 'not null' => TRUE,
19 'description' => t("Hidden ID for each security event."),
20 ),
21 'host' => array(
22 'type' => 'varchar',
23 'length' => 39,
24 'not null' => TRUE,
25 'default' => '',
26 'description' => t("The ip address of the connection."),
27 ),
28 'name' => array(
29 'type' => 'varchar',
30 'length' => 64,
31 'not null' => TRUE,
32 'default' => '',
33 'description' => t("Username used in the login."),
34 ),
35 'timestamp' => array(
36 'type' => 'int',
37 'not null' => TRUE,
38 'default' => 0,
39 'description' => t("Timestamp of the event."),
40 ),
41 ),
42 'indexes' => array(
43 'name' => array('name'),
44 'host' => array('host'),
45 'timestamp' => array('timestamp'),
46 ),
47 'primary key' => array('id')
48 );
49
50 return $schema;
51 }
52
53 /**
54 * Implementation of hook_install().
55 */
56 function login_security_install() {
57 drupal_install_schema('login_security');
58 }
59
60 /**
61 * Implementation of hook_uninstall().
62 */
63 function login_security_uninstall() {
64 variable_del('login_security_track_time');
65 variable_del('login_security_delay_base_time');
66 variable_del('login_security_user_wrong_count');
67 variable_del('login_security_host_wrong_count');
68 variable_del('login_security_host_wrong_count_hard');
69 variable_del('login_security_disable_core_login_error');
70 variable_del('login_security_notice_attempts_available');
71 variable_del('login_security_notice_attempts_message');
72 variable_del('login_security_host_soft_banned');
73 variable_del('login_security_host_hard_banned');
74 variable_del('login_security_user_blocked');
75 variable_del('login_security_user_blocked_email');
76 variable_del('login_security_user_blocked_email_subject');
77 variable_del('login_security_user_blocked_email_body');
78 variable_del('login_security_delay_increase');
79 variable_del('login_security_last_login_timestamp');
80 variable_del('login_security_last_access_timestamp');
81
82 drupal_uninstall_schema('login_security');
83 }
84
85 /**
86 * Support IPv6 length addresses in 6.x because the original 6.x
87 * didn't have this update function. Since it's redundant from the
88 * previous update function, it's mostly just helping support PostgreSQL.
89 * Because update_5000() was the same, without schema, it was removed.
90 *
91 * @return array
92 */
93 function login_security_update_6000() {
94 $ret = array();
95 db_drop_index($ret, 'login_security_track', 'host');
96 db_change_field($ret, 'login_security_track', 'host', 'host', array(
97 'type' => 'varchar',
98 'length' => 39,
99 'not null' => TRUE,
100 'default' => '',
101 'description' => t("The IP address of the connection."),
102 )
103 );
104 db_add_index($ret, 'login_security_track', 'host', array('host'));
105 return $ret;
106 }
107
108 /**
109 * Database clean up update as for #399390
110 * http://drupal.org/node/399390
111 *
112 * Change current primary key to 'id' and add timestamp index
113 *
114 * @return array
115 */
116 function login_security_update_6001() {
117 $ret = array();
118 // Change current primary key
119 db_drop_primary_key($ret, 'login_security_track');
120 db_add_primary_key($ret, 'login_security_track', array('id'));
121 // Drop indexes
122 db_drop_index($ret, 'login_security_track', 'name');
123 db_drop_index($ret, 'login_security_track', 'id');
124 db_change_field($ret, 'login_security_track', 'name', 'name', array(
125 'type' => 'varchar',
126 'length' => 64,
127 'not null' => TRUE,
128 'default' => '',
129 'description' => t("Username used in the login submission."),
130 )
131 );
132 db_change_field($ret, 'login_security_track', 'timestamp', 'timestamp', array(
133 'type' => 'int',
134 'not null' => TRUE,
135 'default' => 0,
136 'description' => t("Timestamp of the event."),
137 )
138 );
139 // Re-create indexes
140 db_add_index($ret, 'login_security_track', 'name', array('name'));
141 db_add_index($ret, 'login_security_track', 'timestamp', array('timestamp'));
142 return $ret;
143 }

  ViewVC Help
Powered by ViewVC 1.1.2