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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. require_once __DIR__ . "/required.php";
  6. require_once __DIR__ . "/lib/login.php";
  7. // if we're logged in, we don't need to be here.
  8. if ($_SESSION['loggedin']) {
  9. header('Location: app.php');
  10. }
  11. /* Authenticate user */
  12. $userpass_ok = false;
  13. $multiauth = false;
  14. if (checkLoginServer()) {
  15. if ($VARS['progress'] == "1") {
  16. if (!CAPTCHA_ENABLED || (CAPTCHA_ENABLED && verifyCaptcheck($VARS['captcheck_session_code'], $VARS['captcheck_selected_answer'], CAPTCHA_SERVER . "/api.php"))) {
  17. $errmsg = "";
  18. if (authenticate_user($VARS['username'], $VARS['password'], $errmsg)) {
  19. switch (get_account_status($VARS['username'])) {
  20. case "LOCKED_OR_DISABLED":
  21. $alert = lang("account locked", false);
  22. break;
  23. case "TERMINATED":
  24. $alert = lang("account terminated", false);
  25. break;
  26. case "CHANGE_PASSWORD":
  27. $alert = lang("password expired", false);
  28. case "NORMAL":
  29. $userpass_ok = true;
  30. break;
  31. case "ALERT_ON_ACCESS":
  32. sendLoginAlertEmail($VARS['username']);
  33. $userpass_ok = true;
  34. break;
  35. }
  36. if ($userpass_ok) {
  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. } else {
  47. if (!is_empty($errmsg)) {
  48. $alert = lang2("login server error", ['arg' => $errmsg], false);
  49. } else {
  50. $alert = lang("login incorrect", false);
  51. }
  52. }
  53. } else {
  54. $alert = lang("captcha error", false);
  55. }
  56. } else if ($VARS['progress'] == "2") {
  57. if ($_SESSION['passok'] !== true) {
  58. // stop logins using only username and authcode
  59. sendError("Password integrity check failed!");
  60. }
  61. if (verifyTOTP($VARS['username'], $VARS['authcode'])) {
  62. if (doLoginUser($VARS['username'])) {
  63. header('Location: app.php');
  64. die("Logged in, go to app.php");
  65. } else {
  66. $alert = lang("login server user data error", false);
  67. }
  68. } else {
  69. $alert = lang("2fa incorrect", false);
  70. }
  71. }
  72. } else {
  73. $alert = lang("login server unavailable", false);
  74. }
  75. header("Link: <static/fonts/Roboto.css>; rel=preload; as=style", false);
  76. header("Link: <static/css/bootstrap.min.css>; rel=preload; as=style", false);
  77. header("Link: <static/css/material-color/material-color.min.css>; rel=preload; as=style", false);
  78. header("Link: <static/css/index.css>; rel=preload; as=style", false);
  79. header("Link: <static/js/jquery-3.3.1.min.js>; rel=preload; as=script", false);
  80. header("Link: <static/js/bootstrap.min.js>; rel=preload; as=script", false);
  81. ?>
  82. <!DOCTYPE html>
  83. <html>
  84. <head>
  85. <meta charset="UTF-8">
  86. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  87. <meta name="viewport" content="width=device-width, initial-scale=1">
  88. <title><?php echo SITE_TITLE; ?></title>
  89. <link rel="icon" href="static/img/logo.svg">
  90. <link href="static/css/bootstrap.min.css" rel="stylesheet">
  91. <link href="static/css/material-color/material-color.min.css" rel="stylesheet">
  92. <link href="static/css/index.css" rel="stylesheet">
  93. <?php if (CAPTCHA_ENABLED) { ?>
  94. <script src="<?php echo CAPTCHA_SERVER ?>/captcheck.dist.js"></script>
  95. <?php } ?>
  96. </head>
  97. <body>
  98. <div class="row justify-content-center">
  99. <div class="col-auto">
  100. <img class="banner-image" src="static/img/logo.svg" />
  101. </div>
  102. </div>
  103. <div class="row justify-content-center">
  104. <div class="card col-11 col-xs-11 col-sm-8 col-md-6 col-lg-4">
  105. <div class="card-body">
  106. <h5 class="card-title"><?php lang("sign in"); ?></h5>
  107. <form action="" method="POST">
  108. <?php
  109. if (!is_empty($alert)) {
  110. ?>
  111. <div class="alert alert-danger">
  112. <i class="fa fa-fw fa-exclamation-triangle"></i> <?php echo $alert; ?>
  113. </div>
  114. <?php
  115. }
  116. if ($multiauth != true) {
  117. ?>
  118. <input type="text" class="form-control" name="username" placeholder="<?php lang("username"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus /><br />
  119. <input type="password" class="form-control" name="password" placeholder="<?php lang("password"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /><br />
  120. <?php if (CAPTCHA_ENABLED) { ?>
  121. <div class="captcheck_container" data-stylenonce="<?php echo $SECURE_NONCE; ?>"></div>
  122. <br />
  123. <?php } ?>
  124. <input type="hidden" name="progress" value="1" />
  125. <?php
  126. } else if ($multiauth) {
  127. ?>
  128. <div class="alert alert-info">
  129. <?php lang("2fa prompt"); ?>
  130. </div>
  131. <input type="text" class="form-control" name="authcode" placeholder="<?php lang("authcode"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus /><br />
  132. <input type="hidden" name="progress" value="2" />
  133. <input type="hidden" name="username" value="<?php echo $VARS['username']; ?>" />
  134. <?php
  135. }
  136. ?>
  137. <button type="submit" class="btn btn-primary">
  138. <?php lang("continue"); ?>
  139. </button>
  140. </form>
  141. </div>
  142. </div>
  143. </div>
  144. <div class="footer">
  145. <?php echo FOOTER_TEXT; ?><br />
  146. Copyright &copy; <?php echo date('Y'); ?> <?php echo COPYRIGHT_NAME; ?>
  147. </div>
  148. </div>
  149. <script src="static/js/jquery-3.3.1.min.js"></script>
  150. <script src="static/js/bootstrap.min.js"></script>
  151. </body>
  152. </html>