Moderation: all comments with flags, swear word filter; reactions on pictures and comments; last active in member list; map starts with categories hidden
- Moderation page with tabs: approval, all comments (critical/suspicious flags, search, filters), swear word filter (mark / hold / block, maintained by mods, detects leetspeak) - Discord-style emoji reactions on gallery pictures and comments (without reloading) - Member list and profile: "last active" / online dot, sortable - Map: all marker categories hidden at start Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
e4f23fcde4
commit
6d8747c9e4
22 changed files with 1001 additions and 24 deletions
31
README.md
31
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
|
- Jeder Benutzer kann mehreren Berechtigungsgruppen angehören
|
||||||
- Events-Seite: geplante (wiederkehrende) Event-Erinnerungen des Bots ansehen, anlegen,
|
- Events-Seite: geplante (wiederkehrende) Event-Erinnerungen des Bots ansehen, anlegen,
|
||||||
bearbeiten und löschen - synchron mit `/event_planen` / `/event_liste` im Discord
|
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
|
Ishalgen, Reshanta) mit Markern und Kategorie-Filtern, dazu Taktiken in Schritten, die
|
||||||
direkt auf die Karte gezeichnet werden
|
direkt auf die Karte gezeichnet werden
|
||||||
- Lumipunkte: Punkte für Raids, Events und andere Aktivitäten an einzelne oder viele
|
- Lumipunkte: Punkte für Raids, Events und andere Aktivitäten an einzelne oder viele
|
||||||
|
|
@ -334,10 +334,10 @@ Bot-Prozess neu gestartet werden.
|
||||||
### Karte
|
### Karte
|
||||||
|
|
||||||
Die Seite **Karte** (`map.php`) zeigt eine interaktive Karte aller Regionen: Verteron,
|
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
|
Reshanta. Oben wird die Region gewählt, unten links lassen sich die Marker-Kategorien
|
||||||
(Orte, Monster, NPCs, Ressourcen, Sammelbares, Quests …) einzeln, gruppenweise oder mit
|
(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.
|
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/`
|
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
|
und lassen sich mit den Scripten unter `assets/map/scripts/` neu herunterladen. Details dazu
|
||||||
stehen in `assets/map/README.md`.
|
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.
|
gibt es Marker, Poeta, Ishalgen und Abyss Reshanta B zeigen nur die Karte.
|
||||||
|
|
||||||
#### Taktiken
|
#### 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
|
(siehe „Moderation“ unten). Jedes Mitglied kann Kommentare unter den eigenen
|
||||||
Bildern beim Bearbeiten der Profilseite abschalten (`users.gallery_comments_enabled`).
|
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)
|
## Wiki (Einsteiger-Guide)
|
||||||
|
|
||||||
Unter **Wiki** im Menü liegt der Einsteiger-Guide der Legion: Kapitel mit Unterseiten,
|
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
|
Die Moderation kann freigeben, ausblenden, Meldungen verwerfen oder löschen - alles landet im
|
||||||
Audit- und Discord-Log. Grenzen: `MODERATION_TRUST_DAYS`, `MODERATION_REPORT_THRESHOLD`.
|
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)
|
## Fehlerseite (404)
|
||||||
|
|
||||||
Nicht vorhandene Seiten und Seiten **ohne Berechtigung** zeigen dieselbe 404-Seite
|
Nicht vorhandene Seiten und Seiten **ohne Berechtigung** zeigen dieselbe 404-Seite
|
||||||
|
|
|
||||||
|
|
@ -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 { 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-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-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); }
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,9 @@
|
||||||
return ca.localeCompare(cb, 'de') || byName(a, b);
|
return ca.localeCompare(cb, 'de') || byName(a, b);
|
||||||
},
|
},
|
||||||
joined: function (a, b) { return b.dataset.joined.localeCompare(a.dataset.joined) || 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() {
|
function grid() {
|
||||||
|
|
|
||||||
71
assets/js/reactions.js
Normal file
71
assets/js/reactions.js
Normal file
|
|
@ -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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
@ -265,7 +265,7 @@ class MapController {
|
||||||
|
|
||||||
html += `
|
html += `
|
||||||
<div class="category-item">
|
<div class="category-item">
|
||||||
<input type="checkbox" id="cat-${cat.key}" checked>
|
<input type="checkbox" id="cat-${cat.key}" ${this.mapData.visibleCategories.has(cat.key) ? 'checked' : ''}>
|
||||||
${iconHtml}
|
${iconHtml}
|
||||||
<label for="cat-${cat.key}">${cat.name}</label>
|
<label for="cat-${cat.key}">${cat.name}</label>
|
||||||
<span class="category-count">${cat.count}</span>
|
<span class="category-count">${cat.count}</span>
|
||||||
|
|
|
||||||
|
|
@ -76,10 +76,8 @@ class MapData {
|
||||||
this.categories[key].count++;
|
this.categories[key].count++;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Show all categories by default
|
// Anfangs sind alle Kategorien versteckt - man blendet gezielt ein, was man sucht
|
||||||
Object.keys(this.categories).forEach(key => {
|
// (einzeln, per Gruppe oder mit "Alle anzeigen").
|
||||||
this.visibleCategories.add(key);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/includes/bootstrap.php';
|
require_once __DIR__ . '/includes/bootstrap.php';
|
||||||
require_once __DIR__ . '/includes/member_profile.php';
|
require_once __DIR__ . '/includes/member_profile.php';
|
||||||
|
require_once __DIR__ . '/includes/reactions.php';
|
||||||
require_permission('members.view');
|
require_permission('members.view');
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
|
|
@ -53,6 +54,10 @@ if ($action === 'add') {
|
||||||
set_flash('error', 'Diesen Kommentar hast du gerade schon geschrieben.');
|
set_flash('error', 'Diesen Kommentar hast du gerade schon geschrieben.');
|
||||||
redirect($back);
|
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')) {
|
if (!security_throttle('comment')) {
|
||||||
set_flash('error', 'Du hast in den letzten Minuten schon viele Kommentare geschrieben. Bitte warte kurz.');
|
set_flash('error', 'Du hast in den letzten Minuten schon viele Kommentare geschrieben. Bitte warte kurz.');
|
||||||
redirect($back);
|
redirect($back);
|
||||||
|
|
@ -88,6 +93,7 @@ if ($action === 'delete') {
|
||||||
|
|
||||||
$pdo->prepare('DELETE FROM gallery_comments WHERE id = ?')->execute([$commentId]);
|
$pdo->prepare('DELETE FROM gallery_comments WHERE id = ?')->execute([$commentId]);
|
||||||
moderation_clear_reports('comment', $commentId);
|
moderation_clear_reports('comment', $commentId);
|
||||||
|
reactions_delete('comment', [$commentId]);
|
||||||
// Loescht die Moderation einen fremden Kommentar auf einem fremden Bild -> ins Log
|
// Loescht die Moderation einen fremden Kommentar auf einem fremden Bild -> ins Log
|
||||||
$isAuthor = (int) $comment['author_id'] === (int) $me['id'];
|
$isAuthor = (int) $comment['author_id'] === (int) $me['id'];
|
||||||
$isOwner = (int) $comment['owner_id'] === (int) $me['id'];
|
$isOwner = (int) $comment['owner_id'] === (int) $me['id'];
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,16 @@ function current_user(): ?array
|
||||||
return null;
|
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;
|
$user = $row;
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -415,3 +415,42 @@ function show_not_found(): void
|
||||||
include __DIR__ . '/not_found.php';
|
include __DIR__ . '/not_found.php';
|
||||||
exit;
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,10 @@ function moderation_initial_status(string $type, string $text = ''): array
|
||||||
if (moderation_can()) {
|
if (moderation_can()) {
|
||||||
return ['visible', null];
|
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()) {
|
if (moderation_all_manual()) {
|
||||||
return ['pending', 'Alles wird gerade manuell freigegeben'];
|
return ['pending', 'Alles wird gerade manuell freigegeben'];
|
||||||
}
|
}
|
||||||
|
|
@ -165,3 +169,151 @@ function moderation_my_reports(string $type, array $ids): array
|
||||||
return [];
|
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<string, string> 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<string, string> 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, '*') ? '' : '(?<!\p{L})';
|
||||||
|
$after = str_ends_with((string) $word, '*') ? '' : '(?!\p{L})';
|
||||||
|
foreach ($variants as $variant) {
|
||||||
|
if (preg_match('/' . $before . $core . $after . '/u', $variant)) {
|
||||||
|
$hits[(string) $word] = $action;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $hits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Strengste Aktion der Treffer (block > 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<int, array{0: string, 1: string}>
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
128
includes/reactions.php
Normal file
128
includes/reactions.php
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reaktionen wie bei Discord: Emojis unter Galeriebildern und Kommentaren. Jedes Mitglied kann
|
||||||
|
* pro Inhalt mehrere verschiedene Emojis setzen, jedes aber nur einmal (nochmal klicken = weg).
|
||||||
|
* Nur Emojis aus REACTION_EMOJIS - so kann niemand beliebigen Text als "Reaktion" posten.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const REACTION_EMOJIS = ['👍', '❤️', '😂', '😮', '😢', '🔥', '🎉', '👏', '💪', '😍', '🤯', '👀', '🙏', '💯', '⚔️', '🏆'];
|
||||||
|
// Inhaltsarten: Schluessel => Tabelle
|
||||||
|
const REACTION_TYPES = ['picture' => 'member_gallery', 'comment' => 'gallery_comments'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reaktionen fuer mehrere Inhalte einer Art, in der Reihenfolge der ersten Reaktion.
|
||||||
|
*
|
||||||
|
* @param array<int, int> $ids
|
||||||
|
* @return array<int, array<string, array{count: int, mine: bool, names: array<int, string>}>>
|
||||||
|
*/
|
||||||
|
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<string, array{count: int, mine: bool, names: array<int, string>}> $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 '<span class="' . $class . '" title="' . e($title) . '">' . $inner . '</span>';
|
||||||
|
}
|
||||||
|
return '<form method="post" action="/reaction_action.php" class="reaction-form">' . csrf_field()
|
||||||
|
. '<input type="hidden" name="type" value="' . e($type) . '"><input type="hidden" name="id" value="' . $contentId . '">'
|
||||||
|
. '<input type="hidden" name="emoji" value="' . e($emoji) . '">'
|
||||||
|
. '<button type="submit" class="' . $class . '" title="' . e($title) . '">' . $inner . '</button></form>';
|
||||||
|
};
|
||||||
|
|
||||||
|
$html = '<div class="reaction-bar' . ($compact ? ' reaction-bar-compact' : '') . '" data-type="' . e($type) . '" data-id="' . $contentId . '">';
|
||||||
|
foreach ($reactions as $emoji => $info) {
|
||||||
|
$html .= $form(
|
||||||
|
(string) $emoji,
|
||||||
|
'<span class="reaction-emoji">' . e((string) $emoji) . '</span><span class="reaction-count">' . $info['count'] . '</span>',
|
||||||
|
'reaction' . ($info['mine'] ? ' is-mine' : ''),
|
||||||
|
reaction_names_label($info['names']) . ($canReact ? ($info['mine'] ? ' - klicken zum Entfernen' : ' - klicken zum Mitreagieren') : '')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ($canReact) {
|
||||||
|
$html .= '<details class="reaction-add"><summary class="reaction reaction-add-button" title="Reaktion hinzufügen" aria-label="Reaktion hinzufügen">'
|
||||||
|
. '<span class="reaction-emoji">😀</span><span class="reaction-plus">+</span></summary><div class="reaction-picker">';
|
||||||
|
foreach (REACTION_EMOJIS as $emoji) {
|
||||||
|
$html .= $form($emoji, e($emoji), 'reaction-pick', $emoji);
|
||||||
|
}
|
||||||
|
$html .= '</div></details>';
|
||||||
|
}
|
||||||
|
return $html . '</div>';
|
||||||
|
}
|
||||||
|
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu.
|
// 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).
|
* 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_picture (gallery_id, created_at),
|
||||||
INDEX idx_gallery_comments_author (author_id, created_at)
|
INDEX idx_gallery_comments_author (author_id, created_at)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
) 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,
|
SQL,
|
||||||
'content_reports' => <<<'SQL'
|
'content_reports' => <<<'SQL'
|
||||||
CREATE TABLE IF NOT EXISTS content_reports (
|
CREATE TABLE IF NOT EXISTS content_reports (
|
||||||
|
|
@ -392,6 +420,11 @@ function schema_column_upgrades(): array
|
||||||
"UPDATE users SET tour_completed_at = NOW()",
|
"UPDATE users SET tour_completed_at = NOW()",
|
||||||
],
|
],
|
||||||
// Wird hochgezaehlt, um alle Sitzungen eines Kontos sofort zu beenden (Sperren/Abmelden).
|
// 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",
|
'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)
|
// 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",
|
'gallery_comments_enabled' => "ALTER TABLE users ADD COLUMN gallery_comments_enabled TINYINT(1) NOT NULL DEFAULT 1 AFTER profile_bio",
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ const SECURITY_LIMITS = [
|
||||||
'upload' => [30, 600], // hochgeladene Bilder pro Konto
|
'upload' => [30, 600], // hochgeladene Bilder pro Konto
|
||||||
'comment' => [6, 300], // Kommentare unter Galeriebildern pro Konto
|
'comment' => [6, 300], // Kommentare unter Galeriebildern pro Konto
|
||||||
'report' => [10, 600], // Meldungen (Melden-Knopf) pro Konto
|
'report' => [10, 600], // Meldungen (Melden-Knopf) pro Konto
|
||||||
|
'reaction' => [60, 300], // Reaktionen (Emojis) pro Konto
|
||||||
'bug' => [5, 3600], // Fehlermeldungen pro Konto
|
'bug' => [5, 3600], // Fehlermeldungen pro Konto
|
||||||
'login_ip' => [15, 900], // fehlgeschlagene Logins pro IP (egal welches Konto)
|
'login_ip' => [15, 900], // fehlgeschlagene Logins pro IP (egal welches Konto)
|
||||||
'login_pair' => [5, 900], // fehlgeschlagene Logins pro IP + Benutzername
|
'login_pair' => [5, 900], // fehlgeschlagene Logins pro IP + Benutzername
|
||||||
|
|
@ -52,7 +53,7 @@ function audit_area_for_script(string $script): string
|
||||||
$prefixes = [
|
$prefixes = [
|
||||||
'raid' => 'raids', 'premade' => 'premades', 'event' => 'events', 'tactics' => 'map', 'map' => 'map',
|
'raid' => 'raids', 'premade' => 'premades', 'event' => 'events', 'tactics' => 'map', 'map' => 'map',
|
||||||
'warehouse' => 'warehouse', 'contributions' => 'contributions', 'shop' => 'shop',
|
'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',
|
'user' => 'users', 'role' => 'users', 'discord' => 'users', 'settings' => 'users',
|
||||||
];
|
];
|
||||||
foreach ($prefixes as $prefix => $area) {
|
foreach ($prefixes as $prefix => $area) {
|
||||||
|
|
@ -192,6 +193,7 @@ function security_bucket_label(string $bucket): string
|
||||||
'upload' => 'Bilder hochladen',
|
'upload' => 'Bilder hochladen',
|
||||||
'comment' => 'Kommentare',
|
'comment' => 'Kommentare',
|
||||||
'report' => 'Meldungen',
|
'report' => 'Meldungen',
|
||||||
|
'reaction' => 'Reaktionen',
|
||||||
'bug' => 'Fehlermeldungen',
|
'bug' => 'Fehlermeldungen',
|
||||||
'destructive' => 'Löschungen',
|
'destructive' => 'Löschungen',
|
||||||
][$bucket] ?? $bucket;
|
][$bucket] ?? $bucket;
|
||||||
|
|
|
||||||
14
member.php
14
member.php
|
|
@ -1,13 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/includes/bootstrap.php';
|
require_once __DIR__ . '/includes/bootstrap.php';
|
||||||
require_once __DIR__ . '/includes/member_profile.php';
|
require_once __DIR__ . '/includes/member_profile.php';
|
||||||
|
require_once __DIR__ . '/includes/reactions.php';
|
||||||
require_once __DIR__ . '/includes/wiki.php'; // wiki_render() fuer den Beschreibungstext
|
require_once __DIR__ . '/includes/wiki.php'; // wiki_render() fuer den Beschreibungstext
|
||||||
require_permission('members.view');
|
require_permission('members.view');
|
||||||
|
|
||||||
$id = (int) ($_GET['id'] ?? 0);
|
$id = (int) ($_GET['id'] ?? 0);
|
||||||
$stmt = db()->prepare(
|
$stmt = db()->prepare(
|
||||||
"SELECT id, username, display_name, class_name, profile_bio, gallery_comments_enabled, discord_id, discord_username, avatar_filename, status,
|
"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 = ?"
|
FROM users WHERE id = ?"
|
||||||
);
|
);
|
||||||
$stmt->execute([$id]);
|
$stmt->execute([$id]);
|
||||||
|
|
@ -33,6 +35,7 @@ $galleryStmt->execute([$id]);
|
||||||
$gallery = $galleryStmt->fetchAll();
|
$gallery = $galleryStmt->fetchAll();
|
||||||
$commentsEnabled = !empty($member['gallery_comments_enabled']);
|
$commentsEnabled = !empty($member['gallery_comments_enabled']);
|
||||||
$commentCounts = $commentsEnabled ? gallery_comment_counts(array_map('intval', array_column($gallery, 'id'))) : [];
|
$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'];
|
$name = $member['display_name'] !== '' ? $member['display_name'] : $member['username'];
|
||||||
$canEdit = profile_can_edit($id);
|
$canEdit = profile_can_edit($id);
|
||||||
|
|
@ -50,6 +53,7 @@ include __DIR__ . '/includes/header.php';
|
||||||
<span class="discord-inline"><?= discord_logo(14) ?> <?= e($member['discord_username']) ?></span>
|
<span class="discord-inline"><?= discord_logo(14) ?> <?= e($member['discord_username']) ?></span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<span title="<?= $member['joined_discord'] ? 'Beitritt zum Discord-Server der Legion' : 'Konto auf der Website angelegt' ?>">Dabei seit <?= e(date('d.m.Y', strtotime($member['joined_at']))) ?></span>
|
<span title="<?= $member['joined_discord'] ? 'Beitritt zum Discord-Server der Legion' : 'Konto auf der Website angelegt' ?>">Dabei seit <?= e(date('d.m.Y', strtotime($member['joined_at']))) ?></span>
|
||||||
|
<span class="member-last-seen<?= is_online($member['last_active']) ? ' is-online' : '' ?>" title="Zuletzt auf der Website aktiv"><span class="online-dot"></span><?= is_online($member['last_active']) ? 'Online' : 'Zuletzt aktiv ' . e(last_active_label($member['last_active'])) ?></span>
|
||||||
<?php if (!empty($characters)): ?><span><?= count($characters) ?> <?= count($characters) === 1 ? 'Charakter' : 'Charaktere' ?></span><?php endif; ?>
|
<?php if (!empty($characters)): ?><span><?= count($characters) ?> <?= count($characters) === 1 ? 'Charakter' : 'Charaktere' ?></span><?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php if (!empty($groups)): ?>
|
<?php if (!empty($groups)): ?>
|
||||||
|
|
@ -129,6 +133,14 @@ include __DIR__ . '/includes/header.php';
|
||||||
<?php if ($commentsEnabled): ?>data-comments-url="<?= e($pictureUrl . '#kommentare') ?>" data-comments-count="<?= $commentCount ?>"<?php endif; ?>>
|
<?php if ($commentsEnabled): ?>data-comments-url="<?= e($pictureUrl . '#kommentare') ?>" data-comments-count="<?= $commentCount ?>"<?php endif; ?>>
|
||||||
<img src="<?= e($url) ?>" alt="<?= e($picture['caption'] ?: 'Bild von ' . $name) ?>" loading="lazy">
|
<img src="<?= e($url) ?>" alt="<?= e($picture['caption'] ?: 'Bild von ' . $name) ?>" loading="lazy">
|
||||||
</a>
|
</a>
|
||||||
|
<?php $reactionsHere = $pictureReactions[(int) $picture['id']] ?? []; ?>
|
||||||
|
<?php if ($reactionsHere): ?>
|
||||||
|
<?php arsort($reactionsHere); ?>
|
||||||
|
<a class="gallery-reaction-summary" href="<?= e($pictureUrl) ?>" title="Reaktionen ansehen">
|
||||||
|
<?= e(implode('', array_slice(array_keys($reactionsHere), 0, 3))) ?>
|
||||||
|
<span><?= array_sum(array_column($reactionsHere, 'count')) ?></span>
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
<?php if ($commentsEnabled): ?>
|
<?php if ($commentsEnabled): ?>
|
||||||
<a class="gallery-comment-badge<?= $commentCount > 0 ? ' has-comments' : '' ?>" href="<?= e($pictureUrl . '#kommentare') ?>"
|
<a class="gallery-comment-badge<?= $commentCount > 0 ? ' has-comments' : '' ?>" href="<?= e($pictureUrl . '#kommentare') ?>"
|
||||||
title="<?= $commentCount > 0 ? $commentCount . ' ' . ($commentCount === 1 ? 'Kommentar' : 'Kommentare') . ' ansehen' : 'Kommentieren' ?>">
|
title="<?= $commentCount > 0 ? $commentCount . ' ' . ($commentCount === 1 ? 'Kommentar' : 'Kommentare') . ' ansehen' : 'Kommentieren' ?>">
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,10 @@ switch ($action) {
|
||||||
'tmp_name' => $_FILES['images']['tmp_name'][$i] ?? '',
|
'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));
|
$uploadCount = count(array_filter($files, static fn (array $f): bool => $f['error'] !== UPLOAD_ERR_NO_FILE));
|
||||||
if ($uploadCount > 0 && !security_throttle('upload', $uploadCount)) {
|
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.');
|
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':
|
case 'gallery_update':
|
||||||
$caption = mb_substr(trim((string) ($_POST['caption'] ?? '')), 0, 150);
|
$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 = ?')
|
$pdo->prepare('UPDATE member_gallery SET caption = ? WHERE id = ? AND user_id = ?')
|
||||||
->execute([$caption !== '' ? $caption : null, (int) ($_POST['picture_id'] ?? 0), $userId]);
|
->execute([$caption !== '' ? $caption : null, (int) ($_POST['picture_id'] ?? 0), $userId]);
|
||||||
// Nachtraeglich ein Link in die Unterschrift? Dann erst wieder nach Freigabe sichtbar.
|
// Nachtraeglich ein Link oder zurueckgehaltenes Wort in der Unterschrift? Dann erst wieder nach Freigabe sichtbar.
|
||||||
if (!moderation_can() && moderation_has_link($caption)) {
|
[$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 = ?")
|
$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]);
|
->execute([$captionNote, (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.');
|
set_flash('success', 'Bildunterschrift gespeichert. Das Bild ist bis zur Freigabe durch die Moderation nur für dich sichtbar.');
|
||||||
redirect($back);
|
redirect($back);
|
||||||
}
|
}
|
||||||
set_flash('success', 'Bildunterschrift gespeichert.');
|
set_flash('success', 'Bildunterschrift gespeichert.');
|
||||||
|
|
@ -213,6 +223,11 @@ switch ($action) {
|
||||||
$stmt->execute([(int) ($_POST['picture_id'] ?? 0), $userId]);
|
$stmt->execute([(int) ($_POST['picture_id'] ?? 0), $userId]);
|
||||||
$filename = $stmt->fetchColumn();
|
$filename = $stmt->fetchColumn();
|
||||||
if ($filename !== false) {
|
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)]);
|
$pdo->prepare('DELETE FROM member_gallery WHERE id = ?')->execute([(int) ($_POST['picture_id'] ?? 0)]);
|
||||||
profile_delete_file((string) $filename);
|
profile_delete_file((string) $filename);
|
||||||
moderation_clear_reports('picture', (int) ($_POST['picture_id'] ?? 0));
|
moderation_clear_reports('picture', (int) ($_POST['picture_id'] ?? 0));
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ include __DIR__ . '/includes/header.php';
|
||||||
<input type="hidden" name="user_id" value="<?= $id ?>">
|
<input type="hidden" name="user_id" value="<?= $id ?>">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="enabled" value="1" <?= !empty($member['gallery_comments_enabled']) ? 'checked' : '' ?> onchange="this.form.submit()">
|
<input type="checkbox" name="enabled" value="1" <?= !empty($member['gallery_comments_enabled']) ? 'checked' : '' ?> onchange="this.form.submit()">
|
||||||
Andere Mitglieder dürfen meine Bilder kommentieren
|
Andere Mitglieder dürfen meine Bilder kommentieren und mit Emojis reagieren
|
||||||
</label>
|
</label>
|
||||||
<noscript><button type="submit" class="button-secondary button-small">Speichern</button></noscript>
|
<noscript><button type="submit" class="button-secondary button-small">Speichern</button></noscript>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/includes/bootstrap.php';
|
require_once __DIR__ . '/includes/bootstrap.php';
|
||||||
require_once __DIR__ . '/includes/member_profile.php';
|
require_once __DIR__ . '/includes/member_profile.php';
|
||||||
|
require_once __DIR__ . '/includes/reactions.php';
|
||||||
require_permission('members.view');
|
require_permission('members.view');
|
||||||
|
|
||||||
$pictureId = (int) ($_GET['id'] ?? 0);
|
$pictureId = (int) ($_GET['id'] ?? 0);
|
||||||
|
|
@ -43,6 +44,10 @@ if ($commentsEnabled) {
|
||||||
$commentStmt->execute([$pictureId, (int) $me['id'], $isModerator ? 1 : 0]);
|
$commentStmt->execute([$pictureId, (int) $me['id'], $isModerator ? 1 : 0]);
|
||||||
$comments = $commentStmt->fetchAll();
|
$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)
|
// Schon gemeldet? (Knopf dann ausgegraut)
|
||||||
$reportedPicture = !empty(moderation_my_reports('picture', [$pictureId]));
|
$reportedPicture = !empty(moderation_my_reports('picture', [$pictureId]));
|
||||||
$reportedComments = moderation_my_reports('comment', array_map('intval', array_column($comments, 'id')));
|
$reportedComments = moderation_my_reports('comment', array_map('intval', array_column($comments, 'id')));
|
||||||
|
|
@ -101,6 +106,9 @@ include __DIR__ . '/includes/header.php';
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if (!empty($picture['caption'])): ?><figcaption><?= e($picture['caption']) ?></figcaption><?php endif; ?>
|
<?php if (!empty($picture['caption'])): ?><figcaption><?= e($picture['caption']) ?></figcaption><?php endif; ?>
|
||||||
</figure>
|
</figure>
|
||||||
|
<?php if ($commentsEnabled): ?>
|
||||||
|
<div class="picture-reactions"><?= reactions_bar_html('picture', $pictureId, $pictureReactions, true) ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel picture-comments" id="kommentare">
|
<div class="panel picture-comments" id="kommentare">
|
||||||
|
|
@ -143,6 +151,7 @@ include __DIR__ . '/includes/header.php';
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<p><?= gallery_comment_html((string) $comment['body']) ?></p>
|
<p><?= gallery_comment_html((string) $comment['body']) ?></p>
|
||||||
|
<?= reactions_bar_html('comment', (int) $comment['id'], $commentReactions[(int) $comment['id']] ?? [], true, true) ?>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
@ -165,6 +174,7 @@ include __DIR__ . '/includes/header.php';
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script src="<?= e(asset_url('/assets/js/reactions.js')) ?>"></script>
|
||||||
<script>
|
<script>
|
||||||
// Pfeiltasten blaettern (nicht beim Schreiben)
|
// Pfeiltasten blaettern (nicht beim Schreiben)
|
||||||
document.addEventListener('keydown', function (e) {
|
document.addEventListener('keydown', function (e) {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ foreach (db()->query('SELECT user_id, role_id FROM user_roles')->fetchAll() as $
|
||||||
$members = db()->query(
|
$members = db()->query(
|
||||||
"SELECT u.id, u.username, u.display_name, u.class_name, u.discord_id, u.avatar_filename,
|
"SELECT u.id, u.username, u.display_name, u.class_name, u.discord_id, u.avatar_filename,
|
||||||
COALESCE(u.discord_joined_at, u.created_at) AS joined_at,
|
COALESCE(u.discord_joined_at, u.created_at) AS joined_at,
|
||||||
|
COALESCE(u.last_seen_at, u.last_login) AS last_active,
|
||||||
GROUP_CONCAT(COALESCE(NULLIF(r.display_name, ''), r.name) ORDER BY COALESCE(r.roster_order, 999), r.name SEPARATOR '|') AS role_names
|
GROUP_CONCAT(COALESCE(NULLIF(r.display_name, ''), r.name) ORDER BY COALESCE(r.roster_order, 999), r.name SEPARATOR '|') AS role_names
|
||||||
FROM users u
|
FROM users u
|
||||||
LEFT JOIN user_roles ur ON ur.user_id = u.id
|
LEFT JOIN user_roles ur ON ur.user_id = u.id
|
||||||
|
|
@ -84,7 +85,8 @@ function member_card(array $member): string
|
||||||
. ' data-classes="' . e('|' . implode('|', $classes) . '|') . '"'
|
. ' data-classes="' . e('|' . implode('|', $classes) . '|') . '"'
|
||||||
. ' data-class="' . e((string) ($member['class_name'] ?? '')) . '"'
|
. ' data-class="' . e((string) ($member['class_name'] ?? '')) . '"'
|
||||||
. ' data-rank="' . (int) $member['rank'] . '"'
|
. ' data-rank="' . (int) $member['rank'] . '"'
|
||||||
. ' data-joined="' . e((string) $member['joined_at']) . '"';
|
. ' data-joined="' . e((string) $member['joined_at']) . '"'
|
||||||
|
. ' data-active="' . e((string) ($member['last_active'] ?? '')) . '"';
|
||||||
|
|
||||||
$html = '<a class="panel member-card" href="/member.php?id=' . (int) $member['id'] . '"' . $data . '>'
|
$html = '<a class="panel member-card" href="/member.php?id=' . (int) $member['id'] . '"' . $data . '>'
|
||||||
. avatar_html($member, 48) . '<div class="member-card-body">'
|
. avatar_html($member, 48) . '<div class="member-card-body">'
|
||||||
|
|
@ -100,6 +102,9 @@ function member_card(array $member): string
|
||||||
}
|
}
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
}
|
}
|
||||||
|
$online = is_online($member['last_active'] ?? null);
|
||||||
|
$html .= '<div class="member-last-seen' . ($online ? ' is-online' : '') . '" title="Zuletzt auf der Website aktiv">'
|
||||||
|
. '<span class="online-dot"></span>' . ($online ? 'Online' : 'aktiv ' . e(last_active_label($member['last_active'] ?? null))) . '</div>';
|
||||||
if (!empty($roles)) {
|
if (!empty($roles)) {
|
||||||
$html .= '<div class="member-roles">';
|
$html .= '<div class="member-roles">';
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
|
|
@ -161,6 +166,7 @@ include __DIR__ . '/includes/header.php';
|
||||||
<button type="button" data-value="class">Klasse</button>
|
<button type="button" data-value="class">Klasse</button>
|
||||||
<button type="button" data-value="joined" title="Zuletzt beigetreten">Neueste</button>
|
<button type="button" data-value="joined" title="Zuletzt beigetreten">Neueste</button>
|
||||||
<button type="button" data-value="oldest" title="Am längsten dabei">Dienstälteste</button>
|
<button type="button" data-value="oldest" title="Am längsten dabei">Dienstälteste</button>
|
||||||
|
<button type="button" data-value="active" title="Wer zuletzt auf der Website war, steht oben">Zuletzt aktiv</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="members-filter-meta">
|
<div class="members-filter-meta">
|
||||||
|
|
|
||||||
180
moderation.php
180
moderation.php
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Moderation: Freigabe-Liste (wartende Bilder und Kommentare) und gemeldete Inhalte.
|
* Moderation: Freigabe-Liste (wartende Bilder und Kommentare, gemeldete Inhalte), alle Kommentare
|
||||||
|
* mit Markierungen fuer Auffaelliges und der Schimpfwortfilter.
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/includes/bootstrap.php';
|
require_once __DIR__ . '/includes/bootstrap.php';
|
||||||
require_once __DIR__ . '/includes/member_profile.php';
|
require_once __DIR__ . '/includes/member_profile.php';
|
||||||
|
|
@ -44,7 +45,7 @@ $pendingTotal = count($pendingPictures) + count($pendingComments);
|
||||||
$reportedTotal = count($reportedPictures) + count($reportedComments);
|
$reportedTotal = count($reportedPictures) + count($reportedComments);
|
||||||
|
|
||||||
/** Knoepfe fuer einen Inhalt. */
|
/** Knoepfe fuer einen Inhalt. */
|
||||||
$actions = static function (string $type, int $id, array $which): string {
|
$actions = static function (string $type, int $id, array $which, string $back = ''): string {
|
||||||
$labels = [
|
$labels = [
|
||||||
'approve' => ['Freigeben', 'button-success'],
|
'approve' => ['Freigeben', 'button-success'],
|
||||||
'hide' => ['Ausblenden', 'button-secondary'],
|
'hide' => ['Ausblenden', 'button-secondary'],
|
||||||
|
|
@ -58,6 +59,7 @@ $actions = static function (string $type, int $id, array $which): string {
|
||||||
$html .= '<form class="inline-form" method="post" action="/moderation_action.php"' . $confirm . '>' . csrf_field()
|
$html .= '<form class="inline-form" method="post" action="/moderation_action.php"' . $confirm . '>' . csrf_field()
|
||||||
. '<input type="hidden" name="action" value="' . $action . '"><input type="hidden" name="type" value="' . $type . '">'
|
. '<input type="hidden" name="action" value="' . $action . '"><input type="hidden" name="type" value="' . $type . '">'
|
||||||
. '<input type="hidden" name="id" value="' . $id . '">'
|
. '<input type="hidden" name="id" value="' . $id . '">'
|
||||||
|
. ($back !== '' ? '<input type="hidden" name="back" value="' . e($back) . '">' : '')
|
||||||
. '<button type="submit" class="button-small ' . $class . '">' . $label . '</button></form>';
|
. '<button type="submit" class="button-small ' . $class . '">' . $label . '</button></form>';
|
||||||
}
|
}
|
||||||
return $html . '</div>';
|
return $html . '</div>';
|
||||||
|
|
@ -78,6 +80,60 @@ $reportList = static function (string $type, int $id) use ($reports): string {
|
||||||
return $html . '</ul>';
|
return $html . '</ul>';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Reiter: Freigabe (Standard), alle Kommentare, Schimpfwortfilter
|
||||||
|
$tab = in_array($_GET['tab'] ?? '', ['comments', 'filter'], true) ? (string) $_GET['tab'] : 'queue';
|
||||||
|
|
||||||
|
// ---- Alle Kommentare mit Markierungen ----
|
||||||
|
$commentFilter = in_array($_GET['show'] ?? '', ['flagged', 'pending', 'reported'], true) ? (string) $_GET['show'] : '';
|
||||||
|
$commentQuery = mb_substr(trim((string) ($_GET['q'] ?? '')), 0, 100);
|
||||||
|
$allComments = [];
|
||||||
|
$flagCounts = ['' => 0, 'flagged' => 0, 'pending' => 0, 'reported' => 0];
|
||||||
|
if ($tab === 'comments') {
|
||||||
|
// Die letzten 1000 reichen - bei einer Legion ist das weit mehr als genug
|
||||||
|
$rows = $pdo->query(
|
||||||
|
"SELECT c.id, c.body, c.status, c.moderation_note, c.created_at, c.author_id, c.gallery_id, g.filename,
|
||||||
|
g.user_id AS owner_id, $name AS author, COALESCE(u.discord_joined_at, u.created_at) AS author_since,
|
||||||
|
COALESCE(NULLIF(o.display_name, ''), o.username) AS owner,
|
||||||
|
(SELECT COUNT(*) FROM content_reports r WHERE r.content_type = 'comment' AND r.content_id = c.id) AS report_count
|
||||||
|
FROM gallery_comments c
|
||||||
|
JOIN users u ON u.id = c.author_id
|
||||||
|
JOIN member_gallery g ON g.id = c.gallery_id
|
||||||
|
JOIN users o ON o.id = g.user_id
|
||||||
|
ORDER BY c.created_at DESC, c.id DESC LIMIT 1000"
|
||||||
|
)->fetchAll();
|
||||||
|
$needle = mb_strtolower($commentQuery);
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$row['flags'] = moderation_comment_flags($row);
|
||||||
|
$row['critical'] = in_array('critical', array_column($row['flags'], 1), true);
|
||||||
|
$flagCounts['']++;
|
||||||
|
$flagCounts['flagged'] += $row['flags'] ? 1 : 0;
|
||||||
|
$flagCounts['pending'] += $row['status'] === 'pending' ? 1 : 0;
|
||||||
|
$flagCounts['reported'] += (int) $row['report_count'] > 0 ? 1 : 0;
|
||||||
|
|
||||||
|
$matchesFilter = match ($commentFilter) {
|
||||||
|
'flagged' => (bool) $row['flags'],
|
||||||
|
'pending' => $row['status'] === 'pending',
|
||||||
|
'reported' => (int) $row['report_count'] > 0,
|
||||||
|
default => true,
|
||||||
|
};
|
||||||
|
$matchesQuery = $needle === '' || mb_strpos(mb_strtolower($row['body'] . ' ' . $row['author'] . ' ' . $row['owner']), $needle) !== false;
|
||||||
|
if ($matchesFilter && $matchesQuery) {
|
||||||
|
$allComments[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$commentsPerPage = 40;
|
||||||
|
$commentPageCount = max(1, (int) ceil(count($allComments) / $commentsPerPage));
|
||||||
|
$commentPage = min($commentPageCount, max(1, (int) ($_GET['page'] ?? 1)));
|
||||||
|
$commentsShown = array_slice($allComments, ($commentPage - 1) * $commentsPerPage, $commentsPerPage);
|
||||||
|
$commentUrl = static function (array $overrides = []) use ($commentFilter, $commentQuery): string {
|
||||||
|
$params = array_filter(array_merge(['tab' => 'comments', 'show' => $commentFilter, 'q' => $commentQuery], $overrides), static fn ($v) => $v !== '' && $v !== null);
|
||||||
|
return '/moderation.php?' . http_build_query($params) . '&';
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---- Schimpfwortfilter ----
|
||||||
|
$filterWords = $tab === 'filter' ? moderation_words() : [];
|
||||||
|
|
||||||
$pageTitle = 'Moderation';
|
$pageTitle = 'Moderation';
|
||||||
$containerWide = true;
|
$containerWide = true;
|
||||||
include __DIR__ . '/includes/header.php';
|
include __DIR__ . '/includes/header.php';
|
||||||
|
|
@ -98,8 +154,15 @@ include __DIR__ . '/includes/header.php';
|
||||||
</label>
|
</label>
|
||||||
<noscript><button type="submit" class="button-secondary button-small">Speichern</button></noscript>
|
<noscript><button type="submit" class="button-secondary button-small">Speichern</button></noscript>
|
||||||
</form>
|
</form>
|
||||||
|
<nav class="members-segment moderation-tabs" aria-label="Bereiche">
|
||||||
|
<a href="/moderation.php" class="<?= $tab === 'queue' ? 'active' : '' ?>">Freigabe<?= $pendingTotal + $reportedTotal > 0 ? ' <span class="chip-count">' . ($pendingTotal + $reportedTotal) . '</span>' : '' ?></a>
|
||||||
|
<a href="/moderation.php?tab=comments" class="<?= $tab === 'comments' ? 'active' : '' ?>">Alle Kommentare</a>
|
||||||
|
<a href="/moderation.php?tab=filter" class="<?= $tab === 'filter' ? 'active' : '' ?>">Schimpfwortfilter</a>
|
||||||
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php if ($tab === 'queue'): ?>
|
||||||
|
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<h2>Wartet auf Freigabe <span class="chip-count"><?= $pendingTotal ?></span></h2>
|
<h2>Wartet auf Freigabe <span class="chip-count"><?= $pendingTotal ?></span></h2>
|
||||||
<?php if ($pendingTotal === 0): ?>
|
<?php if ($pendingTotal === 0): ?>
|
||||||
|
|
@ -187,4 +250,117 @@ include __DIR__ . '/includes/header.php';
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<?php endif; /* Reiter Freigabe */ ?>
|
||||||
|
|
||||||
|
<?php if ($tab === 'comments'): ?>
|
||||||
|
<div class="panel">
|
||||||
|
<h2>Alle Kommentare</h2>
|
||||||
|
<form class="list-toolbar" method="get" action="/moderation.php">
|
||||||
|
<input type="hidden" name="tab" value="comments">
|
||||||
|
<input type="hidden" name="show" value="<?= e($commentFilter) ?>">
|
||||||
|
<label class="search-field">
|
||||||
|
<?= icon('search') ?>
|
||||||
|
<input type="search" name="q" value="<?= e($commentQuery) ?>" placeholder="Text, Verfasser oder Bild-Besitzer suchen …" aria-label="Kommentare durchsuchen">
|
||||||
|
</label>
|
||||||
|
<div class="list-toolbar-row">
|
||||||
|
<div class="members-chips" role="group" aria-label="Filtern">
|
||||||
|
<?php foreach (['' => 'Alle', 'flagged' => 'Markiert', 'pending' => 'Wartet auf Freigabe', 'reported' => 'Gemeldet'] as $value => $label): ?>
|
||||||
|
<button type="submit" name="show" value="<?= e($value) ?>" class="members-chip<?= $commentFilter === $value ? ' active' : '' ?>">
|
||||||
|
<?= e($label) ?> <span class="chip-count"><?= $flagCounts[$value] ?></span>
|
||||||
|
</button>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<span class="list-search-count text-muted"><?= count($allComments) ?> <?= count($allComments) === 1 ? 'Kommentar' : 'Kommentare' ?></span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php if (!$commentsShown): ?>
|
||||||
|
<p class="text-muted"><?= $commentFilter !== '' || $commentQuery !== '' ? 'Kein Kommentar passt zu Suche und Filter.' : 'Noch keine Kommentare.' ?></p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php foreach ($commentsShown as $comment): ?>
|
||||||
|
<div class="moderation-card moderation-comment<?= $comment['critical'] ? ' is-critical' : ($comment['flags'] ? ' is-flagged' : '') ?>">
|
||||||
|
<a href="/member_picture.php?id=<?= (int) $comment['gallery_id'] ?>#kommentar-<?= (int) $comment['id'] ?>" class="moderation-thumb moderation-thumb-small" title="Zum Bild">
|
||||||
|
<img src="<?= e(profile_image_url($comment['filename'])) ?>" alt="" loading="lazy">
|
||||||
|
</a>
|
||||||
|
<div class="moderation-body">
|
||||||
|
<div class="moderation-meta">
|
||||||
|
<a href="/member.php?id=<?= (int) $comment['author_id'] ?>"><strong><?= e((string) $comment['author']) ?></strong></a>
|
||||||
|
<span class="text-muted">unter einem Bild von <?= e((string) $comment['owner']) ?> · <?= e(date('d.m.Y H:i', strtotime((string) $comment['created_at']))) ?></span>
|
||||||
|
</div>
|
||||||
|
<?php if ($comment['flags']): ?>
|
||||||
|
<div class="moderation-flags">
|
||||||
|
<?php foreach ($comment['flags'] as [$flagText, $level]): ?>
|
||||||
|
<span class="mod-flag mod-flag-<?= e($level) ?>"><?= $level === 'critical' ? '⚠' : '•' ?> <?= e($flagText) ?></span>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<p class="moderation-text"><?= nl2br(e((string) $comment['body']), false) ?></p>
|
||||||
|
<?= $reportList('comment', (int) $comment['id']) ?>
|
||||||
|
<?php
|
||||||
|
$commentActions = $comment['status'] === 'pending' ? ['approve', 'delete'] : ['hide', 'delete'];
|
||||||
|
if ((int) $comment['report_count'] > 0 && $comment['status'] !== 'pending') {
|
||||||
|
array_splice($commentActions, 1, 0, ['dismiss']);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?= $actions('comment', (int) $comment['id'], $commentActions, 'comments') ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php if ($commentPageCount > 1): ?>
|
||||||
|
<div class="warehouse-pages">
|
||||||
|
<span class="text-muted">Seite <?= $commentPage ?> von <?= $commentPageCount ?></span>
|
||||||
|
<?php render_pagination($commentUrl(), $commentPage, $commentPageCount); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($tab === 'filter'): ?>
|
||||||
|
<div class="panel">
|
||||||
|
<h2>Schimpfwortfilter <span class="chip-count"><?= count($filterWords) ?></span></h2>
|
||||||
|
<p class="text-muted">
|
||||||
|
Gilt für Kommentare und Bildunterschriften. Groß-/Kleinschreibung egal, auch Schreibweisen wie
|
||||||
|
„f1ck“ oder „fiiick“ werden erkannt. Normalerweise zählt nur das ganze Wort -
|
||||||
|
mit <code>*</code> auch als Wortteil (<code>fick*</code> findet auch „ficken“, <code>*loch</code> auch „Arschloch“).
|
||||||
|
Die Moderation selbst ist vom Filter ausgenommen.
|
||||||
|
</p>
|
||||||
|
<form class="filter-word-form" method="post" action="/moderation_action.php">
|
||||||
|
<?= csrf_field() ?>
|
||||||
|
<input type="hidden" name="action" value="word_add">
|
||||||
|
<input type="text" name="word" maxlength="60" required placeholder="Wort oder Wortteil mit *" aria-label="Wort">
|
||||||
|
<select name="word_action" aria-label="Was passiert">
|
||||||
|
<?php foreach (MODERATION_WORD_ACTIONS as $value => $label): ?>
|
||||||
|
<option value="<?= e($value) ?>" <?= $value === 'hold' ? 'selected' : '' ?>><?= e($label) ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
<button type="submit">Hinzufügen</button>
|
||||||
|
</form>
|
||||||
|
<div class="filter-word-legend">
|
||||||
|
<span class="filter-word filter-word-flag">Nur markieren</span> erscheint markiert in „Alle Kommentare“
|
||||||
|
<span class="filter-word filter-word-hold">Zurückhalten</span> erst nach Freigabe sichtbar
|
||||||
|
<span class="filter-word filter-word-block">Blockieren</span> wird gar nicht gespeichert
|
||||||
|
</div>
|
||||||
|
<?php foreach (MODERATION_WORD_ACTIONS as $wordAction => $wordLabel): ?>
|
||||||
|
<?php $group = array_keys(array_filter($filterWords, static fn ($a) => $a === $wordAction)); ?>
|
||||||
|
<?php if (!$group) continue; ?>
|
||||||
|
<h3 class="filter-word-heading"><?= e($wordLabel) ?> <span class="chip-count"><?= count($group) ?></span></h3>
|
||||||
|
<div class="filter-word-list">
|
||||||
|
<?php foreach ($group as $word): ?>
|
||||||
|
<form class="filter-word filter-word-<?= e($wordAction) ?>" method="post" action="/moderation_action.php">
|
||||||
|
<?= csrf_field() ?>
|
||||||
|
<input type="hidden" name="word" value="<?= e((string) $word) ?>">
|
||||||
|
<span><?= e((string) $word) ?></span>
|
||||||
|
<select name="word_action" onchange="this.form.action.value = 'word_add'; this.form.submit()" aria-label="Aktion für <?= e((string) $word) ?>" title="Aktion ändern">
|
||||||
|
<?php foreach (['flag' => 'markieren ▾', 'hold' => 'zurückhalten ▾', 'block' => 'blockieren ▾'] as $value => $label): ?>
|
||||||
|
<option value="<?= e($value) ?>" <?= $value === $wordAction ? 'selected' : '' ?>><?= e($label) ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
<input type="hidden" name="action" value="word_delete">
|
||||||
|
<button type="submit" class="filter-word-remove" title="Entfernen" aria-label="<?= e((string) $word) ?> entfernen" onclick="this.form.action.value = 'word_delete'">×</button>
|
||||||
|
</form>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,11 @@
|
||||||
* - hide: ausblenden (zurueck in die Freigabe-Liste)
|
* - hide: ausblenden (zurueck in die Freigabe-Liste)
|
||||||
* - dismiss: Meldungen verwerfen, Inhalt bleibt sichtbar
|
* - dismiss: Meldungen verwerfen, Inhalt bleibt sichtbar
|
||||||
* - delete: endgueltig loeschen
|
* - delete: endgueltig loeschen
|
||||||
|
* - word_add / word_delete: Schimpfwortfilter pflegen (Hinzufuegen aendert auch die Aktion)
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/includes/bootstrap.php';
|
require_once __DIR__ . '/includes/bootstrap.php';
|
||||||
require_once __DIR__ . '/includes/member_profile.php';
|
require_once __DIR__ . '/includes/member_profile.php';
|
||||||
|
require_once __DIR__ . '/includes/reactions.php';
|
||||||
require_permission('members.view');
|
require_permission('members.view');
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
|
|
@ -17,6 +19,42 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
verify_csrf();
|
verify_csrf();
|
||||||
|
|
||||||
$action = (string) ($_POST['action'] ?? '');
|
$action = (string) ($_POST['action'] ?? '');
|
||||||
|
|
||||||
|
// Schimpfwortfilter (nur Moderation)
|
||||||
|
if ($action === 'word_add' || $action === 'word_delete') {
|
||||||
|
if (!moderation_can()) {
|
||||||
|
show_not_found();
|
||||||
|
}
|
||||||
|
$word = mb_strtolower(trim((string) preg_replace('/\s+/u', ' ', (string) ($_POST['word'] ?? ''))));
|
||||||
|
$word = mb_substr($word, 0, 60);
|
||||||
|
if (trim($word, '* ') === '') {
|
||||||
|
set_flash('error', 'Bitte ein Wort eingeben.');
|
||||||
|
redirect('/moderation.php?tab=filter');
|
||||||
|
}
|
||||||
|
if ($action === 'word_delete') {
|
||||||
|
db()->prepare('DELETE FROM moderation_words WHERE word = ?')->execute([$word]);
|
||||||
|
admin_log('🧹 Wort aus dem Schimpfwortfilter entfernt', ['Wort' => $word], 'info', 'members');
|
||||||
|
set_flash('success', '„' . $word . '“ entfernt.');
|
||||||
|
} else {
|
||||||
|
$wordAction = isset(MODERATION_WORD_ACTIONS[$_POST['word_action'] ?? '']) ? (string) $_POST['word_action'] : 'flag';
|
||||||
|
$exists = db()->prepare('SELECT action FROM moderation_words WHERE word = ?');
|
||||||
|
$exists->execute([$word]);
|
||||||
|
$before = $exists->fetchColumn();
|
||||||
|
if ($before === false) {
|
||||||
|
db()->prepare('INSERT INTO moderation_words (word, action, created_by) VALUES (?, ?, ?)')
|
||||||
|
->execute([$word, $wordAction, (int) current_user()['id']]);
|
||||||
|
} else {
|
||||||
|
db()->prepare('UPDATE moderation_words SET action = ? WHERE word = ?')->execute([$wordAction, $word]);
|
||||||
|
}
|
||||||
|
admin_log($before === false ? '🧹 Wort zum Schimpfwortfilter hinzugefügt' : '🧹 Schimpfwortfilter geändert', [
|
||||||
|
'Wort' => $word,
|
||||||
|
'Aktion' => MODERATION_WORD_ACTIONS[$wordAction],
|
||||||
|
], 'info', 'members');
|
||||||
|
set_flash('success', '„' . $word . '“: ' . MODERATION_WORD_ACTIONS[$wordAction] . '.');
|
||||||
|
}
|
||||||
|
redirect('/moderation.php?tab=filter');
|
||||||
|
}
|
||||||
|
|
||||||
$type = (string) ($_POST['type'] ?? '');
|
$type = (string) ($_POST['type'] ?? '');
|
||||||
$id = (int) ($_POST['id'] ?? 0);
|
$id = (int) ($_POST['id'] ?? 0);
|
||||||
if (!isset(MODERATION_TYPES[$type]) || $id <= 0) {
|
if (!isset(MODERATION_TYPES[$type]) || $id <= 0) {
|
||||||
|
|
@ -35,7 +73,7 @@ if ($type === 'comment') {
|
||||||
}
|
}
|
||||||
$back = ($action === 'report' || ($_POST['back'] ?? '') === 'picture')
|
$back = ($action === 'report' || ($_POST['back'] ?? '') === 'picture')
|
||||||
? '/member_picture.php?id=' . $pictureId . ($type === 'comment' ? '#kommentare' : '')
|
? '/member_picture.php?id=' . $pictureId . ($type === 'comment' ? '#kommentare' : '')
|
||||||
: '/moderation.php';
|
: (($_POST['back'] ?? '') === 'comments' ? '/moderation.php?tab=comments' : '/moderation.php');
|
||||||
|
|
||||||
if ($action === 'report') {
|
if ($action === 'report') {
|
||||||
if (!security_throttle('report')) {
|
if (!security_throttle('report')) {
|
||||||
|
|
@ -88,6 +126,12 @@ switch ($action) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
|
if ($type === 'picture') {
|
||||||
|
$commentIds = $pdo->prepare('SELECT id FROM gallery_comments WHERE gallery_id = ?');
|
||||||
|
$commentIds->execute([$id]);
|
||||||
|
reactions_delete('comment', $commentIds->fetchAll(PDO::FETCH_COLUMN));
|
||||||
|
}
|
||||||
|
reactions_delete($type, [$id]);
|
||||||
$pdo->prepare("DELETE FROM $table WHERE id = ?")->execute([$id]);
|
$pdo->prepare("DELETE FROM $table WHERE id = ?")->execute([$id]);
|
||||||
moderation_clear_reports($type, $id);
|
moderation_clear_reports($type, $id);
|
||||||
if ($type === 'picture') {
|
if ($type === 'picture') {
|
||||||
|
|
@ -95,7 +139,9 @@ switch ($action) {
|
||||||
}
|
}
|
||||||
admin_log('🗑️ ' . $label . ' gelöscht (Moderation)', $logFields, 'warning', 'members');
|
admin_log('🗑️ ' . $label . ' gelöscht (Moderation)', $logFields, 'warning', 'members');
|
||||||
set_flash('success', $label . ' gelöscht.');
|
set_flash('success', $label . ' gelöscht.');
|
||||||
$back = '/moderation.php';
|
if (str_starts_with($back, '/member_picture.php')) {
|
||||||
|
$back = '/moderation.php';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
72
reaction_action.php
Normal file
72
reaction_action.php
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Reaktion (Emoji) auf ein Galeriebild oder einen Kommentar setzen bzw. entfernen.
|
||||||
|
* Antwortet mit der neuen Reaktionsleiste als JSON (assets/js/reactions.js) oder leitet
|
||||||
|
* ohne JavaScript zurueck zur Bildseite.
|
||||||
|
*/
|
||||||
|
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') {
|
||||||
|
redirect('/members.php');
|
||||||
|
}
|
||||||
|
verify_csrf();
|
||||||
|
|
||||||
|
$isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']);
|
||||||
|
$type = (string) ($_POST['type'] ?? '');
|
||||||
|
$id = (int) ($_POST['id'] ?? 0);
|
||||||
|
$emoji = (string) ($_POST['emoji'] ?? '');
|
||||||
|
|
||||||
|
$fail = static function (string $message) use ($isAjax): void {
|
||||||
|
if ($isAjax) {
|
||||||
|
http_response_code(400);
|
||||||
|
header('Content-Type: application/json; charset=UTF-8');
|
||||||
|
echo json_encode(['ok' => false, 'error' => $message], JSON_UNESCAPED_UNICODE);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
set_flash('error', $message);
|
||||||
|
redirect('/members.php');
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!isset(REACTION_TYPES[$type]) || $id <= 0 || !in_array($emoji, REACTION_EMOJIS, true)) {
|
||||||
|
$fail('Diese Reaktion gibt es nicht.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inhalt, Bild und Besitzer laden - reagieren darf nur, wer den Inhalt auch sehen kann.
|
||||||
|
$me = current_user();
|
||||||
|
if ($type === 'picture') {
|
||||||
|
$stmt = db()->prepare(
|
||||||
|
'SELECT g.id AS picture_id, g.user_id AS owner_id, g.status, g.user_id AS author_id, u.gallery_comments_enabled, u.status AS owner_status
|
||||||
|
FROM member_gallery g JOIN users u ON u.id = g.user_id WHERE g.id = ?'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$stmt = db()->prepare(
|
||||||
|
'SELECT g.id AS picture_id, g.user_id AS owner_id, c.status, c.author_id, u.gallery_comments_enabled, u.status AS owner_status
|
||||||
|
FROM gallery_comments c JOIN member_gallery g ON g.id = c.gallery_id JOIN users u ON u.id = g.user_id WHERE c.id = ?'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$stmt->execute([$id]);
|
||||||
|
$content = $stmt->fetch();
|
||||||
|
$canSee = $content && $content['owner_status'] === 'active'
|
||||||
|
&& ($content['status'] === 'visible' || (int) $content['author_id'] === (int) $me['id'] || moderation_can());
|
||||||
|
if (!$canSee) {
|
||||||
|
$fail('Diesen Inhalt gibt es nicht (mehr).');
|
||||||
|
}
|
||||||
|
if (empty($content['gallery_comments_enabled'])) {
|
||||||
|
$fail('Unter diesen Bildern sind Kommentare und Reaktionen abgeschaltet.');
|
||||||
|
}
|
||||||
|
if (!security_throttle('reaction')) {
|
||||||
|
$fail('Du reagierst gerade sehr schnell - bitte kurz warten.');
|
||||||
|
}
|
||||||
|
|
||||||
|
reaction_toggle($type, $id, $emoji);
|
||||||
|
|
||||||
|
if ($isAjax) {
|
||||||
|
header('Content-Type: application/json; charset=UTF-8');
|
||||||
|
$reactions = reactions_for($type, [$id])[$id] ?? [];
|
||||||
|
echo json_encode(['ok' => true, 'html' => reactions_bar_html($type, $id, $reactions, true, $type === 'comment')], JSON_UNESCAPED_UNICODE);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
redirect('/member_picture.php?id=' . (int) $content['picture_id'] . ($type === 'comment' ? '#kommentar-' . $id : ''));
|
||||||
|
|
@ -41,7 +41,9 @@ CREATE TABLE IF NOT EXISTS users (
|
||||||
-- zuletzt uebernommenes Discord-Profilbild ("u:<hash>" global, "g:<hash>" Server-Profilbild, "" = keines)
|
-- zuletzt uebernommenes Discord-Profilbild ("u:<hash>" global, "g:<hash>" Server-Profilbild, "" = keines)
|
||||||
discord_avatar VARCHAR(120) NULL,
|
discord_avatar VARCHAR(120) NULL,
|
||||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
last_login DATETIME NULL
|
last_login DATETIME NULL,
|
||||||
|
-- Zuletzt aktiv auf der Website (hoechstens alle paar Minuten aktualisiert)
|
||||||
|
last_seen_at DATETIME NULL
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS roles (
|
CREATE TABLE IF NOT EXISTS roles (
|
||||||
|
|
@ -467,3 +469,31 @@ CREATE TABLE IF NOT EXISTS content_reports (
|
||||||
UNIQUE KEY uq_content_reports (content_type, content_id, reporter_id),
|
UNIQUE KEY uq_content_reports (content_type, content_id, reporter_id),
|
||||||
INDEX idx_content_reports_content (content_type, content_id)
|
INDEX idx_content_reports_content (content_type, content_id)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- Schimpfwortfilter der Moderation (Startliste legt includes/moderation.php an)
|
||||||
|
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;
|
||||||
|
|
||||||
|
-- Reaktionen (Emojis) unter Galeriebildern und Kommentaren
|
||||||
|
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;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue