login.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. session_start();
  3. include_once ('tools/util.php');
  4. include_once ('tools/htpasswd.php');
  5. $ini = read_config();
  6. if (isset ( $_POST ['user'] ) && isset ( $_POST ['password'] )) {
  7. $username = $_POST ['user'];
  8. $password = $_POST ['password'];
  9. if ($username == $ini['admin_user'] && htpasswd::check_password_hash($password,$ini['admin_pwd_hash'])) {
  10. $_SESSION ['login'] = true;
  11. header ( 'LOCATION:index.php' );
  12. die ();
  13. }
  14. $error = 'Invalid user or password!';
  15. }
  16. include_once ('includes/head.php');
  17. include_once ('includes/nav.php');
  18. ?>
  19. <div class="container box">
  20. <div class="row">
  21. <div class="col-xs-12">
  22. <h2>Please Login:</h2>
  23. <?php
  24. if (isset ( $error )) {
  25. ?>
  26. <div class="alert alert-danger">
  27. <?php
  28. echo "<p>" . $error . "</p>";
  29. ?>
  30. </div>
  31. <?php
  32. }
  33. ?>
  34. <form class="navbar-form navbar-left" action="login.php" method="post">
  35. <div class="form-group">
  36. <p>Login:</p>
  37. <input type="text" class="form-control" placeholder="Username"
  38. name="user">
  39. </p>
  40. <p>
  41. <input class="form-control" type="password" name="password"
  42. placeholder="Password" />
  43. </p>
  44. <button type="submit" class="btn btn-default">Login</button>
  45. </div>
  46. </form>
  47. </div>
  48. </div>
  49. </div>
  50. <?php
  51. include_once ('includes/footer.php');
  52. ?>