2019-08-26 14:27:55 +00:00
|
|
|
<?php
|
|
|
|
|
2019-09-06 23:33:05 +00:00
|
|
|
if (!isset($_SESSION["role"]) || $_SESSION["role"] != Role::ADMIN && $_SESSION["role"] != Role::ORGANIZER)
|
2019-09-07 11:42:36 +00:00
|
|
|
require_once "server_files/403.php";
|
2019-09-06 11:48:50 +00:00
|
|
|
|
2019-08-26 14:27:55 +00:00
|
|
|
if (isset($_POST["download_zip"])) {
|
|
|
|
$id = $_POST["tournament"];
|
2019-09-07 23:35:05 +00:00
|
|
|
$tournament = Tournament::fromId($id);
|
|
|
|
$sols = $tournament->getAllSolutions();
|
2019-08-26 14:27:55 +00:00
|
|
|
|
|
|
|
$zip = new ZipArchive();
|
|
|
|
|
|
|
|
$temp = tempnam("tmp", "tfjm-");
|
|
|
|
|
|
|
|
if ($zip->open($temp, ZipArchive::CREATE) !== true) {
|
|
|
|
die("Impossible de créer le fichier zip.");
|
|
|
|
}
|
|
|
|
|
2019-09-07 23:35:05 +00:00
|
|
|
/** @var Solution $sol */
|
|
|
|
foreach ($sols as $sol) {
|
|
|
|
$file_id = $sol->getFileId();
|
|
|
|
$problem = $sol->getProblem();
|
|
|
|
$version = $sol->getVersion();
|
|
|
|
$team = Team::fromId($sol->getTeamId());
|
2019-09-06 23:33:05 +00:00
|
|
|
$team_name = $team->getName();
|
|
|
|
$team_trigram = $team->getTrigram();
|
2019-08-26 14:27:55 +00:00
|
|
|
|
|
|
|
$zip->addFile("$LOCAL_PATH/files/$file_id", "Problème $problem $team_trigram.pdf");
|
|
|
|
}
|
|
|
|
|
|
|
|
$zip->close();
|
|
|
|
|
|
|
|
header("Content-Type: application/zip");
|
2019-09-07 23:35:05 +00:00
|
|
|
header("Content-Disposition: attachment; filename=\"Solutions du tournoi de " . $tournament->getName() . ".zip\"");
|
2019-09-06 11:48:50 +00:00
|
|
|
header("Content-Length: " . strval(filesize($temp)));
|
2019-08-26 14:27:55 +00:00
|
|
|
|
|
|
|
readfile($temp);
|
|
|
|
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2019-09-07 23:35:05 +00:00
|
|
|
$user = $_SESSION["user"];
|
|
|
|
$tournaments = $_SESSION["role"] == Role::ADMIN ? Tournament::getAllTournaments() : $user->getOrganizedTournaments();
|
2019-08-21 20:56:46 +00:00
|
|
|
|
2019-09-07 23:35:05 +00:00
|
|
|
require_once "server_files/views/solutions_orga.php";
|