diff options
| author | Savetheinternet <savetheinternet@n0v4.com> | 2011-01-18 17:11:28 +1100 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@n0v4.com> | 2011-01-18 17:11:28 +1100 |
| commit | d284b0d50dabef2627ba9e38291f07e736dd0721 (patch) | |
| tree | 7c2fbaf5adf877b7b4bf473b41d13f792c9b4b78 /inc/functions.php | |
| parent | 5c2b7dfe61c1a702fd7cbb1bbcec6a036055bff9 (diff) | |
flood prevention
Diffstat (limited to 'inc/functions.php')
| -rw-r--r-- | inc/functions.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/inc/functions.php b/inc/functions.php index de188f0b..70a17d23 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -45,6 +45,20 @@ return $boards; } + function checkFlood($post) { + global $board; + + $query = prepare(sprintf("SELECT * FROM `posts_%s` WHERE (`ip` = :ip AND `time` >= :floodtime) OR (`ip` = :ip AND `body` = :body AND `time` >= :floodsameiptime) OR (`body` = :body AND `time` >= :floodsametime) LIMIT 1", $board['uri'])); + $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); + $query->bindValue(':body', $post['body'], PDO::PARAM_INT); + $query->bindValue(':floodtime', time()-FLOOD_TIME, PDO::PARAM_INT); + $query->bindValue(':floodsameiptime', time()-FLOOD_TIME_IP_SAME, PDO::PARAM_INT); + $query->bindValue(':floodsametime', time()-FLOOD_TIME_SAME, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + return (bool)$query->fetch(); + } + function until($timestamp) { $difference = $timestamp - time(); if($difference < 60) { |
