Для юзеров Seditio и новичков
Yusupov |
|
---|---|
#30404 jcrush: Не знаю спасет ли от ддоса такой код: $itime = 10; // Minimum number of seconds between visits $ipenalty = 60; // Seconds before visitor is allowed back $imaxvisit = 42; // Maximum visits $iplogdir = "logs/timefiles/"; $ipfile = substr(md5($_SERVER["REMOTE_ADDR"]), -2); $oldtime = 0; if (file_exists($iplogdir.$ipfile)) $oldtime = filemtime($iplogdir.$ipfile); $time = time(); if ($oldtime < $time) $oldtime = $time; $newtime = $oldtime + $itime; if ($newtime >= $time + $itime*$imaxvisit) { touch($iplogdir.$ipfile, $time + $itime*($imaxvisit-1) + $ipenalty); header("HTTP/1.0 503 Service Temporarily Unavailable"); header("Connection: close"); header("Content-Type: text/html"); echo "<html><body><center><p><b>Превышено число обращений к серверу</b><br>"; echo "Пожалуйста, обратитесь позже...</p></center></body></html>"; exit(); } touch($iplogdir.$ipfile, $newtime);На шоп-скрипте он мне очень помог избавиться от такой атаки. |