What is this module?
If you want to extend Drupal core's flood control mechanism to your custom forms then
this module provide
1) an API to construct an admin form to manage flood control settings per form.
2) an example module (D8 version for now) to implement flood control to your custom form.
Simply
1. You need to implement hook_floodcontrol_settings in your custom module to construct the admin settings form.
2. Then in your custom form submission add code something like
function mycustom_form_submit() {
// first check whether submission is allowed by flood control.
// assumption: mycustom_form is the name of the event.
if ((!flood_is_allowed('mycustom_form', variable_get('floodcontol_api_myform_threshold', '50'), variable_get('floodcontol_api_myform_window', '3600')))) {
// In one hour more than 50 form submission is not allowed.
// Throw error.
drupal_set_message(t('Too many submissions in short period of time. Please try again after some time.'), 'error');
} else {
// do all my successful processing of the form submission.
// Register for flood control.
if (module_exists('floodcontrol_settings_api')) {
flood_register_event('mycustom_form', variable_get('floodcontol_api_myform_window', '3600'));
}
}
}
This module also provides an UI to clear "flood" table.
Background information on why we might need this module.
Drupal provides three core functions to protect forms against flooding.
flood_register_event Registers an event for the current visitor to the flood control mechanism.
flood_is_allowed Checks whether a user is allowed to proceed with the specified event.
flood_clear_event Makes the flood control mechanism forget an event for the current visitor.
Reference:
https://api.drupal.org/api/drupal/includes%21common.inc/7.x
https://drupal.stackexchange.com/questions/168104/how-to-extend-flood-co...
The contact form,login forms in Drupal core are examples of forms which are protected against flood control using above functions.
You may want to extend this flood control mechanism to your custom forms.
You may also want to configure the limit and time windows in Drupal admin panel to control the flooding.
This lightweight module provides an blank UI and an API to configure your own flood control variables.
The UI is populated with your own flood control settings when you implement the floodcontrol_settings API.
How to extend the floodcontrol_settings API
See floodcontrol_settings_api.api.php for more details and an example.
Where is the UI?
1. Go to admin/config/system/floodcontrol-settings-api to see the settings
(Initially it is empty. You need to implement hook_floodcontrol_settings for your custom form)
2. Go to admin/config/system/floodcontrol-settings-api/clear-flood to clear the flood table.
@TODO: add event based and identified based flood table clearance.
Project information
- Project categories: Security
28 sites report using this module
- Created by gopisathya on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.


