1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 17:02:28 +00:00

Utilisation d'un dispatcher pour gérer les redirections

This commit is contained in:
galaxyoyo 2019-09-07 13:42:36 +02:00
parent ae648d7615
commit 4d3f6d1847
45 changed files with 246 additions and 190 deletions

View File

@ -1,28 +1,7 @@
ErrorDocument 403 /tfjm/403.php ErrorDocument 403 /tfjm/server_files/403.php
ErrorDocument 404 /tfjm/404.php ErrorDocument 404 /tfjm/server_files/404.php
Options +FollowSymlinks Options +FollowSymlinks
# Options -Indexes Options -Indexes
RewriteEngine On RewriteEngine On
RewriteOptions Inherit RewriteRule ^(.*)$ dispatcher.php?path=$1 [QSA,L]
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 ^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 ^inscription$ server_files/inscription.php [L]
RewriteRule ^mon_compte$ server_files/mon_compte.php [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 [L]
RewriteRule ^tournois$ server_files/tournois.php [L]

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

68
dispatcher.php Normal file
View File

@ -0,0 +1,68 @@
<?php
require_once "server_files/config.php";
require_once "server_files/model.php";
require_once "server_files/classes/Role.php";
require_once "server_files/classes/Team.php";
require_once "server_files/classes/Tournament.php";
require_once "server_files/classes/User.php";
require_once "server_files/classes/ValidationStatus.php";
loadUserValues();
if (!isset($_GET["path"]))
require_once "server_files/403.php";
$path = $_GET["path"];
$ROUTES = [];
# URL paths
$ROUTES["^(|accueil|index|accueil\.php|accueil\.html|accueil\.py|index\.php|index\.html|index\.py)$"] = ["server_files/controllers/index.php"];
$ROUTES["^ajouter_equipe$"] = ["server_files/controllers/ajouter_equipe.php"];
$ROUTES["^ajouter_organisateur$"] = ["server_files/controllers/ajouter_organisateur.php"];
$ROUTES["^ajouter_tournoi$"] = ["server_files/controllers/ajouter_tournoi.php"];
$ROUTES["^confirmer_mail/([a-z0-9]*)/?$"] = ["server_files/controllers/confirmer_mail.php", "token"];
$ROUTES["^connexion/?$"] = ["server_files/controllers/connexion.php"];
$ROUTES["^deconnexion/?$"] = ["server_files/controllers/deconnexion.php"];
$ROUTES["^equipe/([A-Z]{3})/?$"] = ["server_files/controllers/equipe.php", "trigram"];
$ROUTES["^file/[a-z0-9]{64}/?$"] = ["server_files/controllers/view_file.php", "file_id"];
$ROUTES["^informations/([0-9]*)/.*?$"] = ["server_files/controllers/informations.php", "id"];
$ROUTES["^inscription/?$"] = ["server_files/controllers/inscription.php"];
$ROUTES["^mon_compte/?$"] = ["server_files/controllers/mon_compte.php"];
$ROUTES["^mon_equipe/(modifier)/?$"] = ["server_files/controllers/mon_equipe.php", "modifier"];
$ROUTES["^mon_equipe/?$"] = ["server_files/controllers/mon_equipe.php"];
$ROUTES["^rejoindre_equipe/?$"] = ["server_files/controllers/rejoindre_equipe.php"];
$ROUTES["^solutions/?$"] = ["server_files/controllers/solutions.php"];
$ROUTES["^solutions_orga/?$"] = ["server_files/controllers/solutions_orga.php"];
$ROUTES["^syntheses/?$"] = ["server_files/controllers/syntheses.php"];
$ROUTES["^syntheses_orga/?$"] = ["server_files/controllers/syntheses_orga.php"];
$ROUTES["^tournoi/(.*)/?$"] = ["server_files/controllers/tournoi.php", "name"];
$ROUTES["^tournois/?$"] = ["server_files/controllers/tournois.php"];
# Assets files
$ROUTES["^favicon\.ico$"] = ["assets/favicon.ico", "image/x-icon"];
$ROUTES["^logo\.svg$"] = ["assets/logo.svg", "image/svg+xml"];
$ROUTES["^style\.css$"] = ["assets/style.css", "text/css"];
foreach ($ROUTES as $route => $file) {
if (preg_match('#' . $route . '#', $path, $matches)) {
for ($i = 1; $i < sizeof($file); ++$i)
$_GET[$file[$i]] = $matches[$i];
if (!preg_match("#php$#", $file[0])) {
header("Content-Type: " . $matches[1]);
readfile($file[0]);
exit();
}
/** @noinspection PhpIncludeInspection */
require $file[0];
exit();
}
}
require_once "server_files/404.php";

View File

@ -1 +1,12 @@
Le mod Rewrite n'est pas activé. <!doctype html>
<html lang="fr">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Erreur</title>
</head>
<body>
Le mode <i>Rewrite</i> n'est pas activé.
</body>
</html>

View File

@ -1,7 +1,5 @@
<?php <?php
require_once "../config.php";
class Team class Team
{ {
private $id; private $id;

View File

@ -1,7 +1,5 @@
<?php <?php
require_once "../config.php";
class Tournament class Tournament
{ {
private $id; private $id;

View File

@ -1,7 +1,5 @@
<?php <?php
require_once "../config.php";
class User class User
{ {
private $id; private $id;

View File

@ -1,9 +1,7 @@
<?php <?php
require_once "../config.php";
if (!isset($_SESSION["role"]) || ($_SESSION["role"] != Role::PARTICIPANT && $_SESSION["role"] != Role::ENCADRANT)) if (!isset($_SESSION["role"]) || ($_SESSION["role"] != Role::PARTICIPANT && $_SESSION["role"] != Role::ENCADRANT))
require_once "../403.php"; require_once "server_files/403.php";
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `date_inscription` > CURRENT_DATE AND `year` = '$YEAR';"); $tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `date_inscription` > CURRENT_DATE AND `year` = '$YEAR';");
@ -62,6 +60,4 @@ function registerTeam() {
return false; return false;
} }
require_once "../views/header.php"; require_once "server_files/views/ajouter_equipe.php";
require_once "../views/ajouter_equipe.php";
require_once "../views/footer.php";

View File

@ -1,9 +1,7 @@
<?php <?php
require_once "../config.php";
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN) if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN)
require_once "../403.php"; require_once "server_files/403.php";
if (isset($_POST["submitted"])) { if (isset($_POST["submitted"])) {
$error_message = addOrganizer(); $error_message = addOrganizer();
@ -59,6 +57,4 @@ function addOrganizer()
return false; return false;
} }
require_once "../views/header.php"; require_once "server_files/views/ajouter_organisateur.php";
require_once "../views/ajouter_organisateur.php";
require_once "../views/footer.php";

View File

@ -1,9 +1,7 @@
<?php <?php
require_once "../config.php";
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN) if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN)
require_once "../403.php"; require_once "server_files/403.php";
$orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';"); $orgas_response = $DB->query("SELECT `id`, `surname`, `first_name` FROM `users` WHERE (`role` = 'ORGANIZER' OR `role` = 'ADMIN') AND `year` = '$YEAR';");
@ -109,6 +107,4 @@ function registerTournament() {
return false; return false;
} }
require_once "../views/header.php"; require_once "server_files/views/ajouter_tournoi.php";
require_once "../views/ajouter_tournoi.php";
require_once "../views/footer.php";

View File

@ -1,7 +1,5 @@
<?php <?php
require_once "../config.php";
$token = $_GET["token"]; $token = $_GET["token"];
if (isset($token)) { if (isset($token)) {
@ -16,6 +14,6 @@ if (isset($token)) {
else { else {
$error_message = "Il n'y a pas de compte à valider !"; $error_message = "Il n'y a pas de compte à valider !";
} }
require_once "../views/header.php"; require_once "server_files/views/header.php";
echo "<h2>$error_message</h2>"; echo "<h2>$error_message</h2>";
require_once "../views/footer.php"; require_once "server_files/views/footer.php";

View File

@ -1,7 +1,5 @@
<?php <?php
require_once "../config.php";
if (isset($_POST["submitted"]) && !isset($_SESSION["user_id"])) { if (isset($_POST["submitted"]) && !isset($_SESSION["user_id"])) {
$error_message = login(); $error_message = login();
} }
@ -132,6 +130,4 @@ function sendConfirmEmail() {
return false; return false;
} }
require_once "../views/header.php"; require_once "server_files/views/connexion.php";
require_once "../views/connexion.php";
require_once "../views/footer.php";

View File

@ -1,10 +1,8 @@
<?php <?php
require_once "../config.php";
unset($_SESSION["user_id"]); unset($_SESSION["user_id"]);
session_destroy(); session_destroy();
require_once "../views/header.php"; require_once "server_files/views/header.php";
echo "<h2>Déconnexion réussie !</h2>"; echo "<h2>Déconnexion réussie !</h2>";
require_once "../views/footer.php"; require_once "server_files/views/footer.php";

View File

@ -1,16 +1,14 @@
<?php <?php
require_once "../config.php";
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN) if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN)
require_once "../403.php"; require_once "server_files/403.php";
$trigram = htmlspecialchars($_GET["trigram"]); $trigram = htmlspecialchars($_GET["trigram"]);
$team = Team::fromTrigram($trigram); $team = Team::fromTrigram($trigram);
if ($team === null) if ($team === null)
require_once "../404.php"; require_once "server_files/404.php";
if (isset($_POST["validate"])) { if (isset($_POST["validate"])) {
$team->setValidationStatus(ValidationStatus::VALIDATED); $team->setValidationStatus(ValidationStatus::VALIDATED);
@ -73,6 +71,4 @@ if ($team->isSelectedForFinal()) {
$tournament = Tournament::fromId($team->getTournamentId()); $tournament = Tournament::fromId($team->getTournamentId());
require_once "../views/header.php"; require_once "server_files/views/equipe.php";
require_once "../views/equipe.php";
require_once "../views/footer.php";

View File

@ -1,6 +1,3 @@
<?php <?php
require_once "../config.php"; require_once "server_files/views/index.php";
require_once "../views/header.php";
require_once "../views/index.php";
require_once "../views/footer.php";

View File

@ -1,20 +1,18 @@
<?php <?php
require_once "../config.php";
if (!isset($_SESSION["role"])) if (!isset($_SESSION["role"]))
require_once "../403.php"; require_once "server_files/403.php";
$id = $_GET["id"]; $id = $_GET["id"];
$user = User::fromId($id); $user = User::fromId($id);
if ($_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN) { if ($_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN) {
if ($user->getId() != $_SESSION["user_id"] && ($user->getTeamId() == null || $user->getTeamId() != $_SESSION["user"]->getTeamId())) if ($user->getId() != $_SESSION["user_id"] && ($user->getTeamId() == null || $user->getTeamId() != $_SESSION["user"]->getTeamId()))
require_once "../403.php"; require_once "server_files/403.php";
} }
if ($user === null) { if ($user === null) {
require_once "../404.php"; require_once "server_files/404.php";
} }
$team = Team::fromId($user->getTeamId()); $team = Team::fromId($user->getTeamId());
@ -22,6 +20,4 @@ $team = Team::fromId($user->getTeamId());
$documents_req = $DB->query("SELECT * FROM `documents` WHERE `user` = $id;"); $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`;"); $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 "server_files/views/informations.php";
require_once "../views/informations.php";
require_once "../views/footer.php";

View File

@ -1,7 +1,5 @@
<?php <?php
require_once "../config.php";
if (isset($_POST["submitted"])) { if (isset($_POST["submitted"])) {
$error_message = register(); $error_message = register();
} }
@ -128,6 +126,4 @@ function register() {
return false; return false;
} }
require_once "../views/header.php"; require_once "server_files/views/inscription.php";
require_once "../views/inscription.php";
require_once "../views/footer.php";

View File

@ -1,7 +1,5 @@
<?php <?php
require_once "../config.php";
if (isset($_POST["submitted"])) { if (isset($_POST["submitted"])) {
$error_message = updateAccount(); $error_message = updateAccount();
} elseif (isset($_POST["submitted_password"])) { } elseif (isset($_POST["submitted_password"])) {
@ -9,7 +7,7 @@ if (isset($_POST["submitted"])) {
} }
if (!isset($_SESSION["user_id"])) if (!isset($_SESSION["user_id"]))
require_once "../403.php"; require_once "server_files/403.php";
/** @var User $user */ /** @var User $user */
$user = $_SESSION["user"]; $user = $_SESSION["user"];
@ -126,6 +124,4 @@ function updatePassword()
return false; return false;
} }
require_once "../views/header.php"; require_once "server_files/views/mon_compte.php";
require_once "../views/mon_compte.php";
require_once "../views/footer.php";

View File

@ -1,7 +1,5 @@
<?php <?php
require_once "../config.php";
if (isset($_POST["leave_team"])) { if (isset($_POST["leave_team"])) {
quitTeam(); quitTeam();
exit(); exit();
@ -30,7 +28,7 @@ if (isset($_SESSION["user_id"]) && isset($_SESSION["team"]) && $_SESSION["team"]
$documents_req->execute([$_SESSION["user_id"], $_SESSION[$team->isSelectedForFinal() ? $_SESSION["final"]->getId() : $tournament->getId()]]); $documents_req->execute([$_SESSION["user_id"], $_SESSION[$team->isSelectedForFinal() ? $_SESSION["final"]->getId() : $tournament->getId()]]);
} }
else else
require_once "../403.php"; require_once "server_files/403.php";
if (isset($_POST["team_edit"])) { if (isset($_POST["team_edit"])) {
$error_message = updateTeam(); $error_message = updateTeam();
@ -158,6 +156,4 @@ function checkCanValidate()
return $can_validate; return $can_validate;
} }
require_once "../views/header.php"; require_once "server_files/views/mon_equipe.php";
require_once "../views/mon_equipe.php";
require_once "../views/footer.php";

View File

@ -1,9 +1,7 @@
<?php <?php
require_once "../config.php";
if (isset($_SESSION["team"]) || !isset($_SESSION["user"]) || ($_SESSION["role"] != Role::PARTICIPANT && $_SESSION["role"] != Role::ENCADRANT)) if (isset($_SESSION["team"]) || !isset($_SESSION["user"]) || ($_SESSION["role"] != Role::PARTICIPANT && $_SESSION["role"] != Role::ENCADRANT))
require_once "../403.php"; require_once "server_files/403.php";
if (isset($_POST["submitted"])) { if (isset($_POST["submitted"])) {
$error_message = joinTeam(); $error_message = joinTeam();
@ -52,6 +50,4 @@ function joinTeam() {
return false; return false;
} }
require_once "../views/header.php"; require_once "server_files/views/rejoindre_equipe.php";
require_once "../views/rejoindre_equipe.php";
require_once "../views/footer.php";

View File

@ -1,20 +1,19 @@
<?php <?php
require_once "../config.php"; if (!isset($_SESSION["team"]))
require_once "server_files/403.php";
if (!isset($_SESSION["team_id"]))
require_once "../403.php";
if (isset($_POST["send_solution"])) { if (isset($_POST["send_solution"])) {
$error_message = saveSolution(); $error_message = saveSolution();
} }
$solutions_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;"); /** @var Team $team */
$solutions_req->execute([$_SESSION["team_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]); $team = $_SESSION["team"];
$tournament_req = $DB->prepare("SELECT `date_solutions` FROM `tournaments` WHERE `id` = ?;"); $solutions_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;");
$tournament_req->execute([$_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]); $solutions_req->execute([$team->getId(), $_SESSION[$team->isSelectedForFinal() ? $_SESSION["final"]->getId() : $team->getTournamentId()]]);
$tournament_data = $tournament_req->fetch();
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $_SESSION["final"]->getId() : $team->getTournamentId());
function saveSolution() { function saveSolution() {
global $LOCAL_PATH, $DB; global $LOCAL_PATH, $DB;
@ -58,6 +57,4 @@ function saveSolution() {
return false; return false;
} }
require_once "../views/header.php"; require_once "server_files/views/solutions.php";
require_once "../views/solutions.php";
require_once "../views/footer.php";

View File

@ -1,9 +1,7 @@
<?php <?php
require_once "../config.php";
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER) if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
require_once "../403.php"; require_once "server_files/403.php";
/** @noinspection SqlAggregates */ /** @noinspection SqlAggregates */
$req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE " $req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
@ -47,7 +45,7 @@ if (isset($_POST["download_zip"])) {
exit(); exit();
} }
require_once "../views/header.php"; require_once "server_files/views/header.php";
while (($data_tournament = $req->fetch()) !== false) { while (($data_tournament = $req->fetch()) !== false) {
echo "<h1>Tournoi de " . $data_tournament["name"] . "</h1>\n"; echo "<h1>Tournoi de " . $data_tournament["name"] . "</h1>\n";
@ -72,4 +70,4 @@ while (($data_tournament = $req->fetch()) !== false) {
echo "</form><hr />\n"; echo "</form><hr />\n";
} }
require_once "../views/footer.php"; require_once "server_files/views/footer.php";

View File

@ -1,20 +1,19 @@
<?php <?php
require_once "../config.php"; if (!isset($_SESSION["team"]))
require_once "server_files/403.php";
if (!isset($_SESSION["team_id"]))
require_once "../403.php";
if (isset($_POST["send_synthese"])) { if (isset($_POST["send_synthese"])) {
$error_message = saveSynthese(); $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;"); /** @var Team $team */
$syntheses_req->execute([$_SESSION["team_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]); $team = $_SESSION["team"];
$tournament_req = $DB->prepare("SELECT `date_solutions`, `date_syntheses` FROM `tournaments` WHERE `id` = ?;"); $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;");
$tournament_req->execute([$_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]); $syntheses_req->execute([$team->getId(), $_SESSION[$team->isSelectedForFinal() ? $_SESSION["final"]->getId() : $team->getTournamentId()]]);
$tournament_data = $tournament_req->fetch();
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $_SESSION["final"]->getId() : $team->getTournamentId());
function saveSynthese() { function saveSynthese() {
global $LOCAL_PATH, $DB; global $LOCAL_PATH, $DB;
@ -54,6 +53,4 @@ function saveSynthese() {
return false; return false;
} }
require_once "../views/header.php"; require_once "server_files/views/syntheses.php";
require_once "../views/syntheses.php";
require_once "../views/footer.php";

View File

@ -1,7 +1,5 @@
<?php require_once "../config.php"; <?php if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
require_once "server_files/403.php";
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
require_once "../403.php";
if (isset($_POST["download_zip"])) { if (isset($_POST["download_zip"])) {
$id = $_POST["tournament"]; $id = $_POST["tournament"];
@ -40,7 +38,7 @@ if (isset($_POST["download_zip"])) {
exit(); exit();
} }
require_once "../views/header.php"; require_once "server_files/views/header.php";
$req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE " $req = $DB->query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
. ($_SESSION["role"] == Role::ADMIN ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ") . ($_SESSION["role"] == Role::ADMIN ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
@ -69,4 +67,4 @@ while (($data_tournament = $req->fetch()) !== false) {
echo "</form><hr />\n"; echo "</form><hr />\n";
} }
require_once '../views/footer.php'; require_once "server_files/views/footer.php";

View File

@ -1,13 +1,11 @@
<?php <?php
require_once "../config.php"; $tournament_name = htmlspecialchars($_GET["name"]);
$tournament_name = htmlspecialchars($_GET["nom"]);
$tournament = Tournament::fromName($tournament_name); $tournament = Tournament::fromName($tournament_name);
if ($tournament === null) if ($tournament === null)
require_once "../404.php"; require_once "server_files/404.php";
$orgas_req = $DB->query("SELECT `users`.`id` AS `id` FROM `users` JOIN `organizers` ON `users`.`id` = `organizer` WHERE `tournament` = " . $tournament->getId() . ";"); $orgas_req = $DB->query("SELECT `users`.`id` AS `id` FROM `users` JOIN `organizers` ON `users`.`id` = `organizer` WHERE `tournament` = " . $tournament->getId() . ";");
$orgas = []; $orgas = [];
@ -18,7 +16,7 @@ while (($orga_data = $orgas_req->fetch()) !== false) {
} }
if (isset($_GET["modifier"]) && $_SESSION["role"] != Role::ADMIN && !in_array($_SESSION["user_id"], $orgas_id)) if (isset($_GET["modifier"]) && $_SESSION["role"] != Role::ADMIN && !in_array($_SESSION["user_id"], $orgas_id))
require_once "../403.php"; require_once "server_files/403.php";
if (isset($_POST["edit_tournament"])) { if (isset($_POST["edit_tournament"])) {
$error_message = updateTournament(); $error_message = updateTournament();
@ -123,6 +121,4 @@ function updateTournament() {
exit(); exit();
} }
require_once "../views/header.php"; require_once "server_files/views/tournoi.php";
require_once "../views/tournoi.php";
require_once "../views/footer.php";

View File

@ -1,11 +1,7 @@
<?php <?php
require_once "../config.php";
$response = $DB->query("SELECT `name`, `date_start`, `date_end`, `date_inscription`, `date_solutions`, `size` FROM `tournaments` $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`;"); 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(); $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 "server_files/views/tournois.php";
require_once "../views/tournois.php";
require_once "../views/footer.php";

View File

@ -1,14 +1,12 @@
<?php <?php
require_once "../config.php";
if (!isset($_GET["file_id"])) { if (!isset($_GET["file_id"])) {
header("Location: $URL_BASE"); header("Location: $URL_BASE");
exit(); exit();
} }
if (!isset($_SESSION["user_id"])) if (!isset($_SESSION["user_id"]))
require_once "../403.php"; require_once "server_files/403.php";
$id = htmlspecialchars($_GET["file_id"]); $id = htmlspecialchars($_GET["file_id"]);
$type = "SOLUTION"; $type = "SOLUTION";
@ -34,7 +32,7 @@ if ($data !== false) {
$name = "Problème $problem $trigram.pdf"; $name = "Problème $problem $trigram.pdf";
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId())) if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId()))
require_once "../403.php"; require_once "server_files/403.php";
// TODO Seuls les organisateurs concernés doivent pouvoir télécharger les fichiers // TODO Seuls les organisateurs concernés doivent pouvoir télécharger les fichiers
} }
@ -49,7 +47,7 @@ if ($data !== false) {
$user = User::fromId($user_id); $user = User::fromId($user_id);
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && $user_id != $_SESSION["user_id"]) if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && $user_id != $_SESSION["user_id"])
require_once "../403.php"; require_once "server_files/403.php";
// TODO Seuls les organisateurs concernés doivent pouvoir télécharger les fichiers // TODO Seuls les organisateurs concernés doivent pouvoir télécharger les fichiers
@ -70,7 +68,7 @@ if ($data !== false) {
} }
} }
else { else {
require_once "../404.php"; require_once "server_files/404.php";
http_response_code(404); http_response_code(404);
exit(); exit();
} }

View File

@ -1,4 +1,7 @@
<?php if ($_SESSION["team"] != NULL) { ?> <?php
require_once "header.php";
if ($_SESSION["team"] != NULL) { ?>
<h2>Vous êtes déjà dans une équipe.</h2> <h2>Vous êtes déjà dans une équipe.</h2>
<?php } else if (isset($access_code)) { ?> <?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><?= $access_code ?></strong> Votre équipe a bien été créée ! Voici le code d'accès à transmettre aux autres membres de votre équipe : <strong><?= $access_code ?></strong>
@ -49,3 +52,5 @@
</table> </table>
</form> </form>
<?php } ?> <?php } ?>
<?php require_once "footer.php" ?>

View File

@ -1,4 +1,6 @@
<?php <?php
require_once "header.php";
if (isset($error_message)) { if (isset($error_message)) {
if ($error_message !== false) { if ($error_message !== false) {
echo "<h2>Erreur : " . $error_message . "</h2>"; echo "<h2>Erreur : " . $error_message . "</h2>";
@ -51,3 +53,5 @@ if (isset($error_message)) {
</tbody> </tbody>
</table> </table>
</form> </form>
<?php require_once "footer.php" ?>

View File

@ -1,4 +1,7 @@
<?php if (isset($error_message)) { <?php
require_once "header.php";
if (isset($error_message)) {
if ($error_message !== false) { if ($error_message !== false) {
echo "<h2>Erreur : " . $error_message . "</h2>"; echo "<h2>Erreur : " . $error_message . "</h2>";
} else { } else {
@ -119,3 +122,5 @@
</tbody> </tbody>
</table> </table>
</form> </form>
<?php require_once "footer.php" ?>

View File

@ -1,6 +1,9 @@
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?>
<?php <?php
require_once "header.php";
if (isset($error_message) && $error_message)
echo "<h2>Erreur : " . $error_message . "</h2>";
if (isset($error_message) && $error_message === FALSE) { if (isset($error_message) && $error_message === FALSE) {
if (isset($_GET["mdp_oublie"])) if (isset($_GET["mdp_oublie"]))
echo "Le mail de récupération de mot de passe a bien été envoyé."; echo "Le mail de récupération de mot de passe a bien été envoyé.";
@ -90,3 +93,5 @@ else if (isset($_SESSION["user_id"])) { ?>
</form> </form>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
<?php require_once "footer.php" ?>

View File

@ -1,3 +1,5 @@
<?php require_once "header.php" ?>
<h2>Informations sur l'équipe</h2> <h2>Informations sur l'équipe</h2>
Nom de l'équipe : <?= $team->getName() ?><br /> Nom de l'équipe : <?= $team->getName() ?><br />
@ -91,3 +93,5 @@ if (!$team->isSelectedForFinal() && isset($_SESSION["user_id"]) && $_SESSION["ro
<input style="width: 100%;" type="submit" name="select" value="Sélectionner pour la finale nationale" /> <input style="width: 100%;" type="submit" name="select" value="Sélectionner pour la finale nationale" />
</form> </form>
<?php } ?> <?php } ?>
<?php require_once "footer.php" ?>

View File

@ -22,7 +22,7 @@
<body> <body>
<ul id="menu"> <ul id="menu">
<li id="menu-logo"><img src="<?= $URL_BASE ?>/logo.svg" alt="logo tfjm"></li> <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 ?>/">Accueil</a></li>
<li><a href="<?= $URL_BASE ?>/tournois">Liste des tournois</a></li> <li><a href="<?= $URL_BASE ?>/tournois">Liste des tournois</a></li>
<?php if (!isset($_SESSION["user_id"])) { ?> <?php if (!isset($_SESSION["user_id"])) { ?>
@ -55,16 +55,16 @@
<hr /> <hr />
<?php <?php
if ($_SESSION["role"] != Role::ADMIN) { if ($_SESSION["role"] != Role::ADMIN) {
echo "<li><a href=\"?be-admin=1\">Devenir administrateur</a></li>"; echo "<li><a href=\"?be-admin=1\">Devenir administrateur</a></li>\n";
} }
if ($_SESSION["role"] != Role::ORGANIZER) { if ($_SESSION["role"] != Role::ORGANIZER) {
echo "<li><a href=\"?be-organizer=1\">Devenir organisateur</a></li>"; echo "<li><a href=\"?be-organizer=1\">Devenir organisateur</a></li>\n";
} }
if ($_SESSION["role"] != Role::PARTICIPANT) { if ($_SESSION["role"] != Role::PARTICIPANT) {
echo "<li><a href=\"?be-participant=1\">Devenir participant</a></li>"; echo "<li><a href=\"?be-participant=1\">Devenir participant</a></li>\n";
} }
if ($_SESSION["role"] != Role::ENCADRANT) { if ($_SESSION["role"] != Role::ENCADRANT) {
echo "<li><a href=\"?be-encadrant=1\">Devenir encadrant</a></li>"; echo "<li><a href=\"?be-encadrant=1\">Devenir encadrant</a></li>\n";
} }
?> ?>
<?php } ?> <?php } ?>

View File

@ -1,3 +1,5 @@
<?php require_once "header.php" ?>
<div class="container-fluid"> <div class="container-fluid">
@ -102,3 +104,5 @@
</div> </div>
<?php require_once "footer.php" ?>

View File

@ -1,3 +1,5 @@
<?php require_once "header.php" ?>
<h1><?= $user->getFirstName() . " " . $user->getSurname() ?></h1> <h1><?= $user->getFirstName() . " " . $user->getSurname() ?></h1>
<?php if ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) { ?> <?php if ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCADRANT) { ?>
@ -65,3 +67,5 @@ elseif ($user->getRole() == Role::PARTICIPANT || $user->getRole() == Role::ENCAD
echo "$name de $first_name $surname : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />"; echo "$name de $first_name $surname : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
} }
} }
require_once "footer.php";

View File

@ -1,4 +1,9 @@
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?> <?php
require_once "header.php";
if (isset($error_message) && $error_message)
echo "<h2>Erreur : " . $error_message . "</h2>";
?>
<?php <?php
if (isset($error_message) && $error_message === FALSE) { if (isset($error_message) && $error_message === FALSE) {
@ -141,3 +146,5 @@ if (isset($error_message) && $error_message === FALSE) {
</script> </script>
<?php } ?> <?php } ?>
<?php require_once "footer.php" ?>

View File

@ -1,4 +1,9 @@
<?php if (isset($error_message) && $error_message) echo "<h2>Erreur : " . $error_message . "</h2>"; ?> <?php
require_once "header.php";
if (isset($error_message) && $error_message)
echo "<h2>Erreur : " . $error_message . "</h2>";
?>
<?php <?php
if (isset($error_message) && $error_message === FALSE) { if (isset($error_message) && $error_message === FALSE) {
@ -171,3 +176,5 @@ if (isset($error_message) && $error_message === FALSE) {
</tr> </tr>
</table> </table>
</form> </form>
<?php require_once "footer.php" ?>

View File

@ -1,10 +1,14 @@
<?php if (isset($error_message)) { <?php
require_once "header.php";
if (isset($error_message)) {
if ($error_message !== false) { if ($error_message !== false) {
echo "<h2>Erreur : " . $error_message . "</h2>"; echo "<h2>Erreur : " . $error_message . "</h2>";
} else { } else {
echo "<h2>Le fichier a été correctement envoyé !</h2>"; echo "<h2>Le fichier a été correctement envoyé !</h2>";
} }
} ?> }
?>
<h2>Informations sur l'équipe</h2> <h2>Informations sur l'équipe</h2>
@ -164,3 +168,5 @@ Code d'accès : <strong><?= $team->getAccessCode() ?></strong><br/>
</table> </table>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
<?php require_once "footer.php" ?>

View File

@ -1,4 +1,7 @@
<?php if (isset($error_message) && $error_message === false) { ?> <?php
require_once "header.php" ;
if (isset($error_message) && $error_message === false) { ?>
Vous avez bien rejoint l'équipe <?= $_SESSION["team"]->getName() ?> ! Vous avez bien rejoint l'équipe <?= $_SESSION["team"]->getName() ?> !
<?php } else { ?> <?php } else { ?>
@ -26,3 +29,5 @@
</form> </form>
<?php } ?> <?php } ?>
<?php require_once "footer.php" ?>

View File

@ -1,4 +1,7 @@
<?php if (isset($error_message)) { <?php
require_once "header.php";
if (isset($error_message)) {
if ($error_message !== false) { if ($error_message !== false) {
echo "<h2>Erreur : " . $error_message . "</h2>"; echo "<h2>Erreur : " . $error_message . "</h2>";
} else { } else {
@ -6,7 +9,7 @@
} }
}?> }?>
<?php if (date("yyyy-mm-dd") < $tournament_data["date_solutions"]) { ?> <?php if (date("yyyy-mm-dd") < $tournament->getSolutionsDate()) { ?>
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000" /> <input type="hidden" name="MAX_FILE_SIZE" value="5000000" />
<table style="width: 100%;"> <table style="width: 100%;">
@ -54,5 +57,6 @@ while (($data = $solutions_req->fetch()) !== false) {
$version = $data["version"]; $version = $data["version"];
echo "Problème $problem (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />"; echo "Problème $problem (Version $version) : <a href=\"$URL_BASE/file/$file_id\">Télécharger</a><br />";
} }
?>
require_once "footer.php";

View File

@ -1,7 +1,9 @@
<?php <?php
if (date("yyyy-mm-dd") < $tournament_data["date_solutions"]) { require_once "header.php";
if (date("yyyy-mm-dd") < $tournament->getSolutionsDate()) {
echo "<h3>Il est trop tôt pour se préoccuper des notes de synthèse, attendez le tirage des poules.</h3>"; 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"; require_once "server_files/views/footer.php";
} }
if (isset($error_message)) { if (isset($error_message)) {
@ -13,7 +15,7 @@ if (isset($error_message)) {
} }
}?> }?>
<?php if (date("yyyy-mm-dd") < $tournament_data["date_syntheses"]) { ?> <?php if (date("yyyy-mm-dd") < $tournament->getSynthesesDate()) { ?>
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000" /> <input type="hidden" name="MAX_FILE_SIZE" value="5000000" />
<table style="width: 100%;"> <table style="width: 100%;">
@ -58,4 +60,5 @@ while (($data = $syntheses_req->fetch()) !== false) {
$version = $data["version"]; $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 />"; 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 />";
} }
?>
require_once "footer.php";

View File

@ -1,3 +1,5 @@
<?php require_once "header.php" ?>
<h2>Tournoi de <?= $tournament->getName() ?></h2> <h2>Tournoi de <?= $tournament->getName() ?></h2>
<strong>Organisateur<?= sizeof($orgas) >= 2 ? 's' : '' ?> :</strong> <strong>Organisateur<?= sizeof($orgas) >= 2 ? 's' : '' ?> :</strong>
@ -224,3 +226,5 @@ else {
</form> </form>
<?php } ?> <?php } ?>
<?php require_once "footer.php" ?>

View File

@ -1,3 +1,5 @@
<?php require_once "header.php" ?>
<h2>Liste des tournois</h2> <h2>Liste des tournois</h2>
<table style="border: 1px solid black; width: 100%"> <table style="border: 1px solid black; width: 100%">
@ -42,3 +44,5 @@
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
<?php require_once "footer.php" ?>