Limit the images that previews keep.

A preview that fails the captcha or the form token keeps no image. A session keeps one image, the directory has a size limit, and abandoned images go at the next upload.
This commit is contained in:
tim
2026-09-26 15:27:51 +02:00
parent fe30a0aaa1
commit c4fcef21aa
8 changed files with 215 additions and 42 deletions
+6 -2
View File
@@ -5,10 +5,14 @@ extract($result[0], EXTR_OVERWRITE);
echo '<p>Please review your submission. Once you\'ve finished, please click "Submit" at the bottom of the page, or click "Preview" to check it again.</p>';
// Keep a new image outside the web root until the story is saved;
// display.php shows it to this session only.
if (is_uploaded_file($_FILES['upload']['tmp_name'] ?? '') && !isset($validate['upload'])) {
// display.php shows it to this session only. A request that failed the
// captcha or the form token keeps nothing.
if (is_uploaded_file($_FILES['upload']['tmp_name'] ?? '') &&
!isset($validate['upload']) && !isset($validate['captcha']) && !isset($validate['csrf'])) {
if (store_upload($_FILES['upload']['tmp_name']))
$file_src = pending_upload_url();
else
$validate['upload'] = 'The site cannot keep more images just now. Please try again later.';
} else if (isset($uploaded) && $uploaded === 'pending' && pending_upload() && !$remove_img) {
$file_src = pending_upload_url();
}