mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-11-27 00:47:10 +00:00
53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
|
|
if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ORGANIZER && $_SESSION["role"] != Role::ADMIN)
|
|
require_once "server_files/403.php";
|
|
|
|
$trigram = htmlspecialchars($_GET["trigram"]);
|
|
|
|
$team = Team::fromTrigram($trigram);
|
|
$tournament = Tournament::fromId($team->getTournamentId());
|
|
|
|
if ($team === null)
|
|
require_once "server_files/404.php";
|
|
|
|
if (isset($_POST["validate"])) {
|
|
$team->setValidationStatus(ValidationStatus::VALIDATED);
|
|
}
|
|
|
|
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"];
|
|
$alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
|
|
do {
|
|
$id = "";
|
|
for ($i = 0; $i < 64; ++$i) {
|
|
$id .= $alphabet[rand(0, strlen($alphabet) - 1)];
|
|
}
|
|
}
|
|
while (file_exists("$LOCAL_PATH/files/$id"));
|
|
|
|
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"]]);
|
|
}
|
|
}
|
|
|
|
// TODO Télécharger en zip les documents personnels
|
|
|
|
$documents = $tournament->getAllDocuments($team->getId());
|
|
$documents_final = null;
|
|
|
|
if ($team->isSelectedForFinal())
|
|
$documents_final = $FINAL->getAllDocuments($team->getId());
|
|
|
|
require_once "server_files/views/equipe.php";
|