diff options
| author | Savetheinternet <savetheinternet@n0v4.com> | 2010-12-16 16:36:33 +1100 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@n0v4.com> | 2010-12-16 16:36:33 +1100 |
| commit | faf90e4527dc53960427ade20d781523b525a2c3 (patch) | |
| tree | 5b4c0fe40dd9f66559be5e77d17f8bf1d63a4729 /inc/mod.php | |
| parent | fe1ca57ff5039a2f618c84a6de41097ff6c38841 (diff) | |
deleteThread() function
Diffstat (limited to 'inc/mod.php')
| -rw-r--r-- | inc/mod.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/inc/mod.php b/inc/mod.php index 92d6de09..46d966fe 100644 --- a/inc/mod.php +++ b/inc/mod.php @@ -140,4 +140,41 @@ '</fieldset>'; } + // Delete a post (reply or thread) + function deletePost($id) { + global $board, $sql; + + // Select post and replies (if thread) in one query + $post_res = mysql_query(sprintf( + "SELECT `id`,`thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = '%d' OR `thread` = '%d'", + mysql_real_escape_string($board['uri']), + $id, + $id + ), $sql) or error(mysql_error($sql)); + + // Delete posts and maybe replies + while($post = mysql_fetch_array($post_res)) { + + if(!$post['thread']) { + // Delete thread HTML page + @unlink($board['dir'] . DIR_RES . sprintf(FILE_PAGE, $post['id'])); + } + + if($post['thumb']) { + // Delete thumbnail + @unlink($board['dir'] . DIR_THUMB . $post['thumb']); + } + if($post['file']) { + // Delete file + @unlink($board['dir'] . DIR_IMG . $post['file']); + } + + // Delete post + mysql_query(sprintf( + "DELETE FROM `posts_%s` WHERE `id` = '%d'", + mysql_real_escape_string($board['uri']), + $post['id'] + ), $sql) or error(mysql_error($sql)); + } + } ?>
\ No newline at end of file |
