true, 'samesite' => 'Lax', 'secure' => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https'), ]); session_start(); $STATUSES = [ 'nouveau' => '🆕 Nouveau', 'en_cours' => '🔧 En cours', 'resolu' => '✅ Résolu', 'ignore' => '🙈 Ignoré', ]; $STATUS_COLORS = [ 'nouveau' => '#38bdf8', 'en_cours' => '#fbbf24', 'resolu' => '#4ade80', 'ignore' => '#94a3b8', ]; /* ───────────────────────── helpers ───────────────────────── */ function h(?string $s): string { return htmlspecialchars((string) $s, ENT_QUOTES, 'UTF-8'); } function current_user(): ?array { return isset($_SESSION['admin_user_id']) ? [ 'id' => (int) $_SESSION['admin_user_id'], 'name' => (string) $_SESSION['admin_username'], ] : null; } function csrf_token(): string { if (empty($_SESSION['csrf'])) { $_SESSION['csrf'] = bin2hex(random_bytes(32)); } return $_SESSION['csrf']; } function csrf_ok(): bool { return hash_equals($_SESSION['csrf'] ?? '', $_POST['csrf'] ?? ''); } function format_date(string $utc): string { try { $d = new DateTime($utc, new DateTimeZone('UTC')); $d->setTimezone(new DateTimeZone('Europe/Paris')); return $d->format('d/m/Y H:i'); } catch (Throwable $e) { return $utc; } } function excerpt(string $s, int $len = 140): string { $s = trim(preg_replace('/\s+/', ' ', $s) ?? ''); if (mb_strlen($s) <= $len) { return $s; } return mb_substr($s, 0, $len - 1) . '…'; } /* ───────────────────────── actions POST ───────────────────────── */ $error = null; $notice = null; $freshInvite = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $action = $_POST['action'] ?? ''; if ($action === 'login') { $username = trim((string) ($_POST['username'] ?? '')); $password = (string) ($_POST['password'] ?? ''); try { $pdo = fws_bugs_db(); $st = $pdo->prepare('SELECT * FROM admin_users WHERE username = :u'); $st->execute([':u' => $username]); $user = $st->fetch(); if ($user !== false && password_verify($password, $user['password_hash'])) { session_regenerate_id(true); $_SESSION['admin_user_id'] = (int) $user['id']; $_SESSION['admin_username'] = (string) $user['username']; $_SESSION['csrf'] = bin2hex(random_bytes(32)); header('Location: index.php'); exit; } $error = 'Identifiants incorrects.'; } catch (Throwable $e) { $error = 'Erreur base de données : ' . $e->getMessage(); } } elseif (current_user() !== null) { if (!csrf_ok()) { $error = 'Jeton de sécurité invalide, rechargez la page.'; } elseif ($action === 'logout') { $_SESSION = []; session_destroy(); header('Location: index.php'); exit; } elseif ($action === 'set_status') { $id = (int) ($_POST['id'] ?? 0); $status = (string) ($_POST['status'] ?? ''); if (!isset($STATUSES[$status])) { $error = 'Statut inconnu.'; } else { $pdo = fws_bugs_db(); $st = $pdo->prepare('SELECT status, discord_thread_id FROM bug_reports WHERE id = :id'); $st->execute([':id' => $id]); $row = $st->fetch(); $st = $pdo->prepare('UPDATE bug_reports SET status = :s WHERE id = :id'); $st->execute([':s' => $status, ':id' => $id]); $notice = "Signalement #$id marqué « " . $STATUSES[$status] . " »."; /* Prévenir Discord (best-effort) */ if ($row !== false && !empty($row['discord_thread_id'])) { try { $actor = current_user()['name'] ?? ''; fws_bugs_discord_status_change([ 'thread_id' => (string) $row['discord_thread_id'], 'old_status' => (string) ($row['status'] ?? ''), 'new_status' => $status, 'actor' => (string) $actor, ]); } catch (Throwable $e) { error_log('[fws-bugs] discord statut : ' . $e->getMessage()); } } header('Location: index.php?id=' . $id); exit; } } elseif ($action === 'delete') { $id = (int) ($_POST['id'] ?? 0); $pdo = fws_bugs_db(); $st = $pdo->prepare('DELETE FROM bug_reports WHERE id = :id'); $st->execute([':id' => $id]); $notice = "Signalement #$id supprimé."; header('Location: index.php'); exit; } elseif ($action === 'gen_invite') { $days = (int) ($_POST['days'] ?? 7); if (!in_array($days, [0, 1, 7, 30, 90], true)) { $days = 7; } $pdo = fws_bugs_db(); try { $freshInvite = fws_bugs_create_invite($pdo, (string) (current_user()['name'] ?? ''), $days); $notice = 'Code d\'invitation généré.'; } catch (Throwable $e) { $error = 'Erreur : ' . $e->getMessage(); } } elseif ($action === 'revoke_invite') { $inviteId = (int) ($_POST['invite_id'] ?? 0); $pdo = fws_bugs_db(); $st = $pdo->prepare("UPDATE invite_codes SET revoked_at = datetime('now') WHERE id = :id AND used_by IS NULL AND revoked_at IS NULL"); $st->execute([':id' => $inviteId]); $notice = $st->rowCount() > 0 ? 'Code d\'invitation révoqué : il ne fonctionnera plus.' : 'Impossible de révoquer ce code (déjà utilisé ou déjà révoqué).'; } elseif ($action === 'change_password') { $cur = (string) ($_POST['current_password'] ?? ''); $new = (string) ($_POST['new_password'] ?? ''); $confirm = (string) ($_POST['confirm_password'] ?? ''); $uid = (int) current_user()['id']; $pdo = fws_bugs_db(); $st = $pdo->prepare('SELECT password_hash FROM admin_users WHERE id = :id'); $st->execute([':id' => $uid]); $row = $st->fetch(); if ($row === false || !password_verify($cur, $row['password_hash'])) { $error = 'Mot de passe actuel incorrect.'; } elseif (strlen($new) < 8) { $error = 'Nouveau mot de passe trop court (8 caractères minimum).'; } elseif ($new !== $confirm) { $error = 'Les deux nouveaux mots de passe ne correspondent pas.'; } else { $up = $pdo->prepare('UPDATE admin_users SET password_hash = :h WHERE id = :id'); $up->execute([':h' => password_hash($new, PASSWORD_DEFAULT), ':id' => $uid]); $notice = 'Mot de passe modifié avec succès.'; } } } } $user = current_user(); /* ───────────────────────── routage vues ───────────────────────── */ try { $pdo = fws_bugs_db(); } catch (Throwable $e) { http_response_code(500); exit('Erreur base de données : ' . h($e->getMessage())); } $view_id = (int) ($_GET['id'] ?? 0); $view_invites = ($_GET['view'] ?? '') === 'invites' && $view_id === 0; /* Compteurs pour les filtres */ $counts = ['tous' => 0]; foreach ($STATUSES as $k => $v) { $counts[$k] = 0; } foreach ($pdo->query('SELECT status, COUNT(*) c FROM bug_reports GROUP BY status') as $row) { $s = $row['status']; if (isset($counts[$s])) { $counts[$s] = (int) $row['c']; $counts['tous'] += (int) $row['c']; } } /* ───────────────────────── affichage ───────────────────────── */ header('Content-Type: text/html; charset=utf-8'); ?>
Aucun compte admin pour l'instant.
Créez-le dans le conteneur :
docker exec -it fws-files php /var/www/html/admin/bugs/init.php
Pas encore de compte ? S'inscrire avec un code d'invitation
Signalement #= $view_id ?> introuvable.
← Retour à la liste ← Retour à la liste= h($r['description']) ?>
| = h($r['email']) ?> | |
| Système | = h($r['system_info']) ?> |
| IP | = h($r['ip'] !== '' ? $r['ip'] : '?') ?> |
| User-agent | = h($r['user_agent']) ?> |
| Discord | Voir le post dans le forum ↗ |
| Discord | post créé (lien indisponible) |
= h($r['logs']) ?>
Le code est à usage unique : donnez-le à la personne, elle l'utilise sur la page admin/bugs/register.php pour créer son compte (nom + mot de passe).
= h($freshInvite) ?>
Aucun code pour l'instant.
| Code | Créé | Expire | Statut | Utilisé par | |
|---|---|---|---|---|---|
| = h($inv['code']) ?> | = h(format_date((string) $inv['created_at'])) ?>= $inv['created_by'] !== '' ? ' · ' . h($inv['created_by']) : '' ?> | = $inv['expires_at'] !== null ? h(format_date((string) $inv['expires_at'])) : '∞ jamais' ?> | = $stLabel ?> | = $inv['used_by'] !== null ? h($userNames[(int) $inv['used_by']] ?? '#'.$inv['used_by']) . ' · ' . h(format_date((string) $inv['used_at'])) : '' ?> |
Tous les comptes peuvent consulter et traiter les signalements. Chacun peut modifier son propre mot de passe ci-dessous.
Aucun compte.
| Nom | Créé le |
|---|---|
| = h($u['username']) ?> | = h(format_date((string) $u['created_at'])) ?> |
Connecté en tant que = h($user['name']) ?>. Le nouveau mot de passe doit faire au moins 8 caractères.
Aucun signalement = $filter !== 'tous' ? 'avec ce statut' : '' ?> pour le moment. 🎉
= h(excerpt($r['description'])) ?>