1. <?php include_once("php_includes/check_login_status.php");
  2. ?><?php
  3. // Ajax calls this NAME CHECK code to execute
  4. if(isset($_POST["usernamecheck"])){
  5. include_once("php_includes/db_conx.php");
  6. $username = preg_replace('#[^a-z0-9]#i', '', $_POST['usernamecheck']);
  7. $sql = "SELECT id FROM users WHERE username='$username' LIMIT 1";
  8. $query = mysqli_query($db_conx, $sql);
  9. $uname_check = mysqli_num_rows($query);
  10. if (strlen($username) < 3 || strlen($username) > 25) {
  11. echo '<strong style="color:#F00;">3 - 25 characters please</strong>';
  12. exit();
  13. }
  14. if (is_numeric($username[0])) {
  15. echo '<strong style="color:#F00;">Usernames must begin with a letter</strong>';
  16. exit();
  17. }
  18. if ($uname_check < 1) {
  19. echo '<strong style="color:#009900;">' . $username . ' is OK</strong>';
  20. exit();
  21. } else {
  22. echo '<strong style="color:#F00;">' . $username . ' is taken</strong>';
  23. exit();
  24. }
  25. }
  26. ?><?php
  27. if(isset($_POST["u"])){
  28. include_once("php_includes/db_conx.php");
  29. $u = preg_replace('#[^a-z0-9]#i', '', $_POST['u']);
  30. $e = mysqli_real_escape_string($db_conx, $_POST['e1']);
  31. $p = $_POST['p'];
  32. $bd = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
  33. $g = preg_replace('#[^a-z]#', '', $_POST['g']);
  34. $l = preg_replace('#[^a-z0-9,]#i', '', $_POST['l']);
  35. $ln = preg_replace('#[^a-z]#i', '', $_POST['ln']);
  36. $fn = preg_replace('#[^a-z]#i', '', $_POST['fn']);
  37. $c = preg_replace('#[^a-z ]#i', '', $_POST['c']);
  38. $ip = preg_replace('#[^0-9.]#', '', getenv('REMOTE_ADDR'));
  39. $sql = "SELECT id FROM users WHERE username='$u' LIMIT 1";
  40. $query = mysqli_query($db_conx, $sql);
  41. $u_check = mysqli_num_rows($query);
  42. $sql = "SELECT id FROM users WHERE email='$e' LIMIT 1";
  43. $query = mysqli_query($db_conx, $sql);
  44. $e_check = mysqli_num_rows($query);
  45. if($u == "" || $e == "" || $p == "" || $g == "" || $c == "" || $bd == "" || $l == "" || $fn == "" || $ln == ""){
  46. echo "The form submission is missing values.";
  47. exit();
  48. } else if ($u_check > 0){
  49. echo "The username you entered is alreay taken";
  50. exit();
  51. } else if ($e_check > 0){
  52. echo "That email address is already in use in the system";
  53. exit();
  54. } else if (strlen($u) < 3 || strlen($u) > 25) {
  55. echo "Username must be between 3 and 25 characters";
  56. exit();
  57. } else if (is_numeric($u[0])) {
  58. echo 'Username cannot begin with a number';
  59. exit();
  60. } else {
  61. $p_hash = md5($p);
  62. $sql = "INSERT INTO users (firstname, lastname, birthday, location, username, email, password, gender, country, ip, signup, lastlogin, notescheck)
  63. VALUES('$fn','$ln','$bd','$l','$u','$e','$p_hash','$g','$c','$ip',now(),now(),now())";
  64. $query = mysqli_query($db_conx, $sql);
  65. $uid = mysqli_insert_id($db_conx);
  66. $sql = "INSERT INTO useroptions (id, username, background) VALUES ('$uid','$u','original')";
  67. $query = mysqli_query($db_conx, $sql);
  68. if (!file_exists("user/$u")) {
  69. mkdir("user/$u", 0755);
  70. }
  71. $to = "$e";
  72. $from = "[email protected]";
  73. $subject = 'nssgaming Account Activation';
  74. $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>';
  75. $headers = "From: $from\n";
  76. $headers .= "MIME-Version: 1.0\n";
  77. $headers .= "Content-type: text/html; charset=iso-8859-1\n";
  78. mail($to, $subject, $message, $headers);
  79. echo "signup_success";
  80. exit();
  81. }
  82. exit();
  83. }
  84. ?>