= $article["content"] ?>
+ += $tr["article"]["success"] ?>
+= $article["infos"] ?>
+= $article["place"] ?>
+ += $tr["article"]["message"] ?>
+ + + += $tr["article"]["cam_sel"] ?>
+ + +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 @@ -
= $article["summary"] ?>
+= $article["text"] ?>
= $article["content"] ?>
+ += $tr["article"]["success"] ?>
+= $article["infos"] ?>
+= $article["place"] ?>
+ += $tr["article"]["message"] ?>
+ + + += $tr["article"]["cam_sel"] ?>
+ + +