diff --git a/server_files/403.php b/server_files/403.php index 77bc30d..76739fa 100644 --- a/server_files/403.php +++ b/server_files/403.php @@ -1,12 +1,12 @@ Vous n'êtes pas autorisé à accéder à cette page."; -include "footer.php"; +require_once "footer.php"; exit(); \ No newline at end of file diff --git a/server_files/404.php b/server_files/404.php index b47428f..275bee1 100644 --- a/server_files/404.php +++ b/server_files/404.php @@ -1,12 +1,12 @@ Cette page n'existe pas."; -include "footer.php"; +require_once "footer.php"; exit(); \ No newline at end of file diff --git a/server_files/ajouter_equipe.php b/server_files/ajouter_equipe.php index d9aa7fa..7878268 100644 --- a/server_files/ajouter_equipe.php +++ b/server_files/ajouter_equipe.php @@ -1,127 +1,127 @@ -query("SELECT `id`, `name` FROM `tournaments` WHERE `date_inscription` > CURRENT_DATE AND `year` = '$YEAR';"); - -if (isset($_POST["submitted"])) { - $error_message = registerTeam(); -} - -function registerTeam() { - global $DB, $YEAR, $MAIL_ADDRESS, $access_code; - - if ($_SESSION["team_id"] != NULL) - return "Vous êtes déjà dans une équipe."; - - $name = htmlspecialchars($_POST["name"]); - - if (!isset($name) || $name == "") - return "Vous devez spécifier un nom d'équipe."; - - $result = $DB->query("SELECT `id` FROM `teams` WHERE `name` = '" . $name . "' AND `year` = '$YEAR';"); - if ($result->fetch()) - return "Une équipe existe déjà avec ce nom."; - - $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 `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."; - - $alphabet = "0123456789abcdefghijkmnopqrstuvwxyz0123456789"; - $access_code = ""; - for ($i = 0; $i < 6; ++$i) - $access_code .= $alphabet[rand(0, strlen($alphabet) - 1)]; - - $req = $DB->prepare("INSERT INTO `teams` (`name`, `trigram`, `tournament`, `encadrant_1`, `participant_1`, `validation_status`, `access_code`, `year`) - VALUES (?, ?, ?, ?, ?, ?, ?, ?);"); - $req->execute([$name, $trigram, $tournament_id, $_SESSION["role"] == "ENCADRANT" ? $_SESSION["user_id"] : NULL, - $_SESSION["role"] == "PARTICIPANT" ? $_SESSION["user_id"] : NULL, "NOT_READY", $access_code, $YEAR]); - - $result = $DB->query("SELECT `id` FROM `teams` WHERE `name` = '" . $name . "' AND `year` = '$YEAR';"); - $data_team = $result->fetch(); - $DB->prepare("UPDATE `users` SET `team_id` = ? WHERE `id` = " . $_SESSION["user_id"] . ";")->execute([$data_team["id"]]); - - $msg = "Bonjour " . $_SESSION["first_name"] . " " . $_SESSION["surname"] . ",\r\n\r\n"; - $msg .= "Vous venez de créer l'équipe « $name » ($trigram) pour le TFJM² de " . $data["name"] . " et nous vous en remercions. "; - $msg .= "Afin de permettre aux autres membres de votre équipe de vous rejoindre, veuillez leur transmettre le code d'accès : " . $access_code . "\r\n\r\n"; - $msg .= "Cordialement,\r\n\r\nL'organisation du TFJM² $YEAR"; - mail($_SESSION["email"], "Nouvelle équipe TFJM² $YEAR", $msg, "From: $MAIL_ADDRESS\r\n"); - - return false; -} - -?> - - - - -

Vous devez être participant ou encadrant pour pouvoir ajouter une équipe.

- -

Vous êtes déjà dans une équipe.

- - Votre équipe a bien été créée ! Voici le code d'accès à transmettre aux autres membres de votre équipe : - - -Erreur : " . $error_message . ""; ?> - -
- - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- -
-
- - - - +query("SELECT `id`, `name` FROM `tournaments` WHERE `date_inscription` > CURRENT_DATE AND `year` = '$YEAR';"); + +if (isset($_POST["submitted"])) { + $error_message = registerTeam(); +} + +function registerTeam() { + global $DB, $YEAR, $MAIL_ADDRESS, $access_code; + + if ($_SESSION["team_id"] != NULL) + return "Vous êtes déjà dans une équipe."; + + $name = htmlspecialchars($_POST["name"]); + + if (!isset($name) || $name == "") + return "Vous devez spécifier un nom d'équipe."; + + $result = $DB->query("SELECT `id` FROM `teams` WHERE `name` = '" . $name . "' AND `year` = '$YEAR';"); + if ($result->fetch()) + return "Une équipe existe déjà avec ce nom."; + + $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 `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."; + + $alphabet = "0123456789abcdefghijkmnopqrstuvwxyz0123456789"; + $access_code = ""; + for ($i = 0; $i < 6; ++$i) + $access_code .= $alphabet[rand(0, strlen($alphabet) - 1)]; + + $req = $DB->prepare("INSERT INTO `teams` (`name`, `trigram`, `tournament`, `encadrant_1`, `participant_1`, `validation_status`, `access_code`, `year`) + VALUES (?, ?, ?, ?, ?, ?, ?, ?);"); + $req->execute([$name, $trigram, $tournament_id, $_SESSION["role"] == "ENCADRANT" ? $_SESSION["user_id"] : NULL, + $_SESSION["role"] == "PARTICIPANT" ? $_SESSION["user_id"] : NULL, "NOT_READY", $access_code, $YEAR]); + + $result = $DB->query("SELECT `id` FROM `teams` WHERE `name` = '" . $name . "' AND `year` = '$YEAR';"); + $data_team = $result->fetch(); + $DB->prepare("UPDATE `users` SET `team_id` = ? WHERE `id` = " . $_SESSION["user_id"] . ";")->execute([$data_team["id"]]); + + $msg = "Bonjour " . $_SESSION["first_name"] . " " . $_SESSION["surname"] . ",\r\n\r\n"; + $msg .= "Vous venez de créer l'équipe « $name » ($trigram) pour le TFJM² de " . $data["name"] . " et nous vous en remercions. "; + $msg .= "Afin de permettre aux autres membres de votre équipe de vous rejoindre, veuillez leur transmettre le code d'accès : " . $access_code . "\r\n\r\n"; + $msg .= "Cordialement,\r\n\r\nL'organisation du TFJM² $YEAR"; + mail($_SESSION["email"], "Nouvelle équipe TFJM² $YEAR", $msg, "From: $MAIL_ADDRESS\r\n"); + + return false; +} + +?> + + + + +

Vous devez être participant ou encadrant pour pouvoir ajouter une équipe.

+ +

Vous êtes déjà dans une équipe.

+ + Votre équipe a bien été créée ! Voici le code d'accès à transmettre aux autres membres de votre équipe : + + +Erreur : " . $error_message . ""; ?> + +
+ + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ +
+
+ + + + diff --git a/server_files/ajouter_organisateur.php b/server_files/ajouter_organisateur.php index 1146426..c3950e5 100644 --- a/server_files/ajouter_organisateur.php +++ b/server_files/ajouter_organisateur.php @@ -1,6 +1,6 @@ - + - + diff --git a/server_files/ajouter_tournoi.php b/server_files/ajouter_tournoi.php index 7c73a88..4ab7e02 100644 --- a/server_files/ajouter_tournoi.php +++ b/server_files/ajouter_tournoi.php @@ -1,6 +1,6 @@ query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';"); @@ -108,7 +108,7 @@ function registerTournament() { ?> - + - + diff --git a/server_files/confirmer_mail.php b/server_files/confirmer_mail.php index 951d5b4..317e489 100644 --- a/server_files/confirmer_mail.php +++ b/server_files/confirmer_mail.php @@ -1,6 +1,6 @@ - +

- \ No newline at end of file + \ No newline at end of file diff --git a/server_files/connexion.php b/server_files/connexion.php index 8791be3..5e3882b 100644 --- a/server_files/connexion.php +++ b/server_files/connexion.php @@ -1,6 +1,6 @@ - + Erreur : " . $error_message . ""; ?> @@ -238,6 +238,6 @@ else if (isset($_SESSION["user_id"])) { ?> - + diff --git a/server_files/deconnexion.php b/server_files/deconnexion.php index 31b50ac..f2b10b6 100644 --- a/server_files/deconnexion.php +++ b/server_files/deconnexion.php @@ -1,14 +1,14 @@ - - - - -

Déconnexion réussie !

- - + + + + +

Déconnexion réussie !

+ + diff --git a/server_files/equipe.php b/server_files/equipe.php index 60fe63f..7dc2c38 100644 --- a/server_files/equipe.php +++ b/server_files/equipe.php @@ -1,6 +1,6 @@ query("SELECT `name`, `date_start` FROM `tournaments` WHERE `id` = '" . $team_data["tournament"] . "' AND `year` = '$YEAR';")->fetch(); @@ -74,7 +74,7 @@ if ($team_data["final_selection"]) { ?> - +

Informations sur l'équipe

@@ -170,4 +170,4 @@ if (!$team_data["final_selection"]) { ?> - + diff --git a/server_files/index.php b/server_files/index.php index 39fe89d..e93227b 100644 --- a/server_files/index.php +++ b/server_files/index.php @@ -1,10 +1,10 @@ - +
@@ -111,4 +111,4 @@ include 'config.php';
- \ No newline at end of file + \ No newline at end of file diff --git a/server_files/informations.php b/server_files/informations.php index d80d70b..d32a7f2 100644 --- a/server_files/informations.php +++ b/server_files/informations.php @@ -1,16 +1,16 @@ query("SELECT * FROM `users` WHERE `id` = $id;")->fetch(); if ($user_data === false) { - include "404.php"; + require_once "404.php"; } $team_data = false; @@ -22,7 +22,7 @@ $tournaments_req = $DB->query("SELECT `tournament`, `name` FROM `organizers` JOI ?> - +

@@ -93,4 +93,4 @@ elseif ($user_data["role"] == "PARTICIPANT" || $user_data["role"] == "ENCADRANT" } } ?> - + diff --git a/server_files/inscription.php b/server_files/inscription.php index 7e23a59..751b20d 100644 --- a/server_files/inscription.php +++ b/server_files/inscription.php @@ -1,6 +1,6 @@ - + Erreur : " . $error_message . ""; ?> @@ -276,6 +276,6 @@ function register() { selectRole(); - + diff --git a/server_files/mon_compte.php b/server_files/mon_compte.php index 35b5e0f..1c19358 100644 --- a/server_files/mon_compte.php +++ b/server_files/mon_compte.php @@ -1,323 +1,323 @@ -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; -} - -?> - - - -Vous devez être connecté pour afficher cette page."; - include "footer.php"; - return; -} ?> - -Erreur : " . $error_message . ""; ?> - - -

Votre compte a bien été mis à jour !

- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/> - />
- - - -
- -
- - - -
- -
- - - -
- -
-
- -
- -
- - - - - - - - - - - - - - - - - -
-
- - +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; +} + +?> + + + +Vous devez être connecté pour afficher cette page."; + require_once "footer.php"; + return; +} ?> + +Erreur : " . $error_message . ""; ?> + + +

Votre compte a bien été mis à jour !

+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
/> + />
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + +
+
+ + diff --git a/server_files/mon_equipe.php b/server_files/mon_equipe.php index 4553d4e..92f6a40 100644 --- a/server_files/mon_equipe.php +++ b/server_files/mon_equipe.php @@ -1,6 +1,6 @@ - + Vous devez être dans une équipe pour afficher cette page."; - include "footer.php"; + require_once "footer.php"; return; } ?> @@ -364,4 +364,4 @@ Code d'accès :
- + diff --git a/server_files/rejoindre_equipe.php b/server_files/rejoindre_equipe.php index 0463f5a..3e518ad 100644 --- a/server_files/rejoindre_equipe.php +++ b/server_files/rejoindre_equipe.php @@ -1,93 +1,93 @@ -query("SELECT * FROM `teams` WHERE `access_code` = '" . $access_code . "' AND `year` = '$YEAR';"); - if (($data = $result->fetch()) === FALSE) - return "Ce code d'accès est invalide."; - - if ($_SESSION["role"] != "PARTICIPANT" && $_SESSION["role"] != "ENCADRANT") - return "Seuls les participants et les encadrants peuvent rejoindre une équipe."; - - if ($data["validation_status"] != "NOT_READY") - return "Cette équipe est déjà en cours de validation ou validée, vous ne pouvez pas la rejoindre."; - - for ($i = 1; $i <= $_SESSION["role"] == "PARTICIPANT" ? 6 : 2; ++$i) { - if ($data[strtolower($_SESSION["role"]) . "_" . strval($i)] == NULL) - break; - } - - if ($_SESSION["role"] == "PARTICIPANT" && $i == 7 || $_SESSION["role"] == "ENCADRANT" && $i == 3) - return "Il n'y a plus de place pour vous dans l'équipe."; - - $DB->prepare("UPDATE `users` SET `team_id` = ? WHERE `id` = " . $_SESSION["user_id"] . ";")->execute([$data["id"]]); - /** @noinspection SqlResolve */ - $DB->prepare("UPDATE `teams` SET `" . strtolower($_SESSION["role"]) . "_" . strval($i) . "` = ? WHERE `id` = " . $data["id"] . ";")->execute([$_SESSION["user_id"]]); - - $_SESSION["team_id"] = $data["id"]; - $_SESSION["team_validation_status"] = $data["validation_status"]; - - $msg = "Bonjour " . $_SESSION["first_name"] . " " . $_SESSION["surname"] . ",\r\n\r\n"; - $msg .= "Vous venez de rejoindre l'équipe « " . $data["name"] . " » (" . $data["trigram"] . ") pour le TFJM² de " . $data["name"] . " et nous vous en remercions.\r\n\r\n"; - $msg .= "Cordialement,\r\n\r\nL'organisation du TFJM² $YEAR"; - mail($_SESSION["email"], "Équipe rejointe TFJM² $YEAR", $msg, "From: $MAIL_ADDRESS\r\n"); - - return false; -} - -?> - - - - -

Vous devez être participant ou encadrant pour pouvoir rejoindre une équipe.

- - Vous avez bien rejoint l'équipe ! - -

Vous êtes déjà dans une équipe.

- - -Erreur : " . $error_message . ""; ?> - -
- - - - - - - - - - - -
- - - -
- -
-
- - - - +query("SELECT * FROM `teams` WHERE `access_code` = '" . $access_code . "' AND `year` = '$YEAR';"); + if (($data = $result->fetch()) === FALSE) + return "Ce code d'accès est invalide."; + + if ($_SESSION["role"] != "PARTICIPANT" && $_SESSION["role"] != "ENCADRANT") + return "Seuls les participants et les encadrants peuvent rejoindre une équipe."; + + if ($data["validation_status"] != "NOT_READY") + return "Cette équipe est déjà en cours de validation ou validée, vous ne pouvez pas la rejoindre."; + + for ($i = 1; $i <= $_SESSION["role"] == "PARTICIPANT" ? 6 : 2; ++$i) { + if ($data[strtolower($_SESSION["role"]) . "_" . strval($i)] == NULL) + break; + } + + if ($_SESSION["role"] == "PARTICIPANT" && $i == 7 || $_SESSION["role"] == "ENCADRANT" && $i == 3) + return "Il n'y a plus de place pour vous dans l'équipe."; + + $DB->prepare("UPDATE `users` SET `team_id` = ? WHERE `id` = " . $_SESSION["user_id"] . ";")->execute([$data["id"]]); + /** @noinspection SqlResolve */ + $DB->prepare("UPDATE `teams` SET `" . strtolower($_SESSION["role"]) . "_" . strval($i) . "` = ? WHERE `id` = " . $data["id"] . ";")->execute([$_SESSION["user_id"]]); + + $_SESSION["team_id"] = $data["id"]; + $_SESSION["team_validation_status"] = $data["validation_status"]; + + $msg = "Bonjour " . $_SESSION["first_name"] . " " . $_SESSION["surname"] . ",\r\n\r\n"; + $msg .= "Vous venez de rejoindre l'équipe « " . $data["name"] . " » (" . $data["trigram"] . ") pour le TFJM² de " . $data["name"] . " et nous vous en remercions.\r\n\r\n"; + $msg .= "Cordialement,\r\n\r\nL'organisation du TFJM² $YEAR"; + mail($_SESSION["email"], "Équipe rejointe TFJM² $YEAR", $msg, "From: $MAIL_ADDRESS\r\n"); + + return false; +} + +?> + + + + +

Vous devez être participant ou encadrant pour pouvoir rejoindre une équipe.

+ + Vous avez bien rejoint l'équipe ! + +

Vous êtes déjà dans une équipe.

+ + +Erreur : " . $error_message . ""; ?> + +
+ + + + + + + + + + + +
+ + + +
+ +
+
+ + + + diff --git a/server_files/solutions.php b/server_files/solutions.php index 4699162..379ccde 100644 --- a/server_files/solutions.php +++ b/server_files/solutions.php @@ -1,9 +1,9 @@ - + fetch()) !== false) { } ?> - + diff --git a/server_files/solutions_orga.php b/server_files/solutions_orga.php index 891e4be..8030be8 100644 --- a/server_files/solutions_orga.php +++ b/server_files/solutions_orga.php @@ -1,9 +1,9 @@ - + - + fetch()) !== false) { ?> - + diff --git a/server_files/syntheses.php b/server_files/syntheses.php index 4c720d8..96441d7 100644 --- a/server_files/syntheses.php +++ b/server_files/syntheses.php @@ -1,9 +1,9 @@ - + Il est trop tôt pour se préoccuper des notes de synthèse, attendez le tirage des poules."; - include "footer.php"; + require_once "footer.php"; } if (isset($error_message)) { @@ -120,4 +120,4 @@ while (($data = $syntheses_req->fetch()) !== false) { } ?> - + diff --git a/server_files/syntheses_orga.php b/server_files/syntheses_orga.php index 6e336b6..1e5b1d2 100644 --- a/server_files/syntheses_orga.php +++ b/server_files/syntheses_orga.php @@ -1,9 +1,9 @@ - + - + fetch()) !== false) { } ?> - + diff --git a/server_files/tournoi.php b/server_files/tournoi.php index 4855e01..4645ab4 100644 --- a/server_files/tournoi.php +++ b/server_files/tournoi.php @@ -1,6 +1,6 @@ execute([$tournament_name]); $data = $response->fetch(); if ($data === false) - include "404.php"; + 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 = []; @@ -20,7 +20,7 @@ while (($orga_data = $orgas_req->fetch()) !== false) { } if (isset($_GET["modifier"]) && $_SESSION["role"] != "ADMIN" && !in_array($_SESSION["user_id"], $orgas_id)) - include "403.php"; + require_once "403.php"; if (isset($_POST["edit_tournament"])) { $error_message = updateTournament(); @@ -130,7 +130,7 @@ function updateTournament() { ?> - +

Tournoi de

@@ -356,4 +356,4 @@ else { } ?> - \ No newline at end of file + \ No newline at end of file diff --git a/server_files/tournois.php b/server_files/tournois.php index 5d33359..5f160db 100644 --- a/server_files/tournois.php +++ b/server_files/tournois.php @@ -1,6 +1,6 @@ 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`;"); @@ -8,7 +8,7 @@ $final_data = $DB->query("SELECT `name`, `date_start`, `date_end`, `date_solutio ?> - +

Liste des tournois

@@ -55,4 +55,4 @@ $final_data = $DB->query("SELECT `name`, `date_start`, `date_end`, `date_solutio - \ No newline at end of file + \ No newline at end of file diff --git a/server_files/view_file.php b/server_files/view_file.php index 3acf2fe..5b8fa4c 100644 --- a/server_files/view_file.php +++ b/server_files/view_file.php @@ -1,6 +1,6 @@