include "$_SERVER[DOCUMENT_ROOT]/path/to/ksantiddos.php";
$ksa = new ksantiddos(200000); // number of bytes for shared memory. defau;t is 300000
// script analizes IP activity for last $seconds_limit seconds
$seconds_limit = 20;
// considering hits above $hits_limit as subject of blocking
$hits_limit = 10;
// script indicates visitor`s status ($ks->visitor) as:
// raw - visitor was somehow not processed by KS AntiDDOS
// new - processing first visit from the IP for $seconds_limit seconds
// cool - number of hits from the IP - form 2 to $ksa->warm_level-1
// warm - number of hits from the IP - form $ksa->warm_level to $ksa->hits_limit-1
// hot - number of hits from the IP exeeds hits_limit and visitor should be blocked (suspended) for $ksa->delay seconds
// more optional settings
$ksa->auto = false; // dont suspend hot-visitor by the script (if you are going to make it by yourself)
$ksa->warm_level = 3; // value of warm_level, default is $hits_limit/2
$ksa->delay = 10; // offer 'hot' visitor be back in $ksa->delay second; this is the time of suspension
// default value is 30
$ksa->block_cnet = false; // block IP on C-net basis. script stores 111.222.333.* IPs as single 111.222.333. IP.
// this considerably improves efficiency of infected nets blocking.
// there is no common reason to turn it to false. defalt is true.
// detecting visitor`s status
$ksa->doit($hits_limit,$seconds_limit);
// if you didn`t reset $ksa->auto to false and visitor`s status $ksa->visitor=='hot'
// then scripts sends the browser headers and HTML that suspend the visitor for $ksa->delay seconds (30 as default)
// now, if your reset $ksa->auto to false, do detecting if visitor should be suspended
if ($ksa->visitor=='hot' && isset($_GET['search'])) // blocking only search requests, for example
{
header('HTTP/1.0 503 Service Unavailable');
header('Status: 503 Service Unavailable');
header('Retry-After: 30');
die('sleep');
}
$lite_version = $ksa->visitor=='warm'; // on this variable you can return a lite version of your site to 'warm' visitors
// (that have above $ksa->warm_level hits in $ksa->seconds_limit seconds)