Correction de la résolution du puzzle.

This commit is contained in:
antux18 2023-06-28 20:59:12 +02:00
parent 35c9aeaae5
commit 0dd6af01d5
3 changed files with 16 additions and 22 deletions

View File

@ -1,42 +1,30 @@
<?php <?php
require_once "require/base.php"; require_once "require/base.php";
$team_id = -1;
$art_id = -1;
$article = array();
$database = new Database(); $database = new Database();
if (isset($_GET["code"]) && isset($_GET["team"]) && isset($_GET["id"])) { if (isset($_GET["code"]) && isset($_GET["team"]) && isset($_GET["id"])) {
$art_id = htmlspecialchars($_GET["id"]); $art_id = htmlspecialchars($_GET["id"]);
$team_id = htmlspecialchars($_GET["team"]); $team_id = htmlspecialchars($_GET["team"]);
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE id == :id");
// Recherche de l'énigme avec son code :
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE (id == :id AND code == :code)");
$stmt->bindValue(":id", $art_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->bindValue(":code", htmlspecialchars($_GET["code"]));
$stmt->execute(); $stmt->execute();
$article = $stmt->fetch(); $article = $stmt->fetch();
// Vérification de l'existence du groupe : // Recherche du groupe :
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id"); $stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id");
$stmt->bindValue(":id", $team_id); $stmt->bindValue(":id", $team_id);
$stmt->execute(); $stmt->execute();
if (empty($stmt->fetchAll())) { // Vérification de l'existence du groupe, et de la combinaison ID énigme + code :
header("Location: index.php"); if (empty($article) || empty($stmt->fetchAll())) {
die();
}
if (empty($article)) {
echo 0; echo 0;
} }

View File

@ -2,6 +2,9 @@
require_once "require/base.php"; require_once "require/base.php";
$article = array(); $article = array();
$solved = false;
$team_id = -1;
$art_id = -1;
$database = new Database(); $database = new Database();

View File

@ -1,6 +1,9 @@
<?php <?php
require_once "require/base.php"; require_once "require/base.php";
$puzzles = array();
$team_id = -1;
$database = new Database(); $database = new Database();
if (isset($_GET["team"])) { if (isset($_GET["team"])) {