diff options
| author | Savetheinternet <savetheinternet@n0v4.com> | 2011-01-01 22:18:58 +1100 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@n0v4.com> | 2011-01-01 22:18:58 +1100 |
| commit | f1c48f61227475fad5faa95796b04888089ed589 (patch) | |
| tree | 91ca02be2bb4acd3eb19eaeb1440c1d1510b6013 /inc/mod.php | |
| parent | 463835bc36f61108bdb235c587653e2f104b54d7 (diff) | |
When removing an already-removed image, make it a no-post post.
Diffstat (limited to 'inc/mod.php')
| -rw-r--r-- | inc/mod.php | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/inc/mod.php b/inc/mod.php index c73b72f0..1058cca8 100644 --- a/inc/mod.php +++ b/inc/mod.php @@ -153,14 +153,22 @@ $post = $query->fetch(); - // Delete thumbnail - @unlink($board['dir'] . DIR_THUMB . $post['thumb']); - - // Delete file - @unlink($board['dir'] . DIR_IMG . $post['file']); - + $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 + @unlink($board['dir'] . DIR_THUMB . $post['thumb']); + + // Delete file + @unlink($board['dir'] . DIR_IMG . $post['file']); + + // Set file to 'deleted' + $query->bindValue(':file', 'deleted', PDO::PARAM_INT); + } // 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->execute() or error(db_error($query)); |
