- Every open page in the member area asks live.php every 20 s while it is visible (assets/js/live.js). The counts at the menu items and the own Lumipunkte are replaced in place; header.php and live.php compute them with the same functions (nav_badges(), nav_points() in includes/live_updates.php, links marked with data-badge). - Dashboard, gallery, picture page, profile, member list, calendar, shop, shop orders, Lumipunkte, warehouse, premades, bug reports, moderation, user management and wiki get a fingerprint of the data they show (count, highest id, checksum of the shown columns - no "last active"). When it changes, the page reloads - but only while nobody is typing, has a form started, a dialog, lightbox or menu open or clicked in the last 8 s; otherwise a notice "Es gibt Neues auf dieser Seite" with a reload button, and it reloads once things are quiet. At most 3 automatic reloads per minute. - Tools and forms (map, gear planner, edit pages) never reload on their own; the raid page keeps its own live updates. The dashboard notices new raids and signups through the raid cache (now also stores a fingerprint of dates, slots and signups); premades ask the bot with a 3 s timeout (new timeout parameter for premades_api_request/fetch_premades). - README and patch notes updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.3 KiB
PHP
34 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Live-Aktualisierung im Mitgliederbereich (assets/js/live.js fragt alle 20 Sekunden nach, solange die
|
|
* Seite zu sehen ist):
|
|
*
|
|
* GET /live.php?path=/gallery.php&q=<Query der Seite, z.B. id=5>
|
|
*
|
|
* Antwort: die Zahlen an den Menuepunkten, der eigene Punktestand und der Fingerabdruck der Seite
|
|
* (null = die Seite aktualisiert sich nicht selbst) - siehe includes/live_updates.php.
|
|
*/
|
|
require_once __DIR__ . '/includes/bootstrap.php';
|
|
require_once __DIR__ . '/includes/live_updates.php';
|
|
|
|
// Wird per fetch() aufgerufen - Fehler deshalb als JSON statt Weiterleitung auf die Login-Seite.
|
|
$user = current_user();
|
|
if (!$user || $user['status'] !== 'active') {
|
|
http_response_code(401);
|
|
json_response(false, 'Bitte neu anmelden.');
|
|
}
|
|
// Sitzung gleich freigeben, damit ein gleichzeitiger Seitenaufruf derselben Person nicht wartet
|
|
session_write_close();
|
|
|
|
$path = (string) ($_GET['path'] ?? '');
|
|
if (!preg_match('#^(/[\w-]+)+\.php$#', $path)) {
|
|
$path = '';
|
|
}
|
|
parse_str((string) ($_GET['q'] ?? ''), $params);
|
|
|
|
header('Cache-Control: no-store');
|
|
json_response(true, '', [
|
|
'badges' => (object) nav_badges($user, basename($path)),
|
|
'points' => nav_points((int) $user['id']),
|
|
'fp' => $path !== '' ? live_fingerprint($path, $params, (int) $user['id']) : null,
|
|
]);
|