Clean up expired share links

This commit is contained in:
Ryan
2025-03-21 14:17:25 -04:00
committed by GitHub
parent 559df3c396
commit cef96f0047

View File

@@ -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,