PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Bao Nguyen Quoc   Flood Recorder   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Example
Class: Flood Recorder
Detect attempts to flood a site with many accesses
Author: By
Last change:
Date: 19 years ago
Size: 1,277 bytes


Class file image Download

if (!is_dir('flooddata') || !is_writeable('flooddata')) {
'Please create <b>flooddata</b> folder and CHMOD 0777 it.');


$time = 5;
$interval = 10;

$time2 = 2;
$interval2 = 10;

$flood = new floodrecorder('flooddata' , $time , $interval);
$flood->blocktime = 10;

$message = '';

if (@
$_POST['submit']) {
    if (
$flood->isBlock('press_button' , $time2 , $interval2)) {
$message = "You cannot press the button anymore , please wait for {$flood->blocktime} seconds.<br><br>";
    } else {
$message = "You've pressed the button.<br><br>";

<h3 style="color:navy">FloodRecorder Test Page</h3>
Hello , and welcome to this page . <br>
You can only access this page <?=$time?> times per <?=$interval?> seconds.<br>
Now try to refresh this page many time , you will get a "Flood Detected !" message .<br>
And then , after <?=$flood->blocktime?> seconds , you can view this page again.<bR><br>
<form action="test.php" method=post>
This is a test button : <input type=submit name="submit"><br>
    You can only press this button <?=$time2?> times per <?=$interval2?> seconds.<br>