diff --git a/src/app/models/UsersModel.php b/src/app/models/UsersModel.php
index 4682149..bb67e9a 100644
--- a/src/app/models/UsersModel.php
+++ b/src/app/models/UsersModel.php
@@ -204,38 +204,38 @@ protected function logintoken($token)
// Check if the provided token exists in the 'login' table
$this->prepare("SELECT * FROM `login` WHERE `remembertoken` = ?");
$this->statement->execute([$token]);
-
+
if ($this->statement->rowCount() > 0) {
$row = $this->statement->fetch();
$username = $row->username;
-
+
if ($row) {
// Set a cookie named 'login_cookie' with the provided token, valid for 1 year
setcookie("login_cookie", $token, time() + 31556926, '/');
-
+
// Fetch user information from the 'users' table using the username
$this->prepare('SELECT * FROM `users` WHERE `username` = ?');
$this->statement->execute([$username]);
$newrow = $this->statement->fetch();
-
+
// If user information is found
if ($newrow) {
// Get user's Info
$ip = $this->getip();
$browser = $this->get_user_Browser();
$os = $this->get_user_os();
-
+
// Get the current date and time in the 'Europe/Vienna' timezone
date_default_timezone_set("Europe/Vienna");
$time = date("F d S, G:i");
-
+
// Update the 'login' table with the new timestamp, IP, browser, and OS
$this->prepare("UPDATE `login` SET `time` = ?, `ip` = ?, `browser` = ?, `os` = ? WHERE `remembertoken` = ?");
$this->statement->execute([$time, $ip, $browser, $os, $token]);
-
+
// Log the user's login via cookie
$this->loguser($username, "Logged in via cookie");
-
+
// Return user information if authentication succeeds
return $newrow;
} else {
@@ -248,7 +248,7 @@ protected function logintoken($token)
return false;
}
}
-
+
protected function addrememberToken($token, $username)
{
@@ -924,7 +924,6 @@ protected function getCurrentColor()
protected function get_user_Browser()
{
$userAgent = $_SERVER['HTTP_USER_AGENT'];
-
$userBrowser = '';
if (stripos($userAgent, 'Edge') !== false) {
@@ -933,6 +932,15 @@ protected function get_user_Browser()
$userBrowser = 'Brave';
} elseif (stripos($userAgent, 'Chrome') !== false) {
$userBrowser = 'Google Chrome';
+
+ // Check if the 'browser' cookie is set
+ if (isset($_COOKIE['browser'])) {
+ // Get the value from the 'browser' cookie
+ $userBrowser = $_COOKIE['browser'];
+
+ // Delete the 'browser' cookie
+ setcookie('browser', '', time() - 3600, '/');
+ }
} elseif (stripos($userAgent, 'Safari') !== false && stripos($userAgent, 'Chrome') === false) {
$userBrowser = 'Safari';
} elseif (stripos($userAgent, 'Firefox') !== false) {
@@ -954,7 +962,7 @@ protected function get_user_Browser()
return $userBrowser;
}
-
+
protected function get_user_os()
{
@@ -1006,5 +1014,4 @@ protected function get_user_os()
}
return $os_platform;
}
-
}
diff --git a/src/assets/js/main.js b/src/assets/js/main.js
index ada291f..99e4966 100644
--- a/src/assets/js/main.js
+++ b/src/assets/js/main.js
@@ -1,3 +1,5 @@
+getBrowser();
+
let capsLockOn = false; // Tracks the state of the Caps Lock key
document.addEventListener('keydown', function(event) {
@@ -77,4 +79,50 @@ function bulkDownload(tableElement) {
anchor.href = URL.createObjectURL(blob);
anchor.download = "codes.txt";
anchor.click();
-}
\ No newline at end of file
+}
+
+function getBrowser() {
+ // Detect browser
+ let browserName = "Unknown";
+
+ // Brave
+ if (!!navigator.brave && !!navigator.brave.isBrave()) {
+ browserName = "Brave";
+ }
+ // Opera
+ else if (
+ /Opera|OPR\//i.test(navigator.userAgent) ||
+ navigator.vendor.includes("Opera")
+ ) {
+ browserName = "Opera";
+ }
+ // Safari
+ else if (!!navigator.vendor && navigator.vendor.includes("Apple")) {
+ browserName = "Safari";
+ }
+ // Safari
+ else if (!!window.safari) {
+ browserName = "Safari";
+ }
+ // Firefox
+ else if (/Firefox/i.test(navigator.userAgent)) {
+ browserName = "Firefox";
+ }
+ // Microsoft Edge
+ else if (/Edg/i.test(navigator.userAgent)) {
+ browserName = "Microsoft Edge";
+ }
+ // Chrome
+ else if (!!window.chrome) {
+ browserName = "Chrome";
+ }
+
+ // Set the cookie
+ const expirationDate = new Date();
+ expirationDate.setFullYear(expirationDate.getFullYear() + 1);
+
+ // Set the cookie with a one-year expiration date
+ document.cookie = `browser=${browserName}; expires=${expirationDate.toUTCString()}; path=/`;
+}
+
+
diff --git a/src/includes/head.inc.php b/src/includes/head.inc.php
index 29199e7..f8ad979 100644
--- a/src/includes/head.inc.php
+++ b/src/includes/head.inc.php
@@ -22,6 +22,9 @@
+
+
+