Guest User

Untitled

a guest
Feb 7th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. <?php
  2.  
  3. if (!($user -> LoggedIn()))
  4. {
  5. if (isset($_POST['logINBoss']))
  6. {
  7. $captcha = htmlspecialchars($_POST["g-recaptcha-response"]);
  8. $secret = $odb->query("SELECT `google_secret` FROM `admin` LIMIT 1")->fetchColumn(0);
  9. $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret."&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
  10. $response = json_decode($response);
  11. if (!$captcha || $response->success == false)
  12. {
  13. echo '<center><div class="alert alert-icon alert-warning alert-dismissible fade in" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><i class="mdi mdi-check-all"></i>Invalid Captcha Code</div></center>';
  14. } else {
  15. $username = htmlspecialchars($_POST['username']);
  16. $password = htmlspecialchars($_POST['password']);
  17. $errors = array();
  18. if (!ctype_alnum($username) || strlen($username) < 4 || strlen($username) > 15)
  19. {
  20. //$errors[] = 'Username Must Be Alphanumberic And 4-15 characters in length';
  21. }
  22.  
  23. if (empty($username) || empty($password))
  24. {
  25. $errors[] = '<center><div class="alert alert-icon alert-danger alert-dismissible fade in" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><i class="mdi mdi-check-all"></i>Fill in all fields.</div></center>">';
  26. }
  27. $SQL = $odb->prepare("SELECT `status` FROM `users` WHERE `username` = :username");
  28. $SQL->execute(array(':username' => $username));
  29. $status = $SQL->fetchColumn(0);
  30. if($status == 1)
  31. {
  32. $SQL = $odb->prepare("SELECT `reason` FROM `bans` WHERE `username` = :username");
  33. $SQL->execute(array(':username' => $username));
  34. $ban = $SQL->fetchColumn(0);
  35. header('location: banned.php');
  36. }
  37. if (empty($errors))
  38. {
  39. $SQLCheckLogin = $odb -> prepare("SELECT COUNT(*) FROM `users` WHERE `username` = :username AND `password` = :password");
  40. $SQLCheckLogin -> execute(array(':username' => $username, ':password' => SHA1($password)));
  41. $countLogin = $SQLCheckLogin -> fetchColumn(0);
  42. if ($countLogin == 1)
  43. {
  44. $SQLGetInfo = $odb -> prepare("SELECT `username`, `ID`, `status` FROM `users` WHERE `username` = :username AND `password` = :password");
  45. $SQLGetInfo -> execute(array(':username' => $username, ':password' => SHA1($password)));
  46. $userInfo = $SQLGetInfo -> fetch(PDO::FETCH_ASSOC);
  47. if ($countLogin == 1)
  48. {
  49. $logAddr = $odb->prepare("INSERT INTO `login_history` (`username`,`ip`,`date`,`http_agent`) VALUES (:user, :ip, UNIX_TIMESTAMP(NOW()), :agent);");
  50. $logAddr->execute(array( ":user" => $username, ":ip" => $_SERVER['REMOTE_ADDR'], ":agent" => $_SERVER['HTTP_USER_AGENT']));
  51. htmlspecialchars($_SESSION['username'] = $userInfo['username']);
  52. htmlspecialchars($_SESSION['ID'] = $userInfo['ID']);
  53. echo '<center><div class="alert alert-icon alert-success alert-dismissible fade in" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><i class="mdi mdi-check-all"></i>Login Successful!</div></center><meta http-equiv="refresh" content="1;url=index.php">';
  54. }
  55. else
  56. {
  57. echo '<center><div class="alert alert-icon alert-danger alert-dismissible fade in" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><i class="mdi mdi-check-all"></i>You are Banned!</div></center>';
  58. }
  59. }
  60. else
  61. {
  62. echo '<center><div class="alert alert-icon alert-warning alert-dismissible fade in" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><i class="mdi mdi-check-all"></i>Login Failed!</div></center>';
  63. }
  64. }
  65. else
  66. {
  67. echo '<div class="alert alert-danger"><p><strong>ERROR:</strong><br />';
  68. foreach($errors as $error)
  69. {
  70. echo '-'.htmlspecialchars_decode($error).'<br />';
  71. }
  72. echo '</div>';
  73. }
  74. }
  75. }
  76. }
  77.  
  78. ?>
Add Comment
Please, Sign In to add comment