admin / enigma

This commit is contained in:
Baptiste 2022-06-15 22:58:37 +02:00
parent f91407f051
commit 291f1ff465
4 changed files with 69 additions and 5 deletions

View file

@ -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');
}
?>
<!DOCTYPE html>
<html>
@ -14,6 +46,39 @@ if($user['perm'] < 2) {
</head>
<body>
<main>
<form method="POST">
<input type="texte" name="answer" placeholder="answer" class="input_inline">
<input type="number" name ="points" placeholder="points" class="input_inline">
<select name="team" class="input_inline">
<option value="t">NULL</option>
<option value="t0">Pkpeach</option>
<option value="t1">Boomario</option>
</select>
<input type="submit" name="send" value="Mettre à jour" class="submit_inline">
</form>
<table class="acces">
<tr>
<th width="10%">ID (db)</td>
<th width="40%">Answer</td>
<th width="20%">Points</td>
<th width="10%">Team</td>
</tr>
<tr>
<td><?= $r[0]['id'] ?></td>
<td><?= $r[0]['answer'] ?></td>
<td><?= $r[0]['point'] ?></td>
<td><?php
switch ($r[0]['team']) {
case "0":
echo "Pkpeach";
break;
case "1":
echo "Boomario";
break;
}
?></td>
</tr>
</table>
</main>
</body>
</html>

View file

@ -32,7 +32,6 @@ if($user_exist != 1) {
.'<a href="planning.php"><li class="orange">Planning</li></a>'
.'<a href="gestion_des_acces.php"><li class="red">Gestion des accès</li></a>'
.'<a href="enigma.php"><li class="red">Enigma</li></a>'
.'<a href="stats.php"><li class="red">Stats</li></a>'
.'<a href="vacances.php"><li class="red">Vacances</li></a>';
break;
}

View file

@ -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));

View file

@ -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));
?><script type="text/javascript">alert("Félicitation, vous avez fait gagner 500points à votre équipe");</script><?php
}