login.php 1.3 KB

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