//Idea taken from http://seven-3-five.blogspot.com/2006/09/simple-php-based-bad-bot-trap_04.html $ip = $_SERVER['REMOTE_ADDR']; header("Content-type: text/html; charset=utf-8"); echo ''; echo '
You will now be banned!
'; $text = 'deny from ' . $ip . "\r\n"; $file = dirname(__FILE__).'/.htaccess'; if (is_file($file) && is_writable($file)){ if ($handle = @fopen($file, 'a')) { fwrite($handle, $text); fclose($handle); } } ?>