-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdelete.php
46 lines (44 loc) · 1.39 KB
/
delete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
$out = array();
require 'header.php';
if (isGET('post') && isAdmin()) {
$post = GET('post');
$postEntry = readEntry('posts', $post);
deleteEntry('posts', $post);
foreach ($postEntry['tags'] as $tag) {
$tagEntry = readEntry('tags', $tag);
unset($tagEntry['posts'][$post]);
saveEntry('tags', $tag, $tagEntry);
}
foreach ($postEntry['comment'] as $comment)
deleteEntry('comments', $comment);
home();
} else if (isGET('draft') && isAdmin()) {
deleteEntry('drafts', GET('draft'));
home();
} else if (isGET('comment') && (isAdmin() || isAuthor(GET('comment')))) {
$comment = GET('comment');
$commentEntry = readEntry('comments', $comment);
deleteEntry('comments', $comment);
$postEntry = readEntry('posts', $commentEntry['post']);
unset($postEntry['comments'][$comment]);
saveEntry('posts', $commentEntry['post'], $postEntry);
redirect('view.php?post=' . $commentEntry['post'] . '#comments');
} else if (isGET('link') && isAdmin()) {
deleteEntry('links', GET('link'));
home();
} else if (isGET('tag') && isAdmin()) {
$tag = GET('tag');
$tagEntry = readEntry('tags', $tag);
deleteEntry('tags', $tag);
foreach ($tagEntry['posts'] as $post) {
$postEntry = readEntry('posts', $post);
$postEntry['tags'] = array_diff($postEntry['tags'], array($tag));
saveEntry('posts', $post, $postEntry);
}
home();
} else {
home();
}
require 'templates/page.php';
?>