mirror of
https://github.com/itflow-org/itflow
synced 2026-08-15 12:05:11 +00:00
Claim shared item views atomically and log guest audit IPs
This commit is contained in:
@@ -56,6 +56,12 @@ if (isset($_GET['id']) && isset($_GET['key'])) {
|
||||
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']);
|
||||
@@ -67,10 +73,6 @@ if (isset($_GET['id']) && isset($_GET['key'])) {
|
||||
header('Content-Disposition: attachment; filename=' . $file_name);
|
||||
readfile($file_path);
|
||||
|
||||
// Update file view count
|
||||
$new_item_views = $item_views + 1;
|
||||
mysqli_query($mysqli, "UPDATE shared_items SET item_views = $new_item_views WHERE item_id = $item_id");
|
||||
|
||||
//Logging
|
||||
logAudit("Share", "View", "Downloaded shared file $file_name via link", $client_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user