2023-06-28 20:38:52 +02:00
|
|
|
<?php
|
|
|
|
require_once "require/base.php";
|
|
|
|
|
|
|
|
$database = new Database();
|
|
|
|
|
|
|
|
if (isset($_GET["team"])) {
|
|
|
|
$team_id = htmlspecialchars($_GET["team"]);
|
|
|
|
|
2024-09-01 21:02:51 +02:00
|
|
|
if (!$database->checkTeamExists($team_id)) {
|
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 {
|
2024-09-01 21:02:51 +02:00
|
|
|
if (!isset($_COOKIE["team"])) {
|
|
|
|
// On crée un cookie pour enregistrer l'équipe sélectionnée :
|
|
|
|
setcookie(
|
|
|
|
"team",
|
|
|
|
$team_id,
|
|
|
|
time() + (365 * 24 * 60 * 60),
|
|
|
|
"/",
|
|
|
|
"",
|
|
|
|
false,
|
|
|
|
false
|
|
|
|
);
|
|
|
|
}
|
2024-02-13 13:21:03 +01:00
|
|
|
|
2024-09-01 21:02:51 +02:00
|
|
|
$solved = $database->getSolvedPuzzles($team_id);
|
|
|
|
$puzzles = [];
|
|
|
|
foreach ($solved as $p) {
|
|
|
|
array_push($puzzles, $database->getArticle($p));
|
2024-02-13 13:21:03 +01:00
|
|
|
}
|
2024-09-01 21:02:51 +02:00
|
|
|
$next_art = $database->getNextPuzzle($team_id);
|
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>
|
2024-09-01 21:02:51 +02:00
|
|
|
<?php if ($next_art != -1) : ?>
|
|
|
|
<a href="article.php?team=<?= $team_id ?>&id=<?= $next_art ?>">
|
|
|
|
<button><?= $tr["puzzles"]["pz_but"] ?></button>
|
|
|
|
</a>
|
|
|
|
<?php if (!empty($puzzles)) : ?>
|
|
|
|
<p><?= $tr["puzzles"]["message"]?></p>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php else : ?>
|
|
|
|
<p><?= $tr["puzzles"]["success"]?></p>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($puzzles)) : ?>
|
|
|
|
<ul>
|
2024-02-13 13:21:03 +01:00
|
|
|
<?php foreach ($puzzles as $puzzle) : ?>
|
2024-09-01 21:02:51 +02:00
|
|
|
<li><a href="article.php?team=<?= $team_id ?>&id=<?= $puzzle["id"] ?>"><?= $tr["page_title"]["article"] . $puzzle["id"] . " : " . $puzzle["title"] ?></a></li>
|
2024-02-13 13:21:03 +01:00
|
|
|
<?php endforeach; ?>
|
2024-09-01 21:02:51 +02:00
|
|
|
</ul>
|
|
|
|
<?php endif; ?>
|
2023-06-28 20:38:52 +02:00
|
|
|
</article>
|
|
|
|
</main>
|
|
|
|
<footer>
|
|
|
|
<?php
|
|
|
|
require_once $rq_path . "footer.php";
|
|
|
|
?>
|
|
|
|
</footer>
|
|
|
|
</body>
|
2023-09-03 22:09:11 +02:00
|
|
|
</html>
|