From cef96f0047884a93df6bbf2ec168d9d7a683ef4e Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 21 Mar 2025 14:17:25 -0400 Subject: [PATCH] Clean up expired share links --- createShareLink.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/createShareLink.php b/createShareLink.php index 9ff22da..9b21411 100644 --- a/createShareLink.php +++ b/createShareLink.php @@ -20,8 +20,6 @@ if ($folder !== 'root' && !preg_match('/^[A-Za-z0-9_\- \/]+$/', $folder)) { exit; } -// Optionally, you could check if the file exists in the uploads directory here. - // Generate a secure token. $token = bin2hex(random_bytes(16)); // 32 hex characters. @@ -42,6 +40,14 @@ if (file_exists($shareFile)) { } } +// Clean up expired share links. +$currentTime = time(); +foreach ($shareLinks as $key => $link) { + if ($link["expires"] < $currentTime) { + unset($shareLinks[$key]); + } +} + // Add record. $shareLinks[$token] = [ "folder" => $folder,