';
}
else
{
if(isset($_POST['rb']))
{
$verifyResponse = @file_get_contents('apiurl'.cleanInput($_POST['g-recaptcha-response']));
$responseData = @json_decode($verifyResponse);
if(!(@$responseData->success))
{
$uname = cleanInput((string)$_POST['username']);
$passw = cleanInput((string)$_POST['password']);
$hpasw = password_hash($passw, PASSWORD_DEFAULT);
$cpasw = (string)$_POST['cpassword'];
$email = cleanInput((string)$_POST['email']);
$signupkey = cleanInput((string)$_POST['signup_key']);
if(usernameExists($uname) == true)
{
$error = 'The username you entered already exists
';
}
else
{
if(!(ctype_alnum($uname)))
{
$error = 'Your username must contain letters and numbers only
';
}
if(strlen($uname) < 3 || strlen($uname) > 20)
{
$error = 'Your username must be between 3 and 20 characters long
';
}
if(isFiltered($uname))
{
$error = 'Username is not appropriate for Alphaland
';
}
}
if(strlen($passw) < 8)
{
$error = 'Passwords must be atleast 8 characters long
';
}
else if(!($passw == $cpasw))
{
$error = 'The passwords you entered do not match
';
}
if(FILTER_VAR($email, FILTER_VALIDATE_EMAIL) == false)
{
$error = 'The email you entered is invalid
';
}
if (emailRegistered($email))
{
$error = "Email is already registered";
//redirect("/login"); //email already exists, redirect to login
}
$ip = getIP();
/*
if (isIPAssociatedWithAccount($ip))
{
$error = "IP Associated with another account";
redirect("/login"); //ip is associated with another account, redirect to login
}
*/
if($error == "")
{
$isUserGen = false;
$isAdminGen = false;
if (isSignupKeyUserGenerated($signupkey)) //referral system
{
$isUserGen = true;
}
else if (verifySignupKey($signupkey)) //old invite keys from admins
{
$isAdminGen = true;
}
else
{
$error = 'Invalid signup key
';
}
if($error == "")
{
//register the user
$ruid = $pdo->prepare("INSERT INTO users(email,username,pwd,joindate,ip) VALUES(:e, :u, :p, UNIX_TIMESTAMP(), :i)");
$ruid->bindParam(":u", $uname, PDO::PARAM_STR);
$ruid->bindParam(":p", $hpasw, PDO::PARAM_STR);
$ruid->bindParam(":e", $email, PDO::PARAM_STR);
$ruid->bindParam(":i", $ip, PDO::PARAM_STR);
if($ruid->execute())
{
//grab the new user's id
$userID = getID($uname);
//referral system
if ($isUserGen)
{
handleSignupWithUserKey($userID, $signupkey);
}
//first place
$gamename = $uname . "'s Place Number: 1";
$gamedesc = $uname . "'s first place";
createPlace($userID, $gamename, $gamedesc, 12);
setDefaults($userID); //gives default outfit, body colors and wears the default outfit
//setup the activation system
$activation = new Alphaland\Users\Activation();
$activation::setupUserActivation($userID);
//create new session
createSession($userID);
//send verification email
sendVerificationEmail("info@alphaland.cc", $email);
redirect("/");
}
else
{
$error = 'An error occurred while registering, contact an Administrator
';
}
}
}
}
else
{
$error = 'Please verify the reCAPTCHA and try again.
';
}
}
$body = '
Register
'.(($error != "")? $error:"").'
';
}
pageHandler();
$ph->footer = "";
$ph->pageTitle("Register");
$ph->body = $body;
$ph->output();