2022-06-14 23:36:26 +02:00
|
|
|
<?php
|
|
|
|
include "script.php";
|
|
|
|
|
2023-04-16 15:27:19 +02:00
|
|
|
include "../assets/scripts/globals.php";
|
2023-01-26 15:53:45 +01:00
|
|
|
|
2022-07-24 19:54:06 +02:00
|
|
|
if($user['perm'] < 3) {
|
2022-06-14 23:36:26 +02:00
|
|
|
header('Location: deco.php');
|
|
|
|
}
|
2022-06-15 22:58:37 +02:00
|
|
|
|
|
|
|
$req = $db->query("SELECT * FROM enigma WHERE id = 1");
|
|
|
|
$r = $req -> fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
|
2023-05-04 14:50:55 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Le principe est qu'une seule énigme est émise en même temps,
|
|
|
|
il s'agit de la même pour les deux équipes.
|
|
|
|
D'où le fait que l'id de l'entrée est hardcode à 1.
|
|
|
|
|
|
|
|
La série de if est faite pour n'avoir qu'a remplir la/les colonne(s) dans l'interface
|
|
|
|
que l'on souhaite modifier dans la BDD.
|
|
|
|
*/
|
|
|
|
|
2022-06-15 22:58:37 +02:00
|
|
|
if(isset($_POST['send'])) {
|
2023-05-04 14:50:55 +02:00
|
|
|
|
|
|
|
// on vérifie les privilèges de l'utilisateur
|
2022-07-24 19:54:06 +02:00
|
|
|
if($user['perm'] >= 3) {
|
2023-05-04 14:50:55 +02:00
|
|
|
|
|
|
|
|
2022-06-16 14:38:31 +02:00
|
|
|
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));
|
|
|
|
}
|
2023-05-04 14:50:55 +02:00
|
|
|
|
2022-06-16 14:38:31 +02:00
|
|
|
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));
|
|
|
|
}
|
2023-05-04 14:50:55 +02:00
|
|
|
|
2022-06-16 14:38:31 +02:00
|
|
|
if(isset($_POST['team']) AND !empty($_POST['team'])) {
|
|
|
|
switch (htmlspecialchars($_POST['team'])) {
|
2023-05-04 14:50:55 +02:00
|
|
|
|
|
|
|
// le cas "t" est lorsque aucune équipe n'a encore trouvé
|
2022-06-16 14:38:31 +02:00
|
|
|
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));
|
2022-06-15 22:58:37 +02:00
|
|
|
}
|
2022-06-16 14:38:31 +02:00
|
|
|
header('Refresh:0');
|
2022-06-15 22:58:37 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-15 17:35:34 +02:00
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<title>Admin / Enigma</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<main>
|
2022-06-15 22:58:37 +02:00
|
|
|
<form method="POST">
|
|
|
|
<input type="texte" name="answer" placeholder="answer" class="input_inline">
|
|
|
|
<input type="number" name ="points" placeholder="points" class="input_inline">
|
2023-05-04 14:50:55 +02:00
|
|
|
<select name="team" class="input_inline" id="team">
|
|
|
|
<option value="t">AUCUNE EQUIPE</option>
|
2023-01-26 15:53:45 +01:00
|
|
|
<option value="t0"><?=$TEAM1?></option>
|
|
|
|
<option value="t1"><?=$TEAM2?></option>
|
2022-06-15 22:58:37 +02:00
|
|
|
</select>
|
2023-05-04 14:50:55 +02:00
|
|
|
|
|
|
|
<label for="team">Equipe ayant trouvé l'énigme.</label>
|
2022-06-15 22:58:37 +02:00
|
|
|
<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>
|
2023-05-04 14:50:55 +02:00
|
|
|
<td>
|
|
|
|
<?php
|
2022-06-15 22:58:37 +02:00
|
|
|
switch ($r[0]['team']) {
|
|
|
|
case "0":
|
2023-01-26 15:53:45 +01:00
|
|
|
echo $TEAM1;
|
2022-06-15 22:58:37 +02:00
|
|
|
break;
|
|
|
|
case "1":
|
2023-01-26 15:53:45 +01:00
|
|
|
echo $TEAM2;
|
2022-06-15 22:58:37 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
?></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
2022-06-15 17:35:34 +02:00
|
|
|
</main>
|
|
|
|
</body>
|
|
|
|
</html>
|