- Patch #319407 by Crell: convert common.inc to the new database API.

merge-requests/26/head
Dries Buytaert 2008-10-29 10:06:06 +00:00
parent 5371104a2d
commit ae2e4ccd78
1 changed files with 18 additions and 8 deletions

View File

@ -974,7 +974,13 @@ function valid_url($url, $absolute = FALSE) {
* The name of an event.
*/
function flood_register_event($name) {
db_query("INSERT INTO {flood} (event, hostname, timestamp) VALUES ('%s', '%s', %d)", $name, ip_address(), REQUEST_TIME);
db_insert('flood')
->fields(array(
'event' => $name,
'hostname' => ip_address(),
'timestamp' => REQUEST_TIME,
))
->execute();
}
/**
@ -991,8 +997,12 @@ function flood_register_event($name) {
* True if the user did not exceed the hourly threshold. False otherwise.
*/
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(), REQUEST_TIME - 3600));
return ($number < $threshold ? TRUE : FALSE);
$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);
}
function check_file($filename) {