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) . '…'; } /* ── Paquets : parsing / formatage des champs « une ligne par entrée » ── */ function parse_pipe_lines(string $raw, int $fields): array { $out = []; foreach (preg_split('/\r?\n/', $raw) as $line) { $line = trim($line); if ($line === '') { continue; } $parts = array_map('trim', explode('|', $line)); $parts = array_pad($parts, $fields, ''); $out[] = array_slice($parts, 0, $fields); } return $out; } function links_from_lines(string $raw): array { $out = []; foreach (parse_pipe_lines($raw, 2) as $pair) { [$label, $url] = $pair; if ($url === '') { $url = $label; $label = ''; } if ($url === '') { continue; } $out[] = ['label' => $label !== '' ? $label : $url, 'url' => $url]; } return $out; } function changelog_from_lines(string $raw): array { $out = []; foreach (parse_pipe_lines($raw, 3) as $parts) { [$version, $date, $notes] = $parts; if ($version === '' && $date === '' && $notes === '') { continue; } $out[] = ['version' => $version, 'date' => $date !== '' ? $date : null, 'notes' => $notes]; } return $out; } function screens_from_lines(string $raw): array { $out = []; foreach (parse_pipe_lines($raw, 3) as $parts) { [$src, $alt, $caption] = $parts; if ($src === '') { continue; } $out[] = ['src' => $src, 'alt' => $alt !== '' ? $alt : null, 'caption' => $caption !== '' ? $caption : null]; } return $out; } function lines_from_links(array $links): string { $lines = []; foreach ($links as $l) { $lines[] = ($l['label'] ?? '') . ' | ' . ($l['url'] ?? ''); } return implode("\n", $lines); } function lines_from_changelog(array $cl): string { $lines = []; foreach ($cl as $e) { $lines[] = ($e['version'] ?? '') . ' | ' . ($e['date'] ?? '') . ' | ' . ($e['notes'] ?? ''); } return implode("\n", $lines); } function lines_from_screens(array $s): string { $lines = []; foreach ($s as $e) { $lines[] = ($e['src'] ?? '') . ' | ' . ($e['alt'] ?? '') . ' | ' . ($e['caption'] ?? ''); } return implode("\n", $lines); } /* ───────────────────────── actions POST ───────────────────────── */ $error = null; $notice = null; $freshInvite = ''; /* Message ponctuel d'une action précédente (stocké en session pour la redirection) */ $flash = $_SESSION['flash'] ?? null; unset($_SESSION['flash']); 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.'; } } elseif ($action === 'pkg_save') { $name = trim((string) ($_POST['name'] ?? '')); if ($name === '') { $error = 'Le nom du paquet est obligatoire.'; } else { $pdo = fws_bugs_db(); $savedId = fws_packages_save($pdo, [ 'id' => (int) ($_POST['pkg_id'] ?? 0), 'slug' => (string) ($_POST['slug'] ?? ''), 'name' => $name, 'tagline' => (string) ($_POST['tagline'] ?? ''), 'description' => (string) ($_POST['description'] ?? ''), 'since' => (string) ($_POST['since'] ?? ''), 'since_label' => (string) ($_POST['since_label'] ?? ''), 'latest_name' => (string) ($_POST['latest_name'] ?? ''), 'latest_date' => (string) ($_POST['latest_date'] ?? ''), 'links' => links_from_lines((string) ($_POST['links'] ?? '')), 'screens' => screens_from_lines((string) ($_POST['screens'] ?? '')), 'changelog' => changelog_from_lines((string) ($_POST['changelog'] ?? '')), ]); $wasEdit = (int) ($_POST['pkg_id'] ?? 0) > 0; $_SESSION['flash'] = ['ok' => $wasEdit ? "Paquet « $name » mis à jour." : "Paquet « $name » créé."]; header('Location: index.php?view=packages'); exit; } } elseif ($action === 'pkg_delete') { $pkgId = (int) ($_POST['pkg_id'] ?? 0); $pdo = fws_bugs_db(); fws_packages_delete($pdo, $pkgId); $_SESSION['flash'] = ['ok' => "Paquet #$pkgId supprimé."]; header('Location: index.php?view=packages'); exit; } elseif ($action === 'pkg_sync_gitea') { /* Rafraîchit latest + historique d'un paquet depuis l'API Gitea (le dépôt est déduit de ses liens « Gitea » / « Releases »). */ $pkgId = (int) ($_POST['pkg_id'] ?? 0); $pdo = fws_bugs_db(); $st = $pdo->prepare('SELECT * FROM packages WHERE id = :id'); $st->execute([':id' => $pkgId]); $row = $st->fetch(); if ($row === false) { $_SESSION['flash'] = ['err' => "Paquet #$pkgId introuvable."]; header('Location: index.php?view=packages'); exit; } $links = json_decode((string) $row['links'], true) ?: []; $repo = null; foreach ($links as $link) { if (preg_match('~^https?://gitea\.nocode-var\.tech/([^/]+)/([^/]+)/?$~i', (string) ($link['url'] ?? ''), $m)) { $repo = ['owner' => $m[1], 'name' => $m[2]]; break; } } if ($repo === null) { $_SESSION['flash'] = ['err' => 'Aucun lien Gitea (gitea.nocode-var.tech) dans ce paquet : synchronisation impossible.']; header('Location: index.php?view=packages'); exit; } require_once __DIR__ . '/../../inc/site.php'; $releases = fws_site_gitea_releases($repo['owner'], $repo['name']); if ($releases === []) { $_SESSION['flash'] = ['err' => 'Gitea ne renvoie aucune release pour ' . $repo['owner'] . '/' . $repo['name'] . '.']; header('Location: index.php?view=packages'); exit; } $first = $releases[0]; $changelog = []; foreach ($releases as $rel) { $notes = trim(strip_tags((string) fws_markdown((string) ($rel['body'] ?? '')))); if (mb_strlen($notes) > 200) { $notes = rtrim(mb_substr($notes, 0, 200)) . '…'; } $changelog[] = [ 'version' => (string) ($rel['tag_name'] ?? ''), 'date' => isset($rel['published_at']) ? substr((string) $rel['published_at'], 0, 10) : null, 'notes' => $notes, ]; } fws_packages_save($pdo, [ 'id' => $pkgId, 'slug' => (string) $row['slug'], 'name' => (string) $row['name'], 'tagline' => (string) $row['tagline'], 'description' => (string) $row['description'], 'since' => (string) ($row['since'] ?? ''), 'since_label' => (string) $row['since_label'], 'latest_name' => (string) ($first['tag_name'] ?? ''), 'latest_date' => isset($first['published_at']) ? substr((string) $first['published_at'], 0, 10) : '', 'links' => $links, 'screens' => json_decode((string) $row['screens'], true) ?: [], 'changelog' => $changelog, ]); $_SESSION['flash'] = ['ok' => 'Paquet « ' . $row['name'] . ' » synchronisé depuis Gitea (' . count($releases) . ' releases).']; header('Location: index.php?view=packages'); exit; } } } $user = current_user(); /* Message ponctuel laissé par une action (après redirection) */ if ($flash !== null) { if (!empty($flash['err'])) { $error = (string) $flash['err']; } if (!empty($flash['ok'])) { $notice = (string) $flash['ok']; } } /* ───────────────────────── 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; $view_packages = ($_GET['view'] ?? '') === 'packages' && $view_id === 0; $edit_pkg_id = $view_packages ? (int) ($_GET['edit'] ?? 0) : 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'); ?> Signalements — FWS Linux

🔒 Panneau des signalements

✅ Compte créé ! Connectez-vous avec vos identifiants.

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

🐞 Signalements de bugs

Connecté : · Base SQLite · tester l'API
0): /* ─────────── DÉTAIL ─────────── */ $st = $pdo->prepare('SELECT * FROM bug_reports WHERE id = :id'); $st->execute([':id' => $view_id]); $r = $st->fetch(); if ($r === false): ?>

Signalement # introuvable.

← Retour à la liste ← Retour à la liste

# —

📅 📦

E-mail
Système
IP
User-agent
DiscordVoir le post dans le forum ↗
Discordpost créé (lien indisponible)
📜 Logs :
Changer le statut : $sv): if ($sk === $r['status']) continue; ?>
query('SELECT * FROM invite_codes ORDER BY id DESC LIMIT 200')->fetchAll(); $users = $pdo->query('SELECT id, username, created_at FROM admin_users ORDER BY id')->fetchAll(); $userNames = []; foreach ($users as $u) { $userNames[(int) $u['id']] = (string) $u['username']; } $now = date('Y-m-d H:i:s'); ?>

🎟️ Générer un code d'invitation

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

🎉 Nouveau code à donner :

Codes générés ()

Aucun code pour l'instant.

CodeCrééExpireStatutUtilisé par

👥 Comptes existants ()

Tous les comptes peuvent consulter et traiter les signalements. Chacun peut modifier son propre mot de passe ci-dessous.

Aucun compte.

NomCréé le

🔑 Mon mot de passe

Connecté en tant que . Le nouveau mot de passe doit faire au moins 8 caractères.

query('SELECT * FROM packages ORDER BY id ASC')->fetchAll(); $editing = null; if ($edit_pkg_id > 0) { foreach ($pkgRows as $pr) { if ((int) $pr['id'] === $edit_pkg_id) { $editing = $pr; break; } } if ($editing === null) { $edit_pkg_id = 0; } } $form = $editing !== null ? $editing : [ 'id' => 0, 'slug' => '', 'name' => '', 'tagline' => '', 'description' => '', 'since' => null, 'since_label' => 'FWS', 'latest_name' => '', 'latest_date' => null, 'links' => '[]', 'screens' => '[]', 'changelog' => '[]', ]; $fLinks = lines_from_links((array) (json_decode((string) $form['links'], true) ?: [])); $fScreens = lines_from_screens((array) (json_decode((string) $form['screens'], true) ?: [])); $fChangelog = lines_from_changelog((array) (json_decode((string) $form['changelog'], true) ?: [])); ?>

← Annuler la modification

Les champs « une ligne par entrée » utilisent le format Label | URL (liens), Version | Date | Notes (historique) et src | alt | légende (captures).

📦 Paquets ()

Aucun paquet. Créez le premier avec le formulaire ci-dessus.

#NomDernière release


✏️ Modifier
prepare("SELECT COUNT(*) FROM bug_reports $where"); $st->execute($params); $total = (int) $st->fetchColumn(); $pages = max(1, (int) ceil($total / $perPage)); $page = min($page, $pages); $offset = ($page - 1) * $perPage; $st = $pdo->prepare( "SELECT * FROM bug_reports $where ORDER BY id DESC LIMIT :lim OFFSET :off" ); $st->bindValue(':lim', $perPage, PDO::PARAM_INT); $st->bindValue(':off', $offset, PDO::PARAM_INT); foreach ($params as $k => $v) $st->bindValue($k, $v); $st->execute(); $reports = $st->fetchAll(); ?>
$c): ?> ()

Aucun signalement pour le moment. 🎉

# —

📅 📦 ✉️

1): ?>
1): ?>← Précédent Page / Suivant →