forked from leftypol/leftypol
A bunch of stuff.
This commit is contained in:
parent
d284b0d50d
commit
62bd2ee348
5 changed files with 117 additions and 44 deletions
41
inc/mod.php
41
inc/mod.php
|
@ -209,45 +209,4 @@
|
|||
|
||||
buildThread($post['thread']);
|
||||
}
|
||||
|
||||
// Delete a post (reply or thread)
|
||||
function deletePost($id) {
|
||||
global $board;
|
||||
|
||||
// Select post and replies (if thread) in one query
|
||||
$query = prepare(sprintf("SELECT `id`,`thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = :id OR `thread` = :id", $board['uri']));
|
||||
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
if($query->rowCount() < 1) {
|
||||
error(ERROR_INVALIDPOST);
|
||||
}
|
||||
|
||||
// Delete posts and maybe replies
|
||||
while($post = $query->fetch()) {
|
||||
if(!$post['thread']) {
|
||||
// Delete thread HTML page
|
||||
@unlink($board['dir'] . DIR_RES . sprintf(FILE_PAGE, $post['id']));
|
||||
} elseif($query->rowCount() == 1) {
|
||||
// Rebuild thread
|
||||
$rebuild = $post['thread'];
|
||||
}
|
||||
if($post['thumb']) {
|
||||
// Delete thumbnail
|
||||
@unlink($board['dir'] . DIR_THUMB . $post['thumb']);
|
||||
}
|
||||
if($post['file']) {
|
||||
// Delete file
|
||||
@unlink($board['dir'] . DIR_IMG . $post['file']);
|
||||
}
|
||||
}
|
||||
|
||||
$query = prepare(sprintf("DELETE FROM `posts_%s` WHERE `id` = :id OR `thread` = :id", $board['uri']));
|
||||
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
if(isset($rebuild)) {
|
||||
buildThread($rebuild);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue