From 35c9aeaae5329ee95eb526069b2617d0363821f7 Mon Sep 17 00:00:00 2001 From: antux18 Date: Wed, 28 Jun 2023 20:38:52 +0200 Subject: [PATCH] =?UTF-8?q?Mise=20en=20place=20du=20syst=C3=A8me=20des=20?= =?UTF-8?q?=C3=A9nigmes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- answer.php | 57 +++++++++++++++++++++++++++++++++++ article.php | 57 ++++++++++++++++++++++++++++++----- data/article.db | Bin 16384 -> 24576 bytes data/teams.db | Bin 0 -> 24576 bytes images/phqr1.gif | Bin 0 -> 725 bytes images/phqr2.gif | Bin 0 -> 743 bytes index.php | 22 +++++++------- puzzles.php | 66 +++++++++++++++++++++++++++++++++++++++++ require/database.php | 31 ++++++++++++++----- require/js/answer.js | 26 ++++++++++++++++ require/js/qrscan.js | 55 ++++++++++++++++++++++++++-------- require/locales/en.php | 35 +++++++++++++++------- require/locales/fr.php | 35 +++++++++++++++------- require/nav.php | 3 ++ style.css | 1 + 15 files changed, 327 insertions(+), 61 deletions(-) create mode 100644 answer.php create mode 100644 data/teams.db create mode 100644 images/phqr1.gif create mode 100644 images/phqr2.gif create mode 100644 puzzles.php create mode 100644 require/js/answer.js diff --git a/answer.php b/answer.php new file mode 100644 index 0000000..46b6201 --- /dev/null +++ b/answer.php @@ -0,0 +1,57 @@ +pdo_article->prepare("SELECT * FROM puzzles WHERE id == :id"); + $stmt->bindValue(":id", $art_id); + $stmt->execute(); + $article = $stmt->fetch(); + + // Vérification de l'existence du groupe et de l'énigme : + $stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id"); + $stmt->bindValue(":id", $team_id); + $stmt->execute(); + + if (empty($article) || empty($stmt->fetchAll())) { + header("Location: index.php"); + die(); + } + + $stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE code == :code"); + $stmt->bindValue(":code", htmlspecialchars($_GET["code"])); + $stmt->execute(); + $article = $stmt->fetch(); + + // Vérification de l'existence du groupe : + $stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id"); + $stmt->bindValue(":id", $team_id); + $stmt->execute(); + + if (empty($stmt->fetchAll())) { + header("Location: index.php"); + die(); + } + + if (empty($article)) { + echo 0; + } + + else { + $data = [ + "infos" => $article["infos"], + "place" => $article["place"] + ]; + header('Content-Type: application/json; charset=utf-8'); + echo json_encode($data); + } + } + + else { + header("Location: index.php"); + die(); + } +?> \ No newline at end of file diff --git a/article.php b/article.php index 4444692..2f7c04a 100644 --- a/article.php +++ b/article.php @@ -5,11 +5,36 @@ $database = new Database(); - if (isset($_GET["id"])) { - $stmt = $database->pdo_article->prepare("SELECT * FROM article WHERE id == :id"); - $stmt->bindValue(":id", htmlspecialchars($_GET["id"])); + if (isset($_GET["id"]) && isset($_GET["team"])) { + $art_id = htmlspecialchars($_GET["id"]); + $team_id = htmlspecialchars($_GET["team"]); + $stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE id == :id"); + $stmt->bindValue(":id", $art_id); $stmt->execute(); $article = $stmt->fetch(); + + // Vérification de l'existence du groupe et de l'énigme : + $stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id"); + $stmt->bindValue(":id", $team_id); + $stmt->execute(); + + if (empty($article) || empty($stmt->fetchAll())) { + header("Location: index.php"); + die(); + } + + else { + $stmt = $database->pdo_teams->prepare("SELECT * FROM solved WHERE (team_id == :team_id AND puzzle_id == :puzzle_id)"); + $stmt->bindValue(":team_id", $team_id); + $stmt->bindValue(":puzzle_id", $art_id); + $stmt->execute(); + $solved = !empty($stmt->fetch()); + } + } + + else { + header("Location: index.php"); + die(); } ?> @@ -19,7 +44,8 @@ - <?= $tr["tab_title"]["article"]?> + <?= $tr["tab_title"]["article"] ?> +
@@ -29,12 +55,27 @@
-

-

+

+

- alt=> -

+ +

+

+

+ +

+

+ + +

+ + +