Schnitzeljagd: Leitung laedt die gesuchten Orte hoch, Mitglieder senden je Ort Screenshot + Karte auf der Website ein
Bilder erscheinen erst zur Startzeit; Einsendungen sieht nur die Leitung (hunt.manage) mit sekundengenauer Uhrzeit des Hochladens, sie erkennt an oder lehnt ab. Punkte automatisch (je Ort 5/4/3/3/3, Bonusbild 5 innerhalb von 24 Stunden), Rangliste laesst sich veroeffentlichen. Bilder nur ueber hunt_image.php, Datenauskunft, Kontoloeschung und Datenschutzerklaerung ergaenzt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e1dd3045f5
commit
5c263176e9
19 changed files with 1332 additions and 4 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -23,6 +23,9 @@ assets/uploads/roles/*
|
|||
assets/uploads/armory/*
|
||||
!assets/uploads/armory/.htaccess
|
||||
!assets/uploads/armory/.gitkeep
|
||||
assets/uploads/hunt/*
|
||||
!assets/uploads/hunt/.htaccess
|
||||
!assets/uploads/hunt/.gitkeep
|
||||
# Kacheln, Marker und Icons der Karte (~230 MB) - werden per FTP hochgeladen, siehe README
|
||||
assets/map/data/
|
||||
__pycache__/
|
||||
|
|
|
|||
|
|
@ -10081,3 +10081,86 @@ a.members-chip, a.members-chip:hover { text-decoration: none; }
|
|||
.dsync-overlay, .dsync-modal, .dsync-ring-bar { transition: none; }
|
||||
.dsync-ring-wrap::after, .dsync-pulse, .dsync-current-in, .dsync-bump strong, .dsync-log-item, .dsync-summary { animation: none !important; }
|
||||
}
|
||||
|
||||
/* --- Schnitzeljagd (hunt.php) --- */
|
||||
.hunt-collapse > summary { display: flex; align-items: center; cursor: pointer; list-style: none; }
|
||||
.hunt-collapse > summary::-webkit-details-marker { display: none; }
|
||||
.hunt-collapse > summary h2 { margin: 0; display: inline-flex; align-items: center; gap: 0.5rem; }
|
||||
.hunt-collapse > summary::after { content: '▾'; margin-left: auto; color: var(--text-muted); }
|
||||
.hunt-collapse[open] > summary::after { content: '▴'; }
|
||||
.hunt-collapse[open] > summary { margin-bottom: 1rem; }
|
||||
.hunt-collapse > summary:hover h2 { color: var(--gold); }
|
||||
.hunt-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
|
||||
.hunt-form-grid label { display: flex; flex-direction: column; gap: 0.35rem; }
|
||||
.hunt-form-wide { grid-column: 1 / -1; }
|
||||
.hunt-delete { display: block; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
|
||||
|
||||
.hunt-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
|
||||
.hunt-list-item { display: flex; flex-direction: column; gap: 0.4rem; margin: 0; color: var(--text); transition: border-color 0.15s, transform 0.15s; }
|
||||
.hunt-list-item:hover { border-color: var(--gold); transform: translateY(-1px); text-decoration: none; }
|
||||
.hunt-list-item strong { font-size: 1.1rem; }
|
||||
|
||||
.hunt-dates { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin: 0.5rem 0; }
|
||||
.hunt-dates span { display: inline-flex; align-items: center; gap: 0.4rem; }
|
||||
.hunt-dates .icon, .hunt-wait .icon, .hunt-review-note .icon, .hunt-submission-time .icon { width: 15px; height: 15px; }
|
||||
.hunt-description { background: var(--bg-panel-alt); border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: 6px; padding: 0.8rem 1rem; margin: 0.75rem 0; line-height: 1.55; }
|
||||
.hunt-wait { display: flex; align-items: center; gap: 0.5rem; color: var(--gold); font-weight: 600; }
|
||||
.hunt-tabs { margin-bottom: 1.5rem; }
|
||||
|
||||
.hunt-spots { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; margin-top: 1rem; }
|
||||
.hunt-spot { display: flex; flex-direction: column; background: var(--bg-panel-alt); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; scroll-margin-top: 1rem; }
|
||||
.hunt-spot-bonus { border-color: rgba(201, 162, 39, 0.7); box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.25); }
|
||||
.hunt-spot-body { display: flex; flex-direction: column; gap: 0.75rem; padding: 0.9rem 1rem 1rem; }
|
||||
.hunt-spot-body h3 { margin: 0; font-size: 1.05rem; }
|
||||
.hunt-spot-bonus h3 { color: var(--gold); }
|
||||
.hunt-spot-body .field-hint { margin: -0.4rem 0 0; }
|
||||
.hunt-thumb { display: block; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; transition: border-color 0.15s; }
|
||||
.hunt-thumb:hover { border-color: var(--gold); }
|
||||
.hunt-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
|
||||
a.hunt-spot-image { border: none; border-radius: 0; aspect-ratio: 16 / 9; background: #111; }
|
||||
.hunt-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
|
||||
.hunt-pair .hunt-thumb { aspect-ratio: 16 / 10; }
|
||||
.hunt-own { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.75rem; border: 1px solid var(--border); border-radius: 8px; background: rgba(0, 0, 0, 0.18); }
|
||||
.hunt-own-head, .hunt-review-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
|
||||
.hunt-review-note { display: flex; gap: 0.4rem; align-items: flex-start; margin: 0; font-size: 0.9rem; }
|
||||
.hunt-own .inline-form { display: block; }
|
||||
.hunt-submit-form { gap: 0.6rem; }
|
||||
.hunt-submit-form label { display: flex; flex-direction: column; gap: 0.35rem; }
|
||||
.hunt-spot-edit > summary { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; font-size: 0.85rem; }
|
||||
.hunt-spot-edit > summary .icon { width: 14px; height: 14px; }
|
||||
.hunt-spot-edit[open] > summary { margin-bottom: 0.6rem; }
|
||||
.hunt-spot-edit form { gap: 0.6rem; }
|
||||
.hunt-spot-edit .inline-form { display: block; margin-top: 0.6rem; }
|
||||
.hunt-spot-edit .text-button .icon { width: 14px; height: 14px; vertical-align: -2px; }
|
||||
.hunt-add-spot { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); gap: 0.75rem; max-width: 560px; }
|
||||
.hunt-add-spot h3 { margin: 0; }
|
||||
|
||||
.hunt-review-spot { margin-top: 1.25rem; }
|
||||
.hunt-review-spot h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem; margin: 0 0 0.6rem; }
|
||||
.hunt-review-spot h3 .text-muted { font-size: 0.85rem; font-weight: 400; }
|
||||
a.hunt-review-spot-thumb { width: 64px; height: 40px; flex-shrink: 0; }
|
||||
.hunt-submission { display: grid; grid-template-columns: 56px minmax(170px, 1fr) minmax(220px, 1.2fr) minmax(240px, 1.2fr); gap: 0.9rem; align-items: center; padding: 0.75rem; margin-bottom: 0.5rem; background: var(--bg-panel-alt); border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: 8px; scroll-margin-top: 1rem; }
|
||||
.hunt-submission-accepted { border-left-color: var(--success); }
|
||||
.hunt-submission-rejected { border-left-color: var(--danger); opacity: 0.75; }
|
||||
.hunt-submission-place { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
|
||||
.hunt-submission-place strong { font-size: 1.3rem; }
|
||||
.hunt-points { font-size: 0.8rem; color: var(--gold); font-weight: 700; white-space: nowrap; }
|
||||
.hunt-submission-user { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
|
||||
.hunt-submission-user > div { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
|
||||
.hunt-submission-time { display: inline-flex; align-items: center; gap: 0.3rem; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
|
||||
.hunt-review-form { gap: 0.45rem; }
|
||||
.hunt-review-form input[type="text"] { padding: 0.4rem 0.6rem; font-size: 0.9rem; }
|
||||
.hunt-review-buttons { display: flex; flex-wrap: wrap; gap: 0.4rem; }
|
||||
|
||||
.hunt-board td { vertical-align: middle; }
|
||||
.hunt-board-user { display: flex; align-items: center; gap: 0.5rem; }
|
||||
.hunt-board-me td { background: rgba(201, 162, 39, 0.1); }
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.hunt-submission { grid-template-columns: 48px 1fr; }
|
||||
.hunt-submission .hunt-pair, .hunt-review-form { grid-column: 1 / -1; }
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.hunt-form-grid { grid-template-columns: 1fr; }
|
||||
.hunt-spots { grid-template-columns: 1fr; }
|
||||
}
|
||||
|
|
|
|||
0
assets/uploads/hunt/.gitkeep
Normal file
0
assets/uploads/hunt/.gitkeep
Normal file
11
assets/uploads/hunt/.htaccess
Normal file
11
assets/uploads/hunt/.htaccess
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Bilder der Schnitzeljagd: die gesuchten Orte erst ab dem Start, Einsendungen nur fuer die Leitung - nie
|
||||
# direkt ausliefern, nur ueber /hunt_image.php (prueft, ob man das Bild sehen darf).
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
<IfModule !mod_authz_core.c>
|
||||
Deny from all
|
||||
</IfModule>
|
||||
<IfModule mod_php.c>
|
||||
php_flag engine off
|
||||
</IfModule>
|
||||
|
|
@ -236,6 +236,7 @@ include __DIR__ . '/includes/header.php';
|
|||
<li><strong>Kalender, Wiki und Karte:</strong> Termine, die du einträgst, und deine Teilnahme; Wiki-Seiten und Taktiken samt früheren Versionen mit Autor; welche Pets du auf der Karte als erledigt abgehakt hast (sieht nur du). In der Live-Ansicht einer Taktik sehen die anderen, die sie gerade offen haben, dass du dabei bist und was du gerade zeichnest (<a href="#discord-bot">Abschnitt <?= $number['discord-bot'] + 1 ?></a>).</li>
|
||||
<li><strong>Kalender-Abo:</strong> Richtest du unter „Mein Profil“ ein Kalender-Abo ein, speichern wir dafür eine zufällige Abo-Adresse, wann du sie erzeugt hast und wann und mit welcher Art Kalender-App (z. B. „Google Kalender“) sie zuletzt abgerufen wurde. Die Adresse steht im Klartext in der Datenbank, damit du sie im Profil jederzeit wieder abrufen kannst – sie zeigt nur deine Termine, gibt aber keinen Zugang zu deinem Konto. Welchen Kalenderdienst du nutzt, entscheidest du selbst: Er ruft über die Adresse regelmäßig die Raids und Termine ab, bei denen du mitmachen kannst – Titel, Zeit, Beschreibung und Treffpunkt, wie viele dabei sind und ob du angemeldet bist, aber keine Teilnehmerlisten – und verarbeitet sie in eigener Verantwortung, bei Google, Microsoft oder Apple unter Umständen auch in den USA.</li>
|
||||
<li><strong>Nachrichten der Legionsleitung:</strong> Schickt dir die Legionsleitung eine persönliche Nachricht, speichern wir sie mit Dringlichkeit, Absender und Datum, bis die Leitung sie löscht, spätestens bis zur Löschung deines Kontos. Sie erscheint dir als Popup; wann du sie als gelesen bestätigt hast, sieht die Legionsleitung.</li>
|
||||
<li><strong>Schnitzeljagd:</strong> die Screenshots, die du zu einer Schnitzeljagd hochlädst (Ort und Karte mit deinem Standort), deine Bemerkung, die genaue Uhrzeit des Hochladens und die Bewertung der Leitung. Die Bilder sehen nur du und die Legionsleitung; veröffentlicht die Leitung die Rangliste, sehen die Mitglieder deinen Namen mit Punkten. Gelöscht wird alles mit der Schnitzeljagd, spätestens mit deinem Konto.</li>
|
||||
<li><strong>Fehlermeldungen:</strong> deine Beschreibung, angehängte Bilder oder Links und die Browser-Kennung deines Geräts (hilft beim Nachstellen des Fehlers).</li>
|
||||
<li><strong>Meldungen und Moderation:</strong> wer einen Inhalt gemeldet hat und warum. Neue Bilder, Kommentare und Termine können vor der Veröffentlichung von der Moderation geprüft werden.</li>
|
||||
</ul>
|
||||
|
|
@ -376,7 +377,7 @@ include __DIR__ . '/includes/header.php';
|
|||
<p>
|
||||
Dabei löschen wir dein Profil samt Profilbild und Profiltext, deine Charaktere, Galeriebilder (mit den
|
||||
Kommentaren darunter) und von dir hochgeladene Premade-Banner, Gear-Sets, privaten Taktiken, Gruppen und einzeln vergebenen Rechte, Terminteilnahmen,
|
||||
Bewerbungen für Premades, Befreiungen von den Legionsbeiträgen, Bilder an deinen Fehlermeldungen, dein Kalender-Abo sowie
|
||||
Bewerbungen für Premades, Befreiungen von den Legionsbeiträgen, Bilder an deinen Fehlermeldungen, Einsendungen zur Schnitzeljagd, dein Kalender-Abo sowie
|
||||
deine Login- und Discord-Zugangsschlüssel.
|
||||
Was du zur Legion beigetragen hast - Kommentare, Reaktionen, Wiki-Bearbeitungen, öffentliche Taktiken, Termine,
|
||||
Lumipunkte, Shop-Anträge, Lagerhaus-Buchungen, bezahlte Legionsbeiträge, Raid-Anwesenheiten und Fehlermeldungen -
|
||||
|
|
|
|||
407
hunt.php
Normal file
407
hunt.php
Normal file
|
|
@ -0,0 +1,407 @@
|
|||
<?php
|
||||
/**
|
||||
* Schnitzeljagd (includes/hunt.php): Uebersicht der Jagden und eine einzelne Jagd. Mitglieder sehen ab dem Start die
|
||||
* gesuchten Orte und senden je Ort zwei Screenshots ein; die Leitung (hunt.manage) verwaltet die Jagd, sieht alle
|
||||
* Einsendungen mit sekundengenauer Uhrzeit und die Rangliste.
|
||||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/hunt.php';
|
||||
require_login();
|
||||
$canManage = hunt_can_manage();
|
||||
if (!$canManage && !hunt_can_take_part()) {
|
||||
show_not_found();
|
||||
}
|
||||
$me = current_user();
|
||||
$form = $_SESSION['hunt_form'] ?? [];
|
||||
unset($_SESSION['hunt_form']);
|
||||
$toInput = static fn (?string $datetime): string => $datetime ? date('Y-m-d\TH:i', strtotime($datetime)) : '';
|
||||
|
||||
/** Status einer Jagd als Abzeichen. */
|
||||
$huntBadge = static function (array $hunt): string {
|
||||
if (empty($hunt['is_published'])) {
|
||||
return '<span class="badge badge-disabled">Entwurf</span>';
|
||||
}
|
||||
if (!hunt_started($hunt)) {
|
||||
return '<span class="badge badge-pending">Startet ' . e(hunt_date((string) $hunt['starts_at'])) . '</span>';
|
||||
}
|
||||
return hunt_closed($hunt) ? '<span class="badge">Beendet</span>' : '<span class="badge badge-active">Läuft</span>';
|
||||
};
|
||||
|
||||
/** Formular zum Anlegen bzw. Bearbeiten einer Jagd. */
|
||||
$huntForm = static function (?array $hunt) use ($form, $toInput): string {
|
||||
$value = static fn (string $key, string $fallback = ''): string => e((string) ($form[$key] ?? $fallback));
|
||||
$start = $hunt ? $toInput($hunt['starts_at']) : date('Y-m-d', strtotime('+1 day')) . 'T20:00';
|
||||
$html = '<form method="post" action="/hunt_action.php" class="hunt-form">' . csrf_field()
|
||||
. '<input type="hidden" name="action" value="save_hunt">'
|
||||
. '<input type="hidden" name="hunt_id" value="' . (int) ($hunt['id'] ?? 0) . '">'
|
||||
. '<div class="hunt-form-grid">'
|
||||
. '<label class="hunt-form-wide">Titel<input type="text" name="title" maxlength="120" required value="' . $value('title', (string) ($hunt['title'] ?? 'Schnitzeljagd')) . '"></label>'
|
||||
. '<label>Start <span class="text-muted">(ab dann sehen alle die Bilder)</span><input type="datetime-local" name="starts_at" required value="' . $value('starts_at', $start) . '"></label>'
|
||||
. '<label>Einsendeschluss <span class="text-muted">(optional)</span><input type="datetime-local" name="ends_at" value="' . $value('ends_at', $toInput($hunt['ends_at'] ?? null)) . '"></label>'
|
||||
. '<label class="hunt-form-wide">Ablauf und Regeln <span class="text-muted">(optional, sehen alle Mitglieder)</span>'
|
||||
. '<textarea name="description" rows="7" maxlength="5000" placeholder="z.B. Teilnahme nur mit einem Charakter, Uhrzeit muss auf dem Bild zu sehen sein …">' . $value('description', (string) ($hunt['description'] ?? '')) . '</textarea></label>'
|
||||
. '</div>'
|
||||
. '<label class="checkbox-label"><input type="checkbox" name="is_published" value="1"' . (!$hunt || !empty($hunt['is_published']) ? ' checked' : '') . '>'
|
||||
. ' Für Mitglieder sichtbar – die Bilder erscheinen trotzdem erst zum Start</label>'
|
||||
. '<div class="actions"><button type="submit">' . ($hunt ? 'Speichern' : 'Schnitzeljagd anlegen') . '</button></div>'
|
||||
. '</form>';
|
||||
return $html;
|
||||
};
|
||||
|
||||
$hunt = isset($_GET['id']) ? hunt_find((int) $_GET['id']) : null;
|
||||
if (isset($_GET['id']) && !$hunt) {
|
||||
show_not_found();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- Uebersicht
|
||||
if (!$hunt) {
|
||||
$hunts = db()->query(
|
||||
'SELECT h.*, (SELECT COUNT(*) FROM hunt_spots sp WHERE sp.hunt_id = h.id) AS spot_count
|
||||
FROM hunts h' . ($canManage ? '' : ' WHERE h.is_published = 1') . ' ORDER BY h.starts_at DESC'
|
||||
)->fetchAll();
|
||||
// Mitglieder landen direkt in der Jagd, wenn es nur eine gibt
|
||||
if (!$canManage && count($hunts) === 1) {
|
||||
redirect('/hunt.php?id=' . (int) $hunts[0]['id']);
|
||||
}
|
||||
$pageTitle = 'Schnitzeljagd';
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
<div class="panel">
|
||||
<div class="raid-header">
|
||||
<h1>Schnitzeljagd</h1>
|
||||
</div>
|
||||
<p class="text-muted">
|
||||
Zum Start erscheinen hier die Bilder der gesuchten Orte. Finde sie im Spiel und lade je Ort einen Screenshot
|
||||
vom Ort und einen von deiner Karte mit deinem Standort hoch. Deine Bilder sieht nur die Leitung – mit der genauen Uhrzeit.
|
||||
</p>
|
||||
</div>
|
||||
<?php if ($canManage): ?>
|
||||
<details class="panel hunt-collapse"<?= $form ? ' open' : '' ?>>
|
||||
<summary><h2><?= icon('map-pin') ?> Neue Schnitzeljagd</h2></summary>
|
||||
<?= $huntForm(null) ?>
|
||||
</details>
|
||||
<?php endif; ?>
|
||||
<?php if (!$hunts): ?>
|
||||
<div class="panel"><p class="text-muted">Gerade ist keine Schnitzeljagd geplant.</p></div>
|
||||
<?php else: ?>
|
||||
<div class="hunt-list">
|
||||
<?php foreach ($hunts as $item): ?>
|
||||
<a class="panel hunt-list-item" href="/hunt.php?id=<?= (int) $item['id'] ?>">
|
||||
<strong><?= e($item['title']) ?></strong>
|
||||
<span><?= $huntBadge($item) ?></span>
|
||||
<span class="text-muted">
|
||||
<?= e(hunt_date((string) $item['starts_at'])) ?>
|
||||
<?php if ($canManage): ?> · <?= (int) $item['spot_count'] ?> <?= (int) $item['spot_count'] === 1 ? 'Bild' : 'Bilder' ?><?php endif; ?>
|
||||
</span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
include __DIR__ . '/includes/footer.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- Einzelne Jagd
|
||||
$huntId = (int) $hunt['id'];
|
||||
$spots = hunt_spots($huntId);
|
||||
$started = hunt_started($hunt);
|
||||
$running = hunt_running($hunt);
|
||||
$showSpots = $canManage || $started;
|
||||
$own = hunt_own_submissions($huntId, (int) $me['id']);
|
||||
$bySpot = ($canManage || !empty($hunt['results_public'])) ? hunt_submissions_by_spot($huntId) : [];
|
||||
$board = $bySpot ? hunt_leaderboard($bySpot) : [];
|
||||
|
||||
// Nummern der Orte ("Ort 1", "Ort 2" ...) - das Bonusbild zaehlt nicht mit
|
||||
$labels = [];
|
||||
$number = 0;
|
||||
foreach ($spots as $spot) {
|
||||
$labels[(int) $spot['id']] = hunt_spot_label($spot, empty($spot['is_bonus']) ? ++$number : 0);
|
||||
}
|
||||
$pendingTotal = 0;
|
||||
foreach ($bySpot as $rows) {
|
||||
$pendingTotal += count(array_filter($rows, static fn (array $r): bool => $r['status'] === 'pending'));
|
||||
}
|
||||
|
||||
$pageTitle = $hunt['title'] . ' - Schnitzeljagd';
|
||||
include __DIR__ . '/includes/header.php';
|
||||
?>
|
||||
<div class="panel">
|
||||
<div class="raid-header">
|
||||
<h1><?= e($hunt['title']) ?></h1>
|
||||
<?= $huntBadge($hunt) ?>
|
||||
</div>
|
||||
<p class="hunt-dates">
|
||||
<span><?= icon('calendar') ?> Start: <strong><?= e(hunt_date((string) $hunt['starts_at'])) ?></strong></span>
|
||||
<?php if (!empty($hunt['ends_at'])): ?>
|
||||
<span><?= icon('flag') ?> Einsendeschluss: <strong><?= e(hunt_date((string) $hunt['ends_at'])) ?></strong></span>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
<?php if (trim((string) $hunt['description']) !== ''): ?>
|
||||
<div class="hunt-description"><?= nl2br(e((string) $hunt['description'])) ?></div>
|
||||
<?php endif; ?>
|
||||
<p class="field-hint">
|
||||
Je Ort zählen die 5 schnellsten anerkannten Einsendungen (<?= implode(' / ', HUNT_RANK_POINTS) ?> Punkte).
|
||||
Wer das Bonusbild innerhalb von <?= HUNT_BONUS_HOURS ?> Stunden findet, bekommt <?= HUNT_BONUS_POINTS ?> Punkte.
|
||||
Es zählt die Uhrzeit, zu der deine Bilder hier hochgeladen wurden.
|
||||
</p>
|
||||
<?php if (!$started): ?>
|
||||
<p class="hunt-wait"><?= icon('eye') ?> Die Bilder erscheinen <?= e(hunt_date((string) $hunt['starts_at'])) ?> hier – die Seite lädt dann von selbst neu.</p>
|
||||
<?php elseif (!$running && !empty($hunt['is_published'])): ?>
|
||||
<p class="hunt-wait"><?= icon('lock') ?> Die Schnitzeljagd ist beendet, Einsendungen sind nicht mehr möglich.</p>
|
||||
<?php endif; ?>
|
||||
<p><a href="/hunt.php" class="text-muted">← Alle Schnitzeljagden</a></p>
|
||||
</div>
|
||||
|
||||
<?php if ($canManage): ?>
|
||||
<nav class="filter-tabs hunt-tabs">
|
||||
<a class="filter-tab" href="#orte">Orte <span class="filter-tab-count"><?= count($spots) ?></span></a>
|
||||
<a class="filter-tab" href="#einsendungen">Einsendungen <span class="filter-tab-count"><?= $pendingTotal ?> offen</span></a>
|
||||
<a class="filter-tab" href="#rangliste">Rangliste</a>
|
||||
<a class="filter-tab" href="#einstellungen">Einstellungen</a>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // ---------------------------------------------------------------- Orte ?>
|
||||
<?php if ($showSpots): ?>
|
||||
<div class="panel" id="orte">
|
||||
<h2>Gesuchte Orte</h2>
|
||||
<?php if ($canManage && !$started): ?>
|
||||
<p class="field-hint"><?= icon('lock') ?> Nur die Leitung sieht die Bilder schon jetzt – die Mitglieder erst zum Start.</p>
|
||||
<?php endif; ?>
|
||||
<?php if (!$spots): ?>
|
||||
<p class="text-muted"><?= $canManage ? 'Noch keine Bilder – unten den ersten Ort hochladen.' : 'Hier sind noch keine Bilder.' ?></p>
|
||||
<?php endif; ?>
|
||||
<div class="hunt-spots">
|
||||
<?php foreach ($spots as $spot): ?>
|
||||
<?php
|
||||
$spotId = (int) $spot['id'];
|
||||
$label = $labels[$spotId];
|
||||
$mine = $own[$spotId] ?? null;
|
||||
?>
|
||||
<article class="hunt-spot<?= !empty($spot['is_bonus']) ? ' hunt-spot-bonus' : '' ?>" id="ort-<?= $spotId ?>">
|
||||
<?= hunt_thumb_html('spot', $spotId, 'orte', $label, 'hunt-spot-image') ?>
|
||||
<div class="hunt-spot-body">
|
||||
<h3><?= e($label) ?></h3>
|
||||
<?php if (!empty($spot['is_bonus'])): ?>
|
||||
<p class="field-hint">Zählt bis <?= e(hunt_date(date('Y-m-d H:i:s', hunt_bonus_deadline($hunt)))) ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($mine): ?>
|
||||
<div class="hunt-own">
|
||||
<div class="hunt-own-head">
|
||||
<?= hunt_status_badge((string) $mine['status']) ?>
|
||||
<span class="text-muted">eingesendet <?= e(hunt_time((string) $mine['submitted_at'])) ?></span>
|
||||
</div>
|
||||
<div class="hunt-pair">
|
||||
<?= hunt_thumb_html('shot', (int) $mine['id'], 'mine-' . $spotId, 'Dein Screenshot vom Ort') ?>
|
||||
<?= hunt_thumb_html('map', (int) $mine['id'], 'mine-' . $spotId, 'Deine Karte mit Standort') ?>
|
||||
</div>
|
||||
<?php if (!empty($mine['review_note'])): ?>
|
||||
<p class="hunt-review-note"><?= icon('message') ?> <?= e((string) $mine['review_note']) ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if ($running && $mine['status'] !== 'accepted'): ?>
|
||||
<form method="post" action="/hunt_action.php" class="inline-form" data-confirm="Deine Einsendung für diesen Ort zurückziehen? Sendest du später neu ein, zählt die neue Uhrzeit." data-confirm-title="Einsendung zurückziehen" data-confirm-danger data-confirm-ok="Zurückziehen">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="withdraw">
|
||||
<input type="hidden" name="spot_id" value="<?= $spotId ?>">
|
||||
<button type="submit" class="text-button">Zurückziehen</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // Die Leitung wertet aus und macht nicht mit - bei ihr nur die Verwaltung ?>
|
||||
<?php if ($running && !$canManage && (!$mine || $mine['status'] === 'rejected')): ?>
|
||||
<form method="post" action="/hunt_action.php" enctype="multipart/form-data" class="hunt-submit-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="submit">
|
||||
<input type="hidden" name="spot_id" value="<?= $spotId ?>">
|
||||
<label>Screenshot vom Ort
|
||||
<input type="file" name="screenshot" accept="image/png,image/jpeg,image/gif,image/webp" required data-max-size="<?= HUNT_MAX_SIDE ?>" data-paste>
|
||||
</label>
|
||||
<label>Karte mit deinem Standort
|
||||
<input type="file" name="map" accept="image/png,image/jpeg,image/gif,image/webp" required data-max-size="<?= HUNT_MAX_SIDE ?>" data-paste>
|
||||
</label>
|
||||
<input type="text" name="note" maxlength="255" placeholder="Bemerkung (optional), z.B. dein Charaktername">
|
||||
<div class="field-hint">Uhrzeit muss zu sehen sein (UI nicht ausblenden), auf der Karte Ort und Uhrzeit. Je Bild höchstens 10 MB.</div>
|
||||
<button type="submit"><?= $mine ? 'Neu einsenden' : 'Einsenden' ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($canManage): ?>
|
||||
<details class="hunt-spot-edit">
|
||||
<summary class="text-muted"><?= icon('edit') ?> Bearbeiten</summary>
|
||||
<form method="post" action="/hunt_action.php" enctype="multipart/form-data">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="update_spot">
|
||||
<input type="hidden" name="hunt_id" value="<?= $huntId ?>">
|
||||
<input type="hidden" name="spot_id" value="<?= $spotId ?>">
|
||||
<input type="text" name="title" maxlength="120" placeholder="Hinweis (optional)" value="<?= e((string) $spot['title']) ?>">
|
||||
<label class="checkbox-label"><input type="checkbox" name="is_bonus" value="1"<?= !empty($spot['is_bonus']) ? ' checked' : '' ?>> Bonusbild</label>
|
||||
<label>Anderes Bild <span class="text-muted">(optional)</span>
|
||||
<input type="file" name="image" accept="image/png,image/jpeg,image/gif,image/webp" data-max-size="<?= HUNT_MAX_SIDE ?>">
|
||||
</label>
|
||||
<div class="actions"><button type="submit" class="button-small">Speichern</button></div>
|
||||
</form>
|
||||
<form method="post" action="/hunt_action.php" class="inline-form" data-confirm="Diesen Ort samt allen Einsendungen dafür endgültig löschen?" data-confirm-title="Ort löschen" data-confirm-danger data-confirm-ok="Löschen">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="delete_spot">
|
||||
<input type="hidden" name="hunt_id" value="<?= $huntId ?>">
|
||||
<input type="hidden" name="spot_id" value="<?= $spotId ?>">
|
||||
<button type="submit" class="text-button"><?= icon('trash') ?> Ort löschen</button>
|
||||
</form>
|
||||
</details>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($canManage): ?>
|
||||
<form method="post" action="/hunt_action.php" enctype="multipart/form-data" class="hunt-add-spot">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="add_spot">
|
||||
<input type="hidden" name="hunt_id" value="<?= $huntId ?>">
|
||||
<h3>Ort hinzufügen</h3>
|
||||
<input type="file" name="image" accept="image/png,image/jpeg,image/gif,image/webp" required data-max-size="<?= HUNT_MAX_SIDE ?>" data-paste>
|
||||
<input type="text" name="title" maxlength="120" placeholder="Hinweis (optional), z.B. „Irgendwo in Verteron“">
|
||||
<label class="checkbox-label"><input type="checkbox" name="is_bonus" value="1"> Bonusbild (<?= HUNT_BONUS_POINTS ?> Punkte für alle, die es innerhalb von <?= HUNT_BONUS_HOURS ?> Stunden finden)</label>
|
||||
<div class="actions"><button type="submit">Hochladen</button></div>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // ---------------------------------------------------------------- Einsendungen (nur Leitung) ?>
|
||||
<?php if ($canManage): ?>
|
||||
<div class="panel" id="einsendungen">
|
||||
<h2>Einsendungen</h2>
|
||||
<p class="text-muted">Nur die Leitung sieht diese Bilder. Je Ort nach Uhrzeit des Hochladens sortiert – Platz und Punkte zählen nur anerkannte Einsendungen.</p>
|
||||
<?php if (!$spots): ?>
|
||||
<p class="text-muted">Noch keine Orte.</p>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($spots as $spot): ?>
|
||||
<?php $spotId = (int) $spot['id']; $rows = $bySpot[$spotId] ?? []; ?>
|
||||
<section class="hunt-review-spot">
|
||||
<h3><?= hunt_thumb_html('spot', $spotId, 'review-spot-' . $spotId, $labels[$spotId], 'hunt-review-spot-thumb') ?> <?= e($labels[$spotId]) ?>
|
||||
<span class="text-muted"><?= count($rows) ?> <?= count($rows) === 1 ? 'Einsendung' : 'Einsendungen' ?></span></h3>
|
||||
<?php if (!$rows): ?>
|
||||
<p class="text-muted">Noch keine Einsendungen.</p>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($rows as $row): ?>
|
||||
<?php
|
||||
$memberName = $row['user_id'] === null ? 'Gelöschtes Konto' : ($row['display_name'] !== '' ? $row['display_name'] : $row['username']);
|
||||
$reviewer = $row['reviewer_username'] !== null ? ($row['reviewer_display_name'] !== '' ? $row['reviewer_display_name'] : $row['reviewer_username']) : null;
|
||||
?>
|
||||
<div class="hunt-submission hunt-submission-<?= e((string) $row['status']) ?>" id="einsendung-<?= (int) $row['id'] ?>">
|
||||
<div class="hunt-submission-place">
|
||||
<?php if ($row['rank'] !== null): ?>
|
||||
<strong><?= (int) $row['rank'] ?>.</strong>
|
||||
<?php endif; ?>
|
||||
<?php if ($row['status'] === 'accepted'): ?>
|
||||
<span class="hunt-points"><?= (int) $row['points'] ?> P.</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="hunt-submission-user">
|
||||
<?= avatar_html(['id' => $row['user_id'], 'username' => $row['username'], 'display_name' => $row['display_name'], 'discord_id' => $row['discord_id'], 'avatar_filename' => $row['avatar_filename']], 32) ?>
|
||||
<div>
|
||||
<strong><?= e($memberName) ?></strong>
|
||||
<span class="hunt-submission-time" title="Zeitpunkt des Hochladens"><?= icon('calendar') ?> <?= e(hunt_time((string) $row['submitted_at'])) ?></span>
|
||||
<?php if (!empty($row['note'])): ?>
|
||||
<span class="text-muted">„<?= e((string) $row['note']) ?>“</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hunt-pair">
|
||||
<?= hunt_thumb_html('shot', (int) $row['id'], 'sub-' . (int) $row['id'], $memberName . ': Screenshot vom Ort (' . hunt_time((string) $row['submitted_at']) . ')') ?>
|
||||
<?= hunt_thumb_html('map', (int) $row['id'], 'sub-' . (int) $row['id'], $memberName . ': Karte mit Standort (' . hunt_time((string) $row['submitted_at']) . ')') ?>
|
||||
</div>
|
||||
<form method="post" action="/hunt_action.php" class="hunt-review-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="review">
|
||||
<input type="hidden" name="hunt_id" value="<?= $huntId ?>">
|
||||
<input type="hidden" name="submission_id" value="<?= (int) $row['id'] ?>">
|
||||
<div class="hunt-review-head">
|
||||
<?= hunt_status_badge((string) $row['status']) ?>
|
||||
<?php if ($reviewer !== null): ?>
|
||||
<span class="field-hint">von <?= e($reviewer) ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<input type="text" name="review_note" maxlength="255" placeholder="Begründung (optional, sieht das Mitglied)" value="<?= e((string) ($row['review_note'] ?? '')) ?>">
|
||||
<div class="hunt-review-buttons">
|
||||
<button type="submit" name="status" value="accepted" class="button-small button-success">Anerkennen</button>
|
||||
<button type="submit" name="status" value="rejected" class="button-small button-danger">Ablehnen</button>
|
||||
<?php if ($row['status'] !== 'pending'): ?>
|
||||
<button type="submit" name="status" value="pending" class="button-small button-secondary">Zurücksetzen</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // ---------------------------------------------------------------- Rangliste ?>
|
||||
<?php if ($canManage || !empty($hunt['results_public'])): ?>
|
||||
<div class="panel" id="rangliste">
|
||||
<div class="raid-header">
|
||||
<h2>Rangliste</h2>
|
||||
<?php if ($canManage): ?>
|
||||
<form method="post" action="/hunt_action.php" class="inline-form">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="results">
|
||||
<input type="hidden" name="hunt_id" value="<?= $huntId ?>">
|
||||
<input type="hidden" name="public" value="<?= empty($hunt['results_public']) ? '1' : '0' ?>">
|
||||
<button type="submit" class="button-small<?= empty($hunt['results_public']) ? '' : ' button-secondary' ?>">
|
||||
<?= empty($hunt['results_public']) ? 'Für Mitglieder veröffentlichen' : 'Wieder verbergen' ?>
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ($canManage): ?>
|
||||
<p class="field-hint"><?= !empty($hunt['results_public']) ? 'Die Mitglieder sehen diese Rangliste (ohne die Bilder der anderen).' : 'Nur die Leitung sieht die Rangliste, bis sie veröffentlicht wird.' ?>
|
||||
<?= $pendingTotal > 0 ? ' Noch ' . $pendingTotal . ' ungeprüfte ' . ($pendingTotal === 1 ? 'Einsendung' : 'Einsendungen') . ' – sie zählen erst nach dem Anerkennen.' : '' ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if (!$board): ?>
|
||||
<p class="text-muted">Noch keine anerkannten Einsendungen.</p>
|
||||
<?php else: ?>
|
||||
<div class="table-scroll">
|
||||
<table class="hunt-board">
|
||||
<thead><tr><th>Platz</th><th>Mitglied</th><th>Gefunden</th><th>Punkte</th></tr></thead>
|
||||
<tbody>
|
||||
<?php $place = 0; $lastPoints = null; foreach ($board as $i => $entry): ?>
|
||||
<?php if ($entry['points'] !== $lastPoints) { $place = $i + 1; $lastPoints = $entry['points']; } ?>
|
||||
<tr<?= (int) $entry['user']['id'] === (int) $me['id'] ? ' class="hunt-board-me"' : '' ?>>
|
||||
<td><strong><?= $place ?>.</strong></td>
|
||||
<td class="hunt-board-user"><?= avatar_html($entry['user'], 28) ?> <?= e($entry['user']['display_name'] !== '' ? $entry['user']['display_name'] : $entry['user']['username']) ?></td>
|
||||
<td><?= (int) $entry['found'] ?> / <?= count($spots) ?></td>
|
||||
<td><strong><?= (int) $entry['points'] ?></strong></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php // ---------------------------------------------------------------- Einstellungen (nur Leitung) ?>
|
||||
<?php if ($canManage): ?>
|
||||
<details class="panel hunt-collapse" id="einstellungen"<?= $form ? ' open' : '' ?>>
|
||||
<summary><h2><?= icon('edit') ?> Einstellungen</h2></summary>
|
||||
<?= $huntForm($hunt) ?>
|
||||
<form method="post" action="/hunt_action.php" class="inline-form hunt-delete" data-confirm="Diese Schnitzeljagd samt allen Bildern und Einsendungen endgültig löschen?" data-confirm-title="Schnitzeljagd löschen" data-confirm-danger data-confirm-ok="Löschen">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="delete_hunt">
|
||||
<input type="hidden" name="hunt_id" value="<?= $huntId ?>">
|
||||
<button type="submit" class="button-small button-danger"><?= icon('trash') ?> Schnitzeljagd löschen</button>
|
||||
</form>
|
||||
</details>
|
||||
<?php endif; ?>
|
||||
|
||||
<script src="<?= e(asset_url('/assets/js/image-resize.js')) ?>"></script>
|
||||
<script src="<?= e(asset_url('/assets/js/lightbox.js')) ?>" defer></script>
|
||||
<?php include __DIR__ . '/includes/footer.php'; ?>
|
||||
284
hunt_action.php
Normal file
284
hunt_action.php
Normal file
|
|
@ -0,0 +1,284 @@
|
|||
<?php
|
||||
/**
|
||||
* Schnitzeljagd (includes/hunt.php): Einsendungen der Mitglieder und die Verwaltung durch die Leitung (hunt.manage).
|
||||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/hunt.php';
|
||||
require_login();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
redirect('/hunt.php');
|
||||
}
|
||||
verify_csrf();
|
||||
|
||||
$action = (string) ($_POST['action'] ?? '');
|
||||
$user = current_user();
|
||||
$pdo = db();
|
||||
$huntId = (int) ($_POST['hunt_id'] ?? 0);
|
||||
$back = static fn (int $id, string $anchor = ''): string => '/hunt.php' . ($id > 0 ? '?id=' . $id : '') . ($anchor !== '' ? '#' . $anchor : '');
|
||||
|
||||
/** Ort samt Jagd laden (null, wenn es ihn nicht gibt oder die Jagd fuer das Konto nicht sichtbar ist). */
|
||||
$findSpot = static function (int $spotId): ?array {
|
||||
$stmt = db()->prepare('SELECT sp.*, h.title AS hunt_title FROM hunt_spots sp JOIN hunts h ON h.id = sp.hunt_id WHERE sp.id = ?');
|
||||
$stmt->execute([$spotId]);
|
||||
$spot = $stmt->fetch();
|
||||
return $spot && hunt_find((int) $spot['hunt_id']) !== null ? $spot : null;
|
||||
};
|
||||
|
||||
// ---- Mitglieder: einsenden und zurueckziehen ----
|
||||
|
||||
if ($action === 'submit' || $action === 'withdraw') {
|
||||
if (!hunt_can_take_part()) {
|
||||
show_not_found();
|
||||
}
|
||||
$spot = $findSpot((int) ($_POST['spot_id'] ?? 0));
|
||||
$hunt = $spot ? hunt_find((int) $spot['hunt_id']) : null;
|
||||
if (!$spot || !$hunt || empty($hunt['is_published'])) {
|
||||
set_flash('error', 'Diesen Ort gibt es nicht (mehr).');
|
||||
redirect($back($huntId));
|
||||
}
|
||||
$huntId = (int) $hunt['id'];
|
||||
$anchor = 'ort-' . (int) $spot['id'];
|
||||
if (!hunt_running($hunt)) {
|
||||
set_flash('error', hunt_started($hunt) ? 'Die Schnitzeljagd ist vorbei - Einsendungen sind nicht mehr möglich.' : 'Die Schnitzeljagd hat noch nicht begonnen.');
|
||||
redirect($back($huntId, $anchor));
|
||||
}
|
||||
$ownStmt = $pdo->prepare('SELECT * FROM hunt_submissions WHERE spot_id = ? AND user_id = ?');
|
||||
$ownStmt->execute([(int) $spot['id'], (int) $user['id']]);
|
||||
$own = $ownStmt->fetch() ?: null;
|
||||
if ($own && $own['status'] === 'accepted') {
|
||||
set_flash('error', 'Deine Einsendung für diesen Ort ist schon anerkannt - sie lässt sich nicht mehr ändern.');
|
||||
redirect($back($huntId, $anchor));
|
||||
}
|
||||
|
||||
if ($action === 'withdraw') {
|
||||
if ($own) {
|
||||
$pdo->prepare('DELETE FROM hunt_submissions WHERE id = ?')->execute([(int) $own['id']]);
|
||||
hunt_delete_file($own['screenshot_filename']);
|
||||
hunt_delete_file($own['map_filename']);
|
||||
set_flash('success', 'Deine Einsendung wurde zurückgezogen.');
|
||||
}
|
||||
redirect($back($huntId, $anchor));
|
||||
}
|
||||
|
||||
$screenshot = hunt_uploaded_file('screenshot');
|
||||
$map = hunt_uploaded_file('map');
|
||||
$note = trim((string) preg_replace('/\s+/u', ' ', (string) ($_POST['note'] ?? '')));
|
||||
if ($screenshot === null || $map === null) {
|
||||
set_flash('error', 'Bitte beide Bilder anhängen: den Screenshot vom Ort und die Karte mit deinem Standort.');
|
||||
redirect($back($huntId, $anchor));
|
||||
}
|
||||
if (!security_throttle('upload', 2)) {
|
||||
set_flash('error', 'Du hast in den letzten Minuten schon sehr viele Bilder hochgeladen. Bitte warte ein paar Minuten.');
|
||||
redirect($back($huntId, $anchor));
|
||||
}
|
||||
$stored = [];
|
||||
try {
|
||||
$stored[] = hunt_store_upload($screenshot, 'u' . (int) $user['id']);
|
||||
$stored[] = hunt_store_upload($map, 'u' . (int) $user['id']);
|
||||
} catch (RuntimeException $e) {
|
||||
array_map('hunt_delete_file', $stored);
|
||||
set_flash('error', $e->getMessage() . ' Bitte hänge die Bilder noch einmal an.');
|
||||
redirect($back($huntId, $anchor));
|
||||
}
|
||||
// Erneutes Einsenden (nach Ablehnung oder vor der Pruefung) ersetzt die alte Einsendung - mit neuer Uhrzeit
|
||||
$pdo->prepare(
|
||||
"INSERT INTO hunt_submissions (spot_id, user_id, screenshot_filename, map_filename, note, submitted_at, status)
|
||||
VALUES (?, ?, ?, ?, ?, NOW(), 'pending')
|
||||
ON DUPLICATE KEY UPDATE screenshot_filename = VALUES(screenshot_filename), map_filename = VALUES(map_filename),
|
||||
note = VALUES(note), submitted_at = NOW(), status = 'pending', review_note = NULL, reviewed_by = NULL, reviewed_at = NULL"
|
||||
)->execute([(int) $spot['id'], (int) $user['id'], $stored[0], $stored[1], $note !== '' ? mb_substr($note, 0, 255) : null]);
|
||||
if ($own) {
|
||||
hunt_delete_file($own['screenshot_filename']);
|
||||
hunt_delete_file($own['map_filename']);
|
||||
}
|
||||
set_flash('success', 'Eingesendet! Die Leitung sieht deine Bilder mit der genauen Uhrzeit.');
|
||||
redirect($back($huntId, $anchor));
|
||||
}
|
||||
|
||||
// ---- Alles weitere ist Verwaltung durch die Leitung ----
|
||||
|
||||
if (!hunt_can_manage()) {
|
||||
show_not_found();
|
||||
}
|
||||
|
||||
/** Datum aus einem datetime-local-Feld (2026-10-24T20:00), null wenn leer/ungueltig. */
|
||||
$parseTime = static function (string $value): ?string {
|
||||
$time = DateTimeImmutable::createFromFormat('Y-m-d\TH:i', trim($value), new DateTimeZone('Europe/Berlin'));
|
||||
return $time ? $time->format('Y-m-d H:i:s') : null;
|
||||
};
|
||||
|
||||
if ($action === 'save_hunt') {
|
||||
$title = trim((string) preg_replace('/\s+/u', ' ', (string) ($_POST['title'] ?? '')));
|
||||
$description = trim(str_replace("\r\n", "\n", (string) ($_POST['description'] ?? '')));
|
||||
$startsAt = $parseTime((string) ($_POST['starts_at'] ?? ''));
|
||||
$endsInput = trim((string) ($_POST['ends_at'] ?? ''));
|
||||
$endsAt = $endsInput !== '' ? $parseTime($endsInput) : null;
|
||||
$published = !empty($_POST['is_published']) ? 1 : 0;
|
||||
|
||||
$error = null;
|
||||
if ($title === '' || mb_strlen($title) > 120) {
|
||||
$error = 'Bitte einen Titel angeben (höchstens 120 Zeichen).';
|
||||
} elseif (mb_strlen($description) > 5000) {
|
||||
$error = 'Die Beschreibung ist zu lang (höchstens 5000 Zeichen).';
|
||||
} elseif ($startsAt === null) {
|
||||
$error = 'Bitte Datum und Uhrzeit des Starts angeben.';
|
||||
} elseif ($endsInput !== '' && ($endsAt === null || $endsAt <= $startsAt)) {
|
||||
$error = 'Der Einsendeschluss muss nach dem Start liegen.';
|
||||
}
|
||||
if ($error !== null) {
|
||||
set_flash('error', $error);
|
||||
$_SESSION['hunt_form'] = compact('title', 'description') + ['starts_at' => (string) ($_POST['starts_at'] ?? ''), 'ends_at' => $endsInput];
|
||||
redirect($back($huntId, 'einstellungen'));
|
||||
}
|
||||
unset($_SESSION['hunt_form']);
|
||||
|
||||
if ($huntId > 0) {
|
||||
$old = hunt_find($huntId);
|
||||
if (!$old) {
|
||||
show_not_found();
|
||||
}
|
||||
$pdo->prepare('UPDATE hunts SET title = ?, description = ?, starts_at = ?, ends_at = ?, is_published = ? WHERE id = ?')
|
||||
->execute([$title, $description !== '' ? $description : null, $startsAt, $endsAt, $published, $huntId]);
|
||||
admin_log('🧭 Schnitzeljagd geändert', [
|
||||
'Jagd' => $title,
|
||||
'Start' => hunt_date($startsAt),
|
||||
'Einsendeschluss' => $endsAt !== null ? hunt_date($endsAt) : 'offen',
|
||||
'Sichtbar' => $published ? 'für alle Mitglieder' : 'Entwurf (nur Leitung)',
|
||||
]);
|
||||
set_flash('success', 'Die Schnitzeljagd wurde gespeichert.');
|
||||
} else {
|
||||
$pdo->prepare('INSERT INTO hunts (title, description, starts_at, ends_at, is_published, created_by) VALUES (?, ?, ?, ?, ?, ?)')
|
||||
->execute([$title, $description !== '' ? $description : null, $startsAt, $endsAt, $published, (int) $user['id']]);
|
||||
$huntId = (int) $pdo->lastInsertId();
|
||||
admin_log('🧭 Schnitzeljagd angelegt', ['Jagd' => $title, 'Start' => hunt_date($startsAt)], 'success');
|
||||
set_flash('success', 'Die Schnitzeljagd ist angelegt - jetzt die gesuchten Orte als Bilder hochladen.');
|
||||
}
|
||||
redirect($back($huntId));
|
||||
}
|
||||
|
||||
$hunt = hunt_find($huntId);
|
||||
if (!$hunt) {
|
||||
set_flash('error', 'Diese Schnitzeljagd gibt es nicht (mehr).');
|
||||
redirect('/hunt.php');
|
||||
}
|
||||
|
||||
if ($action === 'delete_hunt') {
|
||||
hunt_delete_files($huntId);
|
||||
$pdo->prepare('DELETE FROM hunts WHERE id = ?')->execute([$huntId]); // Orte und Einsendungen per CASCADE
|
||||
admin_log('🗑️ Schnitzeljagd gelöscht', ['Jagd' => (string) $hunt['title']], 'danger');
|
||||
set_flash('success', 'Die Schnitzeljagd wurde samt Bildern und Einsendungen gelöscht.');
|
||||
redirect('/hunt.php');
|
||||
}
|
||||
|
||||
if ($action === 'results') {
|
||||
$public = !empty($_POST['public']) ? 1 : 0;
|
||||
$pdo->prepare('UPDATE hunts SET results_public = ? WHERE id = ?')->execute([$public, $huntId]);
|
||||
admin_log($public ? '🏆 Schnitzeljagd: Ergebnis veröffentlicht' : '🏆 Schnitzeljagd: Ergebnis verborgen', ['Jagd' => (string) $hunt['title']]);
|
||||
set_flash('success', $public ? 'Die Rangliste ist jetzt für alle Mitglieder sichtbar.' : 'Die Rangliste ist wieder nur für die Leitung sichtbar.');
|
||||
redirect($back($huntId, 'rangliste'));
|
||||
}
|
||||
|
||||
if ($action === 'add_spot') {
|
||||
$file = hunt_uploaded_file('image');
|
||||
$title = trim((string) preg_replace('/\s+/u', ' ', (string) ($_POST['title'] ?? '')));
|
||||
$bonus = !empty($_POST['is_bonus']) ? 1 : 0;
|
||||
if ($file === null) {
|
||||
set_flash('error', 'Bitte ein Bild des gesuchten Ortes anhängen.');
|
||||
redirect($back($huntId, 'orte'));
|
||||
}
|
||||
if (mb_strlen($title) > 120) {
|
||||
set_flash('error', 'Der Hinweis ist zu lang (höchstens 120 Zeichen).');
|
||||
redirect($back($huntId, 'orte'));
|
||||
}
|
||||
try {
|
||||
$filename = hunt_store_upload($file, 'spot' . $huntId);
|
||||
} catch (RuntimeException $e) {
|
||||
set_flash('error', $e->getMessage());
|
||||
redirect($back($huntId, 'orte'));
|
||||
}
|
||||
$sort = $pdo->prepare('SELECT COALESCE(MAX(sort_order), 0) + 1 FROM hunt_spots WHERE hunt_id = ?');
|
||||
$sort->execute([$huntId]);
|
||||
$pdo->prepare('INSERT INTO hunt_spots (hunt_id, title, image_filename, is_bonus, sort_order) VALUES (?, ?, ?, ?, ?)')
|
||||
->execute([$huntId, $title, $filename, $bonus, (int) $sort->fetchColumn()]);
|
||||
$spotId = (int) $pdo->lastInsertId();
|
||||
admin_log('🧭 Schnitzeljagd: Ort hinzugefügt', ['Jagd' => (string) $hunt['title'], 'Ort' => ($bonus ? 'Bonusbild' : 'Ort') . ($title !== '' ? ': ' . $title : '')]);
|
||||
set_flash('success', $bonus ? 'Das Bonusbild ist hochgeladen.' : 'Der Ort ist hochgeladen.');
|
||||
redirect($back($huntId, 'ort-' . $spotId));
|
||||
}
|
||||
|
||||
$spot = $findSpot((int) ($_POST['spot_id'] ?? 0));
|
||||
if (in_array($action, ['update_spot', 'delete_spot'], true) && (!$spot || (int) $spot['hunt_id'] !== $huntId)) {
|
||||
set_flash('error', 'Diesen Ort gibt es nicht (mehr).');
|
||||
redirect($back($huntId, 'orte'));
|
||||
}
|
||||
|
||||
if ($action === 'update_spot') {
|
||||
$title = trim((string) preg_replace('/\s+/u', ' ', (string) ($_POST['title'] ?? '')));
|
||||
$bonus = !empty($_POST['is_bonus']) ? 1 : 0;
|
||||
$file = hunt_uploaded_file('image');
|
||||
$filename = (string) $spot['image_filename'];
|
||||
if (mb_strlen($title) > 120) {
|
||||
set_flash('error', 'Der Hinweis ist zu lang (höchstens 120 Zeichen).');
|
||||
redirect($back($huntId, 'ort-' . (int) $spot['id']));
|
||||
}
|
||||
if ($file !== null) {
|
||||
try {
|
||||
$filename = hunt_store_upload($file, 'spot' . $huntId);
|
||||
} catch (RuntimeException $e) {
|
||||
set_flash('error', $e->getMessage());
|
||||
redirect($back($huntId, 'ort-' . (int) $spot['id']));
|
||||
}
|
||||
}
|
||||
$pdo->prepare('UPDATE hunt_spots SET title = ?, is_bonus = ?, image_filename = ? WHERE id = ?')
|
||||
->execute([$title, $bonus, $filename, (int) $spot['id']]);
|
||||
if ($filename !== $spot['image_filename']) {
|
||||
hunt_delete_file((string) $spot['image_filename']);
|
||||
}
|
||||
set_flash('success', 'Der Ort wurde gespeichert.');
|
||||
redirect($back($huntId, 'ort-' . (int) $spot['id']));
|
||||
}
|
||||
|
||||
if ($action === 'delete_spot') {
|
||||
$files = $pdo->prepare('SELECT screenshot_filename, map_filename FROM hunt_submissions WHERE spot_id = ?');
|
||||
$files->execute([(int) $spot['id']]);
|
||||
foreach ($files->fetchAll(PDO::FETCH_NUM) as [$shot, $mapFile]) {
|
||||
hunt_delete_file($shot);
|
||||
hunt_delete_file($mapFile);
|
||||
}
|
||||
hunt_delete_file((string) $spot['image_filename']);
|
||||
$pdo->prepare('DELETE FROM hunt_spots WHERE id = ?')->execute([(int) $spot['id']]);
|
||||
admin_log('🗑️ Schnitzeljagd: Ort gelöscht', ['Jagd' => (string) $hunt['title'], 'Ort' => (!empty($spot['is_bonus']) ? 'Bonusbild' : 'Ort') . ($spot['title'] !== '' ? ': ' . $spot['title'] : '')], 'warning');
|
||||
set_flash('success', 'Der Ort wurde samt seinen Einsendungen gelöscht.');
|
||||
redirect($back($huntId, 'orte'));
|
||||
}
|
||||
|
||||
if ($action === 'review') {
|
||||
$status = (string) ($_POST['status'] ?? '');
|
||||
$note = trim((string) preg_replace('/\s+/u', ' ', (string) ($_POST['review_note'] ?? '')));
|
||||
$submissionId = (int) ($_POST['submission_id'] ?? 0);
|
||||
if (!array_key_exists($status, HUNT_SUBMISSION_STATUSES)) {
|
||||
set_flash('error', 'Ungültiger Status.');
|
||||
redirect($back($huntId, 'einsendungen'));
|
||||
}
|
||||
$stmt = $pdo->prepare(
|
||||
'SELECT s.id, s.user_id, sp.id AS spot_id FROM hunt_submissions s JOIN hunt_spots sp ON sp.id = s.spot_id WHERE s.id = ? AND sp.hunt_id = ?'
|
||||
);
|
||||
$stmt->execute([$submissionId, $huntId]);
|
||||
$submission = $stmt->fetch();
|
||||
if (!$submission) {
|
||||
set_flash('error', 'Diese Einsendung gibt es nicht (mehr).');
|
||||
redirect($back($huntId, 'einsendungen'));
|
||||
}
|
||||
$pdo->prepare('UPDATE hunt_submissions SET status = ?, review_note = ?, reviewed_by = ?, reviewed_at = ? WHERE id = ?')
|
||||
->execute([
|
||||
$status,
|
||||
$note !== '' ? mb_substr($note, 0, 255) : null,
|
||||
$status === 'pending' ? null : (int) $user['id'],
|
||||
$status === 'pending' ? null : date('Y-m-d H:i:s'),
|
||||
$submissionId,
|
||||
]);
|
||||
redirect($back($huntId, 'einsendung-' . $submissionId));
|
||||
}
|
||||
|
||||
redirect($back($huntId));
|
||||
42
hunt_image.php
Normal file
42
hunt_image.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* Liefert ein Bild der Schnitzeljagd aus (includes/hunt.php). Der Ordner assets/uploads/hunt/ ist direkt nicht abrufbar.
|
||||
* - kind=spot: gesuchter Ort - fuer Mitglieder erst ab dem Start einer veroeffentlichten Jagd, fuer die Leitung immer
|
||||
* - kind=shot / kind=map: Einsendung (Screenshot vom Ort bzw. Karte) - nur an die Leitung und den Einsender
|
||||
*/
|
||||
require_once __DIR__ . '/includes/bootstrap.php';
|
||||
require_once __DIR__ . '/includes/hunt.php';
|
||||
require_login();
|
||||
|
||||
$kind = (string) ($_GET['kind'] ?? '');
|
||||
$id = (int) ($_GET['id'] ?? 0);
|
||||
$filename = null;
|
||||
|
||||
if ($kind === 'spot') {
|
||||
$stmt = db()->prepare('SELECT sp.image_filename, h.starts_at, h.is_published FROM hunt_spots sp JOIN hunts h ON h.id = sp.hunt_id WHERE sp.id = ?');
|
||||
$stmt->execute([$id]);
|
||||
$row = $stmt->fetch();
|
||||
if ($row && (hunt_can_manage() || (hunt_can_take_part() && !empty($row['is_published']) && hunt_started($row)))) {
|
||||
$filename = (string) $row['image_filename'];
|
||||
}
|
||||
} elseif ($kind === 'shot' || $kind === 'map') {
|
||||
$stmt = db()->prepare('SELECT user_id, screenshot_filename, map_filename FROM hunt_submissions WHERE id = ?');
|
||||
$stmt->execute([$id]);
|
||||
$row = $stmt->fetch();
|
||||
if ($row && ((int) $row['user_id'] === (int) current_user()['id'] || hunt_can_manage())) {
|
||||
$filename = (string) $row[$kind === 'shot' ? 'screenshot_filename' : 'map_filename'];
|
||||
}
|
||||
}
|
||||
|
||||
$types = ['png' => 'image/png', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'webp' => 'image/webp'];
|
||||
$type = $filename !== null ? ($types[strtolower(pathinfo($filename, PATHINFO_EXTENSION))] ?? null) : null;
|
||||
if ($filename === null || strpos($filename, '/') !== false || $type === null || !is_file(HUNT_UPLOAD_DIR . $filename)) {
|
||||
show_not_found();
|
||||
}
|
||||
|
||||
session_write_close();
|
||||
header('Content-Type: ' . $type);
|
||||
header('Content-Length: ' . filesize(HUNT_UPLOAD_DIR . $filename));
|
||||
header('Cache-Control: private, max-age=86400');
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
readfile(HUNT_UPLOAD_DIR . $filename);
|
||||
|
|
@ -210,6 +210,7 @@ function account_anonymize(int $userId, ?array $actor = null): void
|
|||
require_once __DIR__ . '/member_profile.php'; // PROFILE_UPLOAD_DIR
|
||||
require_once __DIR__ . '/armory.php'; // Portraits aus dem Spiel
|
||||
require_once __DIR__ . '/bugs.php'; // BUG_UPLOAD_DIR
|
||||
require_once __DIR__ . '/hunt.php'; // HUNT_UPLOAD_DIR
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare('SELECT * FROM users WHERE id = ? AND deleted_at IS NULL');
|
||||
$stmt->execute([$userId]);
|
||||
|
|
@ -239,6 +240,10 @@ function account_anonymize(int $userId, ?array $actor = null): void
|
|||
foreach (data_rows_column($pdo, 'SELECT filename FROM bug_report_images WHERE bug_id IN (' . $in($bugIds) . ')', []) as $file) {
|
||||
$files[] = BUG_UPLOAD_DIR . $file;
|
||||
}
|
||||
// Einsendungen zur Schnitzeljagd (Screenshots aus dem Spiel)
|
||||
foreach (data_rows_column($pdo, 'SELECT screenshot_filename FROM hunt_submissions WHERE user_id = ? UNION ALL SELECT map_filename FROM hunt_submissions WHERE user_id = ?', [$userId, $userId]) as $file) {
|
||||
$files[] = HUNT_UPLOAD_DIR . $file;
|
||||
}
|
||||
|
||||
// Zuerst der Discord-Bot - danach kennt die Website die Discord-ID nicht mehr. Ist er nicht
|
||||
// erreichbar, merkt sich die Website den Auftrag und holt ihn nach (account_deletion_bot_retry).
|
||||
|
|
@ -281,6 +286,7 @@ function account_anonymize(int $userId, ?array $actor = null): void
|
|||
'DELETE FROM dues_reminders WHERE user_id = ?', // Erinnerungen an Legionsbeitraege (Protokoll, ggf. noch der Text)
|
||||
'DELETE FROM premade_applications WHERE user_id = ?', // Bewerbungen fuer Premades samt Nachricht
|
||||
'DELETE FROM user_notices WHERE user_id = ?', // Persoenliche Nachrichten der Legionsleitung
|
||||
'DELETE FROM hunt_submissions WHERE user_id = ?', // Einsendungen zur Schnitzeljagd
|
||||
"DELETE FROM tactic_revisions WHERE owner_id = ? AND visibility = 'private'",
|
||||
"DELETE FROM tactics WHERE created_by = ? AND visibility = 'private'", // Schritte und Zeichnungen per CASCADE
|
||||
] as $sql) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ declare(strict_types=1);
|
|||
|
||||
require_once __DIR__ . '/member_profile.php'; // PROFILE_UPLOAD_DIR (Charaktere, Galerie)
|
||||
require_once __DIR__ . '/bugs.php'; // BUG_UPLOAD_DIR
|
||||
require_once __DIR__ . '/hunt.php'; // HUNT_UPLOAD_DIR
|
||||
require_once __DIR__ . '/raids_api.php';
|
||||
require_once __DIR__ . '/events_api.php';
|
||||
require_once __DIR__ . '/activity_api.php';
|
||||
|
|
@ -166,6 +167,27 @@ function data_export_collect(int $userId): array
|
|||
}
|
||||
unset($bug);
|
||||
|
||||
$huntSubmissions = data_export_rows(
|
||||
'SELECT s.id, h.title AS schnitzeljagd, sp.title AS ort, sp.is_bonus, s.note, s.submitted_at, s.status, s.review_note, s.reviewed_at,
|
||||
s.screenshot_filename, s.map_filename
|
||||
FROM hunt_submissions s JOIN hunt_spots sp ON sp.id = s.spot_id JOIN hunts h ON h.id = sp.hunt_id
|
||||
WHERE s.user_id = ? ORDER BY s.submitted_at',
|
||||
[$userId]
|
||||
);
|
||||
foreach ($huntSubmissions as &$submission) {
|
||||
$submission['bilder'] = [];
|
||||
foreach (['screenshot_filename' => 'ort', 'map_filename' => 'karte'] as $column => $suffix) {
|
||||
$path = data_export_file(HUNT_UPLOAD_DIR, (string) $submission[$column]);
|
||||
if ($path !== null) {
|
||||
$name = 'bilder/schnitzeljagd/' . $submission['id'] . '-' . $suffix . '.' . strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||
$submission['bilder'][] = $name;
|
||||
$files[$name] = $path;
|
||||
}
|
||||
unset($submission[$column]);
|
||||
}
|
||||
}
|
||||
unset($submission);
|
||||
|
||||
$points = data_export_rows(
|
||||
'SELECT a.awarded_at, a.category, a.title, a.note, e.points
|
||||
FROM contribution_entries e JOIN contribution_awards a ON a.id = e.award_id WHERE e.user_id = ? ORDER BY a.awarded_at, a.id',
|
||||
|
|
@ -265,6 +287,7 @@ function data_export_collect(int $userId): array
|
|||
'taktiken' => data_export_rows('SELECT id, map_slug, name, description, visibility, highlight, created_at, updated_at FROM tactics WHERE created_by = ? ORDER BY id', [$userId]),
|
||||
'raid_vorlagen' => data_export_rows('SELECT area AS bereich, name, data AS inhalt, created_at, updated_at FROM raid_templates WHERE created_by = ? ORDER BY id', [$userId]),
|
||||
'fehlermeldungen' => $bugs,
|
||||
'schnitzeljagd' => $huntSubmissions,
|
||||
'angemeldete_geraete' => data_export_rows('SELECT login_method, user_agent, created_at, last_used_at, expires_at FROM auth_tokens WHERE user_id = ? ORDER BY created_at', [$userId]),
|
||||
// Verwaltungsaktionen, die das Konto selbst ausgefuehrt hat - ohne Details, darin stehen oft andere Mitglieder
|
||||
'protokoll_eigene_aktionen' => data_export_rows('SELECT created_at, area, title, ip FROM audit_log WHERE user_id = ? ORDER BY id', [$userId]),
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ declare(strict_types=1);
|
|||
// Admin-Bereich wird getrennt sortiert und bleibt unter seiner Ueberschrift.
|
||||
const SIDEBAR_NAV_MAIN = [
|
||||
'/dashboard.php', '/checklist.php', '/consilium.php', '/profile.php', '/members.php', '/gallery.php', '/contributions.php', '/shop.php', 'gap',
|
||||
'/wiki.php', '/raids.php', '/premades.php', '/calendar.php', '/events.php',
|
||||
'/wiki.php', '/raids.php', '/premades.php', '/calendar.php', '/events.php', '/hunt.php',
|
||||
'/map.php', '/raidplan.php', '/gear.php', '/professions.php', '/warehouse.php',
|
||||
];
|
||||
// So viele zusaetzliche Trennlinien darf jedes Mitglied einfuegen
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ if ($shellUser && user_has_permission('dashboard.view')) {
|
|||
}
|
||||
}
|
||||
$canViewMembers = $currentUser && user_has_permission('members.view');
|
||||
// Schnitzeljagd (includes/hunt.php): fuer Mitglieder nur, solange eine Jagd ansteht oder gerade vorbei ist
|
||||
require_once __DIR__ . '/hunt.php';
|
||||
$canViewHunt = $currentUser && hunt_nav_visible();
|
||||
$canViewWiki = $currentUser && user_has_permission('wiki.view');
|
||||
$canViewReports = $currentUser && user_has_permission('reports.view');
|
||||
$canManageBugs = $currentUser && user_has_permission('bugs.manage');
|
||||
|
|
@ -71,6 +74,7 @@ $isProfileActive = $currentScript === 'profile.php';
|
|||
$isRaidsActive = $currentScript === 'raids.php';
|
||||
$isPremadesActive = $currentScript === 'premades.php';
|
||||
$isEventsActive = $currentScript === 'events.php';
|
||||
$isHuntActive = $currentScript === 'hunt.php';
|
||||
$isCalendarActive = $currentScript === 'calendar.php';
|
||||
$isActivityActive = $currentScript === 'activity.php';
|
||||
$isDuesActive = $currentScript === 'dues.php';
|
||||
|
|
@ -107,6 +111,7 @@ $pageBackgrounds = [
|
|||
'change_password.php' => 'bg-profile',
|
||||
'premades.php' => 'bg-premades',
|
||||
'events.php' => 'bg-events',
|
||||
'hunt.php' => 'bg-events',
|
||||
'calendar.php' => 'bg-events',
|
||||
'activity.php' => 'bg-events',
|
||||
'map.php' => 'bg-map',
|
||||
|
|
@ -349,6 +354,11 @@ $brandLogo = $isConsiliumOnly
|
|||
<?= icon('bell') ?><span class="label">Events</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($canViewHunt && !$isConsiliumOnly): ?>
|
||||
<a href="/hunt.php" data-nav="/hunt.php" data-badge="/hunt.php"<?= $navOrder('/hunt.php') ?> class="sidebar-link<?= $isHuntActive ? ' active' : '' ?>" title="Schnitzeljagd: gesuchte Orte finden und Screenshots einsenden">
|
||||
<?= icon('map-pin') ?><span class="label">Schnitzeljagd</span><?= nav_badge_html($navBadges, '/hunt.php') ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($isConsiliumOnly): ?>
|
||||
<?php // Gaeste des Consiliums: nur die fuer sie freigegebenen Live-Sitzungen der Karte (map.php) ?>
|
||||
<a href="/map.php" data-nav="/map.php"<?= $navOrder('/map.php') ?> class="sidebar-link<?= $isMapActive || $isRaidplanActive ? ' active' : '' ?>" title="Karte: Live-Sitzungen, die für <?= e(CONSILIUM_NAME) ?> freigegeben sind">
|
||||
|
|
|
|||
306
includes/hunt.php
Normal file
306
includes/hunt.php
Normal file
|
|
@ -0,0 +1,306 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Schnitzeljagd (hunt.php): Die Leitung (hunt.manage) legt eine Jagd an und laedt die gesuchten Orte als Bilder hoch.
|
||||
* Ab der Startzeit sehen die Mitglieder die Bilder und schicken je Ort zwei Screenshots ein - den Ort selbst und die
|
||||
* Karte mit ihrem Standort. Die Einsendungen sieht nur die Leitung (mit sekundengenauer Uhrzeit des Hochladens), sie
|
||||
* erkennt sie an oder lehnt sie ab. Punkte gibt es fuer die schnellsten anerkannten Einsendungen je Ort
|
||||
* (HUNT_RANK_POINTS) und fuer jeden, der das Bonusbild innerhalb von HUNT_BONUS_HOURS findet.
|
||||
*/
|
||||
|
||||
// Punkte nach Platz je Ort: 1. Platz 5, 2. Platz 4, 3. bis 5. Platz 3
|
||||
const HUNT_RANK_POINTS = [5, 4, 3, 3, 3];
|
||||
// Bonusbild: wer es innerhalb dieser Stunden nach dem Start findet, bekommt HUNT_BONUS_POINTS
|
||||
const HUNT_BONUS_HOURS = 24;
|
||||
const HUNT_BONUS_POINTS = 5;
|
||||
|
||||
const HUNT_SUBMISSION_STATUSES = [
|
||||
'pending' => ['Wartet auf Prüfung', 'badge-pending'],
|
||||
'accepted' => ['Anerkannt', 'badge-active'],
|
||||
'rejected' => ['Abgelehnt', 'badge-disabled'],
|
||||
];
|
||||
|
||||
// Bilder liegen NICHT oeffentlich abrufbar im Webroot-Ordner (eigene .htaccess sperrt ihn), sondern werden ueber
|
||||
// /hunt_image.php ausgeliefert: die gesuchten Orte erst ab dem Start, die Einsendungen nur an die Leitung und
|
||||
// an den, der sie geschickt hat.
|
||||
const HUNT_UPLOAD_DIR = __DIR__ . '/../assets/uploads/hunt/';
|
||||
const HUNT_MAX_UPLOAD = 10 * 1024 * 1024;
|
||||
// Laengste Seite gespeicherter Bilder - Uhrzeit und Koordinaten auf den Screenshots muessen lesbar bleiben
|
||||
const HUNT_MAX_SIDE = 2560;
|
||||
|
||||
function hunt_can_manage(): bool
|
||||
{
|
||||
return user_has_permission('hunt.manage');
|
||||
}
|
||||
|
||||
/** Mitmachen duerfen alle aus der Legion (dashboard.view). */
|
||||
function hunt_can_take_part(): bool
|
||||
{
|
||||
return user_has_permission('dashboard.view');
|
||||
}
|
||||
|
||||
/** Hat die Jagd begonnen (Bilder sichtbar)? */
|
||||
function hunt_started(array $hunt): bool
|
||||
{
|
||||
return strtotime((string) $hunt['starts_at']) <= time();
|
||||
}
|
||||
|
||||
/** Ist Einsendeschluss vorbei? Ohne Ende bleibt die Jagd offen, bis die Leitung sie schliesst. */
|
||||
function hunt_closed(array $hunt): bool
|
||||
{
|
||||
return !empty($hunt['ends_at']) && strtotime((string) $hunt['ends_at']) <= time();
|
||||
}
|
||||
|
||||
/** Laeuft die Jagd gerade (Einsendungen moeglich)? */
|
||||
function hunt_running(array $hunt): bool
|
||||
{
|
||||
return !empty($hunt['is_published']) && hunt_started($hunt) && !hunt_closed($hunt);
|
||||
}
|
||||
|
||||
/** Bis wann zaehlt das Bonusbild? */
|
||||
function hunt_bonus_deadline(array $hunt): int
|
||||
{
|
||||
return strtotime((string) $hunt['starts_at']) + HUNT_BONUS_HOURS * 3600;
|
||||
}
|
||||
|
||||
/** Jagd laden - Mitglieder sehen nur veroeffentlichte. */
|
||||
function hunt_find(int $id): ?array
|
||||
{
|
||||
$stmt = db()->prepare('SELECT * FROM hunts WHERE id = ?');
|
||||
$stmt->execute([$id]);
|
||||
$hunt = $stmt->fetch();
|
||||
if (!$hunt || (empty($hunt['is_published']) && !hunt_can_manage())) {
|
||||
return null;
|
||||
}
|
||||
return $hunt;
|
||||
}
|
||||
|
||||
/** @return array<int, array> Orte der Jagd in Reihenfolge, das Bonusbild zuletzt */
|
||||
function hunt_spots(int $huntId): array
|
||||
{
|
||||
$stmt = db()->prepare('SELECT * FROM hunt_spots WHERE hunt_id = ? ORDER BY is_bonus, sort_order, id');
|
||||
$stmt->execute([$huntId]);
|
||||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
/** Anzeigename eines Ortes: "Ort 3" bzw. "Bonusbild", mit Titel, falls die Leitung einen vergeben hat. */
|
||||
function hunt_spot_label(array $spot, int $number): string
|
||||
{
|
||||
$base = !empty($spot['is_bonus']) ? 'Bonusbild' : 'Ort ' . $number;
|
||||
return trim((string) $spot['title']) !== '' ? $base . ': ' . $spot['title'] : $base;
|
||||
}
|
||||
|
||||
function hunt_status_badge(string $status): string
|
||||
{
|
||||
[$label, $class] = HUNT_SUBMISSION_STATUSES[$status] ?? [$status, ''];
|
||||
return '<span class="badge ' . e($class) . '">' . e($label) . '</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle Einsendungen einer Jagd mit Mitglied, je Ort nach Zeitpunkt sortiert - dazu Platz und Punkte der anerkannten.
|
||||
*
|
||||
* @return array<int, array<int, array>> Ort-ID => Einsendungen
|
||||
*/
|
||||
function hunt_submissions_by_spot(int $huntId): array
|
||||
{
|
||||
$stmt = db()->prepare(
|
||||
'SELECT s.*, u.username, u.display_name, u.discord_id, u.avatar_filename, sp.is_bonus,
|
||||
r.username AS reviewer_username, r.display_name AS reviewer_display_name
|
||||
FROM hunt_submissions s
|
||||
JOIN hunt_spots sp ON sp.id = s.spot_id
|
||||
LEFT JOIN users u ON u.id = s.user_id
|
||||
LEFT JOIN users r ON r.id = s.reviewed_by
|
||||
WHERE sp.hunt_id = ?
|
||||
ORDER BY s.submitted_at, s.id'
|
||||
);
|
||||
$stmt->execute([$huntId]);
|
||||
$hunt = db()->prepare('SELECT starts_at FROM hunts WHERE id = ?');
|
||||
$hunt->execute([$huntId]);
|
||||
$bonusDeadline = hunt_bonus_deadline(['starts_at' => (string) $hunt->fetchColumn()]);
|
||||
|
||||
$bySpot = [];
|
||||
$ranks = [];
|
||||
foreach ($stmt->fetchAll() as $row) {
|
||||
$spotId = (int) $row['spot_id'];
|
||||
$row['rank'] = null;
|
||||
$row['points'] = 0;
|
||||
if ($row['status'] === 'accepted') {
|
||||
if (!empty($row['is_bonus'])) {
|
||||
$row['points'] = strtotime((string) $row['submitted_at']) <= $bonusDeadline ? HUNT_BONUS_POINTS : 0;
|
||||
} else {
|
||||
$ranks[$spotId] = ($ranks[$spotId] ?? 0) + 1;
|
||||
$row['rank'] = $ranks[$spotId];
|
||||
$row['points'] = HUNT_RANK_POINTS[$ranks[$spotId] - 1] ?? 0;
|
||||
}
|
||||
}
|
||||
$bySpot[$spotId][] = $row;
|
||||
}
|
||||
return $bySpot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rangliste: Punkte je Mitglied ueber alle Orte, absteigend; bei Gleichstand zaehlt die fruehere letzte Einsendung.
|
||||
*
|
||||
* @param array<int, array<int, array>> $bySpot aus hunt_submissions_by_spot()
|
||||
* @return array<int, array{user: array, points: int, found: int, last: string}>
|
||||
*/
|
||||
function hunt_leaderboard(array $bySpot): array
|
||||
{
|
||||
$board = [];
|
||||
foreach ($bySpot as $submissions) {
|
||||
foreach ($submissions as $row) {
|
||||
if ($row['status'] !== 'accepted' || $row['user_id'] === null) {
|
||||
continue;
|
||||
}
|
||||
$userId = (int) $row['user_id'];
|
||||
$board[$userId] ??= [
|
||||
'user' => [
|
||||
'id' => $userId, 'username' => $row['username'], 'display_name' => $row['display_name'],
|
||||
'discord_id' => $row['discord_id'], 'avatar_filename' => $row['avatar_filename'],
|
||||
],
|
||||
'points' => 0, 'found' => 0, 'last' => '',
|
||||
];
|
||||
$board[$userId]['points'] += (int) $row['points'];
|
||||
$board[$userId]['found']++;
|
||||
$board[$userId]['last'] = max($board[$userId]['last'], (string) $row['submitted_at']);
|
||||
}
|
||||
}
|
||||
usort($board, static fn (array $a, array $b): int => [$b['points'], $a['last']] <=> [$a['points'], $b['last']]);
|
||||
return $board;
|
||||
}
|
||||
|
||||
/** @return array<int, array> Eigene Einsendungen einer Jagd: Ort-ID => Einsendung */
|
||||
function hunt_own_submissions(int $huntId, int $userId): array
|
||||
{
|
||||
$stmt = db()->prepare(
|
||||
'SELECT s.* FROM hunt_submissions s JOIN hunt_spots sp ON sp.id = s.spot_id WHERE sp.hunt_id = ? AND s.user_id = ?'
|
||||
);
|
||||
$stmt->execute([$huntId, $userId]);
|
||||
$own = [];
|
||||
foreach ($stmt->fetchAll() as $row) {
|
||||
$own[(int) $row['spot_id']] = $row;
|
||||
}
|
||||
return $own;
|
||||
}
|
||||
|
||||
/** Anzahl Einsendungen, die noch auf Pruefung warten (Abzeichen in der Seitenleiste). */
|
||||
function hunt_pending_count(): int
|
||||
{
|
||||
try {
|
||||
return (int) db()->query("SELECT COUNT(*) FROM hunt_submissions WHERE status = 'pending'")->fetchColumn();
|
||||
} catch (PDOException $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menuepunkt fuer Mitglieder nur, solange es eine Jagd gibt, die bald beginnt, laeuft oder vor kurzem
|
||||
* zu Ende gegangen ist - die Leitung sieht ihn immer.
|
||||
*/
|
||||
function hunt_nav_visible(): bool
|
||||
{
|
||||
if (hunt_can_manage()) {
|
||||
return true;
|
||||
}
|
||||
if (!hunt_can_take_part()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return (bool) db()->query(
|
||||
'SELECT 1 FROM hunts WHERE is_published = 1
|
||||
AND (ends_at IS NULL OR ends_at > NOW() - INTERVAL 14 DAY) LIMIT 1'
|
||||
)->fetchColumn();
|
||||
} catch (PDOException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function hunt_image_url(string $kind, int $id): string
|
||||
{
|
||||
return '/hunt_image.php?' . http_build_query(['kind' => $kind, 'id' => $id]);
|
||||
}
|
||||
|
||||
/** Vorschaubild mit Grossansicht (assets/js/lightbox.js). */
|
||||
function hunt_thumb_html(string $kind, int $id, string $group, string $caption, string $class = ''): string
|
||||
{
|
||||
$url = e(hunt_image_url($kind, $id));
|
||||
return '<a href="' . $url . '" class="hunt-thumb' . ($class !== '' ? ' ' . e($class) : '') . '" data-lightbox="' . e($group)
|
||||
. '" data-caption="' . e($caption) . '"><img src="' . $url . '" alt="' . e($caption) . '" loading="lazy"></a>';
|
||||
}
|
||||
|
||||
/** Datum mit Sekunden - fuer die Reihenfolge der Einsendungen kommt es darauf an. */
|
||||
function hunt_time(string $datetime): string
|
||||
{
|
||||
return date('d.m.Y H:i:s', strtotime($datetime));
|
||||
}
|
||||
|
||||
/** "Fr, 24.10. um 20:00 Uhr" */
|
||||
function hunt_date(string $datetime): string
|
||||
{
|
||||
$ts = strtotime($datetime);
|
||||
return ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'][(int) date('w', $ts)] . ', ' . date('d.m.Y', $ts) . ' um ' . date('H:i', $ts) . ' Uhr';
|
||||
}
|
||||
|
||||
/** Ein einzelnes Bild aus $_FILES (leeres Feld = null). */
|
||||
function hunt_uploaded_file(string $field): ?array
|
||||
{
|
||||
$file = $_FILES[$field] ?? null;
|
||||
if (!is_array($file) || is_array($file['name'] ?? null) || (int) ($file['error'] ?? UPLOAD_ERR_NO_FILE) === UPLOAD_ERR_NO_FILE) {
|
||||
return null;
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hochgeladenes Bild pruefen, neu speichern (entfernt EXIF/angehaengten Code, verkleinert auf HUNT_MAX_SIDE)
|
||||
* und den Dateinamen zurueckgeben.
|
||||
*
|
||||
* @param array<string, mixed> $file Eintrag aus $_FILES
|
||||
* @throws RuntimeException mit verstaendlicher Meldung
|
||||
*/
|
||||
function hunt_store_upload(array $file, string $prefix): string
|
||||
{
|
||||
if (($file['error'] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_OK) {
|
||||
throw new RuntimeException(in_array($file['error'] ?? 0, [UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE], true)
|
||||
? 'Ein Bild ist zu groß.' : 'Ein Bild konnte nicht hochgeladen werden.');
|
||||
}
|
||||
if ((int) $file['size'] > HUNT_MAX_UPLOAD) {
|
||||
throw new RuntimeException('Ein Bild ist zu groß (höchstens 10 MB).');
|
||||
}
|
||||
$info = @getimagesize((string) $file['tmp_name']);
|
||||
$types = [IMAGETYPE_PNG => 'png', IMAGETYPE_JPEG => 'jpg', IMAGETYPE_GIF => 'gif', IMAGETYPE_WEBP => 'webp'];
|
||||
if ($info === false || !isset($types[$info[2]])) {
|
||||
throw new RuntimeException('Nur PNG, JPG, GIF oder WEBP sind als Bild erlaubt.');
|
||||
}
|
||||
if (!is_dir(HUNT_UPLOAD_DIR)) {
|
||||
@mkdir(HUNT_UPLOAD_DIR, 0755, true);
|
||||
}
|
||||
$name = $prefix . '_' . bin2hex(random_bytes(8)) . '.' . $types[$info[2]];
|
||||
$error = store_uploaded_image((string) $file['tmp_name'], HUNT_UPLOAD_DIR . $name, $info[2], HUNT_MAX_SIDE, true);
|
||||
if ($error !== null) {
|
||||
throw new RuntimeException($error);
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
function hunt_delete_file(?string $filename): void
|
||||
{
|
||||
if ($filename !== null && $filename !== '' && strpos($filename, '/') === false && is_file(HUNT_UPLOAD_DIR . $filename)) {
|
||||
@unlink(HUNT_UPLOAD_DIR . $filename);
|
||||
}
|
||||
}
|
||||
|
||||
/** Dateien aller Einsendungen (und Ortsbilder) einer Jagd loeschen - die Zeilen fallen per Fremdschluessel weg. */
|
||||
function hunt_delete_files(int $huntId): void
|
||||
{
|
||||
$stmt = db()->prepare(
|
||||
'SELECT s.screenshot_filename, s.map_filename FROM hunt_submissions s JOIN hunt_spots sp ON sp.id = s.spot_id WHERE sp.hunt_id = ?
|
||||
UNION ALL SELECT image_filename, NULL FROM hunt_spots WHERE hunt_id = ?'
|
||||
);
|
||||
$stmt->execute([$huntId, $huntId]);
|
||||
foreach ($stmt->fetchAll(PDO::FETCH_NUM) as $row) {
|
||||
hunt_delete_file($row[0]);
|
||||
hunt_delete_file($row[1]);
|
||||
}
|
||||
}
|
||||
|
|
@ -93,6 +93,13 @@ function nav_badges(array $user, string $currentScript, ?array $seen = null): ar
|
|||
$badges['/bugs.php'] = $plain($count, 'Offene Fehlermeldungen');
|
||||
}
|
||||
}
|
||||
if (user_has_permission('hunt.manage')) {
|
||||
require_once __DIR__ . '/hunt.php';
|
||||
$count = hunt_pending_count();
|
||||
if ($count > 0) {
|
||||
$badges['/hunt.php'] = $plain($count, $count === 1 ? '1 Einsendung wartet auf Prüfung' : $count . ' Einsendungen warten auf Prüfung');
|
||||
}
|
||||
}
|
||||
if (user_has_permission('comments.moderate')) {
|
||||
// Wartet auf Freigabe und gemeldet, aber noch sichtbar - wie der Reiter "Freigabe"
|
||||
[$pending, $reported] = moderation_open_counts();
|
||||
|
|
@ -348,6 +355,21 @@ function live_fingerprint_parts(string $path, array $params, int $userId): ?arra
|
|||
$sum('SELECT COUNT(*), COALESCE(MAX(id), 0) FROM bug_report_images'),
|
||||
];
|
||||
|
||||
case '/hunt.php':
|
||||
if (!user_has_permission('dashboard.view') && !user_has_permission('hunt.manage')) {
|
||||
return null;
|
||||
}
|
||||
// Mit dem Start (Bilder werden sichtbar) laedt die Seite von selbst neu. Fremde Einsendungen nur fuer die
|
||||
// Leitung - Mitglieder bekaemen sonst bei jeder Einsendung ein Neuladen
|
||||
$parts = [
|
||||
$sum('SELECT COUNT(*), ' . $crc('id, title, description, starts_at, ends_at, is_published, results_public') . ', SUM(starts_at <= NOW()), SUM(ends_at <= NOW()) FROM hunts'),
|
||||
$sum('SELECT COUNT(*), ' . $crc('id, hunt_id, title, is_bonus, sort_order') . ' FROM hunt_spots'),
|
||||
];
|
||||
$parts[] = user_has_permission('hunt.manage')
|
||||
? $sum('SELECT COUNT(*), ' . $crc('id, submitted_at, status, review_note') . ' FROM hunt_submissions')
|
||||
: $sum('SELECT COUNT(*), ' . $crc('id, submitted_at, status, review_note') . ' FROM hunt_submissions WHERE user_id = ?', [$userId]);
|
||||
return $parts;
|
||||
|
||||
case '/moderation.php':
|
||||
if (!user_has_permission('comments.moderate')) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,16 @@ const PATCHNOTE_TYPES = [
|
|||
];
|
||||
|
||||
const PATCHNOTES = [
|
||||
[
|
||||
'id' => '2026-10-23-a',
|
||||
'date' => '2026-10-23',
|
||||
'title' => 'Schnitzeljagd',
|
||||
'summary' => 'Neuer Bereich Schnitzeljagd: gesuchte Orte finden und die Screenshots direkt auf der Website einsenden.',
|
||||
'changes' => [
|
||||
['type' => 'neu', 'area' => 'Schnitzeljagd', 'text' => 'Zum Start einer Schnitzeljagd erscheinen im Menüpunkt „Schnitzeljagd“ die Bilder der gesuchten Orte (plus Bonusbild). Je Ort lädst du einen Screenshot vom Ort und einen von deiner Karte mit deinem Standort hoch. Deine Bilder sehen nur du und die Leitung – mit der genauen Uhrzeit, zu der du sie hochgeladen hast; danach richtet sich dein Platz. Abgelehnte Einsendungen kannst du neu schicken, solange die Jagd läuft.'],
|
||||
['type' => 'neu', 'area' => 'Schnitzeljagd', 'audience' => 'leitung', 'text' => 'Mit dem Recht hunt.manage legst du Jagden an (Start, Einsendeschluss, Regeln), lädst die Orte hoch, siehst alle Einsendungen je Ort nach Uhrzeit sortiert und erkennst sie an oder lehnst sie ab. Die Punkte rechnet die Seite selbst (je Ort 5/4/3/3/3 für die schnellsten, Bonusbild 5 innerhalb von 24 Stunden); die Rangliste lässt sich für alle veröffentlichen.'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => '2026-10-18-h',
|
||||
'date' => '2026-10-18',
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ const CORE_PERMISSIONS = [
|
|||
['key' => 'premades.lead_multiple', 'description' => 'Premades: beliebig viele Premades gleichzeitig leiten (sonst höchstens 3 - Mitglied sein kann jeder in beliebig vielen)'],
|
||||
['key' => 'events.view', 'description' => 'Geplante Event-Erinnerungen einsehen'],
|
||||
['key' => 'events.manage', 'description' => 'Event-Erinnerungen planen, bearbeiten und löschen'],
|
||||
['key' => 'hunt.manage', 'description' => 'Schnitzeljagd: Jagden anlegen, die gesuchten Orte als Bilder hochladen, alle Einsendungen mit Uhrzeit sehen, anerkennen oder ablehnen und die Rangliste veröffentlichen (mitmachen kann jeder mit dashboard.view)'],
|
||||
['key' => 'activity.manage', 'description' => 'Aktivitätschecks im Discord starten, ansehen und beenden (inkl. Folgen wie PN und Rollenänderung)'],
|
||||
['key' => 'map.view', 'description' => 'Interaktive Karte und öffentliche Taktiken ansehen (PvP-Taktiken nur Strategen), eigene (private oder öffentliche) Taktiken anlegen und zeichnen'],
|
||||
['key' => 'map.tactics', 'description' => 'Stratege: alle öffentlichen Taktiken sehen (auch die geheimen PvP-Taktiken) und bearbeiten, darin zeichnen und löschen – auch die anderer Mitglieder (offizielle nur mit map.tactics.highlight)'],
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
|
||||
// Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu.
|
||||
const SCHEMA_VERSION = 76;
|
||||
const SCHEMA_VERSION = 77;
|
||||
|
||||
/**
|
||||
* Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql).
|
||||
|
|
@ -971,6 +971,67 @@ CREATE TABLE IF NOT EXISTS raid_templates (
|
|||
UNIQUE KEY uniq_raid_template_name (area, name),
|
||||
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
|
||||
SQL,
|
||||
// Schnitzeljagd (includes/hunt.php, hunt.php): eine Jagd mit Startzeit, ab der die Mitglieder die Bilder sehen
|
||||
'hunts' => <<<'SQL'
|
||||
CREATE TABLE IF NOT EXISTS hunts (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
title VARCHAR(120) NOT NULL,
|
||||
-- Ablauf und Regeln (Text mit Zeilenumbruechen)
|
||||
description TEXT NULL,
|
||||
-- Ab dann sehen die Mitglieder die gesuchten Orte und koennen einsenden
|
||||
starts_at DATETIME NOT NULL,
|
||||
-- Einsendeschluss, NULL = offen, bis die Leitung ihn setzt
|
||||
ends_at DATETIME NULL,
|
||||
-- 0 = Entwurf, nur die Leitung sieht die Jagd
|
||||
is_published TINYINT(1) NOT NULL DEFAULT 0,
|
||||
-- 1 = Mitglieder sehen die Rangliste (ohne die Bilder der anderen)
|
||||
results_public TINYINT(1) NOT NULL DEFAULT 0,
|
||||
created_by INT UNSIGNED NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_hunts_start (starts_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
SQL,
|
||||
// Gesuchte Orte einer Schnitzeljagd (Bild unter assets/uploads/hunt/, nur ueber /hunt_image.php)
|
||||
'hunt_spots' => <<<'SQL'
|
||||
CREATE TABLE IF NOT EXISTS hunt_spots (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
hunt_id INT UNSIGNED NOT NULL,
|
||||
-- optionaler Hinweis zum Bild, z.B. "Irgendwo in Verteron"
|
||||
title VARCHAR(120) NOT NULL DEFAULT '',
|
||||
image_filename VARCHAR(120) NOT NULL,
|
||||
-- 1 = Bonusbild: Punkte fuer jeden, der es rechtzeitig findet (HUNT_BONUS_HOURS)
|
||||
is_bonus TINYINT(1) NOT NULL DEFAULT 0,
|
||||
sort_order INT NOT NULL DEFAULT 0,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (hunt_id) REFERENCES hunts(id) ON DELETE CASCADE,
|
||||
INDEX idx_hunt_spots_hunt (hunt_id, sort_order)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
SQL,
|
||||
// Einsendungen: je Mitglied und Ort ein Screenshot vom Ort und einer der Karte mit dem Standort.
|
||||
// Sieht nur die Leitung (hunt.manage) und wer sie geschickt hat.
|
||||
'hunt_submissions' => <<<'SQL'
|
||||
CREATE TABLE IF NOT EXISTS hunt_submissions (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
spot_id INT UNSIGNED NOT NULL,
|
||||
user_id INT UNSIGNED NOT NULL,
|
||||
screenshot_filename VARCHAR(120) NOT NULL,
|
||||
map_filename VARCHAR(120) NOT NULL,
|
||||
note VARCHAR(255) NULL,
|
||||
-- Zeitpunkt des Hochladens - danach richtet sich der Platz (bei erneutem Einsenden der neue)
|
||||
submitted_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
status ENUM('pending', 'accepted', 'rejected') NOT NULL DEFAULT 'pending',
|
||||
-- Begruendung der Leitung (sieht das Mitglied)
|
||||
review_note VARCHAR(255) NULL,
|
||||
reviewed_by INT UNSIGNED NULL,
|
||||
reviewed_at DATETIME NULL,
|
||||
UNIQUE KEY uq_hunt_submissions (spot_id, user_id),
|
||||
FOREIGN KEY (spot_id) REFERENCES hunt_spots(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (reviewed_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_hunt_submissions_status (status)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
SQL,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ function audit_area_for_script(string $script): string
|
|||
$prefixes = [
|
||||
'raid' => 'raids', 'premade' => 'premades', 'event' => 'events', 'tactics' => 'map', 'map' => 'map',
|
||||
'warehouse' => 'warehouse', 'contributions' => 'contributions', 'shop' => 'shop', 'dues' => 'dues',
|
||||
'member' => 'members', 'gallery' => 'members', 'moderation' => 'members', 'reaction' => 'members', 'calendar' => 'events', 'wiki' => 'wiki', 'gear' => 'gear', 'report' => 'reports', 'bug' => 'bugs',
|
||||
'member' => 'members', 'gallery' => 'members', 'moderation' => 'members', 'reaction' => 'members', 'calendar' => 'events', 'wiki' => 'wiki', 'gear' => 'gear', 'report' => 'reports', 'bug' => 'bugs', 'hunt' => 'events',
|
||||
'user' => 'users', 'role' => 'users', 'discord' => 'users', 'settings' => 'users', 'consilium' => 'users',
|
||||
'site' => 'site', 'announcement' => 'site', 'bot' => 'discord',
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1127,3 +1127,61 @@ CREATE TABLE IF NOT EXISTS consilium_legions (
|
|||
discord_role_id VARCHAR(20) NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Schnitzeljagd (includes/hunt.php, hunt.php): eine Jagd mit Startzeit, ab der die Mitglieder die Bilder sehen
|
||||
CREATE TABLE IF NOT EXISTS hunts (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
title VARCHAR(120) NOT NULL,
|
||||
-- Ablauf und Regeln (Text mit Zeilenumbruechen)
|
||||
description TEXT NULL,
|
||||
-- Ab dann sehen die Mitglieder die gesuchten Orte und koennen einsenden
|
||||
starts_at DATETIME NOT NULL,
|
||||
-- Einsendeschluss, NULL = offen, bis die Leitung ihn setzt
|
||||
ends_at DATETIME NULL,
|
||||
-- 0 = Entwurf, nur die Leitung sieht die Jagd
|
||||
is_published TINYINT(1) NOT NULL DEFAULT 0,
|
||||
-- 1 = Mitglieder sehen die Rangliste (ohne die Bilder der anderen)
|
||||
results_public TINYINT(1) NOT NULL DEFAULT 0,
|
||||
created_by INT UNSIGNED NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_hunts_start (starts_at)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Gesuchte Orte einer Schnitzeljagd (Bild unter assets/uploads/hunt/, nur ueber /hunt_image.php)
|
||||
CREATE TABLE IF NOT EXISTS hunt_spots (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
hunt_id INT UNSIGNED NOT NULL,
|
||||
-- optionaler Hinweis zum Bild, z.B. "Irgendwo in Verteron"
|
||||
title VARCHAR(120) NOT NULL DEFAULT '',
|
||||
image_filename VARCHAR(120) NOT NULL,
|
||||
-- 1 = Bonusbild: Punkte fuer jeden, der es rechtzeitig findet (HUNT_BONUS_HOURS)
|
||||
is_bonus TINYINT(1) NOT NULL DEFAULT 0,
|
||||
sort_order INT NOT NULL DEFAULT 0,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (hunt_id) REFERENCES hunts(id) ON DELETE CASCADE,
|
||||
INDEX idx_hunt_spots_hunt (hunt_id, sort_order)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Einsendungen: je Mitglied und Ort ein Screenshot vom Ort und einer der Karte mit dem Standort.
|
||||
-- Sieht nur die Leitung (hunt.manage) und wer sie geschickt hat.
|
||||
CREATE TABLE IF NOT EXISTS hunt_submissions (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
spot_id INT UNSIGNED NOT NULL,
|
||||
user_id INT UNSIGNED NOT NULL,
|
||||
screenshot_filename VARCHAR(120) NOT NULL,
|
||||
map_filename VARCHAR(120) NOT NULL,
|
||||
note VARCHAR(255) NULL,
|
||||
-- Zeitpunkt des Hochladens - danach richtet sich der Platz (bei erneutem Einsenden der neue)
|
||||
submitted_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
status ENUM('pending', 'accepted', 'rejected') NOT NULL DEFAULT 'pending',
|
||||
-- Begruendung der Leitung (sieht das Mitglied)
|
||||
review_note VARCHAR(255) NULL,
|
||||
reviewed_by INT UNSIGNED NULL,
|
||||
reviewed_at DATETIME NULL,
|
||||
UNIQUE KEY uq_hunt_submissions (spot_id, user_id),
|
||||
FOREIGN KEY (spot_id) REFERENCES hunt_spots(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (reviewed_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
INDEX idx_hunt_submissions_status (status)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
|
|
|||
Loading…
Reference in a new issue