PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/delete.php

http://github.com/taylorchu/goolog
PHP | 93 lines | 88 code | 5 blank | 0 comment | 17 complexity | d33339ae35ef3c5d2cd0ed921b2a4816 MD5 | raw file
 1<?php
 2
 3$out['self'] = 'delete';
 4require 'header.php';
 5
 6if(isGETValidEntry('post', 'post') && isAdmin())
 7{
 8	$postEntry = readEntry('post', $_GET['post']);
 9	$out['subtitle'] = lang('delete post : %s', $postEntry['title']);
10	if(checkBot())
11	{
12		deleteEntry('post', $_GET['post']);
13		if($postEntry['category'] !== '')
14		{
15			$categoryEntry = readEntry('category', $postEntry['category']);
16			unset($categoryEntry['post'][$_GET['post']]);
17			saveEntry('category', $postEntry['category'], $categoryEntry);
18		}
19		foreach($postEntry['reply'] as $reply)
20		{
21			deleteEntry('reply', $reply);
22		}
23		$out['content'] .= '<p><a href="index.php/post">? ' .$lang['redirect']. ' : ' .$lang['post']. '</a></p>';
24	}
25	else
26	{
27		$out['content'] .= form('delete.php/post/' .$_GET['post'],
28			submit());
29	}
30}
31else if(isGETValidEntry('reply', 'reply') && (isAdmin() || isAuthor($_GET['reply'])))
32{
33	$replyEntry = readEntry('reply', $_GET['reply']);
34	$out['subtitle'] = lang('delete reply');
35	if(checkBot())
36	{
37		deleteEntry('reply', $_GET['reply']);
38
39		$postEntry = readEntry('post', $replyEntry['post']);
40		unset($postEntry['reply'][$_GET['reply']]);
41		saveEntry('post', $replyEntry['post'], $postEntry);
42		$out['content'] .= '<p><a href="view.php/post/' .$replyEntry['post']. '">? ' .$lang['redirect']. ' : ' .$postEntry['title']. '</a></p>';
43	}
44	else
45	{
46		$out['content'] .= form('delete.php/reply/' .$_GET['reply'],
47			submit());
48	}
49}
50else if(isGETValidEntry('link', 'link') && isAdmin())
51{
52	$linkEntry = readEntry('link', $_GET['link']);
53	$out['subtitle'] = lang('delete link : %s', $linkEntry['name']);
54	if(checkBot())
55	{
56		deleteEntry('link', $_GET['link']);
57		$out['content'] .= '<p><a href="index.php/post">? ' .$lang['redirect']. ' : ' .$lang['post']. '</a></p>';
58	}
59	else
60	{
61		$out['content'] .= form('delete.php/link/' .$_GET['link'],
62			submit());
63	}
64}
65else if(isGETValidEntry('category', 'category') && isAdmin())
66{
67	$categoryEntry = readEntry('category', $_GET['category']);
68	$out['subtitle'] = lang('delete category : %s', $categoryEntry['name']);
69	if(checkBot())
70	{
71		deleteEntry('category', $_GET['category']);
72		foreach($categoryEntry['post'] as $post)
73		{
74			$postEntry = readEntry('post', $post);
75			$postEntry['category'] = '';
76			saveEntry('post', $post, $postEntry);
77		}
78		$out['content'] .= '<p><a href="index.php/post">? ' .$lang['redirect']. ' : ' .$lang['post']. '</a></p>';
79	}
80	else
81	{
82		$out['content'] .= form('delete.php/category/' .$_GET['category'],
83			submit());
84	}
85}
86else
87{
88	exit;
89}
90
91require 'footer.php';
92
93?>