Advertisement
Guest User

Untitled

a guest
Jun 10th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. <?php
  2. function Error($Error)
  3. {
  4. echo "<center><b><span style='color:#FFFFFF;'>" . $Error . "</span></b></center>";
  5. }
  6. function ConnectMysql()
  7. {
  8. include('functions/configs.php');
  9. $link=mysql_connect("" . $mysql_host . "","" . $mysql_user . "","" . $mysql_pass . "");
  10.  
  11. if(!$link) {
  12. echo "Cannot connect to database!";
  13. }else{
  14. mysql_select_db("". $mysql_db . "",$link);
  15. }
  16. }
  17.  
  18. function register()
  19. {
  20. include('functions/configs.php');
  21.  
  22. if($core == 1) {
  23. $flags = 2;
  24. ConnectMysql();
  25. $user_chars = "#[^a-zA-Z0-9_\-]#";
  26.  
  27. if ((empty($_POST["user"]))||(empty($_POST["password"])) ) {
  28. echo '<script type="text/javascript">window.location = "?pagina=register&error=You did not enter all the required information.";</script>';
  29. } else {
  30. $username = strtoupper($_POST["user"]);
  31. $password = strtoupper($_POST["password"]);
  32. if (strlen($username) < 3) {
  33. echo '<script type="text/javascript">window.location = "?pagina=register&error=Username too short.";</script>';
  34. exit();
  35. };
  36. if (strlen($username) > 30) {
  37. echo '<script type="text/javascript">window.location = "?pagina=register&error=Username too long.";</script>';
  38. exit();
  39. };
  40. if (strlen($password) < 3) {
  41. echo '<script type="text/javascript">window.location = "?pagina=register&error=Password too short.";</script>';
  42. exit();
  43. };
  44. if (strlen($password) > 30) {
  45. echo '<script type="text/javascript">window.location = "?pagina=register&error=Password too long.";</script>';
  46. exit();
  47. };
  48. if (preg_match($user_chars,$username)) {
  49. echo '<script type="text/javascript">window.location = "?pagina=register&error=Username contained illegal characters.";</script>';
  50. exit();
  51. };
  52. if (preg_match($user_chars,$password)) {
  53. echo '<script type="text/javascript">window.location = "?pagina=register&error=Password contained illegal characters.";</script>';
  54. exit();
  55. };
  56. $username = mysql_real_escape_string($username);
  57. $password = mysql_real_escape_string($password);
  58. $qry = mysql_query("SELECT username FROM account WHERE username = '" . $username . "'");
  59. if (!$qry) {
  60. echo '<script type="text/javascript">window.location = "?pagina=register&error=Error querying database.";</script>';
  61. exit();
  62. };
  63. if ($existing_username = mysql_fetch_assoc($qry)) {
  64. foreach ($existing_username as $key => $value) {
  65. $existing_username = $value;
  66. };
  67. };
  68. $existing_username = strtoupper($existing_username);
  69. if ($existing_username == strtoupper($_POST['user'])) {
  70. echo '<script type="text/javascript">window.location = "?pagina=register&error=That username is already taken.";</script>';
  71. exit();
  72. };
  73. unset($qry);
  74. $sha_pass_hash = sha1(strtoupper($username) . ":" . strtoupper($password));
  75. $register_sql = "INSERT INTO account (username, sha_pass_hash, expansion) VALUES ('" . $username . "','" . $sha_pass_hash . "','" . $flags . "')";
  76. $qry = mysql_query($register_sql);
  77. if (!$qry) {
  78. echo '<script type="text/javascript">window.location = "?pagina=register&error=Error creating account.";</script>';
  79. exit();
  80. };
  81. echo '<br /><br /><br /><br /><br /><br /><center><span style="color:#FFFFFF;">Account successfully created.<br /></span></center>';
  82. };
  83.  
  84. }
  85. }
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement