-
Notifications
You must be signed in to change notification settings - Fork 0
/
checker.php
57 lines (56 loc) · 2.37 KB
/
checker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
include('include_haut.php');
if(isset($_POST['envoi']) && $_POST['envoi'] == 1)
{
$pseudo = htmlspecialchars($_POST['pseudo']);
$code = htmlspecialchars($_POST['code']);
$moment = date_valide(htmlspecialchars($_POST['moment']));
if(!($moment === false) && strlen($pseudo) > 0)
{
//On commence par voir si le monsieur est en BDD
$requete = mysql_query('SELECT id FROM utilisateurs WHERE pseudo = "'.$pseudo.'"');
if(!($requete === false) && $donnees2 = mysql_fetch_array($requete)) //Oui
{
$id_personne = $donnees2['id'];
if(strlen($code) > 0)
$requete = mysql_query('SELECT id_evenement FROM codes WHERE id_user = "'.$id_personne.'" AND codes.code = "'.$code.'"
AND date_debut <= ("'.$moment.'" + INTERVAL 5 MINUTE) AND date_fin >= ("'.$moment.'" - INTERVAL 5 MINUTE)');
else
$requete = mysql_query('SELECT id_evenement FROM codes WHERE id_user = "'.$id_personne.'"
AND date_debut <= ("'.$moment.'" + INTERVAL 5 MINUTE) AND date_fin >= ("'.$moment.'" - INTERVAL 5 MINUTE)');
if(!($requete === false) && $donnees = mysql_fetch_array($requete))
{
mysql_query('INSERT INTO checks (id_checkeur, id_checke, moment, evenement) VALUES ('.$_SESSION['id'].', '.$id_personne.', "'.$moment.'", '.$donnees['id_evenement'].')') or die(mysql_error());
header('location: index.php');
exit();
} else {
echo "Erreur";
exit();
}
} else { //Non, on utilise la procedure anonymous
mysql_query('INSERT INTO checks (id_checkeur, id_checke, moment, evenement) VALUES ('.$_SESSION['id'].', 0, "'.$moment.'", 0)') or die(mysql_error());
$id_check = mysql_insert_id();
mysql_query('INSERT INTO anonymous (id_check, pseudo) VALUES ('.$id_check.', "'.$pseudo.'")');
header('location: index.php');
exit();
}
} else {
echo "Erreur";
exit();
}
}
include("page_haut.php");
?>
<h1>Checker</h1>
<form action="checker.php" method="post">
<label name="pseudo">Pseudo : <br />
<input name="pseudo" /></label><br />
<label name="code">Code : <br />
<input name="code" /></label><br />
<label name="moment">Quand ? <a onclick="mettre_maintenant();" style="text-decoration: underline;">Maintenant</a><br />
Format : AAAA-MM-JJ HH:MM:SS<br />
<input name="moment" id="moment" /></label><br />
<input name="envoi" value="1" type="hidden" />
<input type="submit" value="Valider" />
</form>
<?php include('page_bas.php'); ?>