mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-25 17:42:24 +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["^connexion/?$"] = ["server_files/controllers/connexion.php"];
|
||||||
$ROUTES["^deconnexion/?$"] = ["server_files/controllers/deconnexion.php"];
|
$ROUTES["^deconnexion/?$"] = ["server_files/controllers/deconnexion.php"];
|
||||||
$ROUTES["^equipe/([A-Z]{3})/?$"] = ["server_files/controllers/equipe.php", "trigram"];
|
$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["^informations/([0-9]*)/.*?$"] = ["server_files/controllers/informations.php", "id"];
|
||||||
$ROUTES["^inscription/?$"] = ["server_files/controllers/inscription.php"];
|
$ROUTES["^inscription/?$"] = ["server_files/controllers/inscription.php"];
|
||||||
$ROUTES["^mon_compte/?$"] = ["server_files/controllers/mon_compte.php"];
|
$ROUTES["^mon_compte/?$"] = ["server_files/controllers/mon_compte.php"];
|
||||||
|
@ -80,7 +80,7 @@ class Solution
|
|||||||
public static function fromId($id)
|
public static function fromId($id)
|
||||||
{
|
{
|
||||||
global $DB;
|
global $DB;
|
||||||
$req = $DB->prepare("SELECT * FROM `documents` WHERE `file_id` = ?;");
|
$req = $DB->prepare("SELECT * FROM `solutions` WHERE `file_id` = ?;");
|
||||||
$req->execute([htmlspecialchars($id)]);
|
$req->execute([htmlspecialchars($id)]);
|
||||||
$data = $req->fetch();
|
$data = $req->fetch();
|
||||||
|
|
||||||
@ -95,8 +95,8 @@ class Solution
|
|||||||
private function fill($data)
|
private function fill($data)
|
||||||
{
|
{
|
||||||
$this->file_id = $data["file_id"];
|
$this->file_id = $data["file_id"];
|
||||||
$this->team_id = $data["team_id"];
|
$this->team_id = $data["team"];
|
||||||
$this->tournament_id = $data["tournament_id"];
|
$this->tournament_id = $data["tournament"];
|
||||||
$this->problem = $data["problem"];
|
$this->problem = $data["problem"];
|
||||||
$this->uploaded_at = $data["uploaded_at"];
|
$this->uploaded_at = $data["uploaded_at"];
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ class Synthese
|
|||||||
public static function fromId($id)
|
public static function fromId($id)
|
||||||
{
|
{
|
||||||
global $DB;
|
global $DB;
|
||||||
$req = $DB->prepare("SELECT * FROM `documents` WHERE `file_id` = ?;");
|
$req = $DB->prepare("SELECT * FROM `syntheses` WHERE `file_id` = ?;");
|
||||||
$req->execute([htmlspecialchars($id)]);
|
$req->execute([htmlspecialchars($id)]);
|
||||||
$data = $req->fetch();
|
$data = $req->fetch();
|
||||||
|
|
||||||
|
@ -3,20 +3,23 @@
|
|||||||
if (!isset($_SESSION["team"]))
|
if (!isset($_SESSION["team"]))
|
||||||
require_once "server_files/403.php";
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Team $team
|
||||||
|
* @var Tournament $tournament
|
||||||
|
*/
|
||||||
|
$team = $_SESSION["team"];
|
||||||
|
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId());
|
||||||
|
|
||||||
if (isset($_POST["send_solution"])) {
|
if (isset($_POST["send_solution"])) {
|
||||||
$error_message = saveSolution();
|
$error_message = saveSolution();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Team $team */
|
/** @noinspection SqlAggregates */
|
||||||
$team = $_SESSION["team"];
|
$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()]);
|
||||||
$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());
|
|
||||||
|
|
||||||
function saveSolution() {
|
function saveSolution() {
|
||||||
global $LOCAL_PATH, $DB;
|
global $LOCAL_PATH, $DB, $team, $tournament;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$problem = $_POST["problem"];
|
$problem = $_POST["problem"];
|
||||||
@ -52,7 +55,7 @@ function saveSolution() {
|
|||||||
return "Une erreur est survenue lors de l'envoi du fichier.";
|
return "Une erreur est survenue lors de l'envoi du fichier.";
|
||||||
|
|
||||||
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);");
|
$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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3,20 +3,23 @@
|
|||||||
if (!isset($_SESSION["team"]))
|
if (!isset($_SESSION["team"]))
|
||||||
require_once "server_files/403.php";
|
require_once "server_files/403.php";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Team $team
|
||||||
|
* @var Tournament $tournament
|
||||||
|
*/
|
||||||
|
$team = $_SESSION["team"];
|
||||||
|
$tournament = Tournament::fromId($team->isSelectedForFinal() ? $FINAL->getId() : $team->getTournamentId());
|
||||||
|
|
||||||
if (isset($_POST["send_synthese"])) {
|
if (isset($_POST["send_synthese"])) {
|
||||||
$error_message = saveSynthese();
|
$error_message = saveSynthese();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Team $team */
|
/** @noinspection SqlAggregates */
|
||||||
$team = $_SESSION["team"];
|
$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()]);
|
||||||
$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());
|
|
||||||
|
|
||||||
function saveSynthese() {
|
function saveSynthese() {
|
||||||
global $LOCAL_PATH, $DB;
|
global $LOCAL_PATH, $DB, $team, $tournament;
|
||||||
|
|
||||||
$dest = strtoupper(htmlspecialchars($_POST["dest"]));
|
$dest = strtoupper(htmlspecialchars($_POST["dest"]));
|
||||||
|
|
||||||
@ -48,7 +51,7 @@ function saveSynthese() {
|
|||||||
return "Une erreur est survenue lors de l'envoi du fichier.";
|
return "Une erreur est survenue lors de l'envoi du fichier.";
|
||||||
|
|
||||||
$req = $DB->prepare("INSERT INTO `syntheses`(`file_id`, `team`, `tournament`, `dest`) VALUES (?, ?, ?, ?);");
|
$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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ if (isset($_POST["download_zip"])) {
|
|||||||
|
|
||||||
header("Content-Type: application/zip");
|
header("Content-Type: application/zip");
|
||||||
header("Content-Disposition: attachment; filename=\"Notes de syntèses du tournoi de $tournament_name.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);
|
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()))
|
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && (!isset($_SESSION["team"]) || $_SESSION["team"]->getId() != $team->getId()))
|
||||||
require_once "server_files/403.php";
|
require_once "server_files/403.php";
|
||||||
}
|
}
|
||||||
else if ($type == "SYNTHESE") {
|
else if ($type == DocumentType::SYNTHESE) {
|
||||||
$dest = $file->getDest();
|
$dest = $file->getDest();
|
||||||
$name = "Note de synthèse $trigram pour " . ($dest == DestType::OPPOSANT ? "l'opposant" : "le rapporteur") . ".pdf";
|
$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";
|
$name .= " de $first_name $surname.pdf";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
require_once "server_files/404.php";
|
require_once "server_files/404.php";
|
||||||
http_response_code(404);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
header("Content-Type: application/pdf");
|
header("Content-Type: application/pdf");
|
||||||
header("Content-Disposition: inline; filename=\"$name\"");
|
header("Content-Disposition: inline; filename=\"$name\"");
|
||||||
|
|
||||||
readfile("$URL_BASE/files/$id");
|
readfile("$LOCAL_PATH/files/$id");
|
||||||
|
|
||||||
exit();
|
exit();
|
Loading…
Reference in New Issue
Block a user