Took me a day or two to make something work but this is what I have:
To see it in action: http://www.mediasponder.biz/x/t.php/2
(((( PLEASE BACK UP YOUR CURRENT FILES FIRST ))))
In the skins directory open 'mainregisterusernopass.htm' and add this code to the top;
Code:
<script language='JavaScript' type='text/javascript'>
function refreshCaptcha()
{
var img = document.images['captchaimg'];
img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
}
</script>
PS: that smiley that jumped into the code box is supposed to be a second closed parenthesis )
Then just above the input submit button code, add this;
Code:
<p>
<img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br>
<label for='message'>Enter the code above here :</label><br>
<input id="6_letters_code" name="6_letters_code" type="text"><br>
<small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small>
</p>
<input class=inputbutton type=submit name=register value="Register">
Save this and be prepared to upload it back into your skin directory.
Now open up the 'register.php' file and add the following code at the top just after the <?php;
Code:
session_start(); // start up your PHP session!
// Function to validate against any email injection attempts
function IsInjected($str)
{
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str))
{
return true;
}
else
{
return false;
}
}
#-------------------------------------------------------------#
Find Code:
if (isset($_POST['register']))
{
and place the following code just after the '{' symbol like this;
Code:
if(IsInjected($useremail))
{
$errormessage = get_error($lang['invalid_email']);
}
if(empty($_SESSION['6_letters_code'] ) ||
strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
{
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()
$errormessage = get_error($lang['captcha']);
}
Save that and be prepared to re-upload it.
Open up the eng.php file located in the lang directory and add the following line anywhere in the top half of the page;
Code:
'captcha' => 'wrong captcha answer try again',
Save that and be prepared to re-upload it.
Now before you upload those modified files above, download unzip and upload this package.
http://www.mediasponder.biz/x/t.php/1
Now you can upload all the new and modified files. post here if there are problems. I kinda got excited and posted this fast because I wanted to share this with you guys. My site is new and I haven't done the domain name for it yet.
|