Keep uploads outside the web root.

save_uploaded_file() read, and prune_images() deleted, any path in the
"uploaded" POST field. Uploads now go to UPLOAD_DIR under a random name
that only the session knows.
This commit is contained in:
tim
2026-09-25 21:31:47 +02:00
parent c85f54116c
commit e881ddb458
7 changed files with 104 additions and 41 deletions
+19 -1
View File
@@ -14,7 +14,25 @@ if (isset($_SESSION['editor'])) {
$is_admin = FALSE;
}
display_img(get_id());
if (isset($_GET['pending']))
display_pending_img();
else
display_img(get_id());
// Show the image this session uploaded at the preview step
function display_pending_img() {
$file = pending_upload();
$info = $file ? getimagesize($file) : FALSE;
if (!$info) {
header("HTTP/1.1 404 Not Found");
return;
}
header("Content-type: ".$info['mime']);
header("Content-length: ".filesize($file));
header("X-Content-Type-Options: nosniff");
header("Cache-Control: private, no-store");
readfile($file);
}
function display_img($id) {
global $db, $is_admin, $queue;