13) {
$unitl = true;
}
// if username already exists
$q = mysqli_query($conx, "SELECT username FROM accounts WHERE username='$username_p'");
$c = mysqli_num_rows($q);
if($c > 0) {
$unae = true;
}
// hash the email
$email_hasher = "make ur own random shit here like ...asfkjfj&*Y$#@JK.asfdHf... i know this shit prob aint too secure maybe but i tried";
$email_hashed = hash("sha256",$email_hasher.$email_addr);
// if email already exists
$qq = mysqli_query($conx, "SELECT username FROM accounts WHERE email_secure='$email_hashed'");
$cc = mysqli_num_rows($qq);
if($cc > 0) {
$_SESSION['m6'] = "gen_error";
header("location: /join");
exit();
}
// if length error
if($unitl == true) {
$_SESSION['m4'] = "user_leng";
header("location: /join");
exit();
}
// if username exists error
if($unae == true) {
$_SESSION['m5'] = "user_exi";
header("location: /join");
exit();
}
// if both username and password error
elseif($pdnm == true && $uinan == true && $unitl == '') {
$_SESSION['m3'] = "pdnm_aumna";
header("location: /join");
exit();
}
// if just password error
elseif($pdnm == true && $uinan == '') {
$_SESSION['m1'] = "chec_yapass";
header("location: /join");
exit();
}
// if just username error
elseif($uinan == true && $pdnm == '') {
$_SESSION['m2'] = "user_alnum";
header("location: /join");
exit();
}
// hash the password
$password_hashed = hash("sha256",$username_p.$password_p);
// generate random strings
function genRand1($length = 50) {
return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
}
function genRand2($length = 50) {
return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
}
function genRand3($length = 50) {
return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
}
function genRand4($length = 10) {
return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
}
$genran_str1 = genRand1();
$genran_str2 = genRand2();
$genran_str3 = genRand3();
$gentoken = genRand4();
# ACTUAL ACCOUNT CREATION
$site_locdesc = "attemptin\' verification";
mysqli_query($conx, "INSERT INTO accounts (username, password, email_secure, token, rstringa, rstringb, rstringc, last_ip, current_ip, uagent, joinstamp, site_locdesc) VALUES ('$username_p','$password_hashed','$email_hashed','$gentoken','$genran_str1','$genran_str2','$genran_str3','$ipaddr','$ipaddr','$uagent','$tstamp','$site_locdesc')");
# LOG USER IN TO ACCOUNT
$cs = mysqli_query($conx, "SELECT uid,token,username,rstringa,rstringb,rstringc FROM accounts WHERE username='$username_p'");
$cr = mysqli_fetch_assoc($cs);
$c_userid = $cr['uid'];
$c_username = $cr['username'];
$c_token = $cr['token'];
$c_rstringa = $cr['rstringa'];
$c_rstringb = $cr['rstringb'];
$c_rstringc = $cr['rstringc'];
setcookie("akgnxoPwqlIs", $c_rstringa, time()+3600*24*30, '/', '.misdew.com');
setcookie("LoILilzcnmwe", $c_rstringb, time()+3600*24*30, '/', '.misdew.com');
setcookie("puTtxXvbEkOo", $c_rstringc, time()+3600*24*30, '/', '.misdew.com');
# PUSH OUT EMAIL
$to = $email_addr;
$subject = "misdew.com verification";
$txt = "$c_username,
Thank you for creating an account. Now it's time to verify.
Follow the link below to continue. Please allow it to load completely.
https://misdew.com/join/verify.php?k=$c_token
";
$headers = "Content-Type: text/html; charset=utf-8";
mail($to,$subject,$txt,$headers);
header("location: /hub");
exit();
}
else {
$_SESSION['m'] = "all_req";
header("location: /join");
exit();
}
?>