JeuPistesSarreguemines/puzzles.php
antux18 03fb59404e Correction structure HTML + CSS.
Ajout fichier manquant qr-scanner.
2023-09-03 15:34:28 -04:00

97 lines
2.8 KiB
PHP

<?php
require_once "require/base.php";
$puzzles = array();
$team_id = -1;
$database = new Database();
if (isset($_GET["team"])) {
$team_id = htmlspecialchars($_GET["team"]);
// 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->fetch())) {
header("Location: index.php");
die();
}
else {
// On crée un cookie pour enregistrer l'équipe sélectionnée :
setcookie(
"team",
$team_id,
time() + (365 * 24 * 60 * 60),
"/",
"",
false,
false
);
// On vérifie si l'équipe a débloqué l'énigme bonus :
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id = :id");
$stmt->bindValue(":id", $team_id);
$stmt->execute();
// Si c'est le cas, on affiche toutes les énigmes :
if ($stmt->fetchAll()[0][1] == 1) {
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles");
}
// Sinon, on cache la bonus :
else {
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE id <> 13");
}
$stmt->execute();
$puzzles = $stmt->fetchAll();
}
}
else {
header("Location: index.php");
die();
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<?php
require_once $rq_path . "head.php";
?>
<title><?= $tr["tab_title"]["puzzles"]?></title>
</head>
<body>
<header>
<?php
require_once $rq_path . "nav.php";
?>
</header>
<main>
<header>
<h1><?= $tr["page_title"]["puzzles"] . $team_id ?></h1>
</header>
<article>
<p><?= $tr["puzzles"]["message"]?></p>
<ul>
<?php foreach ($puzzles as $puzzle) : ?>
<li><a href="article.php?team=<?= $team_id ?>&id=<?= $puzzle["id"] ?>"><?= $tr["page_title"]["article"] . $puzzle["id"] . " : " . $puzzle["title"] ?></a></li>
<?php endforeach; ?>
</ul>
<p><?= $tr["puzzles"]["map_desc"] ?></p>
<canvas width="2199px" height="2459px">
<img src="images/map/base_map.png" alt="Puzzles map">
</canvas>
</article>
</main>
<footer>
<?php
require_once $rq_path . "footer.php";
?>
</footer>
</body>
</html>