From 291f1ff46556c3494baf96dc3bed8933759c6785 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Wed, 15 Jun 2022 22:58:37 +0200 Subject: [PATCH] admin / enigma --- admin/enigma.php | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ admin/script.php | 1 - enigma.php | 4 +-- vacances.php | 4 +-- 4 files changed, 69 insertions(+), 5 deletions(-) diff --git a/admin/enigma.php b/admin/enigma.php index 07115b3..ea20c0c 100644 --- a/admin/enigma.php +++ b/admin/enigma.php @@ -4,6 +4,38 @@ include "script.php"; if($user['perm'] < 2) { header('Location: deco.php'); } + +$req = $db->query("SELECT * FROM enigma WHERE id = 1"); +$r = $req -> fetchAll(PDO::FETCH_ASSOC); + +if(isset($_POST['send'])) { + if(isset($_POST['answer']) AND !empty($_POST['answer'])) { + $ans = htmlspecialchars($_POST['answer']); + $req = $db->prepare("UPDATE enigma SET answer = ? WHERE id = 1"); + $req->execute(array($ans)); + } + if(isset($_POST['points']) AND !empty($_POST['points'])) { + $point = (int) htmlspecialchars($_POST['points']); + $req = $db->prepare("UPDATE enigma SET point = ? WHERE id = 1"); + $req->execute(array($point)); + } + if(isset($_POST['team']) AND !empty($_POST['team'])) { + switch (htmlspecialchars($_POST['team'])) { + case "t": + $t_int = NULL; + break; + case "t0": + $t_int = 0; + break; + case "t1": + $t_int = 1; + break; + } + $req = $db->prepare("UPDATE enigma SET team = ? WHERE id = 1"); + $req->execute(array($t_int)); + } + header('Refresh:0'); +} ?> @@ -14,6 +46,39 @@ if($user['perm'] < 2) {
+
+ + + + +
+ + + + + + + + + +
ID (db) + Answer + Points + Team +
\ No newline at end of file diff --git a/admin/script.php b/admin/script.php index 8e75895..5aee025 100644 --- a/admin/script.php +++ b/admin/script.php @@ -32,7 +32,6 @@ if($user_exist != 1) { .'
  • Planning
  • ' .'
  • Gestion des accès
  • ' .'
  • Enigma
  • ' - .'
  • Stats
  • ' .'
  • Vacances
  • '; break; } diff --git a/enigma.php b/enigma.php index 7d0fbfb..ea7bf11 100644 --- a/enigma.php +++ b/enigma.php @@ -24,8 +24,8 @@ if(isset($_POST['send'])) { if($ans == $reponse[0]['answer']) { - $req = $db->prepare("INSERT INTO scores(texte, points, team) VALUES(?, ?, ?)"); - $req->execute(array("enigme de la plaquette", $reponse[0]['point'], $team)); + $req = $db->prepare("INSERT INTO scores(texte, points, team, id_staff) VALUES(?, ?, ?, ?)"); + $req->execute(array("enigme de la plaquette", $reponse[0]['point'], $team, 0)); $req = $db->prepare("UPDATE enigma SET team = ? WHERE id = 1"); $req->execute(array($team)); diff --git a/vacances.php b/vacances.php index efb5b93..540a0c6 100644 --- a/vacances.php +++ b/vacances.php @@ -45,8 +45,8 @@ if(isset($_POST['send'])) { header('Refresh: 0'); } - $req = $db->prepare("INSERT INTO scores(texte, points, team) VALUES(?, ?, ?)"); - $req->execute(array("Mots croises","500", $team)); + $req = $db->prepare("INSERT INTO scores(texte, points, team, id_staff) VALUES(?, ?, ?, ?)"); + $req->execute(array("Mots croises","500", $team, 0)); ?>