forked from antux18/ChasseTresorPange
antux18
d0a515df65
Corrections traductions. Corrections ordres des énigmes. Corrections CSS. Corrections DB.
130 lines
4.8 KiB
PHP
130 lines
4.8 KiB
PHP
<?php
|
|
require_once "require/base.php";
|
|
|
|
$article = array();
|
|
$solved = false;
|
|
$team_id = -1;
|
|
$art_id = -1;
|
|
$art_index = -1; // Index de l'article dans la liste pzorder assignée à l'équipe
|
|
|
|
$database = new Database();
|
|
|
|
$max_art = $database->getArticleNb();
|
|
|
|
if (isset($_GET["id"]) && isset($_GET["team"])) {
|
|
$art_id = htmlspecialchars($_GET["id"]);
|
|
$team_id = htmlspecialchars($_GET["team"]);
|
|
|
|
// Recherche de l'énigme indiquée dans la base :
|
|
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE id == :id");
|
|
$stmt->bindValue(":id", $art_id);
|
|
$stmt->execute();
|
|
$article = $stmt->fetch();
|
|
|
|
// Vérification de l'existence du groupe et de l'énigme :
|
|
if (empty($article) || !$database->checkTeamExists($team_id)) {
|
|
header("Location: index.php");
|
|
die();
|
|
}
|
|
|
|
else {
|
|
// On cherche l'index de l'article dans la liste pzorder assignée à l'équipe :
|
|
$stmt = $database->pdo_teams->prepare("SELECT pzorder FROM teams WHERE id == :id");
|
|
$stmt->bindValue(":id", $team_id);
|
|
$stmt->execute();
|
|
$result = $stmt->fetch();
|
|
$order = $result["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 (is_null($order)) {
|
|
$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();
|
|
}
|
|
|
|
$pzo_arr = $pzorder[$order];
|
|
$art_index = array_search($art_id, $pzo_arr);
|
|
$prev_art = $pzo_arr[$art_index - 1];
|
|
if ($art_index == 0) {
|
|
$prev_art = $pzo_arr[$max_art - 1];
|
|
}
|
|
$next_art = $pzo_arr[($art_index + 1) % $max_art];
|
|
|
|
// On indique si l'énigme est résolue :
|
|
$stmt = $database->pdo_teams->prepare("SELECT * FROM solved WHERE (team_id == :team_id AND puzzle_id == :puzzle_id)");
|
|
$stmt->bindValue(":team_id", $team_id);
|
|
$stmt->bindValue(":puzzle_id", $art_id);
|
|
$stmt->execute();
|
|
$solved = !empty($stmt->fetch());
|
|
}
|
|
}
|
|
|
|
else {
|
|
header("Location: index.php");
|
|
die();
|
|
}
|
|
?>
|
|
|
|
<!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>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<?php
|
|
require_once $rq_path . "nav.php";
|
|
?>
|
|
</header>
|
|
<main>
|
|
<header>
|
|
<h1><?= $tr["page_title"]["article"] . $art_id ?></h1>
|
|
<h2><?= $article["text"] ?></h2>
|
|
<section>
|
|
<a href="article.php?team=<?= $team_id ?>&id=<?= $prev_art ?>">
|
|
<button><?= $tr["article"]["prev_but"] ?></button>
|
|
</a>
|
|
<a href="puzzles.php?team=<?= $team_id ?>">
|
|
<button><?= $tr["article"]["back_but"] ?></button>
|
|
</a>
|
|
<a href="article.php?team=<?= $team_id ?>&id=<?= $next_art ?>">
|
|
<button><?= $tr["article"]["next_but"] ?></button>
|
|
</a>
|
|
</section>
|
|
<?php if ($solved) : ?>
|
|
<p><?= $tr["article"]["success"] ?></p>
|
|
<?php else : ?>
|
|
<p><?= $tr["article"]["message"] ?></p>
|
|
<?php endif; ?>
|
|
</header>
|
|
<article>
|
|
<?php if ($solved) : ?>
|
|
<p><?= $article["answer"] ?></p>
|
|
<h1><?= $article["reward"] ?></h1>
|
|
<?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; ?>
|
|
</article>
|
|
</main>
|
|
<footer>
|
|
<?php
|
|
require_once $rq_path . "footer.php";
|
|
?>
|
|
</footer>
|
|
</body>
|
|
</html>
|