PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Leonardo Feitosa   Rate Limit Code Igniter Hook   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Rate Limit Code Igniter Hook
Block computer IP addresses that access many times
Author: By
Last change:
Date: 3 months ago
Size: 974 bytes
 

Contents

Class file image Download

Codeigniter 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

  1. Inside the config directory in the config.php file enable the use of hooks:
    // application/config/config.php
    $config['enable_hooks'] = TRUE;
    
  2. 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'
    );
    
  3. 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;