Vâng, tôi phải nói rằng, kinda thất vọng - Tôi đã hy vọng đối với một số ý tưởng sáng tạo. Tôi đã tìm ra giải pháp lý tưởng ở đây .. http://www.kloth.net/internet/bottrap.php
<html>
<head><title> </title></head>
<body>
<p>There is nothing here to see. So what are you doing here ?</p>
<p><a href="http://your.domain.tld/">Go home.</a></p>
<?php
/* whitelist: end processing end exit */
if (preg_match("/10\.22\.33\.44/",$_SERVER['REMOTE_ADDR'])) { exit; }
if (preg_match("Super Tool",$_SERVER['HTTP_USER_AGENT'])) { exit; }
/* end of whitelist */
$badbot = 0;
/* scan the blacklist.dat file for addresses of SPAM robots
to prevent filling it up with duplicates */
$filename = "../blacklist.dat";
$fp = fopen($filename, "r") or die ("Error opening file ... <br>\n");
while ($line = fgets($fp,255)) {
$u = explode(" ",$line);
$u0 = $u[0];
if (preg_match("/$u0/",$_SERVER['REMOTE_ADDR'])) {$badbot++;}
}
fclose($fp);
if ($badbot == 0) { /* we just see a new bad bot not yet listed ! */
/* send a mail to hostmaster */
$tmestamp = time();
$datum = date("Y-m-d (D) H:i:s",$tmestamp);
$from = "[email protected]";
$to = "[email protected]";
$subject = "domain-tld alert: bad robot";
$msg = "A bad robot hit $_SERVER['REQUEST_URI'] $datum \n";
$msg .= "address is $_SERVER['REMOTE_ADDR'], agent is $_SERVER['HTTP_USER_AGENT']\n";
mail($to, $subject, $msg, "From: $from");
/* append bad bot address data to blacklist log file: */
$fp = fopen($filename,'a+');
fwrite($fp,"$_SERVER['REMOTE_ADDR'] - - [$datum] \"$_SERVER['REQUEST_METHOD'] $_SERVER['REQUEST_URI'] $_SERVER['SERVER_PROTOCOL']\" $_SERVER['HTTP_REFERER'] $_SERVER['HTTP_USER_AGENT']\n");
fclose($fp);
}
?>
</body>
</html>
Sau đó, để bảo vệ trang ném <?php include($DOCUMENT_ROOT . "/blacklist.php"); ?>
trên dòng đầu tiên của mỗi trang ..blacklist.php
chứa:
<?php
$badbot = 0;
/* look for the IP address in the blacklist file */
$filename = "../blacklist.dat";
$fp = fopen($filename, "r") or die ("Error opening file ... <br>\n");
while ($line = fgets($fp,255)) {
$u = explode(" ",$line);
$u0 = $u[0];
if (preg_match("/$u0/",$_SERVER['REMOTE_ADDR'])) {$badbot++;}
}
fclose($fp);
if ($badbot > 0) { /* this is a bad bot, reject it */
sleep(12);
print ("<html><head>\n");
print ("<title>Site unavailable, sorry</title>\n");
print ("</head><body>\n");
print ("<center><h1>Welcome ...</h1></center>\n");
print ("<p><center>Unfortunately, due to abuse, this site is temporarily not available ...</center></p>\n");
print ("<p><center>If you feel this in error, send a mail to the hostmaster at this site,<br>
if you are an anti-social ill-behaving SPAM-bot, then just go away.</center></p>\n");
print ("</body></html>\n");
exit;
}
?>
Tôi định đưa ra lời khuyên của Scott Chamberlain và an toàn để lên kế hoạch triển khai Captcha trên tập lệnh. Nếu người dùng trả lời chính xác thì nó sẽ chỉ die
hoặc chuyển hướng trở lại trang gốc. Chỉ để cho vui, tôi đang ném cái bẫy vào một thư mục có tên /admin/
và được thêm vào Disallow: /admin/
vào robots.txt.
EDIT: Ngoài ra tôi đang chuyển hướng các bot bỏ qua các quy tắc để trang này: http://www.seastory.us/bot_this.htm
Đây là một câu hỏi thú vị, và tôi rất muốn nhìn thấy một số câu trả lời. Nhưng tôi nghi ngờ rằng nó có thể phù hợp hơn với [Server Fault] (http://serverfault.com). –
Tôi đồng ý nhưng các nhà phát triển sáng tạo hơn rất nhiều rồi các chuyên gia CNTT..lol! – Mikey1980
Nhưng ai đó "tạo ra" giải pháp này đã có, và các chàng trai CNTT rất giỏi triển khai nó. –