- <?php include_once("php_includes/check_login_status.php");
- ?><?php
- // Ajax calls this NAME CHECK code to execute
- if(isset($_POST["usernamecheck"])){
- include_once("php_includes/db_conx.php");
- $username = preg_replace('#[^a-z0-9]#i', '', $_POST['usernamecheck']);
- $sql = "SELECT id FROM users WHERE username='$username' LIMIT 1";
- $query = mysqli_query($db_conx, $sql);
- $uname_check = mysqli_num_rows($query);
- if (strlen($username) < 3 || strlen($username) > 25) {
- echo '<strong style="color:#F00;">3 - 25 characters please</strong>';
- exit();
- }
- if (is_numeric($username[0])) {
- echo '<strong style="color:#F00;">Usernames must begin with a letter</strong>';
- exit();
- }
- if ($uname_check < 1) {
- echo '<strong style="color:#009900;">' . $username . ' is OK</strong>';
- exit();
- } else {
- echo '<strong style="color:#F00;">' . $username . ' is taken</strong>';
- exit();
- }
- }
- ?><?php
- if(isset($_POST["u"])){
- include_once("php_includes/db_conx.php");
- $u = preg_replace('#[^a-z0-9]#i', '', $_POST['u']);
- $e = mysqli_real_escape_string($db_conx, $_POST['e1']);
- $p = $_POST['p'];
- $bd = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
- $g = preg_replace('#[^a-z]#', '', $_POST['g']);
- $l = preg_replace('#[^a-z0-9,]#i', '', $_POST['l']);
- $ln = preg_replace('#[^a-z]#i', '', $_POST['ln']);
- $fn = preg_replace('#[^a-z]#i', '', $_POST['fn']);
- $c = preg_replace('#[^a-z ]#i', '', $_POST['c']);
- $ip = preg_replace('#[^0-9.]#', '', getenv('REMOTE_ADDR'));
- $sql = "SELECT id FROM users WHERE username='$u' LIMIT 1";
- $query = mysqli_query($db_conx, $sql);
- $u_check = mysqli_num_rows($query);
- $sql = "SELECT id FROM users WHERE email='$e' LIMIT 1";
- $query = mysqli_query($db_conx, $sql);
- $e_check = mysqli_num_rows($query);
- if($u == "" || $e == "" || $p == "" || $g == "" || $c == "" || $bd == "" || $l == "" || $fn == "" || $ln == ""){
- echo "The form submission is missing values.";
- exit();
- } else if ($u_check > 0){
- echo "The username you entered is alreay taken";
- exit();
- } else if ($e_check > 0){
- echo "That email address is already in use in the system";
- exit();
- } else if (strlen($u) < 3 || strlen($u) > 25) {
- echo "Username must be between 3 and 25 characters";
- exit();
- } else if (is_numeric($u[0])) {
- echo 'Username cannot begin with a number';
- exit();
- } else {
- $p_hash = md5($p);
- $sql = "INSERT INTO users (firstname, lastname, birthday, location, username, email, password, gender, country, ip, signup, lastlogin, notescheck)
- VALUES('$fn','$ln','$bd','$l','$u','$e','$p_hash','$g','$c','$ip',now(),now(),now())";
- $query = mysqli_query($db_conx, $sql);
- $uid = mysqli_insert_id($db_conx);
- $sql = "INSERT INTO useroptions (id, username, background) VALUES ('$uid','$u','original')";
- $query = mysqli_query($db_conx, $sql);
- if (!file_exists("user/$u")) {
- mkdir("user/$u", 0755);
- }
- $to = "$e";
- $subject = 'nssgaming Account Activation';
- $message = '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>nssgaming Message</title></head><body style="margin:0px; font-family:Tahoma, Geneva, sans-serif;"><div style="padding:10px; background:#333; font-size:24px; color:#CCC;"><a href="http://social.nssgaming.com/"><img src="http://social.nssgaming.com/images/logo.png" width="36" height="30" alt="nssgaming" style="border:none; float:left;"></a>nssgaming Account Activation</div><div style="padding:24px; font-size:17px;">Hello '.$u.',<br /><br />Click the link below to activate your account when ready:<br /><br /><a href="http://social.nssgaming.com/activation.php?id='.$uid.'&u='.$u.'&e='.$e.'&p='.$p_hash.'">Click here to activate your account now</a><br /><br />Login after successful activation using your:<br />* E-mail Address: <b>'.$e.'</b></div></body></html>';
- $headers = "From: $from\n";
- $headers .= "MIME-Version: 1.0\n";
- $headers .= "Content-type: text/html; charset=iso-8859-1\n";
- mail($to, $subject, $message, $headers);
- echo "signup_success";
- exit();
- }
- exit();
- }
- ?>