spambot.install 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * @file
  4. * Install and update hooks for Spambot module.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function spambot_schema() {
  10. $schema['node_spambot'] = array(
  11. 'description' => 'Node table to track author IP addresses. For use by spambot only.',
  12. 'fields' => array(
  13. 'nid' => array(
  14. 'type' => 'int',
  15. 'unsigned' => TRUE,
  16. 'not null' => TRUE,
  17. 'default' => 0,
  18. ),
  19. 'uid' => array(
  20. 'type' => 'int',
  21. 'unsigned' => TRUE,
  22. 'not null' => TRUE,
  23. 'default' => 0,
  24. ),
  25. 'hostname' => array(
  26. 'type' => 'varchar',
  27. 'length' => 128,
  28. 'not null' => FALSE,
  29. ),
  30. ),
  31. 'primary key' => array('nid'),
  32. 'indexes' => array(
  33. 'uid' => array('uid'),
  34. ),
  35. );
  36. return $schema;
  37. }
  38. /**
  39. * Implements hook_uninstall().
  40. */
  41. function spambot_uninstall() {
  42. db_delete('variable')
  43. ->condition('name', 'spambot_%', 'LIKE')
  44. ->execute();
  45. }
  46. /**
  47. * Update variables, create new table 'node_spambot'.
  48. */
  49. function spambot_update_7101() {
  50. $messages = array();
  51. variable_del('spambot_user_register_report');
  52. $messages[] = t('Deleted variable <em>spambot_user_register_report.</em>');
  53. $message = variable_get('spambot_blocked_message', FALSE);
  54. if ($message !== FALSE) {
  55. variable_set('spambot_blocked_message_email', $message);
  56. variable_set('spambot_blocked_message_username', $message);
  57. variable_set('spambot_blocked_message_ip', $message);
  58. variable_del('spambot_blocked_message');
  59. $messages[] = t('Transferred user registration blocked message to new format.');
  60. }
  61. // Create new table node_spambot.
  62. if (!db_table_exists('node_spambot')) {
  63. $node_spambot = array(
  64. 'description' => t('Node table to track author IP addresses. For use by spambot only.'),
  65. 'fields' => array(
  66. 'nid' => array(
  67. 'type' => 'int',
  68. 'unsigned' => TRUE,
  69. 'not null' => TRUE,
  70. 'default' => 0,
  71. ),
  72. 'uid' => array(
  73. 'type' => 'int',
  74. 'unsigned' => TRUE,
  75. 'not null' => TRUE,
  76. 'default' => 0,
  77. ),
  78. 'hostname' => array(
  79. 'type' => 'varchar',
  80. 'length' => 128,
  81. 'not null' => FALSE,
  82. ),
  83. ),
  84. 'primary key' => array('nid'),
  85. 'indexes' => array(
  86. 'uid' => array('uid'),
  87. ),
  88. );
  89. db_create_table('node_spambot', $node_spambot);
  90. $messages[] = t('Created new table <em>node_spambot</em>.');
  91. }
  92. return implode('<br />', $messages);
  93. }