Captcha Integration - How?

Solutions for other advanced phplisters

Captcha Integration - How?

Postby Antonimo » 12:07pm, Tue 13 Feb, 2007

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?

Please.

Best regards,
Antonimo
PL Geek
 
Posts: 53
Joined: 10:53am, Tue 13 Feb, 2007

Postby H2B2 » 4:57pm, Tue 13 Feb, 2007

Haven't tried it, but you could take a look at this:
Adding Captcha functionality to the subscribe form - http://mantis.phplist.com/view.php?id=8826

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

Source: http://docs.phplist.com/PhplistHacks
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby Antonimo » 7:44pm, Tue 13 Feb, 2007

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?
Antonimo
PL Geek
 
Posts: 53
Joined: 10:53am, Tue 13 Feb, 2007

Postby H2B2 » 9:55pm, Tue 13 Feb, 2007

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.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby Dragonrider » 10:16pm, Tue 13 Feb, 2007

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!
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.8 (10 September 2014) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3178
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

Postby clubwager » 4:22pm, Wed 24 Oct, 2007

This post explains how I added captcha: http://forums.phplist.com/viewtopic.php?p=38047#38047
clubwager
PL Nut
 
Posts: 30
Joined: 9:40pm, Mon 09 May, 2005

Postby jsherk » 8:43pm, Tue 27 May, 2008

Here's another alternative for preventing spammers from reaching your subscribe pages:
http://forums.phplist.com/viewtopic.php?t=18290
jsherk
PL Geek
 
Posts: 101
Joined: 11:37pm, Mon 28 May, 2007

Re: Captcha Integration - How?

Postby Ranma » 5:42pm, Sun 30 Oct, 2011

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 http://www.google.com/recaptcha.

Soon after that you can follow these easy steps:

- within /lists/config/config.php add this line
Code: Select all
define("USE_CAPTCHA",true);


- 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
if(USE_CAPTCHA) {
  $html .= '<tr><td><script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=yourpublickeygoeshere"></script>
<noscript><iframe src="http://www.google.com/recaptcha/api/noscript?k=yourpublickeygoeshere " 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"];

...you 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
    require_once('recaptchalib.php');
    $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!
:wink:
Ranma
phpLister
 
Posts: 7
Joined: 11:44am, Mon 17 Oct, 2011

Re: Captcha Integration - How?

Postby RonFred » 2:55am, Mon 19 Dec, 2011

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:
http://code.google.com/apis/recaptcha/docs/customization.html

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:
http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest

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
RonFred
phpLister
 
Posts: 14
Joined: 7:23pm, Thu 27 Apr, 2006
Location: Sunnyvale, CA USA

Re: Captcha Integration - How?

Postby mvssysprog » 6:09am, Fri 22 Jun, 2012

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.

Dave
Attachments
phplist screen.png
phplist screen.png (50.49 KiB) Viewed 14015 times
mvssysprog
phpList newbie
 
Posts: 2
Joined: 5:42am, Fri 22 Jun, 2012

Re: Captcha Integration - How?

Postby Dragonrider » 6:36pm, Fri 22 Jun, 2012

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.
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.8 (10 September 2014) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3178
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

Re: Captcha Integration - How?

Postby mylinuxbox » 11:58pm, Thu 28 Jun, 2012

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?

Cheers.
mylinuxbox
phpLister
 
Posts: 5
Joined: 4:09pm, Thu 28 Jun, 2012

Re: Captcha Integration - How?

Postby AlanGeorge » 9:11pm, Fri 22 Feb, 2013

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....

http://www.alangeorge-photography.com/listCode_005.php

This has been working since 2.10.17....

regards

Alan
AlanGeorge
PL Geek
 
Posts: 93
Joined: 7:14pm, Tue 28 Feb, 2012

Re: Captcha Integration - How?

Postby chrison » 7:55pm, Mon 25 Mar, 2013

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?

Thanks!

Regards,

Chris
chrison
phpList newbie
 
Posts: 2
Joined: 7:51pm, Mon 25 Mar, 2013

Re: Captcha Integration - How?

Postby AlanGeorge » 9:10pm, Mon 25 Mar, 2013

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...

Update....

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
www.mydomain.com/ and not www.mydomain.com/lists/

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....

regards

Alan
AlanGeorge
PL Geek
 
Posts: 93
Joined: 7:14pm, Tue 28 Feb, 2012

Next

Return to Advanced Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest