#!/usr/bin/perl
# AntiSpamBot.pl -- V1.0 7/2003 -- www.sugarscript.com/antispam
# Anti spam bot script. Converts html "mailto" and email address hotlinks to JavaScript,
# so that spambots can't gather email addresses from your website. Goes through each
# directory recursively and changes emails within .htm .html .php and .dwt (Dreamweaver template) files.
# (try it on a test directory first).
#
# Note: Use www.sugarscript.com/antispam to create online email addresses, one at a time.
#
# ******** Please let me know of any problems with this script: jodybrabec{{at}}gmail.com *********
# Disclaimer: Use at own risk.
# An email address of the form Webmanager will be converted to:
#
# Webmanager
#
# An email address of the form iceMan21@aol.com will be converted to:
#
# For some reason, STDIN needs to be near the top, or else when running this program you need to hit RETURN twice followed by CTRL+D
print "Enter the root directory (include trailing slash): ";
chomp ($dirRoot = );
# Log file to record just the names of each file that was changed.
open (BULOG, ">>~jbrabec/antispam.log");
# Let the server know what we are sending back
# print "Content-type: text/html\n\n";
local $/; # slurp - this reads entire file into $_
use File::Find;
# Recursively goes through each directory
find (\&ChangePath, "$dirRoot");
sub ChangePath {
#Get current directory name
#my $curdir = $File::Find::dir;
#Get full pathname of curdir and file
my $full = $File::Find::name;
#If the current name is a directory
if (-d $full) {
;
}else{ # Not a directory
if ( -f and (/\.html?$/ || /\.php$/ || /\.dwt$/) ) {
$total = "";
$changed = 0;
open (HTMLFILE, "$full");
while (){
# this is to scramble emails of the form:
# blabla@gmail.com.com
# Note: You can take out my url (www.sugarscript.com/antispam) but I would like to become famous some day.
if (s/]+)\@([^\">]+)\"\s*>\s*([^<\@\"\n]{1,45})\@([^<\"\n]{0,70}?)\s*<\/a>/