Advertisement
Guest User

Untitled

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