ChasseTresorPange/article.php

102 lines
3.6 KiB
PHP
Raw Normal View History

2023-06-27 14:31:55 +02:00
<?php
require_once "require/base.php";
$database = new Database();
$bonus = $database->getArticleNb(); // L'énigme bonus est la dernière
if (isset($_GET["id"]) && isset($_GET["team"])) {
$art_id = htmlspecialchars($_GET["id"]);
$team_id = htmlspecialchars($_GET["team"]);
// Vérification de l'existence du groupe et de l'énigme :
if (!$database->checkArticleExists($art_id)) {
if (!$database->checkTeamExists($team_id)) {
header("Location: index.php");
die();
}
else if ($art_id == -1) {
header("Location: puzzles.php?team=" . $team_id);
die();
}
else {
header("Location: index.php");
die();
}
}
else {
// On vérifie si l'énigme bonus n'est pas débloquée :
if (!$database->checkTeamBonus($team_id)) {
// Si c'est celle qui est sélectionnée, on choisit une autre énigme :
if ($art_id == $bonus) {
$next_art = $database->getNextPuzzle($team_id);
header("Location: article.php?team=" . $team_id . "&id=" . $next_art);
die();
}
}
$article = $database->getArticle($art_id);
$next_art = $database->getNextPuzzle($team_id);
$solved = $database->isPuzzleSolved($art_id, $team_id);
}
}
else {
header("Location: index.php");
die();
2023-06-27 14:31:55 +02:00
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<?php
require_once $rq_path . "head.php";
?>
<title><?= $tr["tab_title"]["article"] ?></title>
<script type="module" src="<?= $rq_path ?>js/qrscan.js"></script>
2023-06-27 14:31:55 +02:00
</head>
<body>
<header>
<?php
require_once $rq_path . "nav.php";
?>
</header>
<main>
<header>
<h1><?= $tr["page_title"]["article"] . $art_id . " : " . $article["title"] ?></h1>
<h2><?= $article["text"] ?></h2>
<?php if ($solved) : ?>
<a href="article.php?team=<?= $team_id ?>&id=<?= $next_art ?>">
<button><?= $tr["article"]["next_but"] ?></button>
</a>
<p><?= $tr["article"]["success"] ?></p>
<?php else : ?>
<p><?= $tr["article"]["message"] ?></p>
<?php endif; ?>
</header>
<article>
<?php if ($solved) : ?>
<p><?= $article["answer"] ?></p>
<img src="images/map/puzzles/<?= $article["id"] ?>.png"/>
<?php else : ?>
<button><?= $tr["article"]["qr_but"] ?></button>
<p></p> <!-- Emplacement du message d'erreur JS concernant la caméra. !-->
<video></video>
<p><?= $tr["article"]["cam_sel"] ?></p>
<select>
<option value="rear" selected><?= $tr["article"]["r_cam"] ?></option>
<option value="front"><?= $tr["article"]["f_cam"] ?></option>
</select>
<!-- <p>Scanner depuis un fichier</p>
<input type="file" id="file-selector"> -->
<?php endif; ?>
2023-06-27 14:31:55 +02:00
</article>
</main>
<footer>
<?php
require_once $rq_path . "footer.php";
?>
</footer>
</body>
</html>