function shurly_flood_register_event in ShURLy 8
Same name and namespace in other branches
- 6 shurly.module \shurly_flood_register_event()
- 7 shurly.module \shurly_flood_register_event()
Function to store the flood event.
1 call to shurly_flood_register_event()
- shurly_rate_limit_allowed in ./
shurly.module - Check rate limit for this user return an array in the following format array( 'allowed' => TRUE/FALSE 'rate' => number of requests allowed 'time' => period of time in minutes )
File
- ./
shurly.module, line 85 - Description http://www.youtube.com/watch?v=Qo7qoonzTCE.
Code
function shurly_flood_register_event($name, $window = 3600, $identifier = NULL) {
if (!isset($identifier)) {
$identifier = \Drupal::request()
->getClientIp();
}
$request_time = \Drupal::time()
->getRequestTime();
\Drupal::database()
->query("INSERT INTO {shurly_flood} (event, identifier, timestamp, expiration) VALUES (:event, :identifier, :timestamp, :expiration)", [
'event' => $name,
'identifier' => \Drupal::request()
->getClientIp(),
'timestamp' => $request_time,
'expiration' => time() + $window,
]);
}