Hej
This post introduce you how to install a captcha in Ubbthreads v. 6, in new user registration. If you have problems with spambots registrations, this post could help you.
First of all, all credits regarding this captcha should be given to
http://php.webmaster-kit.com/. You can download the captcha
here New files to be uploaded- button.php
- audit.php
Modified files- newuser.php
- newuser.php(language file)
- adduser.php
- adduser.php (language file)
- newuser_signup.tmpl
Step.1
Open newuser.php(language file) and add the line
$ubbt_lang['CAPTCHA'] = "Enter digits";
Step.2
Open adduser.php(language file) and add the line
$ubbt_lang['NO_CAPTCHA'] = "Wrong digits";
Step.3
Open adduser.php and add the following red marked code
// ------------------------------------------------------------
// If all required info is not filled in, then we can't proceed
// Redigeret Okt.06 af arentzen - og marts 07
if((!$Username)||(!$Password)||(!$Email)||(!eregi("@",$Email))||(!eregi("\.",$Email))
||(!$userdigit)||($agree != "yes")){
$html -> not_right($ubbt_lang['ALL_FIELDS'],$Cat);
}
Step.4
Scroll further down the same page and add following red marked code.
// ------------------------------------------------------------
// Captcha - af Arentzen marts 07
include "audit.php";
if(audit()){
}
else {
$html -> not_right($ubbt_lang['NO_CAPTCHA'],$Cat);
} // --------------------------------------
// Check to see if this is the first user
$query = "
SELECT COUNT(U_Number)
FROM w3t_Users
";
$sth = $dbh -> do_query($query);
list ($firstuser) = $dbh -> fetch_array($sth);
$dbh -> finish_sth($sth);
$Groups = $config['newusergroup'];
Step 5.
Open newuser_signup.tmpl and add the captcha and input box.
<img width="120" height="30" src="button.php" border="1" />
<br />
<br />
{$ubbt_lang['CAPTCHA']}
<br />
<input maxlenght="5" size="5" name="userdigit" type="text" value="" />
<br />
<br />Step 6.
To make the captcha works correct without an errormessage when running the script first time, its nessesary to install a " dummy" to reset the captcha.
Open newuser.php and add the following red marked code in bottom of page.
//---------------------------------------------------------------------------
// Reset captcha ved registrering - af Arentzen
include "audit.php";
if(!audit()){
}
// ----------------------------------------------------------------------
// If we are allowing the user to create their own password, then we give
// them a form
if ($config['userpass']) {
$choosepassword = "
{$ubbt_lang['OPT_PASS']}<br />
<input type=\"password\" name=\"Loginpass\" class=\"formboxes\" />
<br /><br />
{$ubbt_lang['VER_PASS']}<br />
<input type=\"password\" name = \"Verify\" class=\"formboxes\" />
<br /><br />
";
}
include("$thispath/templates/$tempstyle/newuser_signup.tmpl");
$html -> send_new_footer();
?>
Thats it! Enjoy.