mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-24 17:42:23 +00:00
Correction de problèmes vis-à-vis de l'envoi et le téléchargement de fichiers
This commit is contained in:
parent
44e91a1f8b
commit
5a93a0a754
@ -32,7 +32,7 @@ $ROUTES["^confirmer_mail/([a-z0-9]*)/?$"] = ["server_files/controllers/confirmer
|
||||
$ROUTES["^connexion/?$"] = ["server_files/controllers/connexion.php"];
|
||||
$ROUTES["^deconnexion/?$"] = ["server_files/controllers/deconnexion.php"];
|
||||
$ROUTES["^equipe/([A-Z]{3})/?$"] = ["server_files/controllers/equipe.php", "trigram"];
|
||||
$ROUTES["^file/[a-z0-9]{64}/?$"] = ["server_files/controllers/view_file.php", "file_id"];
|
||||
$ROUTES["^file/([a-z0-9]{64})/?$"] = ["server_files/controllers/view_file.php", "file_id"];
|
||||
$ROUTES["^informations/([0-9]*)/.*?$"] = ["server_files/controllers/informations.php", "id"];
|
||||
$ROUTES["^inscription/?$"] = ["server_files/controllers/inscription.php"];
|
||||
$ROUTES["^mon_compte/?$"] = ["server_files/controllers/mon_compte.php"];
|
||||
|
@ -80,7 +80,7 @@ class Solution
|
||||
public static function fromId($id)
|
||||
{
|
||||
global $DB;
|
||||
$req = $DB->prepare("SELECT * FROM `documents` WHERE `file_id` = ?;");
|
||||
$req = $DB->prepare("SELECT * FROM `solutions` WHERE `file_id` = ?;");
|
||||
$req->execute([htmlspecialchars($id)]);
|
||||
$data = $req->fetch();
|
||||
|
||||
@ -95,8 +95,8 @@ class Solution
|
||||
private function fill($data)
|
||||
{
|
||||
$this->file_id = $data["file_id"];
|
||||
$this->team_id = $data["team_id"];
|
||||
$this->tournament_id = $data["tournament_id"];
|
||||
$this->team_id = $data["team"];
|
||||
$this->tournament_id = $data["tournament"];
|
||||
$this->problem = $data["problem"];
|
||||
$this->uploaded_at = $data["uploaded_at"];
|
||||
}
|
||||
@ -140,7 +140,7 @@ class Synthese
|
||||
public static function fromId($id)
|
||||
{
|
||||
global $DB;
|
||||
$req = $DB->prepare("SELECT * FROM `documents` WHERE `file_id` = ?;");
|
||||
$req = $DB->prepare("SELECT * FROM `syntheses` WHERE `file_id` = ?;");
|
||||
$req->execute([htmlspecialchars($id)]);
|
||||
$data = $req->fetch();
|
||||
|
||||
|
@ -3,20 +3,23 @@
|
||||
if (!isset($_SESSION["team"]))
|
||||
require_once "server_files/403.php";
|
||||
|
||||
if (isset($_POST["send_solution"])) {
|
||||
$error_message = saveSolution();
|
||||
}
|
||||
|
||||
/** @var Team $team */
|
||||
/**
|
||||
* @var Team $team
|
||||
* @var Tournament $tournament
|
||||
*/
|
||||
$team = $_SESSION["team"];
|
||||
|
||||
$solutions_req = $DB->prepare("SELECT `file_id`, `problem`, COUNT(`problem`) AS `version` FROM `solutions` WHERE `team` = ? AND `tournament` = ? GROUP BY `problem`, `uploaded_at` ORDER BY `problem`, `uploaded_at` DESC;");
|
||||
$solutions_req->execute([$team->getId(), $_SESSION[$team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId()]]);
|
||||
|
||||
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId());
|
||||
|
||||
if (isset($_POST["send_solution"])) {
|
||||
$error_message = saveSolution();
|
||||
}
|
||||
|
||||
/** @noinspection SqlAggregates */
|
||||
$solutions_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;");
|
||||
$solutions_req->execute([$team->getId(), $tournament->getId()]);
|
||||
|
||||
function saveSolution() {
|
||||
global $LOCAL_PATH, $DB;
|
||||
global $LOCAL_PATH, $DB, $team, $tournament;
|
||||
|
||||
try {
|
||||
$problem = $_POST["problem"];
|
||||
@ -52,7 +55,7 @@ function saveSolution() {
|
||||
return "Une erreur est survenue lors de l'envoi du fichier.";
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);");
|
||||
$req->execute([$id, $_SESSION["team_id"], $_SESSION["tournament_id"], $problem]);
|
||||
$req->execute([$id, $team->getId(), $tournament->getId(), $problem]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -3,20 +3,23 @@
|
||||
if (!isset($_SESSION["team"]))
|
||||
require_once "server_files/403.php";
|
||||
|
||||
if (isset($_POST["send_synthese"])) {
|
||||
$error_message = saveSynthese();
|
||||
}
|
||||
|
||||
/** @var Team $team */
|
||||
/**
|
||||
* @var Team $team
|
||||
* @var Tournament $tournament
|
||||
*/
|
||||
$team = $_SESSION["team"];
|
||||
|
||||
$syntheses_req = $DB->prepare("SELECT `file_id`, `dest`, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `team` = ? AND `tournament` = ? GROUP BY `dest`, `uploaded_at` ORDER BY `dest`, `uploaded_at` DESC;");
|
||||
$syntheses_req->execute([$team->getId(), $_SESSION[$team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId()]]);
|
||||
|
||||
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId());
|
||||
|
||||
if (isset($_POST["send_synthese"])) {
|
||||
$error_message = saveSynthese();
|
||||
}
|
||||
|
||||
/** @noinspection SqlAggregates */
|
||||
$syntheses_req = $DB->prepare("SELECT `file_id`, `dest`, COUNT(`dest`) AS `version` FROM `syntheses` WHERE `team` = ? AND `tournament` = ? GROUP BY `dest` ORDER BY `dest`, `uploaded_at` DESC;");
|
||||
$syntheses_req->execute([$team->getId(), $tournament->getId()]);
|
||||
|
||||
function saveSynthese() {
|
||||
global $LOCAL_PATH, $DB;
|
||||
global $LOCAL_PATH, $DB, $team, $tournament;
|
||||
|
||||
$dest = strtoupper(htmlspecialchars($_POST["dest"]));
|
||||
|
||||
@ -48,7 +51,7 @@ function saveSynthese() {
|
||||
return "Une erreur est survenue lors de l'envoi du fichier.";
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
|
||||
$req->execute([$id, $_SESSION["team_id"], $_SESSION["tournament_id"], $dest]);
|
||||
$req->execute([$id, $team->getId(), $tournament->getId(), $dest]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ if (isset($_POST["download_zip"])) {
|
||||
|
||||
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));
|
||||
header("Content-Length: " . filesize($temp));
|
||||
|
||||
readfile($temp);
|
||||
|
||||
|
@ -37,7 +37,7 @@ if ($file !== null) {
|
||||
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId()))
|
||||
require_once "server_files/403.php";
|
||||
}
|
||||
else if ($type == "SYNTHESE") {
|
||||
else if ($type == DocumentType::SYNTHESE) {
|
||||
$dest = $file->getDest();
|
||||
$name = "Note de synthèse $trigram pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . ".pdf";
|
||||
|
||||
@ -67,15 +67,12 @@ if ($file !== null) {
|
||||
$name .= " de $first_name $surname.pdf";
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
require_once "server_files/404.php";
|
||||
http_response_code(404);
|
||||
exit();
|
||||
}
|
||||
|
||||
header("Content-Type: application/pdf");
|
||||
header("Content-Disposition: inline; filename=\"$name\"");
|
||||
|
||||
readfile("$URL_BASE/files/$id");
|
||||
readfile("$LOCAL_PATH/files/$id");
|
||||
|
||||
exit();
|
Loading…
Reference in New Issue
Block a user