Advertisement
Guest User

Untitled

a guest
Oct 5th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.34 KB | None | 0 0
  1. <?php
  2. require_once("config.php");
  3. session_start();
  4. if(isset($_SESSION["user"]) && !empty($_SESSION["user"])){
  5. exit(header("Location: /panel/index.php"));
  6. }
  7.  
  8. if(isset($_POST["submit"])){
  9.  
  10. if(!isset($_POST["user"]) || empty($_POST["user"])){
  11. $_SESSION["errorx"] = "You Need To Insert Your Username And Password!";
  12. exit(header("Location: /panel/login.php"));
  13. }else if(!isset($_POST["pass"]) || empty($_POST["pass"])){
  14. $_SESSION["errorx"] = "You Need To Insert Your Username And Password!";
  15. exit(header("Location: /panel/login.php"));
  16. }else{
  17. $servername = "localhost";
  18. $username = "root";
  19. $password = "oGM0zotOMn098GimSfGCnWhHS8Nyr94chQHJaGg2B55LpgAfu-";
  20.  
  21. try {
  22. $conn = new PDO("mysql:host=$servername;dbname=booter", $username, $password);
  23. // set the PDO error mode to exception
  24. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  25. echo "Connected successfully";
  26. }
  27. catch(PDOException $e)
  28. {
  29. echo "Connection failed: " . $e->getMessage();
  30. }
  31. $user = $con->real_escape_string(htmlspecialchars(stripslashes(strip_tags($_POST["user"]))));
  32. $pass = md5($con->real_escape_string(htmlspecialchars(stripslashes(strip_tags($_POST["pass"])))));
  33. $sql = "SELECT id, firstname, lastname FROM MyGuests";
  34. $result = $conn->query($sql);
  35. if($res->num_rows === 1){
  36.  
  37. $data = $res->fetch_assoc();
  38. $act = $data["active"];
  39. $id = $data["id"];
  40.  
  41. if(intval($act) === 0){
  42. $_SESSION["errorx"] = "This account has been disabled";
  43. exit(header("Location: /panel/login.php"));
  44. }
  45.  
  46. $_SESSION["errorx"] = 0;
  47. $_SESSION["userx"] = $user;
  48. $ipx = strval(getremoteip());
  49. $uuid = sha1(time() + mt_rand(200, 99999))."X".md5(mt_rand(100,999)."".mt_rand(100,999));
  50. $_SESSION["uuid"] = strval($uuid);
  51. $sql = "UPDATE users SET lastip='$ipx',uuid='$uuid' WHERE id='$id'";
  52. $conn->query($sql);
  53. $conn->close();
  54. exit(header("Location: /panel/login.php"));
  55. }else{
  56. $_SESSION["errorx"] = "Invalid Username Or Password!";
  57. exit(header("Location: /panel/login.php"));
  58. }
  59. $con->close();
  60. }
  61.  
  62. exit(header("Location: login.php"));
  63. }
  64.  
  65. ?>
  66. <!DOCTYPE html>
  67. <html lang="en">
  68. <head>
  69. <title>MCSpam - Login</title>
  70. <meta charset="utf-8">
  71. <meta name="viewport" content="width=device-width, initial-scale=1">
  72. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  73. <link rel="stylesheet" type="text/css" href="style.css">
  74. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  75. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  76. <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  77. </head>
  78. <body>
  79. <?php
  80. if(isset($_SESSION["errorx"]) && isset($_SESSION["userx"]) && !empty($_SESSION["userx"]) && intval($_SESSION["errorx"]) === 0){
  81. unset($_SESSION["errorx"]);
  82. $user = ucfirst(strtolower($_SESSION["userx"]));
  83. unset($_SESSION["userx"]);
  84. echo "<script>
  85. swal({
  86. title: 'Success!',
  87. text: 'You Logged In Succesfuly And Will Be Redirected....',
  88. icon: 'success',
  89. button: 'Continue',
  90. });
  91. </script>";
  92. $_SESSION["user"] = $user;
  93. header("refresh:2;url=/panel/index.php");
  94. }else if(isset($_SESSION["errorx"]) && !empty($_SESSION["errorx"])){
  95. $error = strval($_SESSION["errorx"]);
  96. unset($_SESSION["errorx"]);
  97. echo "<script>
  98. swal({
  99. title: 'Error Occurred!',
  100. text: '$error',
  101. icon: 'error',
  102. button: 'Continue',
  103. });
  104. </script>";
  105. }
  106. ?>
  107. <div class="container-fluid bg">
  108. <div class="row">
  109. <div class="col-md-4 col-sm-4 col-xs-12"></div>
  110. <div class="col-md-4 col-sm-4 col-xs-12">
  111. <form class="form-cont" method="post">
  112. <h1>Account Login</h1>
  113. <div class="form-group">
  114. <label for="user">Username</label>
  115. <input type="text" class="form-control" name="user" id="user" required>
  116. </div>
  117. <div class="form-group">
  118. <label for="pass">Password</label>
  119. <input type="password" class="form-control" name="pass" id="pass" required>
  120. </div>
  121. <div class="checkbox">
  122. <label>
  123. <input type="checkbox" checked> Remeber Me
  124. </label>
  125. </div>
  126. <button type="submit" name="submit" class="btn btn-success btn-block">Login</button><br/>
  127. <a class="text-center" style="color: #e84118; font-size: 18px; font-weight: bold;" href="register.php">I don't have An Account?</a>
  128. <a class="text-center" style="color: #e84118; font-size: 18px; font-weight: bold;" href="https://discord.me/">I Forget password? Contact Discord Server</a>
  129. </form>
  130. </div>
  131. <div class="col-md-4 col-sm-4 col-xs-12"></div>
  132. </div>
  133. </div>
  134.  
  135. </body>
  136. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement