Adding a challenge question to the Registration page

· 7 · 921
*

Sue

  • ***
  • Posts: 128
Adding a challenge question to the Registration page
« on: November 23, 2017, 11:50:43 pm »
Although BadBehaviour and Captcha are activated, I'm getting hammered with dental spam (how come I can't read the Captcha but the bots have no problem?). Anyway...

I also maintain a phpBB forum and registrations were also being spammed and the spam was stopped absolutely dead by adding a challenge question (not one spam account in the last two years, at least).

Has anyone successfully added a challenge question and if so, can you share your code?

thanks!

*

Sue

  • ***
  • Posts: 128
Re: Adding a challenge question to the Registration page
« Reply #1 on: December 03, 2017, 12:58:34 am »
Still getting spam. Interestingly (or not), I got 15 membership profiles created all from the one IP address (46.29.19.49) which another anti-spam site lists as a "forum spammer" site in Poland.

I'm considering adding a "honey pot" question to the registration form. I'm just investigating now.

Edited: Investigated but way beyond my meagre programming skills. Oh well.
« Last Edit: December 03, 2017, 02:00:42 am by Sue »

*

LD-MTT

  • **
  • Posts: 37
    • MoreThanThat
Re: Adding a challenge question to the Registration page
« Reply #2 on: December 04, 2017, 02:37:03 am »
A fellow "tech lady" at another archive helped me set up a spam test question, so far it's been doing the trick (fingers crossed)

The two files modified are user/editbio.php and languages/en.php. Probably a good idea to install and test this out on a test archive first, and definitely a good idea to back up editbio.php before starting.

First order of business is coming up with your spam test question, something any fan of your fandom knows but a spammer can't find easily.

Step 1:
Open user/editbio.php and find the following line near the end (around line 207 if this file has no other modifications)
Code: [Select]
if(!empty($captcha) && $action == "register") $output .= "<div><label for='userdigit'>"._CAPTCHANOTE."</label><input MAXLENGTH=5 SIZE=5 name=\"userdigit\" type=\"text\" value=\"\"><div style='text-align: center;'><img width=120 height=30 src=\""._BASEDIR."includes/button.php\" style=\"border: 1px solid #111;\"></div></div>";

right above this line add the following:
Code: [Select]
if(!isMEMBER && $action = "register"){
         $output .= "<div><label for='spamcheck' style=\"margin-top: 2ex;\"><b>Spam test:</b>Your spam question goes here:</label> <INPUT name=\"spamcheck\" class=\"textbox\" value=\"\" type=\"spamcheck\" style=\"margin-top: 2ex;\">".($action == "register" ? "<font color=\"red\">*</font>" : "")."</div>";}

Made sure to replace "Your spam question goes here" with your question.

Step 2:
Now up towards the start of editbio.php and find this line (around line 63):
Code: [Select]
if($captcha && !captcha_confirm()) $output .= write_error(_CAPTCHAFAIL);

right after this line add the following
Code: [Select]
        else if (!isset($_POST[ 'spamcheck' ]) || empty($_POST['spamcheck'])) {$output .= write_error(_SPAMCHECKEMPTY);}
        else if ((trim(strtolower($_POST['spamcheck']))) != 'your answer here' ) {$output .= write_error(_SPAMCHECKFAIL);}

Again, replace "your answer here" with your answer, and write it in lower case.

Step 3:
Open up languages/en.php and add your error messages for leaving the spam test question field empty and for answering incorrectly.
Code: [Select]
define ("_SPAMCHECKEMPTY", "You must answer the spam test question, please go back in your browser and try again");
define ("_SPAMCHECKFAIL", "You did not answer the spam test question correctly, please go back in your browser and try again.");

I added a section to our help page with an answer hint. If you want to do something similar, include the follow before the "); part of the SPAMCHECKFAIL definition
Code: [Select]
<a href=\"viewpage.php?page=pagename#anchorname\">Click here if you need help</a>.
replacing "pagename" with whatever your shortcode name is for your help page and #anchorname with what you called that section (or just omit the #anchor part if you don't need it.

Hopefully this helps get the spam under control!
« Last Edit: December 04, 2017, 02:39:03 am by Ladama »

*

Sue

  • ***
  • Posts: 128
Re: Adding a challenge question to the Registration page
« Reply #3 on: December 05, 2017, 07:58:21 am »
Ooooh! I am SO going to try this out. This is very exciting - thank you!!!

OMGOMGOMG I just added the code and IT WORKS.

Now...I just have to think of a question....hmmm.

Thank you so much Ladama!!!
« Last Edit: December 05, 2017, 08:13:35 am by Sue »

*

JessicaR

  • *
  • Posts: 7
Re: Adding a challenge question to the Registration page
« Reply #4 on: December 10, 2017, 10:08:21 pm »
Awesome!  I just added this to my site too (tested it with both outcomes - correct/incorrect).  Works like a dream.  :)

Re: Adding a challenge question to the Registration page
« Reply #5 on: July 12, 2019, 01:28:24 am »
I've tried adding this to my site with no luck. The challenge question shows up, but even when answered correctly, when I test it, the site always tells me that I've entered the incorrect answer. Any suggestions?  :down: My site is chosentwofanfic.com. I don't have the question on right now as I can't get it to work. Would so appreciate any help!

*

LD-MTT

  • **
  • Posts: 37
    • MoreThanThat
Re: Adding a challenge question to the Registration page
« Reply #6 on: August 07, 2019, 03:52:42 pm »
I've tried adding this to my site with no luck. The challenge question shows up, but even when answered correctly, when I test it, the site always tells me that I've entered the incorrect answer. Any suggestions?  :down: My site is chosentwofanfic.com. I don't have the question on right now as I can't get it to work. Would so appreciate any help!
I would start by making sure your spam test answer is in all lower case letters. I’m not positive but it may only work If your answer is one word with no spaces or non-alphanumeric characters. So if your spam-test answer does have a space or other character like a hyphen, try removing that and seeing if that does the trick.

If it’s not that maybe it’s a small error in the code? Double check that everything is in the right spot and you have all the right quote marks and slashes and parenthesis etc