Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.64 KB | None | 0 0
  1. <?php
  2.  
  3. include("config.php");
  4.  
  5. if(!file_exists($installationFile))
  6. {
  7. redirect("install", 0);
  8. }
  9.  
  10. echo "<center>";
  11.  
  12. echo
  13. "<form action='index' method='POST'>
  14. <input type='hidden' name='register' value='1'>
  15. <input type='submit' value='' class='register'>
  16. </form>
  17.  
  18. <form action='index' method='POST'>
  19. <input type='hidden' name='login' value='1'>
  20. <input type='submit' value='' class='login'>
  21. </form>";
  22.  
  23. echo "<br><br><br><br>";
  24.  
  25. if($_POST['register'])
  26. {
  27. echo
  28. "<form action='index' method='POST'>
  29. <input type='text' name='username' placeholder='* Username' maxlength='60' size='30'/><br>
  30. <input type='password' name='password' placeholder='* Password' size='30'/><br>
  31. <input type='email' name='email' placeholder='* Email' maxlength='60' size='30'/><br>
  32. <input type='text' name='nickname' placeholder='* Nickname' maxlength='60' size='30'/><br><br>
  33. <font class='outline' face='arial' color='red'><b>Fields marked with a * are required.</b></font><br><br>
  34. <input type='hidden' name='doregister' value='1'>
  35. <input type='submit' value='' class='continue'>
  36. </form>";
  37. }
  38. else if($_POST['login'])
  39. {
  40. echo
  41. "<form action='index' method='POST'>
  42. <input type='text' name='username' placeholder='Username' maxlength='60' size='30'/><br>
  43. <input type='password' name='password' placeholder='Password' size='30'/><br><br>
  44. <input type='hidden' name='dologin' value='1'>
  45. <input type='submit' value='' class='continue'>
  46. </form>";
  47. }
  48. else if($_POST['doregister'])
  49. {
  50. $username = $_POST['username'];
  51. $password = hash('whirlpool', $_POST['password']);
  52. $email = $_POST['email'];
  53. $nickname = $_POST['nickname'];
  54.  
  55. if($username && $password && email)
  56. {
  57. $query = mysql_query("SELECT `id` FROM `shop_accounts` WHERE `username` = '$username'");
  58.  
  59. if(!mysql_num_rows($query))
  60. {
  61. if(strpos($email, "@") !== false && strpos($email, ".") !== false)
  62. {
  63. $query = mysql_query("SELECT `id` FROM `shop_accounts` WHERE `email` = '$email'");
  64.  
  65. if(!mysql_num_rows($query))
  66. {
  67. $validateNumber1 = rand(1000000000, 2147483646);
  68. $validateNumber2 = rand(1000000000, 2147483646);
  69. $validateNumber3 = rand(1000000000, 2147483646);
  70. $validateNumber4 = rand(1000000000, 2147483646);
  71. $validateNumber5 = rand(1000000000, 2147483646);
  72. $validateKey = "$validateNumber1$validateNumber2$validateNumber3$validateNumber4$validateNumber5";
  73.  
  74. $query = mysql_query("SELECT `id` FROM `shop_accounts` WHERE `validatekey` = '$validateKey'");
  75.  
  76. while(mysql_num_rows())
  77. {
  78. $validateNumber1 = rand(1000000000, 2147483646);
  79. $validateNumber2 = rand(1000000000, 2147483646);
  80. $validateNumber3 = rand(1000000000, 2147483646);
  81. $validateNumber4 = rand(1000000000, 2147483646);
  82. $validateNumber5 = rand(1000000000, 2147483646);
  83. $validateKey = "$validateNumber1$validateNumber2$validateNumber3$validateNumber4$validateNumber5";
  84.  
  85. $query = mysql_query("SELECT `id` FROM `shop_accounts` WHERE `validatekey` = '$validateKey'");
  86. }
  87.  
  88. mysql_query("INSERT INTO `shop_accounts` (`username`, `password`, `email`, `validatekey`, `requirevalidate`, `nickname`) VALUES ('$username', '$password', '$email', '$validateKey', '1', '$nickname')");
  89. $_SESSION['accountid'] = mysql_insert_id();
  90. redirect("register", 0);
  91. }
  92. else echo "<font class='outline' face='arial' color='red'><b>That email address is already in use!</b></font>";
  93. }
  94. else echo "<font class='outline' face='arial' color='red'><b>You have entered an invalid email address!</b></font>";
  95. }
  96. else echo "<font class='outline' face='arial' color='red'><b>That account already exists!</b></font>";
  97. }
  98. else echo "<font class='outline' face='arial' color='red'><b>You must fill all of the fields!</b></font>";
  99. }
  100. else if($_POST['dologin'])
  101. {
  102. $username = $_POST['username'];
  103. $password = hash('whirlpool', $_POST['password']);
  104.  
  105. $query = mysql_query("SELECT `id`, `password` FROM `shop_accounts` WHERE `username` = '$username'");
  106.  
  107. if(mysql_num_rows($query))
  108. {
  109. $row = mysql_fetch_assoc($query);
  110.  
  111. $accountID = $row['id'];
  112. $accountPassword = $row['password'];
  113.  
  114. if($password == $accountPassword)
  115. {
  116. $_SESSION['accountid'] = $accountID;
  117. $_SESSION['loggedin'] = true;
  118. redirect("main", 0);
  119. }
  120. else echo "<font class='outline' face='arial' color='red'><b>The password you have entered is incorrect!</b></font>";
  121. }
  122. else echo "<font class='outline' face='arial' color='red'><b>That account does not exist!</b></font>";
  123. }
  124.  
  125. echo "</center>";
  126.  
  127. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement