LuminaWebsite/admin/gear_items.php
Maaxxs 5dabbccbd7 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>
2026-09-22 09:27:09 +02:00

175 lines
9.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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'; ?>