forked from vergnet/site-accueil-insa
ville coté client
This commit is contained in:
parent
0e30bafa3d
commit
a143d1e373
2 changed files with 154 additions and 7 deletions
|
@ -28,3 +28,45 @@ a.team:hover {
|
|||
transition: 0.3s ease-out;
|
||||
border: 2px solid red;
|
||||
}
|
||||
|
||||
.img_enigme {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 50%;
|
||||
background-color: white;
|
||||
border: 3px solid grey;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
height: 50px;
|
||||
margin: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.submit {
|
||||
width: 50%;
|
||||
background-color: grey;
|
||||
border: 3px solid grey;
|
||||
color: white;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
height: 50px;
|
||||
margin: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.submit:hover {
|
||||
transition: 0.3s ease;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.submit {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 80%;
|
||||
}
|
||||
}
|
119
com_ville.php
119
com_ville.php
|
@ -4,30 +4,133 @@ include "assets/fonts/color.php";
|
|||
|
||||
include "script/db.php";
|
||||
|
||||
$nombre_d_epreuve = (int) 17;
|
||||
|
||||
if(isset($_GET['team']) AND !empty($_GET['team']))
|
||||
{
|
||||
$team = (int) htmlspecialchars($_GET['team']);
|
||||
|
||||
$req = $db->prepare("SELECT id FROM ville_equipe WHERE id = ?");
|
||||
$req = $db->prepare("SELECT * FROM ville_equipe WHERE id = ?");
|
||||
$req->execute(array($team));
|
||||
$rc = $req->rowcount();
|
||||
$r = $req -> fetchAll(PDO::FETCH_ASSOC);
|
||||
if($rc == 1) {
|
||||
if($r[0]['id'] < 17) {
|
||||
if($r[0]['id'] < $nombre_d_epreuve) {
|
||||
$session = 1;
|
||||
} else {
|
||||
$session = 2;
|
||||
}
|
||||
$reqtest = $db->prepare("SELECT state FROM ville WHERE session = ?");
|
||||
$reqtest->execute(array($session));
|
||||
$rtest = $reqtest -> fetchAll(PDO::FETCH_ASSOC);
|
||||
if($rtest[0]['state']<1 OR $rtest[0]['state']>2 ) {
|
||||
$reqsession = $db->prepare("SELECT state, time_begin FROM ville WHERE session = ?");
|
||||
$reqsession->execute(array($session));
|
||||
$rs = $reqsession -> fetchAll(PDO::FETCH_ASSOC);
|
||||
if($rs[0]['state']<1 OR $rs[0]['state']>2 ) {
|
||||
header('Location: error.php');
|
||||
}
|
||||
} else {
|
||||
header('Location: error.php');
|
||||
}
|
||||
}
|
||||
|
||||
//page avec le GET team
|
||||
$name = $r[0]["nom"];
|
||||
$begin = $r[0]["begin"];
|
||||
$temps_init = $r[0]["temps"];
|
||||
$tab_time = explode(";", $temps_init);
|
||||
|
||||
if($temps_init == NULL) {
|
||||
$avancement = (int) 0;
|
||||
$delta_temps = time() - $rs[0]['time_begin'];
|
||||
$delta_temps_begin = $delta_temps;
|
||||
} else {
|
||||
$avancement = count($tab_time);
|
||||
$delta_temps = time() - $tab_time[$avancement-1];
|
||||
$delta_temps_begin = time() - $rs[0]['time_begin'];
|
||||
$def_time = $tab_time[$avancement-1] - $rs[0]['time_begin'];
|
||||
}
|
||||
|
||||
$etape = (int) ($begin + $avancement)%($nombre_d_epreuve+1); //attention ici pour 2022 on a decidé d'avoir une épreuve de plus que de nombre d'équipe, à refaire en fonction des années <=> [nombre d'équipe = nombre d'épreuve - 1]
|
||||
if($begin + $avancement <= 17) {
|
||||
$etape = $begin + $avancement;
|
||||
} else {
|
||||
$etape = ( ($begin + $avancement)%($nombre_d_epreuve+1) ) + 1; //même chose ici
|
||||
}
|
||||
$req = $db->prepare("SELECT * FROM ville_epreuve WHERE id = ?");
|
||||
$req->execute(array($etape));
|
||||
$r = $req -> fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if($avancement+1 <= $nombre_d_epreuve) {
|
||||
if(isset($_POST['send'])) {
|
||||
if(isset($_POST['answer']) AND !empty($_POST['answer'])) {
|
||||
$pass = htmlspecialchars($_POST['answer']);
|
||||
|
||||
if($pass == $r[0]['reponse']) {
|
||||
if($temps_init == NULL) {
|
||||
$temps_new = time();
|
||||
} else {
|
||||
$temps_new = $temps_init.";".time();
|
||||
}
|
||||
|
||||
$req = $db->prepare("UPDATE ville_equipe SET temps = ? WHERE id = ?");
|
||||
$req->execute(array($temps_new, $team));
|
||||
header('Refresh: 0');
|
||||
} else {
|
||||
$error = "Le code est incorrect";
|
||||
}
|
||||
} else {
|
||||
$error = "Vous devez entrer le code pour passer à l'étape suivante !";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<main>
|
||||
<div class="box-jaune">
|
||||
<span class="corners corners-top"></span>
|
||||
<span class="corners corners-bottom"></span>
|
||||
|
||||
<div class="title">
|
||||
Equipe <?= $name ?>
|
||||
<?php
|
||||
if($avancement+1 <= $nombre_d_epreuve) {
|
||||
echo '<br>Etape <font color="red">'.($avancement+1).'</font>/17';
|
||||
} else {
|
||||
echo '<br><font color="red">finit</font> aka <font color="red">17</font>/17';
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
<span class="circles circles-top"></span>
|
||||
<span class="circles circles-bottom"></span>
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<?php
|
||||
if($avancement+1 <= $nombre_d_epreuve) {
|
||||
?>
|
||||
L'épreuve à commencé depuis <font color="red"><?= gmdate("H:i:s",$delta_temps_begin) ?></font> !<br>
|
||||
Vous êtes sur cette étape depuis <font color="red"><?= gmdate("H:i:s",$delta_temps) ?></font> !<br><br>
|
||||
<?php if($r[0]["photo"] != NULL) { ?><img src="assets/img/com_ville/<?= $r[0]["photo"] ?>" class="img_enigme"><br><br><?php } ?>
|
||||
<strong><?= $r[0]["indice"] ?></strong><br><br>
|
||||
<form method="POST">
|
||||
<input type="text" placeholder="le code (the only one)" name="answer" class="input">
|
||||
<input type="submit" name="send" value="Passer à l'étape suivante" class="submit">
|
||||
</form>
|
||||
<font color="red"><?php if(isset($error)) { echo $error; } ?></font>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
Vous avez finit le circuit en <font color="red"><?= gmdate("H:i:s",$def_time) ?></font> !<br><br>
|
||||
<?= colored_text("Felicitation") ?> !
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</section>
|
||||
</main>
|
||||
<?php
|
||||
//gin de la page avec le GET team
|
||||
} else {
|
||||
//page sans le GET team
|
||||
?>
|
||||
<main>
|
||||
<div class="box-jaune">
|
||||
|
@ -115,6 +218,8 @@ if(isset($_GET['team']) AND !empty($_GET['team']))
|
|||
?>
|
||||
</main>
|
||||
<?php
|
||||
} //fin de la page ou y'a pas de GET team
|
||||
|
||||
$infopage = ["", "Com'ville", ob_get_clean(), "", "com_ville"]; //relativepath, pagetitle, pagecontent, pagescript, pagename | cf structure/template.php ligne 2 à 6
|
||||
include("structure/template.php");
|
||||
?>
|
Loading…
Reference in a new issue