PDA

View Full Version : Prevent people making multiple accounts


kisazeky
04-04-2009, 04:53 PM
This is hard to believe, but some people are desperate as to keep registering accounts to level up their adoptables. Let's make this method of leveling up not worth it.

Step 1:

Run this query

ALTER TABLE users ADD (ip VARCHAR(30) NOT NULL DEFAULT "0")


Step 2:

Open register2.php

Find

// Connect to our database


Above this line, put


$ip = $_SERVER['REMOTE_ADDR'];
$ip = preg_replace("/[^a-zA-Z0-9@._-]/", "", $ip);


Step 3:

Still in register2.php, find this code:


//Check that username does not already exist

$query = "SELECT * FROM users WHERE username = '$username'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

//Loop out code
$i=0;
while ($i < 1) {

$luser=@mysql_result($result,$i,"username");


$i++;
}

$luser = strtolower($luser);
$u2 = $str = strtolower($username);

if($luser == $u2){
$template = replace(':ARTICLETITLE:','Error',$template);
$template = replace(':ARTICLECONTENT:','Your username has been taken. Please <a href="register.php">go back</a> and select a different username.',$template);
echo $template;
die();
}



Below all of that, put


// Check that user is not making multiple accounts

$query = "SELECT * FROM users WHERE ip = '$ip'";
$result = @mysql_query($query);
$num = @mysql_numrows($result);

//Loop out code
$i=0;
while ($i < 1) {

$ip2=@mysql_result($result,$i,"ip");


$i++;
}

if($ip == $ip2){
$template = replace(':ARTICLETITLE:','Error',$template);
$template = replace(':ARTICLECONTENT:','You are not allowed to make multiple accounts.',$template);
echo $template;
die();
}


Step 4:

Find this line

//All checks pass, create the user

Insert below it:

$pass1 = md5($pass1); //MD5 the password
mysql_query("INSERT INTO users VALUES ('', '$username', '$pass1','$email','free', '$ip')");

Note: if you have installed my currency mod, you'll want to insert this instead:

$pass1 = md5($pass1); //MD5 the password
mysql_query("INSERT INTO users VALUES ('', '$username', '$pass1','$email','free', '0', '$ip')");

Ashje
04-04-2009, 05:30 PM
Awesome, trying it now.

EDIT:

Works perfectly but Members registered before the mod was installed have an IP "0" so they can still make double accounts. With sites like Arvyre, which already has over 4000 members, this is useless.

kisazeky
04-04-2009, 05:47 PM
I am not sure if exceptions can be made, honestly

BMR777
04-04-2009, 07:57 PM
This is a bad idea because of legitimate users sharing IP addresses, such as Dial Up Users and DSL users who get a new IP each time they connect, users in public places such as schools and countries where the IP address pool for all users is limited or the same, such as Turkey where everyone shares about 20 IP addresses. :)

eaglelegend
04-06-2009, 12:27 PM
Point taken Brandon, but, what if you have a limit, say you cant register with the same IP address for say 30 mins, just to be safe say.

kisazeky
04-06-2009, 07:57 PM
Good idea but I don't know how to do time in php.

For now I'm letting people ask for exceptions in my forums.

Blue Icebox
04-24-2009, 01:44 AM
Well... since brandon made the 24 hours limit adoptable part... go to that section and change a little to fit the requirements! :D