diff --git a/answer.php b/answer.php index 86a4263..00aab09 100644 --- a/answer.php +++ b/answer.php @@ -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 : diff --git a/article.php b/article.php index b680f0e..f1c9ba6 100644 --- a/article.php +++ b/article.php @@ -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); diff --git a/data/teams.db b/data/teams.db index 2f2a624..82b9f18 100644 Binary files a/data/teams.db and b/data/teams.db differ diff --git a/images/qr/qr1.gif b/images/qr/qr1.gif deleted file mode 100644 index ce94f54..0000000 Binary files a/images/qr/qr1.gif and /dev/null differ diff --git a/images/qr/qr10.gif b/images/qr/qr10.gif deleted file mode 100644 index a3b68fc..0000000 Binary files a/images/qr/qr10.gif and /dev/null differ diff --git a/images/qr/qr11.gif b/images/qr/qr11.gif deleted file mode 100644 index 3b0f756..0000000 Binary files a/images/qr/qr11.gif and /dev/null differ diff --git a/images/qr/qr12.gif b/images/qr/qr12.gif deleted file mode 100644 index e407b36..0000000 Binary files a/images/qr/qr12.gif and /dev/null differ diff --git a/images/qr/qr13.gif b/images/qr/qr13.gif deleted file mode 100644 index d155c0c..0000000 Binary files a/images/qr/qr13.gif and /dev/null differ diff --git a/images/qr/qr2.gif b/images/qr/qr2.gif deleted file mode 100644 index 641a951..0000000 Binary files a/images/qr/qr2.gif and /dev/null differ diff --git a/images/qr/qr3.gif b/images/qr/qr3.gif deleted file mode 100644 index 3fa7293..0000000 Binary files a/images/qr/qr3.gif and /dev/null differ diff --git a/images/qr/qr4.gif b/images/qr/qr4.gif deleted file mode 100644 index 8b08ce4..0000000 Binary files a/images/qr/qr4.gif and /dev/null differ diff --git a/images/qr/qr5.gif b/images/qr/qr5.gif deleted file mode 100644 index 091b18e..0000000 Binary files a/images/qr/qr5.gif and /dev/null differ diff --git a/images/qr/qr6.gif b/images/qr/qr6.gif deleted file mode 100644 index ccbf6f3..0000000 Binary files a/images/qr/qr6.gif and /dev/null differ diff --git a/images/qr/qr7.gif b/images/qr/qr7.gif deleted file mode 100644 index 8fdbcda..0000000 Binary files a/images/qr/qr7.gif and /dev/null differ diff --git a/images/qr/qr8.gif b/images/qr/qr8.gif deleted file mode 100644 index 6c4c54a..0000000 Binary files a/images/qr/qr8.gif and /dev/null differ diff --git a/images/qr/qr9.gif b/images/qr/qr9.gif deleted file mode 100644 index 0f00f56..0000000 Binary files a/images/qr/qr9.gif and /dev/null differ diff --git a/index.php b/index.php index ba05edf..6d78f9c 100644 --- a/index.php +++ b/index.php @@ -1,16 +1,19 @@ 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(); + } ?> diff --git a/puzzles.php b/puzzles.php index d17ec2e..e572353 100644 --- a/puzzles.php +++ b/puzzles.php @@ -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"); } diff --git a/require/base.php b/require/base.php index fe654d5..7c2d9d7 100644 --- a/require/base.php +++ b/require/base.php @@ -10,6 +10,7 @@ $lg = "en"; } } + else { if (isset($_COOKIE["language"])) { if (htmlspecialchars($_COOKIE["language"]) == "en") { diff --git a/require/database.php b/require/database.php index 24ab06c..7c1d848 100644 --- a/require/database.php +++ b/require/database.php @@ -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(*)"]; + // } } ?> \ No newline at end of file