diff --git a/dispatcher.php b/dispatcher.php index 00de4bc..6849162 100644 --- a/dispatcher.php +++ b/dispatcher.php @@ -32,7 +32,7 @@ $ROUTES["^ajouter_organisateur$"] = ["server_files/controllers/ajouter_organisat $ROUTES["^ajouter_tournoi$"] = ["server_files/controllers/ajouter_tournoi.php"]; $ROUTES["^confirmer_mail/([a-z0-9]*)/?$"] = ["server_files/controllers/confirmer_mail.php", "token"]; $ROUTES["^connexion/(confirmation-mail)/?$"] = ["server_files/controllers/connexion.php", "confirmation-mail"]; -$ROUTES["^connexion/(mdp_oublie)/?$"] = ["server_files/controllers/connexion.php", "mdp_oublie"]; +$ROUTES["^connexion/(mdp-oublie)/?$"] = ["server_files/controllers/connexion.php", "mdp_oublie"]; $ROUTES["^connexion/(reinitialiser_mdp)/(.*)/?$"] = ["server_files/controllers/connexion.php", "reset_password", "token"]; $ROUTES["^connexion/?$"] = ["server_files/controllers/connexion.php"]; $ROUTES["^deconnexion/?$"] = ["server_files/controllers/deconnexion.php"]; diff --git a/server_files/controllers/mon_compte.php b/server_files/controllers/mon_compte.php index fa1b762..9d7998c 100644 --- a/server_files/controllers/mon_compte.php +++ b/server_files/controllers/mon_compte.php @@ -188,7 +188,8 @@ class SendDocument ensure($this->file["size"] <= 2e6, "Le fichier doit peser moins que 2 Mo."); ensure(!$this->file["error"], "Une erreur est survenue."); - ensure(finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]) == "application/pdf", "Le fichier doit être au format PDF."); + $mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]); + ensure($mime == "application/pdf" || $mime = "image/png" || $mime == "image/jpeg", "Le fichier doit être au format PDF."); ensure(is_dir("$LOCAL_PATH/files") || mkdir("$LOCAL_PATH/files"), "Un problème est survenue dans l'envoi du fichier. Veuillez contacter l'administrateur du serveur."); } diff --git a/server_files/controllers/view_file.php b/server_files/controllers/view_file.php index f576f9e..98c2dcc 100644 --- a/server_files/controllers/view_file.php +++ b/server_files/controllers/view_file.php @@ -32,14 +32,14 @@ if ($file !== null) { if ($type == DocumentType::SOLUTION) { $problem = $file->getProblem(); - $name = "Problème $problem $trigram.pdf"; + $name = "Problème $problem $trigram"; if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId())) require_once "server_files/403.php"; } else if ($type == DocumentType::SYNTHESIS) { $dest = $file->getDest(); - $name = "Note de synthèse $trigram pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . ".pdf"; + $name = "Note de synthèse $trigram pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur"); if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId())) require_once "server_files/403.php"; @@ -68,18 +68,26 @@ if ($file !== null) { break; } if ($type == DocumentType::MOTIVATION_LETTER) - $name = "Lettre de motivation de l'équipe $trigram.pdf"; + $name = "Lettre de motivation de l'équipe $trigram"; else { $surname = $user->getSurname(); $first_name = $user->getFirstName(); - $name .= " de $first_name $surname.pdf"; + $name .= " de $first_name $surname"; } } } else require_once "server_files/404.php"; -header("Content-Type: application/pdf"); +$mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), "$LOCAL_PATH/files/$id"); +if ($mime == "application/pdf") + $name .= ".pdf"; +elseif ($mime == "image/png") + $name .= ".png"; +else + $name = ".jpg"; + +header("Content-Type: $mime"); header("Content-Disposition: inline; filename=\"$name\""); readfile("$LOCAL_PATH/files/$id"); diff --git a/server_files/views/inscription.php b/server_files/views/inscription.php index 6ebf717..92f1285 100644 --- a/server_files/views/inscription.php +++ b/server_files/views/inscription.php @@ -86,7 +86,7 @@ if (isset($user) && !$has_error) {