103 lines
2.5 KiB
Plaintext
103 lines
2.5 KiB
Plaintext
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Install and update hooks for Spambot module.
|
|
*/
|
|
|
|
/**
|
|
* Implements hook_schema().
|
|
*/
|
|
function spambot_schema() {
|
|
$schema['node_spambot'] = array(
|
|
'description' => 'Node table to track author IP addresses. For use by spambot only.',
|
|
'fields' => array(
|
|
'nid' => array(
|
|
'type' => 'int',
|
|
'unsigned' => TRUE,
|
|
'not null' => TRUE,
|
|
'default' => 0,
|
|
),
|
|
'uid' => array(
|
|
'type' => 'int',
|
|
'unsigned' => TRUE,
|
|
'not null' => TRUE,
|
|
'default' => 0,
|
|
),
|
|
'hostname' => array(
|
|
'type' => 'varchar',
|
|
'length' => 128,
|
|
'not null' => FALSE,
|
|
),
|
|
),
|
|
'primary key' => array('nid'),
|
|
'indexes' => array(
|
|
'uid' => array('uid'),
|
|
),
|
|
);
|
|
|
|
return $schema;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_uninstall().
|
|
*/
|
|
function spambot_uninstall() {
|
|
db_delete('variable')
|
|
->condition('name', 'spambot_%', 'LIKE')
|
|
->execute();
|
|
}
|
|
|
|
/**
|
|
* Update variables, create new table 'node_spambot'.
|
|
*/
|
|
function spambot_update_7101() {
|
|
$messages = array();
|
|
|
|
variable_del('spambot_user_register_report');
|
|
$messages[] = t('Deleted variable <em>spambot_user_register_report.</em>');
|
|
|
|
$message = variable_get('spambot_blocked_message', FALSE);
|
|
if ($message !== FALSE) {
|
|
variable_set('spambot_blocked_message_email', $message);
|
|
variable_set('spambot_blocked_message_username', $message);
|
|
variable_set('spambot_blocked_message_ip', $message);
|
|
variable_del('spambot_blocked_message');
|
|
$messages[] = t('Transferred user registration blocked message to new format.');
|
|
}
|
|
|
|
// Create new table node_spambot.
|
|
if (!db_table_exists('node_spambot')) {
|
|
$node_spambot = array(
|
|
'description' => t('Node table to track author IP addresses. For use by spambot only.'),
|
|
'fields' => array(
|
|
'nid' => array(
|
|
'type' => 'int',
|
|
'unsigned' => TRUE,
|
|
'not null' => TRUE,
|
|
'default' => 0,
|
|
),
|
|
'uid' => array(
|
|
'type' => 'int',
|
|
'unsigned' => TRUE,
|
|
'not null' => TRUE,
|
|
'default' => 0,
|
|
),
|
|
'hostname' => array(
|
|
'type' => 'varchar',
|
|
'length' => 128,
|
|
'not null' => FALSE,
|
|
),
|
|
),
|
|
'primary key' => array('nid'),
|
|
'indexes' => array(
|
|
'uid' => array('uid'),
|
|
),
|
|
);
|
|
db_create_table('node_spambot', $node_spambot);
|
|
$messages[] = t('Created new table <em>node_spambot</em>.');
|
|
}
|
|
|
|
return implode('<br />', $messages);
|
|
}
|