From 583a6a58d99504177b3c27e698a9644bdba0cf9d Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Sat, 1 Jan 2011 21:44:11 +1100 Subject: [PATCH] Remove files --- inc/mod.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/inc/mod.php b/inc/mod.php index dd16a1a6..a2ee93ce 100644 --- a/inc/mod.php +++ b/inc/mod.php @@ -143,13 +143,23 @@ function deleteFile($id) { global $board; - $query = prepare(sprintf("SELECT `thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = :id AND `thread` IS NOT NULL", $board['uri'])); + $query = prepare(sprintf("SELECT `thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = :id AND `thread` IS NOT NULL LIMIT 1", $board['uri'])); $query->bindValue(':id', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); if($query->rowCount() < 1) { error(ERROR_INVALIDPOST); } + + $post = $query->fetch(); + + // Delete thumbnail + @unlink($board['dir'] . DIR_THUMB . $post['thumb']); + + // Delete file + @unlink($board['dir'] . DIR_IMG . $post['file']); + + } // Delete a post (reply or thread)