plateforme-corres2math/server_files/controllers/view_file.php

36 lines
905 B
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());
$type = $file->getType();
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";
} else
require_once "server_files/404.php";
header("Content-Type: application/pdf");
header("Content-Disposition: inline; filename=\"$name\"");
readfile("$LOCAL_PATH/files/$id");
exit();