Advertisement
Guest User

Untitled

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