Clean up expired share links
This commit is contained in:
@@ -20,8 +20,6 @@ if ($folder !== 'root' && !preg_match('/^[A-Za-z0-9_\- \/]+$/', $folder)) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optionally, you could check if the file exists in the uploads directory here.
|
|
||||||
|
|
||||||
// Generate a secure token.
|
// Generate a secure token.
|
||||||
$token = bin2hex(random_bytes(16)); // 32 hex characters.
|
$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.
|
// Add record.
|
||||||
$shareLinks[$token] = [
|
$shareLinks[$token] = [
|
||||||
"folder" => $folder,
|
"folder" => $folder,
|
||||||
|
|||||||
Reference in New Issue
Block a user