Forum Moderators: coopster
2006-05-23 04:48:52 GET /modules.php name=4ndvddb&rop=show_dvd&id=108 - 210.182.198.181 HTTP/1.0 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1) damn.spammers 200 64 0
Code start#
<?php
if(phpversion() >= "4.2.0") {
extract($_SERVER);
}
?>
<html>
<head><title> </title></head>
<body>
<p>There is nothing here to see. So what are you doing here?</p>
<p><a href="http://www.altavista.se/">Go home.</a></p>
<?php
$badbot = 0;
/* scan the blacklist.dat file for addresses of SPAM robots
to prevent filling it up with duplicates */
$filename = "blacklist.txt";
$fp = fopen($filename, "r") or die ("Error opening file ... <br>\n");
while ($line = fgets($fp,255)) {
$u = explode(" ",$line);
if (ereg($u[0],$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 = "webmaster@yourdoman.com";
$to = "webmaster@yourdomain.com";
$subject = "ALERT: BAD ROBOT";
$msg = "A bad robot hit $REQUEST_URI $datum \n";
$msg .= "address is $REMOTE_ADDR, agent is $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,"$REMOTE_ADDR - - [$datum] \"$REQUEST_METHOD $REQUEST_URI $SERVER_PROTOCOL\" $HTTP_REFERER $HTTP_USER_AGENT\n");
fclose($fp);
}
?>
</body>
</html>
Code end#
Regards
Peter
It looks good, although i looked over it very fast. Have you tried it to see if everything works correctly?