LuminaWebsite/includes/site_notice.php
Maaxxs 62d6634829 Impressum and privacy policy, third-party videos and images load only after a click
- impressum.php (§ 18 MStV) and datenschutz.php, which describes what the website and the Discord bot
  actually process: Discord login scopes, member area, bot data (raids, premades, player reports with the
  automatic 48 h timeout, activity checks), cookies and browser storage keys, retention periods and rights.
  Both stay reachable in maintenance mode and are noindex. Operator data defaults to the c/o address of the
  Impressum service Online-Impressum.de (LEGAL_OPERATOR_DEFAULT), the hoster to Living-Bots; both can be
  changed under Admin -> Impressum & Datenschutz (new permission site.legal, schema v43). The audit/Discord
  log only records which fields changed, not the name or address.
- Links in the footer of all public pages, the start page footer, the sidebar and the maintenance page,
  plus a short data notice on the login page.
- Wiki and profile texts: YouTube, Twitch and Vimeo players and images or video files from other servers
  render as placeholders and load only after a click (embed_consent_html(), assets/js/embed-consent.js).
  "immer direkt laden" is remembered per provider in localStorage and can be reset in the privacy policy.
  Image URLs are now protected from inline formatting (e.g. _underscores_ in the address).
- map_frame.php only serves logged-in, active members.
- Deleting a user also removes the avatar file; audit_log entries older than 12 months are deleted
  automatically (AUDIT_LOG_KEEP_MONTHS).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 16:26:54 +02:00

178 lines
7.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
/**
* Wartungsmodus und Ankuendigungsbanner (Verwaltung unter admin/site.php).
*
* Wartungsmodus: sperrt die Website fuer alle ohne site.maintenance - sie sehen eine
* Wartungsseite. Anmelden bleibt moeglich (damit die Leitung hineinkommt), ebenso der
* Rueckkanal fuer den Bot.
*
* Ankuendigung: grosses Banner oben auf jeder Seite des Mitgliederbereichs (optional auch
* oeffentlich). Mitglieder koennen es wegklicken - ausser es ist "dringend".
* Beides liegt in der Tabelle settings.
*/
const ANNOUNCEMENT_LEVELS = [
'info' => 'Info',
'warning' => 'Wichtig',
'urgent' => 'Dringend',
];
// Skripte, die auch im Wartungsmodus fuer alle erreichbar bleiben - Impressum und
// Datenschutzerklaerung muessen staendig verfuegbar sein.
const MAINTENANCE_ALLOWED_SCRIPTS = [
'login.php', 'logout.php', 'discord_login.php', 'discord_callback.php', 'bot_api.php', 'install.php',
'impressum.php', 'datenschutz.php',
];
function maintenance_active(): bool
{
return setting_get('maintenance_mode') === '1';
}
/** Darf das aktuelle Konto die Website trotz Wartung benutzen? */
function maintenance_bypass(): bool
{
return current_user() !== null && user_has_permission('site.maintenance');
}
/**
* Laeuft in der bootstrap: ist die Wartung aktiv und das Konto darf nicht vorbei, endet der
* Aufruf hier mit der Wartungsseite (bzw. JSON fuer Skripte, die per fetch() aufgerufen werden).
*/
function maintenance_gate(): void
{
if (!maintenance_active()) {
return;
}
$script = basename((string) ($_SERVER['SCRIPT_NAME'] ?? ''));
if (in_array($script, MAINTENANCE_ALLOWED_SCRIPTS, true) || maintenance_bypass()) {
return;
}
http_response_code(503);
header('Retry-After: 900');
$message = trim(setting_get('maintenance_message'));
$accept = (string) ($_SERVER['HTTP_ACCEPT'] ?? '');
$contentType = (string) ($_SERVER['CONTENT_TYPE'] ?? '');
if (str_contains($accept, 'application/json') || str_contains($contentType, 'application/json')) {
json_response(false, 'Die Website ist gerade im Wartungsmodus. ' . ($message !== '' ? $message : 'Bitte versuche es später noch einmal.'));
}
$user = current_user();
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noindex">
<title>Wartungsarbeiten - Lumina Ascendens</title>
<link rel="icon" type="image/x-icon" href="<?= e(asset_url('/assets/images/favicon.ico')) ?>">
<link rel="stylesheet" href="<?= e(asset_url('/assets/css/style.css')) ?>">
</head>
<body class="guest-bg">
<main class="maintenance-page">
<div class="panel maintenance-card">
<img src="<?= e(asset_url('/assets/images/logo-lumina-ascendens.webp')) ?>" alt="Lumina Ascendens" width="410" height="168" class="maintenance-logo">
<div class="maintenance-icon" aria-hidden="true">🔧</div>
<h1>Wartungsarbeiten</h1>
<p><?= $message !== '' ? nl2br(e($message)) : 'Wir arbeiten gerade an der Website. Bitte schau in Kürze wieder vorbei.' ?></p>
<p class="text-muted">Neuigkeiten gibt es solange in unserem Discord.</p>
<div class="maintenance-actions">
<?php if ($user): ?>
<a class="button button-secondary" href="/logout.php">Abmelden</a>
<?php else: ?>
<a class="button button-secondary" href="/login.php">Anmelden (Leitung)</a>
<?php endif; ?>
</div>
<?= legal_links_html('legal-links maintenance-legal') ?>
</div>
</main>
</body>
</html>
<?php
exit;
}
/**
* Die aktuelle Ankuendigung, wenn es eine gibt und sie nicht abgelaufen ist.
*
* @return array{id: string, title: string, text: string, level: string, until: string, public: bool, by: string}|null
*/
function announcement_current(): ?array
{
$text = trim(setting_get('announcement_text'));
$title = trim(setting_get('announcement_title'));
if ($text === '' && $title === '') {
return null;
}
$until = setting_get('announcement_until');
if ($until !== '' && strtotime($until) !== false && strtotime($until) <= time()) {
return null;
}
$level = setting_get('announcement_level');
return [
'id' => setting_get('announcement_id'),
'title' => $title,
'text' => $text,
'level' => isset(ANNOUNCEMENT_LEVELS[$level]) ? $level : 'info',
'until' => $until,
'public' => setting_get('announcement_public') === '1',
// Autor nur, wenn er beim Speichern nicht ausgeblendet wurde ('0'); aeltere Ankuendigungen zeigen ihn
'by' => setting_get('announcement_show_author') === '0' ? '' : setting_get('announcement_by'),
];
}
/** Text der Ankuendigung als HTML: Zeilenumbrueche und klickbare Links (https://...). */
function announcement_html(string $text): string
{
$html = nl2br(e($text));
return (string) preg_replace_callback(
'~https?://[^\s<]+~u',
static fn (array $m): string => '<a href="' . $m[0] . '" target="_blank" rel="noopener">' . $m[0] . '</a>',
$html
);
}
/**
* Banner-HTML fuer den Seitenkopf. $dismissedId: users.announcement_dismissed (null bei Gaesten -
* die koennen es nicht wegklicken).
*/
function announcement_banner(array $announcement, ?string $dismissedId, bool $loggedIn): string
{
$canDismiss = $loggedIn && $announcement['level'] !== 'urgent';
if ($canDismiss && $dismissedId !== null && $dismissedId === $announcement['id']) {
return '';
}
$icons = ['info' => '📢', 'warning' => '⚠️', 'urgent' => '🚨'];
ob_start();
?>
<section class="site-announcement site-announcement-<?= e($announcement['level']) ?>" role="<?= $announcement['level'] === 'urgent' ? 'alert' : 'status' ?>">
<div class="site-announcement-icon" aria-hidden="true"><?= $icons[$announcement['level']] ?></div>
<div class="site-announcement-body">
<div class="site-announcement-label"><?= e(ANNOUNCEMENT_LEVELS[$announcement['level']]) ?></div>
<?php if ($announcement['title'] !== ''): ?>
<h2><?= e($announcement['title']) ?></h2>
<?php endif; ?>
<?php if ($announcement['text'] !== ''): ?>
<p><?= announcement_html($announcement['text']) ?></p>
<?php endif; ?>
<?php if ($announcement['by'] !== ''): ?>
<div class="site-announcement-by">– <?= e($announcement['by']) ?></div>
<?php endif; ?>
</div>
<?php if ($canDismiss): ?>
<form method="post" action="/announcement_dismiss.php" class="site-announcement-close">
<?= csrf_field() ?>
<input type="hidden" name="id" value="<?= e($announcement['id']) ?>">
<input type="hidden" name="back" value="<?= e((string) ($_SERVER['REQUEST_URI'] ?? '/dashboard.php')) ?>">
<button type="submit" class="icon-button" title="Gelesen - ausblenden"><?= icon('x') ?></button>
</form>
<?php endif; ?>
</section>
<?php
return (string) ob_get_clean();
}