123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- /**
- * Implementation of hook_schema().
- */
- function spambot_schema() {
- $schema = array();
- $schema['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'),
- ),
- );
- return $schema;
- }
- /**
- * Implementation of hook_uninstall().
- */
- function spambot_uninstall() {
- db_query("DELETE FROM {variable} WHERE name LIKE 'spambot_%'");
- }
- /**
- * Migrate settings from previous version of spambot (6.x-2.0)
- */
- function spambot_update_6300() {
- $ret = array();
- // In previous versions of spambot, the default message was 'Blacklisted. Now go away!'
- // If no custom message was configured, then configure it to 'Blacklisted. Now go away!'
- $message = variable_get('spambot_blocked_message', FALSE);
- if (!$message) {
- variable_set('spambot_blocked_message', t('Blacklisted. Now go away!'));
- }
- // Previous versions of spambot blacklisted on any of the three criteria
- variable_set('spambot_criteria_email', TRUE);
- variable_set('spambot_criteria_username', TRUE);
- variable_set('spambot_criteria_ip', TRUE);
- return $ret;
- }
- function spambot_update_6301() {
- $ret = array();
- // Change criteria settings from booleans to numbers
- if (variable_set('spambot_criteria_email', TRUE)) {
- variable_set('spambot_criteria_email', 1);
- }
- if (variable_set('spambot_criteria_username', FALSE)) {
- variable_set('spambot_criteria_username', 1);
- }
- if (variable_set('spambot_criteria_ip', FALSE)) {
- variable_set('spambot_criteria_ip', 1);
- }
- return $ret;
- }
- 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')) {
- $schema = array();
- $schema['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', $schema['node_spambot']);
- $messages[] = t('Created new table <em>node_spambot</em>.');
- }
-
- return join('<br />', $messages);
- }
|