FirstProductions Human Test, a CGI script written in the Perl language, is based on the ideas of The CAPTCHA Project. It generates distored text that most humans can read, but computers cannot to prevent automated robots from submitting forms. Software similar to this is starting to become widely used throughout the Internet, and is currently in place on major websites such as Yahoo! to prevent automated sign-ups.
FirstProductions Human Test
Copyright © 2003, First Productions, Inc.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Visit our website at: http://www.firstproductions.com/cgi/human/
Email us at: cgi@firstproductions.com
Before you can use FirstProductions Human Test, be sure that your web site passes the minimum requirements:
First, you will need to uncompress the software package using WinZip or similar unzipping software. You should have a directory tree similar to this:
CGI (directory)
|__captcha.pl
|__captchatest.cgi
DATA (directory)
|__codes.txt
|__images (directory)
|__(various PNG files)
First open captchatest.cgi (the example script) in main CGI directory. Be sure that the first line of the script matches the path to Perl for your server. The path to Perl is usually similar to: /usr/bin/perl or /usr/local/bin/perl. Be sure not to remove the #! before the path to Perl. If you are unsure of the path to Perl, contact your server administrator.
Next, open captcha.pl in a text editor. This is the Human Test library used by the example script. You can also use this library in your own scripts for easy access to the Human Test functions (generateCode and checkCode). Here is a guide to configuring the options in the Settings section:
After configuring the script, create a folder in your "cgi-bin" for the files in the CGI directory. Upload the files in the CGI directory to your new folder on your web server in ASCII mode. Make the captchatest.cgi file executable by CHMODing it as 755. Next, create the web-accessible folder you configured captcha_webfolder, and give it appropriate permissions so the script will be able to write files to it. Then, create the captcha_datafolder you specified in the configuration section outside of your web-accessible folders. Give it write permissions and upload the files in the DATA directory to this folder. Give the codes.txt database write permissions.
Now that you have uploaded the files, it is time to see if it worked. In a web browser, navigate to the URL of the example script (captchatest.cgi). If there is an error, see the troubleshooting section of the documentation. If it works, go on to the Usage section.
There are two functions that you can call in captcha.pl - generateCode and checkCode. The example script demonstrates how to use these two functions. Here is an explanation of the functions.
generateCode($length) will generate a random sequence of letters and numbers of the specified length. It will then encrypt the sequence using md5. The md5 crypt is what the function returns. The function also outputs a PNG image of the code sequence to the output folder. The md5 crypt is the filename without the .png suffix. The function will add the md5 crypt to the database in the data folder with a timestamp, and expire old codes from the database. If a crypt is not returned, then a file error occured.
checkCode($code,$crypt) will check a code against the md5 crypt and code database. There are several possible values that can be returned:
1 : Passed - the entered sequence is correct and the crypt is valid and was found in the database.
0 : Code not checked - a file error occured.
-1 : Failed: code expired - the code was found in the database but it was expired.
-2 : Failed: invalid code (not in database) - the code was not found in the database either because it expired, was already used, or it is invalid.
-3 : Failed: invalid code (code does not match crypt) - the entered sequence is incorrect and the crypt has been removed from the database.
For more information about using these functions, please refer to the example script included with this package.
Updated - we have just released an extensive tutorial showing how to integrate the Human Test library into an existing script. To read it, please go to the FormMail Example on our website.
500 Internal Server
Error
Possible causes of a 500 Internal Server Error:
The path to Perl in line one of the captchatest.cgi
file is incorrect. Contact your server administrator on consult
your server's documentation to find out your path to Perl.
Files were not uploaded in ASCII mode. Transfer the files
to your server again in ASCII mode.
The permissions of captchatest.cgi were not set
to executable. Set the permissions of captchatest.cgi to
executable (CHMOD 755).
The captcha.pl file was not found. If you renamed
captcha.pl, name it back to captcha.pl.
404 File Not Found
Check the URL that you used to access captchatest.cgi
and try again.
403 Forbidden
The permissions for captchatest.cgi were not set to
executable (CHMOD 755).
Broken Image
If the example script displays a broken image, check the captcha_outputfolder
and captcha_webfolder settings in the
configuration section.
"Code not
checked/generated (file error)"
Check the settings in the configuration section to be sure that
they point to the correct folders, files, and paths.
FormMail Example (Released 6/29/2003):
Version 1.0 (Released 6/19/2003):
Check our web site: http://www.firstproductions.com/cgi/human/ for the latest information. Post ideas for new features and changes to our Support Forum. Current plans for future versions include additional distortion and image generation methods.
Copyright 2003, First Productions, Inc.