QwikClock is an employee time tracking app.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

index.php 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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']) {
  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. $_SESSION['passok'] = true; // stop logins using only username and authcode
  35. if (userHasTOTP($VARS['username'])) {
  36. $multiauth = true;
  37. } else {
  38. doLoginUser($VARS['username'], $VARS['password']);
  39. header('Location: app.php');
  40. die("Logged in, go to app.php");
  41. }
  42. }
  43. } else {
  44. if (!is_empty($errmsg)) {
  45. $alert = lang2("login server error", ['arg' => $errmsg], false);
  46. } else {
  47. $alert = lang("login incorrect", false);
  48. }
  49. }
  50. } else {
  51. $alert = lang("captcha error", false);
  52. }
  53. } else if ($VARS['progress'] == "2") {
  54. if ($_SESSION['passok'] !== true) {
  55. // stop logins using only username and authcode
  56. sendError("Password integrity check failed!");
  57. }
  58. if (verifyTOTP($VARS['username'], $VARS['authcode'])) {
  59. if (doLoginUser($VARS['username'])) {
  60. header('Location: app.php');
  61. die("Logged in, go to app.php");
  62. } else {
  63. $alert = lang("login server user data error", false);
  64. }
  65. } else {
  66. $alert = lang("2fa incorrect", false);
  67. }
  68. }
  69. } else {
  70. $alert = lang("login server unavailable", false);
  71. }
  72. ?>
  73. <!DOCTYPE html>
  74. <html>
  75. <head>
  76. <meta charset="UTF-8">
  77. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  78. <meta name="viewport" content="width=device-width, initial-scale=1">
  79. <title><?php echo SITE_TITLE; ?></title>
  80. <link href="static/css/bootstrap.min.css" rel="stylesheet">
  81. <link href="static/css/font-awesome.min.css" rel="stylesheet">
  82. <link href="static/css/material-color/material-color.min.css" rel="stylesheet">
  83. <link href="static/css/app.css" rel="stylesheet">
  84. <?php if (RECAPTCHA_ENABLED) { ?>
  85. <script src='https://www.google.com/recaptcha/api.js'></script>
  86. <?php } ?>
  87. </head>
  88. <body>
  89. <div class="container">
  90. <div class="row">
  91. <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">
  92. <div>
  93. <?php
  94. if (SHOW_ICON == "both" || SHOW_ICON == "index") {
  95. ?>
  96. <img class="img-responsive banner-image" src="static/img/logo.png" />
  97. <?php } ?>
  98. </div>
  99. <div class="panel panel-primary">
  100. <div class="panel-heading">
  101. <h3 class="panel-title"><?php lang("sign in"); ?></h3>
  102. </div>
  103. <div class="panel-body">
  104. <form action="" method="POST">
  105. <?php
  106. if (!is_empty($alert)) {
  107. ?>
  108. <div class="alert alert-danger">
  109. <i class="fa fa-fw fa-exclamation-triangle"></i> <?php echo $alert; ?>
  110. </div>
  111. <?php
  112. }
  113. if ($multiauth != true) {
  114. ?>
  115. <input type="text" class="form-control" name="username" placeholder="<?php lang("username"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus /><br />
  116. <input type="password" class="form-control" name="password" placeholder="<?php lang("password"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /><br />
  117. <?php if (RECAPTCHA_ENABLED) { ?>
  118. <div class="g-recaptcha" data-sitekey="<?php echo RECAPTCHA_SITE_KEY; ?>"></div>
  119. <br />
  120. <?php } ?>
  121. <input type="hidden" name="progress" value="1" />
  122. <?php
  123. } else if ($multiauth) {
  124. ?>
  125. <div class="alert alert-info">
  126. <?php lang("2fa prompt"); ?>
  127. </div>
  128. <input type="text" class="form-control" name="authcode" placeholder="<?php lang("authcode"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus /><br />
  129. <input type="hidden" name="progress" value="2" />
  130. <input type="hidden" name="username" value="<?php echo $VARS['username']; ?>" />
  131. <?php
  132. }
  133. ?>
  134. <button type="submit" class="btn btn-primary">
  135. <?php lang("continue"); ?>
  136. </button>
  137. </form>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. <div class="footer">
  143. <?php echo LICENSE_TEXT; ?><br />
  144. Copyright &copy; <?php echo date('Y'); ?> <?php echo COPYRIGHT_NAME; ?>
  145. </div>
  146. </div>
  147. <script src="static/js/jquery-3.2.1.min.js"></script>
  148. <script src="static/js/bootstrap.min.js"></script>
  149. </body>
  150. </html>