Adds session expiration debug message
parent
d67e376220
commit
bbceb44c3d
|
|
@ -4,13 +4,74 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<!-- Footer -->
|
|
||||||
<div id="footer">Jilo Web <?= htmlspecialchars($config['version']) ?> ©2024-<?= date('Y') ?> - web interface for <a href="https://lindeas.com/jilo">Jilo</a></div>
|
|
||||||
<!-- /Footer -->
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
// Preparing the remaining session time debug message
|
||||||
|
$sessionDebugMarkup = '';
|
||||||
|
if (Session::getUsername()) {
|
||||||
|
$canSeeSessionDebug = false;
|
||||||
|
if (isset($userId, $userObject) && method_exists($userObject, 'hasRight')) {
|
||||||
|
$canSeeSessionDebug = ($userId === 1) || (bool)$userObject->hasRight($userId, 'superuser');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($canSeeSessionDebug) {
|
||||||
|
Session::startSession();
|
||||||
|
$remember = !empty($_SESSION['REMEMBER_ME']);
|
||||||
|
$timeoutSeconds = $remember ? (30 * 24 * 60 * 60) : 7200;
|
||||||
|
$lastActivity = $_SESSION['LAST_ACTIVITY'] ?? null;
|
||||||
|
|
||||||
|
$remainingLabel = 'Session activity timestamp unavailable.';
|
||||||
|
$expiresAtLabel = 'unknown expiry';
|
||||||
|
|
||||||
|
if ($lastActivity !== null) {
|
||||||
|
$elapsed = time() - (int)$lastActivity;
|
||||||
|
$secondsRemaining = max(0, $timeoutSeconds - $elapsed);
|
||||||
|
|
||||||
|
$days = intdiv($secondsRemaining, 86400);
|
||||||
|
$hours = intdiv($secondsRemaining % 86400, 3600);
|
||||||
|
$minutes = intdiv($secondsRemaining % 3600, 60);
|
||||||
|
$seconds = $secondsRemaining % 60;
|
||||||
|
|
||||||
|
$parts = [];
|
||||||
|
if ($days > 0) {
|
||||||
|
$parts[] = $days . ' ' . ($days === 1 ? 'day' : 'days');
|
||||||
|
}
|
||||||
|
if ($hours > 0) {
|
||||||
|
$parts[] = $hours . ' ' . ($hours === 1 ? 'hour' : 'hours');
|
||||||
|
}
|
||||||
|
if ($minutes > 0) {
|
||||||
|
$parts[] = $minutes . ' ' . ($minutes === 1 ? 'minute' : 'minutes');
|
||||||
|
}
|
||||||
|
if ($seconds > 0 || empty($parts)) {
|
||||||
|
$parts[] = $seconds . ' ' . ($seconds === 1 ? 'second' : 'seconds');
|
||||||
|
}
|
||||||
|
|
||||||
|
$remainingLabel = implode(' ', $parts);
|
||||||
|
$expiresAtLabel = date('Y-m-d H:i:s', time() + $secondsRemaining);
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
?>
|
||||||
|
<span class="tm-session-debug">
|
||||||
|
<strong>Session debug:</strong>
|
||||||
|
<?= $remember ? 'Remember-me' : 'Standard' ?> session expires in <?= htmlspecialchars($remainingLabel) ?> (<?= htmlspecialchars($expiresAtLabel) ?>)
|
||||||
|
</span>
|
||||||
|
<?php
|
||||||
|
$sessionDebugMarkup = ob_get_clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
<div id="footer">
|
||||||
|
« <?= htmlspecialchars($config['site_name'] . (!empty($config['site_slogan']) ? ' - ' . ucfirst($config['site_slogan']) : '')) ?> »
|
||||||
|
v.<?= htmlspecialchars($config['version']) ?> © 2024-<?= date('Y') ?> — web interface for <a href="https://lindeas.com/jilo">Jilo</a>
|
||||||
|
<?php if ($sessionDebugMarkup !== ''): ?>
|
||||||
|
<?= $sessionDebugMarkup ?>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- /Footer -->
|
||||||
|
|
||||||
<?php if (Session::getUsername() && $page !== 'logout') { ?>
|
<?php if (Session::getUsername() && $page !== 'logout') { ?>
|
||||||
<script src="static/js/sidebar.js"></script>
|
<script src="static/js/sidebar.js"></script>
|
||||||
|
|
@ -42,6 +103,5 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,13 @@
|
||||||
|
.tm-session-debug {
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 1rem;
|
||||||
|
background: #fff3cd;
|
||||||
|
color: #533f03;
|
||||||
|
border: 1px solid #ffe69c;
|
||||||
|
border-radius: 0.4rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
.tm-profile-view {
|
.tm-profile-view {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue