[plugin] Captcha for subscription forms

3rd party code for phpList

[plugin] Captcha for subscription forms

Postby duncanc » 9:23pm, Mon 23 Jun, 2014

This plugin provides a CAPTCHA field on the phplist subscription forms using the Securimage package. The aim is to stop automatic subscriptions by "bots" through ensuring that only a real person is subscribing. The subscriber must be able to read the distorted characters within the image.

captcha.png
captcha.png (11.23 KiB) Viewed 6491 times

The plugin is available on GitHub, see https://github.com/bramley/phplist-plugin-captcha for how to install and use the plugin.
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: [plugin] Captcha for subscription forms

Postby danwaterloo » 12:13pm, Thu 26 Jun, 2014

Hi Duncan,

THANK YOU! I've used it already.

Dan
danwaterloo
PL Master
 
Posts: 276
Joined: 3:51am, Wed 30 Oct, 2013
Location: http://www.phplistsupport.com

Re: [plugin] Captcha for subscription forms

Postby Dragonrider » 8:02am, Sun 29 Jun, 2014

I'll second that! What a great and very useful not to mention pretty simple to implement plugin!
Thanks Duncan.

One little tip I'd like to share is that if you have a number of phpList installations on a server/website, for different websites, all hosted on the same server, just upload the secureimage directory to the root directory and all your phpList installs can use it without altering any setting on your phpList admin settings pages. Thus needing just the one copy of secureimage directory instead of one for each.

I've come across a little snag, nothing to do with the above tip and that's shown on the image below, look at the last two plugin titles.

captcha.jpg
captcha.jpg (40.98 KiB) Viewed 6364 times


Neither actually link to the dashboard or the hello world plugin. Any thoughts please Duncan? Or is it just me?
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

Re: [plugin] Captcha for subscription forms

Postby duncanc » 9:08am, Sun 29 Jun, 2014

I don't look at the dashboard page so had not noticed that. If you update the plugin now then those entries will not appear.
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: [plugin] Captcha for subscription forms

Postby Dragonrider » 10:32am, Sun 29 Jun, 2014

Many thanks Duncan! You're a gentleman.
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

Re: [plugin] Captcha for subscription forms

Postby tvdeyen » 5:13pm, Tue 09 Sep, 2014

Hi Duncan,

i'm using phplist 3.0.8 and can't make the CAPTCHA plugin work. When I type the text showed in the CAPTCHA image and I submit it, I get an message saying that it not correct. If I use the example_form.php in the securimage installation, the CAPTCHA code works fine, but when it runs from a subscription page in the phplist installation, it doesn't work.

I have tried to do some simple debuging of the code and it seems that the $_SESSION['securimage_code_value'] etc. (info about the securimage image) is not set after submission in the subscription from.
What seems to be the issue? Is it some session issue in phplist?

best regards,

Torben.
tvdeyen
phpList newbie
 
Posts: 3
Joined: 4:49pm, Tue 09 Sep, 2014

Re: [plugin] Captcha for subscription forms

Postby duncanc » 10:34am, Wed 10 Sep, 2014

On my phplist release 3.0.8 the captcha works.

If I add this a line to the start of method validateSubscriptionPage() in file CaptchaPlugin.php
Code: Select all
    public function validateSubscriptionPage($pageData)
    {
        echo htmlspecialchars(print_r($_SESSION, true));
        if (!isset($_POST['email'])) {


the results include these values
Code: Select all
    [securimage_code_disp] => Array
        (
            [default] => B2eb4A
        )

    [securimage_code_value] => Array
        (
            [default] => b2eb4a
        )

    [securimage_code_ctime] => Array
        (
            [default] => 1410341699
        )

Have you installed any other plugins or made any changes to the phplist code?
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: [plugin] Captcha for subscription forms

Postby tvdeyen » 12:00pm, Wed 10 Sep, 2014

Did a fresh install of phplist 3.0.8 (using Installatron from cpanel at my webhotel) and installed the CAPTCHA plugin (this and fckphplist is the only plugins). I also uploaded a fresh securimage folder to the server (VERSION: 3.5.4).

The issue is still there :S

The subscription page is here http://www.bkv.dk/lists/?p=subscribe&id=1
(added your code 'echo htmlspecialchars(print_r($_SESSION, true));' to the validateSubscriptionPage() function)

could it be some php settings, that is not correct?
tvdeyen
phpList newbie
 
Posts: 3
Joined: 4:49pm, Tue 09 Sep, 2014

Re: [plugin] Captcha for subscription forms

Postby duncanc » 12:52pm, Wed 10 Sep, 2014

The securimage documentation https://www.phpcaptcha.org/documentation/quickstart-guide/ has this warning
On the very first line of the form processor, add the following code:
1 <?php session_start(); ?>
It is important to put this at the top of the file before any HTML output, otherwise the validation may always fail.

Not sure why it should be a problem for you, but can you add a line to the beginning of lists/index.php. phplist starts the session at line 59 but doing it earlier seems to work for me.
Code: Select all
<?php
session_start();
ob_start();
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: [plugin] Captcha for subscription forms

Postby tvdeyen » 2:18pm, Wed 10 Sep, 2014

got it to work now :-)

what i did was what you suggested, adding the session_start(); to index.php. This unfortunately didn't work, so I read some of the comments on phpcaptcha quick-guide page you sent, and in https://www.phpcaptcha.org/documentation/quickstart-guide/#comment-3012 it describes a problem like mine and a solution by modifying the php.ini.
I know from my webhotel that to add a customized php.ini to the folder of your site, you need to add this to the top of the .htaccess of you site (in mycase it is /home/<my username>/public_html/lists) :
Code: Select all
<IfModule mod_suphp.c>
  suPHP_ConfigPath /home/<my username>/public_html/lists
          <Files php.ini>
                    order allow,deny
                    deny from all
          </Files>
</IfModule>

I then added a php.ini file to /home/<my username>/public_html/lists and added this to my php.ini:
Code: Select all
session.save_path = "/tmp"
session.cookie_path = "/"
session.use_cookies = 1

So now it works :-)

Thank you for your reply and solution
tvdeyen
phpList newbie
 
Posts: 3
Joined: 4:49pm, Tue 09 Sep, 2014

Re: [plugin] Captcha for subscription forms

Postby SteveK » 6:24pm, Sat 25 Oct, 2014

I recently became aware of the Captcha plugin for phpList. I installed it, after first installing the SecurImage package per the documentation. I then enabled the Captcha plugin on the plugin page, and checked that all the settings seemed OK on the settings page. However when I test the form, there is no Captcha image. Is there an additional step required for this to work? I assumed (maybe wrongly so) that the forms would automatically include the Captcha image.

Thanks,
SteveK
phpLister
 
Posts: 10
Joined: 7:48pm, Fri 24 Oct, 2014
Location: Boston

Re: [plugin] Captcha for subscription forms

Postby duncanc » 10:01am, Sun 26 Oct, 2014

The only setting that you might have wrong is the path to securimage. Where have you installed securimage and what value do you have on the Settings page for "Path to the securimage directory (from the web root)"?
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: [plugin] Captcha for subscription forms

Postby SteveK » 3:23pm, Sun 26 Oct, 2014

I've installed the securimage folder in my root directory /securimage, and have the same value on the settings page. I just verified this again to make sure.
SteveK
phpLister
 
Posts: 10
Joined: 7:48pm, Fri 24 Oct, 2014
Location: Boston

Re: [plugin] Captcha for subscription forms

Postby duncanc » 6:05pm, Sun 26 Oct, 2014

By "root directory" you mean the web root directory not the file system root directory?

I have modified the plugin to log an event when the securimage file cannot be found. if you update the plugin on the Manage Plugins page, then go to your subscribe page again. There should then be an entry on the event log page showing the full path of the file that cannot be found.
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: [plugin] Captcha for subscription forms

Postby SteveK » 7:26pm, Sun 26 Oct, 2014

Thanks so much for your help Duncan. :D

It was my fault. I didn't understand the terms dealing with "root" (although I don't know how you could have described it any better then you've done). The error log you put in really helped me out. The securimage file was installed in /home3/skon/. I moved it to /home3/skon/public_html/ and and now it works fine.

Many thanks, Steve
SteveK
phpLister
 
Posts: 10
Joined: 7:48pm, Fri 24 Oct, 2014
Location: Boston

Next

Return to Contributions: Plug-ins, Add-ons, Mods

Who is online

Users browsing this forum: No registered users and 1 guest