Notifications
Clear all

Adding a challenge question to the Registration page

9 Posts
5 Users
0 Reactions
2,117 Views
 Sue
(@sue)
Posts: 131
Estimable Member
Topic starter
 

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!


 
Posted : 23/11/2017 7:50 pm
 Sue
(@sue)
Posts: 131
Estimable Member
Topic starter
 

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.


 
Posted : 02/12/2017 8:58 pm
(@ladama)
Posts: 57
Trusted Member
 

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)

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:

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):

if($captcha && !captcha_confirm()) $output .= write_error(_CAPTCHAFAIL);

right after this line add the following

        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.

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

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


 
Posted : 03/12/2017 10:37 pm
 Sue
(@sue)
Posts: 131
Estimable Member
Topic starter
 

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


 
Posted : 05/12/2017 3:58 am
(@jessicar)
Posts: 9
Active Member
 

Awesome!  I just added this to my site too (tested it with both outcomes - correct/incorrect).  Works like a dream.  πŸ™‚


 
Posted : 10/12/2017 6:08 pm
(@aliceinwonderbra)
Posts: 10
Active Member
 

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!


 
Posted : 11/07/2019 9:28 pm
(@ladama)
Posts: 57
Trusted Member
 

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


 
Posted : 07/08/2019 11:52 am
(@charl)
Posts: 17
Active Member
 

I've tried making the changes but now the register and edit password and personal information pages are blank.Β 


 
Posted : 06/02/2022 6:15 am
(@ladama)
Posts: 57
Trusted Member
 

@charl its a little tricky, you have to make sure all the quote marks are correct etc. If possible I could take a look at your editbio.php and make sure it all right. Looks like DM isn't available on the forum any more, I'll try to contact you via the contact form on your archive (our messaging isn't working atm on our archive, hopefully you aren't having the same issue!)


 
Posted : 15/02/2022 11:21 pm
Share: