
| Current Path : /var/www/html/stolberg/web/modules/contrib/honeypot/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/stolberg/web/modules/contrib/honeypot/honeypot.install |
<?php
/**
* @file
* Install, update and uninstall functions for the Honeypot module.
*/
use Drupal\Core\Url;
/**
* Implements hook_schema().
*/
function honeypot_schema() {
$schema['honeypot_user'] = [
'description' => 'Table that stores failed attempts to submit a form.',
'fields' => [
'id' => [
'type' => 'serial',
'not null' => TRUE,
'description' => 'Unique record ID.',
],
'uid' => [
'description' => 'Foreign key to {users}.uid; uniquely identifies a Drupal user to whom this ACL data applies.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],
'hostname' => [
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'description' => 'Hostname of user that that triggered honeypot.',
],
'timestamp' => [
'description' => 'Date/time when the form submission failed, as Unix timestamp.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],
],
'primary key' => ['id'],
'indexes' => [
'uid' => ['uid'],
'timestamp' => ['timestamp'],
'hostname' => ['hostname'],
],
];
return $schema;
}
/**
* Implements hook_install().
*/
function honeypot_install() {
if (PHP_SAPI !== 'cli') {
// Rebuild so that routes defined in honeypot.routing.yml become available.
\Drupal::service('router.builder')->rebuild();
// Prompt the user to configure Honeypot.
\Drupal::messenger()->addMessage(t('Honeypot installed successfully. Please <a href=":url">configure Honeypot</a> to protect your forms from spam bots.', [
':url' => Url::fromRoute('honeypot.config')->toString(),
]));
}
}
/**
* Implements hook_uninstall().
*/
function honeypot_uninstall() {
// Clear the bootstrap cache.
\Drupal::cache('bootstrap')->deleteAll();
}
/**
* Implements hook_update_last_removed().
*/
function honeypot_update_last_removed() {
return 8104;
}