Upload via GUI (258 Dateien)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* staff/session_ping.php
|
||||
*
|
||||
* Wird vom Frontend per fetch() aufgerufen wenn der Nutzer aktiv ist.
|
||||
* Aktualisiert staff_last_activity und gibt die verbleibende Zeit zurück.
|
||||
*/
|
||||
require_once __DIR__ . '/../includes/bootstrap.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Nur POST erlauben
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
http_response_code(405);
|
||||
echo json_encode(['error' => 'Method not allowed']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Muss eingeloggt sein
|
||||
if (empty($_SESSION['staff_id'])) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['error' => 'Nicht eingeloggt', 'remaining' => 0]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$timeout = (int)(get_setting('staff_session_timeout', '30') ?: 30);
|
||||
$last = $_SESSION['staff_last_activity'] ?? 0;
|
||||
$elapsed = time() - $last;
|
||||
|
||||
// Abgelaufen? Dann nicht mehr verlängern
|
||||
if ($last && $elapsed > ($timeout * 60)) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['error' => 'Session abgelaufen', 'remaining' => 0]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Aktivität erneuern
|
||||
$_SESSION['staff_last_activity'] = time();
|
||||
$remaining = $timeout * 60;
|
||||
|
||||
echo json_encode(['ok' => true, 'remaining' => $remaining]);
|
||||
Reference in New Issue
Block a user