Remove files

This commit is contained in:
Savetheinternet 2011-01-01 21:44:11 +11:00
parent 1fa0f64038
commit 583a6a58d9

View File

@ -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)