From d135147939a5b6335f8e7e1c515a2d3a823efae9 Mon Sep 17 00:00:00 2001 From: Yohann Date: Sun, 17 Nov 2019 12:24:51 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Les=20archives=20d'autorisations=20parental?= =?UTF-8?q?es=20=C3=A9taient=20invalides?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server_files/model.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server_files/model.php b/server_files/model.php index 1f73cfd..bb8f2ff 100644 --- a/server_files/model.php +++ b/server_files/model.php @@ -155,7 +155,9 @@ function getZipFile($problem, $team_id = -1) foreach ($data as $file) { $file_id = $file->getFileId(); $user = User::fromId($file->getUserId()); - $name = "Autorisation de droit à l'image de " . $user->getFirstName() . " " . $user->getSurname() . ".pdf"; + $mime_type = finfo_file(finfo_open(FILEINFO_MIME_TYPE), "$LOCAL_PATH/files/$file_id"); + $ext = $mime_type == "application/pdf" ? "pdf" : ($mime_type == "image/png" ? "png" : "jpg"); + $name = "Autorisation de droit à l'image de " . $user->getFirstName() . " " . $user->getSurname() . "." . $ext; $zip->addFile("$LOCAL_PATH/files/$file_id", $name); } From 65ef31e4e603407163b6d7447b419c9add5781f8 Mon Sep 17 00:00:00 2001 From: Yohann Date: Sun, 17 Nov 2019 12:41:03 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Une=20=C3=A9quipe=20ne=20peut=20pas=20recev?= =?UTF-8?q?oir=20de=20vid=C3=A9os=20d'une=20autre=20=C3=A9quipe=20non=20pa?= =?UTF-8?q?rticipante?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server_files/classes/Team.php | 4 ++-- server_files/controllers/equipe.php | 2 +- server_files/controllers/mon_compte.php | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server_files/classes/Team.php b/server_files/classes/Team.php index a3d54d4..a5e75f2 100644 --- a/server_files/classes/Team.php +++ b/server_files/classes/Team.php @@ -70,10 +70,10 @@ class Team return $team; } - public static function getAllTeams($problem) + public static function getAllTeams($problem, $only_validated = false) { global $DB, $YEAR; - $req = $DB->prepare("SELECT * FROM `teams` WHERE " . ($problem < 0 ? "" : "`problem` = ? AND ") . "`year` = $YEAR;"); + $req = $DB->prepare("SELECT * FROM `teams` WHERE " . ($problem < 0 ? "" : "`problem` = ? AND ") . ($only_validated ? "`validation_status` = 'VALIDATED' AND " : "") . "`year` = $YEAR;"); $req->execute([htmlspecialchars($problem)]); $teams = []; diff --git a/server_files/controllers/equipe.php b/server_files/controllers/equipe.php index b71b1f6..871c3a6 100644 --- a/server_files/controllers/equipe.php +++ b/server_files/controllers/equipe.php @@ -102,7 +102,7 @@ class UpdateVideoTeams } } -$other_teams = Team::getAllTeams($team->getProblem()); +$other_teams = Team::getAllTeams($team->getProblem(), true); $documents = Document::getAllDocuments($team->getProblem(), $team->getId()); require_once "server_files/views/equipe.php"; diff --git a/server_files/controllers/mon_compte.php b/server_files/controllers/mon_compte.php index 6bc8462..dc944e4 100644 --- a/server_files/controllers/mon_compte.php +++ b/server_files/controllers/mon_compte.php @@ -150,8 +150,9 @@ 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."); - 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."); + $mime_type = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->file["tmp_name"]); + ensure($mime_type == "application/pdf" || $mime_type == "image/png" || $mime_type == "image/jpeg", "Le fichier doit être au format PDF."); + ensure(is_dir("$LOCAL_PATH/files") || mkdir("$LOCAL_PATH/files"), "Un problème est survenu dans l'envoi du fichier. Veuillez vérifier que le fichier pèse moins de 2 Mo. Merci de compresser votre fichier si tel n'est pas le cas. En cas de problème, merci de contacter l'administrateur du serveur."); } public function sendDocument()