QwikClock is an employee time tracking app.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. require_once __DIR__ . "/required.php";
  3. require_once __DIR__ . "/lib/login.php";
  4. // if we're logged in, we don't need to be here.
  5. if ($_SESSION['loggedin'] && account_has_permission($_SESSION['username'], "QWIKCLOCK")) {
  6. header('Location: app.php');
  7. }
  8. /* Authenticate user */
  9. $userpass_ok = false;
  10. $multiauth = false;
  11. if (checkLoginServer()) {
  12. if ($VARS['progress'] == "1") {
  13. if (!RECAPTCHA_ENABLED || (RECAPTCHA_ENABLED && verifyReCaptcha($VARS['g-recaptcha-response']))) {
  14. $errmsg = "";
  15. if (authenticate_user($VARS['username'], $VARS['password'], $errmsg)) {
  16. switch (get_account_status($VARS['username'])) {
  17. case "LOCKED_OR_DISABLED":
  18. $alert = lang("account locked", false);
  19. break;
  20. case "TERMINATED":
  21. $alert = lang("account terminated", false);
  22. break;
  23. case "CHANGE_PASSWORD":
  24. $alert = lang("password expired", false);
  25. case "NORMAL":
  26. $userpass_ok = true;
  27. break;
  28. case "ALERT_ON_ACCESS":
  29. sendLoginAlertEmail($VARS['username']);
  30. $userpass_ok = true;
  31. break;
  32. }
  33. if ($userpass_ok) {
  34. if (account_has_permission($VARS['username'], "QWIKCLOCK") == FALSE) {
  35. $alert = lang("no permission", false);
  36. } else {
  37. $_SESSION['passok'] = true; // stop logins using only username and authcode
  38. if (userHasTOTP($VARS['username'])) {
  39. $multiauth = true;
  40. } else {
  41. doLoginUser($VARS['username'], $VARS['password']);
  42. header('Location: app.php');
  43. die("Logged in, go to app.php");
  44. }
  45. }
  46. }
  47. } else {
  48. if (!is_empty($errmsg)) {
  49. $alert = lang2("login server error", ['arg' => $errmsg], false);
  50. } else {
  51. $alert = lang("login incorrect", false);
  52. }
  53. }
  54. } else {
  55. $alert = lang("captcha error", false);
  56. }
  57. } else if ($VARS['progress'] == "2") {
  58. if ($_SESSION['passok'] !== true) {
  59. // stop logins using only username and authcode
  60. sendError("Password integrity check failed!");
  61. }
  62. if (verifyTOTP($VARS['username'], $VARS['authcode'])) {
  63. if (doLoginUser($VARS['username'])) {
  64. header('Location: app.php');
  65. die("Logged in, go to app.php");
  66. } else {
  67. $alert = lang("login server user data error", false);
  68. }
  69. } else {
  70. $alert = lang("2fa incorrect", false);
  71. }
  72. }
  73. } else {
  74. $alert = lang("login server unavailable", false);
  75. }
  76. ?>
  77. <!DOCTYPE html>
  78. <html>
  79. <head>
  80. <meta charset="UTF-8">
  81. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  82. <meta name="viewport" content="width=device-width, initial-scale=1">
  83. <title><?php echo SITE_TITLE; ?></title>
  84. <link href="static/css/bootstrap.min.css" rel="stylesheet">
  85. <link href="static/css/font-awesome.min.css" rel="stylesheet">
  86. <link href="static/css/material-color/material-color.min.css" rel="stylesheet">
  87. <link href="static/css/app.css" rel="stylesheet">
  88. <?php if (RECAPTCHA_ENABLED) { ?>
  89. <script src='https://www.google.com/recaptcha/api.js'></script>
  90. <?php } ?>
  91. </head>
  92. <body>
  93. <div class="container">
  94. <div class="row">
  95. <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 col-sm-offset-3 col-md-offset-4 col-lg-offset-4">
  96. <div>
  97. <?php
  98. if (SHOW_ICON == "both" || SHOW_ICON == "index") {
  99. ?>
  100. <img class="img-responsive banner-image" src="static/img/logo.png" />
  101. <?php } ?>
  102. </div>
  103. <div class="panel panel-primary">
  104. <div class="panel-heading">
  105. <h3 class="panel-title"><?php lang("sign in"); ?></h3>
  106. </div>
  107. <div class="panel-body">
  108. <form action="" method="POST">
  109. <?php
  110. if (!is_empty($alert)) {
  111. ?>
  112. <div class="alert alert-danger">
  113. <i class="fa fa-fw fa-exclamation-triangle"></i> <?php echo $alert; ?>
  114. </div>
  115. <?php
  116. }
  117. if ($multiauth != true) {
  118. ?>
  119. <input type="text" class="form-control" name="username" placeholder="<?php lang("username"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus /><br />
  120. <input type="password" class="form-control" name="password" placeholder="<?php lang("password"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /><br />
  121. <?php if (RECAPTCHA_ENABLED) { ?>
  122. <div class="g-recaptcha" data-sitekey="<?php echo RECAPTCHA_SITE_KEY; ?>"></div>
  123. <br />
  124. <?php } ?>
  125. <input type="hidden" name="progress" value="1" />
  126. <?php
  127. } else if ($multiauth) {
  128. ?>
  129. <div class="alert alert-info">
  130. <?php lang("2fa prompt"); ?>
  131. </div>
  132. <input type="text" class="form-control" name="authcode" placeholder="<?php lang("authcode"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus /><br />
  133. <input type="hidden" name="progress" value="2" />
  134. <input type="hidden" name="username" value="<?php echo $VARS['username']; ?>" />
  135. <?php
  136. }
  137. ?>
  138. <button type="submit" class="btn btn-primary">
  139. <?php lang("continue"); ?>
  140. </button>
  141. </form>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. <div class="footer">
  147. <?php echo LICENSE_TEXT; ?><br />
  148. Copyright &copy; <?php echo date('Y'); ?> <?php echo COPYRIGHT_NAME; ?>
  149. </div>
  150. </div>
  151. <script src="static/js/jquery-3.2.1.min.js"></script>
  152. <script src="static/js/bootstrap.min.js"></script>
  153. </body>
  154. </html>