Page 1 of 2

Captcha Integration - How?

PostPosted: 12:07pm, Tue 13 Feb, 2007
by Antonimo
I searched "captcha" on these boards and looked through all the results, but I cannot find any message that can explain how to integrate "captcha" into phplist.

Has anybody managed it?

Can anybody explain how to do it?


Best regards,

PostPosted: 4:57pm, Tue 13 Feb, 2007
by H2B2
Haven't tried it, but you could take a look at this:
Adding Captcha functionality to the subscribe form -

Captcha is an anti spam method that requires the user to type the code on an image to subscribe.


PostPosted: 7:44pm, Tue 13 Feb, 2007
by Antonimo
Thanks H2B2,

That's where I downloaded the "hack" but I could not get it to work.

The admin section appeared on the Configure page, but editing the index.php caused the page to show up white.

The installation instruction for index.php is:
Code: Select all
1) In  index.php (not admin/index.php) :

Line 509 (in my script) if (!empty($data['button'])) {
    $data['button'] = $GLOBALS['strSubmit'];
Following :

//modified by r.adelli
   if(USE_CAPTCHA)include ("text/examples/CAPTCHA_form.php");

My index.php was different in that I did not have the "!" in the line
Code: Select all
if (!empty($data['button'])) {

I haven't managed to get it work.

Any ideas?

PostPosted: 9:55pm, Tue 13 Feb, 2007
by H2B2
Sorry, I haven't. Perhaps the problem is related to the Phplist version the captcha mod was meant for. You might add a note to the corresponding Mantis entry and hope the author will answer.

On the other hand Phplist 2.10.4 has a built in feature to neutralize most bot spamming attempts. See the release notes.

PostPosted: 10:16pm, Tue 13 Feb, 2007
by Dragonrider
I've had a play around and have had the same problem, possibly due to the fact that it was written with phplist 2.10.3 in mind, and we are now on 2.10.41

I hit the same issue, ie: no "!" in the line, which I believe negates the equation.

I have an alternative captcha code which I am playing around with and although I have managed to add it to the phplist code, the actual image does not appear and so far it does not work, but I'll keep plugging away at it as time permits.

Okay, so far I've managed to add a Captcha code block into phplist and get it to display. I'm having problems working out how and where to get it to validate it at the moment. I'll keep working at it!

PostPosted: 4:22pm, Wed 24 Oct, 2007
by clubwager
This post explains how I added captcha:

PostPosted: 8:43pm, Tue 27 May, 2008
by jsherk
Here's another alternative for preventing spammers from reaching your subscribe pages:

Re: Captcha Integration - How?

PostPosted: 5:42pm, Sun 30 Oct, 2011
by Ranma
Here's how I managed to have recaptcha integrated into phpList (v. 2.10.17)

First of all you need to obtain your recaptcha keys (private and public) by signing up a google account at

Soon after that you can follow these easy steps:

- within /lists/config/config.php add this line
Code: Select all

- within /list/index.php in the subscribeform form of the subscribepage section, after this line ..
Code: Select all
$html .= ListAttributes($attributes,$attributedata,$data["htmlchoice"],0,$data['emaildoubleentry']);

...insert this block of code (make sure to replace yourpublickeygoeshere with your own public key):
Code: Select all
  $html .= '<tr><td><script type="text/javascript" src=""></script>
<noscript><iframe src=" " height="300" width="500" frameborder="0"></iframe><br>
     <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
     <input type="hidden" name="recaptcha_response_field" value="manual_challenge"></noscript></td></tr>';

where the subscribePage($id) function begins, just below this line..
Code: Select all
  $html .= $data["intro"]; might also insert this block of code in order to customize the color of your captcha, among the available colors, just like this
Code: Select all
  $html .= '<script type="text/javascript">
 var RecaptchaOptions = {
    theme : "white"

Once this is done you can already see the recaptcha box in your subscribe page but we need a few more steps to make it work.

Since we are working on index.php page we can keep doing what else is missing in here by altering a bit the script checkform to check if the recaptcha_response_field input field is left empty, by adding this block of code:
Code: Select all
$html .='
  if(document.subscribeform.elements["recaptcha_response_field"].value == "") {
      alert("Please enter the recaptcha strings");
      return false;

...just above
Code: Select all
$html .='
  return true;

Now we can leave this file and move to /lists/admin/subscribelib2.php where just below the line...
Code: Select all
$randval = mt_rand();

...we can add this block of code (make sure to replace yourprivatekeygoeshere with your own private key)
Code: Select all
if (isset($_POST['recaptcha_response_field'])) {
    // reCAPTCHA verification
    $privatekey = "yourprivatekeygoeshere";
    $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
    #check if the recaptcha validation field is empty
    if (trim($_POST['recaptcha_response_field']) == "") {
        return false;
    else {
        if (!$resp->is_valid) {
            // when the CAPTCHA was entered incorrectly
            die ("The entered code does not match the provided one. Please go back and try again. " . "(reCAPTCHA said: " . $resp->error . ")");

...and that's all!

Re: Captcha Integration - How?

PostPosted: 2:55am, Mon 19 Dec, 2011
by RonFred
I really appreciate Ranma's How To install google's reCaptcha. Clean and simple as far as hacks go.

I would add two additional notes that I had to include to make Ranma's steps work for me:

1) There is one problem in Ranma's code insert - the step for adding the white theme background to the reCaptcha install. The entire step can be skipped, and the default "red" theme will be used. But to try out this option at the location Ranma suggests: It should have an end of script tag </script>, and an end of string tick ', at the end like this:

Code: Select all
$html .= '<script type="text/javascript">
var RecaptchaOptions = {
    theme : "white"
}; </script>';

More notes on the theme selection above:
These are the current theme options, "red" (default), "white", "blackglass", or "clean" ;
Details and sample images of the 4 themes are shown here:

2 - a) Don't forget to add the recaptcha PHP library code itself to your installation. During your request for keys from google's reCaptcha site, don't forget to download the free reCaptcha zipped code from here:

2 - b) Take the recaptchalib.php file from the downloaded zip and stick it into your phplist install directory - same location as your modified lists->index.php file location, based on the code suggested by Ranma, above.

Thanks again Ranma, without your description I would not have been able to thwart the spammer who was creating all the goofy email subscriptions on my site.

Best regards,

Ron Fredericks
Video Producer at LectureMaker LLC

Re: Captcha Integration - How?

PostPosted: 6:09am, Fri 22 Jun, 2012
by mvssysprog
I appreciate all of the work that Ranma and Ronfred did to get Captcha to work. I am very new to PHP and followed their directions exactly. Unfortunately, when I attempted to trigger the generic PHP subscribe panel, I still am not getting the Captcha fill-in to appear. I already had registered with Google to get my public and private keys. I am running PHPlist 2.10.17. Below you can see the default screen (customized using the PHPlist panels). What do I need to do in order to show Captcha on this panel?

thanks in advance for any assistance.


Re: Captcha Integration - How?

PostPosted: 6:36pm, Fri 22 Jun, 2012
by Dragonrider
This fix works with 2.10.18 as well, just remember to follow all the instructions in both posts, and do get your Google API numbers and the Google code recaptchalib file.

If anyone wants to have a look and make any suggestions, feel free! Test it outIf you want to enter your email fine, you will get an email confirmation to prove it works but it won't be added to ANY list as this install is just for test purposes.

Re: Captcha Integration - How?

PostPosted: 11:58pm, Thu 28 Jun, 2012
by mylinuxbox
In terms of spam prevention this is a great tool to use until phplist has its own built in captcha.

I found this very easy to install. I had this up and running in a matter of minutes.

i do have one problem though.

I have tested the recaptcha and when you enter the wrong challenge you are directed to a one line response telling you that the data was entered wrong. I can see from Ranmas post above where it gets the line from.

I have spent a lot of time making sure the site has a uniform look through error pages, thank yous, subscriber pages etc, and then there is this one page I cannot figure out. I am no good with php.

Can anyone advise how it is possible to direct the user back to the subscribe page so they can complete a new challenge without having to re-enter their data, or have the error page look like the rest of my site?


Re: Captcha Integration - How?

PostPosted: 9:11pm, Fri 22 Feb, 2013
by AlanGeorge
Just in case anyone is looking for a self-contained captcha that can be toggled off and on from within the config.php file as with other phpList features and does not require you to sign up for a third party account in order to obtain recaptcha keys (private and public) then...... follow the link below....

This has been working since 2.10.17....



Re: Captcha Integration - How?

PostPosted: 7:55pm, Mon 25 Mar, 2013
by chrison
Hi, Alan:

AlanGeorge wrote:This has been working since 2.10.17....

I'm obviously doing something wrong! I followed the instructions to the letter, but all I get is "capture image" instead of the actual captcha image on my web page. I have checked my changes (twice!) and all appears to be okay.

Any suggestions on how I can get it to work?




Re: Captcha Integration - How?

PostPosted: 9:10pm, Mon 25 Mar, 2013
by AlanGeorge
Hi Chris

can you either pm me with a link to the subscribe page you are working on or use the contact page on my website...


Thanks for highlighting this.... my notes for the install need to be adjusted. As I use the same captcha on my sites contact page the captchacode.php and ttf files are in the folder below lists i.e. in and not

Copy the two files there and let me know.... another alternative to this would be to add captchacode.php to the .htaccess file in the lists folder....