27 lines
883 B
PHP
27 lines
883 B
PHP
<?php
|
|
$file = $_GET['file'] ?? '';
|
|
$year = $_GET['year'] ?? '';
|
|
|
|
// Проверяем безопасность пути
|
|
if (!preg_match('/^202[0-4]$/', $year) || !preg_match('/^[a-zA-Z0-9_\-\.\s]+\.pdf$/', $file)) {
|
|
header("HTTP/1.0 404 Not Found");
|
|
die('File not found');
|
|
}
|
|
|
|
$filePath = $_SERVER['DOCUMENT_ROOT'] . "/bitrix/documents/sout/{$year}/{$file}";
|
|
|
|
if (!file_exists($filePath)) {
|
|
header("HTTP/1.0 404 Not Found");
|
|
die('File not found');
|
|
}
|
|
|
|
// Устанавливаем заголовки для просмотра в браузере
|
|
header('Content-Type: application/pdf');
|
|
header('Content-Disposition: inline; filename="' . basename($filePath) . '"');
|
|
header('Content-Length: ' . filesize($filePath));
|
|
header('X-Content-Type-Options: nosniff');
|
|
header('Cache-Control: private, max-age=3600');
|
|
|
|
// Отправляем файл
|
|
readfile($filePath);
|
|
exit; |