From 4481043adb9d882e04cccdb059dea5e4b3c3050a Mon Sep 17 00:00:00 2001 From: Dominic Date: Sat, 10 Oct 2026 00:50:02 +0200 Subject: [PATCH] Allow deleting unused unlock codes --- intern/statistik/index.php | 39 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/intern/statistik/index.php b/intern/statistik/index.php index 05b1622..8cb3fad 100644 --- a/intern/statistik/index.php +++ b/intern/statistik/index.php @@ -98,12 +98,41 @@ endif; if (empty($_SESSION['csrf_token'])) $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); $promoFlash = $_SESSION['promo_flash'] ?? null; unset($_SESSION['promo_flash']); +$promoDeleteFlash = (string) ($_SESSION['promo_delete_flash'] ?? ''); +unset($_SESSION['promo_delete_flash']); $promoError = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['promo_action'])) { $providedCsrf = (string) ($_POST['csrf_token'] ?? ''); if (!hash_equals((string) $_SESSION['csrf_token'], $providedCsrf)) { $promoError = 'Die Sitzung ist abgelaufen. Bitte lade die Seite neu und versuche es erneut.'; } else { + $action = (string) $_POST['promo_action']; + if ($action === 'delete') { + $codeKey = strtolower(trim((string) ($_POST['code_key'] ?? ''))); + $httpKey = trim((string) ($config['nakama_http_key'] ?? '')); + $rpcBase = preg_replace('~/private_stats$~', '/delete_unlock_code', (string) ($config['nakama_rpc_url'] ?? '')); + if (!preg_match('/^[a-f0-9]{64}$/D', $codeKey)) { + $promoError = 'Ungültiger Code-Eintrag.'; + } elseif ($httpKey === '' || !is_string($rpcBase) || $rpcBase === (string) ($config['nakama_rpc_url'] ?? '')) { + $promoError = 'Die interne Codeverwaltung ist noch nicht mit Nakama verbunden.'; + } else { + $url = $rpcBase . '?http_key=' . rawurlencode($httpKey) . '&unwrap'; + $response = fetchJson($url, 'POST', json_encode(['code_key' => $codeKey], JSON_THROW_ON_ERROR)); + if (is_array($response) && isset($response['payload']) && is_string($response['payload'])) { + $decodedPayload = json_decode($response['payload'], true); + if (is_array($decodedPayload)) $response = $decodedPayload; + } + if (is_array($response) && !empty($response['accepted'])) { + $_SESSION['promo_delete_flash'] = 'Der nicht eingelöste Code wurde gelöscht.'; + header('Location: ./'); + exit; + } + $reason = is_array($response) ? (string) ($response['error'] ?? '') : ''; + $promoError = $reason === 'already_used' + ? 'Dieser Code wurde inzwischen eingelöst und kann nicht gelöscht werden.' + : ($reason === 'not_found' ? 'Der Code ist bereits gelöscht oder nicht mehr vorhanden.' : 'Der Code konnte nicht gelöscht werden. Bitte später erneut versuchen.'); + } + } elseif ($action === 'create') { $reward = (string) ($_POST['reward'] ?? ''); $maxUses = filter_var($_POST['max_uses'] ?? '1', FILTER_VALIDATE_INT); $note = trim((string) ($_POST['note'] ?? '')); @@ -137,6 +166,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['promo_action'])) { } $promoError = 'Der Server konnte keinen Code erstellen. Prüfe die Verbindung und versuche es erneut.'; } + } else { + $promoError = 'Unbekannte Code-Aktion.'; + } } } @@ -204,14 +236,16 @@ if ($httpKey !== '') { Void Bastion – Interne Statistik

GERGAMES · NICHT ÖFFENTLICH

Void Bastion Statistik

Abmelden
Downloads insgesamt
Downloads aktuelles Release
Registrierte Piloten
Heute aktive Piloten
Windows-Downloads
Android-Downloads

Die Downloadwerte stammen direkt aus den Gitea-Release-Anhängen und werden alle fünf Minuten neu geladen.

Die private Nakama-Statistik ist noch nicht mit dem HTTP-Schlüssel verbunden.

Letzte Spieleraktualisierung:

Diese Seite ist nicht verlinkt, von Suchmaschinen ausgeschlossen und verlangt eine Anmeldung. Es werden ausschließlich zusammengefasste Werte dargestellt.

Freischaltcodes erstellen

Codes und Bemerkungen werden ausschließlich in der geschützten Serverablage verwaltet. Der Klartext ist nur in diesem angemeldeten Bereich sichtbar.

Code erstellt: · offen · maximal Einlösungen ·
+

-

Code-Übersicht

Noch keine Freischaltcodes vorhanden.

Code-Übersicht

Noch keine Freischaltcodes vorhanden.

CodeFreischaltungStatusEinlösungenErstelltBemerkung
= $maxUses ? 'redeemed' : ($uses > 0 ? 'partial' : 'open'); @@ -220,5 +254,6 @@ $createdAt = (int) ($promoCode['created_at'] ?? 0); $createdLabel = $createdAt > 0 ? date('d.m.Y H:i', intdiv($createdAt, 1000)) : '—'; $codeLabel = (string) ($promoCode['code'] ?? ''); if ($codeLabel === '') $codeLabel = 'Alter Code – Klartext nicht gespeichert'; -?>
CodeFreischaltungStatusEinlösungenErstelltBemerkungAktion
/
+$codeKey = strtolower((string) ($promoCode['code_key'] ?? '')); +?> /
—