author | Dan |
Sun, 02 Sep 2007 11:00:57 -0400 | |
changeset 5 | e3d7322305bf |
parent 2 | a8a21e1c7afa |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/*********************************************************************** |
|
3 |
||
4 |
Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org) |
|
5 |
||
6 |
This file is part of PunBB. |
|
7 |
||
8 |
PunBB is free software; you can redistribute it and/or modify it |
|
9 |
under the terms of the GNU General Public License as published |
|
10 |
by the Free Software Foundation; either version 2 of the License, |
|
11 |
or (at your option) any later version. |
|
12 |
||
13 |
PunBB is distributed in the hope that it will be useful, but |
|
14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
GNU General Public License for more details. |
|
17 |
||
18 |
You should have received a copy of the GNU General Public License |
|
19 |
along with this program; if not, write to the Free Software |
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
|
21 |
MA 02111-1307 USA |
|
22 |
||
23 |
************************************************************************/ |
|
24 |
||
25 |
||
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
26 |
//define('PUN_ROOT', './'); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
27 |
//require PUN_ROOT.'include/common.php'; |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
28 |
|
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
29 |
global $pun_db, $pun_user, $pun_config, $lang_common; |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
30 |
|
0 | 31 |
|
32 |
||
33 |
if ($pun_user['g_read_board'] == '0') |
|
34 |
message($lang_common['No view']); |
|
35 |
||
36 |
||
37 |
$id = isset($_GET['id']) ? intval($_GET['id']) : 0; |
|
38 |
if ($id < 1) |
|
39 |
message($lang_common['Bad request']); |
|
40 |
||
41 |
// Fetch some info about the post, the topic and the forum |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
42 |
$result = $pun_db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
43 |
if (!$pun_db->num_rows($result)) |
0 | 44 |
message($lang_common['Bad request']); |
45 |
||
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
46 |
$cur_post = $pun_db->fetch_assoc($result); |
0 | 47 |
|
48 |
// Sort out who the moderators are and if we are currently a moderator (or an admin) |
|
49 |
$mods_array = ($cur_post['moderators'] != '') ? unserialize($cur_post['moderators']) : array(); |
|
50 |
$is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && array_key_exists($pun_user['username'], $mods_array))) ? true : false; |
|
51 |
||
52 |
// Determine whether this post is the "topic post" or not |
|
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
53 |
$result = $pun_db->query('SELECT id FROM '.$pun_db->prefix.'posts WHERE topic_id='.$cur_post['tid'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); |
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
54 |
$topic_post_id = $pun_db->result($result); |
0 | 55 |
|
56 |
$is_topic_post = ($id == $topic_post_id) ? true : false; |
|
57 |
||
58 |
// Do we have permission to edit this post? |
|
59 |
if (($pun_user['g_delete_posts'] == '0' || |
|
60 |
($pun_user['g_delete_topics'] == '0' && $is_topic_post) || |
|
61 |
$cur_post['poster_id'] != $pun_user['id'] || |
|
62 |
$cur_post['closed'] == '1') && |
|
63 |
!$is_admmod) |
|
64 |
message($lang_common['No permission']); |
|
65 |
||
66 |
// Load the delete.php language file |
|
67 |
require PUN_ROOT.'lang/'.$pun_user['language'].'/delete.php'; |
|
68 |
||
69 |
||
70 |
if (isset($_POST['delete'])) |
|
71 |
{ |
|
72 |
if ($is_admmod) |
|
5 | 73 |
confirm_referrer('delete'); |
0 | 74 |
|
75 |
require PUN_ROOT.'include/search_idx.php'; |
|
76 |
||
77 |
if ($is_topic_post) |
|
78 |
{ |
|
79 |
// Delete the topic and all of it's posts |
|
80 |
delete_topic($cur_post['tid']); |
|
81 |
update_forum($cur_post['fid']); |
|
82 |
||
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
83 |
pun_redirect('viewforum.php?id='.$cur_post['fid'], $lang_delete['Topic del redirect']); |
0 | 84 |
} |
85 |
else |
|
86 |
{ |
|
87 |
// Delete just this one post |
|
88 |
delete_post($id, $cur_post['tid']); |
|
89 |
update_forum($cur_post['fid']); |
|
90 |
||
2
a8a21e1c7afa
Let's just say that the API loads. While a decent part of PunBB works, we've still got a LONG way to go, mainly with form validation and security. At this point, Punano is NOT secure as far as privileges and user levels go.
Dan
parents:
0
diff
changeset
|
91 |
pun_redirect('viewtopic.php?id='.$cur_post['tid'], $lang_delete['Post del redirect']); |
0 | 92 |
} |
93 |
} |
|
94 |
||
95 |
||
96 |
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_delete['Delete post']; |
|
97 |
require PUN_ROOT.'header.php'; |
|
98 |
||
99 |
require PUN_ROOT.'include/parser.php'; |
|
100 |
$cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']); |
|
101 |
||
102 |
?> |
|
103 |
<div class="linkst"> |
|
104 |
<div class="inbox"> |
|
105 |
<ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li> » <a href="viewforum.php?id=<?php echo $cur_post['fid'] ?>"><?php echo pun_htmlspecialchars($cur_post['forum_name']) ?></a></li><li> » <?php echo pun_htmlspecialchars($cur_post['subject']) ?></li></ul> |
|
106 |
</div> |
|
107 |
</div> |
|
108 |
||
109 |
<div class="blockform"> |
|
110 |
<h2><span><?php echo $lang_delete['Delete post'] ?></span></h2> |
|
111 |
<div class="box"> |
|
112 |
<form method="post" action="delete.php?id=<?php echo $id ?>"> |
|
113 |
<div class="inform"> |
|
114 |
<fieldset> |
|
115 |
<legend class="warntext"><?php echo $lang_delete['Warning'] ?></legend> |
|
116 |
<div class="infldset"> |
|
117 |
<div class="postmsg"> |
|
118 |
<p><?php echo $lang_common['Author'] ?>: <strong><?php echo pun_htmlspecialchars($cur_post['poster']) ?></strong></p> |
|
119 |
<?php echo $cur_post['message'] ?> |
|
120 |
</div> |
|
121 |
</div> |
|
122 |
</fieldset> |
|
123 |
</div> |
|
124 |
<p><input type="submit" name="delete" value="<?php echo $lang_delete['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p> |
|
125 |
</form> |
|
126 |
</div> |
|
127 |
</div> |
|
128 |
<?php |
|
129 |
||
130 |
require PUN_ROOT.'footer.php'; |