Advertisement
Guest User

Untitled

a guest
Oct 4th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.31 KB | None | 0 0
  1. // This is just a script... Another Try
  2. if (!$con) {
  3. error_s("Unable to connect to database: " . mysql_error());
  4. };
  5.  
  6. if (!empty($_POST)) {
  7. if ((empty($_POST["username"]))||(empty($_POST["password"]))||(empty($_POST["email"]))||(empty($_POST["tbc"])) ) {
  8. error_s("You did not enter all the required information.");
  9. exit();
  10. } else {
  11. $username = strtoupper($_POST["username"]);
  12. $password = strtoupper($_POST["password"]);
  13. $email = strtoupper($_POST["email"]);
  14. if (strlen($username) < 5) {
  15. error_s("Username too short.");
  16. exit();
  17. };
  18. if (strlen($username) > 14) {
  19. error_s("Username too long.");
  20. exit();
  21. };
  22. if (strlen($password) < 8) {
  23. error_s("Password too short.");
  24. exit();
  25. };
  26. if (strlen($password) > 12) {
  27. error_s("Password too long.");
  28. exit();
  29. };
  30. if (strlen($email) < 15) {
  31. error_s("Email was too short.");
  32. exit();
  33. };
  34. if (strlen($email) > 50) {
  35. error_s("Email was too long.");
  36. exit();
  37. };
  38. if (preg_match($user_chars,$username)) {
  39. error_s("Username contained illegal characters.");
  40. exit();
  41. };
  42. if (preg_match($user_chars,$password)) {
  43. error_s("Password contained illegal characters.");
  44. exit();
  45. };
  46. if (!preg_match($email_chars,$email)) {
  47. error_s("Email was in an incorrect format.");
  48. exit();
  49. };
  50. if ($_POST['tbc'] != "on") {
  51. $tbc = "0";
  52. } else {
  53. $tbc = "1";
  54. };
  55. $username = mysql_real_escape_string($username);
  56. $password = mysql_real_escape_string($password);
  57. $email = mysql_real_escape_string($email);
  58. $qry = @mysql_query("select username from " . mysql_real_escape_string($adb) . ".account where username = '" . $username . "'", $con);
  59. if (!$qry) {
  60. error_s("Error querying database: " . mysql_error());
  61. };
  62. if ($existing_username = mysql_fetch_assoc($qry)) {
  63. foreach ($existing_username as $key => $value) {
  64. $existing_username = $value;
  65. };
  66. };
  67. $existing_username = strtoupper($existing_username);
  68. if ($existing_username == strtoupper($_POST['username'])) {
  69. error_s("That username is already taken.");
  70. exit();
  71. };
  72. unset($qry);
  73. $qry = @mysql_query("select email from " . mysql_real_escape_string($adb) . ".account where email = '" . $email . "'", $con);
  74. if (!$qry) {
  75. error_s("Error querying database: " . mysql_error());
  76. };
  77. if ($existing_email = mysql_fetch_assoc($qry)) {
  78. foreach ($existing_email as $key => $value) {
  79. $existing_email = $value;
  80. };
  81. };
  82. if ($existing_email == $_POST['email']) {
  83. error_s("That email is already in use.");
  84. exit();
  85. };
  86. unset($qry);
  87. $sha_pass_hash = sha1(strtoupper($username) . ":" . strtoupper($password));
  88. $register_sql = "insert into " . mysql_real_escape_string($r_db) . ".account (username, sha_pass_hash, email, expansion) values (upper('" . $username . "'),'" . $sha_pass_hash . "','" . $email . "','" . $tbc . "')";
  89. $qry = @mysql_query($register_sql, $con);
  90. if (!$qry) {
  91. error_s("Error creating account: " . mysql_error());
  92. };
  93. echo("Account successfully created.");
  94. exit();
  95. };
  96. } else {
  97. echo($page);
  98. };
  99.  
  100. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement