Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

flood_control

With this function you are able to prevent users from flooding the system, typical spam bots and others.
This function should be used whenever users have the ability to post to the database.
The function will automatically ban spammers.

flood_control

Quote

flood_control ( string $field, string $table, string $where )


Parameters
field
The field in the table which holds the Unix timestamp. It is important that this is a Unix timestamp and not some other kind of datestamp!

table
The table you are flood controlling and where the UNIX timestamp field is located in.

where
The where statement to select the right rows and the right datestamp. This should either be a user_id or a user_ip.

Return Values
This function will return true if the user have exceeded the flood limit. Else it will return false if the user is not flooding the system.

Example
Code
<?php
require_once INCLUDES."flood_include.php";
if (!flood_control("comment_datestamp", DB_COMMENTS, "comment_ip='".USER_IP."'")) {
 $result = dbquery(
 "INSERT INTO ".DB_COMMENTS." (
 comment_item_id,
 comment_type,
 comment_name,
 comment_message,
 comment_datestamp,
 comment_ip
 ) VALUES (
 '$cid',
 '$ctype',
 '$comment_name',
 '$comment_message',
 '".time()."',
 '".USER_IP."'
 )"
 );
}
?>

We use the flood control function to check if the user is flooding before we store the request to the database. If the function returns false it means the user is not flooding and we'll add the post to the database.

Changelog
7.01.00 - Admin option to enable or disable flood control auto ban. Function will now send out mail to the banned user about the ban through the flood control.
7.00.00 - Function added to PHP-Fusion

Notes
Be sure to require_once INCLUDES."flood_include.php"; or else this function will not work!


See also …


References