master #1
BIN
data/teams.db
BIN
data/teams.db
Binary file not shown.
26
puzzles.php
26
puzzles.php
@ -2,6 +2,7 @@
|
||||
require_once "require/base.php";
|
||||
|
||||
$puzzles = array();
|
||||
$order = 0;
|
||||
$team_id = -1;
|
||||
|
||||
$database = new Database();
|
||||
@ -35,6 +36,23 @@
|
||||
|
||||
$stmt->execute();
|
||||
$puzzles = $stmt->fetchAll();
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,8 +83,12 @@
|
||||
<article>
|
||||
<p><?= $tr["puzzles"]["message"]?></p>
|
||||
<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 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; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</article>
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
require_once "database.php";
|
||||
require_once "puzzles_order.php";
|
||||
|
||||
$rq_path = "require/";
|
||||
|
||||
|
9
require/puzzles_order.php
Normal file
9
require/puzzles_order.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
$pzorder = [
|
||||
[7,4,3,2,5,8,9,6,10,1],
|
||||
[10,6,8,5,2,7,4,3,1],
|
||||
[5,2,7,4,3,6,8,10,1],
|
||||
[3,6,8,10,9,4,7,5,8,2,1],
|
||||
[9,6,10,4,7,8,5,3,2,1]
|
||||
]
|
||||
?>
|
Loading…
Reference in New Issue
Block a user