Gear planner, dashboard polish, images on bug reports

Gear planner:
- Personal gear sets (18 slots) with enchant, exceed, soul imprint and manastones,
  stat totals by source and side-by-side comparison of 2-4 sets
- Sets can be shown on the own profile page (read-only for other members)
- Admin catalog: import items from aion2hub.com (Global client), compare stored
  values with the source one by one or all at once, at most one request per second
- New permissions gear.view (all with dashboard access) and gear.manage

Dashboard:
- Role badges ordered like the member list (roster_order)
- Stronger hover effect on "Rangliste & Verlauf" / "Zum Lumishop", no more blue
  hover on secondary buttons
- "Anstehende Raids" box links to the raids page, next raids link to the raid
  and to the calendar day
- Raid attendance only knows present/absent (old "excused" entries count as unset)

Bug reports:
- Up to 5 images per report, pasting copied images with Ctrl+V (also for the gallery)
- Images are only served to the reporter and bugs.manage via bug_image.php

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Maaxxs 2026-09-22 09:27:09 +02:00
parent e2f1fc53fd
commit 5dabbccbd7
32 changed files with 2826 additions and 30 deletions

6
.gitignore vendored
View file

@ -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__/

175
admin/gear_items.php Normal file
View file

@ -0,0 +1,175 @@
<?php
/**
* Gear-Planer, Katalog: Gegenstaende von aion2hub.com (Global-Client) uebernehmen, einzeln oder
* alle mit der Quelle abgleichen (z.B. nach einem Patch) und Unterschiede pruefen.
*/
require_once __DIR__ . '/../includes/bootstrap.php';
require_once __DIR__ . '/../includes/gear.php';
require_permission('gear.manage');
$query = mb_substr(trim((string) ($_GET['q'] ?? '')), 0, 100);
$slotFilter = (string) ($_GET['slot'] ?? '');
$slotNames = db()->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';
?>
<div class="panel">
<h1>Gear-Planer: Gegenstände</h1>
<p class="text-muted">
Werte kommen von <a href="https://aion2hub.com/database" target="_blank" rel="noopener">aion2hub.com</a>
(aus dem Global-Client ausgelesen). Abgerufen wird immer nur eine Seite pro Sekunde und nur auf Knopfdruck.
<?php if ($lastVersion !== ''): ?>Zuletzt abgeglichener Stand: <strong><?= e($lastVersion) ?></strong>.<?php endif; ?>
</p>
<div class="gear-import" id="gear-import"
data-action="/admin/gear_items_action.php" data-csrf="<?= e(csrf_token()) ?>" data-all-ids="<?= e(json_encode($allIds)) ?>">
<h2>Übernehmen</h2>
<p class="text-muted">
Gegenstands-ID, Link zu einem Gegenstand (<code>aion2hub.com/database/items/110130060</code>) oder
eine Listen-Seite (z.B. <code>aion2hub.com/database?cat=Armor&amp;grade=Unique</code> - übernimmt
alle Gegenstände dieser Seite, bis zu 60).
</p>
<div class="gear-import-row">
<input type="text" id="gear-import-input" placeholder="ID oder aion2hub-Link …" aria-label="ID oder aion2hub-Link">
<label class="checkbox-label"><input type="checkbox" id="gear-import-skip" checked> schon vorhandene überspringen</label>
<button type="button" class="button" id="gear-import-start">Übernehmen</button>
</div>
<div class="gear-import-row">
<button type="button" class="button button-secondary" id="gear-check-all"<?= $allIds ? '' : ' disabled' ?>>
Alle <?= count($allIds) ?> abgleichen
</button>
<label class="checkbox-label"><input type="checkbox" id="gear-check-apply"> Änderungen gleich übernehmen</label>
<button type="button" class="button button-secondary" id="gear-import-stop" hidden>Anhalten</button>
</div>
<div class="gear-import-progress" id="gear-import-progress" hidden>
<div class="gear-progress-bar"><span id="gear-progress-fill"></span></div>
<div class="text-muted" id="gear-progress-text"></div>
<ol class="gear-import-log" id="gear-import-log"></ol>
</div>
</div>
</div>
<div class="panel">
<form class="list-toolbar" method="get" action="/admin/gear_items.php">
<div class="audit-search-row">
<label class="search-field">
<?= icon('search') ?>
<input type="search" name="q" value="<?= e($query) ?>" placeholder="Name oder ID suchen …" aria-label="Gegenstände durchsuchen">
</label>
<select name="slot" onchange="this.form.submit()" aria-label="Slot">
<option value="">Alle Slots</option>
<?php foreach ($slotNames as $slotName => $count): ?>
<option value="<?= e($slotName) ?>"<?= $slotFilter === $slotName ? ' selected' : '' ?>><?= e($slotName) ?> (<?= (int) $count ?>)</option>
<?php endforeach; ?>
</select>
</div>
<span class="list-search-count text-muted"><?= number_format($total, 0, ',', '.') ?> Gegenstände</span>
</form>
<?php if (!$items): ?>
<p class="text-muted"><?= $query !== '' || $slotFilter !== '' ? 'Nichts gefunden.' : 'Noch keine Gegenstände übernommen.' ?></p>
<?php else: ?>
<div class="table-scroll">
<table class="gear-admin-table">
<thead>
<tr>
<th>Gegenstand</th>
<th>Slot</th>
<th>Stufe</th>
<th>Sockel</th>
<th>Aufwertung</th>
<th>Geprüft</th>
<th>In Sets</th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($items as $item): ?>
<tr id="gear-item-<?= (int) $item['id'] ?>">
<td>
<span class="gear-compare-item">
<?php if ($url = gear_icon_url($item)): ?><img class="gear-icon <?= e(gear_grade_class($item['grade'])) ?>" src="<?= e($url) ?>" alt="" width="28" height="28" loading="lazy"><?php endif; ?>
<span>
<a class="<?= e(gear_grade_class($item['grade'])) ?>" href="<?= e(GEAR_SOURCE_ITEM_URL . (int) $item['id']) ?>" target="_blank" rel="noopener"><?= e($item['name']) ?></a>
<span class="text-muted gear-admin-sub">#<?= (int) $item['id'] ?> · <?= e(gear_stats_text($item['stats'])) ?></span>
</span>
</span>
</td>
<td><?= e($item['slot']) ?><?= $item['item_type'] !== $item['slot'] ? '<div class="text-muted">' . e($item['item_type']) . '</div>' : '' ?></td>
<td><?= (int) $item['item_level'] ?></td>
<td><?= (int) $item['manastone_slots'] ?><?= (int) $item['godstone_slots'] ? ' + ' . (int) $item['godstone_slots'] . ' G' : '' ?></td>
<td>
<?= (int) $item['enchant_max'] ? '+' . (int) $item['enchant_max'] : '–' ?>
<?= (int) $item['exceed_max'] ? ' · ⬆' . (int) $item['exceed_max'] : '' ?>
</td>
<td class="text-muted"><?= $item['checked_at'] ? e(date('d.m.Y', strtotime((string) $item['checked_at']))) : '–' ?></td>
<td><?= (int) $item['used'] ?></td>
<td class="gear-admin-actions">
<button type="button" class="button button-secondary button-small" data-gear-check="<?= (int) $item['id'] ?>">Abgleichen</button>
<form method="post" action="/admin/gear_items_action.php" onsubmit="return confirm('„<?= e(addslashes($item['name'])) ?>“ aus dem Katalog löschen?<?= (int) $item['used'] ? ' Er steckt in ' . (int) $item['used'] . ' Sets - die Slots werden leer.' : '' ?>');">
<?= csrf_field() ?>
<input type="hidden" name="action" value="delete">
<input type="hidden" name="id" value="<?= (int) $item['id'] ?>">
<button type="submit" class="icon-button" title="Löschen"><?= icon('trash') ?></button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php render_pagination($listUrl(), $page, $pageCount); ?>
<?php endif; ?>
</div>
<div class="modal-overlay" id="gear-diff-modal" hidden>
<div class="modal gear-diff-modal">
<button type="button" class="modal-close icon-button" title="Schließen"><?= icon('x') ?></button>
<h2 id="gear-diff-title">Abgleich</h2>
<div id="gear-diff-body"></div>
<div class="actions">
<button type="button" class="button" id="gear-diff-apply" hidden>Neue Werte übernehmen</button>
</div>
</div>
</div>
<script src="<?= e(asset_url('/assets/js/gear-admin.js')) ?>"></script>
<?php include __DIR__ . '/../includes/footer.php'; ?>

124
admin/gear_items_action.php Normal file
View file

@ -0,0 +1,124 @@
<?php
/**
* Gear-Planer, Katalog: Gegenstaende von aion2hub uebernehmen und abgleichen.
* Antwortet als JSON (Aufrufe aus assets/js/gear-admin.js), nur "delete" leitet zurueck.
*/
require_once __DIR__ . '/../includes/bootstrap.php';
require_once __DIR__ . '/../includes/gear.php';
require_permission('gear.manage');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
redirect('/admin/gear_items.php');
}
verify_csrf();
$userId = (int) current_user()['id'];
$action = (string) ($_POST['action'] ?? '');
/** JSON-Antwort und Ende. */
$respond = static function (array $data, int $status = 200): void {
http_response_code($status);
header('Content-Type: application/json; charset=UTF-8');
echo json_encode($data, JSON_UNESCAPED_UNICODE);
exit;
};
/**
* Hoechstens ein Abruf pro Sekunde (pro Sitzung) - aion2hub soll von uns nicht mehr merken als
* von jemandem, der sich durch die Seiten klickt.
*/
$politePause = static function (): void {
$last = (float) ($_SESSION['gear_source_last_fetch'] ?? 0);
$wait = 1.0 - (microtime(true) - $last);
if ($wait > 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);

View file

@ -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; }

View file

@ -2,6 +2,10 @@
* Schoenere Datei-Auswahl: macht aus jedem sichtbaren <input type="file"> 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 = '<svg viewBox="0 0 24 24" width="26" height="26" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">'
+ '<rect x="3" y="4" width="18" height="16" rx="3"/><circle cx="9" cy="10" r="2"/><path d="M21 16l-5-5-8 8"/></svg>';
// 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 =
'<div class="file-drop-body">' + ICON +
'<span class="file-drop-title">' + (multiple ? 'Bilder auswählen' : 'Bild auswählen') + '</span>' +
'<span class="file-drop-hint">oder hierher ziehen · PNG, JPG, GIF, WEBP</span>' +
'<span class="file-drop-hint">oder hierher ziehen' + (input.hasAttribute('data-paste') ? ' · Strg+V fügt kopierte Bilder ein' : '') + ' · PNG, JPG, GIF, WEBP</span>' +
'</div>' +
'<div class="file-drop-files" hidden></div>';
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);
}

218
assets/js/gear-admin.js Normal file
View file

@ -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 = '<thead><tr><th>Feld</th><th>Gespeichert</th><th>aion2hub jetzt</th></tr></thead>';
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; });
})();

72
assets/js/gear.js Normal file
View file

@ -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();
});
})();

View file

View file

@ -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).
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
<IfModule mod_php.c>
php_flag engine off
</IfModule>

View file

View file

@ -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.
<IfModule mod_php.c>
php_flag engine off
</IfModule>
<IfModule mod_php7.c>
php_flag engine off
</IfModule>
<FilesMatch "\.(php|phtml|php[0-9]?|phar|cgi|pl)$">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
</FilesMatch>

View file

@ -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');

32
bug_image.php Normal file
View file

@ -0,0 +1,32 @@
<?php
/**
* Liefert ein Bild einer Fehlermeldung aus - nur an den Melder selbst und an die Leitung
* (bugs.manage). Der Ordner assets/uploads/bugs/ ist direkt nicht abrufbar.
*/
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/bugs.php';
require_login();
$stmt = db()->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);

View file

@ -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';
<div class="report-card-body">
<div class="report-reason-text"><?= e($bug['description']) ?></div>
<?= bug_images_html($bugImages[(int) $bug['id']] ?? [], (int) $bug['id']) ?>
<?php if (!empty($bug['screenshot_url'])): ?>
<div class="report-evidence">
<?= icon('link') ?>
@ -145,4 +147,5 @@ include __DIR__ . '/includes/header.php';
<?php endforeach; ?>
</div>
<?php endif; ?>
<script src="<?= e(asset_url('/assets/js/lightbox.js')) ?>" defer></script>
<?php include __DIR__ . '/includes/footer.php'; ?>

View file

@ -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';
</div>
<?php endif; ?>
<div class="dashboard-points-links">
<a class="button button-secondary" href="/contributions.php">Rangliste &amp; Verlauf</a>
<a class="button button-secondary dashboard-cta" href="/contributions.php"><?= icon('list') ?><span>Rangliste &amp; Verlauf</span></a>
<?php if ($canViewShop): ?>
<a class="button" href="/shop.php">Zum Lumishop</a>
<a class="button dashboard-cta dashboard-cta-primary" href="/shop.php"><?= icon('bag') ?><span>Zum Lumishop</span></a>
<?php endif; ?>
</div>
</div>
@ -180,13 +184,14 @@ include __DIR__ . '/includes/header.php';
<div class="panel">
<div class="card-grid">
<?php if ($canViewRaids): ?>
<div class="panel stat-card">
<a class="panel stat-card stat-card-link" href="/raids.php" title="Zu den Raids">
<div class="icon-badge"><?= icon('calendar') ?></div>
<div>
<h3><?= count($upcomingRaids) ?></h3>
<p class="text-muted">Anstehende Raids</p>
</div>
</div>
<span class="stat-card-arrow" aria-hidden="true">&rarr;</span>
</a>
<?php endif; ?>
<?php if ($canViewUsers): ?>
<div class="panel stat-card">
@ -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';
?>
<tr>
<td><a href="/raids.php"><?= e($title) ?></a></td>
<td class="text-muted"><?= e($dateLabel) ?></td>
<td><a href="/raids.php#raid-<?= (int) ($raid['raid_id'] ?? 0) ?>"><?= e($title) ?></a></td>
<td class="text-muted">
<a class="raid-calendar-link" href="<?= e($calendarUrl) ?>" title="Im Kalender ansehen"><?= icon('calendar') ?><?= e($dateLabel) ?></a>
</td>
<td><?= $activeCount ?> / <?= $maxSlots ?></td>
<td>
<?php if ($mySignup): ?>
@ -333,7 +343,7 @@ include __DIR__ . '/includes/header.php';
</span>
<span class="button button-secondary button-small bug-report-toggle">Fehler melden</span>
</summary>
<form method="post" action="/bug_action.php" class="bug-form">
<form method="post" action="/bug_action.php" class="bug-form" enctype="multipart/form-data">
<?= csrf_field() ?>
<input type="hidden" name="action" value="create">
<div class="bug-form-row">
@ -360,7 +370,13 @@ include __DIR__ . '/includes/header.php';
<div class="field-hint">Je genauer, desto schneller finden wir den Fehler. Browser und Gerät werden automatisch mitgeschickt.</div>
</div>
<div>
<label for="bug-screenshot">Link zu einem Screenshot (optional)</label>
<label for="bug-images">Bilder anhängen (optional)</label>
<input type="file" id="bug-images" name="images[]" accept="image/png,image/jpeg,image/gif,image/webp" multiple
data-max-size="1920" data-paste data-max-files="<?= BUG_MAX_IMAGES ?>">
<div class="field-hint">Bis zu <?= BUG_MAX_IMAGES ?> Screenshots, je höchstens 8 MB. Kopierte Bilder einfach mit <kbd>Strg</kbd>+<kbd>V</kbd> einfügen. Nur du und die Leitung sehen die Bilder.</div>
</div>
<div>
<label for="bug-screenshot">Oder Link zu einem Screenshot (optional)</label>
<input type="text" id="bug-screenshot" name="screenshot_url" maxlength="500"
placeholder="https://… (z.B. Bild aus Discord kopieren)"
value="<?= e((string) ($bugForm['screenshot'] ?? '')) ?>">
@ -383,6 +399,7 @@ include __DIR__ . '/includes/header.php';
<div class="text-muted bug-my-meta">
<?= e(bug_area_label($bug['area'])) ?> · gemeldet am <?= e(date('d.m.Y H:i', strtotime($bug['created_at']))) ?>
</div>
<?= bug_images_html($myBugImages[(int) $bug['id']] ?? [], (int) $bug['id']) ?>
<?php if (!empty($bug['admin_note'])): ?>
<div class="bug-admin-note"><strong>Antwort der Leitung:</strong> <?= e($bug['admin_note']) ?></div>
<?php endif; ?>
@ -438,4 +455,5 @@ if (empty($user['tour_completed_at'])):
<script src="<?= e(asset_url('/assets/js/tour.js')) ?>" defer></script>
<?php endif; ?>
<?php if ($myBugImages): ?><script src="<?= e(asset_url('/assets/js/lightbox.js')) ?>" defer></script><?php endif; ?>
<?php include __DIR__ . '/includes/footer.php'; ?>

523
gear.php Normal file
View file

@ -0,0 +1,523 @@
<?php
/**
* Gear-Planer: eigene Ausruestungssets zusammenstellen und vergleichen.
* /gear.php Uebersicht der eigenen Sets
* /gear.php?set=ID[&slot=KEY] ein Set (eigene bearbeitbar, fremde nur wenn aufs Profil freigegeben)
* /gear.php?compare[]=ID&… 2-4 Sets nebeneinander
*/
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/gear.php';
require_permission('gear.view');
$me = current_user();
$userId = (int) $me['id'];
$canManage = user_has_permission('gear.manage');
$catalogCount = (int) db()->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 '<span class="gear-icon gear-icon-empty" style="width:' . $size . 'px;height:' . $size . 'px"></span>';
}
return '<img class="gear-icon ' . e(gear_grade_class($item['grade'] ?? null)) . '" src="' . e($url) . '" alt="" width="' . $size . '" height="' . $size . '" loading="lazy">';
};
$pageTitle = $set ? $set['name'] . ' - Gear-Planer' : 'Gear-Planer';
$containerWide = true;
include __DIR__ . '/includes/header.php';
?>
<div class="panel gear-head">
<div>
<h1>Gear-Planer</h1>
<p class="text-muted">
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 <span class="gear-estimated">≈</span> sind für Zwischenstufen hochgerechnet.
</p>
</div>
<div class="gear-head-actions">
<?php if ($set || $compare): ?>
<a class="button button-secondary button-small" href="/gear.php">Meine Sets</a>
<?php endif; ?>
<?php if ($canManage): ?>
<a class="button button-secondary button-small" href="/admin/gear_items.php"><?= icon('list') ?> Gegenstände verwalten</a>
<?php endif; ?>
</div>
</div>
<?php if ($catalogCount === 0): ?>
<div class="panel gear-empty">
<p><strong>Noch keine Gegenstände im Katalog.</strong></p>
<p class="text-muted">
<?= $canManage
? 'Übernimm zuerst Gegenstände von aion2hub - danach lassen sie sich in die Sets einsetzen.'
: 'Die Leitung muss erst die Gegenstände übernehmen. Sets anlegen kannst du trotzdem schon.' ?>
</p>
<?php if ($canManage): ?><a class="button" href="/admin/gear_items.php">Gegenstände übernehmen</a><?php endif; ?>
</div>
<?php endif; ?>
<?php if ($compare): ?>
<?php
// ---- Vergleich ----
$compareSlots = gear_slots_for_sets(array_column($compare, 'id'));
$compareTotals = [];
$allKeys = [];
foreach ($compare as $c) {
$compareTotals[(int) $c['id']] = gear_set_totals($compareSlots[(int) $c['id']] ?? []);
foreach ($compareTotals[(int) $c['id']] as $key => $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'];
?>
<div class="panel">
<h2>Vergleich</h2>
<p class="text-muted">Unterschiede beziehen sich immer auf das erste Set (links).</p>
<div class="table-scroll">
<table class="gear-compare">
<thead>
<tr>
<th></th>
<?php foreach ($compare as $c): ?>
<th>
<a href="/gear.php?set=<?= (int) $c['id'] ?>"><?= e($c['name']) ?></a>
<?= class_badge_html($c['class_name'], 18) ?>
<?php if ((int) $c['user_id'] !== $userId): ?><div class="text-muted gear-compare-owner"><?= e($c['owner_name']) ?></div><?php endif; ?>
</th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<tr class="gear-compare-group"><th colspan="<?= count($compare) + 1 ?>">Werte</th></tr>
<?php foreach ($allKeys as $key => $meta): ?>
<?php $base = $compareTotals[$first][$key]['total'] ?? 0.0; ?>
<tr>
<th><?= e($meta['name']) ?></th>
<?php foreach ($compare as $index => $c): ?>
<?php $row = $compareTotals[(int) $c['id']][$key] ?? null; $value = $row['total'] ?? 0.0; $diff = $value - $base; ?>
<td>
<?= $row ? ($row['estimated'] ? '<span class="gear-estimated" title="enthält hochgerechnete Zwischenstufen">≈</span>' : '') . e(gear_format_value($value, $meta['unit'])) : '<span class="text-muted">–</span>' ?>
<?php if ($index > 0 && abs($diff) > 0.001): ?>
<span class="gear-diff <?= $diff > 0 ? 'is-up' : 'is-down' ?>"><?= $diff > 0 ? '+' : '−' ?><?= e(gear_format_value(abs($diff), $meta['unit'])) ?></span>
<?php endif; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
<tr class="gear-compare-group"><th colspan="<?= count($compare) + 1 ?>">Ausrüstung</th></tr>
<?php foreach (GEAR_SLOTS as $slotKey => [$slotLabel]): ?>
<tr>
<th><?= e($slotLabel) ?></th>
<?php foreach ($compare as $c): ?>
<?php $row = $compareSlots[(int) $c['id']][$slotKey] ?? null; ?>
<td>
<?php if ($row && $row['item']): ?>
<span class="gear-compare-item">
<?= $itemIcon($row['item'], 24) ?>
<span class="<?= e(gear_grade_class($row['item']['grade'])) ?>"><?= e($row['item']['name']) ?></span>
<span class="text-muted"><?= e(implode(' · ', $slotTags($row))) ?></span>
</span>
<?php else: ?>
<span class="text-muted">–</span>
<?php endif; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php elseif ($set): ?>
<?php $totals = gear_set_totals($slots); $itemLevel = gear_set_item_level($slots); ?>
<div class="panel gear-set-head">
<div class="gear-set-title">
<h2><?= e($set['name']) ?> <?= class_badge_html($set['class_name'], 26) ?></h2>
<div class="text-muted">
<?php if (!$isOwn): ?>Set von <?= e($set['owner_name']) ?> · <?php endif; ?>
<?= count(array_filter($slots, static fn (array $row): bool => !empty($row['item']))) ?>/<?= count(GEAR_SLOTS) ?> Slots belegt
<?php if ($itemLevel !== null): ?> · Ø Gegenstandsstufe <?= e(number_format($itemLevel, 1, ',', '.')) ?><?php endif; ?>
<?php if ($isOwn && $set['show_on_profile']): ?> · <span class="badge">auf dem Profil sichtbar</span><?php endif; ?>
</div>
<?php if (!empty($set['note'])): ?><p><?= e($set['note']) ?></p><?php endif; ?>
</div>
<div class="gear-set-actions">
<?php if ($isOwn): ?>
<button type="button" class="button button-secondary button-small" data-modal-open="gear-set-edit"><?= icon('edit') ?> Bearbeiten</button>
<form method="post" action="/gear_action.php">
<?= csrf_field() ?>
<input type="hidden" name="action" value="duplicate">
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
<button type="submit" class="button button-secondary button-small">Kopieren</button>
</form>
<?php endif; ?>
<?php $compareWith = array_values(array_filter($mySets, static fn (array $s): bool => (int) $s['id'] !== (int) $set['id'])); ?>
<?php if ($compareWith): ?>
<form method="get" action="/gear.php" class="gear-compare-with">
<input type="hidden" name="compare[]" value="<?= (int) $set['id'] ?>">
<select name="compare[]" aria-label="Vergleichen mit" onchange="this.form.submit()">
<option value="">Vergleichen mit …</option>
<?php foreach ($compareWith as $other): ?>
<option value="<?= (int) $other['id'] ?>"><?= e($other['name']) ?></option>
<?php endforeach; ?>
</select>
</form>
<?php endif; ?>
</div>
</div>
<div class="gear-layout<?= $activeSlot !== '' ? ' has-editor' : '' ?>">
<div class="panel gear-slots-panel">
<?php foreach (['Waffen', 'Rüstung', 'Schmuck'] as $group): ?>
<h3 class="gear-group-title"><?= e($group) ?></h3>
<div class="gear-slot-grid">
<?php foreach (GEAR_SLOTS as $slotKey => [$slotLabel, $slotGroup]): ?>
<?php if ($slotGroup !== $group) continue; ?>
<?php $row = $slots[$slotKey] ?? null; $item = $row['item'] ?? null; ?>
<a class="gear-slot<?= $item ? ' is-filled ' . e(gear_grade_class($item['grade'])) : '' ?><?= $slotKey === $activeSlot ? ' is-active' : '' ?>"
href="/gear.php?set=<?= (int) $set['id'] ?>&amp;slot=<?= e($slotKey) ?>#slot">
<?= $itemIcon($item, 42) ?>
<span class="gear-slot-body">
<span class="gear-slot-label"><?= e($slotLabel) ?></span>
<span class="gear-slot-name"><?= $item ? e($item['name']) : ($isOwn ? 'leer – auswählen' : 'leer') ?></span>
<?php if ($item): ?><span class="gear-slot-tags"><?= e(implode(' · ', $slotTags($row))) ?></span><?php endif; ?>
</span>
</a>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
<?php if ($activeSlot !== ''): ?>
<div class="gear-side">
<div class="panel gear-slot-editor" id="slot">
<h3><?= e(GEAR_SLOTS[$activeSlot][0]) ?></h3>
<?php if ($activeItem): ?>
<div class="gear-item-card">
<?= $itemIcon($activeItem, 48) ?>
<div>
<strong class="<?= e(gear_grade_class($activeItem['grade'])) ?>"><?= e($activeItem['name']) ?></strong>
<div class="text-muted">
<?= e($activeItem['grade']) ?> · Stufe <?= (int) $activeItem['item_level'] ?>
<?= $activeItem['item_type'] !== $activeItem['slot'] ? ' · ' . e($activeItem['item_type']) : '' ?>
· <a href="<?= e(GEAR_SOURCE_ITEM_URL . (int) $activeItem['id']) ?>" target="_blank" rel="noopener">aion2hub</a>
</div>
<div class="gear-item-stats"><?= e(gear_stats_text($activeItem['stats'])) ?></div>
</div>
</div>
<?php endif; ?>
<?php if ($isOwn): ?>
<?php $pickerItems = gear_picker_items($activeSlot); ?>
<form method="post" action="/gear_action.php" class="gear-slot-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="save_slot">
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
<input type="hidden" name="slot" value="<?= e($activeSlot) ?>">
<div>
<label for="gear-item-search">Gegenstand</label>
<div class="item-picker" data-picker-items="gear-picker" data-picker-mode="id" data-picker-empty="Nichts gefunden - fehlt ein Gegenstand, sag der Leitung Bescheid.">
<label class="search-field">
<span class="item-picker-icon"><?= icon('search') ?></span>
<input type="text" class="item-picker-input" id="gear-item-search" required placeholder="<?= $pickerItems ? 'Gegenstand suchen …' : 'Noch keine Gegenstände für diesen Slot' ?>">
</label>
<input type="hidden" name="item_id" value="<?= $activeItem ? (int) $activeItem['id'] : '' ?>">
</div>
<script type="application/json" id="gear-picker"><?= json_encode($pickerItems, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP) ?></script>
</div>
<?php if ($activeItem): ?>
<div class="gear-form-row">
<?php if ((int) $activeItem['enchant_max'] > 0): ?>
<label>Aufwertung
<select name="enchant">
<?php for ($level = 0; $level <= (int) $activeItem['enchant_max']; $level++): ?>
<option value="<?= $level ?>"<?= (int) $activeRow['enchant'] === $level ? ' selected' : '' ?>>+<?= $level ?></option>
<?php endfor; ?>
</select>
</label>
<?php endif; ?>
<?php if ((int) $activeItem['exceed_max'] > 0): ?>
<label>Durchbruch
<select name="exceed">
<?php for ($level = 0; $level <= (int) $activeItem['exceed_max']; $level++): ?>
<option value="<?= $level ?>"<?= (int) $activeRow['exceed'] === $level ? ' selected' : '' ?>><?= $level ?></option>
<?php endfor; ?>
</select>
</label>
<?php endif; ?>
</div>
<?php if ($activeItem['enchant_stats']): ?>
<p class="gear-hint text-muted">
Bei +<?= (int) $activeItem['enchant_max'] ?>: <?= e(gear_stats_text($activeItem['enchant_stats'])) ?>
<?php if ($activeItem['exceed_stats']): ?><br>Durchbruch <?= (int) $activeItem['exceed_max'] ?>: <?= e(gear_stats_text($activeItem['exceed_stats'])) ?><?php endif; ?>
</p>
<?php endif; ?>
<?php if ((int) $activeItem['soul_imprint_count'] > 0): ?>
<fieldset class="gear-fieldset">
<legend>Seelenprägung <span class="text-muted">(bis zu <?= (int) $activeItem['soul_imprint_count'] ?>, wie im Spiel gewürfelt)</span></legend>
<?php for ($i = 0; $i < (int) $activeItem['soul_imprint_count']; $i++): ?>
<?php $entry = $activeRow['soul_imprint'][$i] ?? null; ?>
<div class="gear-roll-row">
<select name="soul_stat[]" aria-label="Seelenprägung <?= $i + 1 ?>" data-range-select>
<option value="">– keine –</option>
<?php foreach ($activeItem['soul_imprint'] as [$stat, $min, $max, $unit]): ?>
<option value="<?= e($stat) ?>" data-min="<?= e((string) $min) ?>" data-max="<?= e((string) $max) ?>" data-unit="<?= e($unit) ?>"<?= $entry && $entry[0] === $stat ? ' selected' : '' ?>>
<?= e($stat) ?> (<?= e(gear_format_value((float) $min, $unit)) ?>–<?= e(gear_format_value((float) $max, $unit)) ?>)
</option>
<?php endforeach; ?>
</select>
<input type="text" inputmode="decimal" name="soul_value[]" value="<?= $entry ? e(str_replace('.', ',', (string) $entry[1])) : '' ?>" placeholder="Wert" aria-label="Wert Seelenprägung <?= $i + 1 ?>">
</div>
<?php endfor; ?>
</fieldset>
<?php endif; ?>
<?php if ((int) $activeItem['manastone_slots'] > 0): ?>
<?php $manastoneStats = gear_manastone_stats(); ?>
<fieldset class="gear-fieldset">
<legend>Manasteine <span class="text-muted">(<?= (int) $activeItem['manastone_slots'] ?> Sockel)</span></legend>
<?php for ($i = 0; $i < (int) $activeItem['manastone_slots']; $i++): ?>
<?php $entry = $activeRow['manastones'][$i] ?? null; ?>
<div class="gear-roll-row">
<select name="mana_stat[]" aria-label="Manastein <?= $i + 1 ?>">
<option value="">– leer –</option>
<?php foreach ($manastoneStats as $stat): ?>
<option value="<?= e($stat) ?>"<?= $entry && $entry[0] === $stat ? ' selected' : '' ?>><?= e($stat) ?></option>
<?php endforeach; ?>
</select>
<input type="text" inputmode="numeric" name="mana_value[]" value="<?= $entry ? (int) $entry[1] : '' ?>" placeholder="Wert" aria-label="Wert Manastein <?= $i + 1 ?>">
</div>
<?php endfor; ?>
</fieldset>
<?php endif; ?>
<?php if ((int) $activeItem['godstone_slots'] > 0): ?>
<label>Götterstein <span class="text-muted">(nur zur Info, zählt nicht in die Werte)</span>
<input type="text" name="godstone" maxlength="100" value="<?= e((string) ($activeRow['godstone'] ?? '')) ?>" placeholder="z.B. Götterstein: …">
</label>
<?php endif; ?>
<p class="gear-hint text-muted">Wechselst du den Gegenstand, werden Seelenprägung und Manasteine zurückgesetzt.</p>
<?php endif; ?>
<div class="actions">
<button type="submit" class="button">Speichern</button>
<a class="button button-secondary" href="/gear.php?set=<?= (int) $set['id'] ?>">Schließen</a>
</div>
</form>
<?php if ($activeItem): ?>
<form method="post" action="/gear_action.php" class="gear-clear-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="clear_slot">
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
<input type="hidden" name="slot" value="<?= e($activeSlot) ?>">
<button type="submit" class="button button-secondary button-small">Slot leeren</button>
</form>
<?php endif; ?>
<?php elseif ($activeItem): ?>
<dl class="gear-detail-list">
<?php if ((int) $activeItem['enchant_max'] > 0): ?><div><dt>Aufwertung</dt><dd>+<?= (int) $activeRow['enchant'] ?> von +<?= (int) $activeItem['enchant_max'] ?></dd></div><?php endif; ?>
<?php if ((int) $activeItem['exceed_max'] > 0): ?><div><dt>Durchbruch</dt><dd><?= (int) $activeRow['exceed'] ?> von <?= (int) $activeItem['exceed_max'] ?></dd></div><?php endif; ?>
<?php if ($activeRow['soul_imprint']): ?>
<div><dt>Seelenprägung</dt><dd><?= e(implode(', ', array_map(static fn (array $s): string => $s[0] . ' ' . str_replace('.', ',', (string) $s[1]), $activeRow['soul_imprint']))) ?></dd></div>
<?php endif; ?>
<?php if ($activeRow['manastones']): ?>
<div><dt>Manasteine</dt><dd><?= e(implode(', ', array_map(static fn (array $s): string => $s[0] . ' ' . (int) $s[1], $activeRow['manastones']))) ?></dd></div>
<?php endif; ?>
<?php if (!empty($activeRow['godstone'])): ?><div><dt>Götterstein</dt><dd><?= e((string) $activeRow['godstone']) ?></dd></div><?php endif; ?>
</dl>
<?php else: ?>
<p class="text-muted">Dieser Slot ist leer.</p>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>
<div class="panel gear-totals">
<h3>Werte gesamt</h3>
<?php if (!$totals): ?>
<p class="text-muted">Noch keine Gegenstände eingesetzt.</p>
<?php else: ?>
<?php $usedSources = array_keys(array_filter(GEAR_SOURCES, static fn (string $label, string $source): bool => (bool) array_filter($totals, static fn (array $t): bool => isset($t['by'][$source])), ARRAY_FILTER_USE_BOTH)); ?>
<div class="table-scroll">
<table class="gear-totals-table">
<thead>
<tr>
<th>Wert</th>
<th class="gear-total-col">Gesamt</th>
<?php foreach ($usedSources as $source): ?><th class="gear-source-col"><?= e(GEAR_SOURCES[$source]) ?></th><?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($totals as $row): ?>
<tr>
<th><?= e($row['name']) ?></th>
<td class="gear-total-col">
<?php if ($row['estimated']): ?><span class="gear-estimated" title="enthält hochgerechnete Zwischenstufen">≈</span><?php endif; ?>
<?= e(gear_format_value($row['total'], $row['unit'])) ?>
</td>
<?php foreach ($usedSources as $source): ?>
<td class="gear-source-col"><?= isset($row['by'][$source]) ? e(gear_format_value($row['by'][$source], $row['unit'])) : '<span class="text-muted">–</span>' ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<p class="gear-hint text-muted">Einfache Summe aller Gegenstände - Klassen- und Charakterwerte, Set-Boni und Götterstein sind nicht enthalten.</p>
<?php endif; ?>
</div>
<?php if ($isOwn): ?>
<div class="modal-overlay" id="gear-set-edit" hidden>
<div class="modal">
<button type="button" class="modal-close icon-button" title="Schließen"><?= icon('x') ?></button>
<h2>Set bearbeiten</h2>
<form method="post" action="/gear_action.php">
<?= csrf_field() ?>
<input type="hidden" name="action" value="update">
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
<label>Name <input type="text" name="name" maxlength="80" required value="<?= e($set['name']) ?>"></label>
<label>Klasse
<select name="class_name">
<option value="">– keine –</option>
<?php foreach (AION_CLASSES as $class): ?>
<option value="<?= e($class) ?>"<?= $set['class_name'] === $class ? ' selected' : '' ?>><?= e($class) ?></option>
<?php endforeach; ?>
</select>
</label>
<label>Notiz <input type="text" name="note" maxlength="255" value="<?= e((string) $set['note']) ?>" placeholder="z.B. PvP, Raid, Ziel-Ausrüstung …"></label>
<label class="checkbox-label"><input type="checkbox" name="show_on_profile" value="1"<?= $set['show_on_profile'] ? ' checked' : '' ?>> Auf meiner Profilseite zeigen</label>
<div class="actions">
<button type="submit" class="button">Speichern</button>
</div>
</form>
<form method="post" action="/gear_action.php" onsubmit="return confirm('Set „<?= e(addslashes($set['name'])) ?>“ wirklich löschen?');" class="gear-delete-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="delete">
<input type="hidden" name="set_id" value="<?= (int) $set['id'] ?>">
<button type="submit" class="button button-danger button-small"><?= icon('trash') ?> Set löschen</button>
</form>
</div>
</div>
<?php endif; ?>
<?php else: ?>
<?php // ---- Uebersicht der eigenen Sets ---- ?>
<div class="panel">
<div class="gear-overview-head">
<h2>Meine Sets</h2>
<form method="post" action="/gear_action.php" class="gear-create-form">
<?= csrf_field() ?>
<input type="hidden" name="action" value="create">
<input type="text" name="name" maxlength="80" required placeholder="Name, z.B. Raid-Set" aria-label="Name des neuen Sets">
<select name="class_name" aria-label="Klasse">
<?php foreach (AION_CLASSES as $class): ?>
<option value="<?= e($class) ?>"<?= ($me['class_name'] ?? '') === $class ? ' selected' : '' ?>><?= e($class) ?></option>
<?php endforeach; ?>
</select>
<button type="submit" class="button">Neues Set</button>
</form>
</div>
<?php if (!$mySets): ?>
<p class="text-muted">Du hast noch kein Set. Leg oben eins an - z.B. deine aktuelle Ausrüstung und ein Ziel-Set zum Vergleichen.</p>
<?php else: ?>
<form method="get" action="/gear.php" id="gear-compare-form">
<div class="gear-set-cards">
<?php foreach ($mySets as $s): ?>
<?php $sSlots = $mySlots[(int) $s['id']] ?? []; $sLevel = gear_set_item_level($sSlots); ?>
<article class="gear-set-card">
<label class="gear-set-card-check" title="Zum Vergleich auswählen">
<input type="checkbox" name="compare[]" value="<?= (int) $s['id'] ?>">
</label>
<a class="gear-set-card-link" href="/gear.php?set=<?= (int) $s['id'] ?>">
<span class="gear-set-card-title"><?= e($s['name']) ?> <?= class_badge_html($s['class_name'], 20) ?></span>
<span class="text-muted">
<?= count(array_filter($sSlots, static fn (array $row): bool => !empty($row['item']))) ?>/<?= count(GEAR_SLOTS) ?> Slots
<?php if ($sLevel !== null): ?> · Ø Stufe <?= e(number_format($sLevel, 1, ',', '.')) ?><?php endif; ?>
<?php if ($s['show_on_profile']): ?> · auf dem Profil<?php endif; ?>
</span>
<span class="gear-set-card-icons">
<?php foreach (GEAR_SLOTS as $slotKey => $unused): ?>
<?php if (!empty($sSlots[$slotKey]['item'])): ?><?= $itemIcon($sSlots[$slotKey]['item'], 26) ?><?php endif; ?>
<?php endforeach; ?>
</span>
<?php if (!empty($s['note'])): ?><span class="gear-set-card-note"><?= e($s['note']) ?></span><?php endif; ?>
</a>
</article>
<?php endforeach; ?>
</div>
<?php if (count($mySets) > 1): ?>
<div class="actions gear-compare-bar">
<button type="submit" class="button button-secondary" id="gear-compare-button" disabled>Ausgewählte vergleichen</button>
<span class="text-muted">2–4 Sets anhaken</span>
</div>
<?php endif; ?>
</form>
<?php endif; ?>
</div>
<?php endif; ?>
<script src="<?= e(asset_url('/assets/js/item-picker.js')) ?>"></script>
<script src="<?= e(asset_url('/assets/js/gear.js')) ?>"></script>
<?php include __DIR__ . '/includes/footer.php'; ?>

212
gear_action.php Normal file
View file

@ -0,0 +1,212 @@
<?php
/**
* Gear-Planer: Sets anlegen, bearbeiten, kopieren, loeschen und Slots belegen. Jedes Mitglied
* bearbeitet nur seine eigenen Sets.
*/
require_once __DIR__ . '/includes/bootstrap.php';
require_once __DIR__ . '/includes/gear.php';
require_permission('gear.view');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
redirect('/gear.php');
}
verify_csrf();
$me = current_user();
$userId = (int) $me['id'];
$pdo = db();
$action = (string) ($_POST['action'] ?? '');
/** Eigenes Set laden oder mit Meldung zurueck. */
$ownSet = static function () use ($userId): array {
$set = gear_set((int) ($_POST['set_id'] ?? 0));
if (!$set || (int) $set['user_id'] !== $userId) {
set_flash('error', 'Dieses Set gibt es nicht (mehr).');
redirect('/gear.php');
}
return $set;
};
$cleanName = static fn (string $value): string => 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');

View file

@ -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<string, mixed> $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<int, array<int, 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 = '<div class="bug-images">';
foreach ($images as $i => $image) {
$url = e(bug_image_url((int) $image['id']));
$html .= '<a href="' . $url . '" data-lightbox="bug-' . $bugId . '" data-caption="Bild ' . ($i + 1) . ' von ' . count($images) . '">'
. '<img src="' . $url . '" alt="Bild ' . ($i + 1) . ' zur Fehlermeldung" loading="lazy"></a>';
}
return $html . '</div>';
}
/** 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);
}
}
}

View file

@ -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

View file

@ -144,6 +144,7 @@ function icon(string $name): string
'sort' => '<path d="M7 4v16"/><polyline points="3 8 7 4 11 8"/><path d="M17 20V4"/><polyline points="13 16 17 20 21 16"/>',
'book' => '<path d="M4 19.5V5a2 2 0 0 1 2-2h13v16H6.5A2.5 2.5 0 0 0 4 21.5v-2z"/><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H19"/><line x1="8" y1="7" x2="15" y2="7"/><line x1="8" y1="11" x2="13" y2="11"/>',
'code' => '<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>',
'sword' => '<path d="M14.5 17.5 3 6V3h3l11.5 11.5"/><path d="m13 19 6-6"/><path d="m16 16 4 4"/><path d="m19 21 2-2"/>',
'bug' => '<rect x="8" y="6" width="8" height="14" rx="4"/><path d="M19 7l-3 2"/><path d="M5 7l3 2"/><path d="M19 19l-3-2"/><path d="M5 19l3-2"/><path d="M20 13h-4"/><path d="M4 13h4"/><path d="M10 4l1 2"/><path d="M14 4l-1 2"/>',
'shield-check' => '<path d="M12 21c4.5-1.8 7-5.2 7-9.5V6l-7-3-7 3v5.5c0 4.3 2.5 7.7 7 9.5z"/><polyline points="9 12 11.2 14.2 15.5 9.8"/>',
];

459
includes/gear.php Normal file
View file

@ -0,0 +1,459 @@
<?php
declare(strict_types=1);
/**
* Gear-Planer: persoenliche Ausruestungssets (Gegenstand je Slot, Aufwertung, Durchbruch,
* Seelenpraegung, Manasteine) und der Katalog der Gegenstaende mit ihren Werten.
*
* Der Katalog kommt von aion2hub.com (Global-Client, siehe includes/gear_source.php) und wird
* von Admins unter /admin/gear_items.php uebernommen und abgeglichen. Verlaesslich sind die
* Grundwerte, die Sockel und die Werte bei maximaler Aufwertung/Durchbruch - Zwischenstufen
* rechnen wir gleichmaessig hoch und kennzeichnen sie als geschaetzt (≈). Seelenpraegung und
* Manasteine sind im Spiel zufaellig, die traegt jedes Mitglied so ein, wie sie gewuerfelt wurden.
*/
require_once __DIR__ . '/gear_source.php';
const GEAR_ICON_DIR = __DIR__ . '/../assets/uploads/gear/';
const GEAR_ICON_URL = '/assets/uploads/gear/';
const GEAR_MAX_SETS = 20;
/**
* Slots eines Sets: Schluessel => [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<int, 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<int, array{0: string, 1: float, 2: string, 3: bool}> [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<int, array{source: string, name: string, value: float, unit: string, estimated: bool}>
*/
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<string, array{name: string, unit: string, total: float, by: array<string, float>, 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<int, 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<int, array<string, 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);
}

226
includes/gear_source.php Normal file
View file

@ -0,0 +1,226 @@
<?php
declare(strict_types=1);
/**
* Gear-Planer: Werte der Gegenstaende von aion2hub.com holen und auslesen.
*
* aion2hub liest die Werte direkt aus dem Spielclient aus (Global-Client). Abgerufen wird nur
* auf Knopfdruck eines Admins und immer nur eine Seite auf einmal (siehe admin/gear_items.php) -
* die Schnittstelle /api/ der Seite ist fuer Bots gesperrt, die normalen Seiten und die Icons
* (/api/icon/) sind erlaubt.
*/
const GEAR_SOURCE_HOST = 'aion2hub.com';
const GEAR_SOURCE_ITEM_URL = 'https://aion2hub.com/database/items/';
const GEAR_SOURCE_ICON_URL = 'https://aion2hub.com/api/icon/items/';
const GEAR_SOURCE_AGENT = 'LuminaAscendensGearPlanner/1.0 (+Legion-Website, einzelne Abrufe auf Knopfdruck)';
/** Laedt eine Seite von aion2hub (nur dieser Host, kein Weiterleiten auf andere Seiten). */
function gear_source_fetch(string $url): string
{
$host = strtolower((string) parse_url($url, PHP_URL_HOST));
if (parse_url($url, PHP_URL_SCHEME) !== 'https' || ($host !== GEAR_SOURCE_HOST && $host !== 'www.' . GEAR_SOURCE_HOST)) {
throw new RuntimeException('Nur Adressen von ' . GEAR_SOURCE_HOST . ' sind erlaubt.');
}
if (!function_exists('curl_init')) {
throw new RuntimeException('Die PHP-cURL-Erweiterung ist auf diesem Server nicht aktiviert.');
}
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => 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.*?</\1>#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 / <Kategorie> / <Name> / Copy link / <Seltenheit> / 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;
}

View file

@ -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 => ($
</a>
<?php endif; ?>
<?php if ($canViewRaids || $canViewPremades || $canViewEvents || $canViewMap || $canViewWarehouse): ?>
<?php if ($canViewRaids || $canViewPremades || $canViewEvents || $canViewMap || $canViewWarehouse || $canViewGear): ?>
<div class="sidebar-nav-gap"></div>
<?php endif; ?>
<?php if ($canViewRaids): ?>
@ -242,6 +246,11 @@ $otherFlashes = array_values(array_filter($allFlashes, fn (array $f): bool => ($
<?= icon('map') ?><span class="label">Karte</span>
</a>
<?php endif; ?>
<?php if ($canViewGear): ?>
<a href="/gear.php" class="sidebar-link<?= $isGearActive ? ' active' : '' ?>" title="Gear-Planer">
<?= icon('sword') ?><span class="label">Gear-Planer</span>
</a>
<?php endif; ?>
<?php if ($canViewWarehouse): ?>
<a href="/warehouse.php" class="sidebar-link<?= $isWarehouseActive ? ' active' : '' ?>" title="Lagerhaus">
<?= icon('box') ?><span class="label">Lagerhaus</span>

View file

@ -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'],

View file

@ -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} */

View file

@ -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>)
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

View file

@ -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) {

View file

@ -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';
</div>
<?php endif; ?>
<?php if (!empty($gearSets)): ?>
<div class="panel">
<h2>Ausrüstung</h2>
<div class="gear-set-cards">
<?php foreach ($gearSets as $gear): ?>
<article class="gear-set-card">
<a class="gear-set-card-link" href="/gear.php?set=<?= (int) $gear['set']['id'] ?>">
<span class="gear-set-card-title"><?= e($gear['set']['name']) ?> <?= class_badge_html($gear['set']['class_name'], 20) ?></span>
<span class="text-muted">
<?= count(array_filter($gear['slots'], static fn (array $row): bool => !empty($row['item']))) ?>/<?= count(GEAR_SLOTS) ?> Slots
<?php if ($gear['item_level'] !== null): ?> · Ø Stufe <?= e(number_format($gear['item_level'], 1, ',', '.')) ?><?php endif; ?>
</span>
<span class="gear-set-card-icons">
<?php foreach (GEAR_SLOTS as $slotKey => $unused): ?>
<?php $slotItem = $gear['slots'][$slotKey]['item'] ?? null; ?>
<?php if ($slotItem && ($iconUrl = gear_icon_url($slotItem))): ?>
<img class="gear-icon <?= e(gear_grade_class($slotItem['grade'])) ?>" src="<?= e($iconUrl) ?>" alt="" title="<?= e($slotItem['name']) ?>" width="26" height="26" loading="lazy">
<?php endif; ?>
<?php endforeach; ?>
</span>
<?php if (!empty($gear['set']['note'])): ?><span class="gear-set-card-note"><?= e($gear['set']['note']) ?></span><?php endif; ?>
</a>
</article>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if (!empty($gallery)): ?>
<div class="panel">
<h2>Galerie</h2>

View file

@ -160,7 +160,7 @@ include __DIR__ . '/includes/header.php';
<?= csrf_field() ?>
<input type="hidden" name="action" value="gallery_upload">
<input type="hidden" name="user_id" value="<?= $id ?>">
<input type="file" name="images[]" accept="image/png,image/jpeg,image/gif,image/webp" multiple required data-max-size="1920">
<input type="file" name="images[]" accept="image/png,image/jpeg,image/gif,image/webp" multiple required data-max-size="1920" data-paste>
<input type="text" name="caption" maxlength="150" placeholder="Bildunterschrift (optional)">
<button type="submit">Hochladen</button>
</form>

View file

@ -110,7 +110,6 @@ include __DIR__ . '/includes/header.php';
<span class="text-muted">Schnell setzen:</span>
<button type="button" class="button-secondary button-small" data-bulk="groups:present">Alle in Gruppen anwesend</button>
<button type="button" class="button-secondary button-small" data-bulk="bench:absent">Ersatzbank abwesend</button>
<button type="button" class="button-secondary button-small" data-bulk="declined:excused">Abgemeldete entschuldigt</button>
<button type="button" class="button-secondary button-small" data-bulk="all:">Alles zurücksetzen</button>
</div>
@ -121,6 +120,7 @@ include __DIR__ . '/includes/header.php';
<?php foreach ($rows as $row): ?>
<?php
$current = $attendance[$row['discord_id']]['status'] ?? '';
$current = isset(RAID_ATTENDANCE_STATUSES[$current]) ? $current : '';
$hasAccount = isset($userIds[$row['discord_id']]);
?>
<div class="attendance-row" data-section="<?= e($row['section']) ?>">

View file

@ -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);

View file

@ -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>)
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;