How to Modifiying SMF User Register Page to Protect from Spammer or Junker

June 27th, 2009 by dr.emi

Hello my fox! glad to see you today. For more than one week, I got spam and bad posting (junk) on my forum . But today I hope no more again. I think this tutorial will help you, how to modifiying SMF User Register Page to protect from spammer or junker. As you know, SMF has Spam Protection like Captcha, called as Visual Verification. For a simple spam protection, I think captcha is enough for your forum register protection. But how if users do register and then make some posting on your forum ?

 

As you know, forum is place for your community to discuss about your website or other, and absolutly your website have members. But becarefull, how if your member only want to post spam or junk maybe. You will not have more time to moderate the junk or spam posts.

It explain about, we need personal verification for the register user page. So we must modify the user register page. Actually SMF has a default template for displaying user register, you can found it at: /SMF-Folder/Themes/default/Register.template.php

Just begin from this file, open it and find this line:

if ($context['visual_verification'])

Before these line, you will see table structure for password field.

<tr>
<td width="40%">
<b>', $txt[82], ':</b>
</td>
<td>
<input type="password" name="passwrd2" size="30" tabindex="', $context['tabindex']++, '" />
</td>
</tr>

Add this code after password table row

$tempPhrase = 'YourSecreetWord';
$_SESSION['temp_phrase'] = $tempPhrase;

echo '
<tr>
<td width="40%">
<b>', $txt[88], ':</b>
<div class="smalltext">', $txt['valid_phrase_description'], '</div>
</td>
<td>
<input type="text" name="valid_phrase" size="30" tabindex="', $context['tabindex']++, '" />
</td>
</tr>

Let’s see this extra code:

$tempPhrase = 'Azami'; ==> YourSecreetWord, will used for session value and this is your answer of Personal Perification
$_SESSION['temp_phrase'] = $tempPhrase; ==> make session value registered

$txt[88] ==> Language array, will used for displaying Personal Verfication Label.
$txt['valid_phrase_description'] ==> Language array, will used for displaying notes or simple question for you new member
name="valid_phrase" ==> a name for your new field

Then how to adding new language array ?? just open Login.english.php that located on /SMF-Folder/Themes/default/Languages/Login.english.php

Then Add this line wherever you want:

$txt['valid_phrase_description'] = 'What is my last name ?'; //will displayed on Register.template.php

Next, open /SMF-Folder/Themes/default/Languages/index.english.php file. Then add this line wherever you want:

$txt[88] = 'Personal Verification '; //will displayed on Register.template.php
##note: 88 is number of variable for Language array of Login.english.php

Next step is modifying this file: /SMF-Folder/Sources/Register.php. Then find this line :

if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && !isset($_POST['skip_coppa']))

Add this code after these line:

if ($_SESSION['temp_phrase'] != $_POST['valid_phrase'])
	{
		loadLanguage('Login');
		fatal_lang_error('phrase_verification_failed', false);
	}
	elseif (isset($_SESSION['temp_phrase']))
		unset($_SESSION['temp_phrase']);

The code above will used for session authentication of Personal Perification Answer.

And don’t forget to add “phrase_verification_failed” array string into file: /SMF-Folder/Themes/default/Languages/Errors.english.php

$txt['phrase_verification_failed'] = 'Your answer is wrong ! Please Try Again.';

It’s DONE! :)

Upload your new modifiying files into Host. And then you will see the new Personal Verification in User Register Page.

This is my screeshoot of spammer (human) user that trying to register with wrong answer in User Register Page.

Photobucket

Regard, dr.emi

Popularity: 16% [?]

You may also like

  • No Related Post

Download Unavailable Demo Unavailable
Bookmark Subscribe
Hello my fox! Glad to see you today!

If you love my tutorial, please chose any action from the left button.

3 Comments

hadi Said:  

not yet try but this is great job, thank you.

dr.emi Said:  

well, that’s just to improve your defense of your forum register page.. nice to try :)
so, try it !

currencylaund Said:  

I think that your site is very interesting and nice. Good job !

Hi.. ! Wanna say anything about my tutorial ?
Just say it with fill the comment form.
Comment Form
 

 
 
 
 
 
Category
stack