Compare commits
13 Commits
master
...
random-puz
Author | SHA1 | Date | |
---|---|---|---|
806271e6b2 | |||
4491a5c7ef | |||
cd84b319e7 | |||
bd8275f7ae | |||
6e063e4ce1 | |||
2de91ad8a3 | |||
d0a515df65 | |||
f655529f31 | |||
559d42fff1 | |||
a0e3ba8c09 | |||
fabc5e55fd | |||
b2bdc6350f | |||
d2ea5ebbcd |
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
localhost-key.pem
|
localhost-key.pem
|
||||||
localhost.pem
|
localhost.pem
|
||||||
|
data/teams.db
|
||||||
|
data/article.db
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
**Auteur :** Antoine WAEHREN
|
**Auteur :** Antoine WAEHREN
|
||||||
|
|
||||||
|
Sur cette version, la liste des énigmes n'affiche pas immédiatement toutes les énigmes, uniquement celles qui ont été résolues. L'énigme suivante est choisie aléatoirement.
|
||||||
|
|
||||||
## Crédits
|
## Crédits
|
||||||
|
|
||||||
Ce projet utilise le module QR Scanner de NIMIQ : https://github.com/nimiq/qr-scanner
|
Ce projet utilise le module QR Scanner de NIMIQ : https://github.com/nimiq/qr-scanner
|
||||||
|
56
answer.php
56
answer.php
@ -1,30 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "require/base.php";
|
require_once "require/base.php";
|
||||||
|
|
||||||
$team_id = -1;
|
|
||||||
$art_id = -1;
|
|
||||||
$article = array();
|
|
||||||
|
|
||||||
$database = new Database();
|
$database = new Database();
|
||||||
|
$bonus = $database->getArticleNb(); // L'énigme bonus est la dernière
|
||||||
|
|
||||||
if (isset($_GET["code"]) && isset($_GET["team"]) && isset($_GET["id"])) {
|
if (isset($_GET["code"]) && isset($_GET["team"]) && isset($_GET["id"])) {
|
||||||
$team_id = htmlspecialchars($_GET["team"]);
|
$team_id = htmlspecialchars($_GET["team"]);
|
||||||
|
|
||||||
// Recherche du groupe :
|
|
||||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id");
|
|
||||||
$stmt->bindValue(":id", $team_id);
|
|
||||||
$stmt->execute();
|
|
||||||
|
|
||||||
// Vérification de l'existence du groupe :
|
// Vérification de l'existence du groupe :
|
||||||
if (!empty($stmt->fetch())) {
|
if ($database->checkTeamExists($team_id)) {
|
||||||
$art_id = htmlspecialchars($_GET["id"]);
|
$art_id = htmlspecialchars($_GET["id"]);
|
||||||
|
$code = htmlspecialchars($_GET["code"]);
|
||||||
// Recherche de l'énigme avec son code :
|
$article = $database->getArticle($art_id);
|
||||||
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE (id == :id AND code == :code)");
|
|
||||||
$stmt->bindValue(":id", $art_id);
|
|
||||||
$stmt->bindValue(":code", htmlspecialchars($_GET["code"]));
|
|
||||||
$stmt->execute();
|
|
||||||
$article = $stmt->fetch();
|
|
||||||
|
|
||||||
// Données renvoyées :
|
// Données renvoyées :
|
||||||
$data = [
|
$data = [
|
||||||
@ -33,40 +20,27 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Vérification de la combinaison ID énigme + code :
|
// Vérification de la combinaison ID énigme + code :
|
||||||
if (empty($article)) {
|
if (!$database->checkPuzzle($art_id, $code)) {
|
||||||
// Si la combinaison ne fonctionne pas, affichage de l'indice :
|
|
||||||
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE id == :id");
|
|
||||||
$stmt->bindValue(":id", $art_id);
|
|
||||||
$stmt->execute();
|
|
||||||
$article = $stmt->fetch();
|
|
||||||
$data["hint"] = $article["hint"];
|
$data["hint"] = $article["hint"];
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
// On enregistre la réussite dans la table :
|
// On enregistre la réussite dans la table :
|
||||||
// Vérification que ce n'est pas déjà enregistré :
|
// Vérification que ce n'est pas déjà enregistré
|
||||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM solved WHERE (puzzle_id == :puzzle_id AND team_id == :team_id)");
|
// Si ce n'est pas le cas, on enregistre :
|
||||||
$stmt->bindValue(":puzzle_id", $art_id);
|
if (!$database->isPuzzleSolved($art_id, $team_id)) {
|
||||||
|
$database->solvePuzzle($art_id, $team_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// On ajoute l'énigme bonus si toutes les autres sont résolues :
|
||||||
|
$stmt = $database->pdo_teams->prepare("SELECT COUNT(*) FROM solved WHERE team_id == :team_id");
|
||||||
$stmt->bindValue(":team_id", $team_id);
|
$stmt->bindValue(":team_id", $team_id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
// Si ce n'est pas le cas, on enregistre :
|
if ($stmt->fetchAll()[0]["COUNT(*)"] == $bonus - 1) {
|
||||||
if (empty($stmt->fetch())) {
|
$stmt = $database->pdo_teams->prepare("UPDATE teams SET bonus = 1 WHERE id = :team_id");
|
||||||
$stmt = $database->pdo_teams->prepare("INSERT INTO solved VALUES (:puzzle_id, :team_id)");
|
|
||||||
$stmt->bindValue(":puzzle_id", $art_id);
|
|
||||||
$stmt->bindValue(":team_id", $team_id);
|
$stmt->bindValue(":team_id", $team_id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
// On ajoute l'énigme bonus si toutes les autres sont résolues :
|
|
||||||
$stmt = $database->pdo_teams->prepare("SELECT COUNT(*) FROM solved WHERE team_id == :team_id");
|
|
||||||
$stmt->bindValue(":team_id", $team_id);
|
|
||||||
$stmt->execute();
|
|
||||||
|
|
||||||
if ($stmt->fetchAll()[0]["COUNT(*)"] == "12") { // Il y a 12 énigmes sans compter la bonus
|
|
||||||
$stmt = $database->pdo_teams->prepare("UPDATE teams SET bonus = 1 WHERE id = :team_id");
|
|
||||||
$stmt->bindValue(":team_id", $team_id);
|
|
||||||
$stmt->execute();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data["valid_qr"] = true;
|
$data["valid_qr"] = true;
|
||||||
|
60
article.php
60
article.php
@ -1,50 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "require/base.php";
|
require_once "require/base.php";
|
||||||
|
|
||||||
$article = array();
|
|
||||||
$solved = false;
|
|
||||||
$team_id = -1;
|
|
||||||
$art_id = -1;
|
|
||||||
|
|
||||||
$database = new Database();
|
$database = new Database();
|
||||||
|
$bonus = $database->getArticleNb(); // L'énigme bonus est la dernière
|
||||||
$max_art = $database->getArticleNb();
|
|
||||||
|
|
||||||
if (isset($_GET["id"]) && isset($_GET["team"])) {
|
if (isset($_GET["id"]) && isset($_GET["team"])) {
|
||||||
$art_id = htmlspecialchars($_GET["id"]);
|
$art_id = htmlspecialchars($_GET["id"]);
|
||||||
$team_id = htmlspecialchars($_GET["team"]);
|
$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 :
|
// Vérification de l'existence du groupe et de l'énigme :
|
||||||
if (empty($article) || !$database->checkTeamExists($team_id)) {
|
if (!$database->checkArticleExists($art_id)) {
|
||||||
header("Location: index.php");
|
if (!$database->checkTeamExists($team_id)) {
|
||||||
die();
|
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 {
|
else {
|
||||||
// On vérifie si l'énigme bonus n'est pas débloquée :
|
// On vérifie si l'énigme bonus n'est pas débloquée :
|
||||||
if (!$database->checkTeamBonus($team_id)) {
|
if (!$database->checkTeamBonus($team_id)) {
|
||||||
// Si c'est celle qui est sélectionnée, on retourne à la liste des énigmes :
|
// Si c'est celle qui est sélectionnée, on choisit une autre énigme :
|
||||||
if ($art_id == $max_art) {
|
if ($art_id == $bonus) {
|
||||||
header("Location: puzzles.php?team=" . $team_id);
|
$next_art = $database->getNextPuzzle($team_id);
|
||||||
|
header("Location: article.php?team=" . $team_id . "&id=" . $next_art);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
// On retire l'énigme bonus du total :
|
|
||||||
$max_art--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// On indique si l'énigme est résolue :
|
$article = $database->getArticle($art_id);
|
||||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM solved WHERE (team_id == :team_id AND puzzle_id == :puzzle_id)");
|
$next_art = $database->getNextPuzzle($team_id);
|
||||||
$stmt->bindValue(":team_id", $team_id);
|
$solved = $database->isPuzzleSolved($art_id, $team_id);
|
||||||
$stmt->bindValue(":puzzle_id", $art_id);
|
|
||||||
$stmt->execute();
|
|
||||||
$solved = !empty($stmt->fetch());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,15 +66,10 @@
|
|||||||
<header>
|
<header>
|
||||||
<h1><?= $tr["page_title"]["article"] . $art_id . " : " . $article["title"] ?></h1>
|
<h1><?= $tr["page_title"]["article"] . $art_id . " : " . $article["title"] ?></h1>
|
||||||
<h2><?= $article["text"] ?></h2>
|
<h2><?= $article["text"] ?></h2>
|
||||||
<section>
|
|
||||||
<a href="puzzles.php?team=<?= $team_id ?>">
|
|
||||||
<button><?= $tr["article"]["back_but"] ?></button>
|
|
||||||
</a>
|
|
||||||
<!-- <a href="article.php?team=<?= $team_id ?>&id=<?= ($art_id % $max_art) + 1 ?>">
|
|
||||||
<button><?= $tr["article"]["next_but"] ?></button>
|
|
||||||
</a> -->
|
|
||||||
</section>
|
|
||||||
<?php if ($solved) : ?>
|
<?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>
|
<p><?= $tr["article"]["success"] ?></p>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<p><?= $tr["article"]["message"] ?></p>
|
<p><?= $tr["article"]["message"] ?></p>
|
||||||
|
BIN
data/article.db
BIN
data/article.db
Binary file not shown.
BIN
data/teams.db
BIN
data/teams.db
Binary file not shown.
16
index.php
16
index.php
@ -2,8 +2,9 @@
|
|||||||
require_once "require/base.php";
|
require_once "require/base.php";
|
||||||
|
|
||||||
$database = new Database();
|
$database = new Database();
|
||||||
|
$teams = $database->getTeams();
|
||||||
|
|
||||||
// Si l'appareil a déjà choisi une équipe, on le redirige vers la bonne page :
|
// Si l'appareil a déjà choisi une équipe, on le redirige vers une énigme :
|
||||||
if (isset($_COOKIE["team"])) {
|
if (isset($_COOKIE["team"])) {
|
||||||
$team_id = htmlspecialchars($_COOKIE["team"]);
|
$team_id = htmlspecialchars($_COOKIE["team"]);
|
||||||
|
|
||||||
@ -11,19 +12,6 @@
|
|||||||
header("Location: puzzles.php?team=" . $team_id);
|
header("Location: puzzles.php?team=" . $team_id);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
|
||||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams");
|
|
||||||
$stmt->execute();
|
|
||||||
$teams = $stmt->fetchAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sinon, on affiche la liste des équipes :
|
|
||||||
else {
|
|
||||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams");
|
|
||||||
$stmt->execute();
|
|
||||||
$teams = $stmt->fetchAll();
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
74
puzzles.php
74
puzzles.php
@ -1,53 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "require/base.php";
|
require_once "require/base.php";
|
||||||
|
|
||||||
$puzzles = array();
|
|
||||||
$team_id = -1;
|
|
||||||
|
|
||||||
$database = new Database();
|
$database = new Database();
|
||||||
|
|
||||||
if (isset($_GET["team"])) {
|
if (isset($_GET["team"])) {
|
||||||
$team_id = htmlspecialchars($_GET["team"]);
|
$team_id = htmlspecialchars($_GET["team"]);
|
||||||
|
|
||||||
// Vérification de l'existence du groupe :
|
if (!$database->checkTeamExists($team_id)) {
|
||||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id");
|
|
||||||
$stmt->bindValue(":id", $team_id);
|
|
||||||
$stmt->execute();
|
|
||||||
|
|
||||||
if (empty($stmt->fetch())) {
|
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
// On crée un cookie pour enregistrer l'équipe sélectionnée :
|
if (!isset($_COOKIE["team"])) {
|
||||||
setcookie(
|
// On crée un cookie pour enregistrer l'équipe sélectionnée :
|
||||||
"team",
|
setcookie(
|
||||||
$team_id,
|
"team",
|
||||||
time() + (365 * 24 * 60 * 60),
|
$team_id,
|
||||||
"/",
|
time() + (365 * 24 * 60 * 60),
|
||||||
"",
|
"/",
|
||||||
false,
|
"",
|
||||||
false
|
false,
|
||||||
);
|
false
|
||||||
|
);
|
||||||
// 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 :
|
|
||||||
if ($stmt->fetchAll()[0][1] == 1) {
|
|
||||||
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sinon, on cache la bonus :
|
$solved = $database->getSolvedPuzzles($team_id);
|
||||||
else {
|
$puzzles = [];
|
||||||
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE id <> 13");
|
foreach ($solved as $p) {
|
||||||
|
array_push($puzzles, $database->getArticle($p));
|
||||||
}
|
}
|
||||||
|
$next_art = $database->getNextPuzzle($team_id);
|
||||||
$stmt->execute();
|
|
||||||
$puzzles = $stmt->fetchAll();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,12 +59,23 @@
|
|||||||
<h1><?= $tr["page_title"]["puzzles"] . $team_id ?></h1>
|
<h1><?= $tr["page_title"]["puzzles"] . $team_id ?></h1>
|
||||||
</header>
|
</header>
|
||||||
<article>
|
<article>
|
||||||
<p><?= $tr["puzzles"]["message"]?></p>
|
<?php if ($next_art != -1) : ?>
|
||||||
<ul>
|
<a href="article.php?team=<?= $team_id ?>&id=<?= $next_art ?>">
|
||||||
<?php foreach ($puzzles as $puzzle) : ?>
|
<button><?= $tr["puzzles"]["pz_but"] ?></button>
|
||||||
<li><a href="article.php?team=<?= $team_id ?>&id=<?= $puzzle["id"] ?>"><?= $tr["page_title"]["article"] . $puzzle["id"] . " : " . $puzzle["title"] ?></a></li>
|
</a>
|
||||||
<?php endforeach; ?>
|
<?php if (!empty($puzzles)) : ?>
|
||||||
</ul>
|
<p><?= $tr["puzzles"]["message"]?></p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php else : ?>
|
||||||
|
<p><?= $tr["puzzles"]["success"]?></p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (!empty($puzzles)) : ?>
|
||||||
|
<ul>
|
||||||
|
<?php foreach ($puzzles as $puzzle) : ?>
|
||||||
|
<li><a href="article.php?team=<?= $team_id ?>&id=<?= $puzzle["id"] ?>"><?= $tr["page_title"]["article"] . $puzzle["id"] . " : " . $puzzle["title"] ?></a></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif; ?>
|
||||||
</article>
|
</article>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
$this->pdo_teams = new PDO("sqlite:" . dirname(__FILE__) . $data_path . "teams.db");
|
$this->pdo_teams = new PDO("sqlite:" . dirname(__FILE__) . $data_path . "teams.db");
|
||||||
$this->pdo_teams->query('CREATE TABLE IF NOT EXISTS "teams" (
|
$this->pdo_teams->query('CREATE TABLE IF NOT EXISTS "teams" (
|
||||||
"id" INTEGER NOT NULL UNIQUE,
|
"id" INTEGER NOT NULL UNIQUE,
|
||||||
"bonus" INTEGER NOT NULL,
|
"bonus" INTEGER NOT NULL,
|
||||||
PRIMARY KEY("id" AUTOINCREMENT)
|
PRIMARY KEY("id" AUTOINCREMENT)
|
||||||
)');
|
)');
|
||||||
|
|
||||||
@ -45,11 +45,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkTeamExists(int $id) {
|
public function getArticle(int $id) {
|
||||||
$stmt = $this->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id");
|
$stmt = $this->pdo_article->prepare("SELECT * FROM puzzles WHERE id == :id");
|
||||||
$stmt->bindValue(":id", $id);
|
$stmt->bindValue(":id", $id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
return !empty($stmt->fetch());
|
return $stmt->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArticleNb() {
|
public function getArticleNb() {
|
||||||
@ -57,10 +57,85 @@
|
|||||||
return $query->fetch()["COUNT(*)"];
|
return $query->fetch()["COUNT(*)"];
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkTeamBonus(int $team) {
|
public function checkTeamExists(int $id) {
|
||||||
|
$stmt = $this->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id");
|
||||||
|
$stmt->bindValue(":id", $id);
|
||||||
|
$stmt->execute();
|
||||||
|
return !empty($stmt->fetch());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkArticleExists(int $id) {
|
||||||
|
return !empty($this->getArticle($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkPuzzle(int $id, string $code) {
|
||||||
|
$stmt = $this->pdo_article->prepare("SELECT * FROM puzzles WHERE (id == :id AND code == :code)");
|
||||||
|
$stmt->bindValue(":id", $id);
|
||||||
|
$stmt->bindValue(":code", $code);
|
||||||
|
$stmt->execute();
|
||||||
|
return !empty($stmt->fetch());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isPuzzleSolved(int $id, int $team) {
|
||||||
|
$stmt = $this->pdo_teams->prepare("SELECT * FROM solved WHERE (team_id == :team_id AND puzzle_id == :puzzle_id)");
|
||||||
|
$stmt->bindValue(":team_id", $team);
|
||||||
|
$stmt->bindValue(":puzzle_id", $id);
|
||||||
|
$stmt->execute();
|
||||||
|
return !empty($stmt->fetch());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function solvePuzzle(int $id, int $team) {
|
||||||
|
$stmt = $this->pdo_teams->prepare("INSERT INTO solved VALUES (:puzzle_id, :team_id)");
|
||||||
|
$stmt->bindValue(":puzzle_id", $id);
|
||||||
|
$stmt->bindValue(":team_id", $team);
|
||||||
|
$stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSolvedPuzzles(int $team) {
|
||||||
// $team doit être une équipe existante :
|
// $team doit être une équipe existante :
|
||||||
$query = $this->pdo_teams->query("SELECT bonus FROM teams WHERE id = " . $team);
|
$stmt = $this->pdo_teams->prepare("SELECT * FROM solved WHERE team_id == :id");
|
||||||
return $query->fetch()[0] == 1;
|
$stmt->bindValue(":id", $team);
|
||||||
|
$stmt->execute();
|
||||||
|
$res = $stmt->fetchAll();
|
||||||
|
$solved = [];
|
||||||
|
foreach ($res as $r) {
|
||||||
|
array_push($solved, $r["puzzle_id"]);
|
||||||
|
}
|
||||||
|
return $solved;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUnsolvedPuzzles(int $team) {
|
||||||
|
$solved = $this->getSolvedPuzzles($team);
|
||||||
|
$unsolved = range(1, $this->getArticleNb());
|
||||||
|
// On supprime les énigmes résolues :
|
||||||
|
foreach ($solved as $p) {
|
||||||
|
$key = array_search($p, $unsolved);
|
||||||
|
array_splice($unsolved, $key, 1);
|
||||||
|
}
|
||||||
|
return $unsolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNextPuzzle(int $team) {
|
||||||
|
$unsolved = $this->getUnsolvedPuzzles($team);
|
||||||
|
$next = -1; // Quand il n'y a plus d'autre énigme à résoudre
|
||||||
|
if (!empty($unsolved)) {
|
||||||
|
$next = $unsolved[array_rand($unsolved)];
|
||||||
|
}
|
||||||
|
return $next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkTeamBonus(int $team) {
|
||||||
|
// $team doit être une équipe existante :
|
||||||
|
$stmt = $this->pdo_teams->prepare("SELECT bonus FROM teams WHERE id == :id");
|
||||||
|
$stmt->bindValue(":id", $team);
|
||||||
|
$stmt->execute();
|
||||||
|
return $stmt->fetch()[0] == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTeams() {
|
||||||
|
$stmt = $this->pdo_teams->prepare("SELECT * FROM teams");
|
||||||
|
$stmt->execute();
|
||||||
|
return $stmt->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function getTeamsNb() {
|
// public function getTeamsNb() {
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
],
|
],
|
||||||
"puzzles" => [
|
"puzzles" => [
|
||||||
"message" => "Select a puzzle in the list below :",
|
"message" => "Select a puzzle in the list below :",
|
||||||
|
"success" => "Congratulations, you solved all the puzzles ! You can now select a specific puzzle in the list below :",
|
||||||
|
"pz_but" => "Solve a puzzle",
|
||||||
"map_desc" => "Here is a map showing the location of the puzzles you already solved :"
|
"map_desc" => "Here is a map showing the location of the puzzles you already solved :"
|
||||||
],
|
],
|
||||||
"nav" => [
|
"nav" => [
|
||||||
@ -45,4 +47,4 @@
|
|||||||
"text" => "Lycée Jean de Pange Sarreguemines<br><a href='https://forge.chapril.org/antux18/ChasseTresorPange'>Source code</a>"
|
"text" => "Lycée Jean de Pange Sarreguemines<br><a href='https://forge.chapril.org/antux18/ChasseTresorPange'>Source code</a>"
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
?>
|
?>
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
],
|
],
|
||||||
"puzzles" => [
|
"puzzles" => [
|
||||||
"message" => "Choisissez une énigme dans la liste ci-dessous :",
|
"message" => "Choisissez une énigme dans la liste ci-dessous :",
|
||||||
|
"success" => "Félicitations, vous avez résolu toutes les énigmes ! Vous pouvez maintenant sélectionner une énigme en particulier dans la liste ci-dessous :",
|
||||||
|
"pz_but" => "Résoudre une énigme",
|
||||||
"map_desc" => "Voici la carte des emplacements des énigmes que vous avez résolues :"
|
"map_desc" => "Voici la carte des emplacements des énigmes que vous avez résolues :"
|
||||||
],
|
],
|
||||||
"nav" => [
|
"nav" => [
|
||||||
@ -45,4 +47,4 @@
|
|||||||
"text" => "Lycée Jean de Pange Sarreguemines<br><a href='https://forge.chapril.org/antux18/ChasseTresorPange'>Code source</a>"
|
"text" => "Lycée Jean de Pange Sarreguemines<br><a href='https://forge.chapril.org/antux18/ChasseTresorPange'>Code source</a>"
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
?>
|
?>
|
||||||
|
@ -149,6 +149,7 @@ main header section {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once "require/base.php";
|
require_once "require/base.php";
|
||||||
|
|
||||||
$team_id = -1;
|
|
||||||
|
|
||||||
$database = new Database();
|
$database = new Database();
|
||||||
|
|
||||||
if (isset($_GET["team"])) {
|
if (isset($_GET["team"])) {
|
||||||
|
Loading…
Reference in New Issue
Block a user