Fix share link view accounting and quote response handling

This commit is contained in:
johnnyq
2026-07-27 21:11:45 -04:00
parent f129311b2e
commit 22e93589cb
5 changed files with 34 additions and 13 deletions

View File

@@ -56,17 +56,22 @@ if (isset($_GET['id']) && isset($_GET['key'])) {
exit("Item cannot be viewed at this time (No file, may have been deleted).");
}
$file_name = escapeSql($file_row['file_name']);
$file_reference_name = escapeSql($file_row['file_reference_name']);
$client_id = intval($file_row['file_client_id']);
$file_path = "../uploads/clients/$client_id/$file_reference_name";
// Don't burn a view on a file that is missing from disk
if (!is_readable($file_path)) {
exit("Item cannot be viewed at this time (No file, may have been deleted).");
}
// Claim the view before the file is served. The checks above stay as a
// fast path for messaging - this UPDATE is what enforces the limit.
if (!claimSharedItemView($item_id)) {
exit("Item cannot be viewed at this time (view limit exceeded).");
}
$file_name = escapeSql($file_row['file_name']);
$file_reference_name = escapeSql($file_row['file_reference_name']);
$client_id = intval($file_row['file_client_id']);
$file_path = "../uploads/clients/$client_id/$file_reference_name";
// Display file as download
$mime_type = mime_content_type($file_path);
header('Content-type: '.$mime_type);
@@ -74,6 +79,6 @@ if (isset($_GET['id']) && isset($_GET['key'])) {
readfile($file_path);
//Logging
logAudit("Share", "View", "Downloaded shared file $file_name via link", $client_id);
logAudit("Share", "View", "Downloaded shared file $file_name via link", $client_id, $item_id);
}