Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. <?php
  2.  
  3. include "config.php";
  4.  
  5. $tbc = 2;
  6. $database_encoding = 'CP1251';
  7.  
  8. $auth = mysql_connect("$dbip:$dbport", "$dblogin", "$dbpass", True);
  9. mysql_selectdb("$rdb", $auth);
  10.  
  11. $world = mysql_connect("$dbip:$dbport", "$dblogin", "$dbpass", True);
  12. mysql_selectdb("$mdb", $world);
  13.  
  14. $characters = mysql_connect("$dbip:$dbport", "$dblogin", "$dbpass", True);
  15. mysql_selectdb("$cdb", $characters);
  16.  
  17. echo "
  18. <script type=\"text/javascript\">
  19. function isAlphaNumeric(value)
  20. {
  21. if (value.match(/^[a-zA-Z0-9_]+$/))
  22. return true;
  23. return false;
  24. }
  25. function checkform(f)
  26. {
  27. if (f.account.value == \"\")
  28. {
  29. alert(\"Введите логин\");
  30. return false;
  31. }
  32. if (!isAlphaNumeric(f.account.value))
  33. {
  34. alert(\"Запрещенные символы в логине\");
  35. return false;
  36. }
  37. if (f.password.value==\"\")
  38. {
  39. alert(\"Введите пароль\");
  40. return false;
  41. }
  42. if (!isAlphaNumeric(f.password.value))
  43. {
  44. alert(\"Запрещенные символы в пароле\");
  45. return false;
  46. }
  47. if (f.password2.value==\"\")
  48. {
  49. alert(\"Вы не ввели повтор пароля\");
  50. return false;
  51. }
  52. if (f.password.value != f.password2.value)
  53. {
  54. alert(\"Пароли не совпадают\");
  55. return false;
  56. }
  57. if (f.email.value==\"\")
  58. {
  59. alert(\"Вы не ввели e-mail\");
  60. return false;
  61.  
  62. }
  63. }
  64. </script>";
  65.  
  66. echo "
  67.  
  68. <font color=#00CC00>
  69. </font><br><br>
  70. <center>
  71. <form method=post action=reg.php onsubmit=\"return checkform(this)\">
  72. <table>
  73.  
  74. <tr>
  75. <td><font color=grey>Имя аккаунта:</font></td>
  76. <td><input type=text name=account maxlength=20></td>
  77. </tr>
  78.  
  79. <tr>
  80. <td><font color=grey>Пароль:</font></td>
  81. <td><input type=password name=password maxlength=20></td>
  82. </tr>
  83. <tr>
  84. <td><font color=grey>Пароль ещё раз:</font></td>
  85. <td><input type=password name=password2 maxlength=20></td>
  86. </tr>
  87. <tr>
  88. <td><font color=grey>Почта:</font></td>
  89. <td><input type=text name=email maxlength=32></td><br>
  90. </tr>
  91. <tr>
  92. <td colspan=2 style=\"text-align: center;\"><br><input type=submit value=Зарегистрироваться></td>
  93. </tr>
  94. </table>
  95. </form></center>";
  96. if (isset($_POST['account'])) {
  97. if ($_POST['account'] && strlen($_POST['account'])<=20 && strlen($_POST['account'])>=3 && strlen($_POST['password'])>=3 && $_POST['password'] && $_POST['password2'] && $_POST['password']==$_POST['password2']) {
  98. if (!eregi("^[a-zA-Z0-9_]+$", $_POST['account']))
  99. die ("<p>Error: SQL-Injection</p>";
  100. if (!eregi("^[a-zA-Z0-9_]+$", $_POST['password']))
  101. die ("<p>Error: SQL-Injection</p>";
  102. $pass = ($_POST['password']);
  103. $username = ($_POST['account']);
  104. $result = mysql_query("SELECT * FROM account WHERE username='".$_POST['account']."' AND sha_pass_hash='$pass'", $auth);
  105. if (mysql_num_rows($result) != 0) {
  106. echo "<center><p><font color=#CC0000><b>Такой аккаунт уже есть!</b></font></p></center>";
  107. } else {
  108. if (!mysql_query("INSERT INTO account (username, sha_pass_hash, gmlevel, email, expansion) VALUES ('$username', SHA1(CONCAT(UPPER('$username'),':',UPPER('$pass'))), 0, '".$_POST['email']."', $tbc)", $auth)) {echo "<center><p><font color=#CC0000><b>Ошибка</b></font></p></center>";} else {echo "<center><p><font color=#00CC00><b>Аккаунт успешно зарегестрирован!</b></font></p></center>";}
  109. }
  110. } else {
  111. echo "<center><p><font color=#CC0000><b>Проверьте правильность ввода!</b></font></p></center>";
  112. }
  113. }
  114.  
  115. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement