Register script with 1 ip limit?
How can i get this script to check for ip as well?
1 account per ip like the username.
PHP Code:
<?php
if(isset($_POST["go"])){
foreach ($_POST as $key => $protect) {
$_POST[$key] = addslashes($protect);
}
$user = $_POST["user"];
$password = $_POST["password"];
$password1= $_POST["password1"];
$email = $_POST["email"];
$email1 = $_POST["email1"];
$name = $_POST["name"];
$sex = $_POST["sex"];
$code = $_POST["code"];
if(!$user) {
$error[]="Please fill username input.";
} else {
if(strlen($user) < 6) $error[] = "Username too short.";
if(strlen($user) > 16) $error[] = "Username too long.";
if(!ctype_alnum($user)) $error[] = "Username should be Characters and Numbers only.";
}
if(!$password) {
$error[]= "Please fill password input";
} else {
if(strlen($password) < 6) $error[] = "Password too short.";
if(strlen($password) > 32) $error[] = "Password too long.";
if(!ctype_alnum($password)) $error[] = "Password should be Characters and Numbers only.";
}
if(!$password1) {
$error[]="Please fill confirm password input.";
} else {
if(strlen($password1) < 6) $error[] = "Confirm Password too short.";
if(strlen($password1) > 32) $error[] = "Confirm Password too long.";
}
if ($password && $password1) {
if($password !== $password1){$error[] = "Passwords are not the same";}
}
if(!$email) {
$error[]="Please fill E-mail input";
}
if(!$email1) {
$error[]="Please fill confirm E-mail input";
}
if ($email && $email1) {
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) $error[]= "E-mail is not valid";
if($email !== $email1){$error[] = "E-mails are not the same";}
}
if(!$name) {
$error[]="Please fill name input";
} else {
if(!ctype_alnum($name)) $error[] = "Name should be Characters and Numbers only";
}
if(!$sex) {
$error[]="Please choose sex";
} else {
if(!ctype_alnum($sex)) $error[] = "Sex should be Characters and Numbers only";
if ($sex > 2 || $sex < 0) {
$error[] = "There some thing wrong with sex!";
} else {
if ($sex == 1) {
$sex = "M";
} else if ($sex == 2) {
$sex = "F";
}
}
}
if(!$code) {
$error[]="Please fill code input";
} else {
if($code != $_SESSION["captcha"]){$error[]= "Wrong captcha Code !";}
}
$check = odbc_exec($connect, "SELECT * FROM TB_User WHERE StrUserID = '".$user."'");
if (odbc_num_rows($check) > 0) {
$error[] = "Account with such username already exists please chose another one";
}
if (@count($error) > 0) {
echo "
<div id=\"boxes\">
<div id=\"dialog\" class=\"window\">
<b style=\"float:left;\">Message</b><div title=\"close\" id=\"close\">X</div><br /><hr />
<div class=\"content\">
<ol>
";
for($e=0;$e<count($error);$e++) {
echo "
<li>".$error[$e]."</li>
";
}
echo "
</ol>
</div>
</div>
<div id=\"mask\"></div>
</div>
<script type=\"text/javascript\">
dialog();
</script>
";
} else {
@$register = odbc_exec($connect, "INSERT INTO TB_User(StrUserID, password, Name, Email, sex, reg_ip, sec_primary, sec_content) VALUES ('".$user."', '".md5($password)."', '".$name."', '".$email."', '".$sex."', '".$ip."', '3', '3')");
if ($register) {
$find = odbc_fetch_array(odbc_exec($connect, "SELECT * FROM TB_User WHERE StrUserID = '".$user."'"));
$gift = $find["JID"];
odbc_exec($connect, "INSERT INTO SK_Silk(JID, silk_own) VALUES (".$gift.", ".$silk.")");
odbc_exec($connect, "USE SRO_VT_SHARD INSERT INTO _AccountJID(AccountID, JID, Gold) VALUES ('".$user."',".$gift.", ".$gold.")");
echo "
<script type=\"text/javascript\">
alert(\"Register complete\");
</script>
";
if ($home != "") {
echo "
<script type=\"text/javascript\">
window.location = \"".$home."\";
</script>
";
}
} else {
echo odbc_errormsg();
}
}
}
?>
Re: Register script with 1 ip limit?
PHP Code:
$check = odbc_exec($connect, "SELECT * FROM TB_User WHERE reg_ip = '".$ip."'");
if (odbc_num_rows($check) > 0) {
$error[] = "Only one account per IP allowed.";
}
PHP Code:
$ip = getenv("REMOTE_ADDR") ;
Re: Register script with 1 ip limit?
How would I make a script or change this one to allow more than 1 IP for e.g. 2-3?