2023-06-28 20:38:52 +02:00
|
|
|
<?php
|
|
|
|
require_once "require/base.php";
|
|
|
|
|
2023-06-28 20:59:12 +02:00
|
|
|
$team_id = -1;
|
|
|
|
$art_id = -1;
|
|
|
|
$article = array();
|
|
|
|
|
2023-06-28 20:38:52 +02:00
|
|
|
$database = new Database();
|
|
|
|
|
|
|
|
if (isset($_GET["code"]) && isset($_GET["team"]) && isset($_GET["id"])) {
|
|
|
|
$art_id = htmlspecialchars($_GET["id"]);
|
|
|
|
$team_id = htmlspecialchars($_GET["team"]);
|
|
|
|
|
2023-06-28 20:59:12 +02:00
|
|
|
// 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);
|
2023-06-28 20:38:52 +02:00
|
|
|
$stmt->bindValue(":code", htmlspecialchars($_GET["code"]));
|
|
|
|
$stmt->execute();
|
|
|
|
$article = $stmt->fetch();
|
|
|
|
|
2023-06-28 20:59:12 +02:00
|
|
|
// Recherche du groupe :
|
2023-06-28 20:38:52 +02:00
|
|
|
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id");
|
|
|
|
$stmt->bindValue(":id", $team_id);
|
|
|
|
$stmt->execute();
|
|
|
|
|
2023-06-28 20:59:12 +02:00
|
|
|
// Vérification de l'existence du groupe, et de la combinaison ID énigme + code :
|
|
|
|
if (empty($article) || empty($stmt->fetchAll())) {
|
2023-06-28 20:38:52 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
?>
|