Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   Forum for discussion of ANTICHAT (https://forum.antichat.xyz/forumdisplay.php?f=72)
-   -   protect your site against DDOS with PHP script (https://forum.antichat.xyz/showthread.php?t=2022442)

KrypTik 07.09.2014 01:00

Hello

0) $iptime = 20; // minimum number of seconds between visits for users with certain cookie
else $iptime = 10; // minimum number of seconds between visits for everyone else

$ippenalty = 60; // seconds before visitor is allowed back

if($cookie && $othercookie > 0)$ipmaxvisit = 30; // maximum visits, per $iptime segment
else $ipmaxvisit = 20; // maximum visits per $iptime segment

$iplogdir = "./iplog/";
$iplogfile = "iplog.dat";

$ipfile = substr(md5($_server["remote_addr"]), -2);
$oldtime = 0;
if (file_exists($iplogdir.$ipfile)) $oldtime = filemtime($iplogdir.$ipfile);

$time = time();
if ($oldtime = $time + $iptime*$ipmaxvisit)
{
touch($iplogdir.$ipfile, $time + $iptime*($ipmaxvisit-1) + $ippenalty);
$oldref = $_server['http_referer'];
header("http/1.0 503 service temporarily unavailable");
header("connection: close");
header("content-type: text/html");
echo "

temporary access denialtoo many quick page views by your ip address (more than ".$ipmaxvisit." visits within ".$iptime." seconds).
";
echo "
please wait ".$ippenalty." seconds and reload.";
touch($iplogdir.$iplogfile); //create if not existing
$fp = fopen($iplogdir.$iplogfile, "a");
$yourdomain = $_server['http_host'];
if ($fp)
{
$useragent = "";
if (isset($_server["http_user_agent"])) $useragent = $_server["http_user_agent"];
fputs($fp, $_server["remote_addr"]." ".date("d/m/y h:i:s")." ".$useragent."\n");
fclose($fp);
$yourdomain = $_server['http_host'];

//the @ symbol before @mail means 'supress errors' so you wont see errors on the page if email fails.
if($_session['reportedflood']

Give me please +1 like

SharkyUA 26.10.2014 01:00

Sorry, but it's not a solution.
If you're need protection, then you'll should setup hardware firewall or use CDN services.
Such as Cloudflare, Cloud Front, etc.

And you should use CODE forum tag.

[S]Didn't see post date =\[/S]


Время: 04:00