diff --git a/README.md b/README.md index a07a216..c6b6b87 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ und wird später ausgebaut. Fokus dieser Version ist der Mitglieder-/Admin-Berei - Jeder Benutzer kann mehreren Berechtigungsgruppen angehören - Events-Seite: geplante (wiederkehrende) Event-Erinnerungen des Bots ansehen, anlegen, bearbeiten und löschen - synchron mit `/event_planen` / `/event_liste` im Discord -- Karte: interaktive Zoom-Karte aller Regionen (Verteron, Altgard, Elthen, Morheim, Poeta, +- Karte: interaktive Zoom-Karte aller Regionen (Verteron, Altgard, Eltnen, Morheim, Poeta, Ishalgen, Reshanta) mit Markern und Kategorie-Filtern, dazu Taktiken in Schritten, die direkt auf die Karte gezeichnet werden - Lumipunkte: Punkte für Raids, Events und andere Aktivitäten an einzelne oder viele @@ -334,10 +334,10 @@ Bot-Prozess neu gestartet werden. ### Karte Die Seite **Karte** (`map.php`) zeigt eine interaktive Karte aller Regionen: Verteron, -Altgard, Elthen, Morheim, Poeta, Ishalgen, Abyss Reshanta A/B sowie Chaotic Middle/Upper +Altgard, Eltnen, Morheim, Poeta, Ishalgen, Abyss Reshanta A/B sowie Chaotic Middle/Upper Reshanta. Oben wird die Region gewählt, unten links lassen sich die Marker-Kategorien (Orte, Monster, NPCs, Ressourcen, Sammelbares, Quests …) einzeln, gruppenweise oder mit -„Alle anzeigen“/„Alle verstecken“ auf einmal ein- und ausblenden, beim Überfahren eines Markers erscheint sein Name. Zoomen per Mausrad, `+`/`-` +„Alle anzeigen“/„Alle verstecken“ auf einmal ein- und ausblenden (beim Öffnen sind alle versteckt), beim Überfahren eines Markers erscheint sein Name. Zoomen per Mausrad, `+`/`-` oder die Knöpfe oben rechts, verschieben per Ziehen, `0` setzt die Ansicht zurück. Der Viewer ist ein eigenständiges Paket (HTML/CSS/JS ohne Bibliotheken) unter `assets/map/` @@ -352,7 +352,7 @@ hochgeladen werden. Er stammt aus dem Kartenpaket `Aion2_Map_In_Gut_BonzenEditio und lassen sich mit den Scripten unter `assets/map/scripts/` neu herunterladen. Details dazu stehen in `assets/map/README.md`. -Für Verteron, Altgard, Elthen, Morheim, Abyss Reshanta A sowie Chaotic Middle/Upper Reshanta +Für Verteron, Altgard, Eltnen, Morheim, Abyss Reshanta A sowie Chaotic Middle/Upper Reshanta gibt es Marker, Poeta, Ishalgen und Abyss Reshanta B zeigen nur die Karte. #### Taktiken @@ -655,6 +655,16 @@ werden klickbar. Löschen dürfen Verfasser, Bild-Besitzer und wer `comments.mod (siehe „Moderation“ unten). Jedes Mitglied kann Kommentare unter den eigenen Bildern beim Bearbeiten der Profilseite abschalten (`users.gallery_comments_enabled`). +**Reaktionen** wie bei Discord gibt es direkt am Bild und unter jedem Kommentar: Klick auf 😀+ +öffnet die Emoji-Auswahl, Klick auf eine vorhandene Reaktion reagiert mit bzw. nimmt die eigene +zurück, beim Überfahren steht, wer reagiert hat. Nur die Emojis aus `REACTION_EMOJIS` +(`includes/reactions.php`), ohne Neuladen über `assets/js/reactions.js`. Die Vorschaubilder +im Profil zeigen die häufigsten Reaktionen. Abschalten geht zusammen mit den Kommentaren. + +In der Mitgliederliste steht bei jedem, wann er **zuletzt aktiv** war (grüner Punkt = in den +letzten 10 Minuten online), sortierbar über „Zuletzt aktiv“; ebenso auf der Profilseite. +Gespeichert in `users.last_seen_at`, höchstens alle 5 Minuten aktualisiert. + ## Wiki (Einsteiger-Guide) Unter **Wiki** im Menü liegt der Einsteiger-Guide der Legion: Kapitel mit Unterseiten, @@ -745,6 +755,19 @@ sichtbar - erst nach Freigabe sichtbar (für alle außer Verfasser und Moderatio Die Moderation kann freigeben, ausblenden, Meldungen verwerfen oder löschen - alles landet im Audit- und Discord-Log. Grenzen: `MODERATION_TRUST_DAYS`, `MODERATION_REPORT_THRESHOLD`. +Die Seite hat drei Reiter: + +- **Freigabe:** wartende und gemeldete Inhalte. +- **Alle Kommentare:** jeder Kommentar mit Suche und Filtern; Auffälliges ist markiert - rot + (wartet auf Freigabe, gemeldet, Filterwort), gelb (Link, neues Mitglied, nur Großbuchstaben, + Zeichen-Spam). +- **Schimpfwortfilter:** Wortliste, die die Moderation selbst pflegt (Tabelle + `moderation_words`, beim ersten Aufruf mit einer Startliste befüllt). Pro Wort: *nur + markieren*, *zur Freigabe zurückhalten* oder *blockieren* (wird gar nicht gespeichert, landet + im Log). Gilt für Kommentare und Bildunterschriften, ganze Wörter; mit `*` auch Wortteile + (`fick*`). Schreibweisen wie „f1ck“ oder „fiiick“ werden erkannt. Die Moderation selbst ist + ausgenommen. + ## Fehlerseite (404) Nicht vorhandene Seiten und Seiten **ohne Berechtigung** zeigen dieselbe 404-Seite diff --git a/assets/css/style.css b/assets/css/style.css index 3a89788..a8e4ae3 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -5162,3 +5162,149 @@ input[type="file"]::file-selector-button { .moderation-reports { list-style: none; margin: 0; padding: 0; font-size: 0.82rem; display: flex; flex-direction: column; gap: 0.2rem; } .moderation-reports .icon { width: 13px; height: 13px; color: #ed4245; vertical-align: -2px; } .moderation-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.2rem; } + +/* Moderation: Reiter, Markierungen, Schimpfwortfilter */ +.moderation-tabs { margin-top: 1rem; } +.moderation-tabs a { text-decoration: none; } +.moderation-comment.is-critical { border-color: rgba(237, 66, 69, 0.55); background: rgba(237, 66, 69, 0.06); } +.moderation-comment.is-flagged { border-color: rgba(240, 178, 50, 0.45); } +.moderation-flags { display: flex; flex-wrap: wrap; gap: 0.35rem; } +.mod-flag { padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; } +.mod-flag-critical { background: rgba(237, 66, 69, 0.18); color: #ff8a8c; } +.mod-flag-warning { background: rgba(240, 178, 50, 0.16); color: #f0b232; } + +.filter-word-form { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 0.6rem; } +.filter-word-form input[type="text"] { flex: 1 1 220px; } +.filter-word-form select { width: auto; } +.filter-word-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; } +.filter-word-heading { display: flex; align-items: center; gap: 0.5rem; margin: 1.2rem 0 0.5rem; font-size: 1rem; } +.filter-word-list { display: flex; flex-wrap: wrap; gap: 0.4rem; } +.filter-word { + display: inline-flex; + align-items: center; + gap: 0.35rem; + margin: 0; + padding: 0.2rem 0.3rem 0.2rem 0.7rem; + border-radius: 999px; + border: 1px solid var(--border); + font-size: 0.85rem; +} +.filter-word-legend .filter-word { padding: 0.1rem 0.6rem; } +.filter-word-flag { background: rgba(240, 178, 50, 0.1); border-color: rgba(240, 178, 50, 0.4); } +.filter-word-hold { background: rgba(88, 101, 242, 0.12); border-color: rgba(88, 101, 242, 0.5); } +.filter-word-block { background: rgba(237, 66, 69, 0.12); border-color: rgba(237, 66, 69, 0.5); } +.filter-word select { width: auto; padding: 0 0.2rem; font-size: 0.75rem; background: transparent; border: none; color: var(--text-muted); cursor: pointer; } +.filter-word-remove { padding: 0 0.45rem; min-width: 0; background: transparent; border: none; color: var(--text-muted); font-size: 1rem; line-height: 1; cursor: pointer; } +.filter-word-remove:hover { color: #ed4245; background: transparent; } + +/* ---- Reaktionen (Emojis) wie bei Discord ---- */ +.picture-reactions { display: flex; justify-content: center; margin-top: 0.8rem; } +.reaction-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-top: 0.45rem; } +.reaction-bar.is-busy { opacity: 0.6; pointer-events: none; } +.reaction-form { display: inline; margin: 0; } +.reaction { + display: inline-flex; + align-items: center; + gap: 0.3rem; + min-width: 0; + padding: 0.15rem 0.55rem; + border-radius: 8px; + border: 1px solid transparent; + background: rgba(255, 255, 255, 0.06); + color: var(--text); + font-size: 0.9rem; + line-height: 1.4; + cursor: pointer; + transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease; +} +.reaction:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.18); } +.reaction.is-mine { background: rgba(88, 101, 242, 0.22); border-color: #5865f2; } +.reaction.is-mine .reaction-count { color: #c9cdfb; } +.reaction-count { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); } +.reaction.pop { animation: reaction-pop 0.25s ease; } +@keyframes reaction-pop { 50% { transform: scale(1.18); } } +span.reaction { cursor: default; } + +.reaction-add { position: relative; } +.reaction-add > summary { list-style: none; } +.reaction-add > summary::-webkit-details-marker { display: none; } +.reaction-add-button { opacity: 0.65; } +.reaction-add-button:hover, .reaction-add[open] .reaction-add-button { opacity: 1; } +.reaction-plus { font-weight: 700; font-size: 0.8rem; margin-left: -0.15rem; } +.reaction-bar-compact .reaction-add-button { opacity: 0; } +.comment:hover .reaction-bar-compact .reaction-add-button, +.reaction-bar-compact .reaction-add[open] .reaction-add-button, +.reaction-bar-compact .reaction-add-button:focus-visible { opacity: 0.8; } +@media (hover: none) { .reaction-bar-compact .reaction-add-button { opacity: 0.65; } } + +.reaction-picker { + position: absolute; + bottom: calc(100% + 6px); + left: 0; + z-index: 20; + display: grid; + grid-template-columns: repeat(8, 2.2rem); + gap: 0.15rem; + padding: 0.4rem; + border-radius: 12px; + background: #1e1f22; + border: 1px solid var(--border); + box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55); + animation: item-picker-in 0.12s ease-out; +} +.reaction-pick { + width: 2.2rem; + height: 2.2rem; + min-width: 0; + padding: 0; + border: none; + border-radius: 8px; + background: transparent; + font-size: 1.3rem; + line-height: 1; + cursor: pointer; +} +.reaction-pick:hover { background: rgba(255, 255, 255, 0.1); transform: scale(1.12); } +@media (max-width: 480px) { .reaction-picker { grid-template-columns: repeat(6, 2.2rem); } } + +.gallery-reaction-summary { + position: absolute; + top: 0.45rem; + left: 0.45rem; + display: inline-flex; + align-items: center; + gap: 0.25rem; + padding: 0.1rem 0.5rem; + border-radius: 999px; + background: rgba(0, 0, 0, 0.6); + color: #fff; + font-size: 0.8rem; + backdrop-filter: blur(4px); +} +.gallery-reaction-summary:hover { text-decoration: none; color: var(--gold); } +.gallery-reaction-summary span { font-weight: 700; font-size: 0.75rem; } + +/* Zuletzt aktiv (Mitgliederliste, Profil) */ +.member-last-seen { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; } +.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #6b6f76; flex-shrink: 0; } +.member-last-seen.is-online { color: #57d68d; font-weight: 600; } +.member-last-seen.is-online .online-dot { background: #3ba55d; box-shadow: 0 0 0 3px rgba(59, 165, 93, 0.25); } +.member-list .member-last-seen { margin-top: 0; } +.reaction-picker.align-right { left: auto; right: 0; } +.moderation-tabs a { + display: inline-flex; + align-items: center; + gap: 0.35rem; + padding: 0.4rem 1rem; + border-radius: 999px; + color: var(--text-muted); + font-size: 0.88rem; + font-weight: 600; +} +.moderation-tabs a:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); text-decoration: none; } +.moderation-tabs a.active { background: var(--gold); color: #1a1a1a; } +.moderation-tabs a.active .chip-count { background: rgba(0, 0, 0, 0.2); } +.filter-word-form, .filter-word { flex-direction: row; align-items: center; } +.filter-word-form input[type="text"] { width: auto; } +.filter-word select { -webkit-appearance: none; appearance: none; flex: 0 0 auto; padding: 0.05rem 0.45rem; border-radius: 999px; background: rgba(255, 255, 255, 0.06); } +.filter-word select:hover { color: var(--text); } diff --git a/assets/js/members.js b/assets/js/members.js index d5a54c0..e717623 100644 --- a/assets/js/members.js +++ b/assets/js/members.js @@ -35,7 +35,9 @@ return ca.localeCompare(cb, 'de') || byName(a, b); }, joined: function (a, b) { return b.dataset.joined.localeCompare(a.dataset.joined) || byName(a, b); }, - oldest: function (a, b) { return a.dataset.joined.localeCompare(b.dataset.joined) || byName(a, b); } + oldest: function (a, b) { return a.dataset.joined.localeCompare(b.dataset.joined) || byName(a, b); }, + // Zuletzt aktiv zuerst, wer sich nie angemeldet hat ganz unten + active: function (a, b) { return (b.dataset.active || '').localeCompare(a.dataset.active || '') || byName(a, b); } }; function grid() { diff --git a/assets/js/reactions.js b/assets/js/reactions.js new file mode 100644 index 0000000..074a315 --- /dev/null +++ b/assets/js/reactions.js @@ -0,0 +1,71 @@ +/** + * Reaktionen (Emojis) ohne Neuladen: Klick auf eine Reaktion oder ein Emoji in der Auswahl + * schickt das Formular im Hintergrund und ersetzt die Leiste durch die neue vom Server. + * Ohne JavaScript funktionieren die Formulare ganz normal (mit Neuladen). + */ +(function () { + 'use strict'; + + document.addEventListener('submit', function (event) { + var form = event.target; + if (!form.classList || !form.classList.contains('reaction-form')) return; + event.preventDefault(); + + var bar = form.closest('.reaction-bar'); + if (!bar || bar.classList.contains('is-busy')) return; + bar.classList.add('is-busy'); + + fetch(form.action, { + method: 'POST', + body: new FormData(form), + credentials: 'same-origin', + headers: { 'X-Requested-With': 'fetch', 'Accept': 'application/json' } + }) + .then(function (response) { return response.json(); }) + .then(function (data) { + if (!data.ok) { + alert(data.error || 'Das hat nicht geklappt.'); + bar.classList.remove('is-busy'); + return; + } + var wrapper = document.createElement('div'); + wrapper.innerHTML = data.html; + var fresh = wrapper.firstElementChild; + if (fresh) { + bar.replaceWith(fresh); + var changed = fresh.querySelector('.reaction.is-mine'); + if (changed) changed.classList.add('pop'); + } else { + bar.remove(); + } + }) + .catch(function () { + bar.classList.remove('is-busy'); + form.submit(); // Rueckfall: normal abschicken + }); + }); + + // Emoji-Auswahl im Bild halten: ragt sie rechts hinaus, klappt sie nach links auf + document.addEventListener('toggle', function (event) { + var details = event.target; + if (!details.classList || !details.classList.contains('reaction-add') || !details.open) return; + var picker = details.querySelector('.reaction-picker'); + picker.classList.remove('align-right'); + if (picker.getBoundingClientRect().right > window.innerWidth - 8) { + picker.classList.add('align-right'); + } + }, true); + + // Emoji-Auswahl schliessen bei Klick daneben oder Escape + document.addEventListener('click', function (event) { + document.querySelectorAll('.reaction-add[open]').forEach(function (details) { + if (!details.contains(event.target)) details.removeAttribute('open'); + }); + }); + document.addEventListener('keydown', function (event) { + if (event.key !== 'Escape') return; + document.querySelectorAll('.reaction-add[open]').forEach(function (details) { + details.removeAttribute('open'); + }); + }); +})(); diff --git a/assets/map/js/controllers/MapController.js b/assets/map/js/controllers/MapController.js index 2caf45e..eb3c88d 100644 --- a/assets/map/js/controllers/MapController.js +++ b/assets/map/js/controllers/MapController.js @@ -265,7 +265,7 @@ class MapController { html += `
- + ${iconHtml} ${cat.count} diff --git a/assets/map/js/models/MapData.js b/assets/map/js/models/MapData.js index 0f9e9f2..816bdd2 100644 --- a/assets/map/js/models/MapData.js +++ b/assets/map/js/models/MapData.js @@ -76,10 +76,8 @@ class MapData { this.categories[key].count++; }); - // Show all categories by default - Object.keys(this.categories).forEach(key => { - this.visibleCategories.add(key); - }); + // Anfangs sind alle Kategorien versteckt - man blendet gezielt ein, was man sucht + // (einzeln, per Gruppe oder mit "Alle anzeigen"). } /** diff --git a/gallery_comment_action.php b/gallery_comment_action.php index da779a4..08f9b52 100644 --- a/gallery_comment_action.php +++ b/gallery_comment_action.php @@ -5,6 +5,7 @@ */ require_once __DIR__ . '/includes/bootstrap.php'; require_once __DIR__ . '/includes/member_profile.php'; +require_once __DIR__ . '/includes/reactions.php'; require_permission('members.view'); if ($_SERVER['REQUEST_METHOD'] !== 'POST') { @@ -53,6 +54,10 @@ if ($action === 'add') { set_flash('error', 'Diesen Kommentar hast du gerade schon geschrieben.'); redirect($back); } + if (moderation_blocks($body, 'Kommentar unter einem Galeriebild')) { + set_flash('error', 'Dein Kommentar enthält ein Wort, das hier nicht erlaubt ist.'); + redirect($back); + } if (!security_throttle('comment')) { set_flash('error', 'Du hast in den letzten Minuten schon viele Kommentare geschrieben. Bitte warte kurz.'); redirect($back); @@ -88,6 +93,7 @@ if ($action === 'delete') { $pdo->prepare('DELETE FROM gallery_comments WHERE id = ?')->execute([$commentId]); moderation_clear_reports('comment', $commentId); + reactions_delete('comment', [$commentId]); // Loescht die Moderation einen fremden Kommentar auf einem fremden Bild -> ins Log $isAuthor = (int) $comment['author_id'] === (int) $me['id']; $isOwner = (int) $comment['owner_id'] === (int) $me['id']; diff --git a/includes/auth.php b/includes/auth.php index 1c56619..540861e 100644 --- a/includes/auth.php +++ b/includes/auth.php @@ -51,6 +51,16 @@ function current_user(): ?array return null; } + // "Zuletzt aktiv" fuer die Mitgliederliste - nicht bei jedem Seitenaufruf schreiben. + if (($_SESSION['last_seen_touch'] ?? 0) < time() - 300) { + $_SESSION['last_seen_touch'] = time(); + try { + db()->prepare('UPDATE users SET last_seen_at = ? WHERE id = ?')->execute([date('Y-m-d H:i:s'), (int) $row['id']]); + } catch (PDOException $e) { + // Spalte kommt erst mit dem naechsten Schema-Abgleich + } + } + $user = $row; return $user; } diff --git a/includes/functions.php b/includes/functions.php index 901ccbb..8653794 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -415,3 +415,42 @@ function show_not_found(): void include __DIR__ . '/not_found.php'; exit; } + +/** Online = in den letzten Minuten aktiv. */ +const ONLINE_MINUTES = 10; + +/** + * "Zuletzt aktiv" lesbar: "gerade online", "vor 20 Min.", "vor 3 Std.", "gestern", "vor 5 Tagen", + * danach das Datum. Null = noch nie angemeldet. + */ +function last_active_label(?string $datetime): string +{ + $time = $datetime ? strtotime($datetime) : false; + if ($time === false) { + return 'noch nie'; + } + $diff = max(0, time() - $time); + if ($diff < ONLINE_MINUTES * 60) { + return 'gerade online'; + } + if ($diff < 3600) { + return 'vor ' . (int) floor($diff / 60) . ' Min.'; + } + if (date('Y-m-d', $time) === date('Y-m-d')) { + return 'vor ' . (int) floor($diff / 3600) . ' Std.'; + } + if (date('Y-m-d', $time) === date('Y-m-d', strtotime('-1 day'))) { + return 'gestern'; + } + $days = (int) floor((strtotime('today') - strtotime(date('Y-m-d', $time))) / 86400); + if ($days < 30) { + return 'vor ' . $days . ' Tagen'; + } + return 'am ' . date('d.m.Y', $time); +} + +function is_online(?string $datetime): bool +{ + $time = $datetime ? strtotime($datetime) : false; + return $time !== false && $time > time() - ONLINE_MINUTES * 60; +} diff --git a/includes/moderation.php b/includes/moderation.php index 8bacdd1..641c64b 100644 --- a/includes/moderation.php +++ b/includes/moderation.php @@ -63,6 +63,10 @@ function moderation_initial_status(string $type, string $text = ''): array if (moderation_can()) { return ['visible', null]; } + $hits = moderation_word_hits($text); + if (moderation_word_action($hits) === 'hold') { + return ['pending', 'Schimpfwortfilter: ' . implode(', ', array_keys(array_filter($hits, static fn ($a) => $a === 'hold')))]; + } if (moderation_all_manual()) { return ['pending', 'Alles wird gerade manuell freigegeben']; } @@ -165,3 +169,151 @@ function moderation_my_reports(string $type, array $ids): array return []; } } + +// ---- Schimpfwortfilter ---- + +// Was ein Filterwort bewirkt: Schluessel => Beschriftung +const MODERATION_WORD_ACTIONS = [ + 'flag' => 'Nur markieren', + 'hold' => 'Zur Freigabe zurückhalten', + 'block' => 'Blockieren', +]; + +// Startliste beim ersten Aufruf - danach pflegt die Moderation die Liste selbst (moderation.php). +const MODERATION_DEFAULT_WORDS = [ + 'hurensohn' => 'hold', 'hure' => 'hold', 'wichser' => 'hold', 'fotze' => 'hold', 'missgeburt' => 'hold', + 'spast*' => 'hold', 'schwuchtel' => 'hold', 'heil hitler' => 'hold', 'fick*' => 'hold', 'arschloch' => 'hold', + 'bastard' => 'hold', 'kys' => 'hold', 'kill yourself' => 'hold', 'bring dich um' => 'hold', 'behindert' => 'flag', + 'nazi*' => 'flag', 'nitro' => 'flag', 'free' => 'flag', 'gratis' => 'flag', 'gewinnspiel' => 'flag', + 'giveaway' => 'flag', 'kaufen' => 'flag', 'verkaufe*' => 'flag', 'cheap' => 'flag', 'boost*' => 'flag', + 'steam gift' => 'flag', 'airdrop' => 'flag', 'crypto' => 'flag', 'krypto*' => 'flag', + 'passwort' => 'flag', 'password' => 'flag', 'verify' => 'flag', 'verifizier*' => 'flag', +]; + +/** + * Die Filterwoerter (beim allerersten Aufruf mit der Startliste befuellt). + * + * @return array Wort => Aktion + */ +function moderation_words(bool $reload = false): array +{ + static $words = null; + if ($words !== null && !$reload) { + return $words; + } + try { + $words = db()->query('SELECT word, action FROM moderation_words ORDER BY word')->fetchAll(PDO::FETCH_KEY_PAIR); + if (!$words && setting_get('moderation_words_seeded') !== '1') { + $insert = db()->prepare('INSERT INTO moderation_words (word, action) VALUES (?, ?)'); + foreach (MODERATION_DEFAULT_WORDS as $word => $action) { + $insert->execute([$word, $action]); + } + setting_set('moderation_words_seeded', '1'); + $words = MODERATION_DEFAULT_WORDS; + ksort($words); + } + } catch (PDOException $e) { + $words = []; + } + return $words; +} + +/** Text fuer den Vergleich: klein, Leetspeak aufgeloest (f1ck, @rsch), Buchstaben-Wiederholungen gekuerzt. */ +function moderation_normalize(string $text): string +{ + $text = mb_strtolower($text); + $text = strtr($text, ['0' => 'o', '1' => 'i', '3' => 'e', '4' => 'a', '5' => 's', '7' => 't', '@' => 'a', '$' => 's', '€' => 'e']); + return (string) preg_replace('/(\p{L})\1{2,}/u', '$1', $text); // fiiiick -> fick +} + +/** + * Welche Filterwoerter kommen im Text vor? Ganze Woerter, mit * auch als Wortteil. + * + * @return array Wort => Aktion + */ +function moderation_word_hits(string $text): array +{ + if (trim($text) === '') { + return []; + } + $variants = array_unique([mb_strtolower($text), moderation_normalize($text)]); + $hits = []; + foreach (moderation_words() as $word => $action) { + $core = preg_quote(trim((string) $word, '*'), '/'); + $core = str_replace(' ', '\s+', $core); // Leerzeichen im Filterwort: beliebig viel Abstand + $before = str_starts_with((string) $word, '*') ? '' : '(? hold > flag), null ohne Treffer. */ +function moderation_word_action(array $hits): ?string +{ + foreach (['block', 'hold', 'flag'] as $action) { + if (in_array($action, $hits, true)) { + return $action; + } + } + return null; +} + +/** Blockiert der Filter diesen Text? (Moderation ausgenommen) - dann gleich ins Log. */ +function moderation_blocks(string $text, string $where): bool +{ + $hits = moderation_word_hits($text); + if (moderation_can() || moderation_word_action($hits) !== 'block') { + return false; + } + admin_log('🚫 Beitrag vom Schimpfwortfilter blockiert', [ + 'Wo' => $where, + 'Wörter' => implode(', ', array_keys(array_filter($hits, static fn ($a) => $a === 'block'))), + 'Text' => mb_strimwidth($text, 0, 300, '…'), + ], 'warning', 'members'); + return true; +} + +/** + * Markierungen fuer einen Kommentar: [Text, Stufe] mit Stufe "critical" oder "warning". + * Erwartet: status, body, report_count, author_since (Discord-Beitritt bzw. Kontoerstellung). + * + * @return array + */ +function moderation_comment_flags(array $comment): array +{ + $flags = []; + $body = (string) $comment['body']; + + if (($comment['status'] ?? '') === 'pending') { + $flags[] = ['Wartet auf Freigabe', 'critical']; + } + $reports = (int) ($comment['report_count'] ?? 0); + if ($reports > 0) { + $flags[] = [$reports === 1 ? '1 Meldung' : $reports . ' Meldungen', 'critical']; + } + $hits = moderation_word_hits($body); + if ($hits) { + $flags[] = ['Filterwort: ' . implode(', ', array_slice(array_keys($hits), 0, 3)), 'critical']; + } + if (moderation_has_link($body)) { + $flags[] = ['Enthält Link', 'warning']; + } + $since = strtotime((string) ($comment['author_since'] ?? '')); + if ($since !== false && $since > time() - MODERATION_TRUST_DAYS * 86400) { + $flags[] = ['Neues Mitglied', 'warning']; + } + $letters = preg_replace('/[^\p{L}]/u', '', $body) ?? ''; + if (mb_strlen($letters) >= 12 && mb_strtoupper($letters) === $letters) { + $flags[] = ['Nur Großbuchstaben', 'warning']; + } + if (preg_match('/(.)\1{7,}/u', $body)) { + $flags[] = ['Zeichen-Spam', 'warning']; + } + return $flags; +} diff --git a/includes/reactions.php b/includes/reactions.php new file mode 100644 index 0000000..699586f --- /dev/null +++ b/includes/reactions.php @@ -0,0 +1,128 @@ + Tabelle +const REACTION_TYPES = ['picture' => 'member_gallery', 'comment' => 'gallery_comments']; + +/** + * Reaktionen fuer mehrere Inhalte einer Art, in der Reihenfolge der ersten Reaktion. + * + * @param array $ids + * @return array}>> + */ +function reactions_for(string $type, array $ids): array +{ + if (empty($ids)) { + return []; + } + $me = current_user(); + $placeholders = implode(',', array_fill(0, count($ids), '?')); + try { + $stmt = db()->prepare( + "SELECT r.content_id, r.emoji, r.user_id, COALESCE(NULLIF(u.display_name, ''), u.username) AS name + FROM reactions r JOIN users u ON u.id = r.user_id + WHERE r.content_type = ? AND r.content_id IN ($placeholders) + ORDER BY r.created_at, r.id" + ); + $stmt->execute(array_merge([$type], array_map('intval', $ids))); + $rows = $stmt->fetchAll(); + } catch (PDOException $e) { + return []; // Tabelle noch nicht angelegt + } + $result = []; + foreach ($rows as $row) { + $entry = &$result[(int) $row['content_id']][$row['emoji']]; + $entry ??= ['count' => 0, 'mine' => false, 'names' => []]; + $entry['count']++; + $entry['names'][] = (string) $row['name']; + if ($me && (int) $row['user_id'] === (int) $me['id']) { + $entry['mine'] = true; + } + unset($entry); + } + return $result; +} + +/** Reaktion setzen oder (wenn schon gesetzt) wieder entfernen. */ +function reaction_toggle(string $type, int $contentId, string $emoji): void +{ + $userId = (int) current_user()['id']; + $delete = db()->prepare('DELETE FROM reactions WHERE content_type = ? AND content_id = ? AND user_id = ? AND emoji = ?'); + $delete->execute([$type, $contentId, $userId, $emoji]); + if ($delete->rowCount() === 0) { + db()->prepare('INSERT INTO reactions (content_type, content_id, user_id, emoji) VALUES (?, ?, ?, ?)') + ->execute([$type, $contentId, $userId, $emoji]); + } +} + +/** Reaktionen eines geloeschten Inhalts entfernen. */ +function reactions_delete(string $type, array $ids): void +{ + if (empty($ids)) { + return; + } + $placeholders = implode(',', array_fill(0, count($ids), '?')); + try { + db()->prepare("DELETE FROM reactions WHERE content_type = ? AND content_id IN ($placeholders)") + ->execute(array_merge([$type], array_map('intval', $ids))); + } catch (PDOException $e) { + // Tabelle fehlt (noch) + } +} + +/** Kurztext fuer den Tooltip: "Maaxxs, Damaskar und 3 weitere". */ +function reaction_names_label(array $names): string +{ + $shown = array_slice($names, 0, 3); + $rest = count($names) - count($shown); + return implode(', ', $shown) . ($rest > 0 ? ' und ' . $rest . ($rest === 1 ? ' weitere*r' : ' weitere') : ''); +} + +/** + * Reaktionsleiste: vorhandene Reaktionen als Knoepfe (eigene hervorgehoben) und ein "+" mit + * Emoji-Auswahl. Funktioniert auch ohne JavaScript (Formulare), assets/js/reactions.js macht es + * ohne Neuladen. + * + * @param array}> $reactions + */ +function reactions_bar_html(string $type, int $contentId, array $reactions, bool $canReact, bool $compact = false): string +{ + if (!$canReact && !$reactions) { + return ''; + } + $form = static function (string $emoji, string $inner, string $class, string $title) use ($type, $contentId, $canReact): string { + if (!$canReact) { + return '' . $inner . ''; + } + return '
' . csrf_field() + . '' + . '' + . '
'; + }; + + $html = '
'; + foreach ($reactions as $emoji => $info) { + $html .= $form( + (string) $emoji, + '' . e((string) $emoji) . '' . $info['count'] . '', + 'reaction' . ($info['mine'] ? ' is-mine' : ''), + reaction_names_label($info['names']) . ($canReact ? ($info['mine'] ? ' - klicken zum Entfernen' : ' - klicken zum Mitreagieren') : '') + ); + } + if ($canReact) { + $html .= '
' + . '😀+
'; + foreach (REACTION_EMOJIS as $emoji) { + $html .= $form($emoji, e($emoji), 'reaction-pick', $emoji); + } + $html .= '
'; + } + return $html . '
'; +} diff --git a/includes/schema.php b/includes/schema.php index 79bb353..b93caaf 100644 --- a/includes/schema.php +++ b/includes/schema.php @@ -11,7 +11,7 @@ declare(strict_types=1); */ // Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu. -const SCHEMA_VERSION = 19; +const SCHEMA_VERSION = 20; /** * Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql). @@ -342,6 +342,34 @@ CREATE TABLE IF NOT EXISTS gallery_comments ( INDEX idx_gallery_comments_picture (gallery_id, created_at), INDEX idx_gallery_comments_author (author_id, created_at) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +SQL, + 'moderation_words' => <<<'SQL' +CREATE TABLE IF NOT EXISTS moderation_words ( + id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + -- Wort (klein geschrieben); * am Anfang/Ende = auch als Wortteil (z.B. fick*) + word VARCHAR(60) NOT NULL, + -- flag = nur markieren, hold = erst nach Freigabe sichtbar, block = wird nicht gespeichert + action VARCHAR(10) NOT NULL DEFAULT 'flag', + created_by INT UNSIGNED NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + UNIQUE KEY uq_moderation_words (word), + FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci +SQL, + 'reactions' => <<<'SQL' +CREATE TABLE IF NOT EXISTS reactions ( + id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + -- Reaktion auf: picture = member_gallery.id, comment = gallery_comments.id + content_type VARCHAR(20) NOT NULL, + content_id INT UNSIGNED NOT NULL, + user_id INT UNSIGNED NOT NULL, + -- ein Emoji aus REACTION_EMOJIS (includes/reactions.php) + emoji VARCHAR(16) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + UNIQUE KEY uq_reactions (content_type, content_id, user_id, emoji), + INDEX idx_reactions_content (content_type, content_id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci SQL, 'content_reports' => <<<'SQL' CREATE TABLE IF NOT EXISTS content_reports ( @@ -392,6 +420,11 @@ function schema_column_upgrades(): array "UPDATE users SET tour_completed_at = NOW()", ], // Wird hochgezaehlt, um alle Sitzungen eines Kontos sofort zu beenden (Sperren/Abmelden). + // Zuletzt aktiv (Mitgliederliste) - bis zum ersten Besuch gilt der letzte Login + 'last_seen_at' => [ + "ALTER TABLE users ADD COLUMN last_seen_at DATETIME NULL AFTER last_login", + "UPDATE users SET last_seen_at = last_login", + ], 'session_epoch' => "ALTER TABLE users ADD COLUMN session_epoch INT UNSIGNED NOT NULL DEFAULT 0 AFTER is_admin", // Kommentare unter den eigenen Galeriebildern (0 = vom Mitglied abgeschaltet) 'gallery_comments_enabled' => "ALTER TABLE users ADD COLUMN gallery_comments_enabled TINYINT(1) NOT NULL DEFAULT 1 AFTER profile_bio", diff --git a/includes/security.php b/includes/security.php index c1795af..478ffa8 100644 --- a/includes/security.php +++ b/includes/security.php @@ -36,6 +36,7 @@ const SECURITY_LIMITS = [ 'upload' => [30, 600], // hochgeladene Bilder pro Konto 'comment' => [6, 300], // Kommentare unter Galeriebildern pro Konto 'report' => [10, 600], // Meldungen (Melden-Knopf) pro Konto + 'reaction' => [60, 300], // Reaktionen (Emojis) pro Konto 'bug' => [5, 3600], // Fehlermeldungen pro Konto 'login_ip' => [15, 900], // fehlgeschlagene Logins pro IP (egal welches Konto) 'login_pair' => [5, 900], // fehlgeschlagene Logins pro IP + Benutzername @@ -52,7 +53,7 @@ function audit_area_for_script(string $script): string $prefixes = [ 'raid' => 'raids', 'premade' => 'premades', 'event' => 'events', 'tactics' => 'map', 'map' => 'map', 'warehouse' => 'warehouse', 'contributions' => 'contributions', 'shop' => 'shop', - 'member' => 'members', 'gallery' => 'members', 'moderation' => 'members', 'wiki' => 'wiki', 'report' => 'reports', 'bug' => 'bugs', + 'member' => 'members', 'gallery' => 'members', 'moderation' => 'members', 'reaction' => 'members', 'wiki' => 'wiki', 'report' => 'reports', 'bug' => 'bugs', 'user' => 'users', 'role' => 'users', 'discord' => 'users', 'settings' => 'users', ]; foreach ($prefixes as $prefix => $area) { @@ -192,6 +193,7 @@ function security_bucket_label(string $bucket): string 'upload' => 'Bilder hochladen', 'comment' => 'Kommentare', 'report' => 'Meldungen', + 'reaction' => 'Reaktionen', 'bug' => 'Fehlermeldungen', 'destructive' => 'Löschungen', ][$bucket] ?? $bucket; diff --git a/member.php b/member.php index 5f6fdb8..e23ea5a 100644 --- a/member.php +++ b/member.php @@ -1,13 +1,15 @@ prepare( "SELECT id, username, display_name, class_name, profile_bio, gallery_comments_enabled, discord_id, discord_username, avatar_filename, status, - COALESCE(discord_joined_at, created_at) AS joined_at, discord_joined_at IS NOT NULL AS joined_discord + COALESCE(discord_joined_at, created_at) AS joined_at, discord_joined_at IS NOT NULL AS joined_discord, + COALESCE(last_seen_at, last_login) AS last_active FROM users WHERE id = ?" ); $stmt->execute([$id]); @@ -33,6 +35,7 @@ $galleryStmt->execute([$id]); $gallery = $galleryStmt->fetchAll(); $commentsEnabled = !empty($member['gallery_comments_enabled']); $commentCounts = $commentsEnabled ? gallery_comment_counts(array_map('intval', array_column($gallery, 'id'))) : []; +$pictureReactions = $commentsEnabled ? reactions_for('picture', array_map('intval', array_column($gallery, 'id'))) : []; $name = $member['display_name'] !== '' ? $member['display_name'] : $member['username']; $canEdit = profile_can_edit($id); @@ -50,6 +53,7 @@ include __DIR__ . '/includes/header.php'; Dabei seit +
@@ -129,6 +133,14 @@ include __DIR__ . '/includes/header.php'; data-comments-url="" data-comments-count=""> <?= e($picture['caption'] ?: 'Bild von ' . $name) ?> + + + + + + + + diff --git a/member_action.php b/member_action.php index cd098fb..92c2a23 100644 --- a/member_action.php +++ b/member_action.php @@ -150,6 +150,10 @@ switch ($action) { 'tmp_name' => $_FILES['images']['tmp_name'][$i] ?? '', ]; } + if (moderation_blocks($caption, 'Bildunterschrift (Galerie)')) { + set_flash('error', 'Die Bildunterschrift enthält ein Wort, das hier nicht erlaubt ist.'); + redirect($back); + } $uploadCount = count(array_filter($files, static fn (array $f): bool => $f['error'] !== UPLOAD_ERR_NO_FILE)); if ($uploadCount > 0 && !security_throttle('upload', $uploadCount)) { set_flash('error', 'Du hast in den letzten Minuten schon sehr viele Bilder hochgeladen. Bitte warte ein paar Minuten.'); @@ -196,13 +200,19 @@ switch ($action) { case 'gallery_update': $caption = mb_substr(trim((string) ($_POST['caption'] ?? '')), 0, 150); + if (moderation_blocks($caption, 'Bildunterschrift (Galerie)')) { + set_flash('error', 'Die Bildunterschrift enthält ein Wort, das hier nicht erlaubt ist.'); + redirect($back); + } $pdo->prepare('UPDATE member_gallery SET caption = ? WHERE id = ? AND user_id = ?') ->execute([$caption !== '' ? $caption : null, (int) ($_POST['picture_id'] ?? 0), $userId]); - // Nachtraeglich ein Link in die Unterschrift? Dann erst wieder nach Freigabe sichtbar. - if (!moderation_can() && moderation_has_link($caption)) { + // Nachtraeglich ein Link oder zurueckgehaltenes Wort in der Unterschrift? Dann erst wieder nach Freigabe sichtbar. + [$captionStatus, $captionNote] = $caption !== '' ? moderation_initial_status('caption', $caption) : ['visible', null]; + $captionReason = $captionNote !== null && (moderation_has_link($caption) || str_starts_with($captionNote, 'Schimpfwortfilter')); + if ($captionStatus === 'pending' && $captionReason) { $pdo->prepare("UPDATE member_gallery SET status = 'pending', moderation_note = ? WHERE id = ? AND user_id = ?") - ->execute(['Link in der Bildunterschrift', (int) ($_POST['picture_id'] ?? 0), $userId]); - set_flash('success', 'Bildunterschrift gespeichert. Wegen des Links ist das Bild bis zur Freigabe nur für dich sichtbar.'); + ->execute([$captionNote, (int) ($_POST['picture_id'] ?? 0), $userId]); + set_flash('success', 'Bildunterschrift gespeichert. Das Bild ist bis zur Freigabe durch die Moderation nur für dich sichtbar.'); redirect($back); } set_flash('success', 'Bildunterschrift gespeichert.'); @@ -213,6 +223,11 @@ switch ($action) { $stmt->execute([(int) ($_POST['picture_id'] ?? 0), $userId]); $filename = $stmt->fetchColumn(); if ($filename !== false) { + require_once __DIR__ . '/includes/reactions.php'; + $commentIds = $pdo->prepare('SELECT id FROM gallery_comments WHERE gallery_id = ?'); + $commentIds->execute([(int) ($_POST['picture_id'] ?? 0)]); + reactions_delete('comment', $commentIds->fetchAll(PDO::FETCH_COLUMN)); + reactions_delete('picture', [(int) ($_POST['picture_id'] ?? 0)]); $pdo->prepare('DELETE FROM member_gallery WHERE id = ?')->execute([(int) ($_POST['picture_id'] ?? 0)]); profile_delete_file((string) $filename); moderation_clear_reports('picture', (int) ($_POST['picture_id'] ?? 0)); diff --git a/member_edit.php b/member_edit.php index a58e4f1..5eb7a3e 100644 --- a/member_edit.php +++ b/member_edit.php @@ -151,7 +151,7 @@ include __DIR__ . '/includes/header.php'; diff --git a/member_picture.php b/member_picture.php index d16e450..f5018e8 100644 --- a/member_picture.php +++ b/member_picture.php @@ -4,6 +4,7 @@ */ require_once __DIR__ . '/includes/bootstrap.php'; require_once __DIR__ . '/includes/member_profile.php'; +require_once __DIR__ . '/includes/reactions.php'; require_permission('members.view'); $pictureId = (int) ($_GET['id'] ?? 0); @@ -43,6 +44,10 @@ if ($commentsEnabled) { $commentStmt->execute([$pictureId, (int) $me['id'], $isModerator ? 1 : 0]); $comments = $commentStmt->fetchAll(); } +// Reaktionen (Emojis) am Bild und an den Kommentaren - gehen mit den Kommentaren an und aus +$pictureReactions = reactions_for('picture', [$pictureId])[$pictureId] ?? []; +$commentReactions = reactions_for('comment', array_map('intval', array_column($comments, 'id'))); + // Schon gemeldet? (Knopf dann ausgegraut) $reportedPicture = !empty(moderation_my_reports('picture', [$pictureId])); $reportedComments = moderation_my_reports('comment', array_map('intval', array_column($comments, 'id'))); @@ -101,6 +106,9 @@ include __DIR__ . '/includes/header.php';
+ +
+
@@ -143,6 +151,7 @@ include __DIR__ . '/includes/header.php';

+ @@ -165,6 +174,7 @@ include __DIR__ . '/includes/header.php'; +