2023-06-28 20:38:52 +02:00
|
|
|
<?php
|
|
|
|
require_once "require/base.php";
|
|
|
|
|
2023-06-28 20:59:12 +02:00
|
|
|
$puzzles = array();
|
2024-02-13 13:21:03 +01:00
|
|
|
$order = 0;
|
2023-06-28 20:59:12 +02:00
|
|
|
$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();
|
|
|
|
|
2023-09-02 01:44:54 +02:00
|
|
|
if (empty($stmt->fetch())) {
|
2023-06-28 20:38:52 +02:00
|
|
|
header("Location: index.php");
|
|
|
|
die();
|
|
|
|
}
|
2023-09-02 01:00:27 +02:00
|
|
|
|
2023-06-28 20:38:52 +02:00
|
|
|
else {
|
2023-09-02 01:44:54 +02:00
|
|
|
// On crée un cookie pour enregistrer l'équipe sélectionnée :
|
|
|
|
setcookie(
|
|
|
|
"team",
|
|
|
|
$team_id,
|
|
|
|
time() + (365 * 24 * 60 * 60),
|
|
|
|
"/",
|
|
|
|
"",
|
|
|
|
false,
|
|
|
|
false
|
|
|
|
);
|
2023-09-01 21:31:54 +02:00
|
|
|
|
2024-02-13 10:36:59 +01:00
|
|
|
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles");
|
2023-08-11 21:38:37 +02:00
|
|
|
|
2023-06-28 20:38:52 +02:00
|
|
|
$stmt->execute();
|
|
|
|
$puzzles = $stmt->fetchAll();
|
2024-02-13 13:21:03 +01:00
|
|
|
|
|
|
|
// Recherche de l'ordre des énigmes :
|
|
|
|
$stmt = $database->pdo_teams->prepare("SELECT pzorder FROM teams WHERE id == :id");
|
|
|
|
$stmt->bindValue(":id", $team_id);
|
|
|
|
$stmt->execute();
|
|
|
|
$order = $stmt->fetch();
|
|
|
|
|
|
|
|
echo (string) $order["pzorder"];
|
|
|
|
|
|
|
|
// Si un ordre d'énigmes n'a pas été défini au préalable pour cette équipe, on en choisit un au hasard :
|
|
|
|
if ($order == NULL) {
|
|
|
|
$order = rand(0, sizeof($pzorder));
|
|
|
|
$stmt = $database->pdo_teams->prepare("UPDATE teams SET pzorder = :order WHERE id == :id");
|
|
|
|
$stmt->bindValue(":id", $team_id);
|
|
|
|
$stmt->bindValue(":order", $order);
|
|
|
|
$stmt->execute();
|
|
|
|
}
|
2023-06-28 20:38:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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>
|
2023-09-03 21:34:28 +02:00
|
|
|
<p><?= $tr["puzzles"]["message"]?></p>
|
2023-06-28 20:38:52 +02:00
|
|
|
<ul>
|
2024-02-13 13:21:03 +01:00
|
|
|
<?php foreach ($pzorder[$order["pzorder"]] as $pzid) : ?>
|
|
|
|
<?php foreach ($puzzles as $puzzle) : ?>
|
|
|
|
<?php if ($puzzle["id"] == $pzid) : ?>
|
|
|
|
<li><a href="article.php?team=<?= $team_id ?>&id=<?= $puzzle["id"] ?>"><?= $tr["page_title"]["article"] . $puzzle["id"] . " : " . $puzzle["title"] ?></a></li>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endforeach; ?>
|
2023-06-28 20:38:52 +02:00
|
|
|
<?php endforeach; ?>
|
|
|
|
</ul>
|
|
|
|
</article>
|
|
|
|
</main>
|
|
|
|
<footer>
|
|
|
|
<?php
|
|
|
|
require_once $rq_path . "footer.php";
|
|
|
|
?>
|
|
|
|
</footer>
|
|
|
|
</body>
|
2023-09-03 22:09:11 +02:00
|
|
|
</html>
|