modifiying smf – dremi.INFO https://www.dremi.info Software Development, Digital Marketing and News Sat, 27 Jun 2009 15:23:59 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 https://www.dremi.info/wp-content/uploads/2020/12/cropped-icon-32x32.png modifiying smf – dremi.INFO https://www.dremi.info 32 32 How to Modifiying SMF User Register Page to Protect from Spammer or Junker https://www.dremi.info/tutorials/php/how-to-modifiying-smf-user-register-page-to-protect-from-spammer-or-junker.html https://www.dremi.info/tutorials/php/how-to-modifiying-smf-user-register-page-to-protect-from-spammer-or-junker.html#comments Sat, 27 Jun 2009 15:23:59 +0000 https://www.dremi.info/?p=853 […]]]> 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

]]> https://www.dremi.info/tutorials/php/how-to-modifiying-smf-user-register-page-to-protect-from-spammer-or-junker.html/feed 3