Page is a not externally linkable
carfac - 4:47 pm on Dec 9, 2002 (gmt 0)
I had a few requests, and the script is not a secret, so I decided to post here. Apologies to Key_Master for hacking his script! Comments welcome- thats why we are in this forum, right? Lets make it all better! OK, here is the script. See instructions AFTER the script! #!/usr/local/bin/perl # This is the only variable that needs to be modified. Replace it with the absolute path to your root directory. # Grab the IP of the bad bot if ($visitor_ip =~ /^216\.239\.3([3¦7¦9]\.5)$¦^216\.239\.35\.4$/) { $visitor_ip =~ s/\./\\\./gi; # Set Date # Open .htaccess file # Write banned IP to .htaccess file # Close } ########################## END OF SCRIPT OK, so take and pop this little puppie into the same directory you want protected, chmod 755. I use a file I call "bad_ip.txt" to hold my bad IP's, but you can change to anything (including .htaccess, but make sure you escape the "."!) This will write to the TOP of any file you have set up, so, the older stuff goes down two linbes every time this gets written to. If you edit bad_ip.txt (or .htaccess) make SURE to upload to your server ASCII, or it wiull not work. I think that is it... comments welcome! dave
Hi:
# Name this script trap.pl, upload it in ASCII mode to your cgi-bin and set the file permissions to CHMOD 755.
# Original script by Key_Master taken from [webmasterworld.com...]
$rootdir = "/path/to/root/directory";
$visitor_ip = $ENV{'REMOTE_ADDR'};
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Forward On</title>\n<META NAME=\"robots\" CONTENT=\"NOINDEX,NOFOLLOW\">\n";
print "</head>\n";
print "<body>\n";
print "<p><b>We had an error.<BR>Please return to continue!</b></p>\n";
print "</body>\n";
print "</html>\n";
exit;
}
else {
$date = scalar localtime ( time );
open(HTACCESS,"".$rootdir."/bad_ip.txt") ¦¦ die $!;
@htaccess = <HTACCESS>;
close(HTACCESS);
open(HTACCESS,">".$rootdir."/bad_ip.txt") ¦¦ die $!;
print HTACCESS "\^".$visitor_ip."\$\n\# $date\n";
foreach $deny_ip (@htaccess) {
print HTACCESS $deny_ip;
}
close(HTACCESS);
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Error</title>\n<META NAME=\"robots\" CONTENT=\"NOINDEX,NOFOLLOW\">\n";
print "</head>\n";
print "<body>\n";
print "<p><b>A fatal error has occured:</b></p>\n";
print "<p><b>Invalid Site HTML method...</b></p>\n";
print "<p><b>Please enable debugging in setup for more details.</b></p>\n";
print "<A HREF=\"http://www.imdb.com/harvest_me/\"> </A>\n";
print "</body>\n";
print "</html>\n";
exit;