summaryrefslogtreecommitdiff
path: root/lib/blog/delete.php
blob: bfc428b56df078730db01c3bb665249b382c299b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php

assert_redir(count($args) >= 3, 'blog');
$postid = intval($args[2]);

$post = mysql_fetch_assoc(sql("SELECT owner FROM blog_posts WHERE id = $postid"));
assert_error($post && $post['owner'] == $user['id'],
	"This post does not exist, or you are not allowed to delete it.");

token_validate("Do you really want to delete this post ?", "blog");
sql("DELETE FROM blog_posts WHERE id = $postid");
sql("DELETE FROM blog_tags WHERE post = $postid");
sql("DELETE FROM blog_comments WHERE post = $postid");
header("Location: drafts-blog");