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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
| <?php
//jours d'avances afffiché
$jours_avance = 14;
//heure de debut
$heure_debut = 7;
//heure de fin
$heure_fin = 21;
//nombres de terrains
$nb_terrains = 5;
//nom de la page
$page = 'tennis.php';
?>
<html>
<head>
<title>Réservez votre terrain de tennis</title>
<style type="text/css">
body
{
background-image: url("untitled.bmp");
}
table td
{
border: 1px solid black;
text-align: center;
}
h1
{
text-align:center ;
font-family:Comic Sans MS
}
caption
{
margin: auto;
}
table
{
margin: auto;
font-family:Comic Sans MS
}
p
{
text-align: center;
}
</style>
</head>
<body>
<?php
if(!isset($_POST['pass']))
{
if(!isset($_GET['t']))
{
////////////////////// PAGE D'AFFICHAGE /////////////////////////////
?>
<h1>Réservations des terrains :</h1>
<p>
Bonjour et bienvenue sur le site de réservation du TC Ploufragan,<br/>
Merci de prendre en compte les différents critères ci-dessous : <br/>
( si une réservation est faite alors que le terrain était réserver suivants les critères ci-dessous alors elle ne sera pas valable ! )<br/>
<br/>
Les entrainements ont lieu le lundi à 17h ==> 20h : 2 terrains<br/>
mardi de 18h30==> 21h : 3 terrains (terre balle )<br/>
mercredi 11h ==> 21h : 2 terrains (terre battue)<br/>
.............<br/>
ATENTION : tournoi du club du mardi 20 octobre au 1 aout 2009 : aucune réservation valable durant cette pérode ( contactez le club au 0296...)
<br/><br/><br/>
<table>
<tr><!--jours-->
<td>Jours / Heures</td>
<?php
$time = time();
for($i = 0; $i < $jours_avance; $i++)
{
echo '
<td>
'.date('d/m', $time).'
</td>';
$time = $time +(60*60*24);
}
?>
</tr>
<?php
chmod ("/reservations.txt", 777);
$reservations = fopen("reservations.txt", "r+");
$tab_reservations = file("reservations.txt");
$tab_resa = array();
$tab_pseudo = array();
foreach($tab_reservations as $cle=>$valeur)//on supprime les mot de passe en fin de resa
{
$val = explode('_', $valeur);
$tab_resa[$cle] = $val[0].'_'.$val[1];
$tab_pseudo[$cle] = $val[3];
}
$nb_terrains_reserve =0;
for($h = $heure_debut; $h <= $heure_fin; $h++)
{
echo '
<tr>
<td>
'.$h.'h
</td>';
//on s'occupe ici des cases interieures du tableau
//on affiche tout les terrains
$time = time();
for($j=0; $j <$jours_avance; $j++)//jour par jour
{
echo '<td>';
for($i=1; $i<=$nb_terrains; $i++)
{
$num = $i.'_'.mktime($h, '0', '0', date("m", $time), date("d", $time), date("Y", $time)).'';
if(in_array($num, $tab_resa))
{
//si le terrain est reservé
echo '<a href="#" style="color:black;text-decoration:none;background-color:#FF6600;" title="Réservation : '.$tab_pseudo[$nb_terrains_reserve].'">'.$i.'|</a>';
$nb_terrains_reserve ++;
}
else
{
//si le terrain est libre
echo '<a href="?t='.$num.'" style="color:black;text-decoration:none;background-color:;">'.$i.'|</a>';
}
}
echo'</td>';
$time = $time +(60*60*24);
}
echo '
</tr>';
}
fclose($reservations);
?>
</table>
<?php
}
else ////////////////// PAGE DE COMFIRMATION //////////////////
{
$t = explode('_', htmlentities($_GET['t']));
?>
<h1>Reservation :</h1>
<p>Etes vous sûr de vouloir reserver le terrain n
<?php echo $t[0].', le '.date("d/m", $t[1]).' à '.date("H", $t[1]).'h ?'; ?>
</p>
<form method="post" action="">
<input type="hidden" value="<?php echo htmlentities($_GET['t']);?>" name="id"/>
<p>Mot de passe : <input type="password" name="pass"/><br/>
Nom et Prénom des joueurs : <input type="text" name="pseudo"/><br/>
<br/>
<input type="submit" value="Oui"/> <input type="button" value="Non" onClick="history.go(-1);"/></p>
</form>
<?php
//////////// fin /////////
}
}
else///////////////////////// PAGE D'ENREGISTREMENT DE LA RESERVATION /////////////////
{
chmod ("/mdp.txt", 777);
$mdp = fopen("mdp.txt", "r+");
$tab_mdp = file("mdp.txt");
chmod ("/reservations.txt", 777);
$mdp = fopen("reservations.txt", "r+");
$tab_resa = file("reservations.txt");
$id = explode('_', htmlentities($_POST['id']));
$t_debut = mktime('0', '0', '0', date("m", $id[1]), date("d", $id[1]), date("Y", $id[1]));
$t_fin = mktime('23', '59', '59', date("m", $id[1]), date("d", $id[1]), date("Y", $id[1]));
$i =0;
foreach($tab_resa as $cle=>$valeur)//on recupere uniquement les mots de passe utilisé dans la journée
{
$val = explode('_', $valeur);
if($val[1] <= $t_fin AND $val[1] >= $t_debut AND $val[2] == htmlentities($_POST['pass']).'
')
{
$i++; //il existe deja un mot de passe qui a reservé pour la journée
}
}
if($i >= 1)//si la personne a deja reservé sur la journée
{
////////////// Si la personne a deja reservé un terrain dans la journée /////
?>
<p><h1>Vous avez déjà réservé un terrain pour cette journée</h1></p>
<p><a href="<?php echo $page;?>">Retour</a><br/><p/>
<?php
//////////// Fin //////////
}
else
{
if(in_array(htmlentities($_POST['pass']).'
', $tab_mdp))//si le mot de passe est ok
{
chmod ("/reservations.txt", 777);
$reservations = fopen("reservations.txt", "a+");
feof($reservations);
fwrite($reservations, htmlentities($_POST['id']).'_'.htmlentities($_POST['pass']).'_'.htmlentities($_POST['pseudo']).'
');
fclose($reservations);
/////////// si le terrain est bien enregistré//////////
?>
<p><h1>Enregistrement : OK</h1></p>
<p>
<a href="<?php echo $page;?>">Retour</a><br/>
</p>
<?php
///////// fin ///////
}
else
{
//////// si le mot de passe est faux ///////
?>
<h1>Enregistrement : Erreur de mot de passe</h1>
<p><a href="<?php echo $page;?>">Retour</a><br/></p>
<?php
/////// fin //////
}
}
}
?>
</body>
</html> |
Partager