mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2024-12-25 19:02:27 +00:00
49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
if (!isset($_GET["file_id"])) {
|
|
header("Location: $URL_BASE");
|
|
exit();
|
|
}
|
|
|
|
if (!isset($_SESSION["user_id"]))
|
|
require_once "server_files/403.php";
|
|
|
|
$id = htmlspecialchars($_GET["file_id"]);
|
|
|
|
$file = Document::fromId($id);
|
|
|
|
if ($file !== null) {
|
|
$team = Team::fromId($file->getTeamId());;
|
|
$trigram = $team->getTrigram();
|
|
|
|
$user = User::fromId($file->getUserId());
|
|
|
|
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && $user->getId() != $_SESSION["user_id"])
|
|
require_once "server_files/403.php";
|
|
|
|
$surname = $user->getSurname();
|
|
$first_name = $user->getFirstName();
|
|
$name = "Autorisation de droit à l'image de $first_name $surname.pdf";
|
|
|
|
header("Content-Type: application/pdf");
|
|
}
|
|
else {
|
|
$question = Question::fromAttachedFile($id);
|
|
if ($question != null)
|
|
{
|
|
$from = Team::fromId($question->getFrom());
|
|
$to = Team::fromId($question->getTo());
|
|
$mime_type = finfo_file(finfo_open(FILEINFO_MIME_TYPE), "$LOCAL_PATH/files/$id");
|
|
$name = "Pièce jointe n°" . $question->getNumber() . " de l'équipe " . $from->getTrigram() . " pour l'équipe " . $from->getTrigram() . " (problème " . $question->getProblem() . ")";
|
|
$name .= getExtFromMimeType($mime_type);
|
|
header("Content-Type: " . $mime_type);
|
|
}
|
|
else
|
|
require_once "server_files/404.php";
|
|
}
|
|
|
|
header("Content-Disposition: inline; filename=\"$name\"");
|
|
|
|
readfile("$LOCAL_PATH/files/$id");
|
|
|
|
exit();
|