diff --git a/.gitignore b/.gitignore index 81ab70f..bb6941f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,12 @@ assets/uploads/wiki/* assets/uploads/profiles/* !assets/uploads/profiles/.htaccess !assets/uploads/profiles/.gitkeep +assets/uploads/bugs/* +!assets/uploads/bugs/.htaccess +!assets/uploads/bugs/.gitkeep +assets/uploads/gear/* +!assets/uploads/gear/.htaccess +!assets/uploads/gear/.gitkeep # Kacheln, Marker und Icons der Karte (~230 MB) - werden per FTP hochgeladen, siehe README assets/map/data/ __pycache__/ diff --git a/admin/gear_items.php b/admin/gear_items.php new file mode 100644 index 0000000..44a924c --- /dev/null +++ b/admin/gear_items.php @@ -0,0 +1,175 @@ +query('SELECT slot, COUNT(*) FROM gear_items GROUP BY slot ORDER BY slot')->fetchAll(PDO::FETCH_KEY_PAIR); +if (!isset($slotNames[$slotFilter])) { + $slotFilter = ''; +} + +$conditions = []; +$params = []; +if ($query !== '') { + $conditions[] = '(g.name LIKE ? OR g.id = ?)'; + $params[] = '%' . addcslashes($query, '%_\\') . '%'; + $params[] = ctype_digit($query) ? (int) $query : 0; +} +if ($slotFilter !== '') { + $conditions[] = 'g.slot = ?'; + $params[] = $slotFilter; +} +$where = $conditions ? 'WHERE ' . implode(' AND ', $conditions) : ''; + +$countStmt = db()->prepare("SELECT COUNT(*) FROM gear_items g $where"); +$countStmt->execute($params); +$total = (int) $countStmt->fetchColumn(); +$perPage = 50; +$pageCount = max(1, (int) ceil($total / $perPage)); +$page = min($pageCount, max(1, (int) ($_GET['page'] ?? 1))); +$stmt = db()->prepare( + "SELECT g.*, (SELECT COUNT(*) FROM gear_set_slots s WHERE s.item_id = g.id) AS used + FROM gear_items g $where ORDER BY g.item_level DESC, g.name LIMIT $perPage OFFSET " . (($page - 1) * $perPage) +); +$stmt->execute($params); +$items = array_map('gear_item_decode', $stmt->fetchAll()); +$allIds = array_map('intval', db()->query('SELECT id FROM gear_items ORDER BY checked_at, id')->fetchAll(PDO::FETCH_COLUMN)); +$lastVersion = (string) db()->query('SELECT source_version FROM gear_items ORDER BY checked_at DESC LIMIT 1')->fetchColumn(); + +$listUrl = static function (array $overrides = []) use ($query, $slotFilter): string { + $params = array_filter(array_merge(['q' => $query, 'slot' => $slotFilter], $overrides), static fn ($v): bool => $v !== '' && $v !== null); + return '/admin/gear_items.php?' . ($params ? http_build_query($params) . '&' : ''); +}; + +$pageTitle = 'Gear-Planer: Gegenstände'; +$containerWide = true; +include __DIR__ . '/../includes/header.php'; +?> +
+

Gear-Planer: Gegenstände

+

+ Werte kommen von aion2hub.com + (aus dem Global-Client ausgelesen). Abgerufen wird immer nur eine Seite pro Sekunde und nur auf Knopfdruck. + Zuletzt abgeglichener Stand: . +

+ +
+

Übernehmen

+

+ Gegenstands-ID, Link zu einem Gegenstand (aion2hub.com/database/items/110130060) oder + eine Listen-Seite (z.B. aion2hub.com/database?cat=Armor&grade=Unique - übernimmt + alle Gegenstände dieser Seite, bis zu 60). +

+
+ + + +
+
+ + + +
+ +
+
+ +
+
+
+ + +
+ Gegenstände +
+ + +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
GegenstandSlotStufeSockelAufwertungGeprüftIn Sets
+ + + + + # · + + + ' . e($item['item_type']) . '' : '' ?> + + + + +
+ + + + +
+
+
+ + +
+ + + + + diff --git a/admin/gear_items_action.php b/admin/gear_items_action.php new file mode 100644 index 0000000..ff481f1 --- /dev/null +++ b/admin/gear_items_action.php @@ -0,0 +1,124 @@ + 0) { + usleep((int) ($wait * 1000000)); + } + $_SESSION['gear_source_last_fetch'] = microtime(true); +}; + +try { + switch ($action) { + case 'list': + // Listen-Seite von aion2hub (z.B. database?cat=Armor&grade=Unique&page=2) -> enthaltene IDs + $url = trim((string) ($_POST['url'] ?? '')); + $single = gear_source_parse_id($url); + if ($single !== null) { + $respond(['ok' => true, 'ids' => [$single]]); + } + if (!preg_match('#^https://(www\.)?aion2hub\.com/database(\?|$)#i', $url)) { + $respond(['ok' => false, 'error' => 'Bitte eine Gegenstands-ID, einen Gegenstands-Link oder eine Listen-Seite von aion2hub.com/database eintragen.'], 400); + } + $politePause(); + $ids = gear_source_list_ids(gear_source_fetch($url)); + if (!$ids) { + $respond(['ok' => false, 'error' => 'Auf dieser Seite wurden keine Gegenstände gefunden.'], 404); + } + $known = db()->query('SELECT id FROM gear_items')->fetchAll(PDO::FETCH_COLUMN); + $respond(['ok' => true, 'ids' => $ids, 'known' => array_map('intval', array_values(array_intersect($known, $ids)))]); + + case 'import': + case 'check': + $id = (int) ($_POST['id'] ?? 0); + if ($id <= 0) { + $respond(['ok' => false, 'error' => 'Ungültige ID.'], 400); + } + $politePause(); + $parsed = gear_item_fetch($id); + $old = gear_item($id); + $diffs = gear_item_diff($old, $parsed); + // Abgleich ohne Uebernehmen: nur zeigen, was anders waere + $apply = $action === 'import' || !empty($_POST['apply']); + if ($apply) { + $result = gear_item_store($parsed, $userId); + } elseif ($old !== null) { + // Trotzdem als "geprueft" vermerken, wenn sich nichts geaendert hat + if (!$diffs) { + db()->prepare('UPDATE gear_items SET checked_at = NOW(), checked_by = ?, source_version = ? WHERE id = ?') + ->execute([$userId, mb_substr($parsed['source_version'], 0, 120), $id]); + } + } + if (empty($_POST['batch']) && $apply) { + admin_log($old === null ? '🗡️ Gear-Planer: Gegenstand übernommen' : '🗡️ Gear-Planer: Gegenstand abgeglichen', [ + 'Gegenstand' => $parsed['name'] . ' (#' . $id . ')', + 'Änderungen' => $old === null ? 'neu' : ($diffs ? implode(', ', array_column($diffs, 0)) : 'keine'), + ], 'info', 'gear'); + } + $respond([ + 'ok' => true, + 'id' => $id, + 'name' => $parsed['name'], + 'new' => $old === null, + 'applied' => $apply, + 'diffs' => $old === null ? [] : $diffs, + ]); + + case 'batch_done': + // Eine Zusammenfassung pro Durchlauf statt eines Eintrags je Gegenstand + $summary = array_filter([ + 'Art' => (string) ($_POST['kind'] ?? '') === 'check' ? 'Abgleich' : 'Übernahme', + 'Neu' => (int) ($_POST['new'] ?? 0) ?: null, + 'Geändert' => (int) ($_POST['changed'] ?? 0) ?: null, + 'Unverändert' => (int) ($_POST['same'] ?? 0) ?: null, + 'Fehler' => (int) ($_POST['failed'] ?? 0) ?: null, + 'Quelle' => mb_substr((string) ($_POST['source'] ?? ''), 0, 200) ?: null, + ], static fn ($value): bool => $value !== null); + admin_log('🗡️ Gear-Planer: Gegenstände von aion2hub', $summary, 'info', 'gear'); + $respond(['ok' => true]); + + case 'delete': + $item = gear_item((int) ($_POST['id'] ?? 0)); + if ($item) { + db()->prepare('DELETE FROM gear_items WHERE id = ?')->execute([$item['id']]); + if (!empty($item['icon']) && strpos((string) $item['icon'], '/') === false) { + @unlink(GEAR_ICON_DIR . $item['icon']); + } + admin_log('🗡️ Gear-Planer: Gegenstand gelöscht', ['Gegenstand' => $item['name'] . ' (#' . $item['id'] . ')'], 'danger', 'gear'); + set_flash('success', '„' . $item['name'] . '“ gelöscht - in Sets ist der Slot jetzt leer.'); + } + redirect('/admin/gear_items.php'); + } +} catch (RuntimeException $e) { + $respond(['ok' => false, 'error' => $e->getMessage()], 422); +} + +$respond(['ok' => false, 'error' => 'Unbekannte Aktion.'], 400); diff --git a/assets/css/style.css b/assets/css/style.css index 089e092..ec5d5b4 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -598,11 +598,13 @@ input[type="datetime-local"]::-webkit-calendar-picker-indicator { .button:hover, button:hover { background: var(--gold-hover); color: #1a1a1a; text-decoration: none; } +/* [hidden] soll auch bei Buttons wirken (display von .button wuerde es sonst ueberstimmen) */ +.button[hidden] { display: none !important; } .button-danger { background: var(--danger); color: #fff; } .button-danger:hover { background: #c9302c; color: #fff; } .button-secondary { background: var(--bg-panel-alt); color: var(--text); border: 1px solid var(--border); } -.button-secondary:hover { background: #30304a; color: var(--text); } +.button-secondary:hover { background: #383838; border-color: rgba(201, 162, 39, 0.55); color: var(--text); } .button-success { background: var(--success); color: #fff; } .button-success:hover { background: #3d8b40; color: #fff; } @@ -2647,7 +2649,6 @@ a.button-small:hover { text-decoration: none; } .attendance-option:hover { border-color: var(--text-muted); } .attendance-present:has(input:checked) { border-color: var(--success); background: rgba(76, 175, 80, 0.2); color: #8fdc92; } .attendance-absent:has(input:checked) { border-color: var(--danger); background: rgba(217, 83, 79, 0.2); color: #ff9b97; } -.attendance-excused:has(input:checked) { border-color: var(--gold); background: rgba(201, 162, 39, 0.18); color: var(--gold); } .attendance-none:has(input:checked) { border-color: var(--text-muted); background: var(--bg-panel-alt); } .attendance-option:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; } @@ -2904,7 +2905,88 @@ input.shop-approve-quantity { width: 72px; padding: 0.3rem 0.45rem; font-size: 0 .dashboard-points-value { font-size: 2.2rem; font-weight: 700; line-height: 1.15; color: var(--gold); font-variant-numeric: tabular-nums; } .dashboard-points-main p { margin: 0.1rem 0 0; font-size: 0.85rem; } .dashboard-points-shop { display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; } -.dashboard-points-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-left: auto; } +.dashboard-points-links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-left: auto; } +/* Buttons unter den Lumipunkten: heben sich beim Drueberfahren an, leuchten golden und ein + Lichtstreifen laeuft darueber */ +.dashboard-cta { + position: relative; + overflow: hidden; + display: inline-flex; + align-items: center; + gap: 0.5rem; + isolation: isolate; + transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.3), box-shadow 0.25s ease, background 0.25s ease, border-color 0.25s ease, color 0.25s ease; +} +.dashboard-cta .icon { transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4); } +.dashboard-cta::before { + content: ''; + position: absolute; + top: 0; + left: -80%; + width: 60%; + height: 100%; + background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.55), transparent); + transform: skewX(-20deg); + pointer-events: none; + z-index: -1; +} +.dashboard-cta:hover, .dashboard-cta:focus-visible { + transform: translateY(-3px) scale(1.04); + text-decoration: none; +} +.dashboard-cta:hover::before, .dashboard-cta:focus-visible::before { animation: dashboard-cta-shine 0.75s ease; } +.dashboard-cta:hover .icon, .dashboard-cta:focus-visible .icon { transform: scale(1.2) rotate(-8deg); } +.dashboard-cta:active { transform: translateY(-1px) scale(1.01); } +@keyframes dashboard-cta-shine { to { left: 130%; } } + +/* Rangliste & Verlauf: dunkel mit Goldrand, beim Hovern goldener Schimmer */ +.dashboard-cta.button-secondary:hover, .dashboard-cta.button-secondary:focus-visible { + background: linear-gradient(135deg, rgba(201, 162, 39, 0.28), rgba(201, 162, 39, 0.08)); + border-color: var(--gold); + color: #f3d77a; + box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45), 0 0 18px rgba(201, 162, 39, 0.35), inset 0 0 12px rgba(201, 162, 39, 0.15); +} +.dashboard-cta.button-secondary::before { background: linear-gradient(105deg, transparent, rgba(243, 215, 122, 0.35), transparent); } + +/* Zum Lumishop: Gold mit Verlauf und kraeftigem Leuchten */ +.dashboard-cta-primary { background: linear-gradient(135deg, #e6c24a, var(--gold) 55%, #a8841c); } +.dashboard-cta-primary:hover, .dashboard-cta-primary:focus-visible { + background: linear-gradient(135deg, #fff0b3, #f0cd4f 45%, var(--gold)); + color: #1a1a1a; + box-shadow: 0 10px 26px rgba(201, 162, 39, 0.45), 0 0 30px rgba(243, 215, 122, 0.45); +} + +@media (prefers-reduced-motion: reduce) { + .dashboard-cta, .dashboard-cta .icon { transition: background 0.2s, box-shadow 0.2s, border-color 0.2s, color 0.2s; } + .dashboard-cta:hover, .dashboard-cta:focus-visible, .dashboard-cta:hover .icon { transform: none; } + .dashboard-cta:hover::before, .dashboard-cta:focus-visible::before { animation: none; } +} + +/* Klickbares Kaestchen (z.B. "Anstehende Raids" -> Raids) */ +.stat-card-link { + position: relative; + color: var(--text); + transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease; +} +.stat-card-link:hover, .stat-card-link:focus-visible { + color: var(--text); + text-decoration: none; + border-color: var(--gold); + transform: translateY(-2px); + box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35), 0 0 14px rgba(201, 162, 39, 0.2); +} +.stat-card-arrow { margin-left: auto; color: var(--text-muted); font-size: 1.2rem; transition: transform 0.2s ease, color 0.2s ease; } +.stat-card-link:hover .stat-card-arrow, .stat-card-link:focus-visible .stat-card-arrow { color: var(--gold); transform: translateX(4px); } +@media (prefers-reduced-motion: reduce) { + .stat-card-link:hover, .stat-card-link:focus-visible { transform: none; } +} + +/* Termin eines Raids -> Kalender an diesem Tag */ +.raid-calendar-link { display: inline-flex; align-items: center; gap: 0.35rem; color: inherit; } +.raid-calendar-link .icon { width: 14px; height: 14px; opacity: 0.6; transition: opacity 0.15s, color 0.15s; } +.raid-calendar-link:hover { color: var(--gold); } +.raid-calendar-link:hover .icon { opacity: 1; color: var(--gold); } + @media (max-width: 700px) { .shop-order-actions { flex-wrap: wrap; justify-content: flex-end; width: 100%; } } @@ -2981,6 +3063,12 @@ input.shop-approve-quantity { width: 72px; padding: 0.3rem 0.45rem; font-size: 0 .bug-my-meta { font-size: 0.82rem; margin-top: 0.15rem; } +/* Angehaengte Bilder einer Fehlermeldung (Klick -> Grossansicht) */ +.bug-images { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0 0.2rem; } +.bug-images a { display: block; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; transition: border-color 0.15s, transform 0.15s; } +.bug-images a:hover { border-color: var(--gold); transform: translateY(-1px); } +.bug-images img { display: block; width: 96px; height: 72px; object-fit: cover; } + .bug-admin-note { margin-top: 0.5rem; padding: 0.55rem 0.75rem; @@ -4629,6 +4717,22 @@ a.member-card:hover { text-decoration: none; color: var(--text); } .file-drop-clear:hover { background: rgba(217, 83, 79, 0.12); border-color: var(--danger); color: var(--danger); } +/* Bild per Strg+V eingefuegt: kurzes goldenes Aufleuchten */ +.file-drop.is-pasted .file-drop-body { border-color: var(--gold-hover); background: rgba(201, 162, 39, 0.2); box-shadow: 0 0 18px rgba(201, 162, 39, 0.35); } +.file-drop-note { font-size: 0.8rem; color: var(--gold); } + +kbd { + display: inline-block; + padding: 0 0.35rem; + border: 1px solid var(--border); + border-bottom-width: 2px; + border-radius: 4px; + background: rgba(255, 255, 255, 0.06); + font-family: inherit; + font-size: 0.85em; + line-height: 1.5; +} + /* Ohne JavaScript: wenigstens der Knopf im Stil der Seite */ input[type="file"]::file-selector-button { margin-right: 0.75rem; @@ -5177,6 +5281,163 @@ input[type="file"]::file-selector-button { .not-found-stars, .not-found-code { animation: none; } } +/* ---- Gear-Planer ---- */ +/* Seltenheit wie im Spiel: Farbe von Name und Rahmen */ +.grade-common { --grade: #c8c8c8; } +.grade-rare { --grade: #5cc16b; } +.grade-epic { --grade: #4aa3ff; } +.grade-unique { --grade: #e0b930; } +.grade-heroic { --grade: #ff7a3d; } +.grade-special { --grade: #d46cff; } +a.grade-common, a.grade-rare, a.grade-epic, a.grade-unique, a.grade-heroic, a.grade-special, +span.grade-common, span.grade-rare, span.grade-epic, span.grade-unique, span.grade-heroic, span.grade-special, +strong.grade-common, strong.grade-rare, strong.grade-epic, strong.grade-unique, strong.grade-heroic, strong.grade-special { color: var(--grade); } +.gear-icon { + display: inline-block; + flex-shrink: 0; + border-radius: 6px; + border: 1px solid var(--grade, var(--border)); + background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.35)); + object-fit: contain; +} +.gear-icon-empty { border-style: dashed; border-color: var(--border); background: rgba(255, 255, 255, 0.02); } +.gear-estimated { color: var(--gold); font-weight: 600; margin-right: 0.15rem; cursor: help; } +.gear-hint { font-size: 0.82rem; margin: 0.5rem 0 0; } + +.gear-head { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: flex-start; } +.gear-head > div:first-child { flex: 1 1 420px; } +.gear-head p { margin: 0.25rem 0 0; max-width: 760px; } +.gear-head-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; } +.gear-empty p { margin: 0 0 0.5rem; } + +/* Uebersicht */ +.gear-overview-head { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; } +.gear-overview-head h2 { margin: 0; } +.gear-create-form { display: flex; flex-direction: row; flex-wrap: wrap; gap: 0.5rem; align-items: center; } +.gear-create-form input { width: auto; min-width: 0; flex: 1 1 200px; height: auto; } +.gear-create-form select { width: auto; } +.gear-set-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 0.75rem; } +.gear-set-card { + position: relative; + border: 1px solid var(--border); + border-radius: 10px; + background: rgba(255, 255, 255, 0.03); + transition: border-color 0.15s, background 0.15s; +} +.gear-set-card:hover { border-color: rgba(201, 162, 39, 0.6); } +.gear-set-card.is-checked { border-color: var(--gold); background: rgba(201, 162, 39, 0.08); } +.gear-set-card-link { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.9rem 2.6rem 0.9rem 1rem; color: var(--text); } +.gear-set-card-link:hover { text-decoration: none; color: var(--text); } +.gear-set-card-title { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; font-size: 1.05rem; } +.gear-set-card-icons { display: flex; flex-wrap: wrap; gap: 3px; min-height: 26px; } +.gear-set-card-note { font-size: 0.85rem; color: var(--text-muted); font-style: italic; } +.gear-set-card-check { position: absolute; top: 0.75rem; right: 0.75rem; } +.gear-set-card-check input { width: 18px; height: 18px; accent-color: var(--gold); cursor: pointer; } +.gear-compare-bar { margin-top: 1rem; align-items: center; flex-wrap: wrap; } + +/* Ein Set */ +.gear-set-head { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: flex-start; } +.gear-set-title h2 { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.2rem; } +.gear-set-title p { margin: 0.5rem 0 0; } +.gear-set-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; } +.gear-set-actions form { margin: 0; } +.gear-compare-with select { width: auto; padding: 0.35rem 0.6rem; font-size: 0.85rem; } +.gear-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1.5rem; align-items: start; } +.gear-layout.has-editor { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } +@media (max-width: 1100px) { .gear-layout.has-editor { grid-template-columns: 1fr; } } +.gear-group-title { margin: 1rem 0 0.5rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); } +.gear-group-title:first-child { margin-top: 0; } +.gear-slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 0.5rem; } +.gear-slot { + display: flex; + gap: 0.65rem; + align-items: center; + padding: 0.5rem 0.65rem; + border: 1px solid var(--border); + border-left: 3px solid var(--grade, var(--border)); + border-radius: 8px; + background: rgba(255, 255, 255, 0.025); + color: var(--text); + min-width: 0; + transition: background 0.15s, border-color 0.15s; +} +.gear-slot:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; color: var(--text); } +.gear-slot.is-active { border-color: var(--gold); border-left-color: var(--grade, var(--gold)); background: rgba(201, 162, 39, 0.1); } +.gear-slot-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; } +.gear-slot-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); } +.gear-slot-name { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.gear-slot:not(.is-filled) .gear-slot-name { color: var(--text-muted); font-style: italic; } +.gear-slot.is-filled .gear-slot-name { color: var(--grade); } +.gear-slot-tags { font-size: 0.78rem; color: var(--text-muted); } + +.gear-side { display: flex; flex-direction: column; min-width: 0; } +.gear-slot-editor h3, .gear-totals h3 { margin-top: 0; } +.gear-item-card { display: flex; gap: 0.75rem; align-items: flex-start; margin-bottom: 1rem; } +.gear-item-card > div { min-width: 0; } +.gear-item-stats { font-size: 0.85rem; margin-top: 0.25rem; } +.gear-slot-form { display: flex; flex-direction: column; gap: 0.75rem; } +.gear-slot-form label { display: flex; flex-direction: column; gap: 0.3rem; } +.gear-form-row { display: flex; flex-wrap: wrap; gap: 0.75rem; } +.gear-form-row label { flex: 1 1 140px; } +.gear-fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.8rem 0.8rem; margin: 0; } +.gear-fieldset legend { padding: 0 0.3rem; font-weight: 600; } +.gear-fieldset legend .text-muted { font-weight: 400; font-size: 0.82rem; } +.gear-roll-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 0.5rem; margin-top: 0.45rem; } +.gear-roll-row input:invalid { border-color: var(--danger); } +.gear-clear-form { margin-top: 0.75rem; } +.gear-delete-form { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); } +.gear-detail-list { display: flex; flex-direction: column; gap: 0.4rem; margin: 0; } +.gear-detail-list div { display: flex; gap: 0.5rem; } +.gear-detail-list dt { color: var(--text-muted); min-width: 110px; } +.gear-detail-list dd { margin: 0; } + +.gear-totals-table, .gear-compare, .gear-diff-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; } +.gear-totals .table-scroll table { min-width: 560px; } +.gear-totals-table th, .gear-totals-table td, .gear-compare th, .gear-compare td, .gear-diff-table th, .gear-diff-table td { + padding: 0.35rem 0.5rem; + border-bottom: 1px solid rgba(255, 255, 255, 0.06); + text-align: left; + vertical-align: top; +} +.gear-totals-table thead th, .gear-compare thead th, .gear-diff-table thead th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; } +.gear-totals-table tbody th, .gear-compare tbody th { font-weight: 400; color: var(--text-muted); white-space: nowrap; } +.gear-totals-table td { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; } +.gear-total-col { font-weight: 700; color: var(--text); } +.gear-totals-table td.gear-total-col { color: var(--gold); } +.gear-source-col { color: var(--text-muted); } + +.gear-compare td { font-variant-numeric: tabular-nums; } +.gear-compare thead th a { font-size: 1rem; text-transform: none; letter-spacing: 0; } +.gear-compare-owner { text-transform: none; letter-spacing: 0; font-weight: 400; } +.gear-compare-group th { padding-top: 1rem; color: var(--gold) !important; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; } +.gear-diff { display: inline-block; margin-left: 0.35rem; padding: 0 0.35rem; border-radius: 4px; font-size: 0.78rem; font-weight: 600; } +.gear-diff.is-up { color: #7ddc8a; background: rgba(76, 175, 80, 0.15); } +.gear-diff.is-down { color: #f08a86; background: rgba(217, 83, 79, 0.15); } +.gear-compare-item { display: inline-flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; } + +/* Admin: Katalog */ +.gear-import { margin-top: 1rem; padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: 8px; background: rgba(255, 255, 255, 0.025); } +.gear-import h2 { margin: 0 0 0.3rem; font-size: 1.1rem; } +.gear-import-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.75rem; } +.gear-import-row input[type="text"] { flex: 1 1 320px; width: auto; min-width: 0; } +.gear-import-progress { margin-top: 1rem; } +.gear-progress-bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin-bottom: 0.4rem; } +.gear-progress-bar span { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.3s; } +.gear-import-log { list-style: none; margin: 0.6rem 0 0; padding: 0; max-height: 320px; overflow-y: auto; font-size: 0.88rem; } +.gear-import-log > li { padding: 0.3rem 0.5rem; border-left: 3px solid var(--border); margin-bottom: 0.25rem; background: rgba(255, 255, 255, 0.02); } +.gear-import-log ul { margin: 0.25rem 0 0; padding-left: 1.1rem; color: var(--text-muted); } +.gear-log-new { border-left-color: var(--success) !important; } +.gear-log-changed { border-left-color: var(--gold) !important; } +.gear-log-error { border-left-color: var(--danger) !important; color: #f08a86; } +.gear-log-same, .gear-log-info { color: var(--text-muted); } +.gear-admin-sub { display: block; font-size: 0.78rem; max-width: 420px; } +.gear-admin-actions { display: flex; gap: 0.4rem; align-items: center; justify-content: flex-end; } +.gear-admin-actions form { margin: 0; } +.gear-admin-table td { vertical-align: middle; } +.gear-diff-modal { max-width: 760px; } +.gear-diff-table td.is-new { color: var(--gold); } +.gear-diff-table tbody th { white-space: nowrap; color: var(--text-muted); font-weight: 400; } + /* ---- Daten zuruecksetzen (nur Entwickler) ---- */ .reset-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 1.25rem 0 0.9rem; } .reset-toolbar .text-muted { margin-left: auto; font-size: 0.9rem; } diff --git a/assets/js/file-input.js b/assets/js/file-input.js index cb39517..b703f85 100644 --- a/assets/js/file-input.js +++ b/assets/js/file-input.js @@ -2,6 +2,10 @@ * Schoenere Datei-Auswahl: macht aus jedem sichtbaren eine Flaeche zum * Klicken oder Hineinziehen, mit Vorschaubildern der gewaehlten Bilder. Das echte Eingabefeld * bleibt erhalten (liegt unsichtbar ueber der Flaeche), Formulare funktionieren also wie vorher. + * + * Optional am Feld: + * data-paste kopierte Bilder (Screenshot, "Bild kopieren") lassen sich mit Strg+V einfuegen + * data-max-files=N hoechstens N Bilder (mehr ausgewaehlte/eingefuegte werden abgeschnitten) */ (function () { 'use strict'; @@ -9,6 +13,9 @@ var ICON = ''; + // Felder mit data-paste - ein gemeinsamer Paste-Listener entscheidet, welches das Bild bekommt + var pasteTargets = []; + function formatSize(bytes) { return bytes > 1024 * 1024 ? (bytes / 1024 / 1024).toFixed(1).replace('.', ',') + ' MB' : Math.round(bytes / 1024) + ' KB'; } @@ -23,7 +30,7 @@ zone.innerHTML = '
' + ICON + '' + (multiple ? 'Bilder auswählen' : 'Bild auswählen') + '' + - 'oder hierher ziehen · PNG, JPG, GIF, WEBP' + + 'oder hierher ziehen' + (input.hasAttribute('data-paste') ? ' · Strg+V fügt kopierte Bilder ein' : '') + ' · PNG, JPG, GIF, WEBP' + '
' + ''; input.parentNode.insertBefore(zone, input); @@ -33,6 +40,22 @@ var list = zone.querySelector('.file-drop-files'); var urls = []; + var maxFiles = parseInt(input.dataset.maxFiles, 10) || 0; + var trimmed = 0; + + /** Dateien setzen (bei mehreren ggf. an die schon gewaehlten anhaengen), Obergrenze beachten. */ + function setFiles(files, append) { + if (typeof DataTransfer === 'undefined') return false; + var all = (append && multiple ? Array.prototype.slice.call(input.files || []) : []).concat(files); + if (!multiple) all = all.slice(-1); + trimmed = maxFiles && all.length > maxFiles ? all.length - maxFiles : 0; + if (trimmed) all = all.slice(0, maxFiles); + var dt = new DataTransfer(); + all.forEach(function (file) { dt.items.add(file); }); + input.files = dt.files; + render(); + return true; + } function render() { urls.forEach(URL.revokeObjectURL); @@ -58,6 +81,12 @@ item.appendChild(meta); list.appendChild(item); }); + if (trimmed) { + var note = document.createElement('span'); + note.className = 'file-drop-note'; + note.textContent = 'Höchstens ' + maxFiles + ' Bilder - ' + (trimmed === 1 ? 'eins wurde' : trimmed + ' wurden') + ' weggelassen.'; + list.appendChild(note); + } if (files.length) { var clear = document.createElement('button'); clear.type = 'button'; @@ -66,13 +95,33 @@ clear.addEventListener('click', function (e) { e.preventDefault(); input.value = ''; + trimmed = 0; render(); }); list.appendChild(clear); } } - input.addEventListener('change', render); + input.addEventListener('change', function () { + // Zu viele auf einmal ausgewaehlt: auf die Obergrenze kuerzen + if (maxFiles && input.files && input.files.length > maxFiles) { + setFiles(Array.prototype.slice.call(input.files), false); + } else { + trimmed = 0; + render(); + } + }); + if (input.hasAttribute('data-paste')) { + pasteTargets.push({ + input: input, + zone: zone, + add: function (files) { + if (!setFiles(files, true)) return; + zone.classList.add('is-pasted'); + setTimeout(function () { zone.classList.remove('is-pasted'); }, 700); + } + }); + } ['dragenter', 'dragover'].forEach(function (type) { input.addEventListener(type, function () { zone.classList.add('is-dragging'); }); }); @@ -85,6 +134,37 @@ if (input.files && input.files.length) render(); } + /** Bilder aus der Zwischenablage (Strg+V) als Dateien, mit sprechendem Namen. */ + function clipboardImages(event) { + var items = event.clipboardData ? event.clipboardData.items : null; + var files = []; + var now = new Date(); + var pad = function (n) { return (n < 10 ? '0' : '') + n; }; + var stamp = now.getFullYear() + pad(now.getMonth() + 1) + pad(now.getDate()) + '-' + pad(now.getHours()) + pad(now.getMinutes()) + pad(now.getSeconds()); + Array.prototype.forEach.call(items || [], function (item, i) { + if (item.kind !== 'file' || !/^image\//.test(item.type)) return; + var file = item.getAsFile(); + if (!file) return; + var ext = item.type.split('/')[1].replace('jpeg', 'jpg'); + files.push(new File([file], 'Eingefuegt-' + stamp + (i ? '-' + (i + 1) : '') + '.' + ext, { type: item.type })); + }); + return files; + } + + document.addEventListener('paste', function (event) { + if (!pasteTargets.length) return; + // Nur sichtbare Felder (z.B. nicht im zugeklappten Formular); bevorzugt das im Formular, + // in dem man gerade tippt + var visible = pasteTargets.filter(function (t) { return t.zone.offsetParent !== null; }); + if (!visible.length) return; + var active = document.activeElement; + var target = visible.filter(function (t) { return t.input.form && active && t.input.form.contains(active); })[0] || visible[0]; + var files = clipboardImages(event); + if (!files.length) return; // nur Text - normales Einfuegen + event.preventDefault(); + target.add(files); + }); + function init() { document.querySelectorAll('input[type="file"]').forEach(enhance); } diff --git a/assets/js/gear-admin.js b/assets/js/gear-admin.js new file mode 100644 index 0000000..cd7968c --- /dev/null +++ b/assets/js/gear-admin.js @@ -0,0 +1,218 @@ +/** + * Gear-Planer, Katalog (admin/gear_items.php): Gegenstaende nacheinander von aion2hub + * uebernehmen bzw. abgleichen - immer einer nach dem anderen (der Server wartet zusaetzlich + * mindestens eine Sekunde zwischen zwei Abrufen), mit Fortschritt und Protokoll. + */ +(function () { + 'use strict'; + + var root = document.getElementById('gear-import'); + if (!root) return; + + var endpoint = root.dataset.action; + var csrf = root.dataset.csrf; + var input = document.getElementById('gear-import-input'); + var skipKnown = document.getElementById('gear-import-skip'); + var startButton = document.getElementById('gear-import-start'); + var checkAllButton = document.getElementById('gear-check-all'); + var applyBox = document.getElementById('gear-check-apply'); + var stopButton = document.getElementById('gear-import-stop'); + var progress = document.getElementById('gear-import-progress'); + var fill = document.getElementById('gear-progress-fill'); + var progressText = document.getElementById('gear-progress-text'); + var log = document.getElementById('gear-import-log'); + var running = false; + var stopRequested = false; + + function post(data) { + var body = new FormData(); + body.append('csrf_token', csrf); + Object.keys(data).forEach(function (key) { body.append(key, data[key]); }); + return fetch(endpoint, { method: 'POST', body: body, headers: { 'Accept': 'application/json' }, credentials: 'same-origin' }) + .then(function (response) { + return response.json().catch(function () { + return { ok: false, error: 'Unerwartete Antwort vom Server (' + response.status + ').' }; + }); + }) + .catch(function () { return { ok: false, error: 'Keine Verbindung zum Server.' }; }); + } + + function addLog(text, kind, details) { + var li = document.createElement('li'); + li.className = 'gear-log-' + kind; + li.textContent = text; + if (details && details.length) { + var list = document.createElement('ul'); + details.forEach(function (diff) { + var item = document.createElement('li'); + item.textContent = diff[0] + ': ' + diff[1] + ' → ' + diff[2]; + list.appendChild(item); + }); + li.appendChild(list); + } + log.insertBefore(li, log.firstChild); + } + + function showMessage(text, kind) { + progress.hidden = false; + log.innerHTML = ''; + addLog(text, kind); + } + + function setBusy(busy) { + running = busy; + startButton.disabled = busy; + if (checkAllButton) checkAllButton.disabled = busy; + stopButton.hidden = !busy; + stopRequested = false; + } + + /** IDs nacheinander abarbeiten; kind = 'import' oder 'check'. */ + function run(ids, kind, source) { + var counts = { added: 0, changed: 0, same: 0, failed: 0 }; + var apply = kind === 'import' || (applyBox && applyBox.checked); + var index = 0; + setBusy(true); + progress.hidden = false; + log.innerHTML = ''; + + function next() { + fill.style.width = (ids.length ? Math.round(index / ids.length * 100) : 100) + '%'; + progressText.textContent = index + ' von ' + ids.length + ' · neu ' + counts.added + ' · geändert ' + counts.changed + + ' · unverändert ' + counts.same + (counts.failed ? ' · Fehler ' + counts.failed : ''); + if (index >= ids.length || stopRequested) { + if (stopRequested) addLog('Angehalten.', 'info'); + setBusy(false); + if (ids.length > 1 && index > 0) { + post({ action: 'batch_done', kind: kind, 'new': counts.added, changed: counts.changed, same: counts.same, failed: counts.failed, source: source || '' }); + } + if (counts.added || (apply && counts.changed)) { + addLog('Fertig - Seite neu laden, um die Liste zu aktualisieren.', 'info'); + } + return; + } + var id = ids[index++]; + post({ action: kind, id: id, batch: ids.length > 1 ? 1 : '', apply: apply ? 1 : '' }).then(function (result) { + if (!result.ok) { + counts.failed++; + addLog('#' + id + ': ' + result.error, 'error'); + } else if (result['new']) { + counts.added++; + addLog(result.name + ' übernommen', 'new'); + } else if (result.diffs.length) { + counts.changed++; + addLog(result.name + (result.applied ? ' aktualisiert' : ' hat Änderungen (nicht übernommen)'), 'changed', result.diffs); + } else { + counts.same++; + if (ids.length === 1) addLog(result.name + ' ist aktuell - keine Änderungen.', 'same'); + } + next(); + }); + } + next(); + } + + startButton.addEventListener('click', function () { + var value = input.value.trim(); + if (!value || running) return; + startButton.disabled = true; + post({ action: 'list', url: value }).then(function (result) { + startButton.disabled = false; + if (!result.ok) { + showMessage(result.error, 'error'); + return; + } + var known = result.known || []; + var ids = skipKnown.checked ? result.ids.filter(function (id) { return known.indexOf(id) === -1; }) : result.ids; + if (!ids.length) { + showMessage(result.ids.length === 1 ? 'Dieser Gegenstand ist schon im Katalog - „Abgleichen“ in der Liste prüft ihn.' : 'Alle ' + result.ids.length + ' Gegenstände sind schon im Katalog.', 'same'); + return; + } + run(ids, 'import', value); + }); + }); + input.addEventListener('keydown', function (event) { + if (event.key === 'Enter') { + event.preventDefault(); + startButton.click(); + } + }); + + if (checkAllButton) { + checkAllButton.addEventListener('click', function () { + var ids = JSON.parse(root.dataset.allIds || '[]'); + if (!ids.length || running) return; + var minutes = Math.ceil(ids.length * 1.3 / 60); + if (ids.length > 30 && !window.confirm(ids.length + ' Gegenstände abgleichen? Das dauert etwa ' + minutes + ' Minuten - die Seite muss so lange offen bleiben.')) return; + run(ids, 'check', 'alle'); + }); + } + stopButton.addEventListener('click', function () { stopRequested = true; }); + + // ---- Einzelnen Gegenstand abgleichen: Unterschiede im Dialog, dann uebernehmen ---- + var modal = document.getElementById('gear-diff-modal'); + var title = document.getElementById('gear-diff-title'); + var body = document.getElementById('gear-diff-body'); + var applyButton = document.getElementById('gear-diff-apply'); + var currentId = null; + + function paragraph(text, className) { + var p = document.createElement('p'); + if (className) p.className = className; + p.textContent = text; + body.appendChild(p); + } + + function openDiff(id) { + currentId = id; + title.textContent = 'Abgleich #' + id; + body.innerHTML = ''; + paragraph('Werte werden von aion2hub geladen …', 'text-muted'); + applyButton.hidden = true; + modal.hidden = false; + post({ action: 'check', id: id }).then(function (result) { + body.innerHTML = ''; + if (!result.ok) { + paragraph(result.error, 'gear-log-error'); + return; + } + title.textContent = result.name; + if (!result.diffs.length) { + paragraph('Alles aktuell - die Werte stimmen mit aion2hub überein (als geprüft vermerkt).'); + return; + } + var table = document.createElement('table'); + table.className = 'gear-diff-table'; + table.innerHTML = 'FeldGespeichertaion2hub jetzt'; + var tbody = document.createElement('tbody'); + result.diffs.forEach(function (diff) { + var tr = document.createElement('tr'); + diff.forEach(function (cell, i) { + var td = document.createElement(i === 0 ? 'th' : 'td'); + td.textContent = cell; + if (i === 2) td.className = 'is-new'; + tr.appendChild(td); + }); + tbody.appendChild(tr); + }); + table.appendChild(tbody); + body.appendChild(table); + applyButton.hidden = false; + }); + } + + document.querySelectorAll('[data-gear-check]').forEach(function (button) { + button.addEventListener('click', function () { openDiff(button.dataset.gearCheck); }); + }); + applyButton.addEventListener('click', function () { + applyButton.disabled = true; + post({ action: 'import', id: currentId }).then(function (result) { + applyButton.disabled = false; + if (result.ok) window.location.reload(); + else paragraph(result.error, 'gear-log-error'); + }); + }); + modal.querySelector('.modal-close').addEventListener('click', function () { modal.hidden = true; }); + modal.addEventListener('click', function (event) { if (event.target === modal) modal.hidden = true; }); + document.addEventListener('keydown', function (event) { if (event.key === 'Escape') modal.hidden = true; }); +})(); diff --git a/assets/js/gear.js b/assets/js/gear.js new file mode 100644 index 0000000..ad89240 --- /dev/null +++ b/assets/js/gear.js @@ -0,0 +1,72 @@ +/** + * Gear-Planer (gear.php): Dialog "Set bearbeiten", Auswahl zum Vergleichen (2-4 Sets) und + * Hinweise zur Spanne der Seelenpraegung (Platzhalter + Pruefung beim Tippen). + */ +(function () { + 'use strict'; + + // ---- Dialoge ---- + document.querySelectorAll('[data-modal-open]').forEach(function (button) { + button.addEventListener('click', function () { + var modal = document.getElementById(button.dataset.modalOpen); + if (!modal) return; + modal.hidden = false; + var first = modal.querySelector('input[type="text"]'); + if (first) first.focus(); + }); + }); + document.querySelectorAll('.modal-overlay').forEach(function (modal) { + var close = modal.querySelector('.modal-close'); + if (close) close.addEventListener('click', function () { modal.hidden = true; }); + modal.addEventListener('click', function (event) { + if (event.target === modal) modal.hidden = true; + }); + }); + document.addEventListener('keydown', function (event) { + if (event.key !== 'Escape') return; + document.querySelectorAll('.modal-overlay:not([hidden])').forEach(function (modal) { modal.hidden = true; }); + }); + + // ---- Vergleichen: 2 bis 4 Sets ---- + var compareForm = document.getElementById('gear-compare-form'); + var compareButton = document.getElementById('gear-compare-button'); + if (compareForm && compareButton) { + var boxes = compareForm.querySelectorAll('input[name="compare[]"]'); + var update = function () { + var checked = Array.prototype.filter.call(boxes, function (box) { return box.checked; }).length; + compareButton.disabled = checked < 2 || checked > 4; + compareButton.textContent = checked > 4 ? 'Höchstens 4 Sets' : 'Ausgewählte vergleichen' + (checked >= 2 ? ' (' + checked + ')' : ''); + boxes.forEach(function (box) { box.closest('.gear-set-card').classList.toggle('is-checked', box.checked); }); + }; + boxes.forEach(function (box) { box.addEventListener('change', update); }); + update(); + } + + // ---- Seelenpraegung: Spanne als Platzhalter, Wert ausserhalb markieren ---- + function toNumber(value) { + return parseFloat(String(value).replace(/\./g, '').replace(',', '.')); + } + document.querySelectorAll('[data-range-select]').forEach(function (select) { + var input = select.parentNode.querySelector('input'); + if (!input) return; + function sync() { + var option = select.options[select.selectedIndex]; + var min = option && option.dataset.min; + var max = option && option.dataset.max; + var unit = option && option.dataset.unit ? ' %' : ''; + input.placeholder = min ? String(min).replace('.', ',') + '–' + String(max).replace('.', ',') + unit : 'Wert'; + input.required = !!min; + check(); + } + function check() { + var option = select.options[select.selectedIndex]; + var value = toNumber(input.value); + var bad = option && option.dataset.min && input.value.trim() !== '' + && (isNaN(value) || value < parseFloat(option.dataset.min) || value > parseFloat(option.dataset.max)); + input.setCustomValidity(bad ? 'Der Wert muss zwischen ' + input.placeholder + ' liegen.' : ''); + } + select.addEventListener('change', sync); + input.addEventListener('input', check); + sync(); + }); +})(); diff --git a/assets/uploads/bugs/.gitkeep b/assets/uploads/bugs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/assets/uploads/bugs/.htaccess b/assets/uploads/bugs/.htaccess new file mode 100644 index 0000000..869073b --- /dev/null +++ b/assets/uploads/bugs/.htaccess @@ -0,0 +1,11 @@ +# Bilder zu Fehlermeldungen koennen Privates zeigen - nie direkt ausliefern, nur ueber +# /bug_image.php (prueft, ob man die Meldung sehen darf). + + Require all denied + + + Deny from all + + + php_flag engine off + diff --git a/assets/uploads/gear/.gitkeep b/assets/uploads/gear/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/assets/uploads/gear/.htaccess b/assets/uploads/gear/.htaccess new file mode 100644 index 0000000..e64fd2f --- /dev/null +++ b/assets/uploads/gear/.htaccess @@ -0,0 +1,17 @@ +# Icons der Gear-Planer-Gegenstaende (von aion2hub geladen) duerfen niemals als Skript +# ausgefuehrt werden - auch wenn eine Datei die Typpruefung in includes/gear.php umgehen sollte. + + php_flag engine off + + + php_flag engine off + + + + + Require all denied + + + Deny from all + + diff --git a/bug_action.php b/bug_action.php index 0786108..c4dd6a4 100644 --- a/bug_action.php +++ b/bug_action.php @@ -22,6 +22,7 @@ if ($action === 'create') { $area = (string) ($_POST['area'] ?? ''); $description = trim((string) ($_POST['description'] ?? '')); $screenshot = trim((string) ($_POST['screenshot_url'] ?? '')); + $images = bug_uploaded_files(); $error = null; if ($title === '' || mb_strlen($title) > 150) { @@ -34,6 +35,10 @@ if ($action === 'create') { $error = 'Die Beschreibung ist zu lang (höchstens 5000 Zeichen).'; } elseif ($screenshot !== '' && (!preg_match('#^https?://#i', $screenshot) || mb_strlen($screenshot) > 500)) { $error = 'Der Screenshot-Link muss mit http:// oder https:// beginnen.'; + } elseif (count($images) > BUG_MAX_IMAGES) { + $error = 'Bitte höchstens ' . BUG_MAX_IMAGES . ' Bilder anhängen.'; + } elseif ($images && !security_throttle('upload', count($images))) { + $error = 'Du hast in den letzten Minuten schon sehr viele Bilder hochgeladen. Bitte warte ein paar Minuten.'; } else { $recent = $pdo->prepare('SELECT COUNT(*) FROM bug_reports WHERE user_id = ? AND created_at > NOW() - INTERVAL 1 HOUR'); $recent->execute([(int) $user['id']]); @@ -43,7 +48,8 @@ if ($action === 'create') { } if ($error !== null) { - set_flash('error', $error); + // Dateien kann der Browser nicht wieder vorbelegen - darauf hinweisen + set_flash('error', $error . ($images ? ' Bitte hänge die Bilder danach noch einmal an.' : '')); // Eingaben fuer das erneute Anzeigen merken, damit nichts verloren geht. $_SESSION['bug_form'] = compact('title', 'area', 'description', 'screenshot'); redirect('/dashboard.php#fehler-melden'); @@ -59,8 +65,24 @@ if ($action === 'create') { $screenshot !== '' ? $screenshot : null, mb_substr((string) ($_SERVER['HTTP_USER_AGENT'] ?? ''), 0, 255) ?: null, ]); + $bugId = (int) $pdo->lastInsertId(); + + // Angehaengte Bilder: die Meldung ist schon gespeichert, ein kaputtes Bild haelt sie nicht auf + $imageErrors = []; + $insertImage = $pdo->prepare('INSERT INTO bug_report_images (bug_id, filename) VALUES (?, ?)'); + foreach ($images as $file) { + try { + $insertImage->execute([$bugId, bug_store_upload($file, (int) $user['id'])]); + } catch (RuntimeException $e) { + $imageErrors[] = $e->getMessage(); + } + } + unset($_SESSION['bug_form']); set_flash('success', 'Danke! Deine Fehlermeldung ist bei der Leitung angekommen.'); + foreach (array_unique($imageErrors) as $imageError) { + set_flash('error', $imageError . ' Die Meldung selbst ist trotzdem angekommen.'); + } redirect('/dashboard.php#meine-meldungen'); } @@ -94,6 +116,7 @@ if ($action === 'update') { $titleStmt = $pdo->prepare('SELECT title FROM bug_reports WHERE id = ?'); $titleStmt->execute([$id]); $bugTitle = $titleStmt->fetchColumn(); + bug_delete_image_files($id); $pdo->prepare('DELETE FROM bug_reports WHERE id = ?')->execute([$id]); if ($bugTitle !== false) { admin_log('🗑️ Fehlermeldung gelöscht', ['Meldung' => '#' . $id . ': ' . $bugTitle], 'danger'); diff --git a/bug_image.php b/bug_image.php new file mode 100644 index 0000000..8f6e944 --- /dev/null +++ b/bug_image.php @@ -0,0 +1,32 @@ +prepare( + 'SELECT i.filename, b.user_id FROM bug_report_images i JOIN bug_reports b ON b.id = i.bug_id WHERE i.id = ?' +); +$stmt->execute([(int) ($_GET['id'] ?? 0)]); +$image = $stmt->fetch(); +$me = current_user(); +if (!$image || ((int) $image['user_id'] !== (int) $me['id'] && !user_has_permission('bugs.manage'))) { + show_not_found(); +} + +$path = BUG_UPLOAD_DIR . $image['filename']; +$types = ['png' => 'image/png', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'webp' => 'image/webp']; +$type = $types[strtolower(pathinfo((string) $image['filename'], PATHINFO_EXTENSION))] ?? null; +if (strpos((string) $image['filename'], '/') !== false || $type === null || !is_file($path)) { + show_not_found(); +} + +session_write_close(); +header('Content-Type: ' . $type); +header('Content-Length: ' . filesize($path)); +header('Cache-Control: private, max-age=86400'); +header('X-Content-Type-Options: nosniff'); +readfile($path); diff --git a/bugs.php b/bugs.php index 2060b47..88b8222 100644 --- a/bugs.php +++ b/bugs.php @@ -36,6 +36,7 @@ $bugs = db()->query( WHERE {$filters[$filter][1]} ORDER BY FIELD(b.status, 'open', 'in_progress', 'done', 'rejected'), b.created_at DESC" )->fetchAll(); +$bugImages = bug_images_for(array_column($bugs, 'id')); $pageTitle = 'Fehlermeldungen'; include __DIR__ . '/includes/header.php'; @@ -93,6 +94,7 @@ include __DIR__ . '/includes/header.php';
+
@@ -145,4 +147,5 @@ include __DIR__ . '/includes/header.php';
+ diff --git a/dashboard.php b/dashboard.php index 9dff9f0..e2c2dba 100644 --- a/dashboard.php +++ b/dashboard.php @@ -14,9 +14,11 @@ $canViewContributions = user_has_permission('contributions.view'); $canViewShop = user_has_permission('shop.view'); $discordId = $user['discord_id'] ? (int) $user['discord_id'] : null; +// Reihenfolge wie in der Mitgliederliste (roles.roster_order, Gruppen ohne Rang zuletzt) $roleStmt = db()->prepare( "SELECT COALESCE(NULLIF(r.display_name, ''), r.name) AS name - FROM roles r JOIN user_roles ur ON ur.role_id = r.id WHERE ur.user_id = ? ORDER BY r.name" + FROM roles r JOIN user_roles ur ON ur.role_id = r.id WHERE ur.user_id = ? + ORDER BY COALESCE(r.roster_order, 999), r.name" ); $roleStmt->execute([$user['id']]); $roleNames = array_column($roleStmt->fetchAll(), 'name'); @@ -113,6 +115,7 @@ if ($canViewPremades && $discordId) { // Eigene Fehlermeldungen (die neuesten zuerst) und ggf. Eingaben nach einem Fehler. $myBugs = []; +$myBugImages = []; try { $bugStmt = db()->prepare( 'SELECT id, title, area, status, admin_note, created_at, updated_at FROM bug_reports @@ -120,6 +123,7 @@ try { ); $bugStmt->execute([(int) $user['id']]); $myBugs = $bugStmt->fetchAll(); + $myBugImages = bug_images_for(array_column($myBugs, 'id')); } catch (PDOException $e) { $myBugs = []; } @@ -168,9 +172,9 @@ include __DIR__ . '/includes/header.php';
@@ -180,13 +184,14 @@ include __DIR__ . '/includes/header.php';
- + +
@@ -245,10 +250,15 @@ include __DIR__ . '/includes/header.php'; } } $mySignup = $raid['_my_signup'] ?? null; + $raidTime = (int) ($raid['timestamp'] ?? 0); + // Kalender: Monat des Raids, direkt zum Tag gesprungen + $calendarUrl = $raidTime > 0 ? '/calendar.php?month=' . date('Y-m', $raidTime) . '#tag-' . date('Y-m-d', $raidTime) : '/calendar.php'; ?> - - + + + + / @@ -333,7 +343,7 @@ include __DIR__ . '/includes/header.php'; Fehler melden -
+
@@ -360,7 +370,13 @@ include __DIR__ . '/includes/header.php';
Je genauer, desto schneller finden wir den Fehler. Browser und Gerät werden automatisch mitgeschickt.
- + + +
Bis zu Screenshots, je höchstens 8 MB. Kopierte Bilder einfach mit Strg+V einfügen. Nur du und die Leitung sehen die Bilder.
+
+
+ @@ -383,6 +399,7 @@ include __DIR__ . '/includes/header.php';
· gemeldet am
+
Antwort der Leitung:
@@ -438,4 +455,5 @@ if (empty($user['tour_completed_at'])): + diff --git a/gear.php b/gear.php new file mode 100644 index 0000000..c13e8e2 --- /dev/null +++ b/gear.php @@ -0,0 +1,523 @@ +query('SELECT COUNT(*) FROM gear_items')->fetchColumn(); + +$mySets = gear_sets_for_user($userId); +$mySlots = gear_slots_for_sets(array_column($mySets, 'id')); + +// ---- Welche Ansicht? ---- +$set = null; +$compare = []; +if (isset($_GET['compare'])) { + foreach (array_slice(array_unique(array_map('intval', (array) $_GET['compare'])), 0, 4) as $compareId) { + $candidate = gear_set($compareId); + if ($candidate && gear_can_view_set($candidate)) { + $compare[] = $candidate; + } + } + if (count($compare) < 2) { + set_flash('error', 'Zum Vergleichen bitte mindestens zwei Sets auswählen.'); + redirect('/gear.php'); + } +} elseif (isset($_GET['set'])) { + $set = gear_set((int) $_GET['set']); + if (!$set || !gear_can_view_set($set)) { + show_not_found(); + } +} + +$isOwn = $set && gear_is_own_set($set); +$slots = $set ? (gear_slots_for_sets([(int) $set['id']])[(int) $set['id']] ?? []) : []; +$activeSlot = $set && isset(GEAR_SLOTS[$_GET['slot'] ?? '']) ? (string) $_GET['slot'] : ''; +$activeRow = $activeSlot !== '' ? ($slots[$activeSlot] ?? null) : null; +$activeItem = $activeRow['item'] ?? null; + +/** Kurzinfo eines belegten Slots: "+15 · Durchbruch 5 · 3/4 Manasteine" */ +$slotTags = static function (?array $row): array { + if (!$row || empty($row['item'])) { + return []; + } + $item = $row['item']; + $tags = []; + if ((int) $item['enchant_max'] > 0) { + $tags[] = '+' . (int) $row['enchant']; + } + if ((int) $row['exceed'] > 0) { + $tags[] = '⬆' . (int) $row['exceed']; + } + if ((int) $item['manastone_slots'] > 0) { + $tags[] = '◆ ' . count($row['manastones']) . '/' . (int) $item['manastone_slots']; + } + return $tags; +}; + +/** Symbol eines Gegenstands (oder Platzhalter) */ +$itemIcon = static function (?array $item, int $size = 40): string { + $url = gear_icon_url($item); + if ($url === null) { + return ''; + } + return ''; +}; + +$pageTitle = $set ? $set['name'] . ' - Gear-Planer' : 'Gear-Planer'; +$containerWide = true; +include __DIR__ . '/includes/header.php'; +?> +
+
+

Gear-Planer

+

+ Stell Ausrüstungssets zusammen und vergleiche sie. Grundwerte, Sockel und die Werte bei + voller Aufwertung stammen aus dem Spielclient (Global) und werden von der Leitung abgeglichen; + Werte mit ≈ sind für Zwischenstufen hochgerechnet. +

+
+ +
+ + +
+

Noch keine Gegenstände im Katalog.

+

+ +

+ Gegenstände übernehmen +
+ + + + $row) { + $allKeys[$key] = $row; + } + } + uksort($allKeys, static function (string $a, string $b) use ($allKeys): int { + $ia = array_search($allKeys[$a]['name'], GEAR_STAT_ORDER, true); + $ib = array_search($allKeys[$b]['name'], GEAR_STAT_ORDER, true); + return [$ia === false ? 99 : $ia, $allKeys[$a]['unit'], $a] <=> [$ib === false ? 99 : $ib, $allKeys[$b]['unit'], $b]; + }); + $first = (int) $compare[0]['id']; + ?> +
+

Vergleich

+

Unterschiede beziehen sich immer auf das erste Set (links).

+
+ + + + + + + + + + + + $meta): ?> + + + + $c): ?> + + + + + + + [$slotLabel]): ?> + + + + + + + + + +
+ + +
+
Werte
+ ≈' : '') . e(gear_format_value($value, $meta['unit'])) : '–' ?> + 0 && abs($diff) > 0.001): ?> + 0 ? '+' : '−' ?> + +
Ausrüstung
+ + + + + + + + – + +
+
+
+ + + +
+
+

+
+ Set von · + !empty($row['item']))) ?>/ Slots belegt + · Ø Gegenstandsstufe + · auf dem Profil sichtbar +
+

+
+
+ + + + + + + + + + (int) $s['id'] !== (int) $set['id'])); ?> + +
+ + +
+ +
+
+ +
+
+ +

+
+ [$slotLabel, $slotGroup]): ?> + + + + + + + + + + + +
+ +
+ + +
+
+

+ +
+ +
+ +
+ · Stufe + + · aion2hub +
+
+
+
+ + + + +
+ + + + +
+ +
+ + +
+ +
+ + +
+ 0): ?> + + + 0): ?> + + +
+ +

+ Bei +: +
Durchbruch : +

+ + + 0): ?> +
+ Seelenprägung (bis zu , wie im Spiel gewürfelt) + + +
+ + +
+ +
+ + + 0): ?> + +
+ Manasteine ( Sockel) + + +
+ + +
+ +
+ + + 0): ?> + + +

Wechselst du den Gegenstand, werden Seelenprägung und Manasteine zurückgesetzt.

+ + +
+ + Schließen +
+
+ +
+ + + + + +
+ + +
+ 0): ?>
Aufwertung
+ von +
+ 0): ?>
Durchbruch
von
+ +
Seelenprägung
$s[0] . ' ' . str_replace('.', ',', (string) $s[1]), $activeRow['soul_imprint']))) ?>
+ + +
Manasteine
$s[0] . ' ' . (int) $s[1], $activeRow['manastones']))) ?>
+ +
Götterstein
+
+ +

Dieser Slot ist leer.

+ +
+
+ +
+ +
+

Werte gesamt

+ +

Noch keine Gegenstände eingesetzt.

+ + (bool) array_filter($totals, static fn (array $t): bool => isset($t['by'][$source])), ARRAY_FILTER_USE_BOTH)); ?> +
+ + + + + + + + + + + + + + + + + + + +
WertGesamt
+ ≈ + + –' ?>
+
+

Einfache Summe aller Gegenstände - Klassen- und Charakterwerte, Set-Boni und Götterstein sind nicht enthalten.

+ +
+ + + + + + + +
+
+

Meine Sets

+
+ + + + + +
+
+ + +

Du hast noch kein Set. Leg oben eins an - z.B. deine aktuelle Ausrüstung und ein Ziel-Set zum Vergleichen.

+ +
+ + 1): ?> +
+ + 2–4 Sets anhaken +
+ +
+ +
+ + + + + diff --git a/gear_action.php b/gear_action.php new file mode 100644 index 0000000..bdae28a --- /dev/null +++ b/gear_action.php @@ -0,0 +1,212 @@ + mb_substr(trim(preg_replace('/\s+/u', ' ', $value) ?? ''), 0, 80); +$cleanClass = static fn (string $value): ?string => in_array($value, AION_CLASSES, true) ? $value : null; +$touch = static function (int $setId) use ($pdo): void { + $pdo->prepare('UPDATE gear_sets SET updated_at = NOW() WHERE id = ?')->execute([$setId]); +}; + +switch ($action) { + case 'create': + $name = $cleanName((string) ($_POST['name'] ?? '')); + if ($name === '') { + set_flash('error', 'Bitte gib dem Set einen Namen.'); + redirect('/gear.php'); + } + $count = $pdo->prepare('SELECT COUNT(*) FROM gear_sets WHERE user_id = ?'); + $count->execute([$userId]); + if ((int) $count->fetchColumn() >= GEAR_MAX_SETS) { + set_flash('error', 'Du hast schon ' . GEAR_MAX_SETS . ' Sets - lösche erst ein altes.'); + redirect('/gear.php'); + } + $pdo->prepare( + 'INSERT INTO gear_sets (user_id, name, class_name, sort_order, updated_at) + SELECT ?, ?, ?, COALESCE(MAX(sort_order), 0) + 10, NOW() FROM gear_sets WHERE user_id = ?' + )->execute([$userId, $name, $cleanClass((string) ($_POST['class_name'] ?? '')) ?? ($me['class_name'] ?: null), $userId]); + redirect('/gear.php?set=' . (int) $pdo->lastInsertId()); + + case 'update': + $set = $ownSet(); + $name = $cleanName((string) ($_POST['name'] ?? '')); + if ($name === '') { + set_flash('error', 'Der Name darf nicht leer sein.'); + redirect('/gear.php?set=' . (int) $set['id']); + } + $note = mb_substr(trim((string) ($_POST['note'] ?? '')), 0, 255); + $pdo->prepare('UPDATE gear_sets SET name = ?, class_name = ?, note = ?, show_on_profile = ?, updated_at = NOW() WHERE id = ?') + ->execute([$name, $cleanClass((string) ($_POST['class_name'] ?? '')), $note !== '' ? $note : null, isset($_POST['show_on_profile']) ? 1 : 0, $set['id']]); + set_flash('success', 'Set gespeichert.'); + redirect('/gear.php?set=' . (int) $set['id']); + + case 'duplicate': + $set = $ownSet(); + $count = $pdo->prepare('SELECT COUNT(*) FROM gear_sets WHERE user_id = ?'); + $count->execute([$userId]); + if ((int) $count->fetchColumn() >= GEAR_MAX_SETS) { + set_flash('error', 'Du hast schon ' . GEAR_MAX_SETS . ' Sets - lösche erst ein altes.'); + redirect('/gear.php?set=' . (int) $set['id']); + } + $pdo->beginTransaction(); + $pdo->prepare( + 'INSERT INTO gear_sets (user_id, name, class_name, note, show_on_profile, sort_order, updated_at) + SELECT user_id, ?, class_name, note, 0, sort_order + 1, NOW() FROM gear_sets WHERE id = ?' + )->execute([mb_substr($set['name'] . ' (Kopie)', 0, 80), $set['id']]); + $newId = (int) $pdo->lastInsertId(); + $pdo->prepare( + 'INSERT INTO gear_set_slots (set_id, slot, item_id, enchant, exceed, soul_imprint, manastones, godstone) + SELECT ?, slot, item_id, enchant, exceed, soul_imprint, manastones, godstone FROM gear_set_slots WHERE set_id = ?' + )->execute([$newId, $set['id']]); + $pdo->commit(); + set_flash('success', 'Set kopiert - jetzt kannst du Varianten ausprobieren.'); + redirect('/gear.php?set=' . $newId); + + case 'delete': + $set = $ownSet(); + $pdo->prepare('DELETE FROM gear_sets WHERE id = ?')->execute([$set['id']]); + set_flash('success', 'Set „' . $set['name'] . '“ gelöscht.'); + redirect('/gear.php'); + + case 'clear_slot': + $set = $ownSet(); + $slot = (string) ($_POST['slot'] ?? ''); + $pdo->prepare('DELETE FROM gear_set_slots WHERE set_id = ? AND slot = ?')->execute([$set['id'], $slot]); + $touch((int) $set['id']); + redirect('/gear.php?set=' . (int) $set['id']); + + case 'save_slot': + $set = $ownSet(); + $slot = (string) ($_POST['slot'] ?? ''); + $back = '/gear.php?set=' . (int) $set['id'] . '&slot=' . rawurlencode($slot); + if (!isset(GEAR_SLOTS[$slot])) { + set_flash('error', 'Unbekannter Slot.'); + redirect('/gear.php?set=' . (int) $set['id']); + } + $item = gear_item((int) ($_POST['item_id'] ?? 0)); + if (!$item) { + set_flash('error', 'Bitte einen Gegenstand aus der Liste wählen.'); + redirect($back); + } + if (!gear_item_fits_slot($item, $slot)) { + set_flash('error', '„' . $item['name'] . '“ passt nicht in den Slot ' . GEAR_SLOTS[$slot][0] . '.'); + redirect($back); + } + + // Bei einem anderen Gegenstand passen Seelenpraegung und Manasteine nicht mehr - neu anfangen + $current = $pdo->prepare('SELECT item_id FROM gear_set_slots WHERE set_id = ? AND slot = ?'); + $current->execute([$set['id'], $slot]); + $sameItem = (int) $current->fetchColumn() === (int) $item['id']; + + $enchant = max(0, min((int) $item['enchant_max'], (int) ($_POST['enchant'] ?? 0))); + $exceed = max(0, min((int) $item['exceed_max'], (int) ($_POST['exceed'] ?? 0))); + + $errors = []; + $soul = []; + if ($sameItem) { + $ranges = []; + foreach ($item['soul_imprint'] as $entry) { + $ranges[$entry[0]] = $entry; + } + $stats = (array) ($_POST['soul_stat'] ?? []); + $values = (array) ($_POST['soul_value'] ?? []); + foreach ($stats as $i => $stat) { + $stat = (string) $stat; + $raw = str_replace(',', '.', trim((string) ($values[$i] ?? ''))); + if ($stat === '' || $raw === '') { + continue; + } + if (!isset($ranges[$stat])) { + $errors[] = 'Seelenprägung „' . $stat . '“ gibt es bei diesem Gegenstand nicht.'; + continue; + } + if (isset(array_column($soul, 1, 0)[$stat])) { + $errors[] = 'Seelenprägung „' . $stat . '“ ist doppelt eingetragen.'; + continue; + } + $value = (float) $raw; + [, $min, $max, $unit] = $ranges[$stat]; + if (!is_numeric($raw) || $value < $min || $value > $max) { + $errors[] = $stat . ': ' . gear_format_value($value, $unit) . ' liegt nicht in der möglichen Spanne ' + . gear_format_value((float) $min, $unit) . '–' . gear_format_value((float) $max, $unit) . '.'; + continue; + } + $soul[] = [$stat, $value]; + } + if (count($soul) > (int) $item['soul_imprint_count']) { + $errors[] = 'Höchstens ' . (int) $item['soul_imprint_count'] . ' Seelenprägungen.'; + $soul = array_slice($soul, 0, (int) $item['soul_imprint_count']); + } + } + + $manastones = []; + if ($sameItem) { + $allowed = array_flip(gear_manastone_stats()); + $stats = (array) ($_POST['mana_stat'] ?? []); + $values = (array) ($_POST['mana_value'] ?? []); + foreach ($stats as $i => $stat) { + $stat = (string) $stat; + $raw = trim((string) ($values[$i] ?? '')); + if ($stat === '' || $raw === '') { + continue; + } + if (!isset($allowed[$stat]) || !ctype_digit($raw) || (int) $raw < 1 || (int) $raw > 9999) { + $errors[] = 'Manastein ' . ($i + 1) . ': bitte einen Wert aus der Liste und eine ganze Zahl eintragen.'; + continue; + } + $manastones[] = [$stat, (int) $raw]; + } + $manastones = array_slice($manastones, 0, (int) $item['manastone_slots']); + } + $godstone = (int) $item['godstone_slots'] > 0 ? mb_substr(trim((string) ($_POST['godstone'] ?? '')), 0, 100) : ''; + + $pdo->prepare( + 'INSERT INTO gear_set_slots (set_id, slot, item_id, enchant, exceed, soul_imprint, manastones, godstone) + VALUES (?, ?, ?, ?, ?, ?, ?, ?) + ON DUPLICATE KEY UPDATE item_id = VALUES(item_id), enchant = VALUES(enchant), exceed = VALUES(exceed), + soul_imprint = VALUES(soul_imprint), manastones = VALUES(manastones), godstone = VALUES(godstone)' + )->execute([ + $set['id'], $slot, $item['id'], $enchant, $exceed, + json_encode($soul, JSON_UNESCAPED_UNICODE), json_encode($manastones, JSON_UNESCAPED_UNICODE), $godstone !== '' ? $godstone : null, + ]); + $touch((int) $set['id']); + + if ($errors) { + set_flash('error', 'Gespeichert, aber nicht alles übernommen: ' . implode(' ', $errors)); + redirect($back); + } + if (!$sameItem && ((int) $item['soul_imprint_count'] > 0 || (int) $item['manastone_slots'] > 0)) { + set_flash('success', '„' . $item['name'] . '“ eingesetzt - trag jetzt Seelenprägung und Manasteine ein.'); + redirect($back); + } + set_flash('success', GEAR_SLOTS[$slot][0] . ' gespeichert.'); + redirect('/gear.php?set=' . (int) $set['id']); +} + +set_flash('error', 'Unbekannte Aktion.'); +redirect('/gear.php'); diff --git a/includes/bugs.php b/includes/bugs.php index b2832bc..b6f8333 100644 --- a/includes/bugs.php +++ b/includes/bugs.php @@ -59,3 +59,126 @@ function bug_open_count(): int return 0; } } + +// ---- Bilder an Fehlermeldungen ---- +// Liegen NICHT oeffentlich abrufbar im Webroot-Ordner (eigene .htaccess sperrt ihn), sondern +// werden ueber /bug_image.php nur an den Melder und die Leitung ausgeliefert - Screenshots +// koennen Privates zeigen (Nachrichten, Namen, ...). + +const BUG_UPLOAD_DIR = __DIR__ . '/../assets/uploads/bugs/'; +const BUG_MAX_IMAGES = 5; +const BUG_MAX_UPLOAD = 8 * 1024 * 1024; + +/** + * Hochgeladenes Bild pruefen, neu speichern (entfernt EXIF/angehaengten Code, verkleinert auf + * hoechstens 1920 px) und den Dateinamen zurueckgeben. + * + * @param array $file Eintrag aus $_FILES + * @throws RuntimeException mit verstaendlicher Meldung + */ +function bug_store_upload(array $file, int $userId): 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'] > BUG_MAX_UPLOAD) { + throw new RuntimeException('Ein Bild ist zu groß (höchstens 8 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(BUG_UPLOAD_DIR)) { + @mkdir(BUG_UPLOAD_DIR, 0755, true); + } + $name = 'bug' . $userId . '_' . bin2hex(random_bytes(8)) . '.' . $types[$info[2]]; + $error = store_uploaded_image((string) $file['tmp_name'], BUG_UPLOAD_DIR . $name, $info[2], 1920); + if ($error !== null) { + throw new RuntimeException($error); + } + return $name; +} + +/** Die Eintraege aus $_FILES['images'] als Liste einzelner Dateien (leere Felder weggelassen). */ +function bug_uploaded_files(): array +{ + $files = []; + foreach ((array) ($_FILES['images']['name'] ?? []) as $i => $name) { + $error = (int) ($_FILES['images']['error'][$i] ?? UPLOAD_ERR_NO_FILE); + if ($error === UPLOAD_ERR_NO_FILE) { + continue; + } + $files[] = [ + 'name' => (string) $name, + 'error' => $error, + 'size' => (int) ($_FILES['images']['size'][$i] ?? 0), + 'tmp_name' => (string) ($_FILES['images']['tmp_name'][$i] ?? ''), + ]; + } + return $files; +} + +/** @return array> Bilder je Meldung */ +function bug_images_for(array $bugIds): array +{ + $bugIds = array_values(array_unique(array_map('intval', $bugIds))); + if (!$bugIds) { + return []; + } + try { + $stmt = db()->prepare( + 'SELECT id, bug_id, filename FROM bug_report_images WHERE bug_id IN (' . implode(',', array_fill(0, count($bugIds), '?')) . ') ORDER BY id' + ); + $stmt->execute($bugIds); + } catch (PDOException $e) { + return []; + } + $images = []; + foreach ($stmt->fetchAll() as $row) { + $images[(int) $row['bug_id']][] = $row; + } + return $images; +} + +function bug_image_url(int $imageId): string +{ + return '/bug_image.php?id=' . $imageId; +} + +/** Vorschaubilder einer Meldung (Klick oeffnet die Grossansicht, siehe assets/js/lightbox.js). */ +function bug_images_html(array $images, int $bugId): string +{ + if (!$images) { + return ''; + } + $html = '
'; + foreach ($images as $i => $image) { + $url = e(bug_image_url((int) $image['id'])); + $html .= '' + . 'Bild ' . ($i + 1) . ' zur Fehlermeldung'; + } + return $html . '
'; +} + +/** Dateien der Bilder einer (oder aller) Meldungen loeschen - die Zeilen fallen per Fremdschluessel weg. */ +function bug_delete_image_files(?int $bugId = null): void +{ + try { + $stmt = $bugId === null + ? db()->query('SELECT filename FROM bug_report_images') + : db()->prepare('SELECT filename FROM bug_report_images WHERE bug_id = ?'); + if ($bugId !== null) { + $stmt->execute([$bugId]); + } + $filenames = $stmt->fetchAll(PDO::FETCH_COLUMN); + } catch (PDOException $e) { + return; + } + foreach ($filenames as $filename) { + if (strpos((string) $filename, '/') === false && is_file(BUG_UPLOAD_DIR . $filename)) { + @unlink(BUG_UPLOAD_DIR . $filename); + } + } +} diff --git a/includes/data_reset.php b/includes/data_reset.php index c5188ab..9f24662 100644 --- a/includes/data_reset.php +++ b/includes/data_reset.php @@ -9,6 +9,7 @@ declare(strict_types=1); require_once __DIR__ . '/member_profile.php'; require_once __DIR__ . '/wiki.php'; +require_once __DIR__ . '/bugs.php'; /** * Bereiche: Schluessel => Beschriftung, Beschreibung, Zaehl-Abfrage und die Loeschbefehle @@ -102,6 +103,14 @@ const DATA_RESET_AREAS = [ 'delete' => ['UPDATE users SET profile_bio = NULL, profile_background = NULL'], 'reset_ids' => [], ], + 'gear_sets' => [ + 'label' => 'Gear-Planer: Sets', + 'description' => 'Alle Ausrüstungssets der Mitglieder. Der Katalog der Gegenstände bleibt.', + 'count' => 'SELECT COUNT(*) FROM gear_sets', + 'unit' => ['Set', 'Sets'], + 'delete' => ['DELETE FROM gear_sets'], + 'reset_ids' => ['gear_sets'], + ], 'wiki' => [ 'label' => 'Wiki', 'description' => 'Alle Seiten, Versionen, Bilder und Mitwirkenden. Der Einsteiger-Guide lässt sich danach im Wiki neu übernehmen.', @@ -112,11 +121,11 @@ const DATA_RESET_AREAS = [ ], 'bugs' => [ 'label' => 'Fehlermeldungen', - 'description' => 'Alle eingegangenen Fehlermeldungen.', + 'description' => 'Alle eingegangenen Fehlermeldungen samt angehängter Bilder.', 'count' => 'SELECT COUNT(*) FROM bug_reports', 'unit' => ['Meldung', 'Meldungen'], 'delete' => ['DELETE FROM bug_reports'], - 'reset_ids' => ['bug_reports'], + 'reset_ids' => ['bug_report_images', 'bug_reports'], ], 'tour' => [ 'label' => 'Einführungstour', @@ -185,6 +194,15 @@ function data_reset_run(array $keys): array } } + $bugFiles = []; + if (in_array('bugs', $keys, true)) { + try { + $bugFiles = $pdo->query('SELECT filename FROM bug_report_images')->fetchAll(PDO::FETCH_COLUMN); + } catch (PDOException $e) { + $bugFiles = []; + } + } + $pdo->beginTransaction(); try { foreach ($keys as $key) { @@ -203,6 +221,11 @@ function data_reset_run(array $keys): array foreach ($files as $filename) { profile_delete_file($filename); } + foreach ($bugFiles as $filename) { + if (strpos((string) $filename, '/') === false && is_file(BUG_UPLOAD_DIR . $filename)) { + @unlink(BUG_UPLOAD_DIR . $filename); + } + } if (in_array('wiki', $keys, true) && is_dir(WIKI_UPLOAD_DIR)) { foreach (scandir(WIKI_UPLOAD_DIR) ?: [] as $name) { // .htaccess/index-Dateien des Ordners bleiben diff --git a/includes/functions.php b/includes/functions.php index 8653794..a641f4a 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -144,6 +144,7 @@ function icon(string $name): string 'sort' => '', 'book' => '', 'code' => '', + 'sword' => '', 'bug' => '', 'shield-check' => '', ]; diff --git a/includes/gear.php b/includes/gear.php new file mode 100644 index 0000000..f9e7869 --- /dev/null +++ b/includes/gear.php @@ -0,0 +1,459 @@ + [Beschriftung, Gruppe, erlaubte Slots laut aion2hub]. + * Ohrringe, Ringe und Armbaender gibt es doppelt. + */ +const GEAR_SLOTS = [ + 'main_hand' => ['Haupthand', 'Waffen', ['MainHand']], + 'off_hand' => ['Nebenhand', 'Waffen', ['SubHand', 'MainHand']], + 'head' => ['Kopf', 'Rüstung', ['Helmet']], + 'shoulder' => ['Schultern', 'Rüstung', ['Shoulder']], + 'torso' => ['Brust', 'Rüstung', ['Torso']], + 'gloves' => ['Hände', 'Rüstung', ['Gloves']], + 'pants' => ['Beine', 'Rüstung', ['Pants']], + 'boots' => ['Füße', 'Rüstung', ['Boots']], + 'cape' => ['Umhang', 'Rüstung', ['Cape']], + 'necklace' => ['Halskette', 'Schmuck', ['Necklace']], + 'earring_1' => ['Ohrring 1', 'Schmuck', ['Earring']], + 'earring_2' => ['Ohrring 2', 'Schmuck', ['Earring']], + 'ring_1' => ['Ring 1', 'Schmuck', ['Ring']], + 'ring_2' => ['Ring 2', 'Schmuck', ['Ring']], + 'bracelet_1' => ['Armband 1', 'Schmuck', ['Bracelet']], + 'bracelet_2' => ['Armband 2', 'Schmuck', ['Bracelet']], + 'belt' => ['Gürtel', 'Schmuck', ['Belt']], + 'amulet' => ['Amulett', 'Schmuck', ['Amulet']], +]; + +// In der Nebenhand: Schilde & Co. (SubHand) und Einhandwaffen fuer zwei Waffen +const GEAR_OFFHAND_WEAPON_TYPES = ['Sword', 'Dagger', 'Mace']; + +// Seltenheit: Reihenfolge und CSS-Klasse (Farbe) +const GEAR_GRADES = ['Common' => 'common', 'Rare' => 'rare', 'Epic' => 'epic', 'Unique' => 'unique', 'Heroic' => 'heroic', 'Special' => 'special']; + +// Herkunft eines Wertes in der Summe +const GEAR_SOURCES = [ + 'base' => 'Grundwerte', + 'enchant' => 'Aufwertung', + 'exceed' => 'Durchbruch', + 'soul' => 'Seelenprägung', + 'manastone' => 'Manasteine', +]; + +// Diese Werte stehen in der Summe oben, der Rest folgt in der Reihenfolge des Auftretens +const GEAR_STAT_ORDER = ['Min Attack', 'Max Attack', 'Attack', 'Defense', 'HP', 'MP', 'Accuracy', 'Critical Hit', 'Critical Attack', 'Evasion', 'Block', 'Critical Hit Resist']; + +// Beschriftungen der Felder beim Abgleich +const GEAR_FIELD_LABELS = [ + 'name' => 'Name', 'grade' => 'Seltenheit', 'item_level' => 'Gegenstandsstufe', 'required_level' => 'Benötigte Stufe', + 'slot' => 'Slot', 'item_type' => 'Art', 'stats' => 'Grundwerte', 'soul_imprint' => 'Seelenprägung (Spannen)', + 'soul_imprint_count' => 'Seelenprägung (Anzahl)', 'manastone_slots' => 'Manastein-Sockel', 'godstone_slots' => 'Götterstein-Sockel', + 'enchant_max' => 'Aufwertung bis', 'enchant_stats' => 'Aufwertung (Maximum)', 'exceed_max' => 'Durchbruch bis', 'exceed_stats' => 'Durchbruch (Maximum)', +]; + +// Felder, die als JSON in gear_items.data liegen +const GEAR_DATA_FIELDS = ['stats', 'soul_imprint', 'soul_imprint_count', 'manastone_slots', 'godstone_slots', 'enchant_max', 'enchant_stats', 'exceed_max', 'exceed_stats']; + +// ---- Katalog ---- + +/** Zeile aus gear_items mit ausgepackten Werten. */ +function gear_item_decode(array $row): array +{ + $data = json_decode((string) ($row['data'] ?? ''), true) ?: []; + foreach (GEAR_DATA_FIELDS as $field) { + $row[$field] = $data[$field] ?? (in_array($field, ['stats', 'soul_imprint', 'enchant_stats', 'exceed_stats'], true) ? [] : 0); + } + unset($row['data']); + return $row; +} + +/** @return array Gegenstaende nach ID */ +function gear_items_by_ids(array $ids): array +{ + $ids = array_values(array_unique(array_filter(array_map('intval', $ids)))); + if (!$ids) { + return []; + } + $stmt = db()->prepare('SELECT * FROM gear_items WHERE id IN (' . implode(',', array_fill(0, count($ids), '?')) . ')'); + $stmt->execute($ids); + $items = []; + foreach ($stmt->fetchAll() as $row) { + $items[(int) $row['id']] = gear_item_decode($row); + } + return $items; +} + +function gear_item(int $id): ?array +{ + return gear_items_by_ids([$id])[$id] ?? null; +} + +function gear_icon_url(?array $item): ?string +{ + return !empty($item['icon']) ? GEAR_ICON_URL . rawurlencode((string) $item['icon']) : null; +} + +function gear_grade_class(?string $grade): string +{ + return 'grade-' . (GEAR_GRADES[$grade ?? ''] ?? 'common'); +} + +/** Passt ein Katalog-Gegenstand in diesen Slot eines Sets? */ +function gear_item_fits_slot(array $item, string $slotKey): bool +{ + if (!isset(GEAR_SLOTS[$slotKey]) || !in_array($item['slot'], GEAR_SLOTS[$slotKey][2], true)) { + return false; + } + if ($slotKey === 'off_hand' && $item['slot'] === 'MainHand') { + return in_array($item['item_type'], GEAR_OFFHAND_WEAPON_TYPES, true); + } + return true; +} + +/** Eintraege fuer die Suchliste (assets/js/item-picker.js) eines Slots. */ +function gear_picker_items(string $slotKey): array +{ + $slots = GEAR_SLOTS[$slotKey][2] ?? []; + if (!$slots) { + return []; + } + $stmt = db()->prepare( + 'SELECT id, name, slot, item_type, grade, item_level, icon FROM gear_items + WHERE slot IN (' . implode(',', array_fill(0, count($slots), '?')) . ') ORDER BY item_level DESC, name' + ); + $stmt->execute($slots); + $rows = array_values(array_filter($stmt->fetchAll(), static fn (array $row): bool => gear_item_fits_slot($row, $slotKey))); + + // Gleiche Namen (z.B. zwei Varianten) auseinanderhalten - die Suchliste waehlt ueber den Namen + $names = array_count_values(array_column($rows, 'name')); + return array_map(static fn (array $row): array => [ + 'id' => (int) $row['id'], + 'name' => $names[$row['name']] > 1 ? $row['name'] . ' (Stufe ' . (int) $row['item_level'] . ', #' . (int) $row['id'] . ')' : $row['name'], + 'icon' => gear_icon_url($row), + 'category' => $row['grade'] . ' · Stufe ' . (int) $row['item_level'] . ($row['item_type'] !== $row['slot'] ? ' · ' . $row['item_type'] : ''), + ], $rows); +} + +/** + * Werte, die fuer Manasteine zur Wahl stehen: alle festen (nicht prozentualen) Werte, die im + * Katalog als Seelenpraegung vorkommen - die Manasteine wuerfeln aus denselben Grundwerten. + */ +function gear_manastone_stats(): array +{ + static $stats = null; + if ($stats !== null) { + return $stats; + } + $stats = []; + foreach (db()->query('SELECT data FROM gear_items')->fetchAll(PDO::FETCH_COLUMN) as $json) { + foreach ((json_decode((string) $json, true)['soul_imprint'] ?? []) as $entry) { + if (($entry[3] ?? '') === '' && !str_contains((string) $entry[0], '[')) { + $stats[$entry[0]] = true; + } + } + } + $stats = array_keys($stats); + usort($stats, static function (string $a, string $b): int { + $ia = array_search($a, GEAR_STAT_ORDER, true); + $ib = array_search($b, GEAR_STAT_ORDER, true); + return [$ia === false ? 99 : $ia, $a] <=> [$ib === false ? 99 : $ib, $b]; + }); + return $stats; +} + +/** Wert lesbar: 1.100 / 5,95 % */ +function gear_format_value(float $value, string $unit = ''): string +{ + $text = floor($value) == $value + ? number_format($value, 0, ',', '.') + : rtrim(rtrim(number_format($value, 2, ',', '.'), '0'), ','); + return $text . ($unit === '%' ? ' %' : ''); +} + +/** Liste [[Name, Wert, Einheit], …] als Text, z.B. fuer den Abgleich. */ +function gear_stats_text(array $stats): string +{ + return implode(', ', array_map(static fn (array $s): string => $s[0] . ' ' . gear_format_value((float) $s[1], (string) ($s[2] ?? '')), $stats)) ?: '–'; +} + +/** Spannen der Seelenpraegung als Text. */ +function gear_soul_text(array $entries): string +{ + return implode(', ', array_map( + static fn (array $s): string => $s[0] . ' ' . gear_format_value((float) $s[1], $s[3]) . '–' . gear_format_value((float) $s[2], $s[3]), + $entries + )) ?: '–'; +} + +/** Unterschiede zwischen gespeichertem und neu ausgelesenem Gegenstand: [[Feld, alt, neu], …] */ +function gear_item_diff(?array $old, array $new): array +{ + $diffs = []; + foreach (GEAR_FIELD_LABELS as $field => $label) { + $format = static function ($value) use ($field): string { + if (in_array($field, ['stats', 'enchant_stats', 'exceed_stats'], true)) { + return gear_stats_text((array) $value); + } + if ($field === 'soul_imprint') { + return gear_soul_text((array) $value); + } + return $value === null || $value === '' ? '–' : (string) $value; + }; + $before = $old === null ? '–' : $format($old[$field] ?? null); + $after = $format($new[$field] ?? null); + if ($before !== $after) { + $diffs[] = [$label, $before, $after]; + } + } + return $diffs; +} + +/** Icon von aion2hub laden (einmalig beim Uebernehmen). Gibt den Dateinamen zurueck oder null. */ +function gear_icon_download(int $id): ?string +{ + try { + $body = gear_source_fetch(GEAR_SOURCE_ICON_URL . $id); + } catch (RuntimeException $e) { + return null; + } + $info = @getimagesizefromstring($body); + $types = [IMAGETYPE_PNG => 'png', IMAGETYPE_WEBP => 'webp', IMAGETYPE_JPEG => 'jpg', IMAGETYPE_GIF => 'gif']; + if ($info === false || !isset($types[$info[2]]) || strlen($body) > 512 * 1024) { + return null; + } + if (!is_dir(GEAR_ICON_DIR)) { + @mkdir(GEAR_ICON_DIR, 0755, true); + } + $name = $id . '.' . $types[$info[2]]; + return @file_put_contents(GEAR_ICON_DIR . $name, $body) !== false ? $name : null; +} + +/** + * Ausgelesenen Gegenstand speichern (neu oder aktualisiert). + * + * @return array{new: bool, diffs: array} diffs = was sich gegenueber vorher geaendert hat + */ +function gear_item_store(array $parsed, int $userId): array +{ + $id = (int) $parsed['source_id']; + $old = gear_item($id); + $diffs = gear_item_diff($old, $parsed); + $data = json_encode(array_intersect_key($parsed, array_flip(GEAR_DATA_FIELDS)), JSON_UNESCAPED_UNICODE); + $icon = $old['icon'] ?? null; + if (!$icon || !is_file(GEAR_ICON_DIR . $icon)) { + $icon = gear_icon_download($id); + } + + db()->prepare( + 'INSERT INTO gear_items (id, name, category, slot, item_type, grade, item_level, required_level, data, icon, source_version, checked_at, checked_by, updated_at) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?, NOW()) + ON DUPLICATE KEY UPDATE name = VALUES(name), category = VALUES(category), slot = VALUES(slot), item_type = VALUES(item_type), + grade = VALUES(grade), item_level = VALUES(item_level), required_level = VALUES(required_level), data = VALUES(data), + icon = VALUES(icon), source_version = VALUES(source_version), checked_at = NOW(), checked_by = VALUES(checked_by), + updated_at = IF(data <=> VALUES(data) AND name <=> VALUES(name) AND item_level <=> VALUES(item_level), updated_at, NOW())' + )->execute([ + $id, $parsed['name'], $parsed['category'], $parsed['slot'], $parsed['item_type'], $parsed['grade'], + $parsed['item_level'], $parsed['required_level'], $data, $icon, mb_substr($parsed['source_version'], 0, 120), $userId, + ]); + return ['new' => $old === null, 'diffs' => $old === null ? [] : $diffs]; +} + +/** Gegenstand bei aion2hub abrufen und auslesen (ohne zu speichern). */ +function gear_item_fetch(int $id): array +{ + $parsed = gear_source_parse_item(gear_source_fetch(GEAR_SOURCE_ITEM_URL . $id)); + if ((int) $parsed['source_id'] !== $id) { + throw new RuntimeException('Die Seite gehört zu einem anderen Gegenstand (#' . (int) $parsed['source_id'] . ').'); + } + return $parsed; +} + +// ---- Werte berechnen ---- + +/** + * Werte bei Stufe $level, wenn $atMax die Werte bei der Hoechststufe $max sind. Zwischenstufen + * werden gleichmaessig hochgerechnet (geschaetzt). + * + * @return array [Name, Wert, Einheit, geschaetzt] + */ +function gear_scaled_stats(array $atMax, int $level, int $max): array +{ + if ($level <= 0 || $max <= 0) { + return []; + } + $level = min($level, $max); + $estimated = $level < $max; + return array_map(static function (array $stat) use ($level, $max, $estimated): array { + $value = (float) $stat[1] * $level / $max; + $value = ($stat[2] ?? '') === '%' ? round($value, 2) : round($value); + return [$stat[0], $value, (string) ($stat[2] ?? ''), $estimated]; + }, $atMax); +} + +/** + * Alle Werte, die ein belegter Slot beitraegt. + * + * @return array + */ +function gear_slot_contributions(array $slot, array $item): array +{ + $out = []; + $add = static function (string $source, string $name, float $value, string $unit, bool $estimated = false) use (&$out): void { + $out[] = ['source' => $source, 'name' => $name, 'value' => $value, 'unit' => $unit, 'estimated' => $estimated]; + }; + foreach ($item['stats'] as $stat) { + $add('base', $stat[0], (float) $stat[1], (string) $stat[2]); + } + foreach (gear_scaled_stats($item['enchant_stats'], (int) $slot['enchant'], (int) $item['enchant_max']) as $stat) { + $add('enchant', $stat[0], $stat[1], $stat[2], $stat[3]); + } + foreach (gear_scaled_stats($item['exceed_stats'], (int) $slot['exceed'], (int) $item['exceed_max']) as $stat) { + $add('exceed', $stat[0], $stat[1], $stat[2], $stat[3]); + } + $ranges = []; + foreach ($item['soul_imprint'] as $entry) { + $ranges[$entry[0]] = $entry; + } + foreach ($slot['soul_imprint'] as $entry) { + if (isset($ranges[$entry[0]])) { + $add('soul', $entry[0], (float) $entry[1], (string) $ranges[$entry[0]][3]); + } + } + foreach ($slot['manastones'] as $entry) { + $add('manastone', $entry[0], (float) $entry[1], ''); + } + return $out; +} + +/** + * Summe aller Werte eines Sets. + * + * @return array, estimated: bool}> + */ +function gear_set_totals(array $slots): array +{ + $totals = []; + foreach ($slots as $slot) { + if (empty($slot['item'])) { + continue; + } + foreach (gear_slot_contributions($slot, $slot['item']) as $c) { + $key = $c['name'] . '|' . $c['unit']; + $totals[$key] ??= ['name' => $c['name'], 'unit' => $c['unit'], 'total' => 0.0, 'by' => [], 'estimated' => false]; + $totals[$key]['total'] += $c['value']; + $totals[$key]['by'][$c['source']] = ($totals[$key]['by'][$c['source']] ?? 0) + $c['value']; + $totals[$key]['estimated'] = $totals[$key]['estimated'] || $c['estimated']; + } + } + uksort($totals, static function (string $a, string $b) use ($totals): int { + $ia = array_search($totals[$a]['name'], GEAR_STAT_ORDER, true); + $ib = array_search($totals[$b]['name'], GEAR_STAT_ORDER, true); + return [$ia === false ? 99 : $ia, $totals[$a]['unit'], $a] <=> [$ib === false ? 99 : $ib, $totals[$b]['unit'], $b]; + }); + return $totals; +} + +/** Durchschnittliche Gegenstandsstufe der belegten Slots (grobe Einordnung eines Sets). */ +function gear_set_item_level(array $slots): ?float +{ + $levels = []; + foreach ($slots as $slot) { + if (!empty($slot['item'])) { + $levels[] = (int) $slot['item']['item_level']; + } + } + return $levels ? array_sum($levels) / count($levels) : null; +} + +// ---- Sets ---- + +function gear_set(int $id): ?array +{ + $stmt = db()->prepare( + "SELECT s.*, COALESCE(NULLIF(u.display_name, ''), u.username) AS owner_name + FROM gear_sets s JOIN users u ON u.id = s.user_id WHERE s.id = ?" + ); + $stmt->execute([$id]); + return $stmt->fetch() ?: null; +} + +/** @return array Sets eines Mitglieds (nur die fuers Profil freigegebenen, wenn $profileOnly) */ +function gear_sets_for_user(int $userId, bool $profileOnly = false): array +{ + $stmt = db()->prepare( + 'SELECT * FROM gear_sets WHERE user_id = ?' . ($profileOnly ? ' AND show_on_profile = 1' : '') . ' ORDER BY sort_order, id' + ); + $stmt->execute([$userId]); + return $stmt->fetchAll(); +} + +/** Darf der aktuelle Nutzer das Set ansehen? Eigene immer, fremde nur, wenn aufs Profil freigegeben. */ +function gear_can_view_set(array $set): bool +{ + $me = current_user(); + return $me && ((int) $me['id'] === (int) $set['user_id'] || !empty($set['show_on_profile'])); +} + +function gear_is_own_set(array $set): bool +{ + $me = current_user(); + return $me && (int) $me['id'] === (int) $set['user_id']; +} + +/** + * Slots mehrerer Sets mit ihren Gegenstaenden. + * + * @return array> [Set-ID => [Slot => Zeile mit 'item']] + */ +function gear_slots_for_sets(array $setIds): array +{ + $setIds = array_values(array_unique(array_map('intval', $setIds))); + $result = array_fill_keys($setIds, []); + if (!$setIds) { + return $result; + } + $stmt = db()->prepare('SELECT * FROM gear_set_slots WHERE set_id IN (' . implode(',', array_fill(0, count($setIds), '?')) . ')'); + $stmt->execute($setIds); + $rows = $stmt->fetchAll(); + $items = gear_items_by_ids(array_column($rows, 'item_id')); + foreach ($rows as $row) { + if (!isset(GEAR_SLOTS[$row['slot']])) { + continue; + } + $row['soul_imprint'] = json_decode((string) $row['soul_imprint'], true) ?: []; + $row['manastones'] = json_decode((string) $row['manastones'], true) ?: []; + $row['item'] = $items[(int) $row['item_id']] ?? null; + $result[(int) $row['set_id']][$row['slot']] = $row; + } + return $result; +} + +/** Sets fuer die Profilseite: [[set, slots, item_level], …] */ +function gear_profile_sets(int $userId): array +{ + $sets = gear_sets_for_user($userId, true); + $slots = gear_slots_for_sets(array_column($sets, 'id')); + return array_map(static fn (array $set): array => [ + 'set' => $set, + 'slots' => $slots[(int) $set['id']] ?? [], + 'item_level' => gear_set_item_level($slots[(int) $set['id']] ?? []), + ], $sets); +} diff --git a/includes/gear_source.php b/includes/gear_source.php new file mode 100644 index 0000000..7e395bb --- /dev/null +++ b/includes/gear_source.php @@ -0,0 +1,226 @@ + true, + CURLOPT_FOLLOWLOCATION => false, + CURLOPT_TIMEOUT => 15, + CURLOPT_CONNECTTIMEOUT => 5, + CURLOPT_USERAGENT => GEAR_SOURCE_AGENT, + CURLOPT_HTTPHEADER => ['Accept: text/html,image/*'], + ]); + $body = curl_exec($ch); + $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); + $error = curl_error($ch); + if ($body === false) { + throw new RuntimeException('aion2hub nicht erreichbar: ' . $error); + } + if ($status === 404) { + throw new RuntimeException('Diesen Gegenstand gibt es bei aion2hub nicht.'); + } + if ($status !== 200) { + throw new RuntimeException('aion2hub antwortet mit Status ' . $status . '.'); + } + return (string) $body; +} + +/** Gegenstands-ID aus einer ID oder einem aion2hub-Link ("…/database/items/110130060"). */ +function gear_source_parse_id(string $input): ?int +{ + $input = trim($input); + if (preg_match('/^\d{6,12}$/', $input)) { + return (int) $input; + } + if (preg_match('#aion2hub\.com/database/items/(\d{6,12})#i', $input, $m)) { + return (int) $m[1]; + } + return null; +} + +/** Alle Gegenstands-IDs, die auf einer Listenseite von aion2hub verlinkt sind. */ +function gear_source_list_ids(string $html): array +{ + preg_match_all('#href="/database/items/(\d{6,12})"#', $html, $m); + return array_values(array_unique(array_map('intval', $m[1]))); +} + +/** Seite in Textbausteine zerlegen (jedes HTML-Element wird zur Trennstelle). */ +function gear_source_tokens(string $html): array +{ + $html = preg_replace('#<(script|style|noscript)\b.*?#is', '', $html) ?? ''; + $text = preg_replace('/<[^>]+>/', '|', $html) ?? ''; + $text = html_entity_decode($text, ENT_QUOTES | ENT_HTML5, 'UTF-8'); + $tokens = []; + foreach (explode('|', $text) as $token) { + $token = trim(preg_replace('/\s+/u', ' ', $token) ?? ''); + if ($token !== '') { + $tokens[] = $token; + } + } + return $tokens; +} + +/** "1,100" -> [1100, ''], "33%" -> [33, '%'], sonst null */ +function gear_source_number(string $value): ?array +{ + $value = trim($value); + if (!preg_match('/^(-?[\d,]+(?:\.\d+)?)\s*(%?)$/', $value, $m)) { + return null; + } + return [(float) str_replace(',', '', $m[1]), $m[2]]; +} + +/** "Min Attack 106, Max Attack 106" -> [['Min Attack', 106, ''], …] */ +function gear_source_stat_list(string $text): array +{ + $stats = []; + foreach (explode(',', $text) as $part) { + if (preg_match('/^\s*(.+?)\s+(-?[\d.]+)\s*(%?)\s*$/u', $part, $m)) { + $stats[] = [$m[1], (float) $m[2], $m[3]]; + } + } + return $stats; +} + +/** + * Liest eine Gegenstandsseite von aion2hub aus. + * + * @return array{source_id: int, name: string, category: string, grade: string, item_level: int, + * required_level: ?int, slot: string, item_type: string, stats: array, soul_imprint: array, + * soul_imprint_count: int, manastone_slots: int, godstone_slots: int, enchant_max: int, + * enchant_stats: array, exceed_max: int, exceed_stats: array, source_version: string} + */ +function gear_source_parse_item(string $html): array +{ + $t = gear_source_tokens($html); + $n = count($t); + + // Kopf: "Item Database / / / Copy link / / Item Lv / 86 / …" + $start = null; + for ($i = 0; $i < $n - 4; $i++) { + if ($t[$i] === 'Item Database' && $t[$i + 1] === '/' && ($t[$i + 4] ?? '') === 'Copy link') { + $start = $i; + break; + } + } + if ($start === null) { + throw new RuntimeException('Die Seite sieht nicht wie eine Gegenstandsseite von aion2hub aus.'); + } + $item = [ + 'category' => $t[$start + 2], + 'name' => $t[$start + 3], + 'grade' => $t[$start + 5], + 'item_level' => 0, + 'required_level' => null, + 'slot' => '', + 'item_type' => '', + 'stats' => [], + 'soul_imprint' => [], + 'soul_imprint_count' => 0, + 'manastone_slots' => 0, + 'godstone_slots' => 0, + 'enchant_max' => 0, + 'enchant_stats' => [], + 'exceed_max' => 0, + 'exceed_stats' => [], + 'source_version' => '', + 'source_id' => 0, + ]; + $i = $start + 6; + if (($t[$i] ?? '') === 'Item Lv') { + $item['item_level'] = (int) $t[$i + 1]; + $i += 2; + } + if (($t[$i] ?? '') === 'Requires Lv') { + $item['required_level'] = (int) $t[$i + 1]; + $i += 2; + } + $item['slot'] = $t[$i] ?? ''; + $item['item_type'] = $t[$i + 1] ?? ''; + + // Grundwerte: Paare nach "Stats" bis zum naechsten Abschnitt + $stop = ['Soul Imprint', 'Item Info', 'KR/TW', 'Upgrades', 'How to Obtain']; + $statsAt = array_search('Stats', array_slice($t, $i, 40, true), true); + if ($statsAt !== false) { + for ($j = $statsAt + 1; $j < $n - 1 && !in_array($t[$j], $stop, true); $j += 2) { + $number = gear_source_number($t[$j + 1]); + if ($number === null) { + break; + } + $item['stats'][] = [$t[$j], $number[0], $number[1]]; + } + + // Seelenpraegung: "— 4 of these can be selected", dann "Name / 21 ~ 31" (Fertigkeiten danach zaehlen nicht) + if (($t[$j] ?? '') === 'Soul Imprint' && preg_match('/(\d+) of these can be selected/', $t[$j + 1] ?? '', $m)) { + $item['soul_imprint_count'] = (int) $m[1]; + for ($k = $j + 2; $k < $n - 1; $k += 2) { + if (!preg_match('/^(-?[\d,.]+)(%?) ~ (-?[\d,.]+)(%?)$/', $t[$k + 1], $r)) { + break; + } + $item['soul_imprint'][] = [$t[$k], (float) str_replace(',', '', $r[1]), (float) str_replace(',', '', $r[3]), $r[2]]; + } + } + } + + // Sockel und Aufwertung stehen unter "Item Info" / "Upgrades" (nach dem Korea-Vergleich) + $info = array_search('Item Info', $t, true); + if ($info !== false) { + for ($j = $info + 1; $j < $n - 1 && $t[$j] !== 'How to Obtain'; $j++) { + if ($t[$j] === 'Manastone sockets') { + $item['manastone_slots'] = (int) $t[$j + 1]; + } elseif ($t[$j] === 'Godstone sockets') { + $item['godstone_slots'] = (int) $t[$j + 1]; + } elseif (($t[$j] === 'Enchantable to' || str_starts_with($t[$j], 'Exceed')) && ($t[$j + 1] ?? '') === '+') { + // "Enchantable to / + / 15 / At + / 15 / : / Min Attack 106, Max Attack 106" + $max = (int) ($t[$j + 2] ?? 0); + $stats = ($t[$j + 3] ?? '') === 'At +' && ($t[$j + 5] ?? '') === ':' ? gear_source_stat_list($t[$j + 6] ?? '') : []; + if ($t[$j] === 'Enchantable to') { + $item['enchant_max'] = $max; + $item['enchant_stats'] = $stats; + } else { + $item['exceed_max'] = $max; + $item['exceed_stats'] = $stats; + } + } + } + } + + // Fusszeile: "Item # / 110130060 / · Global data (Launch Scale Test client, 2026-09-19)" + $foot = array_search('Item #', $t, true); + if ($foot !== false) { + $item['source_id'] = (int) ($t[$foot + 1] ?? 0); + $item['source_version'] = trim(ltrim((string) ($t[$foot + 2] ?? ''), '· ')); + } + if (!str_contains($item['source_version'], 'Global')) { + throw new RuntimeException('Keine Werte aus dem Global-Client (nur Korea/Taiwan?) - nicht übernommen.'); + } + if (!in_array($item['category'], ['Weapons', 'Armor', 'Accessories'], true)) { + throw new RuntimeException('Nur Waffen, Rüstungen und Schmuck lassen sich übernehmen (das ist: ' . $item['category'] . ').'); + } + return $item; +} diff --git a/includes/header.php b/includes/header.php index 72ed467..03878dc 100644 --- a/includes/header.php +++ b/includes/header.php @@ -17,6 +17,7 @@ $canViewEvents = $currentUser && user_has_permission('events.view'); $canManageActivity = $currentUser && user_has_permission('activity.manage'); $canViewMap = $currentUser && user_has_permission('map.view'); $canViewWarehouse = $currentUser && user_has_permission('warehouse.view'); +$canViewGear = $currentUser && user_has_permission('gear.view'); $canViewContributions = $currentUser && user_has_permission('contributions.view'); $canViewShop = $currentUser && user_has_permission('shop.view'); // Offene Lumishop-Antraege als Zahl am Menuepunkt (nur fuer die, die sie bearbeiten). @@ -70,6 +71,7 @@ $isCalendarActive = $currentScript === 'calendar.php'; $isActivityActive = $currentScript === 'activity.php'; $isMapActive = $currentScript === 'map.php'; $isWarehouseActive = $currentScript === 'warehouse.php'; +$isGearActive = in_array($currentScript, ['gear.php', 'gear_items.php'], true); $isContributionsActive = in_array($currentScript, ['contributions.php', 'contributions_award.php'], true); $isShopActive = in_array($currentScript, ['shop.php', 'shop_orders.php', 'shop_manage.php'], true); $isMembersActive = in_array($currentScript, ['members.php', 'member.php', 'member_edit.php', 'member_picture.php'], true); @@ -93,6 +95,8 @@ $pageBackgrounds = [ 'activity.php' => 'bg-events', 'map.php' => 'bg-map', 'warehouse.php' => 'bg-warehouse', + 'gear.php' => 'bg-warehouse', + 'gear_items.php' => 'bg-admin', 'contributions.php' => 'bg-contributions', 'contributions_award.php' => 'bg-contributions', 'shop.php' => 'bg-shop', @@ -209,7 +213,7 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($ - + @@ -242,6 +246,11 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($ Karte + + + Gear-Planer + + Lagerhaus diff --git a/includes/permissions.php b/includes/permissions.php index 3b38b9a..2dcb5fd 100644 --- a/includes/permissions.php +++ b/includes/permissions.php @@ -31,6 +31,8 @@ const CORE_PERMISSIONS = [ ['key' => 'shop.view', 'description' => 'Lumishop: Angebot ansehen und Gegenstände gegen Lumipunkte beantragen'], ['key' => 'shop.manage', 'description' => 'Lumishop: Kategorien, Gegenstände, Bestand und Preise verwalten, Anträge bewilligen oder ablehnen'], ['key' => 'members.view', 'description' => 'Mitgliederliste einsehen'], + ['key' => 'gear.view', 'description' => 'Gear-Planer: eigene Ausrüstungssets anlegen und vergleichen, freigegebene Sets anderer ansehen'], + ['key' => 'gear.manage', 'description' => 'Gear-Planer: Gegenstände und ihre Werte von aion2hub übernehmen, abgleichen und löschen'], ['key' => 'comments.moderate', 'description' => 'Moderation: Galeriebilder, Kommentare und Kalender-Termine der Mitglieder freigeben, ausblenden und löschen (Freigabe-Liste, Meldungen)'], ['key' => 'audit.view', 'description' => 'Audit-Log einsehen: alle Verwaltungsaktionen und Sicherheitsereignisse der Website'], ['key' => 'reports.view', 'description' => 'Eingegangene Reports einsehen'], diff --git a/includes/raid_attendance.php b/includes/raid_attendance.php index b0e846a..1a4a64d 100644 --- a/includes/raid_attendance.php +++ b/includes/raid_attendance.php @@ -12,10 +12,11 @@ require_once __DIR__ . '/contributions.php'; * (raid_settings) und die Anwesenheitsliste (raid_attendance, je Discord-ID). */ +// Nur noch anwesend/abwesend. Alte Eintraege "excused" (Entschuldigt) gelten als nicht erfasst +// und verschwinden beim naechsten Speichern der Liste; die Spalte kennt den Wert weiterhin. const RAID_ATTENDANCE_STATUSES = [ 'present' => 'Anwesend', 'absent' => 'Abwesend', - 'excused' => 'Entschuldigt', ]; /** @return array{points_present: int, points_absent: int, auto_processed_at: ?string, auto_result: ?string, attendance_checked_at: ?string, checked_by: ?string} */ diff --git a/includes/schema.php b/includes/schema.php index c4dfd75..7d499ca 100644 --- a/includes/schema.php +++ b/includes/schema.php @@ -11,7 +11,7 @@ declare(strict_types=1); */ // Hochzaehlen, sobald unten eine Aenderung dazukommt - dann pruefen alle Sitzungen neu. -const SCHEMA_VERSION = 24; +const SCHEMA_VERSION = 26; /** * Tabellen, die nachtraeglich dazugekommen sind: Tabelle => CREATE-Befehl (wie in sql/schema.sql). @@ -19,6 +19,81 @@ const SCHEMA_VERSION = 24; function schema_table_upgrades(): array { return [ + // Bilder an Fehlermeldungen (includes/bugs.php) + 'bug_report_images' => <<<'SQL' +CREATE TABLE IF NOT EXISTS bug_report_images ( + id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + bug_id INT UNSIGNED NOT NULL, + -- Datei unter assets/uploads/bugs/ (nur ueber /bug_image.php abrufbar) + filename VARCHAR(120) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (bug_id) REFERENCES bug_reports(id) ON DELETE CASCADE, + INDEX idx_bug_report_images_bug (bug_id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +SQL, + // Gear-Planer (includes/gear.php) + 'gear_items' => <<<'SQL' +CREATE TABLE IF NOT EXISTS gear_items ( + -- Gegenstands-ID aus dem Spiel (wie bei aion2hub.com/database/items/) + id INT UNSIGNED NOT NULL PRIMARY KEY, + name VARCHAR(150) NOT NULL, + -- Weapons, Armor, Accessories + category VARCHAR(20) NOT NULL, + -- Slot laut Spiel (MainHand, SubHand, Helmet, Torso, Ring, ...) und Art (Greatsword, ...) + slot VARCHAR(20) NOT NULL, + item_type VARCHAR(40) NOT NULL DEFAULT '', + grade VARCHAR(20) NOT NULL DEFAULT '', + item_level SMALLINT UNSIGNED NOT NULL DEFAULT 0, + required_level SMALLINT UNSIGNED NULL, + -- Werte als JSON: stats, soul_imprint, Sockel, Aufwertung/Durchbruch (GEAR_DATA_FIELDS in includes/gear.php) + data MEDIUMTEXT NOT NULL, + -- Dateiname unter assets/uploads/gear/ + icon VARCHAR(40) NULL, + -- Stand der Quelle, z.B. "Global data (Launch Scale Test client, 2026-09-19)" + source_version VARCHAR(120) NOT NULL DEFAULT '', + -- Zuletzt mit der Quelle abgeglichen (von wem) und zuletzt tatsaechlich geaendert + checked_at DATETIME NULL, + checked_by INT UNSIGNED NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NULL, + FOREIGN KEY (checked_by) REFERENCES users(id) ON DELETE SET NULL, + INDEX idx_gear_items_slot (slot, item_level), + INDEX idx_gear_items_name (name) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +SQL, + 'gear_sets' => <<<'SQL' +CREATE TABLE IF NOT EXISTS gear_sets ( + id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + user_id INT UNSIGNED NOT NULL, + name VARCHAR(80) NOT NULL, + class_name VARCHAR(30) NULL, + note VARCHAR(255) NULL, + -- 1 = auf der eigenen Profilseite zeigen (dann koennen alle Mitglieder es ansehen und vergleichen) + show_on_profile TINYINT(1) NOT NULL DEFAULT 0, + sort_order INT NOT NULL DEFAULT 0, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NULL, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + INDEX idx_gear_sets_user (user_id, sort_order) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +SQL, + 'gear_set_slots' => <<<'SQL' +CREATE TABLE IF NOT EXISTS gear_set_slots ( + set_id INT UNSIGNED NOT NULL, + -- Schluessel aus GEAR_SLOTS (main_hand, head, ring_1, ...) + slot VARCHAR(20) NOT NULL, + item_id INT UNSIGNED NULL, + enchant TINYINT UNSIGNED NOT NULL DEFAULT 0, + exceed TINYINT UNSIGNED NOT NULL DEFAULT 0, + -- JSON [[Wert, Zahl], ...] - so eingetragen, wie im Spiel gewuerfelt + soul_imprint TEXT NULL, + manastones TEXT NULL, + godstone VARCHAR(100) NULL, + PRIMARY KEY (set_id, slot), + FOREIGN KEY (set_id) REFERENCES gear_sets(id) ON DELETE CASCADE, + FOREIGN KEY (item_id) REFERENCES gear_items(id) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +SQL, // "Angemeldet bleiben" (includes/auth.php) 'auth_tokens' => <<<'SQL' CREATE TABLE IF NOT EXISTS auth_tokens ( @@ -625,8 +700,8 @@ function schema_sync_core_permissions(): void $pdo->prepare('INSERT IGNORE INTO role_permissions (role_id, permission_id) VALUES (?, ?)') ->execute([$adminRoleId, $newPermissionId]); } - // Das Wiki sollen alle lesen duerfen, die ins Dashboard kommen. - if ($permission['key'] === 'wiki.view') { + // Das Wiki und den Gear-Planer sollen alle nutzen duerfen, die ins Dashboard kommen. + if (in_array($permission['key'], ['wiki.view', 'gear.view'], true)) { $pdo->prepare( "INSERT IGNORE INTO role_permissions (role_id, permission_id) SELECT rp.role_id, ? FROM role_permissions rp diff --git a/includes/security.php b/includes/security.php index d51049a..bbabf78 100644 --- a/includes/security.php +++ b/includes/security.php @@ -25,6 +25,7 @@ const AUDIT_AREAS = [ 'shop' => 'Lumishop', 'members' => 'Profile', 'wiki' => 'Wiki', + 'gear' => 'Gear-Planer', 'reports' => 'Reports', 'bugs' => 'Fehlermeldungen', 'other' => 'Sonstiges', @@ -44,8 +45,8 @@ const SECURITY_LIMITS = [ 'destructive' => [20, 600], // Loeschungen pro Konto, danach automatische Sperre ]; -// Diese Skripte schicken im Hintergrund viele kleine Anfragen (Zeichnen, Tour, Bot) - kein Tempolimit. -const SECURITY_POST_EXEMPT = ['bot_api.php', 'tactics_api.php', 'tour_action.php']; +// Diese Skripte schicken im Hintergrund viele kleine Anfragen (Zeichnen, Tour, Bot, Gear-Abgleich) - kein Tempolimit. +const SECURITY_POST_EXEMPT = ['bot_api.php', 'tactics_api.php', 'tour_action.php', 'gear_items_action.php']; /** Bereich einer Aktion anhand des aufgerufenen Skripts (raid_delete_action.php -> raids). */ function audit_area_for_script(string $script): string @@ -54,7 +55,7 @@ function audit_area_for_script(string $script): string $prefixes = [ 'raid' => 'raids', 'premade' => 'premades', 'event' => 'events', 'tactics' => 'map', 'map' => 'map', 'warehouse' => 'warehouse', 'contributions' => 'contributions', 'shop' => 'shop', - 'member' => 'members', 'gallery' => 'members', 'moderation' => 'members', 'reaction' => 'members', 'calendar' => 'events', 'wiki' => 'wiki', 'report' => 'reports', 'bug' => 'bugs', + 'member' => 'members', 'gallery' => 'members', 'moderation' => 'members', 'reaction' => 'members', 'calendar' => 'events', 'wiki' => 'wiki', 'gear' => 'gear', 'report' => 'reports', 'bug' => 'bugs', 'user' => 'users', 'role' => 'users', 'discord' => 'users', 'settings' => 'users', ]; foreach ($prefixes as $prefix => $area) { diff --git a/member.php b/member.php index 2078b26..b8f3469 100644 --- a/member.php +++ b/member.php @@ -3,6 +3,7 @@ require_once __DIR__ . '/includes/bootstrap.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/gear.php'; require_permission('members.view'); $id = (int) ($_GET['id'] ?? 0); @@ -26,6 +27,8 @@ $groupStmt->execute([$id]); $groups = array_column($groupStmt->fetchAll(), 'name'); $characters = profile_characters_by_user($id)[$id] ?? []; +// Ausruestungssets aus dem Gear-Planer, die das Mitglied fuers Profil freigegeben hat +$gearSets = user_has_permission('gear.view') ? gear_profile_sets($id) : []; // Noch nicht freigegebene Bilder sehen nur der Besitzer und die Moderation. $seesPending = (int) current_user()['id'] === $id || moderation_can(); $galleryStmt = db()->prepare( @@ -117,6 +120,34 @@ include __DIR__ . '/includes/header.php';
+ + + +

Galerie

diff --git a/member_edit.php b/member_edit.php index df16755..c2190f6 100644 --- a/member_edit.php +++ b/member_edit.php @@ -160,7 +160,7 @@ include __DIR__ . '/includes/header.php'; - + diff --git a/raid_attendance.php b/raid_attendance.php index 8492f43..74d9f5d 100644 --- a/raid_attendance.php +++ b/raid_attendance.php @@ -110,7 +110,6 @@ include __DIR__ . '/includes/header.php'; Schnell setzen: -
@@ -121,6 +120,7 @@ include __DIR__ . '/includes/header.php';
diff --git a/raid_attendance_action.php b/raid_attendance_action.php index 005f85f..78a5c2a 100644 --- a/raid_attendance_action.php +++ b/raid_attendance_action.php @@ -63,14 +63,13 @@ admin_log('📋 Anwesenheit eingetragen', [ 'Raid' => admin_log_raid($raidId), 'Anwesend' => $counts['present'], 'Abwesend' => $counts['absent'], - 'Entschuldigt' => $counts['excused'], 'Nachgetragen' => $addDiscordId !== '' && isset($names[$addDiscordId]) ? admin_log_discord($addDiscordId, (string) $names[$addDiscordId]) : '', 'Kontrolliert' => !empty($_POST['mark_checked']) ? 'ja, Liste abgeschlossen' : '', ], 'success'); set_flash('success', sprintf( - 'Anwesenheit gespeichert: %d anwesend, %d abwesend, %d entschuldigt%s.', - $counts['present'], $counts['absent'], $counts['excused'], + 'Anwesenheit gespeichert: %d anwesend, %d abwesend%s.', + $counts['present'], $counts['absent'], !empty($_POST['mark_checked']) ? ' - als kontrolliert markiert' : '' )); redirect('/raid_attendance.php?raid=' . $raidId); diff --git a/sql/schema.sql b/sql/schema.sql index f72a05e..4d83d47 100644 --- a/sql/schema.sql +++ b/sql/schema.sql @@ -109,6 +109,17 @@ CREATE TABLE IF NOT EXISTS bug_reports ( INDEX idx_bug_reports_user (user_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- Bilder an Fehlermeldungen (Dateien unter assets/uploads/bugs/, nur ueber /bug_image.php) +CREATE TABLE IF NOT EXISTS bug_report_images ( + id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + bug_id INT UNSIGNED NOT NULL, + -- Datei unter assets/uploads/bugs/ (nur ueber /bug_image.php abrufbar) + filename VARCHAR(120) NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (bug_id) REFERENCES bug_reports(id) ON DELETE CASCADE, + INDEX idx_bug_report_images_bug (bug_id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + CREATE TABLE IF NOT EXISTS user_roles ( user_id INT UNSIGNED NOT NULL, role_id INT UNSIGNED NOT NULL, @@ -548,3 +559,63 @@ CREATE TABLE IF NOT EXISTS calendar_participants ( FOREIGN KEY (entry_id) REFERENCES calendar_entries(id) ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +-- Gear-Planer: Gegenstaende (Werte von aion2hub.com, Global-Client) und persoenliche Sets +CREATE TABLE IF NOT EXISTS gear_items ( + -- Gegenstands-ID aus dem Spiel (wie bei aion2hub.com/database/items/) + id INT UNSIGNED NOT NULL PRIMARY KEY, + name VARCHAR(150) NOT NULL, + -- Weapons, Armor, Accessories + category VARCHAR(20) NOT NULL, + -- Slot laut Spiel (MainHand, SubHand, Helmet, Torso, Ring, ...) und Art (Greatsword, ...) + slot VARCHAR(20) NOT NULL, + item_type VARCHAR(40) NOT NULL DEFAULT '', + grade VARCHAR(20) NOT NULL DEFAULT '', + item_level SMALLINT UNSIGNED NOT NULL DEFAULT 0, + required_level SMALLINT UNSIGNED NULL, + -- Werte als JSON: stats, soul_imprint, Sockel, Aufwertung/Durchbruch (GEAR_DATA_FIELDS in includes/gear.php) + data MEDIUMTEXT NOT NULL, + -- Dateiname unter assets/uploads/gear/ + icon VARCHAR(40) NULL, + -- Stand der Quelle, z.B. "Global data (Launch Scale Test client, 2026-09-19)" + source_version VARCHAR(120) NOT NULL DEFAULT '', + -- Zuletzt mit der Quelle abgeglichen (von wem) und zuletzt tatsaechlich geaendert + checked_at DATETIME NULL, + checked_by INT UNSIGNED NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NULL, + FOREIGN KEY (checked_by) REFERENCES users(id) ON DELETE SET NULL, + INDEX idx_gear_items_slot (slot, item_level), + INDEX idx_gear_items_name (name) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS gear_sets ( + id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, + user_id INT UNSIGNED NOT NULL, + name VARCHAR(80) NOT NULL, + class_name VARCHAR(30) NULL, + note VARCHAR(255) NULL, + -- 1 = auf der eigenen Profilseite zeigen (dann koennen alle Mitglieder es ansehen und vergleichen) + show_on_profile TINYINT(1) NOT NULL DEFAULT 0, + sort_order INT NOT NULL DEFAULT 0, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME NULL, + FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, + INDEX idx_gear_sets_user (user_id, sort_order) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS gear_set_slots ( + set_id INT UNSIGNED NOT NULL, + -- Schluessel aus GEAR_SLOTS (main_hand, head, ring_1, ...) + slot VARCHAR(20) NOT NULL, + item_id INT UNSIGNED NULL, + enchant TINYINT UNSIGNED NOT NULL DEFAULT 0, + exceed TINYINT UNSIGNED NOT NULL DEFAULT 0, + -- JSON [[Wert, Zahl], ...] - so eingetragen, wie im Spiel gewuerfelt + soul_imprint TEXT NULL, + manastones TEXT NULL, + godstone VARCHAR(100) NULL, + PRIMARY KEY (set_id, slot), + FOREIGN KEY (set_id) REFERENCES gear_sets(id) ON DELETE CASCADE, + FOREIGN KEY (item_id) REFERENCES gear_items(id) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;