flood_is_allowed($name, $threshold)
drupal-cvs/includes/common.inc, line 1165
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.
$name The name of the event.
$number The maximum number of the specified event per hour (per visitor).
True if the user did not exceed the hourly threshold. False otherwise.
<?php
function flood_is_allowed($name, $threshold) {
$number = db_query("SELECT COUNT(*) FROM {flood} WHERE event = :event AND hostname = :hostname AND timestamp > :timestamp", array(
':event' => $name,
':hostname' => ip_address(),
':timestamp' => REQUEST_TIME - 3600))
->fetchField();
return ($number < $threshold);
}
?>