Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.69 KB | None | 0 0
  1. <?php
  2.  
  3. ob_start();
  4.  
  5. if(file_exists("install.php") == "1"){
  6. header('Location: install.php');
  7. exit();
  8. }
  9.  
  10. include 'inc/database.php';
  11.  
  12. $result = mysqli_query($con, "SELECT * FROM `settings` LIMIT 1") or die(mysqli_error($con));
  13. while($row = mysqli_fetch_assoc($result)){
  14. $website = $row['website'];
  15. $favicon = $row['favicon'];
  16. }
  17.  
  18. if (!isset($_SESSION)) {
  19. session_start();
  20. }
  21.  
  22. if (isset($_SESSION['username'])) {
  23. header('Location: index.php');
  24. exit();
  25. }
  26.  
  27. if(isset($_POST['username']) && isset($_POST['password'])){
  28.  
  29. $username = mysqli_real_escape_string($con, $_POST['username']);
  30. $password = mysqli_real_escape_string($con, md5($_POST['password']));
  31.  
  32. $result = mysqli_query($con, "SELECT * FROM `users` WHERE `username` = '$username'") or die(mysqli_error($con));
  33. if(mysqli_num_rows($result) < 1){
  34. header("Location: login.php?error=incorrect-password");
  35. }
  36. while($row = mysqli_fetch_array($result)){
  37. if($password != $row['password']){
  38. header("Location: login.php?error=incorrect-password");
  39. }elseif($row['status'] == "0"){
  40. header("Location: login.php?error=banned");
  41. }else{
  42. $_SESSION['id'] = $row['id'];
  43. $_SESSION['username'] = $username;
  44. $_SESSION['email'] = $row['email'];
  45. $_SESSION['rank'] = $row['rank'];
  46. header("Location: index.php");
  47. }
  48. }
  49.  
  50. }
  51.  
  52. ?>
  53.  
  54. <!DOCTYPE html>
  55. <html lang="en">
  56. <head>
  57. <meta charset="utf-8">
  58. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  59. <meta name="description" content="">
  60. <meta name="author" content="24/7">
  61. <meta name="keyword" content="">
  62. <link rel="shortcut icon" href="<?php echo $favicon;?>">
  63.  
  64. <title><?php echo $website;?> - Login</title>
  65.  
  66. <!-- Bootstrap core CSS -->
  67. <link href="css/bootstrap.min.css" rel="stylesheet">
  68. <link href="css/bootstrap-reset.css" rel="stylesheet">
  69. <!--external css-->
  70. <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
  71. <!-- Custom styles for this template -->
  72. <link href="css/style.css" rel="stylesheet">
  73. <link href="css/style-responsive.css" rel="stylesheet" />
  74.  
  75. <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
  76. <!--[if lt IE 9]>
  77. <script src="js/html5shiv.js"></script>
  78. <script src="js/respond.min.js"></script>
  79. <![endif]-->
  80.  
  81. </head>
  82.  
  83. <body class="login-body">
  84.  
  85. <div class="container">
  86.  
  87. <form class="form-signin" action="login.php" method="POST">
  88. <h2 class="form-signin-heading"><?php echo $website;?></h2>
  89. <div class="login-wrap">
  90. <input type="text" id="username" name="username" class="form-control" placeholder="Username" autofocus>
  91. <input type="password" id="password" name="password" class="form-control" placeholder="Password">
  92. <button class="btn btn-lg btn-login btn-block" type="submit">Sign in</button>
  93. </form>
  94. <div class="registration">
  95. Don't have an account yet?
  96. <a class="" href="register.php">
  97. Create an account
  98. </a>
  99. </div>
  100.  
  101. </div>
  102.  
  103. </div>
  104.  
  105. <?php
  106. if($_GET['error'] == "banned"){
  107. echo '
  108. <div class="modal fade" id="error" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-hidden="true" style="padding-top: 15%; overflow-y: visible; display: none;">
  109. <div class="modal-dialog modal-sm">
  110. <div class="modal-content panel-danger">
  111. <div class="modal-header panel-heading">
  112. <center><h3 style="margin:0;"><i class="icon-warning-sign"></i> Error!</h3></center>
  113. </div>
  114. <div class="modal-body">
  115. <center>
  116. <strong>Your account has been banned.</strong>
  117. </center>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. ';
  123. }
  124.  
  125. if($_GET['error'] == "incorrect-password"){
  126. echo '
  127. <div class="modal fade" id="error" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-hidden="true" style="padding-top: 15%; overflow-y: visible; display: none;">
  128. <div class="modal-dialog modal-sm">
  129. <div class="modal-content panel-danger">
  130. <div class="modal-header panel-heading">
  131. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  132. <center><h3 style="margin:0;"><i class="icon-warning-sign"></i> Error!</h3></center>
  133. </div>
  134. <div class="modal-body">
  135. <center>
  136. <strong>The password you entered was not correct.</strong>
  137. </center>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. ';
  143. }
  144.  
  145. if($_GET['error'] == "not-logged-in"){
  146. echo '
  147. <div class="modal fade" id="error" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-hidden="true" style="padding-top: 15%; overflow-y: visible; display: none;">
  148. <div class="modal-dialog modal-sm">
  149. <div class="modal-content panel-warning">
  150. <div class="modal-header panel-heading">
  151. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  152. <center><h3 style="margin:0;"><i class="icon-warning-sign"></i> Error!</h3></center>
  153. </div>
  154. <div class="modal-body">
  155. <center>
  156. <strong>You must be logged in to do that.</strong>
  157. </center>
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. ';
  163. }
  164. ?>
  165.  
  166. <!-- js placed at the end of the document so the pages load faster -->
  167. <script src="js/jquery.js"></script>
  168. <script src="js/bootstrap.min.js"></script>
  169.  
  170. <?php
  171. if(isset($_GET['error'])){
  172. echo "<script type='text/javascript'>
  173. $(document).ready(function(){
  174. $('#error').modal('show');
  175. });
  176. </script>"
  177. ;
  178. }
  179. ?>
  180.  
  181. </body>
  182. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement