mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-25 20:57:25 +02:00
Optimisation des téléchargements ZIP
This commit is contained in:
@ -18,12 +18,11 @@ if (isset($_POST["validate"])) {
|
||||
if (isset($_POST["select"])) {
|
||||
$team->selectForFinal(true);
|
||||
$team->setValidationStatus(ValidationStatus::NOT_READY);
|
||||
|
||||
/** @noinspection SqlAggregates */
|
||||
$sols_req = $DB->prepare("SELECT `file_id`, `problem`, COUNT(`problem`) AS `version` FROM `solutions` WHERE `team` = ? AND `tournament` = ? GROUP BY `problem` ORDER BY `problem`, `uploaded_at` DESC;");
|
||||
$sols_req->execute([$team->getId(), $team->getTournamentId()]);
|
||||
while (($sol_data = $sols_req->fetch()) !== false) {
|
||||
$old_id = $sol_data["file_id"];
|
||||
$tournament = Tournament::fromId($team->getTournamentId());
|
||||
$sols = $tournament->getAllSolutions($team->getId());
|
||||
/** @var Solution $sol */
|
||||
foreach ($sols as $sol) {
|
||||
$old_id = $sol->getFileId();
|
||||
do
|
||||
$id = genRandomPhrase(64);
|
||||
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||
@ -31,11 +30,24 @@ if (isset($_POST["select"])) {
|
||||
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);");
|
||||
$req->execute([$id, $team->getId(), $_SESSION["final_id"], $sol_data["problem"]]);
|
||||
$req->execute([$id, $team->getId(), $FINAL->getId(), $sol->getFileId()]);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Télécharger en zip les documents personnels
|
||||
if (isset($_POST["download_zip"])) {
|
||||
$final = isset($_POST["final"]);
|
||||
$tournament = $final ? $FINAL : Tournament::fromId($team->getTournamentId());
|
||||
|
||||
$file_name = getZipFile(DocumentType::PARENTAL_CONSENT, $tournament->getId(), $team->getId());
|
||||
|
||||
header("Content-Type: application/zip");
|
||||
header("Content-Disposition: attachment; filename=\"Documents de l'équipe " . $team->getTrigram() . ".zip\"");
|
||||
header("Content-Length: " . strval(filesize($file_name)));
|
||||
|
||||
readfile($file_name);
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
$documents = $tournament->getAllDocuments($team->getId());
|
||||
$documents_final = null;
|
||||
|
Reference in New Issue
Block a user