friendly_register.install 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * @file
  4. * Allows users to get feedback on username and email without submitting the form.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function friendly_register_schema() {
  10. $schema = array();
  11. $schema['friendly_register_flood'] = array(
  12. 'description' => 'This table is use to limit flooding of requests.',
  13. 'fields' => array(
  14. 'ip' => array(
  15. 'description' => 'The IP address (both IP v4 and v6)',
  16. 'type' => 'char',
  17. 'length' => 40,
  18. 'not null' => TRUE,
  19. ),
  20. 'hits' => array(
  21. 'description' => 'Total number of hits this IP address has caused.',
  22. 'type' => 'int',
  23. 'unsigned' => TRUE,
  24. 'not null' => TRUE,
  25. ),
  26. 'lasthit' => array(
  27. 'description' => 'The date time (unix epoch) of the last hit.',
  28. 'type' => 'int',
  29. 'unsigned' => TRUE,
  30. 'not null' => TRUE,
  31. ),
  32. ),
  33. 'indexes' => array(
  34. 'ip' => array('ip', 'hits'),
  35. 'lasthit' => array('lasthit'),
  36. ),
  37. );
  38. return $schema;
  39. }
  40. function friendly_register_update_7100() {
  41. db_drop_index('friendly_register_flood', 'ip');
  42. db_change_field('friendly_register_flood', 'ip', 'ip',
  43. array('type' => 'char', 'length' => 40, 'not null' => TRUE),
  44. array('indexes' => array(
  45. 'ip' => array(
  46. 'ip',
  47. 'hits',
  48. ),
  49. 'lasthit' => array(
  50. 'lasthit',
  51. )
  52. )));
  53. }