TNG captcha

From Genwiki

Revision as of 22:27, 31 January 2007 by Admin (Talk | contribs)

Jump to: navigation, search

If you are not comfortable with html and php editing, this page may not be for you


Overview

This TNG modification provides a CAPTCHA for the TNG "New User Registration" form and/or the TNG "Suggest" form. It will provide a user challenge screen before the form will be made available.

This implementation is based upon PureMango's code version 1.41. Check the link for a demo of how it works. The original package from PureMango contains an additional php wrapper file that provides the demo example.

A TNG example of this implementation may be tested here - demo

Rev 3.8 Jan 20, 2007 - fix - fix 3.6a was not propagated to 3.7, this has been corrected. (only one file changed, TNG_captcha.php)
Rev 3.7 Nov 30, 2006 - update - removal of problem whitespace in alternate English text file, converted a couple of short_open_tags to the standard syntax. (improved portability)
Rev 3.6a Oct 26, 2006 - fix - correction to the TNG_captcha.php, there was a missing line.
Rev 3.6 Oct 22, 2006 - fix - correction to the TNG_captcha.php file for proper mail information after a suggest submission.


Requirements

  1. A working TNG installation - see The Next Generation of Genealogy Sitebuilding
  2. PHP Graphics support (GD library) http://ca.php.net/gd
    • to check your server; use TNG->admin->Setup&Configuration->PHP-info-Screen
    • look for a section that indicates "GD support enabled"
  3. A backup of your TNG files
    • newacctform.php
    • suggest.php
    • the text.php file for each of your supported languages (found in the language folders such as ./English or ./French)


Side Effects

  1. As with many modification to a TNG file, this modification may get lost during your next TNG version update and you will need to re-implement the mod. However, it is only a single line addition to each of the files.
    • TNG version 6.0 and later includes a "hook" for this captcha. If you install the current version of the captcha, there are no modifications to the TNG distribution files, and future TNG upgrades should not require any changes or re-implementation.
  2. The captcha graphics can be difficult to read for the visually impaired. Although a reload button has been included to allow users to request alternate graphics, they may not be able to gain access to your captcha protected forms.


TNG Installation Contents

The following zip file contains the necessary files to allow the addition of this feature.

  • The zip file TNG_captcha_Rev_3.8.zip contains:
    • the "freecap" fonts, backgrounds, dictionary, and freecap.php file
    • v5.1.4/newacctform.php - a modified TNG 5.1.4 file
    • v5.1.4/suggest.php - a modified TNG 5.1.4 file
    • TNG_captcha.php - the TNG captcha wrapper
    • captcha_text.php - one version for each of the supported languages (English, French, Spanish, Dutch, Portuguese, German)


Installation for TNG Version 6

  1. download this zip (TNG_captcha_Rev_3.8.zip)
  2. unzip it, examine the contents
  3. copy the "freecap" folder to the main TNG folder
    • make sure it is readable and executable by all
  4. verify that all the ".ht****" files and the freecap.php file are in the new "freecap" folder
    • ensure they are all readable
    • MAC users - please note that the .ht*** files are reported to be hidden files and may not be visible. The program "Transfer" has been recommended to assist with this.
  5. copy the applicable captcha_text.php files to your language folders.
    • for example, copy the /./English/captch_text.php to the ./English folder
  6. copy the TNG_captcha.php file to the base TNG folder
  7. check it out



Installation for TNG Version 5.1.4 (click here)

Installation for TNG pre - Version 5.1.4 (click here)

Customizations

The captcha provided in the original puremango package has been included as is. If you wish to experiment with some of the options, please review the freecap.php script in the freecap folder. It includes a description of the code, the possible options, and locations to find alternate fonts and suggestions on background image creation.


Customization - Embedded email address in Captcha page

If you would like to use the version which displays your email address (but hidden from robots), you may use the TNG_captcha.php file in the "Captcha with email address" folder. This file MUST be customized with your email address information. Follow these instructions:

  1. open the TNG_captcha.php file in the "Captcha with email address" folder
  2. if your email address is myname@mydomain.com then
    • edit the line xa="myname";
    • edit the line xs="mydomain.com";
    • edit the line xq="The Subject line for the email message";
  3. edit line 65 and change "My Name" to the name you would like displayed on the page
  4. close the file and copy it to the main TNG folder
  5. check it out


Pre TNG V6 - I'm still getting registration spam!

If you have successfully installed the captcha on the registration form, but are still receiving registration spam, read on. Your site may have been discovered by a spambot that already understands how our TNG sites operate, or one that is continuing to target your site because it has already learned how to spam your site before you installed your captcha. The following simple steps will defeat this learned spambot behaviour.

  • ensure you have a backup copy of your original TNG "addnewacct.php" file
  • rename the addnewacct.php file to something else (such as nospamnewacct.php) as follows:
    • find your local copy of the "addnewacct.php" file
    • copy it to the new name such as "nospamnewacct.php"
    • place the "nospamnewacct.php" file into your TNG main folder (probably using your ftp program)
    • do NOT leave a copy of "addnewacct.php" in your TNG folder (remove the file using your ftp program)
  • open your local copy of "newacctform.php" with your favourite editor (example: wordpad)
    • find the line "$formstr = getFORM( "addnewacct", "post", "form1", "" );"
    • change the "addnewacct" to the new name you chose for the file ("nospamnewacct", leave the .php off in this line)
    • save the changes
  • place the modified "newacctform.php" in your TNG main folder (probably using your ftp program)


Pre TNG V6 - I'm still getting suggest spam!

If you have successfully installed the captcha on the suggest form, but are still receiving suggest spam, read on. Your site may have been discovered by a spambot that already understands how our TNG sites operate, or one that is continuing to target your site because it has already learned how to spam your site before you installed your captcha. The following simple steps will defeat this learned spambot behaviour.

  • ensure you have a backup copy of your original TNG "suggest.php" file
  • rename the "tngsendmail.php" file to something else (such as "mytngsendmail.php") as follows:
    • find your local copy of the "tngsendmail.php" file
    • copy it to the new name such as "mytngsendmail.php"
    • place the "mytngsendmail.php" file into your TNG main folder (probably using your ftp program)
    • do NOT leave a copy of "tngsendmail.php" in your TNG folder (remove the file using your ftp program)
  • open your local copy of "suggest.php" with your favourite editor (example: wordpad)
    • find the line "$formstr = getFORM("tngsendmail", "POST\" onSubmit=\"return validateForm();", "suggest", "suggest" );"
    • change the "tngsendmail" to the new name you chose for the file ("mytngsendmail", leave the .php off in this line)
    • save the changes
  • place the modified "suggest.php" in your TNG main folder (probably using your ftp program)


I've installed the captcha, the text is ok, but my Graphic is not diplayed!

If everything seems to be setup correctly, but the graphic is missing, you may not have the required GD library support loaded with your server's PHP installation. You can verify that the GD library support is loaded by using the TNG->admin->Setup&Configuration->PHP-info_Screen. Search through this long screen to locate a line that indicates "GD support" enabled. If you can't find any mention of this library, then that's the likely problem.

Although this is a fairly standard module to have loaded, you may need to email your hosting company's support contact and request that they enable the GD support for your PHP.

If you are managing your own server, you'll need to add the support. Check http://ca.php.net/gd for assistance.


In the event of a problem with your version 5.1.4 TNG site

  1. copy your backup newacctform.php and/or suggest.php to your base TNG folder
  2. copy your language text.php files back to their language folders
  3. if you made the additional modifications, copy your backup "addnewacct.php" and/or your backup "tngsendmail.php" file to your base TNG folder as well
    • all should be well now
  4. you may also delete the "freecap" folder and files, TNG_captcha.php, and the captcha language support files


In the event of a problem with your version 6 TNG site

  1. delete the captcha_text.php file from all language folders
  2. delete the TNG_captcha.php file from the main TNG folder
  3. delete the "freecap" folder and contents
    • all should be well now


Support

  1. You're sort of on your own... If you have a specific question, or feel some additional info in the above would help others, feel free to contact me directly. Mail me here
    • Please post suggestions, or your own flavour of this mod to the forum or list


Acknowledgments

A big thanks goes out to all those TNG users in the TNGuser list that contributed to the discussion regarding the use of a Captcha in TNG

  • A special thanks goes out to
    • Francis Amar who provided the French and Spanish translations.
    • Martien van Balgooi who provided the Dutch translation.
    • Aguinaldo Valentin Fidelis who provided the Brazilian Portuguese translation.
    • Ian Singer who provided the alternate English text file.
    • John Lisle for providing the code to hide the email address from those pesky spambots and email harvesters.
    • Russell G. Strong who provided the German translation.
    • Henny Savenije who provided some minor code suggestions and suggestions for the installation repackage to connect with TNG version 6 more simply
  • Thanks to Darrin for suggesting to create a single line include version in preparation for TNG v6.
Personal tools