• December 15, 2017, 03:14:32 AM
• Welcome, Guest. Please login or register.
 
News: It's been a while since we started working on eFiction 5, there's been a lot of starting from scratch and half-scratch, but things are moving on.
Now we need you: please visit the eFicition 5 section of the forum and raise your voice, shape the new face of your favourite fanfiction management software.

Author Topic: Adding a challenge question to the Registration page  (Read 113 times)

Sue

  • Veteran
  • ***
  • Posts: 131
  • Country: au
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

  • Veteran
  • ***
  • Posts: 131
  • Country: au
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 »

Ladama

  • Member
  • **
  • Posts: 39
  • Country: us
  • Thanked: 7 times
    • 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

  • Veteran
  • ***
  • Posts: 131
  • Country: au
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

  • Newbie
  • *
  • Posts: 9
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.  :)

 

anything