View source
<?php
function restrict_by_ip_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {restrict_by_ip} (\n uid int unsigned NOT NULL,\n restrict_by_ip_type int unsigned,\n restrict_ip_addr1_q1 int unsigned,\n restrict_ip_addr1_q2 int unsigned,\n restrict_ip_addr1_q3 int unsigned,\n restrict_ip_addr1_q4 int unsigned,\n restrict_ip_addr2_q1 int unsigned,\n restrict_ip_addr2_q2 int unsigned,\n restrict_ip_addr2_q3 int unsigned,\n restrict_ip_addr2_q4 int unsigned,\n PRIMARY KEY(uid)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;\n ");
break;
case 'pgsql':
db_query("CREATE TABLE {restrict_by_ip} (\n uid int NOT NULL, \n restrict_by_ip_type int,\n restrict_ip_addr1_q1 int,\n restrict_ip_addr1_q2 int,\n restrict_ip_addr1_q3 int,\n restrict_ip_addr1_q4 int,\n restrict_ip_addr2_q1 int,\n restrict_ip_addr2_q2 int,\n restrict_ip_addr2_q3 int,\n restrict_ip_addr2_q4 int,\n PRIMARY KEY(uid)\n );\n ");
break;
}
watchdog('restrict_by_ip', 'restrict_by_ip module installed');
drupal_set_message(t('The Restrict by IP Address module was installed. You may want to go to the <a href="!settings">settings page now</a>.', array(
'!settings' => url('admin/settings/restrict_by_ip'),
)));
}
function restrict_by_ip_uninstall() {
db_query('DROP TABLE {restrict_by_ip}');
variable_del('restrict_by_ip_error_page');
cache_clear_all('*', 'cache', TRUE);
cache_clear_all('*', 'cache_filter', TRUE);
cache_clear_all('*', 'cache_menu', TRUE);
cache_clear_all('*', 'cache_page', TRUE);
watchdog('restrict_by_ip', 'restrict_by_ip module removed');
}