2019-09-09 23:48:52 +00:00
|
|
|
<?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"]);
|
|
|
|
|
2019-09-11 16:41:45 +00:00
|
|
|
$file = Document::fromId($id);
|
2019-09-09 23:48:52 +00:00
|
|
|
|
|
|
|
if ($file !== null) {
|
2019-09-11 16:41:45 +00:00
|
|
|
$team = Team::fromId($file->getTeamId());;
|
2019-09-09 23:48:52 +00:00
|
|
|
$trigram = $team->getTrigram();
|
|
|
|
|
2019-09-11 16:41:45 +00:00
|
|
|
$user = User::fromId($file->getUserId());
|
|
|
|
$type = $file->getType();
|
2019-09-09 23:48:52 +00:00
|
|
|
|
2019-09-11 16:41:45 +00:00
|
|
|
if (($_SESSION["role"] == Role::PARTICIPANT || $_SESSION["role"] == Role::ENCADRANT) && $user->getId() != $_SESSION["user_id"])
|
|
|
|
require_once "server_files/403.php";
|
2019-09-09 23:48:52 +00:00
|
|
|
|
2019-09-11 16:41:45 +00:00
|
|
|
$surname = $user->getSurname();
|
|
|
|
$first_name = $user->getFirstName();
|
|
|
|
$name = "Autorisation de droit à l'image de $first_name $surname.pdf";
|
|
|
|
} else
|
2019-09-09 23:48:52 +00:00
|
|
|
require_once "server_files/404.php";
|
|
|
|
|
|
|
|
header("Content-Type: application/pdf");
|
|
|
|
header("Content-Disposition: inline; filename=\"$name\"");
|
|
|
|
|
|
|
|
readfile("$LOCAL_PATH/files/$id");
|
|
|
|
|
|
|
|
exit();
|