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:
+19
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user