2023-06-28 20:38:52 +02:00
|
|
|
<?php
|
|
|
|
require_once "require/base.php";
|
|
|
|
|
2023-06-28 20:59:12 +02:00
|
|
|
$puzzles = array();
|
|
|
|
$team_id = -1;
|
|
|
|
|
2023-06-28 20:38:52 +02:00
|
|
|
$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->fetchAll())) {
|
|
|
|
header("Location: index.php");
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
else {
|
2023-09-01 21:31:54 +02:00
|
|
|
// On crée un cookie pour enregistrer l'équipe sélectionnée si ce n'est pas fait :
|
|
|
|
if (!isset($_COOKIE["team"])) {
|
|
|
|
setcookie(
|
|
|
|
"team",
|
|
|
|
$team_id,
|
|
|
|
time() + (365 * 24 * 60 * 60),
|
|
|
|
"/",
|
|
|
|
"",
|
|
|
|
false,
|
|
|
|
false
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-08-11 21:38:37 +02:00
|
|
|
// 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, sinon, on cache la bonus :
|
2023-08-11 21:47:34 +02:00
|
|
|
if ($stmt->fetchAll()[0][1] == 1) {
|
2023-08-11 21:38:37 +02:00
|
|
|
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles");
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE id <> 13");
|
|
|
|
}
|
|
|
|
|
2023-06-28 20:38:52 +02:00
|
|
|
$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>
|
|
|
|
<p></p>
|
|
|
|
<p><?= $tr["puzzles"]["message"]?></p>
|
|
|
|
</header>
|
|
|
|
<article>
|
|
|
|
<ul>
|
|
|
|
<?php foreach ($puzzles as $puzzle) : ?>
|
2023-07-27 13:10:52 +02:00
|
|
|
<li><a href="article.php?team=<?= $team_id ?>&id=<?= $puzzle["id"] ?>"><?= $tr["page_title"]["article"] . $puzzle["id"] . " : " . $puzzle["title"] ?></a></li>
|
2023-06-28 20:38:52 +02:00
|
|
|
<?php endforeach; ?>
|
|
|
|
</ul>
|
|
|
|
</article>
|
|
|
|
</main>
|
|
|
|
<footer>
|
|
|
|
<?php
|
|
|
|
require_once $rq_path . "footer.php";
|
|
|
|
?>
|
|
|
|
</footer>
|
|
|
|
</body>
|
|
|
|
</html>
|