summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-10-18 11:34:45 +0000
committerDries Buytaert <dries@buytaert.net>2009-10-18 11:34:45 +0000
commit2dc3c05a2b40653f10bd57e76007de22b6468a8f (patch)
tree4b1994df6c6a1dbae1a7087a105fe464e5171096 /includes
parentcae0e2036505e4f3b3a4ff4924b9921385741f10 (diff)
downloadbrdo-2dc3c05a2b40653f10bd57e76007de22b6468a8f.tar.gz
brdo-2dc3c05a2b40653f10bd57e76007de22b6468a8f.tar.bz2
- Patch #589126 by mfb: fixed bug with user module using a flood window of 6 hours, but flood events more than 1 hour old being deleted by cron. Improved API documentation, and added tests.
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc8
1 files changed, 7 insertions, 1 deletions
diff --git a/includes/common.inc b/includes/common.inc
index bcc07fe29..5ecdcddf6 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1563,10 +1563,15 @@ function valid_url($url, $absolute = FALSE) {
*
* @param $name
* The name of an event.
+ * @param $window
+ * Optional number of seconds before this event expires. Defaults to 3600 (1
+ * hour). Typically uses the same value as the flood_is_allowed() $window
+ * parameter. Expired events are purged on cron run to prevent the flood table
+ * from growing indefinitely.
* @param $identifier
* Optional identifier (defaults to the current user's IP address).
*/
-function flood_register_event($name, $identifier = NULL) {
+function flood_register_event($name, $window = 3600, $identifier = NULL) {
if (!isset($identifier)) {
$identifier = ip_address();
}
@@ -1575,6 +1580,7 @@ function flood_register_event($name, $identifier = NULL) {
'event' => $name,
'identifier' => $identifier,
'timestamp' => REQUEST_TIME,
+ 'expiration' => REQUEST_TIME + $window,
))
->execute();
}