| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  | <?php | 
					
						
							|  |  |  | require_once __DIR__ . "/required.php"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require_once __DIR__ . "/lib/login.php"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-02 19:17:59 -06:00
										 |  |  | // if we're logged in, we don't need to be here.
 | 
					
						
							|  |  |  | if ($_SESSION['loggedin']) { | 
					
						
							|  |  |  |     header('Location: app.php'); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  | /* Authenticate user */ | 
					
						
							|  |  |  | $userpass_ok = false; | 
					
						
							|  |  |  | $multiauth = false; | 
					
						
							| 
									
										
										
										
											2017-04-26 00:46:36 -06:00
										 |  |  | if (checkLoginServer()) { | 
					
						
							|  |  |  |     if ($VARS['progress'] == "1") { | 
					
						
							| 
									
										
										
										
											2017-05-02 19:17:59 -06:00
										 |  |  |         if (!RECAPTCHA_ENABLED || (RECAPTCHA_ENABLED && verifyReCaptcha($VARS['g-recaptcha-response']))) { | 
					
						
							| 
									
										
										
										
											2017-05-06 23:20:18 -06:00
										 |  |  |             $errmsg = ""; | 
					
						
							|  |  |  |             if (authenticate_user($VARS['username'], $VARS['password'], $errmsg)) { | 
					
						
							| 
									
										
										
										
											2017-05-02 19:17:59 -06:00
										 |  |  |                 switch (get_account_status($VARS['username'])) { | 
					
						
							|  |  |  |                     case "LOCKED_OR_DISABLED": | 
					
						
							|  |  |  |                         $alert = lang("account locked", false); | 
					
						
							|  |  |  |                         break; | 
					
						
							|  |  |  |                     case "TERMINATED": | 
					
						
							|  |  |  |                         $alert = lang("account terminated", false); | 
					
						
							|  |  |  |                         break; | 
					
						
							|  |  |  |                     case "CHANGE_PASSWORD": | 
					
						
							|  |  |  |                         $alert = lang("password expired", false); | 
					
						
							|  |  |  |                     case "NORMAL": | 
					
						
							|  |  |  |                         $userpass_ok = true; | 
					
						
							|  |  |  |                         break; | 
					
						
							|  |  |  |                     case "ALERT_ON_ACCESS": | 
					
						
							|  |  |  |                         sendLoginAlertEmail($VARS['username']); | 
					
						
							|  |  |  |                         $userpass_ok = true; | 
					
						
							|  |  |  |                         break; | 
					
						
							| 
									
										
										
										
											2017-04-26 00:46:36 -06:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2017-05-02 19:17:59 -06:00
										 |  |  |                 if ($userpass_ok) { | 
					
						
							|  |  |  |                     $_SESSION['passok'] = true; // stop logins using only username and authcode
 | 
					
						
							|  |  |  |                     if (userHasTOTP($VARS['username'])) { | 
					
						
							|  |  |  |                         $multiauth = true; | 
					
						
							|  |  |  |                     } else { | 
					
						
							|  |  |  |                         doLoginUser($VARS['username'], $VARS['password']); | 
					
						
							|  |  |  |                         header('Location: app.php'); | 
					
						
							|  |  |  |                         die("Logged in, go to app.php"); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2017-05-06 23:20:18 -06:00
										 |  |  |                 if (!is_empty($errmsg)) { | 
					
						
							|  |  |  |                     $alert = lang2("login server error", ['arg' => $errmsg], false); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     $alert = lang("login incorrect", false); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2017-04-26 00:46:36 -06:00
										 |  |  |             } | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2017-05-02 19:17:59 -06:00
										 |  |  |             $alert = lang("captcha error", false); | 
					
						
							| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-26 00:46:36 -06:00
										 |  |  |     } else if ($VARS['progress'] == "2") { | 
					
						
							| 
									
										
										
										
											2017-05-02 19:17:59 -06:00
										 |  |  |         if ($_SESSION['passok'] !== true) { | 
					
						
							|  |  |  |             // stop logins using only username and authcode
 | 
					
						
							|  |  |  |             sendError("Password integrity check failed!"); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-26 00:46:36 -06:00
										 |  |  |         if (verifyTOTP($VARS['username'], $VARS['authcode'])) { | 
					
						
							|  |  |  |             if (doLoginUser($VARS['username'])) { | 
					
						
							| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  |                 header('Location: app.php'); | 
					
						
							|  |  |  |                 die("Logged in, go to app.php"); | 
					
						
							| 
									
										
										
										
											2017-04-26 00:46:36 -06:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 $alert = lang("login server user data error", false); | 
					
						
							| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-04-25 18:22:27 -06:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2017-04-26 00:46:36 -06:00
										 |  |  |             $alert = lang("2fa incorrect", false); | 
					
						
							| 
									
										
										
										
											2017-04-25 18:22:27 -06:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-04-26 00:46:36 -06:00
										 |  |  | } else { | 
					
						
							|  |  |  |     $alert = lang("login server unavailable", false); | 
					
						
							| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  | } | 
					
						
							|  |  |  | ?>
 | 
					
						
							|  |  |  | <!DOCTYPE html> | 
					
						
							|  |  |  | <html> | 
					
						
							|  |  |  |     <head> | 
					
						
							|  |  |  |         <meta charset="UTF-8"> | 
					
						
							|  |  |  |         <meta http-equiv="X-UA-Compatible" content="IE=edge"> | 
					
						
							| 
									
										
										
										
											2017-05-04 00:14:08 -06:00
										 |  |  |         <meta name="viewport" content="width=device-width, initial-scale=1"> | 
					
						
							| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |         <title><?php echo SITE_TITLE; ?></title>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-16 14:36:03 -07:00
										 |  |  |         <link rel="icon" href="static/img/logo.svg"> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  |         <link href="static/css/bootstrap.min.css" rel="stylesheet"> | 
					
						
							| 
									
										
										
										
											2017-11-07 15:21:14 -07:00
										 |  |  |         <link href="static/css/material-color/material-color.min.css" rel="stylesheet"> | 
					
						
							| 
									
										
										
										
											2018-01-27 19:18:38 -07:00
										 |  |  |         <link href="static/css/index.css" rel="stylesheet"> | 
					
						
							| 
									
										
										
										
											2017-05-02 19:17:59 -06:00
										 |  |  |         <?php if (RECAPTCHA_ENABLED) { ?>
 | 
					
						
							|  |  |  |             <script src='https://www.google.com/recaptcha/api.js'></script> | 
					
						
							|  |  |  |         <?php } ?>
 | 
					
						
							| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  |     </head> | 
					
						
							|  |  |  |     <body> | 
					
						
							| 
									
										
										
										
											2018-01-27 19:18:38 -07:00
										 |  |  |         <div class="row justify-content-center"> | 
					
						
							|  |  |  |             <div class="col-auto"> | 
					
						
							|  |  |  |                 <img class="banner-image" src="static/img/logo.png" /> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |         <div class="row justify-content-center"> | 
					
						
							|  |  |  |             <div class="card col-11 col-xs-11 col-sm-8 col-md-6 col-lg-4"> | 
					
						
							|  |  |  |                 <div class="card-body"> | 
					
						
							|  |  |  |                     <h5 class="card-title"><?php lang("sign in"); ?></h5>
 | 
					
						
							|  |  |  |                     <form action="" method="POST"> | 
					
						
							| 
									
										
										
										
											2017-04-25 18:22:27 -06:00
										 |  |  |                         <?php | 
					
						
							| 
									
										
										
										
											2018-01-27 19:18:38 -07:00
										 |  |  |                         if (!is_empty($alert)) { | 
					
						
							| 
									
										
										
										
											2017-04-25 18:22:27 -06:00
										 |  |  |                             ?>
 | 
					
						
							| 
									
										
										
										
											2018-01-27 19:18:38 -07:00
										 |  |  |                             <div class="alert alert-danger"> | 
					
						
							|  |  |  |                                 <i class="fa fa-fw fa-exclamation-triangle"></i> <?php echo $alert; ?>
 | 
					
						
							|  |  |  |                             </div> | 
					
						
							|  |  |  |                             <?php | 
					
						
							|  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-27 19:18:38 -07:00
										 |  |  |                         if ($multiauth != true) { | 
					
						
							|  |  |  |                             ?>
 | 
					
						
							|  |  |  |                             <input type="text" class="form-control" name="username" placeholder="<?php lang("username"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus /><br /> | 
					
						
							|  |  |  |                             <input type="password" class="form-control" name="password" placeholder="<?php lang("password"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /><br /> | 
					
						
							|  |  |  |                             <?php if (RECAPTCHA_ENABLED) { ?>
 | 
					
						
							|  |  |  |                                 <div class="g-recaptcha" data-sitekey="<?php echo RECAPTCHA_SITE_KEY; ?>"></div> | 
					
						
							|  |  |  |                                 <br /> | 
					
						
							|  |  |  |                             <?php } ?>
 | 
					
						
							|  |  |  |                             <input type="hidden" name="progress" value="1" /> | 
					
						
							|  |  |  |                             <?php | 
					
						
							|  |  |  |                         } else if ($multiauth) { | 
					
						
							|  |  |  |                             ?>
 | 
					
						
							|  |  |  |                             <div class="alert alert-info"> | 
					
						
							|  |  |  |                                 <?php lang("2fa prompt"); ?>
 | 
					
						
							|  |  |  |                             </div> | 
					
						
							|  |  |  |                             <input type="text" class="form-control" name="authcode" placeholder="<?php lang("authcode"); ?>" required="required" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" autofocus /><br /> | 
					
						
							|  |  |  |                             <input type="hidden" name="progress" value="2" /> | 
					
						
							|  |  |  |                             <input type="hidden" name="username" value="<?php echo $VARS['username']; ?>" /> | 
					
						
							|  |  |  |                             <?php | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                         ?>
 | 
					
						
							|  |  |  |                         <button type="submit" class="btn btn-primary"> | 
					
						
							|  |  |  |                             <?php lang("continue"); ?>
 | 
					
						
							|  |  |  |                         </button> | 
					
						
							|  |  |  |                     </form> | 
					
						
							| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  |                 </div> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |         </div> | 
					
						
							| 
									
										
										
										
											2018-01-27 19:18:38 -07:00
										 |  |  |         <div class="footer"> | 
					
						
							|  |  |  |             <?php echo FOOTER_TEXT; ?><br />
 | 
					
						
							|  |  |  |             Copyright © <?php echo date('Y'); ?> <?php echo COPYRIGHT_NAME; ?>
 | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |     <script src="static/js/jquery-3.3.1.min.js"></script> | 
					
						
							|  |  |  |     <script src="static/js/bootstrap.min.js"></script> | 
					
						
							|  |  |  | </body> | 
					
						
							| 
									
										
										
										
											2017-04-24 17:13:08 -06:00
										 |  |  | </html> |