From 2272a8b45df4f5012f7c4acef0080ac22dc0074a Mon Sep 17 00:00:00 2001 From: galaxyoyo Date: Mon, 26 Aug 2019 16:27:55 +0200 Subject: [PATCH] =?UTF-8?q?Possibilit=C3=A9=20de=20t=C3=A9l=C3=A9charger?= =?UTF-8?q?=20une=20archive=20des=20solutions=20et=20notes=20de=20synth?= =?UTF-8?q?=C3=A8se=20pour=20les=20organisateurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server_files/solutions_orga.php | 48 +++++++++++++++++++++++++++++++++ server_files/syntheses_orga.php | 48 ++++++++++++++++++++++++++++++++- server_files/view_file.php | 2 +- 3 files changed, 96 insertions(+), 2 deletions(-) diff --git a/server_files/solutions_orga.php b/server_files/solutions_orga.php index 58b67df..c464893 100644 --- a/server_files/solutions_orga.php +++ b/server_files/solutions_orga.php @@ -1,5 +1,45 @@ +query("SELECT *, COUNT(`problem`) AS `version` FROM `solutions` WHERE `tournament` = '$id' GROUP BY `team`, `problem` ORDER BY `team`, `problem`, `uploaded_at` DESC;"); + + $zip = new ZipArchive(); + + $temp = tempnam("tmp", "tfjm-"); + + if ($zip->open($temp, ZipArchive::CREATE) !== true) { + die("Impossible de créer le fichier zip."); + } + + while (($data_file = $files_req->fetch()) !== false) { + $file_id = $data_file["file_id"]; + $problem = $data_file["problem"]; + $version = $data_file["version"]; + $team_id = $data_file["team"]; + $team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = '$team_id' AND `year` = $YEAR;")->fetch(); + $team_name = $team_data["name"]; + $team_trigram = $team_data["trigram"]; + + $zip->addFile("$LOCAL_PATH/files/$file_id", "Problème $problem $team_trigram.pdf"); + } + + $zip->close(); + + header("Content-Type: application/zip"); + header("Content-Disposition: attachment; filename=\"Solutions du tournoi de $tournament_name.zip\""); + header("Content-Length: " . strval(filesize($temp) + 1)); + + readfile($temp); + + exit(); +} + +?> + fetch()) !== false) { $team_trigram = $team_data["trigram"]; echo "Problème n°$problem de l'équipe $team_name ($team_trigram), version $version : Télécharger
"; } + + ?> +
+ + " /> + +
+ diff --git a/server_files/syntheses_orga.php b/server_files/syntheses_orga.php index 348b6e6..a2adc23 100644 --- a/server_files/syntheses_orga.php +++ b/server_files/syntheses_orga.php @@ -1,5 +1,45 @@ +query("SELECT *, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `tournament` = '$id' GROUP BY `team`, `dest` ORDER BY `team`, `dest`, `uploaded_at` DESC;"); + + $zip = new ZipArchive(); + + $temp = tempnam("tmp", "tfjm-"); + + if ($zip->open($temp, ZipArchive::CREATE) !== true) { + die("Impossible de créer le fichier zip."); + } + + while (($data_file = $files_req->fetch()) !== false) { + $file_id = $data_file["file_id"]; + $dest = $data_file["dest"]; + $version = $data_file["version"]; + $team_id = $data_file["team"]; + $team_data = $DB->query("SELECT `name`, `trigram` FROM `teams` WHERE `id` = '$team_id' AND `year` = $YEAR;")->fetch(); + $team_name = $team_data["name"]; + $team_trigram = $team_data["trigram"]; + + $zip->addFile("$LOCAL_PATH/files/$file_id", "Note de synthèse $team_trigram pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur") . ".pdf"); + } + + $zip->close(); + + header("Content-Type: application/zip"); + header("Content-Disposition: attachment; filename=\"Notes de syntèses du tournoi de $tournament_name.zip\""); + header("Content-Length: " . strval(filesize($temp) + 1)); + + readfile($temp); + + exit(); +} + +?> + fetch()) !== false) { echo "Note de synthèse de l'équipe $team_name ($team_trigram) pour " . ($dest == "OPPOSANT" ? "l'opposant" : "le rapporteur") . ", version $version : Télécharger
"; } + ?> +
+ + " /> + +
+ diff --git a/server_files/view_file.php b/server_files/view_file.php index 81c3432..3acf2fe 100644 --- a/server_files/view_file.php +++ b/server_files/view_file.php @@ -21,7 +21,7 @@ if (($data = $req->fetch()) === false) { $data = $req->fetch(); } } -print_r($type); + if ($data !== false) { $team_data = $DB->query("SELECT `trigram` FROM `teams` WHERE `id` = " . $data["team"] . ";")->fetch(); $tournament_data = $DB->query("SELECT `name` FROM `tournaments` WHERE `id` = " . $data["tournament"] . ";")->fetch();