57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
|
<?php
|
||
|
require_once "require/base.php";
|
||
|
|
||
|
$database = new Database();
|
||
|
|
||
|
if (isset($_GET["code"]) && isset($_GET["team"]) && isset($_GET["id"])) {
|
||
|
$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();
|
||
|
}
|
||
|
|
||
|
$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();
|
||
|
}
|
||
|
?>
|