Captcha Plug in Modification for PhpList Form Integration

Posted: November 30, 2013 in General, Information Technology, Wordpress
Tags: , ,

power-phplistThanks to Jesse Heap for making a plug in for PHPLIST.  I found some code from GNU , and was able to modify the plug in to accept the Captcha in the form.  This is a mod to Jesse’s PHPList Form Integration.


PhpLIST is a open source ListServ program that runs on PHP Web platform.  I found CaptchaCode mod  by Alan Fairhall.   However, I needed the Captcha for the Plug in Widget used on WordPress by Jesse Heap.   So, using the CaptchaCode PHP, we are able to accomplish adding Captcha to the Widget.  Here’s how.


1) Download the CaptchaCode mod by Alan Fairhall on the PHPList sites.  His notes in the file show this location:

2)  Before you upload, we need to make one minor change in the php file with the text editor.  Open CaptchaCode.php and locate $Font= Line and change it to simply state:  $font = ‘/monofont.ttf’;     Save the file.

3)  Next, upload the captchacode.php, monofont.ttf from Alan’s mod to the root directory of your blog site.

4) Open WordPress, using the Editor function on the dashboard, you want to navigate an edit the phplist.php file for the form.  (Or you can FTP the files and edit, and FTP back).

5) Locate this section in the file:

if( phplist_is_malicious($email)) {
$ok = false; $reason = ‘malicious’;

Just below that } add this section:

//  Captcha Mod  WRM

if(empty($_SESSION[‘capture_codex’] ) ||
strcasecmp($_SESSION[‘capture_codex’], $_POST[‘capture_codex’]) != 0)
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()
//$errors .= “\n The captcha code does not match!”;
$missing = $GLOBALS[“strCaptchaNoMatch”];
$ok = false; $reason = ‘captcha’;

//End Captcha Mod

6.   Scroll down the file and locate this section.

elseif($reason == ‘No Mailing List’) {
$phplist_strings[‘error’] = ‘<label for=”Error”></label><div class=”errored”>’ . __(‘You Must Check a Mailing List’,’phplist’) . ‘</div>’;


Just before the Return False statement, and just below the }, insert this block below:

elseif($reason == ‘captcha’) {
$phplist_strings[‘error’] = ‘<label for=”Error”></label><div class=”errored”>’ . __(‘The captcha code does not match!’,’phplist’) . ‘</div>’;

The very next line should be the Return False statement.

7.  Save the File.  Ftp it back

8.  Now, this next step is the trickiest part of the entire process.  You need a Head Meta, Script added for each page that will use this.  So, what I did is added this script using the HEAD or META Tag section of my theme.  Typically, if you have experience adding a google adsense code, yahoo code in the Head section, this is easy for you.

You need this script tag in the HEAD section.

<script language=”JavaScript” type=”text/javascript”>
function refreshCaptcha()
var img = document.images[“captchaimg”];
img.src = img.src.substring(0,img.src.lastIndexOf(“?”))+”?rand=”+Math.random()*1000;

9.   Save.  Now Test your PHPLIST FORM in WordPress, a Captcha should appear.

If you see the Captcha and no image, then check  Step 2 again and make sure the ttf file is present in the root directory of your blog web site.   Usually, under Public_Html.  The captchacode.php and the ttf file reside here.

If you still dont see the image and you dont have the ability to cycle through clicking the refresh text, then Step 8 is still an issue for you. You need that function in the page up in the head section where the meta tags reside.

  1. William says:

    Someone had asked about customizing the size and features of the Captcha in the form. While the captchacode.php file does not support css, you do have the ability to set some settings in the file. Such as Size and color. It’s at the very top of the file. Open with the editor and look for the size and color settings. You can also change the complexity of the Captcha with the dots and lines setting.
    (The Captchacode.php file is Edited and look for these lines)

    //Settings: You can customize the captcha here
    $image_width = 120;
    $image_height = 40;

    //The characters that can be used in the CAPTCHA code.
    //avoid confusing characters (l 1 and i for example)
    $possible_letters = ‘23456789bcdfghjkmnpqrstvwxyz’;
    $random_dots = 0;
    $random_lines = 20;
    $captcha_noice_color = “0x142864”;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s