Login   Register  
PHP Classes
elePHPant
Icontem

File: test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 9 years ago
Size: 1,277 bytes
 

Contents

Class file image Download
<?

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

include_once 
"class.floodrecorder.php";

$time 5;
$interval 10;

$time2 2;
$interval2 10;

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

$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>";
        
$flood->record('press_button');
    }
}

?>
<html>
<body>
<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>
    <?=$message?>
    This is a test button : <input type=submit name="submit"><br>
    You can only press this button <?=$time2?> times per <?=$interval2?> seconds.<br>
</form>
</body>
</html>