Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 KB | None | 0 0
  1. <style type="text/css">
  2. <!--
  3. body {
  4. background-image: url(images/bg.gif);
  5. }
  6. -->
  7. </style><?php
  8.  
  9. // Configuration.
  10. // Realm database.
  11. $r_db = "realmdz";
  12. // IP (and port).
  13. $ip = "127.0.0.1:3306";
  14. // Username.
  15. $user = "root";
  16. // Password.
  17. $pass = "evox";
  18. // Site title.
  19.  
  20. // End config.
  21.  
  22. $page = '
  23.  
  24.  
  25. <form method="post" action="' . $_SERVER["SCRIPT_NAME"] . '">
  26. <p style="text-align:center;">
  27.  
  28. <br /><br /><br />
  29. Username:
  30. <br /><input name="username" type="text" maxlength="14" /><br />
  31. Password:
  32. <br /><input name="password" type="password" maxlength="12" /><br />
  33. Email:
  34. <br /><input name="email" type="text" maxlength="50" />
  35. <br /> <br />
  36. <button type="submit">Create</button>
  37. </p>
  38. </form>
  39. </body>
  40. </html>';
  41.  
  42. function error_s ($text) {
  43. echo("<p style=\"background-color:black;color:white;\">" . $text);
  44. echo("<br /><br /><a style=\"color:white;\" href=register2.php>Back</a></p>");
  45. echo("<a style=\"color:white;\" href=index.php>Home</a></p>");
  46.  
  47.  
  48. };
  49.  
  50. $user_chars = "#[^a-zA-Z0-9_\-]#";
  51. $email_chars = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";
  52.  
  53. $con = @mysql_connect($ip, $user, $pass);
  54. if (!$con) {
  55. error_s("Unable to connect to database: " . mysql_error());
  56. };
  57.  
  58. if (!empty($_POST)) {
  59. if ((empty($_POST["username"]))||(empty($_POST["password"]))||(empty($_POST["email"])) ) {
  60. error_s("You did not enter all the required information.");
  61. exit();
  62. } else {
  63. $username = strtoupper($_POST["username"]);
  64. $password = strtoupper($_POST["password"]);
  65. $email = strtoupper($_POST["email"]);
  66. if (strlen($username) < 4) {
  67. error_s("Username too short.");
  68. exit();
  69. };
  70. if (strlen($username) > 14) {
  71. error_s("Username too long.");
  72. exit();
  73. };
  74. if (strlen($password) < 4) {
  75. error_s("Password too short.");
  76. exit();
  77. };
  78. if (strlen($password) > 12) {
  79. error_s("Password too long.");
  80. exit();
  81. };
  82. if (strlen($email) < 4) {
  83. error_s("Email was too short.");
  84. exit();
  85. };
  86. if (strlen($email) > 50) {
  87. error_s("Email was too long.");
  88. exit();
  89. };
  90. if (preg_match($user_chars,$username)) {
  91. error_s("Username contained illegal characters.");
  92. exit();
  93. };
  94. if (preg_match($user_chars,$password)) {
  95. error_s("Password contained illegal characters.");
  96. exit();
  97. };
  98. if (!preg_match($email_chars,$email)) {
  99. error_s("Email was in an incorrect format.");
  100. exit();
  101.  
  102. };
  103. if ($_POST['tbc'] != "on") {
  104. $tbc = "3";
  105. } else {
  106. $tbc = "3";
  107. };
  108. $username = mysql_real_escape_string($username);
  109. $password = mysql_real_escape_string($password);
  110. $email = mysql_real_escape_string($email);
  111. $qry = @mysql_query("select username from " . mysql_real_escape_string($r_db) . ".account where username = '" . $username . "'", $con);
  112. if (!$qry) {
  113. error_s("Error querying database: " . mysql_error());
  114. };
  115. if ($existing_username = mysql_fetch_assoc($qry)) {
  116. foreach ($existing_username as $key => $value) {
  117. $existing_username = $value;
  118. };
  119. };
  120. $existing_username = strtoupper($existing_username);
  121. if ($existing_username == strtoupper($_POST['username'])) {
  122. error_s("That username is already taken.");
  123. exit();
  124. };
  125. unset($qry);
  126. $qry = @mysql_query("select email from " . mysql_real_escape_string($r_db) . ".account where email = '" . $email . "'", $con);
  127. if (!$qry) {
  128. error_s("Error querying database: " . mysql_error());
  129. };
  130. if ($existing_email = mysql_fetch_assoc($qry)) {
  131. foreach ($existing_email as $key => $value) {
  132. $existing_email = $value;
  133. };
  134. };
  135. if ($existing_email == $_POST['email']) {
  136. error_s("That email is already in use.");
  137. exit();
  138. };
  139.  
  140. unset($qry);
  141. $sha_pass_hash = sha1(strtoupper($username) . ":" . strtoupper($password));
  142. $register_sql = "insert into " . mysql_real_escape_string($r_db) . ".account (username, sha_pass_hash, gmlevel, email, expansion) values (upper('" . $username . "'),'" . $sha_pass_hash . "','1','" . $email . "','" . $tbc . "')";
  143. $qry = @mysql_query($register_sql, $con);
  144. if (!$qry) {
  145. error_s("Error creating account: " . mysql_error());
  146. };
  147. echo("Account successfully created.Set Realmlist infernowow.servegame.com:3725");
  148. echo("<br><a style=\"color:white;\" href=index.php>Home</a></p><br />");
  149. exit();
  150. };
  151. } else {
  152. echo($page);
  153. };
  154.  
  155. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement