PHP Classes

Traffic Jam: Block unwanted bots based on access speed

Recommend this page to a friend!
  Info   View files Example   View files View files (1)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 79%Total: 284 This week: 1All time: 7,537 This week: 155Up
Version License PHP version Categories
traffic-jam 0.1GNU General Publi...5HTTP, PHP 5, Security
Description 

Author

This class can be used to block unwanted bots based on access speed.

It keeps track of the history of accesses of bots based on their IP address. The accesses information is stored in a history file named based on the IP address.

If the bot accesses more than a given number per second, it will be blocked for a given period of time.

The class can be configured with a whitelist to allow accesses of given user agents that will not be throttled.

Innovation Award
PHP Programming Innovation award nominee
January 2016
Number 2


Prize: One downloadable copy of PhpED Professional
Sometimes sites are abused by bots that crawl them and extract their content.

Since bot scripts often send too many requests to the site servers, that may cause server overload. The site owner may also not be happy with the possibility that other sites that may be stealing their content.

This class may help fighting this kind of abuse by keeping track of the frequency of the accesses performed by bots. It can be used to block bots that are sending requests at a frequency above an acceptable limit.

Manuel Lemos
Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 58
All time rank: 618 in United States United States
Week rank: 13 Up2 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Example

<?php
//traffic jam class 0.1 beta
include('trafficjam.class.php');

$tJam = new trafficJam();

$jamCode = $tJam->jamTraffic();

if( !empty(
$jamCode) ){
   
    include(
'jam_'.$jamCode.'.php');
    exit;
   
}
?>
<html>
    <head>
        <title>Traffic Jam Example</title>
    </head>
    <body>
        <a href="example.php">Click Me</a>
        <p>To test, click link as a normal human would and then click as quickly as possible. Depending on your humanSpeed and jamTime settings, you should get jammed.</p>
        <p>Once jammed, you can refresh the page or visit again later to see countdown to when you will be allowed back in</p>
    </body>
</html>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example Usage

 Version Control Unique User Downloads Download Rankings  
 0%
Total:284
This week:1
All time:7,537
This week:155Up
User Ratings User Comments (1)
 All time
Utility:100%StarStarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:100%StarStarStarStarStarStar
Examples:91%StarStarStarStarStar
Tests:-
Videos:-
Overall:79%StarStarStarStar
Rank:37