Packet-Fence/admin/user/token_exp.php
2025-06-28 06:23:17 +05:30

54 lines
1.8 KiB
PHP

<?php
session_start();
if (!isset($_SESSION['redirect_page'])) {
$_SESSION['redirect_page'] = $_SERVER['REQUEST_URI'];
}
$tokenExpiredOrMissing = false;
$token = $_SESSION['token'] ?? null;
$tokenExpiry = $_SESSION['token_expiry'] ?? 0;
if (!$token || time() > $tokenExpiry) {
$tokenExpiredOrMissing = true;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../css/popup.css">
<title>Token Check</title>
</head>
<body>
<div id="popup_token" class="popup_token">
<span type="button" onclick="closePopup()" class="close">&times;</span>
<form id="form" action="../elements/login.php" method="POST">
<input type="text" name="username" placeholder="Enter User Firstname" required />
<input type="password" name="password" placeholder="Enter Password" required />
<button type="submit">Submit</button>
</form>
</div>
<div class="blur-background"></div>
<script>
function closePopup() {
document.getElementById('popup_token').classList.remove('show');
document.querySelector('.blur-background').style.display = 'none';
}
window.onload = function() {
<?php if ($tokenExpiredOrMissing): ?>
document.getElementById('popup_token').classList.add('show');
document.querySelector('.blur-background').style.display = 'block';
<?php endif; ?>
}
// Prevent form submission on Enter key press
document.getElementById('form').addEventListener('keydown', function(event) {
if (event.key === 'Enter') {
event.preventDefault();
}
});
</script>
</body>
</html>