| 5 common.inc | flood_is_allowed($name, $threshold) |
| 6 common.inc | flood_is_allowed($name, $threshold) |
| 7 common.inc | flood_is_allowed($name, $threshold, $window = 3600, $identifier = NULL) |
| 8 common.inc | flood_is_allowed($name, $threshold, $window = 3600, $identifier = NULL) |
Check if the current visitor (hostname/IP) is allowed to proceed with the specified event.
The user is allowed to proceed if he did not trigger the specified event more than $threshold times per hour.
Parameters
$name: The name of the event.
$threshold: The maximum number of the specified event per hour (per visitor).
Return value
True if the user did not exceed the hourly threshold. False otherwise.
2 calls to flood_is_allowed()
File
- includes/
common.inc, line 1075 - Common functions that many Drupal modules will need to reference.
Code
function flood_is_allowed($name, $threshold) {
$number = db_result(db_query("SELECT COUNT(*) FROM {flood} WHERE event = '%s' AND hostname = '%s' AND timestamp > %d", $name, ip_address(), time() - 3600));
return ($number < $threshold ? TRUE : FALSE);
}
Login or register to post comments