30 lines
711 B
PHP
30 lines
711 B
PHP
<?php
|
|
require_once __DIR__ . '/../src/config.php';
|
|
require_once __DIR__ . '/../src/auth.php';
|
|
require_once __DIR__ . '/../src/expense_functions.php';
|
|
require_login();
|
|
|
|
$id = (int)($_GET['id'] ?? 0);
|
|
$expense = get_expense($id);
|
|
|
|
if (!$expense || empty($expense['attachment_path'])) {
|
|
http_response_code(404);
|
|
echo 'Datei nicht gefunden.';
|
|
exit;
|
|
}
|
|
|
|
$fsPath = __DIR__ . '/' . $expense['attachment_path'];
|
|
|
|
if (!is_readable($fsPath)) {
|
|
http_response_code(404);
|
|
echo 'Datei nicht gefunden.';
|
|
exit;
|
|
}
|
|
|
|
header('Content-Type: application/pdf');
|
|
header('Content-Disposition: inline; filename="Ausgabe-' . $id . '.pdf"');
|
|
header('Content-Length: ' . filesize($fsPath));
|
|
readfile($fsPath);
|
|
exit;
|
|
|