Well, all I have done is added recaptcha to the register already released + a little edition.
1. Run this little query by Reimniess on the ACCOUNT_TBL:
2.Sign up and download the reCaptcha API.
Sign up->
Download->
Put the API(recaptchalib.php) into a folder named "API".
3.Paste the following script to register.php, or something similar in the root/folder where you placed the API folder.
I think that is right, not sure as I wrote it in ragezone editor ;>, never tested it, so can someone let me know if it works, or what error it gives.
1. Run this little query by Reimniess on the ACCOUNT_TBL:
Code:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[createaccount]
@account VARCHAR(15),
@password VARCHAR(32)
AS
SET NOCOUNT ON
DECLARE @DateActivated AS CHAR(8)
IF NOT EXISTS (SELECT account FROM ACCOUNT_TBL WHERE account = @account) BEGIN
INSERT INTO ACCOUNT_TBL (account, [password], id_no2, isuse, member, realname)
VALUES (@account, @password, @password, 'T', 'A', 'F')
SET @DateActivated = CONVERT(CHAR(8), GETDATE()-1, 112 ) --Is the date today - 1
--UPDATE ACCOUNT_TBL_DETAIL SET BlockTime = @DateYesterday WHERE account = @userid
--INSERT INTO ACCOUNT_TBL_DETAIL (account, gamecode, tester, m_chLoginAuthority, regdate, BlockTime, EndTime, WebTime, isuse)
-- VALUES (@account, 'A000', '2', 'F', GETDATE(), '20990101', '20990101', '20050101', 'O')
INSERT INTO ACCOUNT_TBL_DETAIL (account, gamecode, tester, m_chLoginAuthority, regdate, BlockTime, EndTime, WebTime, isuse)
VALUES (@account, 'A000', '2', 'F', GETDATE(), @DateActivated, '20990101', '20050101', 'O')
END
2.Sign up and download the reCaptcha API.
Sign up->
To view the content, you need to sign in or register
Download->
To view the content, you need to sign in or register
Put the API(recaptchalib.php) into a folder named "API".
3.Paste the following script to register.php, or something similar in the root/folder where you placed the API folder.
PHP:
<?php
require_once('API//recaptchalib.php');
$ip=''; //mssql ip, usually something\SQLEXPRESS
$usr=''; //usually sa
$pwd=''; //your mssql pass
$salt=''; //your mssql salt(if using serus, salt is serus)
$pubkey=''; //your reCaptcha public key
$privkey=''; //your reCaptcha private key.
$design='red'; //reCaptcha style, found http://wiki.recaptcha.net/index.php/Theme
?>
<script type="text/javascript">
var RecaptchaOptions = {
theme : '<?php echo $design; ?>'
};
</script>
<?php
$link = @mssql_connect($ip, $usr, $pwd) or die ("Server is down!");
$db = @mssql_select_db('ACCOUNT_DBF') or die ("Accout table is missing!");
$b = '';
$mail = '';
function doesUsernameExist($name){
$exit = FALSE;
$result = @mssql_query("SELECT * FROM ACCOUNT_TBL WHERE account='$name'");
if (mssql_num_rows($result) != 0){
$exit = TRUE;
}
return $exit;
}
if(isset($_POST['submit'])){
$user = preg_replace ("[^A-Za-z0-9]", "", $_POST['username']);
$pass = preg_replace ("[^A-Za-z0-9]", "", $_POST['password']);
$idk=array('"', "'", ';', '-');
$user = str_replace($idk, '', $user);
$pass = str_replace($idk, '', $pass);
if($_POST['username'] == ""){
echo '<font color="red">Enter a user.</font><br /><br />';
}
else if($_POST['password'] == ""){
echo '<font color="red">Enter a password.</font><br /><br />';
}
else if($_POST['password'] != $_POST['password2']){
echo '<font color="red">Passwords do not match.</font><br /><br />';
}
else if ((strlen($_POST['username']) > 16) || (strlen($_POST['username']) < 3)){
echo '<font color="red">The user should be 3 to 16 characters.</font><br /><br />';
}
else if ((strlen($_POST['password']) > 16) || (strlen($_POST['password']) < 3)){
echo '<font color="red">The password should be 3 to 16 characters.</font><br /><br />';
}
else if($_POST['username'] != $user){
echo '<font color="red">User with invalid characters.</font><br /><br />';
}
else if($_POST['password'] != $pass){
echo '<font color="red">Password with invalid characters.</font><br /><br />';
}
else if(strlen($_POST["recaptcha_response_field"]) == 0){
echo '<font color="red">Did you forget to enter reCaptcha?</font><br />';
}
$resp = recaptcha_check_answer ($privkey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
else if(!$resp->is_valid){
echo 'You have entered the reCaptcha wrong, reCaptcha said:'.$resp->error;
}
else {
$pass = md5($salt . $pass);
if(!doesUsernameExist($user)){
$stmt = mssql_init('createaccount', $link);
mssql_bind($stmt, '@account', $user, SQLVARCHAR, false, false, 15);
mssql_bind($stmt, '@password', $pass, SQLVARCHAR, false, false, 36);
mssql_execute($stmt) or die ("Something went wrong during execution, please contact an administrator.");
mssql_free_statement($stmt);
echo '<font color="Green">Register Successfull.</font><br /><br />';
}
else {
echo '<font color="red">User already Exists.</font><br /><br />';
}
}
mssql_close();
}
echo '<form action=" " method="post"><table border=0>';
echo '<tr><td>Username:</td><td><input type="text" name="username" /></td></tr>';
echo '<tr><td>Password:</td><td><input type="password" name="password" /></td></tr>';
echo '<tr><td>Repeat Password:</td><td><input type="password2" name="password2" /></td></tr></table>';
echo recaptcha_get_html($pubkey, $error);
echo '<br /><input type="submit" name="submit" value="Register" />';
echo '</form>';
?>
Last edited:

