Started Logs: Login attempts are now logged, created a logs list in the side nav

This commit is contained in:
johnny@pittpc.com
2019-09-06 00:16:19 -04:00
parent e47853f9cd
commit d259d1b3dc
7 changed files with 138 additions and 6 deletions

View File

@@ -7,6 +7,16 @@ if(!file_exists('config.php')){
?>
<?php include("config.php"); ?>
<?php include("functions.php"); ?>
<?php
$ip = get_ip();
$os = get_os();
$browser = get_web_browser();
$device = get_device();
?>
<?php
@@ -25,9 +35,12 @@ if(isset($_POST['login'])){
$token = $row['token'];
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['name'] = $row['name'];
$name = $row['name'];
$user_id = $row['user_id'];
if(empty($token)){
$_SESSION['logged'] = TRUE;
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login Successful', log_description = '$name successfully logged in from $ip using $os | $browser on a $device', log_created_at = NOW(), user_id = $user_id");
header("Location: dashboard.php");
}else{
@@ -35,9 +48,12 @@ if(isset($_POST['login'])){
if(TokenAuth6238::verify($token,$current_code)){
$_SESSION['logged'] = TRUE;
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login Successful', log_description = '$name successfully logged in with 2FA from $ip using $os | $browser on a $device', log_created_at = NOW(), user_id = $user_id");
//header("Location: $config_start_page");
header("Location: dashboard.php");
}else{
mysqli_query($mysqli,"INSERT INTO logs SET log_type = '2FA Login Failed', log_description = '$name failed 2FA from $ip using $os | $browser on a $device', log_created_at = NOW(), user_id = $user_id");
$response = "
<div class='alert alert-danger'>
Invalid Code.
@@ -48,6 +64,8 @@ if(isset($_POST['login'])){
}
}else{
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login Failed', log_description = '$email failed to login from $ip using $os | $browser on a $device', log_created_at = NOW()");
$response = "
<div class='alert alert-danger'>
Incorrect email or password.