index.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. include_once ('includes/checklogin.php');
  3. include_once ('tools/htpasswd.php');
  4. include_once ('includes/head.php');
  5. include_once ('includes/nav.php');
  6. $htpasswd = new htpasswd ( $ini ['secure_path'] . ".htpasswd" ); // path to your .htpasswd file
  7. ?>
  8. <div class="container box">
  9. <div class="row">
  10. <div class="col-xs-12">
  11. <?php
  12. echo "<h2>" . $ini ['app_title'] . "</h2>";
  13. if (isset ( $_POST ['user'] )) {
  14. $username = $_POST ['user'];
  15. $passwd = $_POST ['pwd'];
  16. if (!check_username($username) || !check_password_quality($passwd)) {
  17. ?>
  18. <div class="alert alert-danger">
  19. <?php
  20. echo "<p>User <em>" . htmlspecialchars ( $username ) . "</em> is invalid!.</p>";
  21. } else {
  22. ?>
  23. <div class="alert alert-info">
  24. <?php
  25. if (! $htpasswd->user_exists ( $username )) {
  26. $htpasswd->user_add ( $username, $passwd );
  27. echo "<p>User <em>" . htmlspecialchars ( $username ) . "</em> created.</p>";
  28. } else {
  29. $htpasswd->user_update ( $username, $passwd );
  30. echo "<p>User <em>" . htmlspecialchars ( $username ) . "</em> changed.</p>";
  31. }
  32. }
  33. ?>
  34. </div>
  35. <?php
  36. }
  37. ?>
  38. <div class="result alert alert-info" style="display: none;"></div>
  39. </div>
  40. </div>
  41. <div class=row>
  42. <div class="col-xs-12 col-md-4">
  43. <h3>Create or change user and password:</h3>
  44. <form class="navbar-form navbar-left" action="index.php"
  45. method="post">
  46. <div class="form-group">
  47. <input type="text" class="userfield form-control"
  48. placeholder="Username" name="user">
  49. </p>
  50. <p>
  51. <input class="passwordfield form-control" type="password"
  52. name="pwd" placeholder="Password" />
  53. </p>
  54. <button type="submit" class="btn btn-default">Submit</button>
  55. </div>
  56. </form>
  57. </div>
  58. <div class="col-xs-12 col-md-6">
  59. <h3>Users found:</h3>
  60. <ul class="list-group">
  61. <?php
  62. $users = $htpasswd->get_users ();
  63. foreach ( $users as $user ) {
  64. echo "<li class='list-group-item list-item-with-button id-" . htmlspecialchars ( $user ) . "' onclick=\"setUserField('" . $user . "');\">" . htmlspecialchars ( $user ) . "<a class='btn btn-danger btn-list-item pull-right' " . "onclick=\"deleteUser('" . $user . "');\"" . "href='#' >Delete</a>" . "</li>\n";
  65. }
  66. ?>
  67. </ul>
  68. </div>
  69. </div>
  70. <div class=row>
  71. <br/><br/>
  72. <div class="col-xs-12 col-md-10 well">
  73. <p>Create new users for the htpasswd file here. A user can change his/her password with this <a href="selfservice.php">self service link.</a><br/>
  74. You can fill the username in the form if you add the url parameter user=&lt;username&gt;</p>
  75. </div>
  76. </div>
  77. </div>
  78. <?php
  79. include_once ('includes/footer.php');
  80. ?>