Anti-Spam Guestbook - Setup Guide


Anit-Spam Guestbook Script
Version 1.2
COPYRIGHT @ 2005 by Aubrey Millard

How to set up the Script      Variables

This script was created with the novice user in mind. If you use most of the defaults then you can configure this script in just a few minutes. The script and the way it displays is highly configurable, so it can be very unique if you want to play with the different formats. We will go into more detail as we go along. First we will look at getting the script running. After that we will get into the customization.

BEFORE you start to try to set up this script make sure you know the following things.
1. The location of PERL on your server ie. /usr/bin/perl or C:/perl/bin/perl.exe
2. the PATH to your website ie. /www/usr/myprofile/
3. The web address for the guestbook ie. http://www.somedomain.com/~mysite/guestbook.html
4. The PATH to where you will want to store the logs and filter files ie. /www/cgi-bin/mylogs/

Also
If you want to use the email options with this script you will need to know...
1. The mail program and it's location ie(Linux) /cgi-bin/sendmail or (Windows) C:/www/cgi-bin/blat.exe
2. Your email login information username/password (you can get this from your email client)
3. Your email server address and port. Again you can get this from your email client

OK, if you know or have handy the above information let's jump in.
I assume that you have the script downloaded and unzipped on your computer somewhere.
(If not go to the Downloads section and get it now)
In Notepad open up the file called asgb.pl. This is the script file that does all the work. BE VERY CAREFUL when editing this file!!!! If you accidently delete something as simple as a "; " it could cause the script to fail.

So now we have the script open in Notepad, here is what we should see.

#!C:/perl/bin/perl.exe
$|=1; 
# Anti Spam Guestbook
# Version 1.0  14/03/05
# (C) 2005 by Aubrey Millard aubrey@bushido.org
#
# This script is freeware and may be used and abused by you.
# (just leave me some credit).

This is the headder of the file. Anything with a # in front of it is just a comment and doesn't actually do (with some exceptions) anything but provide you the reader with some information. The code is heavily commented so feel free to browse through the script to see how PERL works....Just not right now, we have a script to set up!

The first line is VERY important.

#!/usr/bin/perl 

This tells the script where to find the PERL executable. This is the line that can cause some users some real headaches. The #! must be there with NO spaces at the beginning!!

#!C:/perl/bin/perl.exe <== OK
  #!C:/perl/bin/perl.exe <==NOT OK, has a space at the beginning

Ok, so lets go ahead and fill in the PERL path (Dont guess! Not every server is set up the same.)
Some examples:
#!C:/perl/bin/perl.exe <==Windows
#!/usr/bin/perl <== Linuix/Unix


Now we get to some of the variables that we have to set in order for the script to function properly.

set $HTML="NO" if you do not want users to be able to enter HTML tags
$HTML="YES";

Some spammers are getting wise to filters so they are opting to use images to clog your guestbook with. If you set $ALLOWIMAGES="NO" it will strip any image <IMG> tags from the entry.
$ALLOWIMAGES="NO";

$REDIRECT is the internet address of the page you would like the user to go to once the have hit the SUBMIT button. Most people just redirect the person back to the guestbook but you could use a Thank You page or whatever.
ie. http://www.myhomepage.com/guestbook.html
$REDIRECT="http://www.myhomepage.com/guestbook.html";

$GUESTBOOK is the file name for your guestbook file. You must give the filename including it's full path. ie www/users/myprofile/guestbook.html
$GUESTBOOK="/www/users/foo/guestbook.html";

#####################################################################
#                   EMAIL SECTION
# If you are on a windows based server you will have to configure
# the email settings a little differently. A linux/unix system is
# a little easier.
# BE SURE THE MAIL PROGRAM IS SET CORRECTLY BEFORE SETTING "YES" TO
# $SEND_THANKS or TELL_ME!
###################################################################
$SEND_THANKS if "YES" will send the signer of the book a thank you note if they supplied a valid e-mail address. E-mail is sent to the value contained in "email" $SEND_THANKS="NO"; $MY_EMAIL should be your e-mail address. This way people know where they get the thank you note from. Be sure to put that \@ backslash before the AT sign! $MY_EMAIL="me\@somedomain.ca"; If you make $TELL_ME="YES" and supplied a value for $MY_EMAIL, the script will notify you when somebody has signed your book. $TELL_ME="YES"; $MAILPROGRAM is your system's e-mail program typically either /usr/lib/sendmail -t or /usr/sbin/sendmail -t DON'T FORGET THE "-t", omitting it is a major source of script failure. For Windows 95/98/NT using BLAT.EXE, it might look like this: $MAILPROGRAM="C:/winnt/system32/blat.exe"; If you have access to BLAT.EXE but dont have the access to modify it, Make sure you fill in all the fields below. If you are not sure of the settings you can get the information from your email program. $MAILPROGRAM="blat.exe"; If you are using BLAT.EXE then set this to YES. If you are going to use sendmail then set it to NO. $USEBLAT="YES"; Enter your email address here. This is the email address for the account that use the login and password below. It can be the same as the $MY_EMAIL. $FROM="foo\@bar.ca"; Your email server and port (normally 25) $SERVER="smtp.somdomain.ca"; $PORT="25"; Your email login name and password. $USERNAME="foobar"; $PWD="password"; $TEMPDIR is a directory on your server where you have permission to write files that will be deleted when the script finishes running. ie. /cgi-bin/temp/ or /tmp/ if it is the same directory where the script is then leave it blank. $TEMPDIR="/tmp"; MISC VARIABLES $MYDOMAIN contains your domain. ie. somedomain.com or www.somedomain.com it is used to check the link that calls this script. If the link is not in this domnain then the script will not run. Prevents someone else from running your guestbook from thier webpage. $MYDOMAIN="mydomain.ca"; Required fields. enter the fields here that must not be blank when the user submits the entry. Each field name must be separated by a comma and surrounded by quotes. There MUST be atleast one field name. Available filed names are: "name","email","city","country","url","message" @REQUIRED=("name","message"); ################################################################################ # ANTI SPAM CONFIGURATION # The following items should be set in order to use the ANTI-SPAM # features of this script. # If the log files,word filter and ban files will be in the same directory as # the script then you do not need to specify the path, only the filename. ################################################################################ $MASKEMAIL="YES" will replace the . and @ signs in the address to fool most email spiders. Less spam email is a good thing :) $MASKEMAIL="YES"; @ sign replacement if MASKEMAIL set to YES. (can be an image, © &copy; or "AT" or whatever) $ATSIGN="<img src=\"http://www.mydomain.ca/foo/at.jpg\" width=10 height=9>"; . replacement in email addresses if MASKEMAIL set to YES. (can be an image, &middot; or "DoT" or whatever) $DOT="&middot;"; Set "YES" to use word filter. This is a textfile that contains words that you do not want to allow people to post. See the README file for more info on setting up a word filter list. $FILTER="YES"; File path for filtered words file. $WORDFILE="filter.txt"; Use Bans, will permanently ban the offending ip address. If they try to post anything on the guestbook after being banned they will automatically be redirected to a different page and nothing will be written to the guestbook. $USEBANS="YES"; Ban List text file for storing banned IP addresses. $BANLIST="banlist.txt"; Name and location of the Ban Log. This will contain the IP, email,URL and the flagged content. $BANLOG="asgbbans.txt"; Maximum number of Ban log entries. Dont use a high number here. Some spammers try to spam guestbooks with thousands of links. This could cause the banlog to get big quick! 25-100 entries should be enough. $MAXENTRIES=50; Maximum length of Guestbook message (number of characters) Set to 0 for unlimited (not recommended) Since people generally leave short messages on guestbooks, if you get a submission that is a few thousand characters long chances are they are spamming. Most people can say what they want in 1000 characters or less. $MAXLENGTH=800; Log errors. set to 1 to log errors or 0 to not write log. useful to help you debug the script. $LOGERROR=1; Error log file path and filename $ERRLOG="aserrlog.txt";
Thats pretty much it for setting up the script. If you made it this far....well way to go!
Now all you have to do is set up the 2 HTML pages for your guestbook.
See the HTML Setup page for help with editing those. It's a lot easier than this was :-)


Back to Help   ||   Next Messages