Suppression des codes QR.
Ajout de commentaires. Corrections mineures du code.
@ -16,7 +16,7 @@
|
||||
$stmt->execute();
|
||||
|
||||
// Vérification de l'existence du groupe :
|
||||
if (!empty($stmt->fetchAll())) {
|
||||
if (!empty($stmt->fetch())) {
|
||||
$art_id = htmlspecialchars($_GET["id"]);
|
||||
|
||||
// Recherche de l'énigme avec son code :
|
||||
|
@ -11,22 +11,26 @@
|
||||
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 :
|
||||
// Recherche de l'équipe dans la base :
|
||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams WHERE id == :id");
|
||||
$stmt->bindValue(":id", $team_id);
|
||||
$stmt->execute();
|
||||
|
||||
if (empty($article) || empty($stmt->fetchAll())) {
|
||||
// Vérification de l'existence du groupe et de l'énigme :
|
||||
if (empty($article) || empty($stmt->fetch())) {
|
||||
header("Location: index.php");
|
||||
die();
|
||||
}
|
||||
|
||||
else {
|
||||
// On vérifie 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);
|
||||
|
BIN
data/teams.db
Before Width: | Height: | Size: 740 B |
Before Width: | Height: | Size: 740 B |
Before Width: | Height: | Size: 755 B |
Before Width: | Height: | Size: 731 B |
Before Width: | Height: | Size: 737 B |
Before Width: | Height: | Size: 738 B |
Before Width: | Height: | Size: 750 B |
Before Width: | Height: | Size: 751 B |
Before Width: | Height: | Size: 735 B |
Before Width: | Height: | Size: 741 B |
Before Width: | Height: | Size: 747 B |
Before Width: | Height: | Size: 743 B |
Before Width: | Height: | Size: 745 B |
13
index.php
@ -1,16 +1,19 @@
|
||||
<?php
|
||||
require_once "require/base.php";
|
||||
|
||||
// Si l'appareil a déjà choisi une équipe, on le redirige vers la bonne page :
|
||||
if (isset($_COOKIE["team"])) {
|
||||
header("Location: puzzles.php?team=" . htmlspecialchars($_COOKIE["team"]));
|
||||
die();
|
||||
}
|
||||
|
||||
$database = new Database();
|
||||
|
||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams");
|
||||
$stmt->execute();
|
||||
$teams = $stmt->fetchAll();
|
||||
// Sinon, on affiche la liste des équipes :
|
||||
else {
|
||||
$database = new Database();
|
||||
$stmt = $database->pdo_teams->prepare("SELECT * FROM teams");
|
||||
$stmt->execute();
|
||||
$teams = $stmt->fetchAll();
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
@ -18,6 +18,7 @@
|
||||
header("Location: index.php");
|
||||
die();
|
||||
}
|
||||
|
||||
else {
|
||||
// On crée un cookie pour enregistrer l'équipe sélectionnée si ce n'est pas fait :
|
||||
if (!isset($_COOKIE["team"])) {
|
||||
@ -37,11 +38,12 @@
|
||||
$stmt->bindValue(":id", $team_id);
|
||||
$stmt->execute();
|
||||
|
||||
// Si c'est le cas, on affiche toutes les énigmes, sinon, on cache la bonus :
|
||||
// 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 :
|
||||
else {
|
||||
$stmt = $database->pdo_article->prepare("SELECT * FROM puzzles WHERE id <> 13");
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
$lg = "en";
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
if (isset($_COOKIE["language"])) {
|
||||
if (htmlspecialchars($_COOKIE["language"]) == "en") {
|
||||
|
@ -6,20 +6,25 @@
|
||||
public function __construct() {
|
||||
$data_path = "/../data/";
|
||||
try {
|
||||
// Création des bases de données
|
||||
// Base des énigmes :
|
||||
$this->pdo_article = new PDO("sqlite:" . dirname(__FILE__) . $data_path . "article.db");
|
||||
$this->pdo_article->query('CREATE TABLE IF NOT EXISTS "puzzles" (
|
||||
"id" INTEGER NOT NULL UNIQUE,
|
||||
"title" TEXT NOT NULL,
|
||||
"text" TEXT NOT NULL,
|
||||
"hint" TEXT,
|
||||
"infos" TEXT NOT NULL,
|
||||
"place" TEXT NOT NULL,
|
||||
"answer" TEXT NOT NULL,
|
||||
"location" TEXT NOT NULL,
|
||||
"code" TEXT NOT NULL,
|
||||
PRIMARY KEY("id" AUTOINCREMENT)
|
||||
)');
|
||||
|
||||
// Base des équipes :
|
||||
$this->pdo_teams = new PDO("sqlite:" . dirname(__FILE__) . $data_path . "teams.db");
|
||||
$this->pdo_teams->query('CREATE TABLE IF NOT EXISTS "teams" (
|
||||
"id" INTEGER NOT NULL UNIQUE,
|
||||
"bonus" INTEGER NOT NULL,
|
||||
PRIMARY KEY("id" AUTOINCREMENT)
|
||||
)');
|
||||
|
||||
@ -27,6 +32,11 @@
|
||||
"puzzle_id" INTEGER NOT NULL,
|
||||
"team_id" INTEGER NOT NULL
|
||||
)');
|
||||
|
||||
$this->pdo_teams->query('CREATE TABLE IF NOT EXISTS "members" (
|
||||
"name" TEXT NOT NULL,
|
||||
"team_id" INTEGER NOT NULL
|
||||
)');
|
||||
}
|
||||
|
||||
catch (PDOException $exception) {
|
||||
@ -35,14 +45,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
public function getArticleNb() {
|
||||
$query = $this->pdo_article->query("SELECT COUNT(*) FROM puzzles");
|
||||
return $query->fetch()["COUNT(*)"];
|
||||
}
|
||||
// public function getArticleNb() {
|
||||
// $query = $this->pdo_article->query("SELECT COUNT(*) FROM puzzles");
|
||||
// return $query->fetch()["COUNT(*)"];
|
||||
// }
|
||||
|
||||
public function getTeamsNb() {
|
||||
$query = $this->pdo_teams->query("SELECT COUNT(*) FROM teams");
|
||||
return $query->fetch()["COUNT(*)"];
|
||||
}
|
||||
// public function getTeamsNb() {
|
||||
// $query = $this->pdo_teams->query("SELECT COUNT(*) FROM teams");
|
||||
// return $query->fetch()["COUNT(*)"];
|
||||
// }
|
||||
}
|
||||
?>
|