DownloadCodeigniter rate limiter hook
Inspired by: https://github.com/alexandrugaidei/ratelimit-codeigniter-filebased
This hook allows you to block ip addresses for a period of time based on a number of pre-established requests.
Usage
-
Inside the config directory in the config.php file enable the use of hooks:
// application/config/config.php
$config['enable_hooks'] = TRUE;
-
Inside the config directory in the hooks.php file add the code below:
// application/config/hooks.php
$hook['post_controller_constructor'] = array(
'class' => 'ratelimit',
'function' => 'limit_all',
'filename' => 'ratelimit.php',
'filepath' => 'hooks'
);
-
Lastly copy and paste the hatelimit.php file into the hooks folder
// application/hooks
Settings
How changes should be made within the file: application/hooks/ratelimit.php // Number of Requisitions
$max_requests = 100;
// Time it will be locked (seconds)
$sec = 300;
|