Séparation vue et contrôleur
This commit is contained in:
parent
a1b4c42707
commit
a1ef162bdb
48
.htaccess
48
.htaccess
|
@ -7,30 +7,30 @@ RewriteEngine On
|
|||
RewriteOptions Inherit
|
||||
RewriteBase /tfjm
|
||||
RewriteRule index.html accueil [L]
|
||||
RewriteRule ^accueil$ server_files/index.php [L]
|
||||
RewriteRule ^ajouter_equipe$ server_files/ajouter_equipe.php [L]
|
||||
RewriteRule ^ajouter_organisateur$ server_files/ajouter_organisateur.php [L]
|
||||
RewriteRule ^ajouter_tournoi$ server_files/ajouter_tournoi.php [L]
|
||||
RewriteRule ^confirmer_mail/(.*?)$ server_files/confirmer_mail.php?token=$1 [L]
|
||||
RewriteRule ^connexion$ server_files/connexion.php [L]
|
||||
RewriteRule ^connexion/reinitialiser_mdp/(.*?)$ server_files/connexion.php?reset_password&token=$1 [L]
|
||||
RewriteRule ^connexion/(.*?)$ server_files/connexion.php?$1 [L]
|
||||
RewriteRule ^deconnexion$ server_files/deconnexion.php [L]
|
||||
RewriteRule ^equipe/(.*?)$ server_files/equipe.php?trigram=$1 [L]
|
||||
RewriteRule ^file/(.*?)$ server_files/view_file.php?file_id=$1 [L]
|
||||
RewriteRule ^informations/(.*?)/.*?$ server_files/informations.php?id=$1 [L]
|
||||
RewriteRule ^inscription$ server_files/inscription.php [L]
|
||||
RewriteRule ^mon_compte$ server_files/mon_compte.php [L]
|
||||
RewriteRule ^mon_equipe/(.*?)$ server_files/mon_equipe.php?$1 [L]
|
||||
RewriteRule ^mon_equipe$ server_files/mon_equipe.php [L]
|
||||
RewriteRule ^rejoindre_equipe$ server_files/rejoindre_equipe.php [L]
|
||||
RewriteRule ^solutions$ server_files/solutions.php [L]
|
||||
RewriteRule ^solutions_orga$ server_files/solutions_orga.php [L]
|
||||
RewriteRule ^syntheses$ server_files/syntheses.php [L]
|
||||
RewriteRule ^syntheses_orga$ server_files/syntheses_orga.php [L]
|
||||
RewriteRule ^tournoi/(.*?)/(.*?)$ server_files/tournoi.php?nom=$1&$2 [L]
|
||||
RewriteRule ^tournoi/(.*?)$ server_files/tournoi.php?nom=$1 [L]
|
||||
RewriteRule ^tournois$ server_files/tournois.php [L]
|
||||
RewriteRule ^accueil$ server_files/controllers/index.php [L]
|
||||
RewriteRule ^ajouter_equipe$ server_files/controllers/ajouter_equipe.php [L]
|
||||
RewriteRule ^ajouter_organisateur$ server_files/controllers/ajouter_organisateur.php [L]
|
||||
RewriteRule ^ajouter_tournoi$ server_files/controllers/ajouter_tournoi.php [L]
|
||||
RewriteRule ^confirmer_mail/(.*?)$ server_files/controllers/confirmer_mail.php?token=$1 [L]
|
||||
RewriteRule ^connexion$ server_files/controllers/connexion.php [L]
|
||||
RewriteRule ^connexion/reinitialiser_mdp/(.*?)$ server_files/controllers/connexion.php?reset_password&token=$1 [L]
|
||||
RewriteRule ^connexion/(.*?)$ server_files/controllers/connexion.php?$1 [L]
|
||||
RewriteRule ^deconnexion$ server_files/controllers/deconnexion.php [L]
|
||||
RewriteRule ^equipe/(.*?)$ server_files/controllers/equipe.php?trigram=$1 [L]
|
||||
RewriteRule ^file/(.*?)$ server_files/controllers/view_file.php?file_id=$1 [L]
|
||||
RewriteRule ^informations/(.*?)/.*?$ server_files/controllers/informations.php?id=$1 [L]
|
||||
RewriteRule ^inscription$ server_files/controllers/inscription.php [L]
|
||||
RewriteRule ^mon_compte$ server_files/controllers/mon_compte.php [L]
|
||||
RewriteRule ^mon_equipe/(.*?)$ server_files/controllers/mon_equipe.php?$1 [L]
|
||||
RewriteRule ^mon_equipe$ server_files/controllers/mon_equipe.php [L]
|
||||
RewriteRule ^rejoindre_equipe$ server_files/controllers/rejoindre_equipe.php [L]
|
||||
RewriteRule ^solutions$ server_files/controllers/solutions.php [L]
|
||||
RewriteRule ^solutions_orga$ server_files/controllers/solutions_orga.php [L]
|
||||
RewriteRule ^syntheses$ server_files/controllers/syntheses.php [L]
|
||||
RewriteRule ^syntheses_orga$ server_files/controllers/syntheses_orga.php [L]
|
||||
RewriteRule ^tournoi/(.*?)/(.*?)$ server_files/controllers/tournoi.php?nom=$1&$2 [L]
|
||||
RewriteRule ^tournoi/(.*?)$ server_files/controllers/tournoi.php?nom=$1 [L]
|
||||
RewriteRule ^tournois$ server_files/controllers/tournois.php [L]
|
||||
|
||||
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /tfjm/server_files.*? [NC]
|
||||
RewriteRule ^server_files.*?$ - [R=404]
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
require_once "config.php";
|
||||
require_once "header.php";
|
||||
require_once "views/header.php";
|
||||
|
||||
http_response_code(403);
|
||||
|
||||
echo "<h1>Vous n'êtes pas autorisé à accéder à cette page.</h1>";
|
||||
|
||||
require_once "footer.php";
|
||||
require_once "views/footer.php";
|
||||
|
||||
exit();
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
require_once "config.php";
|
||||
require_once "header.php";
|
||||
require_once "views/header.php";
|
||||
|
||||
http_response_code(404);
|
||||
|
||||
echo "<h1>Cette page n'existe pas.</h1>";
|
||||
|
||||
require_once "footer.php";
|
||||
require_once "views/footer.php";
|
||||
|
||||
exit();
|
|
@ -1,124 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
|
||||
if (isset($_POST["submitted"])) {
|
||||
$error_message = addOrganizer();
|
||||
}
|
||||
|
||||
function addOrganizer() {
|
||||
global $DB, $YEAR, $MAIL_ADDRESS;
|
||||
|
||||
$surname = htmlspecialchars($_POST["surname"]);
|
||||
|
||||
if (!isset($surname) || $surname == "")
|
||||
return "Le nom est invalide.";
|
||||
|
||||
$first_name = htmlspecialchars($_POST["first_name"]);
|
||||
|
||||
if (!isset($first_name) || $first_name == "")
|
||||
return "Le prénom est invalide.";
|
||||
|
||||
$email = strtolower(htmlspecialchars($_POST["email"]));
|
||||
if (!isset($email) || $email == "" || !filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||
return "L'adresse e-mail est invalide.";
|
||||
|
||||
$admin = isset($_POST["admin"]) && $_POST["admin"] == "on";
|
||||
|
||||
$req = $DB->prepare("SELECT `id` FROM `users` WHERE `email` = ? AND `year` = '$YEAR';");
|
||||
$req->execute([$email]);
|
||||
if ($req->fetch() !== FALSE)
|
||||
return "Cette adresse e-mail est déjà utilisée.";
|
||||
|
||||
$alphabet = "0123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
$password = "";
|
||||
for ($i = 0; $i < 16; ++$i)
|
||||
$password .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
||||
$hash = password_hash($password, PASSWORD_BCRYPT);
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `surname`, `first_name`, `role`, `year`)
|
||||
VALUES (?, ?, ?, ?, ?, ?);");
|
||||
$req->execute([$email, $hash, $surname, $first_name, $admin ? "ADMIN" : "ORGANIZER", $YEAR]);
|
||||
|
||||
$msg = "Bonjour " . $first_name . " " . $surname . ",\r\n\r\n"
|
||||
. "Vous recevez ce message (envoyé automatiquement) car vous êtes organisateur d'un des tournois du TFJM². "
|
||||
. "Veuillez trouver ci-dessous vos informations d'utilisateur pour le site officiel des inscriptions. "
|
||||
. "Elles vous permettront de gérer les inscriptions des équipes de votre tournoi.\r\n\r\n"
|
||||
. "Votre mot de passe est : $password\r\n\r\n"
|
||||
. "Notez bien que ce mot de passe est temporaire, et pour des raisons de sécurité vous devrez le changer "
|
||||
. "lors de votre prochaine connexion sur le site.\r\n\r\n"
|
||||
. "Merci beaucoup pour votre aide !\r\n\r\n"
|
||||
. "Les organisateurs du TFJM²";
|
||||
|
||||
mail($email, "Organisateur du TFJM²", $msg, "From: $MAIL_ADDRESS\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<?php
|
||||
|
||||
if (!isset($_SESSION["role"]) or $_SESSION["role"] != "ADMIN") {
|
||||
?>
|
||||
<h2>Vous n'êtes pas autorisé à accéder à cette page.</h2>
|
||||
<?php } else { ?>
|
||||
|
||||
<?php if (isset($error_message)) {
|
||||
if ($error_message !== false) {
|
||||
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||
} else {
|
||||
echo "<h2>Organisateur ajouté avec succès ! Ses identifiants ont été transmis par mail.</h2>";
|
||||
}
|
||||
}?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="surname">Nom :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="text" id="surname" name="surname" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="first_name">Prénom :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="text" id="first_name" name="first_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="email">Email :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="email" id="email" name="email" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="admin">Compte administrateur :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="checkbox" id="admin" name="admin" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" value="Ajouter un organisateur" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
||||
|
||||
<?php } ?>
|
|
@ -1,244 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
|
||||
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
|
||||
|
||||
if (isset($_POST["submitted"])) {
|
||||
$error_message = registerTournament();
|
||||
}
|
||||
|
||||
function registerTournament() {
|
||||
global $DB, $YEAR, $MAIL_ADDRESS;
|
||||
|
||||
$name = htmlspecialchars($_POST["name"]);
|
||||
|
||||
$result = $DB->query("SELECT `id` FROM `tournaments` WHERE `name` = '" . $name . "' AND `year` = '$YEAR';");
|
||||
if ($result->fetch())
|
||||
return "Un tournoi existe déjà avec ce nom.";
|
||||
|
||||
if (!isset($_POST["organizer"]) || sizeof($_POST["organizer"]) == 0)
|
||||
return "Aucun organisateur n'a été choisi.";
|
||||
|
||||
$organizers = $_POST["organizer"];
|
||||
$orga_mails = [];
|
||||
|
||||
foreach ($organizers as $orga) {
|
||||
$result = $DB->query("SELECT `role`, `email` FROM `users` WHERE `id` = '" . $orga . "' AND `year` = '$YEAR';");
|
||||
$data = $result->fetch();
|
||||
if ($data === FALSE)
|
||||
return "L'organisateur spécifié n'existe pas.";
|
||||
if ($data["role"] != "ORGANIZER" && $data["role"] != "ADMIN")
|
||||
return "L'organisateur indiqué ne peut pas organiser de tournoi.";
|
||||
$orga_mails[] = $data["email"];
|
||||
}
|
||||
|
||||
try {
|
||||
$size = intval(htmlspecialchars($_POST["size"]));
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
return "Le nombre d'équipes indiqué n'est pas un entier valide.";
|
||||
}
|
||||
|
||||
if ($size < 3 || $size > 12)
|
||||
return "Un tournoi doit comporter entre 3 et 12 équipes.";
|
||||
|
||||
$place = htmlspecialchars($_POST["place"]);
|
||||
|
||||
try {
|
||||
$price = intval(htmlspecialchars($_POST["price"]));
|
||||
}
|
||||
catch (Throwable $t) {
|
||||
return "Le tarif pour les participants n'est pas un nombre valide.";
|
||||
}
|
||||
|
||||
if ($price < 0)
|
||||
return "Le TFJM² ne va pas payer les élèves pour venir.";
|
||||
|
||||
if ($price > 50)
|
||||
return "Soyons raisonnable sur le prix.";
|
||||
|
||||
$date_start = htmlspecialchars($_POST["date_start"]);
|
||||
$date_start_parsed = date_parse_from_format("yyyy-mm-dd", $date_start);
|
||||
|
||||
$date_end = htmlspecialchars($_POST["date_end"]);
|
||||
$date_end_parsed = date_parse_from_format("yyyy-mm-dd", $date_end);
|
||||
|
||||
$date_inscription = htmlspecialchars($_POST["date_inscription"]);
|
||||
$time_inscription = htmlspecialchars($_POST["time_inscription"]);
|
||||
$date_inscription_parsed = date_parse_from_format("yyyy-mm-dd", $date_inscription . ' ' . $time_inscription);
|
||||
|
||||
$date_solutions = htmlspecialchars($_POST["date_solutions"]);
|
||||
$time_solutions = htmlspecialchars($_POST["time_solutions"]);
|
||||
$date_solutions_parsed = date_parse_from_format("yyyy-mm-dd", $date_solutions . ' ' . $time_solutions);
|
||||
|
||||
$date_syntheses = htmlspecialchars($_POST["date_syntheses"]);
|
||||
$time_syntheses = htmlspecialchars($_POST["time_syntheses"]);
|
||||
$date_syntheses_parsed = date_parse_from_format("yyyy-mm-dd", $date_syntheses . ' ' . $time_syntheses);
|
||||
|
||||
if (!$date_start_parsed || !$date_end_parsed || !$date_inscription_parsed || !$date_solutions_parsed || !$date_syntheses_parsed)
|
||||
return "Une date est mal formée.";
|
||||
|
||||
$description = htmlspecialchars($_POST["description"]);
|
||||
|
||||
$final = isset($_POST["final"]) && $_POST["final"];
|
||||
|
||||
if ($final && $DB->query("SELECT `id` FROM `tournaments` WHERE `final` = true AND `year` = $YEAR;")->fetch() !== false)
|
||||
return "Une finale est déjà enregistrée.";
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `tournaments` (`name`, `size`, `place`, `price`, `description`,
|
||||
`date_start`, `date_end`, `date_inscription`, `date_solutions`, `date_syntheses`, `final`, `year`)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
$req->execute([$name, $size, $place, $price, $description, $date_start, $date_end,
|
||||
"$date_inscription $time_inscription", "$date_solutions $time_solutions", "$date_syntheses $time_syntheses", $final, $YEAR]);
|
||||
|
||||
$req = $DB->query("SELECT `id` FROM `tournaments` WHERE `name` = '$name' AND `year` = $YEAR;");
|
||||
$tournament_id = $req->fetch()["id"];
|
||||
|
||||
foreach ($organizers as $orga) {
|
||||
$req = $DB->prepare("INSERT INTO `organizers`(`organizer`, `tournament`) VALUES(?, ?);");
|
||||
$req->execute([$orga, $tournament_id]);
|
||||
}
|
||||
|
||||
foreach ($orga_mails as $orga_mail)
|
||||
mail($orga_mail, "Organisateur TFJM² " . $name, "Vous venez d'être promu organisateur du tournoi " . $name . " pour le TFJM² $YEAR !", "From: $MAIL_ADDRESS");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<?php
|
||||
|
||||
if (!isset($_SESSION["role"]) or $_SESSION["role"] != "ADMIN") {
|
||||
?>
|
||||
<h2>Vous n'êtes pas autorisé à accéder à cette page.</h2>
|
||||
<?php } else { ?>
|
||||
|
||||
<?php if (isset($error_message)) {
|
||||
if ($error_message !== false) {
|
||||
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||
} else {
|
||||
echo "<h2>Tournoi de " . htmlspecialchars($_POST["name"]) . " ajouté avec succès !</h2>";
|
||||
}
|
||||
}?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="name">Nom :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="text" id="name" name="name" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="organizer">Organisateur :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="organizer" name="organizer[]" multiple size="4" required>
|
||||
<?php
|
||||
while (($data = $orgas_response->fetch()) !== FALSE) {
|
||||
echo "<option value=\"" . $data["id"] . "\">" . $data["first_name"] . " " . $data["surname"] . "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="size">Nombre d'équipes :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="number" id="size" name="size" min="3" max="12" value="6" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="place">Lieu :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="text" id="place" name="place" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="price">Prix par participant</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="number" id="price" name="price" min="0" max="21" value="21" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_start">Dates :</label>
|
||||
</td>
|
||||
<td>
|
||||
Du <input style="width: 45%;" type="date" id="date_start" name="date_start" required /> au <!--suppress HtmlFormInputWithoutLabel -->
|
||||
<input style="width: 45%;" type="date" id="date_end" name="date_end" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_inscription">Date limite d'inscription :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 49%;" type="date" id="date_inscription" name="date_inscription" required />
|
||||
<!--suppress HtmlFormInputWithoutLabel -->
|
||||
<input style="width: 49%;" type="time" id="time_inscription" name="time_inscription" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_solutions">Date limite pour rendre les solutions :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 49%;" type="date" id="date_solutions" name="date_solutions" required />
|
||||
<!--suppress HtmlFormInputWithoutLabel -->
|
||||
<input style="width: 49%;" type="time" id="time_solutions" name="time_solutions" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_syntheses">Date limite pour rendre les notes de synthèse :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 49%;" type="date" id="date_syntheses" name="date_syntheses" required />
|
||||
<!--suppress HtmlFormInputWithoutLabel -->
|
||||
<input style="width: 49%;" type="time" id="time_syntheses" name="time_syntheses" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="description">Description :</label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea style="width: 100%;" name="description" id="description" required></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="final">Ce tournoi est la finale nationale :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="checkbox" id="final" name="final" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" value="Ajouter un tournoi" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
||||
|
||||
<?php } ?>
|
|
@ -25,41 +25,8 @@ catch (Exception $ex) {
|
|||
}
|
||||
|
||||
session_start();
|
||||
|
||||
if (isset($_SESSION["user_id"])) {
|
||||
$response = $DB->query("SELECT * FROM `users` WHERE `id` ='" . $_SESSION["user_id"] . "' AND `year` = '$YEAR';");
|
||||
$data = $response->fetch();
|
||||
if ($data === FALSE)
|
||||
unset($_SESSION["user_id"]);
|
||||
else {
|
||||
$_SESSION["email"] = $data["email"];
|
||||
$_SESSION["surname"] = $data["surname"];
|
||||
$_SESSION["first_name"] = $data["first_name"];
|
||||
$_SESSION["birth_date"] = $data["birth_date"];
|
||||
$_SESSION["role"] = $data["role"];
|
||||
$_SESSION["team_id"] = $data["team_id"];
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_SESSION["team_id"]) && $_SESSION["team_id"] != NULL) {
|
||||
$response = $DB->query("SELECT `tournament`, `validation_status`, `final_selection` FROM `teams` WHERE `id` ='" . $_SESSION["team_id"] . "' AND `year` = '$YEAR';");
|
||||
$data = $response->fetch();
|
||||
$_SESSION["tournament_id"] = $data["tournament"];
|
||||
$_SESSION["team_validation_status"] = $data["validation_status"];
|
||||
}
|
||||
|
||||
if ((isset($data["final_selection"]) && $data["final_selection"]) || $_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER") {
|
||||
$response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `final` AND `year` = $YEAR;");
|
||||
$data = $response->fetch();
|
||||
$_SESSION["final_id"] = $data["id"];
|
||||
$_SESSION["final_name"] = $data["name"];
|
||||
}
|
||||
}
|
||||
|
||||
setlocale(LC_ALL, "fr_FR.utf8");
|
||||
|
||||
function echo_date($date = NULL, $with_time = false) {
|
||||
if ($date == NULL)
|
||||
$date = date("yyyy-mm-dd");
|
||||
require_once "model.php";
|
||||
|
||||
return strftime("%d %B %G" . ($with_time ? " %H:%M" : ""), strtotime($date));
|
||||
}
|
||||
loadUserValues();
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
require_once "../config.php";
|
||||
|
||||
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `date_inscription` > CURRENT_DATE AND `year` = '$YEAR';");
|
||||
|
||||
|
@ -62,66 +62,6 @@ function registerTeam() {
|
|||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<?php
|
||||
|
||||
if (!isset($_SESSION["role"]) or ($_SESSION["role"] != "PARTICIPANT" && $_SESSION["role"] != "ENCADRANT")) {
|
||||
?>
|
||||
<h2>Vous devez être participant ou encadrant pour pouvoir ajouter une équipe.</h2>
|
||||
<?php } else if ($_SESSION["team_id"] != NULL) { ?>
|
||||
<h2>Vous êtes déjà dans une équipe.</h2>
|
||||
<?php } else if (isset($access_code)) { ?>
|
||||
Votre équipe a bien été créée ! Voici le code d'accès à transmettre aux autres membres de votre équipe : <strong><?php echo $access_code ?></strong>
|
||||
<?php } else { ?>
|
||||
|
||||
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="name">Nom :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="text" id="name" name="name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="trigram">Trigramme :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="text" id="trigram" name="trigram" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="tournament">Tournoi :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="tournament" name="tournament">
|
||||
<?php
|
||||
while (($data = $tournaments_response->fetch()) !== FALSE) {
|
||||
echo "<option value=\"" . $data["id"] . "\">" . $data["name"] . "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" value="Ajouter une équipe" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
||||
|
||||
<?php } ?>
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/ajouter_equipe.php";
|
||||
require_once "../views/footer.php";
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ADMIN")
|
||||
require_once "../403.php";
|
||||
|
||||
if (isset($_POST["submitted"])) {
|
||||
$error_message = addOrganizer();
|
||||
}
|
||||
|
||||
function addOrganizer()
|
||||
{
|
||||
global $DB, $YEAR, $MAIL_ADDRESS;
|
||||
|
||||
$surname = htmlspecialchars($_POST["surname"]);
|
||||
|
||||
if (!isset($surname) || $surname == "")
|
||||
return "Le nom est invalide.";
|
||||
|
||||
$first_name = htmlspecialchars($_POST["first_name"]);
|
||||
|
||||
if (!isset($first_name) || $first_name == "")
|
||||
return "Le prénom est invalide.";
|
||||
|
||||
$email = strtolower(htmlspecialchars($_POST["email"]));
|
||||
if (!isset($email) || $email == "" || !filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||
return "L'adresse e-mail est invalide.";
|
||||
|
||||
$admin = isset($_POST["admin"]) && $_POST["admin"] == "on";
|
||||
|
||||
$req = $DB->prepare("SELECT `id` FROM `users` WHERE `email` = ? AND `year` = '$YEAR';");
|
||||
$req->execute([$email]);
|
||||
if ($req->fetch() !== FALSE)
|
||||
return "Cette adresse e-mail est déjà utilisée.";
|
||||
|
||||
$alphabet = "0123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
$password = "";
|
||||
for ($i = 0; $i < 16; ++$i)
|
||||
$password .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
||||
$hash = password_hash($password, PASSWORD_BCRYPT);
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `surname`, `first_name`, `role`, `year`)
|
||||
VALUES (?, ?, ?, ?, ?, ?);");
|
||||
$req->execute([$email, $hash, $surname, $first_name, $admin ? "ADMIN" : "ORGANIZER", $YEAR]);
|
||||
|
||||
$msg = "Bonjour " . $first_name . " " . $surname . ",\r\n\r\n"
|
||||
. "Vous recevez ce message (envoyé automatiquement) car vous êtes organisateur d'un des tournois du TFJM². "
|
||||
. "Veuillez trouver ci-dessous vos informations d'utilisateur pour le site officiel des inscriptions. "
|
||||
. "Elles vous permettront de gérer les inscriptions des équipes de votre tournoi.\r\n\r\n"
|
||||
. "Votre mot de passe est : $password\r\n\r\n"
|
||||
. "Notez bien que ce mot de passe est temporaire, et pour des raisons de sécurité vous devrez le changer "
|
||||
. "lors de votre prochaine connexion sur le site.\r\n\r\n"
|
||||
. "Merci beaucoup pour votre aide !\r\n\r\n"
|
||||
. "Les organisateurs du TFJM²";
|
||||
|
||||
mail($email, "Organisateur du TFJM²", $msg, "From: $MAIL_ADDRESS\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/ajouter_organisateur.php";
|
||||
require_once "../views/footer.php";
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ADMIN")
|
||||
require_once "../403.php";
|
||||
|
||||
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
|
||||
|
||||
if (isset($_POST["submitted"])) {
|
||||
$error_message = registerTournament();
|
||||
}
|
||||
|
||||
function registerTournament() {
|
||||
global $DB, $YEAR, $MAIL_ADDRESS;
|
||||
|
||||
$name = htmlspecialchars($_POST["name"]);
|
||||
|
||||
$result = $DB->query("SELECT `id` FROM `tournaments` WHERE `name` = '" . $name . "' AND `year` = '$YEAR';");
|
||||
if ($result->fetch())
|
||||
return "Un tournoi existe déjà avec ce nom.";
|
||||
|
||||
if (!isset($_POST["organizer"]) || sizeof($_POST["organizer"]) == 0)
|
||||
return "Aucun organisateur n'a été choisi.";
|
||||
|
||||
$organizers = $_POST["organizer"];
|
||||
$orga_mails = [];
|
||||
|
||||
foreach ($organizers as $orga) {
|
||||
$result = $DB->query("SELECT `role`, `email` FROM `users` WHERE `id` = '" . $orga . "' AND `year` = '$YEAR';");
|
||||
$data = $result->fetch();
|
||||
if ($data === FALSE)
|
||||
return "L'organisateur spécifié n'existe pas.";
|
||||
if ($data["role"] != "ORGANIZER" && $data["role"] != "ADMIN")
|
||||
return "L'organisateur indiqué ne peut pas organiser de tournoi.";
|
||||
$orga_mails[] = $data["email"];
|
||||
}
|
||||
|
||||
try {
|
||||
$size = intval(htmlspecialchars($_POST["size"]));
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
return "Le nombre d'équipes indiqué n'est pas un entier valide.";
|
||||
}
|
||||
|
||||
if ($size < 3 || $size > 12)
|
||||
return "Un tournoi doit comporter entre 3 et 12 équipes.";
|
||||
|
||||
$place = htmlspecialchars($_POST["place"]);
|
||||
|
||||
try {
|
||||
$price = intval(htmlspecialchars($_POST["price"]));
|
||||
}
|
||||
catch (Throwable $t) {
|
||||
return "Le tarif pour les participants n'est pas un nombre valide.";
|
||||
}
|
||||
|
||||
if ($price < 0)
|
||||
return "Le TFJM² ne va pas payer les élèves pour venir.";
|
||||
|
||||
if ($price > 50)
|
||||
return "Soyons raisonnable sur le prix.";
|
||||
|
||||
$date_start = htmlspecialchars($_POST["date_start"]);
|
||||
$date_start_parsed = date_parse_from_format("yyyy-mm-dd", $date_start);
|
||||
|
||||
$date_end = htmlspecialchars($_POST["date_end"]);
|
||||
$date_end_parsed = date_parse_from_format("yyyy-mm-dd", $date_end);
|
||||
|
||||
$date_inscription = htmlspecialchars($_POST["date_inscription"]);
|
||||
$time_inscription = htmlspecialchars($_POST["time_inscription"]);
|
||||
$date_inscription_parsed = date_parse_from_format("yyyy-mm-dd", $date_inscription . ' ' . $time_inscription);
|
||||
|
||||
$date_solutions = htmlspecialchars($_POST["date_solutions"]);
|
||||
$time_solutions = htmlspecialchars($_POST["time_solutions"]);
|
||||
$date_solutions_parsed = date_parse_from_format("yyyy-mm-dd", $date_solutions . ' ' . $time_solutions);
|
||||
|
||||
$date_syntheses = htmlspecialchars($_POST["date_syntheses"]);
|
||||
$time_syntheses = htmlspecialchars($_POST["time_syntheses"]);
|
||||
$date_syntheses_parsed = date_parse_from_format("yyyy-mm-dd", $date_syntheses . ' ' . $time_syntheses);
|
||||
|
||||
if (!$date_start_parsed || !$date_end_parsed || !$date_inscription_parsed || !$date_solutions_parsed || !$date_syntheses_parsed)
|
||||
return "Une date est mal formée.";
|
||||
|
||||
$description = htmlspecialchars($_POST["description"]);
|
||||
|
||||
$final = isset($_POST["final"]) && $_POST["final"];
|
||||
|
||||
if ($final && $DB->query("SELECT `id` FROM `tournaments` WHERE `final` = true AND `year` = $YEAR;")->fetch() !== false)
|
||||
return "Une finale est déjà enregistrée.";
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `tournaments` (`name`, `size`, `place`, `price`, `description`,
|
||||
`date_start`, `date_end`, `date_inscription`, `date_solutions`, `date_syntheses`, `final`, `year`)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
$req->execute([$name, $size, $place, $price, $description, $date_start, $date_end,
|
||||
"$date_inscription $time_inscription", "$date_solutions $time_solutions", "$date_syntheses $time_syntheses", $final, $YEAR]);
|
||||
|
||||
$req = $DB->query("SELECT `id` FROM `tournaments` WHERE `name` = '$name' AND `year` = $YEAR;");
|
||||
$tournament_id = $req->fetch()["id"];
|
||||
|
||||
foreach ($organizers as $orga) {
|
||||
$req = $DB->prepare("INSERT INTO `organizers`(`organizer`, `tournament`) VALUES(?, ?);");
|
||||
$req->execute([$orga, $tournament_id]);
|
||||
}
|
||||
|
||||
foreach ($orga_mails as $orga_mail)
|
||||
mail($orga_mail, "Organisateur TFJM² " . $name, "Vous venez d'être promu organisateur du tournoi " . $name . " pour le TFJM² $YEAR !", "From: $MAIL_ADDRESS");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/ajouter_tournoi.php";
|
||||
require_once "../views/footer.php";
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
require_once "../config.php";
|
||||
|
||||
$token = $_GET["token"];
|
||||
|
||||
|
@ -16,11 +16,6 @@ if (isset($token)) {
|
|||
else {
|
||||
$error_message = "Il n'y a pas de compte à valider !";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<h2><?php echo $error_message ?></h2>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
||||
require_once "../views/header.php";
|
||||
echo "<h2>$error_message</h2>";
|
||||
require_once "../views/footer.php";
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
require_once "../config.php";
|
||||
|
||||
if (isset($_POST["submitted"]) && !isset($_SESSION["user_id"])) {
|
||||
$error_message = login();
|
||||
|
@ -26,7 +26,7 @@ if (isset($_GET["confirmation-mail"]) && !isset($_SESSION["user_id"])) {
|
|||
}
|
||||
|
||||
function login() {
|
||||
global $DB, $URL_BASE, $YEAR;
|
||||
global $DB, $URL_BASE;
|
||||
|
||||
$email = htmlspecialchars($_POST["email"]);
|
||||
|
||||
|
@ -48,16 +48,7 @@ function login() {
|
|||
return "Le mot de passe est incorrect.";
|
||||
|
||||
$_SESSION["user_id"] = $data["id"];
|
||||
$_SESSION["email"] = $data["email"];
|
||||
$_SESSION["surname"] = $data["surname"];
|
||||
$_SESSION["first_name"] = $data["first_name"];
|
||||
$_SESSION["role"] = $data["role"];
|
||||
$_SESSION["team_id"] = $data["team_id"];
|
||||
|
||||
$response = $DB->query("SELECT `tournament`, `validation_status` FROM `teams` WHERE `id` ='" . $_SESSION["team_id"] . "' AND `year` = '$YEAR';");
|
||||
$data = $response->fetch();
|
||||
$_SESSION["tournament_id"] = $data["tournament"];
|
||||
$_SESSION["team_validation_status"] = $data["validation_status"];
|
||||
loadUserValues();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -141,103 +132,6 @@ function sendConfirmEmail() {
|
|||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||
|
||||
<?php
|
||||
if (isset($error_message) && $error_message === FALSE) {
|
||||
if (isset($_GET["mdp_oublie"]))
|
||||
echo "Le mail de récupération de mot de passe a bien été envoyé.";
|
||||
else if (isset($_POST["reset_password"]))
|
||||
echo "Le mot de passe a bien été changé. Vous pouvez désormais vous connecter.";
|
||||
else if (isset($_GET["confirmation-mail"]))
|
||||
echo "Le mail a bien été renvoyé.";
|
||||
else
|
||||
echo "Connexion réussie !";
|
||||
}
|
||||
else if (isset($_SESSION["user_id"])) { ?>
|
||||
<h2>Vous êtes déjà connecté !</h2>
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<?php if (isset($_GET["mdp_oublie"])) { ?>
|
||||
<form method="POST">
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="email">E-mail associée au compte :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="email" id="email" name="email" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" name="forgotten_password" value="Envoyer l'e-mail de récupération" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php } elseif (isset($_GET["reset_password"])) { ?>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="token" value="<?= $_GET["token"] ?>" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="password">Nouveau mot de passe :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="password" id="password" name="password" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="confirm_password">Confirmer le mot de passe :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="password" id="confirm_password" name="confirm_password" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" name="reset_password" value="Changer le mot de passe" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php } elseif (isset($_GET["confirmation-mail"])) { ?>
|
||||
<?php } else { ?>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td style="width: 30%;"><label for="email">E-mail :</label></td>
|
||||
<td style="width: 70%;"><input style="width: 100%;" type="email" id="email" name="email" value="<?php if (isset($email)) echo $email ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="password">Mot de passe :</label></td>
|
||||
<td><input style="width: 100%;" type="password" id="password" name="password" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="<?= $URL_BASE ?>/connexion/mdp_oublie">Mot de passe oublié ?</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%;" type="submit" value="Se connecter" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
||||
|
||||
<?php } ?>
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/connexion.php";
|
||||
require_once "../views/footer.php";
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
unset($_SESSION["user_id"]);
|
||||
session_destroy();
|
||||
|
||||
require_once "../views/header.php";
|
||||
echo "<h2>Déconnexion réussie !</h2>";
|
||||
require_once "../views/footer.php";
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
$trigram = htmlspecialchars($_GET["trigram"]);
|
||||
|
||||
if (isset($_POST["validate"])) {
|
||||
$DB->exec("UPDATE `teams` SET `validation_status` = 'VALIDATED' WHERE `trigram` = '$trigram' AND `year` = $YEAR;");
|
||||
}
|
||||
|
||||
$team_data = $DB->query("SELECT * FROM `teams` WHERE `trigram` = '$trigram' AND `year` = $YEAR;")->fetch();
|
||||
|
||||
if (isset($_POST["select"])) {
|
||||
$DB->exec("UPDATE `teams` SET `final_selection` = true, `validation_status` = 'NOT_READY' WHERE `trigram` = '$trigram' AND `year` = $YEAR;");
|
||||
$team_data["validation_status"] = "NOT_READY";
|
||||
$team_data["final_selection"] = true;
|
||||
$final_id = $_SESSION["final_id"];
|
||||
$team_id = $team_data["id"];
|
||||
|
||||
$sols_req = $DB->prepare("SELECT `file_id`, `problem`, COUNT(`problem`) AS `version` FROM `solutions` WHERE `team` = ? AND `tournament` = ? GROUP BY `problem`, `uploaded_at` ORDER BY `problem`, `uploaded_at` DESC;");
|
||||
$sols_req->execute([$team_data["id"], $team_data["tournament"]]);
|
||||
while (($sol_data = $sols_req->fetch()) !== false) {
|
||||
$old_id = $sol_data["file_id"];
|
||||
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
do {
|
||||
$id = "";
|
||||
for ($i = 0; $i < 64; ++$i) {
|
||||
$id .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
||||
}
|
||||
}
|
||||
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||
|
||||
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`)
|
||||
VALUES (?, ?, ?, ?);");
|
||||
$req->execute([$id, $team_id, $_SESSION["final_id"], $sol_data["problem"]]);
|
||||
}
|
||||
|
||||
$syntheses_req = $DB->prepare("SELECT `file_id`, `dest`, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `team` = ? AND `tournament` = ? GROUP BY `dest`, `uploaded_at` ORDER BY `dest`, `uploaded_at` DESC;");
|
||||
$syntheses_req->execute([$team_data["id"], $team_data["tournament"]]);
|
||||
while (($synthese_data = $syntheses_req->fetch()) !== false) {
|
||||
$old_id = $synthese_data["file_id"];
|
||||
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
do {
|
||||
$id = "";
|
||||
for ($i = 0; $i < 64; ++$i) {
|
||||
$id .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
||||
}
|
||||
}
|
||||
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||
|
||||
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
|
||||
$req->execute([$id, $team_id, $_SESSION["final_id"], $synthese_data["dest"]]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($team_data === false)
|
||||
require_once "../404.php";
|
||||
|
||||
$tournament_data = $DB->query("SELECT `name`, `date_start` FROM `tournaments` WHERE `id` = '" . $team_data["tournament"] . "' AND `year` = '$YEAR';")->fetch();
|
||||
|
||||
$documents_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` = ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;");
|
||||
$documents_req->execute([$team_data["id"], $team_data["tournament"]]);
|
||||
|
||||
if ($team_data["final_selection"]) {
|
||||
$documents_final_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` != ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;");
|
||||
$documents_final_req->execute([$team_data["id"], $_SESSION["final_id"]]);
|
||||
}
|
||||
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/equipe.php";
|
||||
require_once "../views/footer.php";
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/index.php";
|
||||
require_once "../views/footer.php";
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ORGANIZER" && $_SESSION["role"] != "ADMIN") {
|
||||
require_once "../403.php";
|
||||
}
|
||||
|
||||
$id = $_GET["id"];
|
||||
$user_data = $DB->query("SELECT * FROM `users` WHERE `id` = $id;")->fetch();
|
||||
|
||||
if ($user_data === false) {
|
||||
require_once "../404.php";
|
||||
}
|
||||
|
||||
$team_data = false;
|
||||
if ($user_data["team_id"] !== NULL)
|
||||
$team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = " . $user_data["team_id"] . ";")->fetch();
|
||||
|
||||
$documents_req = $DB->query("SELECT * FROM `documents` WHERE `user` = $id;");
|
||||
$tournaments_req = $DB->query("SELECT `tournament`, `name` FROM `organizers` JOIN `tournaments` ON `tournaments`.`id` = `tournament` WHERE `organizer` = $id ORDER BY `date_start`, `name`;");
|
||||
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/informations.php";
|
||||
require_once "../views/footer.php";
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
if (isset($_POST["submitted"])) {
|
||||
$error_message = register();
|
||||
}
|
||||
|
||||
function register() {
|
||||
global $DB, $YEAR, $URL_BASE, $MAIL_ADDRESS;
|
||||
global $email, $firstname, $surname, $birth_date, $gender, $address, $postal_code, $city, $country, $phone_number, $role, $school, $class, $responsible_name, $responsible_phone, $responsible_email;
|
||||
|
||||
$email = strtolower(htmlspecialchars($_POST["email"]));
|
||||
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||
return "L'email entrée est invalide.";
|
||||
|
||||
$result = $DB->query("SELECT `email` FROM `users` WHERE `email` = '" . $email . "' AND `year` = '$YEAR';");
|
||||
if ($result->fetch())
|
||||
return "Un compte existe déjà avec cette adresse e-mail.";
|
||||
|
||||
$password = htmlspecialchars($_POST["password"]);
|
||||
if (strlen($password) < 8)
|
||||
return "Le mot de passe doit comporter au moins 8 caractères.";
|
||||
if ($password != $_POST["confirm_password"])
|
||||
return "Les deux mots de passe sont différents.";
|
||||
|
||||
$password = password_hash($password, PASSWORD_BCRYPT);
|
||||
|
||||
$surname = strtoupper(htmlspecialchars($_POST["surname"]));
|
||||
if (!isset($surname) || $surname == "")
|
||||
return "Le nom de famille est obligatoire.";
|
||||
|
||||
$firstname = htmlspecialchars($_POST["firstname"]);
|
||||
if (!isset($surname) || $surname == "")
|
||||
return "Le prénom est obligatoire.";
|
||||
|
||||
$birth_date = date_parse_from_format("yyyy-mm-dd", htmlspecialchars($_POST["birth_date"]));
|
||||
|
||||
if ($birth_date === FALSE)
|
||||
return "La date de naissance est invalide.";
|
||||
|
||||
if (htmlspecialchars($_POST["birth_date"]) >= $YEAR . "-01-01")
|
||||
return "Vous devez avoir un âge strictement positif. Date de naissance rentrée : " . htmlspecialchars($_POST["birth_date"]);
|
||||
|
||||
$gender = htmlspecialchars($_POST["gender"]);
|
||||
|
||||
if (!isset($gender) || ($gender != "M" && $gender != "F"))
|
||||
return "Le sexe indiqué est invalide.";
|
||||
|
||||
$address = htmlspecialchars($_POST["address"]);
|
||||
|
||||
if (!isset($address))
|
||||
$address = "";
|
||||
|
||||
try {
|
||||
$postal_code = intval($_POST["postal_code"]);
|
||||
if ($postal_code < 1000 || $postal_code > 95999)
|
||||
return "Le code postal est invalide.";
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
return "Le code postal n'est pas un nombre valide.";
|
||||
}
|
||||
|
||||
$city = htmlspecialchars($_POST["city"]);
|
||||
|
||||
if (!isset($city))
|
||||
$city = "";
|
||||
|
||||
$country = htmlspecialchars($_POST["country"]);
|
||||
|
||||
if (!isset($country))
|
||||
$country = "France";
|
||||
|
||||
$phone_number = htmlspecialchars($_POST["phone_number"]);
|
||||
|
||||
if (!isset($phone_number) || $phone_number == "")
|
||||
return "Vous devez renseigner un numéro de téléphone.";
|
||||
|
||||
$role = htmlspecialchars($_POST["role"]);
|
||||
|
||||
if (!isset($role) || ($role != "participant" && $role != "encadrant"))
|
||||
return "Le rôle entré n'est pas valide.";
|
||||
|
||||
$role = strtoupper($role);
|
||||
|
||||
$school = htmlspecialchars($_POST["school"]);
|
||||
$class = strtoupper(htmlspecialchars($_POST["class"]));
|
||||
$responsible_name = htmlspecialchars($_POST["responsible_name"]);
|
||||
$responsible_phone = htmlspecialchars($_POST["responsible_phone"]);
|
||||
$responsible_email = htmlspecialchars($_POST["responsible_email"]);
|
||||
|
||||
if ($role == "ENCADRANT") {
|
||||
$school = NULL;
|
||||
$class = NULL;
|
||||
$responsible_name = NULL;
|
||||
$responsible_phone = NULL;
|
||||
$responsible_email = NULL;
|
||||
}
|
||||
else {
|
||||
if (!isset($class) && $class != "TERMINALE" && $class != "PREMIERE" && $class != "SECONDE")
|
||||
return "La classe spécifiée est invalide. Merci de ne pas créer vos propres requêtes.";
|
||||
|
||||
if ((!isset($responsible_name) || $responsible_name == "") && $birth_date > strval($YEAR - 18) . "-05-01")
|
||||
return "Veuillez spécifier un nom de responsable légal.";
|
||||
|
||||
if ((!isset($responsible_phone) || $responsible_phone == "") && (!isset($responsible_email) || !filter_var($responsible_email, FILTER_VALIDATE_EMAIL))
|
||||
&& $birth_date > strval($YEAR - 18) . "-05-01")
|
||||
return "Veuillez préciser au moins le numéro de téléphone ou l'addresse e-mail de votre responsable légal.";
|
||||
}
|
||||
|
||||
$description = $_POST["description"];
|
||||
|
||||
if ($role == "PARTICIPANT")
|
||||
$description = NULL;
|
||||
|
||||
$confirm_email_uid = uniqid();
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `birth_date`, `gender`,
|
||||
`address`, `postal_code`, `city`, `country`, `phone_number`, `school`, `class`, `role`, `description`, `year`)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
$req->execute([$email, $password, $confirm_email_uid, $surname, $firstname, $_POST["birth_date"], $gender, $address, $postal_code,
|
||||
$city, $country, $phone_number, $school, $class, $role, $description, $YEAR]);
|
||||
|
||||
$msg = "Merci pour votre inscription au TFJM² $YEAR ! Veuillez désormais confirmer votre adresse mail en cliquant ici : $URL_BASE/confirmer_mail/$confirm_email_uid";
|
||||
mail($email, "Inscription au TFJM² $YEAR", $msg, "From: $MAIL_ADDRESS\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/inscription.php";
|
||||
require_once "../views/footer.php";
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
if (isset($_POST["submitted"])) {
|
||||
$error_message = updateAccount();
|
||||
} elseif (isset($_POST["submitted_password"])) {
|
||||
$error_message = updatePassword();
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"])) {
|
||||
$result = $DB->query("SELECT * FROM `users` WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||||
$user_data = $result->fetch();
|
||||
}
|
||||
else
|
||||
require_once "../403.php";
|
||||
|
||||
function updateAccount()
|
||||
{
|
||||
global $DB, $URL_BASE, $MAIL_ADDRESS;
|
||||
|
||||
if (!isset($_SESSION["user_id"]))
|
||||
return "Vous n'êtes pas connecté.";
|
||||
|
||||
$ID = $_SESSION["user_id"];
|
||||
|
||||
$surname = htmlspecialchars($_POST["surname"]);
|
||||
if (isset($surname) && $surname != "")
|
||||
$DB->prepare("UPDATE `users` SET `surname` = ? WHERE `id` = ?;")->execute([$surname, $ID]);
|
||||
|
||||
$first_name = htmlspecialchars($_POST["firstname"]);
|
||||
if (isset($first_name) && $first_name != "")
|
||||
$DB->prepare("UPDATE `users` SET `first_name` = ? WHERE `id` = ?;")->execute([$first_name, $ID]);
|
||||
|
||||
$birth_date = htmlspecialchars($_POST["birth_date"]);
|
||||
if (isset($birth_date) && $birth_date != "")
|
||||
$DB->prepare("UPDATE `users` SET `birth_date` = ? WHERE `id` = ?;")->execute([$birth_date, $ID]);
|
||||
|
||||
if (isset($_POST["gender"])) {
|
||||
$gender = htmlspecialchars($_POST["gender"]);
|
||||
if (isset($gender) && ($gender == "M" || $gender == "F"))
|
||||
$DB->prepare("UPDATE `users` SET `gender` = ? WHERE `id` = ?;")->execute([$gender, $ID]);
|
||||
}
|
||||
|
||||
$address = htmlspecialchars($_POST["address"]);
|
||||
if (isset($address) && $address != "")
|
||||
$DB->prepare("UPDATE `users` SET `address` = ? WHERE `id` = ?;")->execute([$address, $ID]);
|
||||
|
||||
$postal_code = htmlspecialchars($_POST["postal_code"]);
|
||||
if (isset($postal_code) && $postal_code != "")
|
||||
$DB->prepare("UPDATE `users` SET `postal_code` = ? WHERE `id` = ?;")->execute([$postal_code, $ID]);
|
||||
|
||||
$city = htmlspecialchars($_POST["city"]);
|
||||
if (isset($city) && $city != "")
|
||||
$DB->prepare("UPDATE `users` SET `city` = ? WHERE `id` = ?;")->execute([$city, $ID]);
|
||||
|
||||
$country = htmlspecialchars($_POST["country"]);
|
||||
if (isset($country) && $country != "")
|
||||
$DB->prepare("UPDATE `users` SET `country` = ? WHERE `id` = ?;")->execute([$country, $ID]);
|
||||
|
||||
$phone_number = htmlspecialchars($_POST["phone_number"]);
|
||||
if (isset($phone_number) && $phone_number != "")
|
||||
$DB->prepare("UPDATE `users` SET `phone_number` = ? WHERE `id` = ?;")->execute([$phone_number, $ID]);
|
||||
|
||||
if (isset($_POST["school"])) {
|
||||
$school = htmlspecialchars($_POST["school"]);
|
||||
if (isset($school) && $school != "")
|
||||
$DB->prepare("UPDATE `users` SET `school` = ? WHERE `id` = ?;")->execute([$school, $ID]);
|
||||
}
|
||||
|
||||
if (isset($_POST["class"])) {
|
||||
$class = htmlspecialchars($_POST["class"]);
|
||||
if (isset($class) && ($class == "terminale" || $class == "premiere" || $class == "seconde"))
|
||||
$DB->prepare("UPDATE `users` SET `class` = ? WHERE `id` = ?;")->execute([strtoupper($class), $ID]);
|
||||
}
|
||||
|
||||
if (isset($_POST["responsible_name"])) {
|
||||
$responsible_name = htmlspecialchars($_POST["responsible_name"]);
|
||||
if (isset($responsible_name) && $responsible_name != "")
|
||||
$DB->prepare("UPDATE `users` SET `responsible_name` = ? WHERE `id` = ?;")->execute([$responsible_name, $ID]);
|
||||
}
|
||||
|
||||
if (isset($_POST["responsible_phone"])) {
|
||||
$responsible_phone = htmlspecialchars($_POST["responsible_phone"]);
|
||||
if (isset($responsible_phone) && $responsible_phone != "")
|
||||
$DB->prepare("UPDATE `users` SET `responsible_phone` = ? WHERE `id` = ?;")->execute([$responsible_phone, $ID]);
|
||||
}
|
||||
|
||||
if (isset($_POST["responsible_email"])) {
|
||||
$responsible_email = htmlspecialchars($_POST["responsible_email"]);
|
||||
if (isset($responsible_email) && $responsible_email != "")
|
||||
$DB->prepare("UPDATE `users` SET `responsible_email` = ? WHERE `id` = ?;")->execute([$responsible_email, $ID]);
|
||||
}
|
||||
|
||||
if (isset($_POST["description"])) {
|
||||
$description = htmlspecialchars($_POST["description"]);
|
||||
if (isset($description) && $description != "")
|
||||
$DB->prepare("UPDATE `users` SET `description` = ? WHERE `id` = ?;")->execute([$description, $ID]);
|
||||
}
|
||||
|
||||
$email = htmlspecialchars($_POST["email"]);
|
||||
if (isset($email) && $email != "" && filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$confirm_email_uid = uniqid();
|
||||
$DB->prepare("UPDATE `users` SET `email` = ?, `confirm_email` = ? WHERE `id` = ?;")->execute([$email, $confirm_email_uid, $ID]);
|
||||
|
||||
$msg = "Vous venez de changer votre adresse mail. Veuillez désormais confirmer votre adresse mail en cliquant ici : $URL_BASE/confirmer_mail/$confirm_email_uid";
|
||||
mail($email, "Changement d'adresse mail - TFJM²", $msg, "From: $MAIL_ADDRESS\r\n");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function updatePassword()
|
||||
{
|
||||
global $DB, $YEAR;
|
||||
|
||||
$old = htmlspecialchars($_POST["old_password"]);
|
||||
$new = htmlspecialchars($_POST["new_password"]);
|
||||
$confirm = htmlspecialchars($_POST["confirm_password"]);
|
||||
|
||||
$result = $DB->query("SELECT `pwd_hash` FROM `users` WHERE `id` = '" . $_SESSION["user_id"] . "' AND `year` = '$YEAR';");
|
||||
if (($data = $result->fetch()) === FALSE)
|
||||
return "Le compte n'existe pas.";
|
||||
|
||||
if (!password_verify($old, $data["pwd_hash"]))
|
||||
return "L'ancien mot de passe est incorrect.";
|
||||
|
||||
if (strlen($new) < 8)
|
||||
return "Le mot de passe doit comporter au moins 8 caractères.";
|
||||
|
||||
if ($new != $confirm)
|
||||
return "Les deux mots de passe sont différents.";
|
||||
|
||||
$hash = password_hash($new, PASSWORD_BCRYPT);
|
||||
|
||||
$DB->prepare("UPDATE `users` SET `pwd_hash` = ? WHERE `id` = ?;")->execute([$hash, $_SESSION["user_id"]]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/mon_compte.php";
|
||||
require_once "../views/footer.php";
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
if (isset($_POST["leave_team"])) {
|
||||
quitTeam();
|
||||
}
|
||||
|
||||
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `year` = '$YEAR';");
|
||||
|
||||
if (isset($_POST["send_document"])) {
|
||||
$error_message = sendDocument();
|
||||
}
|
||||
|
||||
if (isset($_POST["request_validation"])) {
|
||||
if (!checkCanValidate())
|
||||
$error_message = "Votre équipe ne peut pas demander la validation : il manque soit des participants, soit des documents.";
|
||||
else {
|
||||
$DB->exec("UPDATE `teams` SET `validation_status` = 'WAITING' WHERE `id` = " . $_SESSION["team_id"] . ";");
|
||||
$_SESSION["team_validation_status"] = "WAITING";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_SESSION["team_id"])) {
|
||||
$result = $DB->query("SELECT * FROM `teams` WHERE `id` = '" . $_SESSION["team_id"] . "' AND `year` = '$YEAR';");
|
||||
$team_data = $result->fetch();
|
||||
|
||||
$tournament_data = $DB->query("SELECT `name`, `date_start` FROM `tournaments` WHERE `id` = '" . $team_data["tournament"] . "' AND `year` = '$YEAR';")->fetch();
|
||||
|
||||
$documents_req = $DB->prepare("SELECT `file_id`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? GROUP BY `type`, `uploaded_at` ORDER BY `type`, `uploaded_at` DESC;");
|
||||
$documents_req->execute([$_SESSION["user_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]);
|
||||
}
|
||||
else
|
||||
require_once "../403.php";
|
||||
|
||||
if (isset($_POST["team_edit"])) {
|
||||
$error_message = updateTeam();
|
||||
}
|
||||
|
||||
function sendDocument()
|
||||
{
|
||||
global $LOCAL_PATH, $DB;
|
||||
|
||||
$type = strtoupper(htmlspecialchars($_POST["type"]));
|
||||
if (!isset($type) || ($type != "PARENTAL_CONSENT" && $type != "PHOTO_CONSENT" && $type != "SANITARY_PLUG"))
|
||||
return "Le type de document est invalide. Merci de ne pas formuler vos propres requêtes.";
|
||||
|
||||
$file = $_FILES["document"];
|
||||
|
||||
if ($file["size"] > 5000000 || $file["error"])
|
||||
return "Une erreur est survenue. Merci de vérifier que le fichier pèse moins que 5 Mo.";
|
||||
|
||||
if (finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file["tmp_name"]) != 'application/pdf')
|
||||
return "Le fichier doit être au format PDF.";
|
||||
|
||||
if (!is_dir("$LOCAL_PATH/files") && !mkdir("$LOCAL_PATH/files"))
|
||||
return "Les droits sont insuffisants. Veuillez contacter l'administrateur du serveur.";
|
||||
|
||||
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
do {
|
||||
$id = "";
|
||||
for ($i = 0; $i < 64; ++$i) {
|
||||
$id .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
||||
}
|
||||
} while (file_exists("$LOCAL_PATH/files/$id"));
|
||||
|
||||
if (!rename($file["tmp_name"], "$LOCAL_PATH/files/$id"))
|
||||
return "Une erreur est survenue lors de l'envoi du fichier.";
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `documents`(`file_id`, `user`, `team`, `tournament`, `type`)
|
||||
VALUES (?, ?, ?, ?, ?);");
|
||||
$req->execute([$id, $_SESSION["user_id"], $_SESSION["team_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"], $type]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function updateTeam()
|
||||
{
|
||||
global $DB, $YEAR, $URL_BASE, $team_data;
|
||||
|
||||
if ($_SESSION["team_id"] == NULL)
|
||||
return "Vous n'êtes pas dans une équipe.";
|
||||
|
||||
$name = htmlspecialchars($_POST["name"]);
|
||||
|
||||
if (!isset($name) || $name == "")
|
||||
return "Vous devez spécifier un nom d'équipe.";
|
||||
|
||||
echo $team_data["id"];
|
||||
$result = $DB->query("SELECT `id` FROM `teams` WHERE `name` = '" . $name . "' AND `id` != " . $team_data["id"] . " AND `year` = '$YEAR';");
|
||||
if ($result->fetch())
|
||||
return "Une équipe existe déjà avec ce nom." . $team_data["id"];
|
||||
|
||||
$trigram = strtoupper(htmlspecialchars($_POST["trigram"]));
|
||||
|
||||
if (!preg_match("#^[A-Z][A-Z][A-Z]$#", $trigram))
|
||||
return "Le trigramme entré n'est pas valide.";
|
||||
|
||||
$result = $DB->query("SELECT `id` FROM `teams` WHERE `trigram` = '" . $trigram . "' AND `id` != '" . $team_data["id"] . "' AND `year` = '$YEAR';");
|
||||
if ($result->fetch())
|
||||
return "Une équipe a déjà choisi ce trigramme.";
|
||||
|
||||
$tournament_id = intval(htmlspecialchars($_POST["tournament"]));
|
||||
|
||||
$result = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `id` = '" . $tournament_id . "' AND `year` = '$YEAR';");
|
||||
$data = $result->fetch();
|
||||
if ($data === FALSE)
|
||||
return "Le tournoi spécifié n'existe pas.";
|
||||
|
||||
$req = $DB->prepare("UPDATE `teams` SET `name` = ?, `trigram` = ?, `tournament` = ? WHERE `id` = ?;");
|
||||
$req->execute([$name, $trigram, $tournament_id, $team_data["id"]]);
|
||||
|
||||
header("Location: $URL_BASE/mon_equipe");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkCanValidate()
|
||||
{
|
||||
global $DB, $team_data, $tournament_data, $YEAR;
|
||||
$can_validate = $team_data["validation_status"] == "NOT_READY";
|
||||
$can_validate &= $team_data["encadrant_1"] != NULL;
|
||||
$can_validate &= $team_data["participant_4"] != NULL;
|
||||
for ($i = 1; $i <= 2; ++$i) {
|
||||
if ($team_data["encadrant_$i"] === NULL)
|
||||
continue;
|
||||
|
||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||
$req->execute([$team_data["encadrant_$i"], "PHOTO_CONSENT"]);
|
||||
$d = $req->fetch();
|
||||
$can_validate &= $d["version"] > 0;
|
||||
|
||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||
$req->execute([$team_data["encadrant_$i"], "SANITARY_PLUG"]);
|
||||
$d = $req->fetch();
|
||||
$can_validate &= $d["version"] > 0;
|
||||
}
|
||||
for ($i = 1; $i <= 6; ++$i) {
|
||||
if ($team_data["participant_$i"] === NULL)
|
||||
continue;
|
||||
|
||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||
$req->execute([$team_data["participant_$i"], "PHOTO_CONSENT"]);
|
||||
$d = $req->fetch();
|
||||
$can_validate &= $d["version"] > 0;
|
||||
|
||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||
$req->execute([$team_data["participant_$i"], "SANITARY_PLUG"]);
|
||||
$d = $req->fetch();
|
||||
$can_validate &= $d["version"] > 0;
|
||||
|
||||
$birth_date = $DB->query("SELECT `birth_date` FROM `users` WHERE `id` = " . $team_data["participant_$i"] . ";")->fetch()["birth_date"];
|
||||
if ($birth_date > strval($YEAR - 18) . substr($tournament_data["date_start"], 4)) {
|
||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||
$req->execute([$team_data["participant_$i"], "PARENTAL_CONSENT"]);
|
||||
$d = $req->fetch();
|
||||
$can_validate &= $d["version"] > 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $can_validate;
|
||||
}
|
||||
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/mon_equipe.php";
|
||||
require_once "../views/footer.php";
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
require_once "../config.php";
|
||||
|
||||
if (isset($_POST["submitted"])) {
|
||||
$error_message = joinTeam();
|
||||
|
@ -50,44 +50,6 @@ function joinTeam() {
|
|||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<?php
|
||||
|
||||
if (!isset($_SESSION["role"]) or ($_SESSION["role"] != "PARTICIPANT" && $_SESSION["role"] != "ENCADRANT")) {
|
||||
?>
|
||||
<h2>Vous devez être participant ou encadrant pour pouvoir rejoindre une équipe.</h2>
|
||||
<?php } else if (isset($access_code)) { ?>
|
||||
Vous avez bien rejoint l'équipe <?php echo $data["name"] ?> !
|
||||
<?php } else if ($_SESSION["team_id"] != NULL) { ?>
|
||||
<h2>Vous êtes déjà dans une équipe.</h2>
|
||||
<?php } else { ?>
|
||||
|
||||
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="access_code">Code d'accès :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="text" id="access_code" name="access_code" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" value="Rejoindre l'équipe" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
||||
|
||||
<?php } ?>
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/rejoindre_equipe.php";
|
||||
require_once "../views/footer.php";
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
require_once "../config.php";
|
||||
|
||||
if (!isset($_SESSION["team_id"]))
|
||||
require_once "403.php";
|
||||
require_once "../403.php";
|
||||
|
||||
if (isset($_POST["send_solution"])) {
|
||||
$error_message = saveSolution();
|
||||
|
@ -58,66 +58,6 @@ function saveSolution() {
|
|||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once 'header.php' ?>
|
||||
|
||||
<?php if (isset($error_message)) {
|
||||
if ($error_message !== false) {
|
||||
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||
} else {
|
||||
echo "<h2>Le fichier a été correctement envoyé !</h2>";
|
||||
}
|
||||
}?>
|
||||
|
||||
<?php if (date("yyyy-mm-dd") < $tournament_data["date_solutions"]) { ?>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="5000000" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="problem">Problème :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="problem" name="problem">
|
||||
<?php
|
||||
for ($i = 1; $i <= 9; ++$i) {
|
||||
echo "<option value=\"$i\">$i</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="file">Fichier :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="file" id="file" name="solution" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" name="send_solution" value="Envoyer" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2>Solutions soumises :</h2>
|
||||
|
||||
<?php
|
||||
while (($data = $solutions_req->fetch()) !== false) {
|
||||
$file_id = $data["file_id"];
|
||||
$problem = $data["problem"];
|
||||
$version = $data["version"];
|
||||
echo "Problème $problem (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php require_once 'footer.php' ?>
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/solutions.php";
|
||||
require_once "../views/footer.php";
|
|
@ -1,9 +1,13 @@
|
|||
<?php require_once 'config.php'; ?>
|
||||
|
||||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ADMIN" && $_SESSION["role"] != "ORGANIZER")
|
||||
require_once "403.php";
|
||||
require_once "../403.php";
|
||||
|
||||
$req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
|
||||
. ($_SESSION["role"] == "ADMIN" ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
|
||||
. "`year` = $YEAR GROUP BY `tournament` ORDER BY `name`;");
|
||||
|
||||
if (isset($_POST["download_zip"])) {
|
||||
$id = $_POST["tournament"];
|
||||
|
@ -34,22 +38,14 @@ if (isset($_POST["download_zip"])) {
|
|||
|
||||
header("Content-Type: application/zip");
|
||||
header("Content-Disposition: attachment; filename=\"Solutions du tournoi de $tournament_name.zip\"");
|
||||
header("Content-Length: " . strval(filesize($temp) + 1));
|
||||
header("Content-Length: " . strval(filesize($temp)));
|
||||
|
||||
readfile($temp);
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once 'header.php'; ?>
|
||||
|
||||
<?php
|
||||
|
||||
$req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
|
||||
. ($_SESSION["role"] == "ADMIN" ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
|
||||
. "`year` = $YEAR GROUP BY `tournament` ORDER BY `name`;");
|
||||
require_once "../views/header.php";
|
||||
|
||||
while (($data_tournament = $req->fetch()) !== false) {
|
||||
echo "<h1>Tournoi de " . $data_tournament["name"] . "</h1>\n";
|
||||
|
@ -66,16 +62,11 @@ while (($data_tournament = $req->fetch()) !== false) {
|
|||
echo "Problème n°$problem de l'équipe $team_name ($team_trigram), version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
|
||||
?>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="tournament" value="<?= $id ?>" />
|
||||
<input type="hidden" name="tournament_name" value="<?= $data_tournament["name"] ?>" />
|
||||
<input style="width: 100%" type="submit" name="download_zip" value="Télécharger l'archive" />
|
||||
</form>
|
||||
<hr />
|
||||
<?php
|
||||
echo "<form method=\"POST\">\n";
|
||||
echo "<input type=\"hidden\" name=\"tournament\" value=\"$id\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"tournament_name\" value=\"" . $data_tournament["name"] . "\" />\n";
|
||||
echo "<input style=\"width: 100%\" type=\"submit\" name=\"download_zip\" value=\"Télécharger l'archive\" />\n";
|
||||
echo "</form><hr />\n";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once 'footer.php'; ?>
|
||||
require_once "../views/footer.php";
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
if (!isset($_SESSION["team_id"]))
|
||||
require_once "../403.php";
|
||||
|
||||
if (isset($_POST["send_synthese"])) {
|
||||
$error_message = saveSynthese();
|
||||
}
|
||||
|
||||
$syntheses_req = $DB->prepare("SELECT `file_id`, `dest`, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `team` = ? AND `tournament` = ? GROUP BY `dest`, `uploaded_at` ORDER BY `dest`, `uploaded_at` DESC;");
|
||||
$syntheses_req->execute([$_SESSION["team_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]);
|
||||
|
||||
$tournament_req = $DB->prepare("SELECT `date_solutions`, `date_syntheses` FROM `tournaments` WHERE `id` = ?;");
|
||||
$tournament_req->execute([$_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]);
|
||||
$tournament_data = $tournament_req->fetch();
|
||||
|
||||
function saveSynthese() {
|
||||
global $LOCAL_PATH, $DB;
|
||||
|
||||
$dest = strtoupper(htmlspecialchars($_POST["dest"]));
|
||||
|
||||
if (!isset($dest) || ($dest != "OPPOSANT" && $dest != "RAPPORTEUR"))
|
||||
return "Le destinataire est invalide.";
|
||||
|
||||
$file = $_FILES["synthese"];
|
||||
|
||||
if ($file["size"] > 5000000 || $file["error"])
|
||||
return "Une erreur est survenue. Merci de vérifier que le fichier pèse moins que 5 Mo.";
|
||||
|
||||
if (finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file["tmp_name"]) != 'application/pdf')
|
||||
return "Le fichier doit être au destmat PDF.";
|
||||
|
||||
if (!is_dir("$LOCAL_PATH/files") && !mkdir("$LOCAL_PATH/files"))
|
||||
return "Les droits sont insuffisants. Veuillez contacter l'administrateur du serveur.";
|
||||
|
||||
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
do {
|
||||
$id = "";
|
||||
for ($i = 0; $i < 64; ++$i) {
|
||||
$id .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
||||
}
|
||||
}
|
||||
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||
|
||||
if (!rename($file["tmp_name"], "$LOCAL_PATH/files/$id"))
|
||||
return "Une erreur est survenue lors de l'envoi du fichier.";
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
|
||||
$req->execute([$id, $_SESSION["team_id"], $_SESSION["tournament_id"], $dest]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/syntheses.php";
|
||||
require_once "../views/footer.php";
|
|
@ -1,9 +1,9 @@
|
|||
<?php require_once 'config.php'; ?>
|
||||
<?php require_once "../config.php"; ?>
|
||||
|
||||
<?php
|
||||
|
||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ADMIN" && $_SESSION["role"] != "ORGANIZER")
|
||||
require_once "403.php";
|
||||
require_once "../403.php";
|
||||
|
||||
if (isset($_POST["download_zip"])) {
|
||||
$id = $_POST["tournament"];
|
||||
|
@ -41,11 +41,7 @@ if (isset($_POST["download_zip"])) {
|
|||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once 'header.php'; ?>
|
||||
|
||||
<?php
|
||||
require_once "../views/header.php";
|
||||
|
||||
$req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
|
||||
. ($_SESSION["role"] == "ADMIN" ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
|
||||
|
@ -66,15 +62,12 @@ while (($data_tournament = $req->fetch()) !== false) {
|
|||
echo "Note de synthèse de l'équipe $team_name ($team_trigram) pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur")
|
||||
. ", version $version : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
?>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="tournament" value="<?= $id ?>" />
|
||||
<input type="hidden" name="tournament_name" value="<?= $data_tournament["name"] ?>" />
|
||||
<input style="width: 100%;" type="submit" name="download_zip" value="Télécharger l'archive" />
|
||||
</form>
|
||||
<hr />
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php require_once 'footer.php'; ?>
|
||||
echo "<form method=\"POST\">\n";
|
||||
echo "<input type=\"hidden\" name=\"tournament\" value=\"$id\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"tournament_name\" value=\"" . $data_tournament["name"] . "\" />\n";
|
||||
echo "<input style=\"width: 100%\" type=\"submit\" name=\"download_zip\" value=\"Télécharger l'archive\" />\n";
|
||||
echo "</form><hr />\n";
|
||||
}
|
||||
|
||||
require_once '../views/footer.php';
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
$tournament_name = htmlspecialchars($_GET["nom"]);
|
||||
|
||||
$response = $DB->prepare("SELECT * FROM `tournaments` WHERE `name` = ? AND `year` = $YEAR;");
|
||||
$response->execute([$tournament_name]);
|
||||
$data = $response->fetch();
|
||||
|
||||
if ($data === false)
|
||||
require_once "../404.php";
|
||||
|
||||
$orgas_req = $DB->query("SELECT `users`.`id` AS `id`, `surname`, `first_name` FROM `users` JOIN `organizers` ON `users`.`id` = `organizer` WHERE `tournament` = " . $data["id"] . ";");
|
||||
$orgas = [];
|
||||
$orgas_id = [];
|
||||
while (($orga_data = $orgas_req->fetch()) !== false) {
|
||||
$orgas[] = $orga_data["first_name"] . " " . $orga_data["surname"];
|
||||
$orgas_id[] = $orga_data["id"];
|
||||
}
|
||||
|
||||
if (isset($_GET["modifier"]) && $_SESSION["role"] != "ADMIN" && !in_array($_SESSION["user_id"], $orgas_id))
|
||||
require_once "../403.php";
|
||||
|
||||
if (isset($_POST["edit_tournament"])) {
|
||||
$error_message = updateTournament();
|
||||
}
|
||||
|
||||
if ($data["final"])
|
||||
$teams_response = $DB->query("SELECT `id`, `name`, `trigram`, `inscription_date`, `validation_status` FROM `teams` WHERE `final_selection` AND `year` = $YEAR;");
|
||||
else
|
||||
$teams_response = $DB->query("SELECT `id`, `name`, `trigram`, `inscription_date`, `validation_status` FROM `teams` WHERE `tournament` = " . $data["id"] . " AND `year` = $YEAR;");
|
||||
|
||||
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
|
||||
|
||||
function updateTournament() {
|
||||
global $DB, $URL_BASE, $YEAR, $data;
|
||||
|
||||
$tournament_id = $data["id"];
|
||||
|
||||
$name = htmlspecialchars($_POST["name"]);
|
||||
|
||||
$result = $DB->query("SELECT `id` FROM `tournaments` WHERE `name` = '" . $name . "' AND `id` != $tournament_id AND `year` = '$YEAR';");
|
||||
if ($result->fetch())
|
||||
return "Un tournoi existe déjà avec ce nom.";
|
||||
|
||||
if (!isset($_POST["organizer"]) || sizeof($_POST["organizer"]) == 0)
|
||||
return "Aucun organisateur n'a été choisi.";
|
||||
|
||||
if ($_SESSION["role"] == "ADMIN") {
|
||||
$organizers = $_POST["organizer"];
|
||||
$orga_mails = [];
|
||||
|
||||
foreach ($organizers as $orga) {
|
||||
$result = $DB->query("SELECT `role`, `email` FROM `users` WHERE `id` = '" . $orga . "' AND `year` = '$YEAR';");
|
||||
$data = $result->fetch();
|
||||
if ($data === FALSE)
|
||||
return "L'organisateur spécifié n'existe pas.";
|
||||
if ($data["role"] != "ORGANIZER" && $data["role"] != "ADMIN")
|
||||
return "L'organisateur indiqué ne peut pas organiser de tournoi.";
|
||||
$orga_mails[] = $data["email"];
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$size = intval(htmlspecialchars($_POST["size"]));
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
return "Le nombre d'équipes indiqué n'est pas un entier valide.";
|
||||
}
|
||||
|
||||
if ($size < 3 || $size > 12)
|
||||
return "Un tournoi doit comporter entre 3 et 12 équipes.";
|
||||
|
||||
$place = htmlspecialchars($_POST["place"]);
|
||||
|
||||
try {
|
||||
$price = intval(htmlspecialchars($_POST["price"]));
|
||||
}
|
||||
catch (Throwable $t) {
|
||||
return "Le tarif pour les participants n'est pas un nombre valide.";
|
||||
}
|
||||
|
||||
if ($price < 0)
|
||||
return "Le TFJM² ne va pas payer les élèves pour venir.";
|
||||
|
||||
if ($price > 50)
|
||||
return "Soyons raisonnable sur le prix.";
|
||||
|
||||
$date_start = htmlspecialchars($_POST["date_start"]);
|
||||
$date_start_parsed = date_parse_from_format("yyyy-mm-dd", $date_start);
|
||||
|
||||
$date_end = htmlspecialchars($_POST["date_end"]);
|
||||
$date_end_parsed = date_parse_from_format("yyyy-mm-dd", $date_end);
|
||||
|
||||
$date_inscription = htmlspecialchars($_POST["date_inscription"]);
|
||||
$time_inscription = htmlspecialchars($_POST["time_inscription"]);
|
||||
$date_inscription_parsed = date_parse_from_format("yyyy-mm-dd", $date_inscription . ' ' . $time_inscription);
|
||||
|
||||
$date_solutions = htmlspecialchars($_POST["date_solutions"]);
|
||||
$time_solutions = htmlspecialchars($_POST["time_solutions"]);
|
||||
$date_solutions_parsed = date_parse_from_format("yyyy-mm-dd", $date_solutions . ' ' . $time_solutions);
|
||||
|
||||
$date_syntheses = htmlspecialchars($_POST["date_syntheses"]);
|
||||
$time_syntheses = htmlspecialchars($_POST["time_syntheses"]);
|
||||
$date_syntheses_parsed = date_parse_from_format("yyyy-mm-dd", $date_syntheses . ' ' . $time_syntheses);
|
||||
|
||||
if (!$date_start_parsed || !$date_end_parsed || !$date_inscription_parsed || !$date_solutions_parsed || !$date_syntheses_parsed)
|
||||
return "Une date est mal formée.";
|
||||
|
||||
$description = htmlspecialchars($_POST["description"]);
|
||||
|
||||
$req = $DB->prepare("UPDATE `tournaments` SET `name` = ?, `size` = ?, `place` = ?, `price` = ?, `description` = ?,
|
||||
`date_start` = ?, `date_end` = ?, `date_inscription` = ?, `date_solutions` = ?, `date_syntheses` = ?
|
||||
WHERE `id` = $tournament_id;");
|
||||
$req->execute([$name, $size, $place, $price, $description, $date_start, $date_end,
|
||||
"$date_inscription $time_inscription", "$date_solutions $time_solutions", "$date_syntheses $time_syntheses"]);
|
||||
|
||||
if ($_SESSION["role"] == "ADMIN") {
|
||||
$DB->exec("DELETE FROM `organizers` WHERE `tournament` = $tournament_id;");
|
||||
foreach ($organizers as $orga) {
|
||||
$req = $DB->prepare("INSERT INTO `organizers`(`organizer`, `tournament`) VALUES(?, ?);");
|
||||
$req->execute([$orga, $tournament_id]);
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: $URL_BASE/tournoi/" . $name);
|
||||
exit();
|
||||
}
|
||||
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/tournoi.php";
|
||||
require_once "../views/footer.php";
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
require_once "../config.php";
|
||||
|
||||
$response = $DB->query("SELECT `name`, `date_start`, `date_end`, `date_inscription`, `date_solutions`, `size` FROM `tournaments`
|
||||
WHERE `year` = '$YEAR' AND `final` = false ORDER BY `date_start`, `name`;");
|
||||
$final_data = $DB->query("SELECT `name`, `date_start`, `date_end`, `date_solutions`, `size` FROM `tournaments` WHERE `final` AND `year` = $YEAR;")->fetch();
|
||||
|
||||
require_once "../views/header.php";
|
||||
require_once "../views/tournois.php";
|
||||
require_once "../views/footer.php";
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once "config.php";
|
||||
require_once "../config.php";
|
||||
|
||||
if (!isset($_GET["file_id"])) {
|
||||
header("Location: $URL_BASE");
|
||||
|
@ -54,7 +54,7 @@ if ($data !== false) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
require_once_once "404.php";
|
||||
require_once "../404.php";
|
||||
http_response_code(404);
|
||||
exit();
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
|
||||
unset($_SESSION["user_id"]);
|
||||
session_destroy();
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<h2>Déconnexion réussie !</h2>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
|
@ -1,173 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once "config.php";
|
||||
|
||||
$trigram = htmlspecialchars($_GET["trigram"]);
|
||||
|
||||
if (isset($_POST["validate"])) {
|
||||
$DB->exec("UPDATE `teams` SET `validation_status` = 'VALIDATED' WHERE `trigram` = '$trigram' AND `year` = $YEAR;");
|
||||
}
|
||||
|
||||
$team_data = $DB->query("SELECT * FROM `teams` WHERE `trigram` = '$trigram' AND `year` = $YEAR;")->fetch();
|
||||
|
||||
if (isset($_POST["select"])) {
|
||||
$DB->exec("UPDATE `teams` SET `final_selection` = true, `validation_status` = 'NOT_READY' WHERE `trigram` = '$trigram' AND `year` = $YEAR;");
|
||||
$team_data["validation_status"] = "NOT_READY";
|
||||
$team_data["final_selection"] = true;
|
||||
$final_id = $_SESSION["final_id"];
|
||||
$team_id = $team_data["id"];
|
||||
|
||||
$sols_req = $DB->prepare("SELECT `file_id`, `problem`, COUNT(`problem`) AS `version` FROM `solutions` WHERE `team` = ? AND `tournament` = ? GROUP BY `problem`, `uploaded_at` ORDER BY `problem`, `uploaded_at` DESC;");
|
||||
$sols_req->execute([$team_data["id"], $team_data["tournament"]]);
|
||||
while (($sol_data = $sols_req->fetch()) !== false) {
|
||||
$old_id = $sol_data["file_id"];
|
||||
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
do {
|
||||
$id = "";
|
||||
for ($i = 0; $i < 64; ++$i) {
|
||||
$id .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
||||
}
|
||||
}
|
||||
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||
|
||||
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`)
|
||||
VALUES (?, ?, ?, ?);");
|
||||
$req->execute([$id, $team_id, $_SESSION["final_id"], $sol_data["problem"]]);
|
||||
}
|
||||
|
||||
$syntheses_req = $DB->prepare("SELECT `file_id`, `dest`, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `team` = ? AND `tournament` = ? GROUP BY `dest`, `uploaded_at` ORDER BY `dest`, `uploaded_at` DESC;");
|
||||
$syntheses_req->execute([$team_data["id"], $team_data["tournament"]]);
|
||||
while (($synthese_data = $syntheses_req->fetch()) !== false) {
|
||||
$old_id = $synthese_data["file_id"];
|
||||
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
do {
|
||||
$id = "";
|
||||
for ($i = 0; $i < 64; ++$i) {
|
||||
$id .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
||||
}
|
||||
}
|
||||
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||
|
||||
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
|
||||
$req->execute([$id, $team_id, $_SESSION["final_id"], $synthese_data["dest"]]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($team_data === false)
|
||||
require_once "404.php";
|
||||
|
||||
$tournament_data = $DB->query("SELECT `name`, `date_start` FROM `tournaments` WHERE `id` = '" . $team_data["tournament"] . "' AND `year` = '$YEAR';")->fetch();
|
||||
|
||||
$documents_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` = ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;");
|
||||
$documents_req->execute([$team_data["id"], $team_data["tournament"]]);
|
||||
|
||||
if ($team_data["final_selection"]) {
|
||||
$documents_final_req = $DB->prepare("SELECT `file_id`, `user`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `team` = ? AND `tournament` != ? GROUP BY `user`, `type` ORDER BY `user`, `type` ASC, MAX(`uploaded_at`) DESC;");
|
||||
$documents_final_req->execute([$team_data["id"], $_SESSION["final_id"]]);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<h2>Informations sur l'équipe</h2>
|
||||
|
||||
Nom de l'équipe : <?= $team_data["name"] ?><br />
|
||||
Trigramme : <?= $team_data["trigram"] ?><br />
|
||||
Tournoi : <a href="<?= $URL_BASE . "/tournoi/" . $tournament_data["name"] ?>"><?= $tournament_data["name"] ?></a><br />
|
||||
<?php
|
||||
for ($i = 1; $i <= 2; ++$i) {
|
||||
if ($team_data["encadrant_" . $i] == NULL)
|
||||
continue;
|
||||
$user_data = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE `id` = " . $team_data["encadrant_" . $i] . " AND `year` = '$YEAR';")->fetch();
|
||||
$id = $user_data["id"];
|
||||
echo "Encadrant $i : <a href=\"$URL_BASE/informations/$id/" . $user_data["first_name"] . " " . $user_data["surname"] . "\">" . $user_data["first_name"] . " " . $user_data["surname"] . "</a><br />";
|
||||
}
|
||||
for ($i = 1; $i <= 6; ++$i) {
|
||||
if ($team_data["participant_" . $i] == NULL)
|
||||
continue;
|
||||
$user_data = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE `id` = " . $team_data["participant_" . $i] . " AND `year` = '$YEAR';")->fetch();
|
||||
$id = $user_data["id"];
|
||||
echo "Participant $i : <a href=\"$URL_BASE/informations/$id/" . $user_data["first_name"] . " " . $user_data["surname"] . "\">" . $user_data["first_name"] . " " . $user_data["surname"] . "</a><br />";
|
||||
}
|
||||
if ($team_data["final_selection"]) {
|
||||
$final_name = $_SESSION["final_name"];
|
||||
echo "<strong>Équipe sélectionnée pour la <a href=\"$URL_BASE/tournoi/$final_name\">finale nationale</a>.</strong>";
|
||||
}
|
||||
?>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2>Autorisations</h2>
|
||||
|
||||
<?php
|
||||
while (($data = $documents_req->fetch()) !== false) {
|
||||
$file_id = $data["file_id"];
|
||||
$type = $data["type"];
|
||||
$user_id = $data["user"];
|
||||
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = '$user_id';")->fetch();
|
||||
$surname = $user_data["surname"];
|
||||
$first_name = $user_data["first_name"];
|
||||
$version = $data["version"];
|
||||
switch ($data["type"]) {
|
||||
case "PARENTAL_CONSENT":
|
||||
$name = "Autorisation parentale";
|
||||
break;
|
||||
case "PHOTO_CONSENT":
|
||||
$name = "Autorisation de droit à l'image";
|
||||
break;
|
||||
case "SANITARY_PLUG":
|
||||
$name = "Fiche sanitaire";
|
||||
break;
|
||||
}
|
||||
echo "$name de $first_name $surname : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ($team_data["final_selection"]) { ?>
|
||||
<hr />
|
||||
<h2>Autorisations pour la finale</h2>
|
||||
<?php
|
||||
while (($data = $documents_req->fetch()) !== false) {
|
||||
$file_id = $data["file_id"];
|
||||
$type = $data["type"];
|
||||
$user_id = $data["user"];
|
||||
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = '$user_id';")->fetch();
|
||||
$surname = $user_data["surname"];
|
||||
$first_name = $user_data["first_name"];
|
||||
$version = $data["version"];
|
||||
switch ($data["type"]) {
|
||||
case "PARENTAL_CONSENT":
|
||||
$name = "Autorisation parentale";
|
||||
break;
|
||||
case "PHOTO_CONSENT":
|
||||
$name = "Autorisation de droit à l'image";
|
||||
break;
|
||||
case "SANITARY_PLUG":
|
||||
$name = "Fiche sanitaire";
|
||||
break;
|
||||
}
|
||||
echo "$name de $first_name $surname : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
}
|
||||
|
||||
if ($team_data["validation_status"] == "WAITING" && $_SESSION["role"] == "ADMIN") { ?>
|
||||
<form method="POST">
|
||||
<input style="width: 100%;" type="submit" name="validate" value="Valider l'équipe" />
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (!$team_data["final_selection"]) { ?>
|
||||
<form method="POST">
|
||||
<input style="width: 100%;" type="submit" name="select" value="Sélectionner pour la finale nationale" />
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
|
@ -1,114 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
|
||||
<div id="header">
|
||||
<center>
|
||||
<img src="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/images/header.jpg" alt="" width="720" height="160">
|
||||
</center>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
<center>
|
||||
|
||||
|
||||
<h3>Vous souhaitez participer au tournoi ? Votre équipe est déjà formée ?</h3>
|
||||
<h4><a href="<?= $URL_BASE ?>/server_files/inscription.php">Créez un compte</a> pour commencer la procédure d'inscription ou <a href="<?= $URL_BASE ?>/server_files/connexion.php">connectez-vous</a> si votre équipe a déjà un compte.</h4>
|
||||
</center>
|
||||
|
||||
<br>
|
||||
|
||||
<center>
|
||||
<h2>Bienvenue sur le site d'inscription du TFJM<sup>2</sup> !</h2>
|
||||
</center>
|
||||
|
||||
<center>
|
||||
Ce site a été conçu pour gérer les inscriptions au Tournoi Français des Jeunes Mathématiciennes et Mathématiciens.
|
||||
<br>
|
||||
<a href="http://www.tfjm.org/">Cliquez ici pour accéder au site de présentation du tournoi.</a>
|
||||
</center>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
<p align="justify"><strong>
|
||||
Attention aux échéances ! Chaque tournoi a une date limite pour les inscriptions et une date limite pour déposer vos solutions. Elles sont affichées avec les informations de chaque tournoi. Merci de vous y référer !
|
||||
<br>
|
||||
Une fois l'échéance passée, le site bloque tout accès aux inscriptions (et respectivement au dépôt des solutions).</strong>
|
||||
</p>
|
||||
|
||||
<p style="color:red;">
|
||||
Attention, modification du règlement par rapport aux années précédentes : article 4.3
|
||||
<br>
|
||||
"l’équipe doit envoyer par mail à contact@tfjm.org, une lettre (au format pdf), répondant aux questions suivantes :
|
||||
<br>
|
||||
|
||||
</p><ul style="color:red;">
|
||||
<li>Comment l’équipe s’est-elle formée ?</li>
|
||||
<li>Comment l’équipe va-t-elle travailler (où peut-elle se rencontrer, à quelle fréquence, rencontres avec l’encadrant•e) ? </li>
|
||||
</ul>
|
||||
|
||||
Cette lettre permettra aux organisateurs•trices de vérifier que l’équipe dispose des conditions nécessaires à une participation sérieuse. Sont dispensées les équipes dont la moitié ou plus des membres sont scolarisés dans le même établissement. Le comité National d’Organisation se réserve le droit d’accepter ou non l’inscription des équipes concernées par cette lettre."
|
||||
<br>
|
||||
|
||||
Pour plus de détail, voir le règlement : <a href="https://tfjm.org/infos-tournois/">https://tfjm.org/infos-tournois/</a>
|
||||
<p></p>
|
||||
|
||||
|
||||
<center>
|
||||
<h2>Comment ça marche ?</h2>
|
||||
</center>
|
||||
|
||||
<p align="justify">
|
||||
Pour participer à l'un des tournois régionaux, il suffit de créer un compte sur la rubrique <b>Inscription</b>. Il vous faudra une adresse email pour ce faire. Un mail de confirmation sera envoyé à cette adresse. Il vous fournira un nom d'utilisateur et un mot de passe que vous allez devoir changer par la suite.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Vous pouvez accéder à votre compte via la rubrique <b>Connexion</b>. Une fois connecté, vous pourrez :
|
||||
</p><ul>
|
||||
<li>rentrer des informations sur les membres de votre équipe, tant participants qu'encadrants ;</li>
|
||||
<li>enregistrer et télécharger des versions préliminaires de vos solutions (seulement la dernière version enregistrée avant
|
||||
la date limite sera prise en compte pour le tournoi).</li>
|
||||
</ul>
|
||||
|
||||
Une fois que vous aurez fourni toutes les informations demandées dans la rubrique <b>Mon Équipe</b>, votre inscription pourra être validée par les organisateurs locaux.
|
||||
<p></p>
|
||||
|
||||
|
||||
<p class="text-danger">ATTENTION ! Votre équipe ne sera considérée comme admissible à participer au tournoi que lorsque cette première étape aura été franchie.</p>
|
||||
|
||||
<p>Pensez donc à former une équipe complète (minimum 4 participants et 1 encadrant) le plus tôt possible pour avoir plus de chances de participer, compte tenu du nombre des places disponibles dans chaque tournoi (qui sera dûment affiché sur la rubrique <b>Liste des Tournois</b>). Les équipes restantes seront placées en liste d'attente.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Pour les équipes dont l'inscription aura été validée, des documents à télécharger, remplir et signer deviendront disponibles sur votre compte. Vous allez devoir ensuite les scanner et les télécharger vers le site pour compléter votre inscription.
|
||||
</p>
|
||||
|
||||
|
||||
<p class="text-danger">ATTENTION ! Les équipes qui ne respecteront pas les délais pour rendre ces documents risquent d'être disqualifiées et de laisser leur place aux équipes placées en liste d'attente.</p>
|
||||
|
||||
<p>
|
||||
<em><strong>NB :</strong> Ce site est récent et il est encore possible que certaines pages ne fonctionnent pas correctement. Si vous remarquez des bugs, merci de les signaler à l'adresse <a href="mailto:contact@tfjm.org">contact@tfjm.org</a>.</em>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<!-- code facebook -->
|
||||
|
||||
<!-- liste des actualités -->
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
|
@ -1,281 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
|
||||
if (isset($_POST["submitted"])) {
|
||||
$error_message = register();
|
||||
}
|
||||
|
||||
function register() {
|
||||
global $DB, $YEAR, $URL_BASE, $MAIL_ADDRESS;
|
||||
global $email, $firstname, $surname, $birth_date, $gender, $address, $postal_code, $city, $country, $phone_number, $role, $school, $class, $responsible_name, $responsible_phone, $responsible_email;
|
||||
|
||||
$email = strtolower(htmlspecialchars($_POST["email"]));
|
||||
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||
return "L'email entrée est invalide.";
|
||||
|
||||
$result = $DB->query("SELECT `email` FROM `users` WHERE `email` = '" . $email . "' AND `year` = '$YEAR';");
|
||||
if ($result->fetch())
|
||||
return "Un compte existe déjà avec cette adresse e-mail.";
|
||||
|
||||
$password = htmlspecialchars($_POST["password"]);
|
||||
if (strlen($password) < 8)
|
||||
return "Le mot de passe doit comporter au moins 8 caractères.";
|
||||
if ($password != $_POST["confirm_password"])
|
||||
return "Les deux mots de passe sont différents.";
|
||||
|
||||
$password = password_hash($password, PASSWORD_BCRYPT);
|
||||
|
||||
$surname = strtoupper(htmlspecialchars($_POST["surname"]));
|
||||
if (!isset($surname) || $surname == "")
|
||||
return "Le nom de famille est obligatoire.";
|
||||
|
||||
$firstname = htmlspecialchars($_POST["firstname"]);
|
||||
if (!isset($surname) || $surname == "")
|
||||
return "Le prénom est obligatoire.";
|
||||
|
||||
$birth_date = date_parse_from_format("yyyy-mm-dd", htmlspecialchars($_POST["birth_date"]));
|
||||
|
||||
if ($birth_date === FALSE)
|
||||
return "La date de naissance est invalide.";
|
||||
|
||||
if (htmlspecialchars($_POST["birth_date"]) >= $YEAR . "-01-01")
|
||||
return "Vous devez avoir un âge strictement positif. Date de naissance rentrée : " . htmlspecialchars($_POST["birth_date"]);
|
||||
|
||||
$gender = htmlspecialchars($_POST["gender"]);
|
||||
|
||||
if (!isset($gender) || ($gender != "M" && $gender != "F"))
|
||||
return "Le sexe indiqué est invalide.";
|
||||
|
||||
$address = htmlspecialchars($_POST["address"]);
|
||||
|
||||
if (!isset($address))
|
||||
$address = "";
|
||||
|
||||
try {
|
||||
$postal_code = intval($_POST["postal_code"]);
|
||||
if ($postal_code < 1000 || $postal_code > 95999)
|
||||
return "Le code postal est invalide.";
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
return "Le code postal n'est pas un nombre valide.";
|
||||
}
|
||||
|
||||
$city = htmlspecialchars($_POST["city"]);
|
||||
|
||||
if (!isset($city))
|
||||
$city = "";
|
||||
|
||||
$country = htmlspecialchars($_POST["country"]);
|
||||
|
||||
if (!isset($country))
|
||||
$country = "France";
|
||||
|
||||
$phone_number = htmlspecialchars($_POST["phone_number"]);
|
||||
|
||||
if (!isset($phone_number) || $phone_number == "")
|
||||
return "Vous devez renseigner un numéro de téléphone.";
|
||||
|
||||
$role = htmlspecialchars($_POST["role"]);
|
||||
|
||||
if (!isset($role) || ($role != "participant" && $role != "encadrant"))
|
||||
return "Le rôle entré n'est pas valide.";
|
||||
|
||||
$role = strtoupper($role);
|
||||
|
||||
$school = htmlspecialchars($_POST["school"]);
|
||||
$class = strtoupper(htmlspecialchars($_POST["class"]));
|
||||
$responsible_name = htmlspecialchars($_POST["responsible_name"]);
|
||||
$responsible_phone = htmlspecialchars($_POST["responsible_phone"]);
|
||||
$responsible_email = htmlspecialchars($_POST["responsible_email"]);
|
||||
|
||||
if ($role == "ENCADRANT") {
|
||||
$school = NULL;
|
||||
$class = NULL;
|
||||
$responsible_name = NULL;
|
||||
$responsible_phone = NULL;
|
||||
$responsible_email = NULL;
|
||||
}
|
||||
else {
|
||||
if (!isset($class) && $class != "TERMINALE" && $class != "PREMIERE" && $class != "SECONDE")
|
||||
return "La classe spécifiée est invalide. Merci de ne pas créer vos propres requêtes.";
|
||||
|
||||
if ((!isset($responsible_name) || $responsible_name == "") && $birth_date > strval($YEAR - 18) . "-05-01")
|
||||
return "Veuillez spécifier un nom de responsable légal.";
|
||||
|
||||
if ((!isset($responsible_phone) || $responsible_phone == "") && (!isset($responsible_email) || !filter_var($responsible_email, FILTER_VALIDATE_EMAIL))
|
||||
&& $birth_date > strval($YEAR - 18) . "-05-01")
|
||||
return "Veuillez préciser au moins le numéro de téléphone ou l'addresse e-mail de votre responsable légal.";
|
||||
}
|
||||
|
||||
$description = $_POST["description"];
|
||||
|
||||
if ($role == "PARTICIPANT")
|
||||
$description = NULL;
|
||||
|
||||
$confirm_email_uid = uniqid();
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `birth_date`, `gender`,
|
||||
`address`, `postal_code`, `city`, `country`, `phone_number`, `school`, `class`, `role`, `description`, `year`)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
$req->execute([$email, $password, $confirm_email_uid, $surname, $firstname, $_POST["birth_date"], $gender, $address, $postal_code,
|
||||
$city, $country, $phone_number, $school, $class, $role, $description, $YEAR]);
|
||||
|
||||
$msg = "Merci pour votre inscription au TFJM² $YEAR ! Veuillez désormais confirmer votre adresse mail en cliquant ici : $URL_BASE/confirmer_mail/$confirm_email_uid";
|
||||
mail($email, "Inscription au TFJM² $YEAR", $msg, "From: $MAIL_ADDRESS\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||
|
||||
<?php
|
||||
if (isset($error_message) && $error_message === FALSE) {
|
||||
?>
|
||||
Votre inscription est validée ! Merci désormais de confirmer votre boîte mail pour valider votre adresse.
|
||||
<?php } else if (isset($_SESSION["user_id"])) { ?>
|
||||
|
||||
<h2>Vous êtes déjà connecté !</h2>
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td style="width: 30%;"><label for="email">E-mail :</label></td>
|
||||
<td style="width: 70%;"><input style="width: 100%;" type="email" id="email" name="email" value="<?php if (isset($_POST["email"])) echo $_POST["email"] ?>" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="password">Mot de passe :</label></td>
|
||||
<td><input style="width: 100%;" type="password" id="password" name="password" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="confirm_password">Confirmer le mot de passe :</label></td>
|
||||
<td><input style="width: 100%;" type="password" id="confirm_password" name="confirm_password" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="surname">Nom :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="surname" name="surname" value="<?php if (isset($_POST["surname"])) echo $_POST["surname"] ?>" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="firstname">Prénom :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="firstname" name="firstname" value="<?php if (isset($_POST["firstname"])) echo $_POST["firstname"] ?>" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="birth_date">Date de naissance :</label></td>
|
||||
<td><input style="width: 100%;" type="date" id="birth_date" name="birth_date" value="<?php if (isset($_POST["birth_date"])) echo $_POST["birth-date"] ?>" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="gender">Sexe :</label></td>
|
||||
<td><input type="radio" id="male" name="gender" value="M" required <?= isset($_POST["gender"]) && $_POST["gender"] == "M" ? "checked" : "" ?> /><label for="male">Homme</label>
|
||||
<input type="radio" id="female" name="gender" value="F" required <?= isset($_POST["gender"]) && $_POST["gender"] == "F" ? "checked" : "" ?> /><label for="female">Femme</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="address">Adresse :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="address" name="address" value="<?php if (isset($_POST["address"])) echo $_POST["address"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="postal_code">Code postal :</label></td>
|
||||
<td><input style="width: 100%;" type="number" id="postal_code" name="postal_code" value="<?php if (isset($_POST["postal_code"])) echo $_POST["postal_code"] ?>" min="1000" max="95999" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="city">Ville :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="city" name="city" value="<?php if (isset($_POST["city"])) echo $_POST["city"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="country">Pays :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="country" name="country" value="<?php echo isset($_POST["country"]) ? $_POST["country"] : "France" ?>" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="phone_number">Numéro de téléphone :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="phone_number" name="phone_number" value="<?php if (isset($_POST["phone_number"])) echo $_POST["phone_number"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="role">Rôle :</label></td>
|
||||
<td><select style="width: 100%;" id="role" name="role" onchange="selectRole()">
|
||||
<option value="participant">Participant</option>
|
||||
<option value="encadrant">Encadrant</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label id="school_label" for="school">Établissement dans lequel l'élève étudie :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="school" name="school" value="<?php if (isset($_POST["school"])) echo $_POST["school"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label id="class_label" for="class">Classe :</label></td>
|
||||
<td><select style="width: 100%;" id="class" name="class">
|
||||
<option value="terminale">Terminale</option>
|
||||
<option value="premiere">Première</option>
|
||||
<option value="seconde">Seconde ou inférieur</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label id="responsible_name_label" for="responsible_name">Nom du responsable légal :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="responsible_name" name="responsible_name" value="<?php if (isset($_POST["responsible_name"])) echo $_POST["responsible_name"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label id="responsible_phone_label" for="responsible_phone">Téléphone du responsable légal :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="responsible_phone" name="responsible_phone" value="<?php if (isset($_POST["responsible_phone"])) echo $_POST["responsible_phone"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label id="responsible_email_label" for="responsible_email">Email du responsable légal :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="responsible_email" name="responsible_email" value="<?php if (isset($_POST["responsible_email"])) echo $_POST["responsible_email"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label id="description_label" for="description">Description :</label></td>
|
||||
<td><textarea style="width: 100%;" id="description" name="description"><?php if (isset($_POST["description"])) echo $_POST["description"] ?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%;" type="submit" value="S'inscrire" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function selectRole() {
|
||||
switch (document.getElementById("role").value) {
|
||||
case "participant":
|
||||
document.getElementById("school_label").style.display = "block";
|
||||
document.getElementById("school").style.display = "block";
|
||||
document.getElementById("school").require = "true";
|
||||
document.getElementById("class_label").style.display = "block";
|
||||
document.getElementById("class").style.display = "block";
|
||||
document.getElementById("responsible_name_label").style.display = "block";
|
||||
document.getElementById("responsible_name").style.display = "block";
|
||||
document.getElementById("responsible_phone_label").style.display = "block";
|
||||
document.getElementById("responsible_phone").style.display = "block";
|
||||
document.getElementById("responsible_email_label").style.display = "block";
|
||||
document.getElementById("responsible_email").style.display = "block";
|
||||
document.getElementById("description_label").style.display = "none";
|
||||
document.getElementById("description").style.display = "none";
|
||||
break;
|
||||
case "encadrant":
|
||||
document.getElementById("school_label").style.display = "none";
|
||||
document.getElementById("school").style.display = "none";
|
||||
document.getElementById("school").require = "false";
|
||||
document.getElementById("class_label").style.display = "none";
|
||||
document.getElementById("class").style.display = "none";
|
||||
document.getElementById("responsible_name_label").style.display = "none";
|
||||
document.getElementById("responsible_name").style.display = "none";
|
||||
document.getElementById("responsible_phone_label").style.display = "none";
|
||||
document.getElementById("responsible_phone").style.display = "none";
|
||||
document.getElementById("responsible_email_label").style.display = "none";
|
||||
document.getElementById("responsible_email").style.display = "none";
|
||||
document.getElementById("description_label").style.display = "block";
|
||||
document.getElementById("description").style.display = "block";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
selectRole();
|
||||
</script>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
||||
|
||||
<?php } ?>
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
function loadUserValues() {
|
||||
global $DB, $URL_BASE, $YEAR;
|
||||
|
||||
if (isset($_SESSION["user_id"])) {
|
||||
$response = $DB->query("SELECT * FROM `users` WHERE `id` ='" . $_SESSION["user_id"] . "' AND `year` = '$YEAR';");
|
||||
$data = $response->fetch();
|
||||
if ($data === FALSE)
|
||||
unset($_SESSION["user_id"]);
|
||||
else {
|
||||
$_SESSION["email"] = $data["email"];
|
||||
$_SESSION["surname"] = $data["surname"];
|
||||
$_SESSION["first_name"] = $data["first_name"];
|
||||
$_SESSION["birth_date"] = $data["birth_date"];
|
||||
$_SESSION["role"] = $data["role"];
|
||||
$_SESSION["team_id"] = $data["team_id"];
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_SESSION["team_id"]) && $_SESSION["team_id"] != NULL) {
|
||||
$response = $DB->query("SELECT `tournament`, `validation_status`, `final_selection` FROM `teams` WHERE `id` ='" . $_SESSION["team_id"] . "' AND `year` = '$YEAR';");
|
||||
$data = $response->fetch();
|
||||
$_SESSION["tournament_id"] = $data["tournament"];
|
||||
$_SESSION["team_validation_status"] = $data["validation_status"];
|
||||
}
|
||||
|
||||
if ((isset($data["final_selection"]) && $data["final_selection"]) || $_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER") {
|
||||
$response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `final` AND `year` = $YEAR;");
|
||||
$data = $response->fetch();
|
||||
$_SESSION["final_id"] = $data["id"];
|
||||
$_SESSION["final_name"] = $data["name"];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_GET["be-admin"])) {
|
||||
$DB->exec("UPDATE `users` SET `role` = 'ADMIN' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||||
quitTeam();
|
||||
header("Location: $URL_BASE");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_GET["be-organizer"])) {
|
||||
$DB->exec("UPDATE `users` SET `role` = 'ORGANIZER' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||||
quitTeam();
|
||||
header("Location: $URL_BASE");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_GET["be-participant"])) {
|
||||
$DB->exec("UPDATE `users` SET `role` = 'PARTICIPANT' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||||
quitTeam();
|
||||
header("Location: $URL_BASE");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_GET["be-encadrant"])) {
|
||||
$DB->exec("UPDATE `users` SET `role` = 'ENCADRANT' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||||
quitTeam();
|
||||
header("Location: $URL_BASE");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
function echoDate($date = NULL, $with_time = false) {
|
||||
if ($date == NULL)
|
||||
$date = date("yyyy-mm-dd");
|
||||
|
||||
return strftime("%d %B %G" . ($with_time ? " %H:%M" : ""), strtotime($date));
|
||||
}
|
||||
|
||||
function quitTeam() {
|
||||
global $DB, $URL_BASE;
|
||||
|
||||
if ($_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER")
|
||||
return;
|
||||
|
||||
for ($i = 1; $i <= ($_SESSION["role"] == "PARTICIPANT" ? 6 : 2); ++$i)
|
||||
/** @noinspection SqlResolve */
|
||||
$DB->exec("UPDATE `teams` SET `" . strtolower($_SESSION["role"]) . "_$i` = NULL WHERE `" . strtolower($_SESSION["role"]) . "_$i` = " . $_SESSION["user_id"] . ";");
|
||||
$DB->exec("UPDATE `users` SET `team_id` = NULL WHERE `id` = " . $_SESSION["user_id"] . ";");
|
||||
$DB->exec("UPDATE `teams` SET `encadrant_1` = `encadrant_2`, `encadrant_2` = NULL WHERE `encadrant_1` IS NULL;");
|
||||
for ($i = 1; $i <= 5; ++$i) {
|
||||
/** @noinspection SqlResolve */
|
||||
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;");
|
||||
}
|
||||
|
||||
$req = $DB->query("SELECT `file_id` FROM `documents` WHERE `user` = '" . $_SESSION["user_id"] . "';");
|
||||
while (($data = $req->fetch()) !== false)
|
||||
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||
$DB->exec("DELETE FROM `documents` WHERE `user` = '" . $_SESSION["user_id"] . "';");
|
||||
|
||||
if ($DB->exec("DELETE FROM `teams` WHERE `encadrant_1` IS NULL AND `participant_1` IS NULL;") > 0) {
|
||||
$req = $DB->query("SELECT `file_id` FROM `solutions` WHERE `team` = '" . $_SESSION["team_id"] . "';");
|
||||
while (($data = $req->fetch()) !== false)
|
||||
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||
$DB->exec("DELETE FROM `solutions` WHERE `team` = " . $_SESSION["team_id"] . ";");
|
||||
|
||||
$req = $DB->query("SELECT `file_id` FROM `syntheses` WHERE `team` = '" . $_SESSION["team_id"] . "';");
|
||||
while (($data = $req->fetch()) !== false)
|
||||
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||
$DB->exec("DELETE FROM `syntheses` WHERE `team` = " . $_SESSION["team_id"] . ";");
|
||||
}
|
||||
unset($_SESSION["team_id"]);
|
||||
unset($_SESSION["team_validation_status"]);
|
||||
}
|
|
@ -1,323 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
|
||||
if (isset($_POST["submitted"])) {
|
||||
$error_message = updateAccount();
|
||||
} elseif (isset($_POST["submitted_password"])) {
|
||||
$error_message = updatePassword();
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"])) {
|
||||
$result = $DB->query("SELECT * FROM `users` WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||||
$user_data = $result->fetch();
|
||||
}
|
||||
|
||||
function updateAccount()
|
||||
{
|
||||
global $DB, $URL_BASE, $MAIL_ADDRESS;
|
||||
|
||||
if (!isset($_SESSION["user_id"]))
|
||||
return "Vous n'êtes pas connecté.";
|
||||
|
||||
$ID = $_SESSION["user_id"];
|
||||
|
||||
$surname = htmlspecialchars($_POST["surname"]);
|
||||
if (isset($surname) && $surname != "")
|
||||
$DB->prepare("UPDATE `users` SET `surname` = ? WHERE `id` = ?;")->execute([$surname, $ID]);
|
||||
|
||||
$first_name = htmlspecialchars($_POST["firstname"]);
|
||||
if (isset($first_name) && $first_name != "")
|
||||
$DB->prepare("UPDATE `users` SET `first_name` = ? WHERE `id` = ?;")->execute([$first_name, $ID]);
|
||||
|
||||
$birth_date = htmlspecialchars($_POST["birth_date"]);
|
||||
if (isset($birth_date) && $birth_date != "")
|
||||
$DB->prepare("UPDATE `users` SET `birth_date` = ? WHERE `id` = ?;")->execute([$birth_date, $ID]);
|
||||
|
||||
if (isset($_POST["gender"])) {
|
||||
$gender = htmlspecialchars($_POST["gender"]);
|
||||
if (isset($gender) && ($gender == "M" || $gender == "F"))
|
||||
$DB->prepare("UPDATE `users` SET `gender` = ? WHERE `id` = ?;")->execute([$gender, $ID]);
|
||||
}
|
||||
|
||||
$address = htmlspecialchars($_POST["address"]);
|
||||
if (isset($address) && $address != "")
|
||||
$DB->prepare("UPDATE `users` SET `address` = ? WHERE `id` = ?;")->execute([$address, $ID]);
|
||||
|
||||
$postal_code = htmlspecialchars($_POST["postal_code"]);
|
||||
if (isset($postal_code) && $postal_code != "")
|
||||
$DB->prepare("UPDATE `users` SET `postal_code` = ? WHERE `id` = ?;")->execute([$postal_code, $ID]);
|
||||
|
||||
$city = htmlspecialchars($_POST["city"]);
|
||||
if (isset($city) && $city != "")
|
||||
$DB->prepare("UPDATE `users` SET `city` = ? WHERE `id` = ?;")->execute([$city, $ID]);
|
||||
|
||||
$country = htmlspecialchars($_POST["country"]);
|
||||
if (isset($country) && $country != "")
|
||||
$DB->prepare("UPDATE `users` SET `country` = ? WHERE `id` = ?;")->execute([$country, $ID]);
|
||||
|
||||
$phone_number = htmlspecialchars($_POST["phone_number"]);
|
||||
if (isset($phone_number) && $phone_number != "")
|
||||
$DB->prepare("UPDATE `users` SET `phone_number` = ? WHERE `id` = ?;")->execute([$phone_number, $ID]);
|
||||
|
||||
if (isset($_POST["school"])) {
|
||||
$school = htmlspecialchars($_POST["school"]);
|
||||
if (isset($school) && $school != "")
|
||||
$DB->prepare("UPDATE `users` SET `school` = ? WHERE `id` = ?;")->execute([$school, $ID]);
|
||||
}
|
||||
|
||||
if (isset($_POST["class"])) {
|
||||
$class = htmlspecialchars($_POST["class"]);
|
||||
if (isset($class) && ($class == "terminale" || $class == "premiere" || $class == "seconde"))
|
||||
$DB->prepare("UPDATE `users` SET `class` = ? WHERE `id` = ?;")->execute([strtoupper($class), $ID]);
|
||||
}
|
||||
|
||||
if (isset($_POST["responsible_name"])) {
|
||||
$responsible_name = htmlspecialchars($_POST["responsible_name"]);
|
||||
if (isset($responsible_name) && $responsible_name != "")
|
||||
$DB->prepare("UPDATE `users` SET `responsible_name` = ? WHERE `id` = ?;")->execute([$responsible_name, $ID]);
|
||||
}
|
||||
|
||||
if (isset($_POST["responsible_phone"])) {
|
||||
$responsible_phone = htmlspecialchars($_POST["responsible_phone"]);
|
||||
if (isset($responsible_phone) && $responsible_phone != "")
|
||||
$DB->prepare("UPDATE `users` SET `responsible_phone` = ? WHERE `id` = ?;")->execute([$responsible_phone, $ID]);
|
||||
}
|
||||
|
||||
if (isset($_POST["responsible_email"])) {
|
||||
$responsible_email = htmlspecialchars($_POST["responsible_email"]);
|
||||
if (isset($responsible_email) && $responsible_email != "")
|
||||
$DB->prepare("UPDATE `users` SET `responsible_email` = ? WHERE `id` = ?;")->execute([$responsible_email, $ID]);
|
||||
}
|
||||
|
||||
if (isset($_POST["description"])) {
|
||||
$description = htmlspecialchars($_POST["description"]);
|
||||
if (isset($description) && $description != "")
|
||||
$DB->prepare("UPDATE `users` SET `description` = ? WHERE `id` = ?;")->execute([$description, $ID]);
|
||||
}
|
||||
|
||||
$email = htmlspecialchars($_POST["email"]);
|
||||
if (isset($email) && $email != "" && filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$confirm_email_uid = uniqid();
|
||||
$DB->prepare("UPDATE `users` SET `email` = ?, `confirm_email` = ? WHERE `id` = ?;")->execute([$email, $confirm_email_uid, $ID]);
|
||||
|
||||
$msg = "Vous venez de changer votre adresse mail. Veuillez désormais confirmer votre adresse mail en cliquant ici : $URL_BASE/confirmer_mail/$confirm_email_uid";
|
||||
mail($email, "Changement d'adresse mail - TFJM²", $msg, "From: $MAIL_ADDRESS\r\n");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function updatePassword()
|
||||
{
|
||||
global $DB, $YEAR;
|
||||
|
||||
$old = htmlspecialchars($_POST["old_password"]);
|
||||
$new = htmlspecialchars($_POST["new_password"]);
|
||||
$confirm = htmlspecialchars($_POST["confirm_password"]);
|
||||
|
||||
$result = $DB->query("SELECT `pwd_hash` FROM `users` WHERE `id` = '" . $_SESSION["user_id"] . "' AND `year` = '$YEAR';");
|
||||
if (($data = $result->fetch()) === FALSE)
|
||||
return "Le compte n'existe pas.";
|
||||
|
||||
if (!password_verify($old, $data["pwd_hash"]))
|
||||
return "L'ancien mot de passe est incorrect.";
|
||||
|
||||
if (strlen($new) < 8)
|
||||
return "Le mot de passe doit comporter au moins 8 caractères.";
|
||||
|
||||
if ($new != $confirm)
|
||||
return "Les deux mots de passe sont différents.";
|
||||
|
||||
$hash = password_hash($new, PASSWORD_BCRYPT);
|
||||
|
||||
$DB->prepare("UPDATE `users` SET `pwd_hash` = ? WHERE `id` = ?;")->execute([$hash, $_SESSION["user_id"]]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<?php if (!isset($_SESSION["user_id"])) {
|
||||
echo "<h2>Vous devez être connecté pour afficher cette page.</h2>";
|
||||
require_once "footer.php";
|
||||
return;
|
||||
} ?>
|
||||
|
||||
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||
|
||||
<?php
|
||||
if (isset($error_message) && $error_message === FALSE) {
|
||||
?>
|
||||
<h2>Votre compte a bien été mis à jour !</h2>
|
||||
<?php
|
||||
if (isset($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
echo "Votre adresse mail a bien été changée. Veuillez vérifier votre boîte mail pour valider votre nouvelle adresse, vous en aurez besoin pour vous reconnecter.";
|
||||
}
|
||||
?>
|
||||
<?php } ?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true"/>
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td style="width: 30%"><label for="email">E-mail :</label></td>
|
||||
<td style="width: 70%"><?php echo $user_data["email"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="email" id="email" name="email"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="surname">Nom :</label></td>
|
||||
<td><?php echo $user_data["surname"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="surname" name="surname"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="firstname">Prénom :</label></td>
|
||||
<td><?php echo $user_data["first_name"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="firstname" name="firstname"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="birth_date">Date de naissance :</label></td>
|
||||
<td><?php echo echo_date($user_data["birth_date"]) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="date" id="birth_date" name="birth_date"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="gender">Sexe :</label></td>
|
||||
<td><input type="radio" id="male" name="gender" value="M" <?php if ($user_data["gender"] == "M") echo "checked" ?> /><label for="male">Homme</label>
|
||||
<input type="radio" id="female" name="gender" value="F" <?php if ($user_data["gender"] == "F") echo "checked" ?> /><label for="female">Femme</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="address">Adresse :</label></td>
|
||||
<td><?php echo $user_data["address"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="address" name="address"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="postal_code">Code postal :</label></td>
|
||||
<td><?php echo $user_data["postal_code"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="number" id="postal_code" name="postal_code" min="1000" max="95999"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="city">Ville :</label></td>
|
||||
<td><?php echo $user_data["city"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="city" name="city"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="country">Pays :</label></td>
|
||||
<td><?php echo $user_data["country"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="country" name="country"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="phone_number">Numéro de téléphone :</label></td>
|
||||
<td><?php echo $user_data["phone_number"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="phone_number" name="phone_number"/></td>
|
||||
</tr>
|
||||
<?php if ($user_data["role"] == "PARTICIPANT") { ?>
|
||||
<tr>
|
||||
<td><label for="school">Établissement dans lequel l'élève étudie :</label></td>
|
||||
<td><?php echo $user_data["school"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="school" name="school"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="class">Classe :</label></td>
|
||||
<td><select style="width: 100%" id="class" name="class">
|
||||
<option value="terminale" <?php if ($user_data["class"] == "terminale") echo "selected" ?>>Terminale</option>
|
||||
<option value="premiere" <?php if ($user_data["class"] == "premiere") echo "selected" ?>>Première</option>
|
||||
<option value="seconde" <?php if ($user_data["class"] == "seconde") echo "selected" ?>>Seconde ou inférieur</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="responsible_name">Nom du responsable légal :</label>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $user_data["responsible_name"] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="text" id="responsible_name" name="responsible_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="responsible_phone">Téléphone du responsable légal :</label>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $user_data["responsible_phone"] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%" type="text" id="responsible_phone" name="responsible_phone" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="responsible_email">Email du responsable légal :</label>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $user_data["responsible_email"] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%" type="email" id="responsible_email" name="responsible_email" />
|
||||
</td>
|
||||
</tr>
|
||||
<?php } else { ?>
|
||||
<tr>
|
||||
<td><label for="description">Description :</label></td>
|
||||
<td><textarea style="width: 100%" id="description" name="description"><?php echo $user_data["description"] ?></textarea></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" style="width: 100%" value="Mettre à jour mes données"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<div style="padding: 20px"></div>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted_password" value="true"/>
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td style="width: 30%"><label for="old_password">Ancien mot de passe :</label></td>
|
||||
<td style="width: 70%"><input style="width: 100%" type="password" id="old_password" name="old_password"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="new_password">Nouveau mot de passe :</label></td>
|
||||
<td><input style="width: 100%" type="password" id="new_password" name="new_password"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="confirm_password">Confirmer le mot de passe :</label></td>
|
||||
<td><input style="width: 100%" type="password" id="confirm_password" name="confirm_password"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" style="width: 100%" value="Mettre à jour mon mot de passe"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
|
@ -1,367 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
|
||||
if (isset($_POST["leave_team"])) {
|
||||
for ($i = 1; $i <= ($_SESSION["role"] == "PARTICIPANT" ? 6 : 2); ++$i)
|
||||
/** @noinspection SqlResolve */
|
||||
$DB->exec("UPDATE `teams` SET `" . strtolower($_SESSION["role"]) . "_$i` = NULL WHERE `" . strtolower($_SESSION["role"]) . "_$i` = " . $_SESSION["user_id"] . ";");
|
||||
$DB->exec("UPDATE `users` SET `team_id` = NULL WHERE `id` = " . $_SESSION["user_id"] . ";");
|
||||
$DB->exec("UPDATE `teams` SET `encadrant_1` = `encadrant_2`, `encadrant_2` = NULL WHERE `encadrant_1` IS NULL;");
|
||||
for ($i = 1; $i <= 5; ++$i) {
|
||||
/** @noinspection SqlResolve */
|
||||
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;");
|
||||
}
|
||||
|
||||
$req = $DB->query("SELECT `file_id` FROM `documents` WHERE `user` = '" . $_SESSION["user_id"] . "';");
|
||||
while (($data = $req->fetch()) !== false)
|
||||
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||
$DB->exec("DELETE FROM `documents` WHERE `user` = '" . $_SESSION["user_id"] . "';");
|
||||
|
||||
if ($DB->exec("DELETE FROM `teams` WHERE `encadrant_1` IS NULL AND `participant_1` IS NULL;") > 0) {
|
||||
$req = $DB->query("SELECT `file_id` FROM `solutions` WHERE `team` = '" . $_SESSION["team_id"] . "';");
|
||||
while (($data = $req->fetch()) !== false)
|
||||
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||
$DB->exec("DELETE FROM `solutions` WHERE `team` = " . $_SESSION["team_id"] . ";");
|
||||
|
||||
$req = $DB->query("SELECT `file_id` FROM `syntheses` WHERE `team` = '" . $_SESSION["team_id"] . "';");
|
||||
while (($data = $req->fetch()) !== false)
|
||||
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||
$DB->exec("DELETE FROM `syntheses` WHERE `team` = " . $_SESSION["team_id"] . ";");
|
||||
}
|
||||
unset($_SESSION["team_id"]);
|
||||
unset($_SESSION["team_validation_status"]);
|
||||
header("Location: $URL_BASE");
|
||||
exit();
|
||||
}
|
||||
|
||||
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `year` = '$YEAR';");
|
||||
|
||||
if (isset($_POST["send_document"])) {
|
||||
$error_message = sendDocument();
|
||||
}
|
||||
|
||||
if (isset($_POST["request_validation"])) {
|
||||
if (!checkCanValidate())
|
||||
$error_message = "Votre équipe ne peut pas demander la validation : il manque soit des participants, soit des documents.";
|
||||
else {
|
||||
$DB->exec("UPDATE `teams` SET `validation_status` = 'WAITING' WHERE `id` = " . $_SESSION["team_id"] . ";");
|
||||
$_SESSION["team_validation_status"] = "WAITING";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_SESSION["team_id"])) {
|
||||
$result = $DB->query("SELECT * FROM `teams` WHERE `id` = '" . $_SESSION["team_id"] . "' AND `year` = '$YEAR';");
|
||||
$team_data = $result->fetch();
|
||||
|
||||
$tournament_data = $DB->query("SELECT `name`, `date_start` FROM `tournaments` WHERE `id` = '" . $team_data["tournament"] . "' AND `year` = '$YEAR';")->fetch();
|
||||
|
||||
$documents_req = $DB->prepare("SELECT `file_id`, `type`, COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `tournament` = ? GROUP BY `type`, `uploaded_at` ORDER BY `type`, `uploaded_at` DESC;");
|
||||
$documents_req->execute([$_SESSION["user_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]);
|
||||
}
|
||||
|
||||
if (isset($_POST["team_edit"])) {
|
||||
$error_message = updateTeam();
|
||||
}
|
||||
|
||||
function sendDocument()
|
||||
{
|
||||
global $LOCAL_PATH, $DB;
|
||||
|
||||
$type = strtoupper(htmlspecialchars($_POST["type"]));
|
||||
if (!isset($type) || ($type != "PARENTAL_CONSENT" && $type != "PHOTO_CONSENT" && $type != "SANITARY_PLUG"))
|
||||
return "Le type de document est invalide. Merci de ne pas formuler vos propres requêtes.";
|
||||
|
||||
$file = $_FILES["document"];
|
||||
|
||||
if ($file["size"] > 5000000 || $file["error"])
|
||||
return "Une erreur est survenue. Merci de vérifier que le fichier pèse moins que 5 Mo.";
|
||||
|
||||
if (finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file["tmp_name"]) != 'application/pdf')
|
||||
return "Le fichier doit être au format PDF.";
|
||||
|
||||
if (!is_dir("$LOCAL_PATH/files") && !mkdir("$LOCAL_PATH/files"))
|
||||
return "Les droits sont insuffisants. Veuillez contacter l'administrateur du serveur.";
|
||||
|
||||
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
do {
|
||||
$id = "";
|
||||
for ($i = 0; $i < 64; ++$i) {
|
||||
$id .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
||||
}
|
||||
} while (file_exists("$LOCAL_PATH/files/$id"));
|
||||
|
||||
if (!rename($file["tmp_name"], "$LOCAL_PATH/files/$id"))
|
||||
return "Une erreur est survenue lors de l'envoi du fichier.";
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `documents`(`file_id`, `user`, `team`, `tournament`, `type`)
|
||||
VALUES (?, ?, ?, ?, ?);");
|
||||
$req->execute([$id, $_SESSION["user_id"], $_SESSION["team_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"], $type]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function updateTeam()
|
||||
{
|
||||
global $DB, $YEAR, $URL_BASE, $team_data;
|
||||
|
||||
if ($_SESSION["team_id"] == NULL)
|
||||
return "Vous n'êtes pas dans une équipe.";
|
||||
|
||||
$name = htmlspecialchars($_POST["name"]);
|
||||
|
||||
if (!isset($name) || $name == "")
|
||||
return "Vous devez spécifier un nom d'équipe.";
|
||||
|
||||
echo $team_data["id"];
|
||||
$result = $DB->query("SELECT `id` FROM `teams` WHERE `name` = '" . $name . "' AND `id` != " . $team_data["id"] . " AND `year` = '$YEAR';");
|
||||
if ($result->fetch())
|
||||
return "Une équipe existe déjà avec ce nom." . $team_data["id"];
|
||||
|
||||
$trigram = strtoupper(htmlspecialchars($_POST["trigram"]));
|
||||
|
||||
if (!preg_match("#^[A-Z][A-Z][A-Z]$#", $trigram))
|
||||
return "Le trigramme entré n'est pas valide.";
|
||||
|
||||
$result = $DB->query("SELECT `id` FROM `teams` WHERE `trigram` = '" . $trigram . "' AND `id` != '" . $team_data["id"] . "' AND `year` = '$YEAR';");
|
||||
if ($result->fetch())
|
||||
return "Une équipe a déjà choisi ce trigramme.";
|
||||
|
||||
$tournament_id = intval(htmlspecialchars($_POST["tournament"]));
|
||||
|
||||
$result = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `id` = '" . $tournament_id . "' AND `year` = '$YEAR';");
|
||||
$data = $result->fetch();
|
||||
if ($data === FALSE)
|
||||
return "Le tournoi spécifié n'existe pas.";
|
||||
|
||||
$req = $DB->prepare("UPDATE `teams` SET `name` = ?, `trigram` = ?, `tournament` = ? WHERE `id` = ?;");
|
||||
$req->execute([$name, $trigram, $tournament_id, $team_data["id"]]);
|
||||
|
||||
header("Location: $URL_BASE/mon_equipe");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkCanValidate()
|
||||
{
|
||||
global $DB, $team_data, $tournament_data, $YEAR;
|
||||
$can_validate = $team_data["validation_status"] == "NOT_READY";
|
||||
$can_validate &= $team_data["encadrant_1"] != NULL;
|
||||
$can_validate &= $team_data["participant_4"] != NULL;
|
||||
for ($i = 1; $i <= 2; ++$i) {
|
||||
if ($team_data["encadrant_$i"] === NULL)
|
||||
continue;
|
||||
|
||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||
$req->execute([$team_data["encadrant_$i"], "PHOTO_CONSENT"]);
|
||||
$d = $req->fetch();
|
||||
$can_validate &= $d["version"] > 0;
|
||||
|
||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||
$req->execute([$team_data["encadrant_$i"], "SANITARY_PLUG"]);
|
||||
$d = $req->fetch();
|
||||
$can_validate &= $d["version"] > 0;
|
||||
}
|
||||
for ($i = 1; $i <= 6; ++$i) {
|
||||
if ($team_data["participant_$i"] === NULL)
|
||||
continue;
|
||||
|
||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||
$req->execute([$team_data["participant_$i"], "PHOTO_CONSENT"]);
|
||||
$d = $req->fetch();
|
||||
$can_validate &= $d["version"] > 0;
|
||||
|
||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||
$req->execute([$team_data["participant_$i"], "SANITARY_PLUG"]);
|
||||
$d = $req->fetch();
|
||||
$can_validate &= $d["version"] > 0;
|
||||
|
||||
$birth_date = $DB->query("SELECT `birth_date` FROM `users` WHERE `id` = " . $team_data["participant_$i"] . ";")->fetch()["birth_date"];
|
||||
if ($birth_date > strval($YEAR - 18) . substr($tournament_data["date_start"], 4)) {
|
||||
$req = $DB->prepare("SELECT COUNT(`type`) AS `version` FROM `documents` WHERE `user` = ? AND `type` = ? GROUP BY `uploaded_at` ORDER BY `uploaded_at` DESC;");
|
||||
$req->execute([$team_data["participant_$i"], "PARENTAL_CONSENT"]);
|
||||
$d = $req->fetch();
|
||||
$can_validate &= $d["version"] > 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $can_validate;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<?php if (!isset($_SESSION["user_id"]) || !isset($_SESSION["team_id"]) || $_SESSION["team_id"] == NULL) {
|
||||
echo "<h2>Vous devez être dans une équipe pour afficher cette page.</h2>";
|
||||
require_once "footer.php";
|
||||
return;
|
||||
} ?>
|
||||
|
||||
<?php if (isset($error_message)) {
|
||||
if ($error_message !== false) {
|
||||
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||
} else {
|
||||
echo "<h2>Le fichier a été correctement envoyé !</h2>";
|
||||
}
|
||||
} ?>
|
||||
|
||||
<h2>Informations sur l'équipe</h2>
|
||||
|
||||
Nom de l'équipe : <?= $team_data["name"] ?><br/>
|
||||
Trigramme : <?= $team_data["trigram"] ?><br/>
|
||||
Tournoi : <a href="<?= $tournament_data["name"] ?>"><?= $tournament_data["name"] ?></a><br/>
|
||||
<?php
|
||||
for ($i = 1; $i <= 2; ++$i) {
|
||||
if ($team_data["encadrant_" . $i] == NULL)
|
||||
continue;
|
||||
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = " . $team_data["encadrant_" . $i] . " AND `year` = '$YEAR';")->fetch();
|
||||
echo "Encadrant $i : " . $user_data["first_name"] . " " . $user_data["surname"] . "<br />";
|
||||
}
|
||||
for ($i = 1; $i <= 6; ++$i) {
|
||||
if ($team_data["participant_" . $i] == NULL)
|
||||
continue;
|
||||
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = " . $team_data["participant_" . $i] . " AND `year` = '$YEAR';")->fetch();
|
||||
echo "Participant $i : " . $user_data["first_name"] . " " . $user_data["surname"] . "<br />";
|
||||
}
|
||||
?>
|
||||
Code d'accès : <strong><?php echo $team_data["access_code"] ?></strong><br/>
|
||||
<?php if (isset($_SESSION["final_id"])) {
|
||||
$final_name = $_SESSION["final_name"];
|
||||
echo "<strong>Équipe sélectionnée pour la <a href=\"$URL_BASE/tournoi/$final_name\">finale nationale</a>.</strong><br />";
|
||||
} ?>
|
||||
|
||||
<?php if (isset($_GET["modifier"])) { ?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="team_edit" value="true"/>
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="name">Nom :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $team_data["name"] ?>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="trigram">Trigramme :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="text" id="trigram" name="trigram"
|
||||
value="<?= $team_data["trigram"] ?>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="tournament">Tournoi :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="tournament" name="tournament">
|
||||
<?php
|
||||
while (($data = $tournaments_response->fetch()) !== FALSE) {
|
||||
echo "<option value=\"" . $data["id"] . "\">" . $data["name"] . "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" value="Modifier l'équipe"/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<?php if ($_SESSION["team_validation_status"] == "NOT_READY") { ?>
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="<?= $URL_BASE ?>/mon_equipe/modifier">Modifier mon équipe</a>
|
||||
<?php } ?>
|
||||
<hr/>
|
||||
<h2>Mes autorisations</h2>
|
||||
<?php
|
||||
while (($data = $documents_req->fetch()) !== false) {
|
||||
$file_id = $data["file_id"];
|
||||
$type = $data["type"];
|
||||
$version = $data["version"];
|
||||
switch ($data["type"]) {
|
||||
case "PARENTAL_CONSENT":
|
||||
$name = "Autorisation parentale";
|
||||
break;
|
||||
case "PHOTO_CONSENT":
|
||||
$name = "Autorisation de droit à l'image";
|
||||
break;
|
||||
case "SANITARY_PLUG":
|
||||
$name = "Fiche sanitaire";
|
||||
break;
|
||||
}
|
||||
echo "$name : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
if ($team_data["validation_status"] == "NOT_READY") { ?>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="type">Type de document :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="type" name="type">
|
||||
<?php if ($_SESSION["birth_date"] > strval($YEAR - 18) . substr($tournament_data["date_start"], 4)) { ?>
|
||||
<option value="parental_consent">Autorisation parentale</option>
|
||||
<?php } ?>
|
||||
<option value="photo_consent">Autorisation de droit à l'image</option>
|
||||
<option value="sanitary_plug">Fiche sanitaire</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="file">Fichier :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="file" id="file" name="document"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" name="send_document" value="Envoyer le document"/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php } ?>
|
||||
<hr/>
|
||||
<?php if ($team_data["validation_status"] == "NOT_READY") { ?>
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td style="width: 50%;">
|
||||
<form method="post">
|
||||
<input style="width: 100%;" type="submit" name="leave_team" value="Quitter l'équipe"/>
|
||||
</form>
|
||||
</td>
|
||||
<?php
|
||||
$can_validate = checkCanValidate();
|
||||
if ($can_validate) { ?>
|
||||
<td style="width: 50%;">
|
||||
<form method="post">
|
||||
<input style="width: 100%;" type="submit" name="request_validation"
|
||||
value="Demander la validation"/>
|
||||
</form>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</table>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
|
@ -1,123 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
|
||||
if (!isset($_SESSION["team_id"]))
|
||||
require_once "403.php";
|
||||
|
||||
if (isset($_POST["send_synthese"])) {
|
||||
$error_message = saveSynthese();
|
||||
}
|
||||
|
||||
$syntheses_req = $DB->prepare("SELECT `file_id`, `dest`, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `team` = ? AND `tournament` = ? GROUP BY `dest`, `uploaded_at` ORDER BY `dest`, `uploaded_at` DESC;");
|
||||
$syntheses_req->execute([$_SESSION["team_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]);
|
||||
|
||||
$tournament_req = $DB->prepare("SELECT `date_solutions`, `date_syntheses` FROM `tournaments` WHERE `id` = ?;");
|
||||
$tournament_req->execute([$_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]);
|
||||
$tournament_data = $tournament_req->fetch();
|
||||
|
||||
function saveSynthese() {
|
||||
global $LOCAL_PATH, $DB;
|
||||
|
||||
$dest = strtoupper(htmlspecialchars($_POST["dest"]));
|
||||
|
||||
if (!isset($dest) || ($dest != "OPPOSANT" && $dest != "RAPPORTEUR"))
|
||||
return "Le destinataire est invalide.";
|
||||
|
||||
$file = $_FILES["synthese"];
|
||||
|
||||
if ($file["size"] > 5000000 || $file["error"])
|
||||
return "Une erreur est survenue. Merci de vérifier que le fichier pèse moins que 5 Mo.";
|
||||
|
||||
if (finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file["tmp_name"]) != 'application/pdf')
|
||||
return "Le fichier doit être au destmat PDF.";
|
||||
|
||||
if (!is_dir("$LOCAL_PATH/files") && !mkdir("$LOCAL_PATH/files"))
|
||||
return "Les droits sont insuffisants. Veuillez contacter l'administrateur du serveur.";
|
||||
|
||||
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
do {
|
||||
$id = "";
|
||||
for ($i = 0; $i < 64; ++$i) {
|
||||
$id .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
||||
}
|
||||
}
|
||||
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||
|
||||
if (!rename($file["tmp_name"], "$LOCAL_PATH/files/$id"))
|
||||
return "Une erreur est survenue lors de l'envoi du fichier.";
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
|
||||
$req->execute([$id, $_SESSION["team_id"], $_SESSION["tournament_id"], $dest]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once 'header.php' ?>
|
||||
|
||||
<?php
|
||||
if (date("yyyy-mm-dd") < $tournament_data["date_solutions"]) {
|
||||
echo "<h3>Il est trop tôt pour se préoccuper des notes de synthèse, attendez le tirage des poules.</h3>";
|
||||
require_once "footer.php";
|
||||
}
|
||||
|
||||
if (isset($error_message)) {
|
||||
if ($error_message !== false) {
|
||||
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||
}
|
||||
else {
|
||||
echo "<h2>Le fichier a été correctement envoyé !</h2>";
|
||||
}
|
||||
}?>
|
||||
|
||||
<?php if (date("yyyy-mm-dd") < $tournament_data["date_syntheses"]) { ?>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="5000000" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="dest">Destination de la note de synthèse :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="dest" name="dest">
|
||||
<option value="opposant">Opposant</option>
|
||||
<option value="rapporteur">Rapporteur</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="file">Fichier :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="file" id="file" name="synthese" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" name="send_synthese" value="Envoyer" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
<div style="padding: 20px"></div>
|
||||
|
||||
<h2>Notes de synthèse soumises :</h2>
|
||||
|
||||
<?php
|
||||
while (($data = $syntheses_req->fetch()) !== false) {
|
||||
$file_id = $data["file_id"];
|
||||
$dest = $data["dest"];
|
||||
$version = $data["version"];
|
||||
echo "Note de synthèse pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur") . " (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php require_once 'footer.php' ?>
|
|
@ -1,359 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
|
||||
$tournament_name = htmlspecialchars($_GET["nom"]);
|
||||
|
||||
$response = $DB->prepare("SELECT * FROM `tournaments` WHERE `name` = ? AND `year` = $YEAR;");
|
||||
$response->execute([$tournament_name]);
|
||||
$data = $response->fetch();
|
||||
|
||||
if ($data === false)
|
||||
require_once "404.php";
|
||||
|
||||
$orgas_req = $DB->query("SELECT `users`.`id` AS `id`, `surname`, `first_name` FROM `users` JOIN `organizers` ON `users`.`id` = `organizer` WHERE `tournament` = " . $data["id"] . ";");
|
||||
$orgas = [];
|
||||
$orgas_id = [];
|
||||
while (($orga_data = $orgas_req->fetch()) !== false) {
|
||||
$orgas[] = $orga_data["first_name"] . " " . $orga_data["surname"];
|
||||
$orgas_id[] = $orga_data["id"];
|
||||
}
|
||||
|
||||
if (isset($_GET["modifier"]) && $_SESSION["role"] != "ADMIN" && !in_array($_SESSION["user_id"], $orgas_id))
|
||||
require_once "403.php";
|
||||
|
||||
if (isset($_POST["edit_tournament"])) {
|
||||
$error_message = updateTournament();
|
||||
}
|
||||
|
||||
if ($data["final"])
|
||||
$teams_response = $DB->query("SELECT `id`, `name`, `trigram`, `inscription_date`, `validation_status` FROM `teams` WHERE `final_selection` AND `year` = $YEAR;");
|
||||
else
|
||||
$teams_response = $DB->query("SELECT `id`, `name`, `trigram`, `inscription_date`, `validation_status` FROM `teams` WHERE `tournament` = " . $data["id"] . " AND `year` = $YEAR;");
|
||||
|
||||
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
|
||||
|
||||
function updateTournament() {
|
||||
global $DB, $URL_BASE, $YEAR, $data;
|
||||
|
||||
$tournament_id = $data["id"];
|
||||
|
||||
$name = htmlspecialchars($_POST["name"]);
|
||||
|
||||
$result = $DB->query("SELECT `id` FROM `tournaments` WHERE `name` = '" . $name . "' AND `id` != $tournament_id AND `year` = '$YEAR';");
|
||||
if ($result->fetch())
|
||||
return "Un tournoi existe déjà avec ce nom.";
|
||||
|
||||
if (!isset($_POST["organizer"]) || sizeof($_POST["organizer"]) == 0)
|
||||
return "Aucun organisateur n'a été choisi.";
|
||||
|
||||
if ($_SESSION["role"] == "ADMIN") {
|
||||
$organizers = $_POST["organizer"];
|
||||
$orga_mails = [];
|
||||
|
||||
foreach ($organizers as $orga) {
|
||||
$result = $DB->query("SELECT `role`, `email` FROM `users` WHERE `id` = '" . $orga . "' AND `year` = '$YEAR';");
|
||||
$data = $result->fetch();
|
||||
if ($data === FALSE)
|
||||
return "L'organisateur spécifié n'existe pas.";
|
||||
if ($data["role"] != "ORGANIZER" && $data["role"] != "ADMIN")
|
||||
return "L'organisateur indiqué ne peut pas organiser de tournoi.";
|
||||
$orga_mails[] = $data["email"];
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$size = intval(htmlspecialchars($_POST["size"]));
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
return "Le nombre d'équipes indiqué n'est pas un entier valide.";
|
||||
}
|
||||
|
||||
if ($size < 3 || $size > 12)
|
||||
return "Un tournoi doit comporter entre 3 et 12 équipes.";
|
||||
|
||||
$place = htmlspecialchars($_POST["place"]);
|
||||
|
||||
try {
|
||||
$price = intval(htmlspecialchars($_POST["price"]));
|
||||
}
|
||||
catch (Throwable $t) {
|
||||
return "Le tarif pour les participants n'est pas un nombre valide.";
|
||||
}
|
||||
|
||||
if ($price < 0)
|
||||
return "Le TFJM² ne va pas payer les élèves pour venir.";
|
||||
|
||||
if ($price > 50)
|
||||
return "Soyons raisonnable sur le prix.";
|
||||
|
||||
$date_start = htmlspecialchars($_POST["date_start"]);
|
||||
$date_start_parsed = date_parse_from_format("yyyy-mm-dd", $date_start);
|
||||
|
||||
$date_end = htmlspecialchars($_POST["date_end"]);
|
||||
$date_end_parsed = date_parse_from_format("yyyy-mm-dd", $date_end);
|
||||
|
||||
$date_inscription = htmlspecialchars($_POST["date_inscription"]);
|
||||
$time_inscription = htmlspecialchars($_POST["time_inscription"]);
|
||||
$date_inscription_parsed = date_parse_from_format("yyyy-mm-dd", $date_inscription . ' ' . $time_inscription);
|
||||
|
||||
$date_solutions = htmlspecialchars($_POST["date_solutions"]);
|
||||
$time_solutions = htmlspecialchars($_POST["time_solutions"]);
|
||||
$date_solutions_parsed = date_parse_from_format("yyyy-mm-dd", $date_solutions . ' ' . $time_solutions);
|
||||
|
||||
$date_syntheses = htmlspecialchars($_POST["date_syntheses"]);
|
||||
$time_syntheses = htmlspecialchars($_POST["time_syntheses"]);
|
||||
$date_syntheses_parsed = date_parse_from_format("yyyy-mm-dd", $date_syntheses . ' ' . $time_syntheses);
|
||||
|
||||
if (!$date_start_parsed || !$date_end_parsed || !$date_inscription_parsed || !$date_solutions_parsed || !$date_syntheses_parsed)
|
||||
return "Une date est mal formée.";
|
||||
|
||||
$description = htmlspecialchars($_POST["description"]);
|
||||
|
||||
$req = $DB->prepare("UPDATE `tournaments` SET `name` = ?, `size` = ?, `place` = ?, `price` = ?, `description` = ?,
|
||||
`date_start` = ?, `date_end` = ?, `date_inscription` = ?, `date_solutions` = ?, `date_syntheses` = ?
|
||||
WHERE `id` = $tournament_id;");
|
||||
$req->execute([$name, $size, $place, $price, $description, $date_start, $date_end,
|
||||
"$date_inscription $time_inscription", "$date_solutions $time_solutions", "$date_syntheses $time_syntheses"]);
|
||||
|
||||
if ($_SESSION["role"] == "ADMIN") {
|
||||
$DB->exec("DELETE FROM `organizers` WHERE `tournament` = $tournament_id;");
|
||||
foreach ($organizers as $orga) {
|
||||
$req = $DB->prepare("INSERT INTO `organizers`(`organizer`, `tournament`) VALUES(?, ?);");
|
||||
$req->execute([$orga, $tournament_id]);
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: $URL_BASE/tournoi/" . $name);
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<h2>Tournoi de <?php echo $data["name"] ?></h2>
|
||||
|
||||
<strong>Organisateur<?= sizeof($orgas) >= 2 ? 's' : '' ?> :</strong>
|
||||
<?php
|
||||
$s = "";
|
||||
for ($i = 0; $i < sizeof($orgas); ++$i) {
|
||||
if ($_SESSION["role"] == "ORGANIZER" || $_SESSION["role"] == "ADMIN")
|
||||
$s .= "<a href=\"$URL_BASE/informations/$orgas_id[$i]/$orgas[$i]\">$orgas[$i]</a>";
|
||||
else
|
||||
$s .= $orgas[$i];
|
||||
$s .= ", ";
|
||||
}
|
||||
echo substr($s, 0, -2);
|
||||
?>
|
||||
<br />
|
||||
<strong>Nombre d'équipes maximal :</strong> <?php echo $data["size"] ?><br />
|
||||
<strong>Lieu :</strong> <?php echo $data["place"] ?><br />
|
||||
<strong>Prix par partipant :</strong> <?php echo $data["price"] == 0 ? "Gratuit" : $data["price"] . " €" ?><br />
|
||||
<strong>Dates :</strong> Du <?php echo echo_date($data["date_start"]) ?> au <?php echo echo_date($data["date_end"]) ?><br />
|
||||
<strong>Clôture des inscriptions :</strong> <?php echo echo_date($data["date_inscription"], true) ?><br />
|
||||
<strong>Date limite d'envoi des solutions :</strong> <?php echo echo_date($data["date_solutions"], true) ?><br />
|
||||
<strong>Date limite d'envoi des notes de synthèse :</strong> <?php echo echo_date($data["date_syntheses"], true) ?><br />
|
||||
<strong>Description :</strong> <?php echo $data["description"] ?><br />
|
||||
<?php
|
||||
if ($data["final"])
|
||||
echo "<strong>Ce tournoi est la finale nationale du TFJM² 2020.</strong><br />";
|
||||
?>
|
||||
|
||||
<?php if (!isset($_GET["modifier"]) && ($_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER" && in_array($_SESSION["user_id"], $orgas_id))) { ?>
|
||||
<a href="<?= $URL_BASE ?>/tournoi/<?= $data["name"] ?>/modifier">Éditer le tournoi</a>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if (!isset($_GET["modifier"])) { ?>
|
||||
<hr/>
|
||||
|
||||
<h2>Équipes inscrites à ce tournoi :</h2>
|
||||
|
||||
<table style="border: 1px solid black; width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
Équipe
|
||||
</th>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
Trigramme
|
||||
</th>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
Date d'inscription
|
||||
</th>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
État de validation de l'inscription
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while (($team_data = $teams_response->fetch()) != false) {
|
||||
?>
|
||||
<tr>
|
||||
<td style="border: 1px solid black; text-align: center">
|
||||
<?php
|
||||
if (isset($_SESSION["role"]) && ($_SESSION["role"] == "ADMIN" || ($_SESSION["role"] == "ORGANIZER" && in_array($_SESSION["user_id"], $orgas_id))))
|
||||
echo "<a href=\"$URL_BASE/equipe/" . $team_data["trigram"] . "\">" . $team_data["name"] . "</a>";
|
||||
else
|
||||
echo $team_data["name"];
|
||||
?>
|
||||
</td>
|
||||
<td style="border: 1px solid black; text-align: center"><?php echo $team_data["trigram"] ?></td>
|
||||
<td style="border: 1px solid black; text-align: center"><?php echo echo_date($team_data["inscription_date"]) ?></td>
|
||||
<td style="border: 1px solid black; text-align: center">
|
||||
<?php
|
||||
switch ($team_data["validation_status"]) {
|
||||
case "NOT_READY":
|
||||
echo "Inscription non terminée";
|
||||
break;
|
||||
case "WAITING":
|
||||
echo "En attente de validation";
|
||||
break;
|
||||
case "VALIDATED":
|
||||
echo "Inscription validée";
|
||||
break;
|
||||
default:
|
||||
echo "Statut inconnu";
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
Équipe
|
||||
</th>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
Trigramme
|
||||
</th>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
Date d'inscription
|
||||
</th>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
État de validation de l'inscription
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="name">Nom :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $data["name"] ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($_SESSION["role"] == "ADMIN") { ?>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="organizer">Organisateur :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="organizer" name="organizer[]" multiple size="4" required>
|
||||
<?php
|
||||
while (($orga_data = $orgas_response->fetch()) !== FALSE) {
|
||||
echo "<option value=\"" . $orga_data["id"] . "\" " . (in_array($orga_data["first_name"] . " " . $orga_data["surname"], $orgas) ? "selected" : "")
|
||||
. ">" . $orga_data["first_name"] . " " . $orga_data["surname"] . "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="size">Nombre d'équipes :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="number" id="size" name="size" min="3" max="12" value="<?= $data["size"] ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="place">Lieu :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="text" id="place" name="place" value="<?= $data["place"] ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="price">Prix par participant</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="number" id="price" name="price" min="0" max="21" value="<?= $data["price"] ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_start">Dates :</label>
|
||||
</td>
|
||||
<td>
|
||||
Du <input style="width: 45%;" type="date" id="date_start" name="date_start" value="<?= $data["date_start"] ?>" required />
|
||||
au <input style="width: 45%;" type="date" id="date_end" name="date_end" value="<?= $data["date_end"] ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_inscription">Date limite d'inscription :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 49%;" type="date" id="date_inscription" name="date_inscription" value="<?= substr($data["date_inscription"], 0, 10) ?>" required />
|
||||
<input style="width: 49%;" type="time" id="time_inscription" name="time_inscription" value="<?= substr($data["date_inscription"], 11) ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_solutions">Date limite pour rendre les solutions :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 49%;" type="date" id="date_solutions" name="date_solutions" value="<?= substr($data["date_solutions"], 0, 10) ?>" required />
|
||||
<input style="width: 49%;" type="time" id="time_solutions" name="time_solutions" value="<?= substr($data["date_solutions"],11) ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_syntheses">Date limite pour rendre les notes de synthèse :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="date" id="date_syntheses" name="date_syntheses" value="<?= substr($data["date_syntheses"], 0, 10) ?>" required />
|
||||
<input style="width: 100%;" type="time" id="time_syntheses" name="time_syntheses" value="<?= substr($data["date_syntheses"], 11) ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="description">Description :</label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea style="width: 100%;" name="description" id="description" required><?= $data["description"] ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" name="edit_tournament" value="Modifier le tournoi" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
|
||||
$response = $DB->query("SELECT `name`, `date_start`, `date_end`, `date_inscription`, `date_solutions`, `size` FROM `tournaments`
|
||||
WHERE `year` = '$YEAR' AND `final` = false ORDER BY `date_start`, `name`;");
|
||||
$final_data = $DB->query("SELECT `name`, `date_start`, `date_end`, `date_solutions`, `size` FROM `tournaments` WHERE `final` AND `year` = $YEAR;")->fetch();
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<h2>Liste des tournois</h2>
|
||||
|
||||
<table style="border: 1px solid black; width: 100%">
|
||||
<thead style="border: 1px solid black">
|
||||
<tr>
|
||||
<th style="border: 1px solid black; text-align: center">Lieu</th>
|
||||
<th style="border: 1px solid black; text-align: center">Dates</th>
|
||||
<th style="border: 1px solid black; text-align: center">Inscription avant le</th>
|
||||
<th style="border: 1px solid black; text-align: center">Date de rendu des solutions</th>
|
||||
<th style="border: 1px solid black; text-align: center">Places disponibles</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody style="border: 1px solid black">
|
||||
<?php
|
||||
while (($data = $response->fetch()) !== FALSE) {
|
||||
?>
|
||||
<tr style="border: 1px solid black">
|
||||
<td style="border: 1px solid black; text-align: center"><a href="<?= $URL_BASE ?>/tournoi/<?= $data["name"] ?>"><?= $data["name"] ?></a></td>
|
||||
<td style="border: 1px solid black; text-align: center">Du <?php echo echo_date($data["date_start"]) ?> au <?php echo echo_date($data["date_end"]) ?></td>
|
||||
<td style="border: 1px solid black; text-align: center"><?php echo echo_date($data["date_inscription"]) ?></td>
|
||||
<td style="border: 1px solid black; text-align: center"><?php echo echo_date($data["date_solutions"]) ?></td>
|
||||
<td style="border: 1px solid black; text-align: center"><?php echo $data["size"] ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr style="border: 1px solid black">
|
||||
<td style="border: 1px solid black; text-align: center"><a href="<?= $URL_BASE ?>/tournoi/<?= $final_data["name"] ?>"><?= $final_data["name"] ?></a></td>
|
||||
<td colspan="2" style="border: 1px solid black; text-align: center">Du <?php echo echo_date($final_data["date_start"]) ?> au <?php echo echo_date($final_data["date_end"]) ?></td>
|
||||
<!-- <td style="border: 1px solid black; text-align: center"><?php echo echo_date($final_data["date_inscription"]) ?></td> -->
|
||||
<td style="border: 1px solid black; text-align: center"><?php echo echo_date($final_data["date_solutions"]) ?></td>
|
||||
<td style="border: 1px solid black; text-align: center"><?php echo $final_data["size"] ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot style="border: 1px solid black">
|
||||
<tr>
|
||||
<th style="border: 1px solid black; text-align: center">Lieu</th>
|
||||
<th style="border: 1px solid black; text-align: center">Dates</th>
|
||||
<th style="border: 1px solid black; text-align: center">Inscription avant le</th>
|
||||
<th style="border: 1px solid black; text-align: center">Date de rendu des solutions</th>
|
||||
<th style="border: 1px solid black; text-align: center">Places disponibles</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
|
@ -0,0 +1,54 @@
|
|||
<?php if (!isset($_SESSION["role"]) or ($_SESSION["role"] != "PARTICIPANT" && $_SESSION["role"] != "ENCADRANT")) {
|
||||
?>
|
||||
<h2>Vous devez être participant ou encadrant pour pouvoir ajouter une équipe.</h2>
|
||||
<?php } else if ($_SESSION["team_id"] != NULL) { ?>
|
||||
<h2>Vous êtes déjà dans une équipe.</h2>
|
||||
<?php } else if (isset($access_code)) { ?>
|
||||
Votre équipe a bien été créée ! Voici le code d'accès à transmettre aux autres membres de votre équipe : <strong><?php echo $access_code ?></strong>
|
||||
<?php } else { ?>
|
||||
|
||||
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="name">Nom :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="text" id="name" name="name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="trigram">Trigramme :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="text" id="trigram" name="trigram" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="tournament">Tournoi :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="tournament" name="tournament">
|
||||
<?php
|
||||
while (($data = $tournaments_response->fetch()) !== FALSE) {
|
||||
echo "<option value=\"" . $data["id"] . "\">" . $data["name"] . "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" value="Ajouter une équipe" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php } ?>
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
if (isset($error_message)) {
|
||||
if ($error_message !== false) {
|
||||
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||
} else {
|
||||
echo "<h2>Organisateur ajouté avec succès ! Ses identifiants ont été transmis par mail.</h2>";
|
||||
}
|
||||
} ?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true"/>
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="surname">Nom :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="text" id="surname" name="surname"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="first_name">Prénom :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="text" id="first_name" name="first_name"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="email">Email :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="email" id="email" name="email"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="admin">Compte administrateur :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="checkbox" id="admin" name="admin"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" value="Ajouter un organisateur"/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
|
@ -0,0 +1,121 @@
|
|||
<?php if (isset($error_message)) {
|
||||
if ($error_message !== false) {
|
||||
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||
} else {
|
||||
echo "<h2>Tournoi de " . htmlspecialchars($_POST["name"]) . " ajouté avec succès !</h2>";
|
||||
}
|
||||
}?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="name">Nom :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="text" id="name" name="name" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="organizer">Organisateur :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="organizer" name="organizer[]" multiple size="4" required>
|
||||
<?php
|
||||
while (($data = $orgas_response->fetch()) !== FALSE) {
|
||||
echo "<option value=\"" . $data["id"] . "\">" . $data["first_name"] . " " . $data["surname"] . "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="size">Nombre d'équipes :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="number" id="size" name="size" min="3" max="12" value="6" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="place">Lieu :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="text" id="place" name="place" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="price">Prix par participant</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="number" id="price" name="price" min="0" max="21" value="21" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_start">Dates :</label>
|
||||
</td>
|
||||
<td>
|
||||
Du <input style="width: 45%;" type="date" id="date_start" name="date_start" required /> au <!--suppress HtmlFormInputWithoutLabel -->
|
||||
<input style="width: 45%;" type="date" id="date_end" name="date_end" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_inscription">Date limite d'inscription :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 49%;" type="date" id="date_inscription" name="date_inscription" required />
|
||||
<!--suppress HtmlFormInputWithoutLabel -->
|
||||
<input style="width: 49%;" type="time" id="time_inscription" name="time_inscription" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_solutions">Date limite pour rendre les solutions :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 49%;" type="date" id="date_solutions" name="date_solutions" required />
|
||||
<!--suppress HtmlFormInputWithoutLabel -->
|
||||
<input style="width: 49%;" type="time" id="time_solutions" name="time_solutions" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_syntheses">Date limite pour rendre les notes de synthèse :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 49%;" type="date" id="date_syntheses" name="date_syntheses" required />
|
||||
<!--suppress HtmlFormInputWithoutLabel -->
|
||||
<input style="width: 49%;" type="time" id="time_syntheses" name="time_syntheses" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="description">Description :</label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea style="width: 100%;" name="description" id="description" required></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="final">Ce tournoi est la finale nationale :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="checkbox" id="final" name="final" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" value="Ajouter un tournoi" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
|
@ -0,0 +1,92 @@
|
|||
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||
|
||||
<?php
|
||||
if (isset($error_message) && $error_message === FALSE) {
|
||||
if (isset($_GET["mdp_oublie"]))
|
||||
echo "Le mail de récupération de mot de passe a bien été envoyé.";
|
||||
else if (isset($_POST["reset_password"]))
|
||||
echo "Le mot de passe a bien été changé. Vous pouvez désormais vous connecter.";
|
||||
else if (isset($_GET["confirmation-mail"]))
|
||||
echo "Le mail a bien été renvoyé.";
|
||||
else
|
||||
echo "Connexion réussie !";
|
||||
}
|
||||
else if (isset($_SESSION["user_id"])) { ?>
|
||||
<h2>Vous êtes déjà connecté !</h2>
|
||||
<?php } else { ?>
|
||||
|
||||
<?php if (isset($_GET["mdp_oublie"])) { ?>
|
||||
<form method="POST">
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="email">E-mail associée au compte :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="email" id="email" name="email" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" name="forgotten_password" value="Envoyer l'e-mail de récupération" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php } elseif (isset($_GET["reset_password"])) { ?>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="token" value="<?= $_GET["token"] ?>" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="password">Nouveau mot de passe :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="password" id="password" name="password" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="confirm_password">Confirmer le mot de passe :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="password" id="confirm_password" name="confirm_password" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" name="reset_password" value="Changer le mot de passe" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php } elseif (isset($_GET["confirmation-mail"])) { ?>
|
||||
<?php } else { ?>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td style="width: 30%;"><label for="email">E-mail :</label></td>
|
||||
<td style="width: 70%;"><input style="width: 100%;" type="email" id="email" name="email" value="<?php if (isset($email)) echo $email ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="password">Mot de passe :</label></td>
|
||||
<td><input style="width: 100%;" type="password" id="password" name="password" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="<?= $URL_BASE ?>/connexion/mdp_oublie">Mot de passe oublié ?</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%;" type="submit" value="Se connecter" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
|
@ -0,0 +1,93 @@
|
|||
<h2>Informations sur l'équipe</h2>
|
||||
|
||||
Nom de l'équipe : <?= $team_data["name"] ?><br />
|
||||
Trigramme : <?= $team_data["trigram"] ?><br />
|
||||
Tournoi : <a href="<?= $URL_BASE . "/tournoi/" . $tournament_data["name"] ?>"><?= $tournament_data["name"] ?></a><br />
|
||||
<?php
|
||||
for ($i = 1; $i <= 2; ++$i) {
|
||||
if ($team_data["encadrant_" . $i] == NULL)
|
||||
continue;
|
||||
$user_data = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE `id` = " . $team_data["encadrant_" . $i] . " AND `year` = '$YEAR';")->fetch();
|
||||
$id = $user_data["id"];
|
||||
echo "Encadrant $i : <a href=\"$URL_BASE/informations/$id/" . $user_data["first_name"] . " " . $user_data["surname"] . "\">" . $user_data["first_name"] . " " . $user_data["surname"] . "</a><br />";
|
||||
}
|
||||
for ($i = 1; $i <= 6; ++$i) {
|
||||
if ($team_data["participant_" . $i] == NULL)
|
||||
continue;
|
||||
$user_data = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE `id` = " . $team_data["participant_" . $i] . " AND `year` = '$YEAR';")->fetch();
|
||||
$id = $user_data["id"];
|
||||
echo "Participant $i : <a href=\"$URL_BASE/informations/$id/" . $user_data["first_name"] . " " . $user_data["surname"] . "\">" . $user_data["first_name"] . " " . $user_data["surname"] . "</a><br />";
|
||||
}
|
||||
if ($team_data["final_selection"]) {
|
||||
$final_name = $_SESSION["final_name"];
|
||||
echo "<strong>Équipe sélectionnée pour la <a href=\"$URL_BASE/tournoi/$final_name\">finale nationale</a>.</strong>";
|
||||
}
|
||||
?>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2>Autorisations</h2>
|
||||
|
||||
<?php
|
||||
while (($data = $documents_req->fetch()) !== false) {
|
||||
$file_id = $data["file_id"];
|
||||
$type = $data["type"];
|
||||
$user_id = $data["user"];
|
||||
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = '$user_id';")->fetch();
|
||||
$surname = $user_data["surname"];
|
||||
$first_name = $user_data["first_name"];
|
||||
$version = $data["version"];
|
||||
switch ($data["type"]) {
|
||||
case "PARENTAL_CONSENT":
|
||||
$name = "Autorisation parentale";
|
||||
break;
|
||||
case "PHOTO_CONSENT":
|
||||
$name = "Autorisation de droit à l'image";
|
||||
break;
|
||||
case "SANITARY_PLUG":
|
||||
$name = "Fiche sanitaire";
|
||||
break;
|
||||
}
|
||||
echo "$name de $first_name $surname : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ($team_data["final_selection"]) { ?>
|
||||
<hr />
|
||||
<h2>Autorisations pour la finale</h2>
|
||||
<?php
|
||||
while (($data = $documents_req->fetch()) !== false) {
|
||||
$file_id = $data["file_id"];
|
||||
$type = $data["type"];
|
||||
$user_id = $data["user"];
|
||||
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = '$user_id';")->fetch();
|
||||
$surname = $user_data["surname"];
|
||||
$first_name = $user_data["first_name"];
|
||||
$version = $data["version"];
|
||||
switch ($data["type"]) {
|
||||
case "PARENTAL_CONSENT":
|
||||
$name = "Autorisation parentale";
|
||||
break;
|
||||
case "PHOTO_CONSENT":
|
||||
$name = "Autorisation de droit à l'image";
|
||||
break;
|
||||
case "SANITARY_PLUG":
|
||||
$name = "Fiche sanitaire";
|
||||
break;
|
||||
}
|
||||
echo "$name de $first_name $surname : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
}
|
||||
|
||||
if ($team_data["validation_status"] == "WAITING" && $_SESSION["role"] == "ADMIN") { ?>
|
||||
<form method="POST">
|
||||
<input style="width: 100%;" type="submit" name="validate" value="Valider l'équipe" />
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (!$team_data["final_selection"]) { ?>
|
||||
<form method="POST">
|
||||
<input style="width: 100%;" type="submit" name="select" value="Sélectionner pour la finale nationale" />
|
||||
</form>
|
||||
<?php } ?>
|
|
@ -1,6 +1,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php exit() ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php exit() ?>
|
|
@ -1,144 +1,75 @@
|
|||
<?php
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_GET["be-admin"])) {
|
||||
$DB->exec("UPDATE `users` SET `role` = 'ADMIN' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||||
quitTeam();
|
||||
header("Location: $URL_BASE");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_GET["be-organizer"])) {
|
||||
$DB->exec("UPDATE `users` SET `role` = 'ORGANIZER' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||||
quitTeam();
|
||||
header("Location: $URL_BASE");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_GET["be-participant"])) {
|
||||
$DB->exec("UPDATE `users` SET `role` = 'PARTICIPANT' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||||
quitTeam();
|
||||
header("Location: $URL_BASE");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_SESSION["user_id"]) && isset($_GET["be-encadrant"])) {
|
||||
$DB->exec("UPDATE `users` SET `role` = 'ENCADRANT' WHERE `id` = '" . $_SESSION["user_id"] . "';");
|
||||
quitTeam();
|
||||
header("Location: $URL_BASE");
|
||||
exit();
|
||||
}
|
||||
|
||||
function quitTeam() {
|
||||
global $DB, $URL_BASE;
|
||||
|
||||
if ($_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER")
|
||||
return;
|
||||
|
||||
for ($i = 1; $i <= ($_SESSION["role"] == "PARTICIPANT" ? 6 : 2); ++$i)
|
||||
/** @noinspection SqlResolve */
|
||||
$DB->exec("UPDATE `teams` SET `" . strtolower($_SESSION["role"]) . "_$i` = NULL WHERE `" . strtolower($_SESSION["role"]) . "_$i` = " . $_SESSION["user_id"] . ";");
|
||||
$DB->exec("UPDATE `users` SET `team_id` = NULL WHERE `id` = " . $_SESSION["user_id"] . ";");
|
||||
$DB->exec("UPDATE `teams` SET `encadrant_1` = `encadrant_2`, `encadrant_2` = NULL WHERE `encadrant_1` IS NULL;");
|
||||
for ($i = 1; $i <= 5; ++$i) {
|
||||
/** @noinspection SqlResolve */
|
||||
$DB->exec("UPDATE `teams` SET `participant_$i` = `participant_" . strval($i + 1) . "`, `participant_" . strval($i + 1) . "` = NULL WHERE `participant_$i` IS NULL;");
|
||||
}
|
||||
|
||||
$req = $DB->query("SELECT `file_id` FROM `documents` WHERE `user` = '" . $_SESSION["user_id"] . "';");
|
||||
while (($data = $req->fetch()) !== false)
|
||||
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||
$DB->exec("DELETE FROM `documents` WHERE `user` = '" . $_SESSION["user_id"] . "';");
|
||||
|
||||
if ($DB->exec("DELETE FROM `teams` WHERE `encadrant_1` IS NULL AND `participant_1` IS NULL;") > 0) {
|
||||
$req = $DB->query("SELECT `file_id` FROM `solutions` WHERE `team` = '" . $_SESSION["team_id"] . "';");
|
||||
while (($data = $req->fetch()) !== false)
|
||||
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||
$DB->exec("DELETE FROM `solutions` WHERE `team` = " . $_SESSION["team_id"] . ";");
|
||||
|
||||
$req = $DB->query("SELECT `file_id` FROM `syntheses` WHERE `team` = '" . $_SESSION["team_id"] . "';");
|
||||
while (($data = $req->fetch()) !== false)
|
||||
unlink("$URL_BASE/files/" . $data["file_id"]);
|
||||
$DB->exec("DELETE FROM `syntheses` WHERE `team` = " . $_SESSION["team_id"] . ";");
|
||||
}
|
||||
unset($_SESSION["team_id"]);
|
||||
unset($_SESSION["team_validation_status"]);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content= "width=device-width, initial-scale=1.0" />
|
||||
<title>Site d'inscription pour le TFJM² <?= $YEAR ?></title>
|
||||
<link rel="stylesheet" type="text/css" href="<?= $URL_BASE ?>/style.css" />
|
||||
<link REL="shortcut icon" href="<?= $URL_BASE ?>/favicon.ico" />
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/vendor/bootstrap/css/bootstrap.min.css">
|
||||
|
||||
<!-- Custom fonts for this template -->
|
||||
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/vendor/font-awesome/css/font-awesome.min.css">
|
||||
|
||||
<!-- Plugin CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/vendor/datatables/dataTables.bootstrap4.css">
|
||||
|
||||
<!-- Custom styles for this template -->
|
||||
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/css2/sb-admin.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ul id="menu">
|
||||
<li id="menu-logo"><img src="<?= $URL_BASE ?>/logo.svg" alt="logo tfjm"></li>
|
||||
<li><a href="<?= $URL_BASE ?>/">Accueil</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/tournois">Liste des tournois</a></li>
|
||||
<?php if (!isset($_SESSION["user_id"])) { ?>
|
||||
<li><a href="<?= $URL_BASE ?>/connexion">Connexion</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/inscription">Inscription</a></li>
|
||||
<?php } else { ?>
|
||||
<li><a href="<?= $URL_BASE ?>/mon_compte">Mon compte</a></li>
|
||||
<?php if ($_SESSION["role"] == "ENCADRANT" || $_SESSION["role"] == "PARTICIPANT") { ?>
|
||||
<?php if ($_SESSION["team_id"] == NULL) { ?>
|
||||
<li><a href="<?= $URL_BASE ?>/ajouter_equipe">Ajouter une équipe</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/rejoindre_equipe">Rejoindre une équipe</a></li>
|
||||
<?php } else { ?>
|
||||
<li><a href="<?= $URL_BASE ?>/mon_equipe">Mon équipe</a></li>
|
||||
<?php if ($_SESSION["team_validation_status"] == "VALIDATED" || true) { ?>
|
||||
<li><a href="https://paypal.me/galaxyoyo42">Paiement</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/solutions">Solutions</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/syntheses">Notes de synthèse</a></li>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php if ($_SESSION["role"] == "ADMIN") { ?>
|
||||
<li><a href="<?= $URL_BASE ?>/ajouter_tournoi">Ajouter un tournoi</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/ajouter_organisateur">Ajouter un organisateur</a></li>
|
||||
<?php } ?>
|
||||
<?php if ($_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER") { ?>
|
||||
<li><a href="<?= $URL_BASE ?>/solutions_orga">Solutions</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/syntheses_orga">Notes de synthèse</a></li>
|
||||
<?php } ?>
|
||||
<li><a href="<?= $URL_BASE ?>/deconnexion">Déconnexion</a></li>
|
||||
<hr />
|
||||
<?php
|
||||
if ($_SESSION["role"] != "ADMIN") {
|
||||
echo "<li><a href=\"?be-admin=1\">Devenir administrateur</a></li>";
|
||||
}
|
||||
if ($_SESSION["role"] != "ORGANIZER") {
|
||||
echo "<li><a href=\"?be-organizer=1\">Devenir organisateur</a></li>";
|
||||
}
|
||||
if ($_SESSION["role"] != "PARTICIPANT") {
|
||||
echo "<li><a href=\"?be-participant=1\">Devenir participant</a></li>";
|
||||
}
|
||||
if ($_SESSION["role"] != "ENCADRANT") {
|
||||
echo "<li><a href=\"?be-encadrant=1\">Devenir encadrant</a></li>";
|
||||
}
|
||||
?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
|
||||
<div id="main-container">
|
||||
<div id="main-content">
|
||||
<!-- <h1 style="text-align: center">Site d'inscription pour le TFJM² <?= $YEAR ?></h1> -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content= "width=device-width, initial-scale=1.0" />
|
||||
<title>Site d'inscription pour le TFJM² <?= $YEAR ?></title>
|
||||
<link rel="stylesheet" type="text/css" href="<?= $URL_BASE ?>/style.css" />
|
||||
<link REL="shortcut icon" href="<?= $URL_BASE ?>/favicon.ico" />
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/vendor/bootstrap/css/bootstrap.min.css">
|
||||
|
||||
<!-- Custom fonts for this template -->
|
||||
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/vendor/font-awesome/css/font-awesome.min.css">
|
||||
|
||||
<!-- Plugin CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/vendor/datatables/dataTables.bootstrap4.css">
|
||||
|
||||
<!-- Custom styles for this template -->
|
||||
<link rel="stylesheet" type="text/css" href="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/css2/sb-admin.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ul id="menu">
|
||||
<li id="menu-logo"><img src="<?= $URL_BASE ?>/logo.svg" alt="logo tfjm"></li>
|
||||
<li><a href="<?= $URL_BASE ?>/">Accueil</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/tournois">Liste des tournois</a></li>
|
||||
<?php if (!isset($_SESSION["user_id"])) { ?>
|
||||
<li><a href="<?= $URL_BASE ?>/connexion">Connexion</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/inscription">Inscription</a></li>
|
||||
<?php } else { ?>
|
||||
<li><a href="<?= $URL_BASE ?>/mon_compte">Mon compte</a></li>
|
||||
<?php if ($_SESSION["role"] == "ENCADRANT" || $_SESSION["role"] == "PARTICIPANT") { ?>
|
||||
<?php if ($_SESSION["team_id"] == NULL) { ?>
|
||||
<li><a href="<?= $URL_BASE ?>/ajouter_equipe">Ajouter une équipe</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/rejoindre_equipe">Rejoindre une équipe</a></li>
|
||||
<?php } else { ?>
|
||||
<li><a href="<?= $URL_BASE ?>/mon_equipe">Mon équipe</a></li>
|
||||
<?php if ($_SESSION["team_validation_status"] == "VALIDATED" || true) { ?>
|
||||
<li><a href="https://paypal.me/galaxyoyo42">Paiement</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/solutions">Solutions</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/syntheses">Notes de synthèse</a></li>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php if ($_SESSION["role"] == "ADMIN") { ?>
|
||||
<li><a href="<?= $URL_BASE ?>/ajouter_tournoi">Ajouter un tournoi</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/ajouter_organisateur">Ajouter un organisateur</a></li>
|
||||
<?php } ?>
|
||||
<?php if ($_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER") { ?>
|
||||
<li><a href="<?= $URL_BASE ?>/solutions_orga">Solutions</a></li>
|
||||
<li><a href="<?= $URL_BASE ?>/syntheses_orga">Notes de synthèse</a></li>
|
||||
<?php } ?>
|
||||
<li><a href="<?= $URL_BASE ?>/deconnexion">Déconnexion</a></li>
|
||||
<hr />
|
||||
<?php
|
||||
if ($_SESSION["role"] != "ADMIN") {
|
||||
echo "<li><a href=\"?be-admin=1\">Devenir administrateur</a></li>";
|
||||
}
|
||||
if ($_SESSION["role"] != "ORGANIZER") {
|
||||
echo "<li><a href=\"?be-organizer=1\">Devenir organisateur</a></li>";
|
||||
}
|
||||
if ($_SESSION["role"] != "PARTICIPANT") {
|
||||
echo "<li><a href=\"?be-participant=1\">Devenir participant</a></li>";
|
||||
}
|
||||
if ($_SESSION["role"] != "ENCADRANT") {
|
||||
echo "<li><a href=\"?be-encadrant=1\">Devenir encadrant</a></li>";
|
||||
}
|
||||
?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
|
||||
<div id="main-container">
|
||||
<div id="main-content">
|
||||
<div class="container-fluid">
|
|
@ -0,0 +1,104 @@
|
|||
<div class="container-fluid">
|
||||
|
||||
|
||||
|
||||
<div id="header">
|
||||
<center>
|
||||
<img src="https://s3-eu-west-1.amazonaws.com/tfjm2-inscriptions/static/inscription/images/header.jpg" alt="" width="720" height="160">
|
||||
</center>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
<center>
|
||||
|
||||
|
||||
<h3>Vous souhaitez participer au tournoi ? Votre équipe est déjà formée ?</h3>
|
||||
<h4><a href="<?= $URL_BASE ?>/server_files/controllers/inscription.php">Créez un compte</a> pour commencer la procédure d'inscription ou <a href="<?= $URL_BASE ?>/server_files/controllers/connexion.php">connectez-vous</a> si votre équipe a déjà un compte.</h4>
|
||||
</center>
|
||||
|
||||
<br>
|
||||
|
||||
<center>
|
||||
<h2>Bienvenue sur le site d'inscription du TFJM<sup>2</sup> !</h2>
|
||||
</center>
|
||||
|
||||
<center>
|
||||
Ce site a été conçu pour gérer les inscriptions au Tournoi Français des Jeunes Mathématiciennes et Mathématiciens.
|
||||
<br>
|
||||
<a href="http://www.tfjm.org/">Cliquez ici pour accéder au site de présentation du tournoi.</a>
|
||||
</center>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
<p align="justify"><strong>
|
||||
Attention aux échéances ! Chaque tournoi a une date limite pour les inscriptions et une date limite pour déposer vos solutions. Elles sont affichées avec les informations de chaque tournoi. Merci de vous y référer !
|
||||
<br>
|
||||
Une fois l'échéance passée, le site bloque tout accès aux inscriptions (et respectivement au dépôt des solutions).</strong>
|
||||
</p>
|
||||
|
||||
<p style="color:red;">
|
||||
Attention, modification du règlement par rapport aux années précédentes : article 4.3
|
||||
<br>
|
||||
"l’équipe doit envoyer par mail à contact@tfjm.org, une lettre (au format pdf), répondant aux questions suivantes :
|
||||
<br>
|
||||
|
||||
</p><ul style="color:red;">
|
||||
<li>Comment l’équipe s’est-elle formée ?</li>
|
||||
<li>Comment l’équipe va-t-elle travailler (où peut-elle se rencontrer, à quelle fréquence, rencontres avec l’encadrant•e) ? </li>
|
||||
</ul>
|
||||
|
||||
Cette lettre permettra aux organisateurs•trices de vérifier que l’équipe dispose des conditions nécessaires à une participation sérieuse. Sont dispensées les équipes dont la moitié ou plus des membres sont scolarisés dans le même établissement. Le comité National d’Organisation se réserve le droit d’accepter ou non l’inscription des équipes concernées par cette lettre."
|
||||
<br>
|
||||
|
||||
Pour plus de détail, voir le règlement : <a href="https://tfjm.org/infos-tournois/">https://tfjm.org/infos-tournois/</a>
|
||||
<p></p>
|
||||
|
||||
|
||||
<center>
|
||||
<h2>Comment ça marche ?</h2>
|
||||
</center>
|
||||
|
||||
<p align="justify">
|
||||
Pour participer à l'un des tournois régionaux, il suffit de créer un compte sur la rubrique <b>Inscription</b>. Il vous faudra une adresse email pour ce faire. Un mail de confirmation sera envoyé à cette adresse. Il vous fournira un nom d'utilisateur et un mot de passe que vous allez devoir changer par la suite.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Vous pouvez accéder à votre compte via la rubrique <b>Connexion</b>. Une fois connecté, vous pourrez :
|
||||
</p><ul>
|
||||
<li>rentrer des informations sur les membres de votre équipe, tant participants qu'encadrants ;</li>
|
||||
<li>enregistrer et télécharger des versions préliminaires de vos solutions (seulement la dernière version enregistrée avant
|
||||
la date limite sera prise en compte pour le tournoi).</li>
|
||||
</ul>
|
||||
|
||||
Une fois que vous aurez fourni toutes les informations demandées dans la rubrique <b>Mon Équipe</b>, votre inscription pourra être validée par les organisateurs locaux.
|
||||
<p></p>
|
||||
|
||||
|
||||
<p class="text-danger">ATTENTION ! Votre équipe ne sera considérée comme admissible à participer au tournoi que lorsque cette première étape aura été franchie.</p>
|
||||
|
||||
<p>Pensez donc à former une équipe complète (minimum 4 participants et 1 encadrant) le plus tôt possible pour avoir plus de chances de participer, compte tenu du nombre des places disponibles dans chaque tournoi (qui sera dûment affiché sur la rubrique <b>Liste des Tournois</b>). Les équipes restantes seront placées en liste d'attente.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Pour les équipes dont l'inscription aura été validée, des documents à télécharger, remplir et signer deviendront disponibles sur votre compte. Vous allez devoir ensuite les scanner et les télécharger vers le site pour compléter votre inscription.
|
||||
</p>
|
||||
|
||||
|
||||
<p class="text-danger">ATTENTION ! Les équipes qui ne respecteront pas les délais pour rendre ces documents risquent d'être disqualifiées et de laisser leur place aux équipes placées en liste d'attente.</p>
|
||||
|
||||
<p>
|
||||
<em><strong>NB :</strong> Ce site est récent et il est encore possible que certaines pages ne fonctionnent pas correctement. Si vous remarquez des bugs, merci de les signaler à l'adresse <a href="mailto:contact@tfjm.org">contact@tfjm.org</a>.</em>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<!-- code facebook -->
|
||||
|
||||
<!-- liste des actualités -->
|
||||
|
||||
|
||||
|
||||
</div>
|
|
@ -1,35 +1,9 @@
|
|||
<?php
|
||||
|
||||
require_once "config.php";
|
||||
|
||||
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ORGANIZER" && $_SESSION["role"] != "ADMIN") {
|
||||
require_once "403.php";
|
||||
}
|
||||
|
||||
$id = $_GET["id"];
|
||||
$user_data = $DB->query("SELECT * FROM `users` WHERE `id` = $id;")->fetch();
|
||||
|
||||
if ($user_data === false) {
|
||||
require_once "404.php";
|
||||
}
|
||||
|
||||
$team_data = false;
|
||||
if ($user_data["team_id"] !== NULL)
|
||||
$team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = " . $user_data["team_id"] . ";")->fetch();
|
||||
|
||||
$documents_req = $DB->query("SELECT * FROM `documents` WHERE `user` = $id;");
|
||||
$tournaments_req = $DB->query("SELECT `tournament`, `name` FROM `organizers` JOIN `tournaments` ON `tournaments`.`id` = `tournament` WHERE `organizer` = $id ORDER BY `date_start`, `name`;");
|
||||
|
||||
?>
|
||||
|
||||
<?php require_once "header.php" ?>
|
||||
|
||||
<h1><?= $user_data["first_name"] . " " . $user_data["surname"] ?></h1>
|
||||
|
||||
<?php if ($user_data["role"] == "PARTICIPANT" || $user_data["role"] == "ENCADRANT") { ?>
|
||||
Équipe : <?= $team_data === false ? "Pas d'équipe" : "<a href=\"$URL_BASE/equipe/" . $team_data["trigram"] . "\">" . $team_data["name"] . " (" . $team_data["trigram"] . ")</a>" ?><br />
|
||||
<?php } ?>
|
||||
Date de naissance : <?= echo_date($user_data["birth_date"]) ?><br />
|
||||
Date de naissance : <?= echoDate($user_data["birth_date"]) ?><br />
|
||||
Sexe : <?= $user_data["gender"] == "M" ? "Masculin" : "Féminin" ?><br />
|
||||
Adresse : <?= $user_data["address"] . ", " . $user_data["postal_code"] . " " . $user_data["city"] . ($user_data["country"] == "France" ? "" : ", " . $user_data["country"]) ?><br />
|
||||
Adresse e-mail : <a href="mailto:<?= $user_data["email"] ?>"><?= $user_data["email"] ?></a><br />
|
||||
|
@ -91,6 +65,4 @@ elseif ($user_data["role"] == "PARTICIPANT" || $user_data["role"] == "ENCADRANT"
|
|||
}
|
||||
echo "$name de $first_name $surname : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
} ?>
|
||||
|
||||
<?php require_once "footer.php" ?>
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||
|
||||
<?php
|
||||
if (isset($error_message) && $error_message === FALSE) {
|
||||
?>
|
||||
Votre inscription est validée ! Merci désormais de confirmer votre boîte mail pour valider votre adresse.
|
||||
<?php } else if (isset($_SESSION["user_id"])) { ?>
|
||||
|
||||
<h2>Vous êtes déjà connecté !</h2>
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td style="width: 30%;"><label for="email">E-mail :</label></td>
|
||||
<td style="width: 70%;"><input style="width: 100%;" type="email" id="email" name="email" value="<?php if (isset($_POST["email"])) echo $_POST["email"] ?>" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="password">Mot de passe :</label></td>
|
||||
<td><input style="width: 100%;" type="password" id="password" name="password" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="confirm_password">Confirmer le mot de passe :</label></td>
|
||||
<td><input style="width: 100%;" type="password" id="confirm_password" name="confirm_password" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="surname">Nom :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="surname" name="surname" value="<?php if (isset($_POST["surname"])) echo $_POST["surname"] ?>" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="firstname">Prénom :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="firstname" name="firstname" value="<?php if (isset($_POST["firstname"])) echo $_POST["firstname"] ?>" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="birth_date">Date de naissance :</label></td>
|
||||
<td><input style="width: 100%;" type="date" id="birth_date" name="birth_date" value="<?php if (isset($_POST["birth_date"])) echo $_POST["birth-date"] ?>" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="gender">Sexe :</label></td>
|
||||
<td><input type="radio" id="male" name="gender" value="M" required <?= isset($_POST["gender"]) && $_POST["gender"] == "M" ? "checked" : "" ?> /><label for="male">Homme</label>
|
||||
<input type="radio" id="female" name="gender" value="F" required <?= isset($_POST["gender"]) && $_POST["gender"] == "F" ? "checked" : "" ?> /><label for="female">Femme</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="address">Adresse :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="address" name="address" value="<?php if (isset($_POST["address"])) echo $_POST["address"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="postal_code">Code postal :</label></td>
|
||||
<td><input style="width: 100%;" type="number" id="postal_code" name="postal_code" value="<?php if (isset($_POST["postal_code"])) echo $_POST["postal_code"] ?>" min="1000" max="95999" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="city">Ville :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="city" name="city" value="<?php if (isset($_POST["city"])) echo $_POST["city"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="country">Pays :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="country" name="country" value="<?php echo isset($_POST["country"]) ? $_POST["country"] : "France" ?>" required /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="phone_number">Numéro de téléphone :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="phone_number" name="phone_number" value="<?php if (isset($_POST["phone_number"])) echo $_POST["phone_number"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="role">Rôle :</label></td>
|
||||
<td><select style="width: 100%;" id="role" name="role" onchange="selectRole()">
|
||||
<option value="participant">Participant</option>
|
||||
<option value="encadrant">Encadrant</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label id="school_label" for="school">Établissement dans lequel l'élève étudie :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="school" name="school" value="<?php if (isset($_POST["school"])) echo $_POST["school"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label id="class_label" for="class">Classe :</label></td>
|
||||
<td><select style="width: 100%;" id="class" name="class">
|
||||
<option value="terminale">Terminale</option>
|
||||
<option value="premiere">Première</option>
|
||||
<option value="seconde">Seconde ou inférieur</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label id="responsible_name_label" for="responsible_name">Nom du responsable légal :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="responsible_name" name="responsible_name" value="<?php if (isset($_POST["responsible_name"])) echo $_POST["responsible_name"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label id="responsible_phone_label" for="responsible_phone">Téléphone du responsable légal :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="responsible_phone" name="responsible_phone" value="<?php if (isset($_POST["responsible_phone"])) echo $_POST["responsible_phone"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label id="responsible_email_label" for="responsible_email">Email du responsable légal :</label></td>
|
||||
<td><input style="width: 100%;" type="text" id="responsible_email" name="responsible_email" value="<?php if (isset($_POST["responsible_email"])) echo $_POST["responsible_email"] ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label id="description_label" for="description">Description :</label></td>
|
||||
<td><textarea style="width: 100%;" id="description" name="description"><?php if (isset($_POST["description"])) echo $_POST["description"] ?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%;" type="submit" value="S'inscrire" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function selectRole() {
|
||||
switch (document.getElementById("role").value) {
|
||||
case "participant":
|
||||
document.getElementById("school_label").style.display = "block";
|
||||
document.getElementById("school").style.display = "block";
|
||||
document.getElementById("school").require = "true";
|
||||
document.getElementById("class_label").style.display = "block";
|
||||
document.getElementById("class").style.display = "block";
|
||||
document.getElementById("responsible_name_label").style.display = "block";
|
||||
document.getElementById("responsible_name").style.display = "block";
|
||||
document.getElementById("responsible_phone_label").style.display = "block";
|
||||
document.getElementById("responsible_phone").style.display = "block";
|
||||
document.getElementById("responsible_email_label").style.display = "block";
|
||||
document.getElementById("responsible_email").style.display = "block";
|
||||
document.getElementById("description_label").style.display = "none";
|
||||
document.getElementById("description").style.display = "none";
|
||||
break;
|
||||
case "encadrant":
|
||||
document.getElementById("school_label").style.display = "none";
|
||||
document.getElementById("school").style.display = "none";
|
||||
document.getElementById("school").require = "false";
|
||||
document.getElementById("class_label").style.display = "none";
|
||||
document.getElementById("class").style.display = "none";
|
||||
document.getElementById("responsible_name_label").style.display = "none";
|
||||
document.getElementById("responsible_name").style.display = "none";
|
||||
document.getElementById("responsible_phone_label").style.display = "none";
|
||||
document.getElementById("responsible_phone").style.display = "none";
|
||||
document.getElementById("responsible_email_label").style.display = "none";
|
||||
document.getElementById("responsible_email").style.display = "none";
|
||||
document.getElementById("description_label").style.display = "block";
|
||||
document.getElementById("description").style.display = "block";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
selectRole();
|
||||
</script>
|
||||
|
||||
<?php } ?>
|
|
@ -0,0 +1,173 @@
|
|||
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||
|
||||
<?php
|
||||
if (isset($error_message) && $error_message === FALSE) {
|
||||
?>
|
||||
<h2>Votre compte a bien été mis à jour !</h2>
|
||||
<?php
|
||||
if (isset($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
echo "Votre adresse mail a bien été changée. Veuillez vérifier votre boîte mail pour valider votre nouvelle adresse, vous en aurez besoin pour vous reconnecter.";
|
||||
}
|
||||
?>
|
||||
<?php } ?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true"/>
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td style="width: 30%"><label for="email">E-mail :</label></td>
|
||||
<td style="width: 70%"><?php echo $user_data["email"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="email" id="email" name="email"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="surname">Nom :</label></td>
|
||||
<td><?php echo $user_data["surname"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="surname" name="surname"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="firstname">Prénom :</label></td>
|
||||
<td><?php echo $user_data["first_name"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="firstname" name="firstname"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="birth_date">Date de naissance :</label></td>
|
||||
<td><?php echo echoDate($user_data["birth_date"]) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="date" id="birth_date" name="birth_date"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="gender">Sexe :</label></td>
|
||||
<td><input type="radio" id="male" name="gender" value="M" <?php if ($user_data["gender"] == "M") echo "checked" ?> /><label for="male">Homme</label>
|
||||
<input type="radio" id="female" name="gender" value="F" <?php if ($user_data["gender"] == "F") echo "checked" ?> /><label for="female">Femme</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="address">Adresse :</label></td>
|
||||
<td><?php echo $user_data["address"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="address" name="address"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="postal_code">Code postal :</label></td>
|
||||
<td><?php echo $user_data["postal_code"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="number" id="postal_code" name="postal_code" min="1000" max="95999"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="city">Ville :</label></td>
|
||||
<td><?php echo $user_data["city"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="city" name="city"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="country">Pays :</label></td>
|
||||
<td><?php echo $user_data["country"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="country" name="country"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="phone_number">Numéro de téléphone :</label></td>
|
||||
<td><?php echo $user_data["phone_number"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="phone_number" name="phone_number"/></td>
|
||||
</tr>
|
||||
<?php if ($user_data["role"] == "PARTICIPANT") { ?>
|
||||
<tr>
|
||||
<td><label for="school">Établissement dans lequel l'élève étudie :</label></td>
|
||||
<td><?php echo $user_data["school"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input style="width: 100%" type="text" id="school" name="school"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="class">Classe :</label></td>
|
||||
<td><select style="width: 100%" id="class" name="class">
|
||||
<option value="terminale" <?php if ($user_data["class"] == "terminale") echo "selected" ?>>Terminale</option>
|
||||
<option value="premiere" <?php if ($user_data["class"] == "premiere") echo "selected" ?>>Première</option>
|
||||
<option value="seconde" <?php if ($user_data["class"] == "seconde") echo "selected" ?>>Seconde ou inférieur</option>
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="responsible_name">Nom du responsable légal :</label>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $user_data["responsible_name"] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="text" id="responsible_name" name="responsible_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="responsible_phone">Téléphone du responsable légal :</label>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $user_data["responsible_phone"] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%" type="text" id="responsible_phone" name="responsible_phone" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="responsible_email">Email du responsable légal :</label>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $user_data["responsible_email"] ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%" type="email" id="responsible_email" name="responsible_email" />
|
||||
</td>
|
||||
</tr>
|
||||
<?php } else { ?>
|
||||
<tr>
|
||||
<td><label for="description">Description :</label></td>
|
||||
<td><textarea style="width: 100%" id="description" name="description"><?php echo $user_data["description"] ?></textarea></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" style="width: 100%" value="Mettre à jour mes données"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<div style="padding: 20px"></div>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted_password" value="true"/>
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td style="width: 30%"><label for="old_password">Ancien mot de passe :</label></td>
|
||||
<td style="width: 70%"><input style="width: 100%" type="password" id="old_password" name="old_password"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="new_password">Nouveau mot de passe :</label></td>
|
||||
<td><input style="width: 100%" type="password" id="new_password" name="new_password"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="confirm_password">Confirmer le mot de passe :</label></td>
|
||||
<td><input style="width: 100%" type="password" id="confirm_password" name="confirm_password"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" style="width: 100%" value="Mettre à jour mon mot de passe"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
|
@ -0,0 +1,164 @@
|
|||
<?php if (isset($error_message)) {
|
||||
if ($error_message !== false) {
|
||||
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||
} else {
|
||||
echo "<h2>Le fichier a été correctement envoyé !</h2>";
|
||||
}
|
||||
} ?>
|
||||
|
||||
<h2>Informations sur l'équipe</h2>
|
||||
|
||||
Nom de l'équipe : <?= $team_data["name"] ?><br/>
|
||||
Trigramme : <?= $team_data["trigram"] ?><br/>
|
||||
Tournoi : <a href="<?= $tournament_data["name"] ?>"><?= $tournament_data["name"] ?></a><br/>
|
||||
<?php
|
||||
for ($i = 1; $i <= 2; ++$i) {
|
||||
if ($team_data["encadrant_" . $i] == NULL)
|
||||
continue;
|
||||
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = " . $team_data["encadrant_" . $i] . " AND `year` = '$YEAR';")->fetch();
|
||||
echo "Encadrant $i : " . $user_data["first_name"] . " " . $user_data["surname"] . "<br />";
|
||||
}
|
||||
for ($i = 1; $i <= 6; ++$i) {
|
||||
if ($team_data["participant_" . $i] == NULL)
|
||||
continue;
|
||||
$user_data = $DB->query("SELECT `surname`, `first_name` FROM `users` WHERE `id` = " . $team_data["participant_" . $i] . " AND `year` = '$YEAR';")->fetch();
|
||||
echo "Participant $i : " . $user_data["first_name"] . " " . $user_data["surname"] . "<br />";
|
||||
}
|
||||
?>
|
||||
Code d'accès : <strong><?php echo $team_data["access_code"] ?></strong><br/>
|
||||
<?php if (isset($_SESSION["final_id"])) {
|
||||
$final_name = $_SESSION["final_name"];
|
||||
echo "<strong>Équipe sélectionnée pour la <a href=\"$URL_BASE/tournoi/$final_name\">finale nationale</a>.</strong><br />";
|
||||
} ?>
|
||||
|
||||
<?php if (isset($_GET["modifier"])) { ?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="team_edit" value="true"/>
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="name">Nom :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $team_data["name"] ?>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="trigram">Trigramme :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="text" id="trigram" name="trigram"
|
||||
value="<?= $team_data["trigram"] ?>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="tournament">Tournoi :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="tournament" name="tournament">
|
||||
<?php
|
||||
while (($data = $tournaments_response->fetch()) !== FALSE) {
|
||||
echo "<option value=\"" . $data["id"] . "\">" . $data["name"] . "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" value="Modifier l'équipe"/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<?php if ($_SESSION["team_validation_status"] == "NOT_READY") { ?>
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="<?= $URL_BASE ?>/mon_equipe/modifier">Modifier mon équipe</a>
|
||||
<?php } ?>
|
||||
<hr/>
|
||||
<h2>Mes autorisations</h2>
|
||||
<?php
|
||||
while (($data = $documents_req->fetch()) !== false) {
|
||||
$file_id = $data["file_id"];
|
||||
$type = $data["type"];
|
||||
$version = $data["version"];
|
||||
switch ($data["type"]) {
|
||||
case "PARENTAL_CONSENT":
|
||||
$name = "Autorisation parentale";
|
||||
break;
|
||||
case "PHOTO_CONSENT":
|
||||
$name = "Autorisation de droit à l'image";
|
||||
break;
|
||||
case "SANITARY_PLUG":
|
||||
$name = "Fiche sanitaire";
|
||||
break;
|
||||
}
|
||||
echo "$name : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
if ($team_data["validation_status"] == "NOT_READY") { ?>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="type">Type de document :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="type" name="type">
|
||||
<?php if ($_SESSION["birth_date"] > strval($YEAR - 18) . substr($tournament_data["date_start"], 4)) { ?>
|
||||
<option value="parental_consent">Autorisation parentale</option>
|
||||
<?php } ?>
|
||||
<option value="photo_consent">Autorisation de droit à l'image</option>
|
||||
<option value="sanitary_plug">Fiche sanitaire</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="file">Fichier :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="file" id="file" name="document"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" name="send_document" value="Envoyer le document"/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php } ?>
|
||||
<hr/>
|
||||
<?php if ($team_data["validation_status"] == "NOT_READY") { ?>
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td style="width: 50%;">
|
||||
<form method="post">
|
||||
<input style="width: 100%;" type="submit" name="leave_team" value="Quitter l'équipe"/>
|
||||
</form>
|
||||
</td>
|
||||
<?php
|
||||
$can_validate = checkCanValidate();
|
||||
if ($can_validate) { ?>
|
||||
<td style="width: 50%;">
|
||||
<form method="post">
|
||||
<input style="width: 100%;" type="submit" name="request_validation"
|
||||
value="Demander la validation"/>
|
||||
</form>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</table>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
if (!isset($_SESSION["role"]) or ($_SESSION["role"] != "PARTICIPANT" && $_SESSION["role"] != "ENCADRANT")) {
|
||||
?>
|
||||
<h2>Vous devez être participant ou encadrant pour pouvoir rejoindre une équipe.</h2>
|
||||
<?php } else if (isset($access_code)) { ?>
|
||||
Vous avez bien rejoint l'équipe <?php echo $data["name"] ?> !
|
||||
<?php } else if ($_SESSION["team_id"] != NULL) { ?>
|
||||
<h2>Vous êtes déjà dans une équipe.</h2>
|
||||
<?php } else { ?>
|
||||
|
||||
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
|
||||
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="access_code">Code d'accès :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="text" id="access_code" name="access_code" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" value="Rejoindre l'équipe" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php } ?>
|
|
@ -0,0 +1,58 @@
|
|||
<?php if (isset($error_message)) {
|
||||
if ($error_message !== false) {
|
||||
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||
} else {
|
||||
echo "<h2>Le fichier a été correctement envoyé !</h2>";
|
||||
}
|
||||
}?>
|
||||
|
||||
<?php if (date("yyyy-mm-dd") < $tournament_data["date_solutions"]) { ?>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="5000000" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="problem">Problème :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="problem" name="problem">
|
||||
<?php
|
||||
for ($i = 1; $i <= 9; ++$i) {
|
||||
echo "<option value=\"$i\">$i</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="file">Fichier :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="file" id="file" name="solution" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" name="send_solution" value="Envoyer" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2>Solutions soumises :</h2>
|
||||
|
||||
<?php
|
||||
while (($data = $solutions_req->fetch()) !== false) {
|
||||
$file_id = $data["file_id"];
|
||||
$problem = $data["problem"];
|
||||
$version = $data["version"];
|
||||
echo "Problème $problem (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
if (date("yyyy-mm-dd") < $tournament_data["date_solutions"]) {
|
||||
echo "<h3>Il est trop tôt pour se préoccuper des notes de synthèse, attendez le tirage des poules.</h3>";
|
||||
require_once "../views/footer.php";
|
||||
}
|
||||
|
||||
if (isset($error_message)) {
|
||||
if ($error_message !== false) {
|
||||
echo "<h2>Erreur : " . $error_message . "</h2>";
|
||||
}
|
||||
else {
|
||||
echo "<h2>Le fichier a été correctement envoyé !</h2>";
|
||||
}
|
||||
}?>
|
||||
|
||||
<?php if (date("yyyy-mm-dd") < $tournament_data["date_syntheses"]) { ?>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="5000000" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="dest">Destination de la note de synthèse :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="dest" name="dest">
|
||||
<option value="opposant">Opposant</option>
|
||||
<option value="rapporteur">Rapporteur</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="file">Fichier :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="file" id="file" name="synthese" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" name="send_synthese" value="Envoyer" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
<div style="padding: 20px"></div>
|
||||
|
||||
<h2>Notes de synthèse soumises :</h2>
|
||||
|
||||
<?php
|
||||
while (($data = $syntheses_req->fetch()) !== false) {
|
||||
$file_id = $data["file_id"];
|
||||
$dest = $data["dest"];
|
||||
$version = $data["version"];
|
||||
echo "Note de synthèse pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur") . " (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,222 @@
|
|||
<h2>Tournoi de <?php echo $data["name"] ?></h2>
|
||||
|
||||
<strong>Organisateur<?= sizeof($orgas) >= 2 ? 's' : '' ?> :</strong>
|
||||
<?php
|
||||
$s = "";
|
||||
for ($i = 0; $i < sizeof($orgas); ++$i) {
|
||||
if ($_SESSION["role"] == "ORGANIZER" || $_SESSION["role"] == "ADMIN")
|
||||
$s .= "<a href=\"$URL_BASE/informations/$orgas_id[$i]/$orgas[$i]\">$orgas[$i]</a>";
|
||||
else
|
||||
$s .= $orgas[$i];
|
||||
$s .= ", ";
|
||||
}
|
||||
echo substr($s, 0, -2);
|
||||
?>
|
||||
<br />
|
||||
<strong>Nombre d'équipes maximal :</strong> <?php echo $data["size"] ?><br />
|
||||
<strong>Lieu :</strong> <?php echo $data["place"] ?><br />
|
||||
<strong>Prix par partipant :</strong> <?php echo $data["price"] == 0 ? "Gratuit" : $data["price"] . " €" ?><br />
|
||||
<strong>Dates :</strong> Du <?php echo echoDate($data["date_start"]) ?> au <?php echo echoDate($data["date_end"]) ?><br />
|
||||
<strong>Clôture des inscriptions :</strong> <?php echo echoDate($data["date_inscription"], true) ?><br />
|
||||
<strong>Date limite d'envoi des solutions :</strong> <?php echo echoDate($data["date_solutions"], true) ?><br />
|
||||
<strong>Date limite d'envoi des notes de synthèse :</strong> <?php echo echoDate($data["date_syntheses"], true) ?><br />
|
||||
<strong>Description :</strong> <?php echo $data["description"] ?><br />
|
||||
<?php
|
||||
if ($data["final"])
|
||||
echo "<strong>Ce tournoi est la finale nationale du TFJM² 2020.</strong><br />";
|
||||
?>
|
||||
|
||||
<?php if (!isset($_GET["modifier"]) && ($_SESSION["role"] == "ADMIN" || $_SESSION["role"] == "ORGANIZER" && in_array($_SESSION["user_id"], $orgas_id))) { ?>
|
||||
<a href="<?= $URL_BASE ?>/tournoi/<?= $data["name"] ?>/modifier">Éditer le tournoi</a>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if (!isset($_GET["modifier"])) { ?>
|
||||
<hr/>
|
||||
|
||||
<h2>Équipes inscrites à ce tournoi :</h2>
|
||||
|
||||
<table style="border: 1px solid black; width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
Équipe
|
||||
</th>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
Trigramme
|
||||
</th>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
Date d'inscription
|
||||
</th>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
État de validation de l'inscription
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while (($team_data = $teams_response->fetch()) != false) {
|
||||
?>
|
||||
<tr>
|
||||
<td style="border: 1px solid black; text-align: center">
|
||||
<?php
|
||||
if (isset($_SESSION["role"]) && ($_SESSION["role"] == "ADMIN" || ($_SESSION["role"] == "ORGANIZER" && in_array($_SESSION["user_id"], $orgas_id))))
|
||||
echo "<a href=\"$URL_BASE/equipe/" . $team_data["trigram"] . "\">" . $team_data["name"] . "</a>";
|
||||
else
|
||||
echo $team_data["name"];
|
||||
?>
|
||||
</td>
|
||||
<td style="border: 1px solid black; text-align: center"><?php echo $team_data["trigram"] ?></td>
|
||||
<td style="border: 1px solid black; text-align: center"><?php echo echoDate($team_data["inscription_date"]) ?></td>
|
||||
<td style="border: 1px solid black; text-align: center">
|
||||
<?php
|
||||
switch ($team_data["validation_status"]) {
|
||||
case "NOT_READY":
|
||||
echo "Inscription non terminée";
|
||||
break;
|
||||
case "WAITING":
|
||||
echo "En attente de validation";
|
||||
break;
|
||||
case "VALIDATED":
|
||||
echo "Inscription validée";
|
||||
break;
|
||||
default:
|
||||
echo "Statut inconnu";
|
||||
break;
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
Équipe
|
||||
</th>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
Trigramme
|
||||
</th>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
Date d'inscription
|
||||
</th>
|
||||
<th style="border: 1px solid black; text-align: center">
|
||||
État de validation de l'inscription
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="submitted" value="true" />
|
||||
<table style="width: 100%;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 30%;">
|
||||
<label for="name">Nom :</label>
|
||||
</td>
|
||||
<td style="width: 70%;">
|
||||
<input style="width: 100%;" type="text" id="name" name="name" value="<?= $data["name"] ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($_SESSION["role"] == "ADMIN") { ?>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="organizer">Organisateur :</label>
|
||||
</td>
|
||||
<td>
|
||||
<select style="width: 100%;" id="organizer" name="organizer[]" multiple size="4" required>
|
||||
<?php
|
||||
while (($orga_data = $orgas_response->fetch()) !== FALSE) {
|
||||
echo "<option value=\"" . $orga_data["id"] . "\" " . (in_array($orga_data["first_name"] . " " . $orga_data["surname"], $orgas) ? "selected" : "")
|
||||
. ">" . $orga_data["first_name"] . " " . $orga_data["surname"] . "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="size">Nombre d'équipes :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="number" id="size" name="size" min="3" max="12" value="<?= $data["size"] ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="place">Lieu :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="text" id="place" name="place" value="<?= $data["place"] ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="price">Prix par participant</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="number" id="price" name="price" min="0" max="21" value="<?= $data["price"] ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_start">Dates :</label>
|
||||
</td>
|
||||
<td>
|
||||
Du <input style="width: 45%;" type="date" id="date_start" name="date_start" value="<?= $data["date_start"] ?>" required />
|
||||
au <input style="width: 45%;" type="date" id="date_end" name="date_end" value="<?= $data["date_end"] ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_inscription">Date limite d'inscription :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 49%;" type="date" id="date_inscription" name="date_inscription" value="<?= substr($data["date_inscription"], 0, 10) ?>" required />
|
||||
<input style="width: 49%;" type="time" id="time_inscription" name="time_inscription" value="<?= substr($data["date_inscription"], 11) ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_solutions">Date limite pour rendre les solutions :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 49%;" type="date" id="date_solutions" name="date_solutions" value="<?= substr($data["date_solutions"], 0, 10) ?>" required />
|
||||
<input style="width: 49%;" type="time" id="time_solutions" name="time_solutions" value="<?= substr($data["date_solutions"],11) ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_syntheses">Date limite pour rendre les notes de synthèse :</label>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width: 100%;" type="date" id="date_syntheses" name="date_syntheses" value="<?= substr($data["date_syntheses"], 0, 10) ?>" required />
|
||||
<input style="width: 100%;" type="time" id="time_syntheses" name="time_syntheses" value="<?= substr($data["date_syntheses"], 11) ?>" required />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="description">Description :</label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea style="width: 100%;" name="description" id="description" required><?= $data["description"] ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input style="width: 100%;" type="submit" name="edit_tournament" value="Modifier le tournoi" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<h2>Liste des tournois</h2>
|
||||
|
||||
<table style="border: 1px solid black; width: 100%">
|
||||
<thead style="border: 1px solid black">
|
||||
<tr>
|
||||
<th style="border: 1px solid black; text-align: center">Lieu</th>
|
||||
<th style="border: 1px solid black; text-align: center">Dates</th>
|
||||
<th style="border: 1px solid black; text-align: center">Inscription avant le</th>
|
||||
<th style="border: 1px solid black; text-align: center">Date de rendu des solutions</th>
|
||||
<th style="border: 1px solid black; text-align: center">Places disponibles</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody style="border: 1px solid black">
|
||||
<?php
|
||||
while (($data = $response->fetch()) !== FALSE) {
|
||||
?>
|
||||
<tr style="border: 1px solid black">
|
||||
<td style="border: 1px solid black; text-align: center"><a href="<?= $URL_BASE ?>/tournoi/<?= $data["name"] ?>"><?= $data["name"] ?></a></td>
|
||||
<td style="border: 1px solid black; text-align: center">Du <?= echoDate($data["date_start"]) ?> au <?= echoDate($data["date_end"]) ?></td>
|
||||
<td style="border: 1px solid black; text-align: center"><?= echoDate($data["date_inscription"]) ?></td>
|
||||
<td style="border: 1px solid black; text-align: center"><?= echoDate($data["date_solutions"]) ?></td>
|
||||
<td style="border: 1px solid black; text-align: center"><?= $data["size"] ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr style="border: 1px solid black">
|
||||
<td style="border: 1px solid black; text-align: center"><a href="<?= $URL_BASE ?>/tournoi/<?= $final_data["name"] ?>"><?= $final_data["name"] ?></a></td>
|
||||
<td colspan="2" style="border: 1px solid black; text-align: center">Du <?= echoDate($final_data["date_start"]) ?> au <?= echoDate($final_data["date_end"]) ?></td>
|
||||
<!-- <td style="border: 1px solid black; text-align: center"><?= echoDate($final_data["date_inscription"]) ?></td> -->
|
||||
<td style="border: 1px solid black; text-align: center"><?= echoDate($final_data["date_solutions"]) ?></td>
|
||||
<td style="border: 1px solid black; text-align: center"><?= $final_data["size"] ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot style="border: 1px solid black">
|
||||
<tr>
|
||||
<th style="border: 1px solid black; text-align: center">Lieu</th>
|
||||
<th style="border: 1px solid black; text-align: center">Dates</th>
|
||||
<th style="border: 1px solid black; text-align: center">Inscription avant le</th>
|
||||
<th style="border: 1px solid black; text-align: center">Date de rendu des solutions</th>
|
||||
<th style="border: 1px solid black; text-align: center">Places disponibles</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
Loading…
Reference in New Issue