diff --git a/.htaccess b/.htaccess
index 7f2d8b2..12806a1 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,28 +1,7 @@
-ErrorDocument 403 /tfjm/403.php
-ErrorDocument 404 /tfjm/404.php
+ErrorDocument 403 /tfjm/server_files/403.php
+ErrorDocument 404 /tfjm/server_files/404.php
Options +FollowSymlinks
-# Options -Indexes
+Options -Indexes
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 ^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]
+RewriteRule ^(.*)$ dispatcher.php?path=$1 [QSA,L]
diff --git a/favicon.ico b/assets/favicon.ico
similarity index 100%
rename from favicon.ico
rename to assets/favicon.ico
diff --git a/logo.svg b/assets/logo.svg
similarity index 100%
rename from logo.svg
rename to assets/logo.svg
diff --git a/style.css b/assets/style.css
similarity index 100%
rename from style.css
rename to assets/style.css
diff --git a/dispatcher.php b/dispatcher.php
new file mode 100644
index 0000000..68f1947
--- /dev/null
+++ b/dispatcher.php
@@ -0,0 +1,68 @@
+ $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";
diff --git a/index.html b/index.html
index 57acf64..da8c197 100644
--- a/index.html
+++ b/index.html
@@ -1 +1,12 @@
-Le mod Rewrite n'est pas activé.
\ No newline at end of file
+
+
+
+
+
+ Erreur
+
+
+
+Le mode Rewrite n'est pas activé.
+
+
\ No newline at end of file
diff --git a/server_files/classes/Team.php b/server_files/classes/Team.php
index 377c94e..53e29a1 100644
--- a/server_files/classes/Team.php
+++ b/server_files/classes/Team.php
@@ -1,7 +1,5 @@
query("SELECT `id`, `name` FROM `tournaments` WHERE `date_inscription` > CURRENT_DATE AND `year` = '$YEAR';");
@@ -62,6 +60,4 @@ function registerTeam() {
return false;
}
-require_once "../views/header.php";
-require_once "../views/ajouter_equipe.php";
-require_once "../views/footer.php";
+require_once "server_files/views/ajouter_equipe.php";
diff --git a/server_files/controllers/ajouter_organisateur.php b/server_files/controllers/ajouter_organisateur.php
index 3300334..ebf5cce 100644
--- a/server_files/controllers/ajouter_organisateur.php
+++ b/server_files/controllers/ajouter_organisateur.php
@@ -1,9 +1,7 @@
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;
}
-require_once "../views/header.php";
-require_once "../views/ajouter_tournoi.php";
-require_once "../views/footer.php";
+require_once "server_files/views/ajouter_tournoi.php";
diff --git a/server_files/controllers/confirmer_mail.php b/server_files/controllers/confirmer_mail.php
index 484a024..abe2e58 100644
--- a/server_files/controllers/confirmer_mail.php
+++ b/server_files/controllers/confirmer_mail.php
@@ -1,7 +1,5 @@
$error_message";
-require_once "../views/footer.php";
+require_once "server_files/views/footer.php";
diff --git a/server_files/controllers/connexion.php b/server_files/controllers/connexion.php
index dda3d3e..41f14f7 100644
--- a/server_files/controllers/connexion.php
+++ b/server_files/controllers/connexion.php
@@ -1,7 +1,5 @@
Déconnexion réussie !";
-require_once "../views/footer.php";
+require_once "server_files/views/footer.php";
diff --git a/server_files/controllers/equipe.php b/server_files/controllers/equipe.php
index 40364aa..3e584e0 100644
--- a/server_files/controllers/equipe.php
+++ b/server_files/controllers/equipe.php
@@ -1,16 +1,14 @@
setValidationStatus(ValidationStatus::VALIDATED);
@@ -73,6 +71,4 @@ if ($team->isSelectedForFinal()) {
$tournament = Tournament::fromId($team->getTournamentId());
-require_once "../views/header.php";
-require_once "../views/equipe.php";
-require_once "../views/footer.php";
+require_once "server_files/views/equipe.php";
diff --git a/server_files/controllers/index.php b/server_files/controllers/index.php
index 254491b..a884dca 100644
--- a/server_files/controllers/index.php
+++ b/server_files/controllers/index.php
@@ -1,6 +1,3 @@
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) {
- require_once "../404.php";
+ require_once "server_files/404.php";
}
$team = Team::fromId($user->getTeamId());
@@ -22,6 +20,4 @@ $team = Team::fromId($user->getTeamId());
$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";
+require_once "server_files/views/informations.php";
diff --git a/server_files/controllers/inscription.php b/server_files/controllers/inscription.php
index 54101e4..5b39e6a 100644
--- a/server_files/controllers/inscription.php
+++ b/server_files/controllers/inscription.php
@@ -1,7 +1,5 @@
execute([$_SESSION["user_id"], $_SESSION[$team->isSelectedForFinal() ? $_SESSION["final"]->getId() : $tournament->getId()]]);
}
else
- require_once "../403.php";
+ require_once "server_files/403.php";
if (isset($_POST["team_edit"])) {
$error_message = updateTeam();
@@ -158,6 +156,4 @@ function checkCanValidate()
return $can_validate;
}
-require_once "../views/header.php";
-require_once "../views/mon_equipe.php";
-require_once "../views/footer.php";
+require_once "server_files/views/mon_equipe.php";
diff --git a/server_files/controllers/rejoindre_equipe.php b/server_files/controllers/rejoindre_equipe.php
index bc41129..8ae550e 100644
--- a/server_files/controllers/rejoindre_equipe.php
+++ b/server_files/controllers/rejoindre_equipe.php
@@ -1,9 +1,7 @@
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;");
-$solutions_req->execute([$_SESSION["team_id"], $_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]);
+/** @var Team $team */
+$team = $_SESSION["team"];
-$tournament_req = $DB->prepare("SELECT `date_solutions` FROM `tournaments` WHERE `id` = ?;");
-$tournament_req->execute([$_SESSION[isset($_SESSION["final_id"]) ? "final_id" : "tournament_id"]]);
-$tournament_data = $tournament_req->fetch();
+$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;");
+$solutions_req->execute([$team->getId(), $_SESSION[$team->isSelectedForFinal() ? $_SESSION["final"]->getId() : $team->getTournamentId()]]);
+
+$tournament = Tournament::fromId($team->isSelectedForFinal() ? $_SESSION["final"]->getId() : $team->getTournamentId());
function saveSolution() {
global $LOCAL_PATH, $DB;
@@ -58,6 +57,4 @@ function saveSolution() {
return false;
}
-require_once "../views/header.php";
-require_once "../views/solutions.php";
-require_once "../views/footer.php";
+require_once "server_files/views/solutions.php";
diff --git a/server_files/controllers/solutions_orga.php b/server_files/controllers/solutions_orga.php
index b1054d8..c049dba 100644
--- a/server_files/controllers/solutions_orga.php
+++ b/server_files/controllers/solutions_orga.php
@@ -1,9 +1,7 @@
query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
@@ -47,7 +45,7 @@ if (isset($_POST["download_zip"])) {
exit();
}
-require_once "../views/header.php";
+require_once "server_files/views/header.php";
while (($data_tournament = $req->fetch()) !== false) {
echo "Tournoi de " . $data_tournament["name"] . "
\n";
@@ -72,4 +70,4 @@ while (($data_tournament = $req->fetch()) !== false) {
echo "
\n";
}
-require_once "../views/footer.php";
+require_once "server_files/views/footer.php";
diff --git a/server_files/controllers/syntheses.php b/server_files/controllers/syntheses.php
index 4c39972..06f78b0 100644
--- a/server_files/controllers/syntheses.php
+++ b/server_files/controllers/syntheses.php
@@ -1,20 +1,19 @@
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"]]);
+/** @var Team $team */
+$team = $_SESSION["team"];
-$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();
+$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->getId(), $_SESSION[$team->isSelectedForFinal() ? $_SESSION["final"]->getId() : $team->getTournamentId()]]);
+
+$tournament = Tournament::fromId($team->isSelectedForFinal() ? $_SESSION["final"]->getId() : $team->getTournamentId());
function saveSynthese() {
global $LOCAL_PATH, $DB;
@@ -54,6 +53,4 @@ function saveSynthese() {
return false;
}
-require_once "../views/header.php";
-require_once "../views/syntheses.php";
-require_once "../views/footer.php";
+require_once "server_files/views/syntheses.php";
diff --git a/server_files/controllers/syntheses_orga.php b/server_files/controllers/syntheses_orga.php
index 6841076..f8f852b 100644
--- a/server_files/controllers/syntheses_orga.php
+++ b/server_files/controllers/syntheses_orga.php
@@ -1,7 +1,5 @@
-query("SELECT `tournaments`.`id`, `name` FROM `tournaments` JOIN `organizers` ON `tournament` = `tournaments`.`id` WHERE "
. ($_SESSION["role"] == Role::ADMIN ? "" : "`organizer` = '" . $_SESSION["user_id"] . "' AND ")
@@ -69,4 +67,4 @@ while (($data_tournament = $req->fetch()) !== false) {
echo "
\n";
}
-require_once '../views/footer.php';
+require_once "server_files/views/footer.php";
diff --git a/server_files/controllers/tournoi.php b/server_files/controllers/tournoi.php
index 7fbafce..43010f5 100644
--- a/server_files/controllers/tournoi.php
+++ b/server_files/controllers/tournoi.php
@@ -1,13 +1,11 @@
query("SELECT `users`.`id` AS `id` FROM `users` JOIN `organizers` ON `users`.`id` = `organizer` WHERE `tournament` = " . $tournament->getId() . ";");
$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))
- require_once "../403.php";
+ require_once "server_files/403.php";
if (isset($_POST["edit_tournament"])) {
$error_message = updateTournament();
@@ -123,6 +121,4 @@ function updateTournament() {
exit();
}
-require_once "../views/header.php";
-require_once "../views/tournoi.php";
-require_once "../views/footer.php";
+require_once "server_files/views/tournoi.php";
diff --git a/server_files/controllers/tournois.php b/server_files/controllers/tournois.php
index a12ff7c..ce23d82 100644
--- a/server_files/controllers/tournois.php
+++ b/server_files/controllers/tournois.php
@@ -1,11 +1,7 @@
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";
+require_once "server_files/views/tournois.php";
diff --git a/server_files/controllers/view_file.php b/server_files/controllers/view_file.php
index 0ce1807..5b14be0 100644
--- a/server_files/controllers/view_file.php
+++ b/server_files/controllers/view_file.php
@@ -1,14 +1,12 @@
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
}
@@ -49,7 +47,7 @@ if ($data !== false) {
$user = User::fromId($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
@@ -70,7 +68,7 @@ if ($data !== false) {
}
}
else {
- require_once "../404.php";
+ require_once "server_files/404.php";
http_response_code(404);
exit();
}
diff --git a/server_files/views/ajouter_equipe.php b/server_files/views/ajouter_equipe.php
index d63ec03..c74842b 100644
--- a/server_files/views/ajouter_equipe.php
+++ b/server_files/views/ajouter_equipe.php
@@ -1,4 +1,7 @@
-
+
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 : = $access_code ?>
@@ -48,4 +51,6 @@
-
\ No newline at end of file
+
+
+
diff --git a/server_files/views/ajouter_organisateur.php b/server_files/views/ajouter_organisateur.php
index f17603e..ea647eb 100644
--- a/server_files/views/ajouter_organisateur.php
+++ b/server_files/views/ajouter_organisateur.php
@@ -1,4 +1,6 @@
Erreur : " . $error_message . "";
@@ -51,3 +53,5 @@ if (isset($error_message)) {
+
+
diff --git a/server_files/views/ajouter_tournoi.php b/server_files/views/ajouter_tournoi.php
index cc8d84f..d62116a 100644
--- a/server_files/views/ajouter_tournoi.php
+++ b/server_files/views/ajouter_tournoi.php
@@ -1,4 +1,7 @@
-Erreur : " . $error_message . "";
} else {
@@ -118,4 +121,6 @@
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/server_files/views/connexion.php b/server_files/views/connexion.php
index 647e99e..7ec97c4 100644
--- a/server_files/views/connexion.php
+++ b/server_files/views/connexion.php
@@ -1,6 +1,9 @@
-Erreur : " . $error_message . ""; ?>
-
Erreur : " . $error_message . "";
+
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é.";
@@ -89,4 +92,6 @@ else if (isset($_SESSION["user_id"])) { ?>
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/server_files/views/equipe.php b/server_files/views/equipe.php
index a19b3f2..346f6f4 100644
--- a/server_files/views/equipe.php
+++ b/server_files/views/equipe.php
@@ -1,3 +1,5 @@
+
+
Informations sur l'équipe
Nom de l'équipe : = $team->getName() ?>
@@ -90,4 +92,6 @@ if (!$team->isSelectedForFinal() && isset($_SESSION["user_id"]) && $_SESSION["ro
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/server_files/views/header.php b/server_files/views/header.php
index 5917855..e8cabc2 100644
--- a/server_files/views/header.php
+++ b/server_files/views/header.php
@@ -22,7 +22,7 @@