mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-11-27 01:27:09 +00:00
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
|
|
require_once "server_files/403.php";
|
|
|
|
if (isset($_POST["download_zip"])) {
|
|
$id = $_POST["tournament"];
|
|
$tournament = Tournament::fromId($id);
|
|
$sols = $tournament->getAllSolutions();
|
|
|
|
$zip = new ZipArchive();
|
|
|
|
$temp = tempnam("tmp", "tfjm-");
|
|
|
|
if ($zip->open($temp, ZipArchive::CREATE) !== true) {
|
|
die("Impossible de créer le fichier zip.");
|
|
}
|
|
|
|
/** @var Solution $sol */
|
|
foreach ($sols as $sol) {
|
|
$file_id = $sol->getFileId();
|
|
$problem = $sol->getProblem();
|
|
$version = $sol->getVersion();
|
|
$team = Team::fromId($sol->getTeamId());
|
|
$team_name = $team->getName();
|
|
$team_trigram = $team->getTrigram();
|
|
|
|
$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->getName() . ".zip\"");
|
|
header("Content-Length: " . strval(filesize($temp)));
|
|
|
|
readfile($temp);
|
|
|
|
exit();
|
|
}
|
|
|
|
$user = $_SESSION["user"];
|
|
$tournaments = $_SESSION["role"] == Role::ADMIN ? Tournament::getAllTournaments() : $user->getOrganizedTournaments();
|
|
|
|
require_once "server_files/views/solutions_orga.php";
|