When removing an already-removed image, make it a no-post post.
This commit is contained in:
parent
463835bc36
commit
f1c48f6122
10
inc/mod.php
10
inc/mod.php
@ -153,14 +153,22 @@
|
|||||||
|
|
||||||
$post = $query->fetch();
|
$post = $query->fetch();
|
||||||
|
|
||||||
|
$query = prepare(sprintf("UPDATE `posts_%s` SET `thumb` = NULL, `thumbwidth` = NULL, `thumbheight` = NULL, `filewidth` = NULL, `fileheight` = NULL, `filesize` = NULL, `filename` = NULL, `filehash` = NULL, `file` = :file WHERE `id` = :id OR `thread` = :id", $board['uri']));
|
||||||
|
if($post['file'] == 'deleted') {
|
||||||
|
// Already deleted; remove file fully
|
||||||
|
$query->bindValue(':file', null, PDO::PARAM_NULL);
|
||||||
|
} else {
|
||||||
// Delete thumbnail
|
// Delete thumbnail
|
||||||
@unlink($board['dir'] . DIR_THUMB . $post['thumb']);
|
@unlink($board['dir'] . DIR_THUMB . $post['thumb']);
|
||||||
|
|
||||||
// Delete file
|
// Delete file
|
||||||
@unlink($board['dir'] . DIR_IMG . $post['file']);
|
@unlink($board['dir'] . DIR_IMG . $post['file']);
|
||||||
|
|
||||||
|
// Set file to 'deleted'
|
||||||
|
$query->bindValue(':file', 'deleted', PDO::PARAM_INT);
|
||||||
|
}
|
||||||
// Update database
|
// Update database
|
||||||
$query = prepare(sprintf("UPDATE `posts_%s` SET `thumb` = NULL, `thumbwidth` = NULL, `thumbheight` = NULL, `filewidth` = NULL, `fileheight` = NULL, `filesize` = NULL, `filename` = NULL, `filehash` = NULL, `file` = 'deleted' WHERE `id` = :id OR `thread` = :id", $board['uri']));
|
|
||||||
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user