You are here

function flood_is_allowed in Drupal 5

Same name and namespace in other branches
  1. 4 includes/common.inc \flood_is_allowed()
  2. 6 includes/common.inc \flood_is_allowed()
  3. 7 includes/common.inc \flood_is_allowed()

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.

$number: 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.

Related topics

2 calls to flood_is_allowed()
contact_site_page in modules/contact/contact.module
Site-wide contact page
contact_user_page in modules/contact/contact.module
Personal contact page.

File

includes/common.inc, line 977
Common functions that many Drupal modules will need to reference.

Code

function flood_is_allowed($name, $threshold) {
  $number = db_num_rows(db_query("SELECT event FROM {flood} WHERE event = '%s' AND hostname = '%s' AND timestamp > %d", $name, $_SERVER['REMOTE_ADDR'], time() - 3600));
  return $number < $threshold ? TRUE : FALSE;
}