mordastik
Newbie | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Следующая цитата взята отсюда... Цитата: ... PHP script that you can include in all your file, it checks if someone is leeching the content of your site by using some sort of bot, download manager or "offline browser" (like Teleport Pro and others) to grab all your files... Here's the code: --------------------------------------------------------------------- <? $itime = 10; // Minimum number of seconds between visits $ipenalty = 60; // Seconds before visitor is allowed back $imaxvisit = 42; // Maximum visits $iplogdir = "iplog/"; $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><p><b>Server under heavy load</b><br>"; echo "Please wait $ipenalty seconds and try again</p></body></html>"; exit(); } touch($iplogdir.$ipfile, $newtime); ?> --------------------------------------------------------------------- What it does, is that it checks if a user is giving X number hits to your site in Y seconds. If it goes above that, it kills the page for Z number of seconds until the user is allowed to try again. In the example, the user can click about 42 times for ever 420 seconds. Be careful though, to still let the settings high enough. I actually triggered the script just by browsing and clicking really quickly. It really helped us though, we noticed in our stats that the leecher were still giving tons and tons of hits (probably started his leeching with some automated program and left it running, not realizing he was only getting the error page over and over again), but the bandwidth usage remained low. Oh, don't forget of course, to create the /iplog directory, and set the proper permissions. | Еще об этом же скрипте можно почитать здесь. А также еще одно интересное решение блокировки, приводиться здесь. | Всего записей: 5 | Зарегистр. 09-12-2002 | Отправлено: 10:46 10-09-2003 | Исправлено: mordastik, 10:16 11-09-2003 |
|