source: branches/rsr.v5.1.dev/web/punbb/delete.php @ 3

Last change on this file since 3 was 3, checked in by dj3c1t, 12 years ago

passage a Fluxbb 1.4.7

File size: 5.2 KB
Line 
1<?php
2
3/**
4 * Copyright (C) 2008-2011 FluxBB
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */
8
9define('PUN_ROOT', dirname(__FILE__).'/');
10require PUN_ROOT.'include/common.php';
11
12
13if ($pun_user['g_read_board'] == '0')
14        message($lang_common['No view']);
15
16
17$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
18if ($id < 1)
19        message($lang_common['Bad request']);
20
21// Fetch some info about the post, the topic and the forum
22$result = $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.first_post_id, t.closed, p.posted, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$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__, $db->error());
23if (!$db->num_rows($result))
24        message($lang_common['Bad request']);
25
26$cur_post = $db->fetch_assoc($result);
27
28if ($pun_config['o_censoring'] == '1')
29        $cur_post['subject'] = censor_words($cur_post['subject']);
30
31// Sort out who the moderators are and if we are currently a moderator (or an admin)
32$mods_array = ($cur_post['moderators'] != '') ? unserialize($cur_post['moderators']) : array();
33$is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_moderator'] == '1' && array_key_exists($pun_user['username'], $mods_array))) ? true : false;
34
35$is_topic_post = ($id == $cur_post['first_post_id']) ? true : false;
36
37// Do we have permission to edit this post?
38if (($pun_user['g_delete_posts'] == '0' ||
39        ($pun_user['g_delete_topics'] == '0' && $is_topic_post) ||
40        $cur_post['poster_id'] != $pun_user['id'] ||
41        $cur_post['closed'] == '1') &&
42        !$is_admmod)
43        message($lang_common['No permission']);
44
45// Load the delete.php language file
46require PUN_ROOT.'lang/'.$pun_user['language'].'/delete.php';
47
48
49if (isset($_POST['delete']))
50{
51        if ($is_admmod)
52                confirm_referrer('delete.php');
53
54        require PUN_ROOT.'include/search_idx.php';
55
56        if ($is_topic_post)
57        {
58                // Delete the topic and all of it's posts
59                delete_topic($cur_post['tid']);
60                update_forum($cur_post['fid']);
61
62                redirect('viewforum.php?id='.$cur_post['fid'], $lang_delete['Topic del redirect']);
63        }
64        else
65        {
66                // Delete just this one post
67                delete_post($id, $cur_post['tid']);
68                update_forum($cur_post['fid']);
69
70                // Redirect towards the previous post
71                $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$cur_post['tid'].' AND id < '.$id.' ORDER BY id DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
72                $post_id = $db->result($result);
73
74                redirect('viewtopic.php?pid='.$post_id.'#p'.$post_id, $lang_delete['Post del redirect']);
75        }
76}
77
78
79$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_delete['Delete post']);
80define ('PUN_ACTIVE_PAGE', 'index');
81require PUN_ROOT.'header.php';
82
83require PUN_ROOT.'include/parser.php';
84$cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
85
86?>
87<div class="linkst">
88        <div class="inbox">
89                <ul class="crumbs">
90                        <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li>
91                        <li><span>»&#160;</span><a href="viewforum.php?id=<?php echo $cur_post['fid'] ?>"><?php echo pun_htmlspecialchars($cur_post['forum_name']) ?></a></li>
92                        <li><span>»&#160;</span><a href="viewtopic.php?pid=<?php echo $id ?>#p<?php echo $id ?>"><?php echo pun_htmlspecialchars($cur_post['subject']) ?></a></li>
93                        <li><span>»&#160;</span><strong><?php echo $lang_delete['Delete post'] ?></strong></li>
94                </ul>
95        </div>
96</div>
97
98<div class="blockform">
99        <h2><span><?php echo $lang_delete['Delete post'] ?></span></h2>
100        <div class="box">
101                <form method="post" action="delete.php?id=<?php echo $id ?>">
102                        <div class="inform">
103                                <div class="forminfo">
104                                        <h3><span><?php printf($is_topic_post ? $lang_delete['Topic by'] : $lang_delete['Reply by'], '<strong>'.pun_htmlspecialchars($cur_post['poster']).'</strong>', format_time($cur_post['posted'])) ?></span></h3>
105                                        <p><?php echo ($is_topic_post) ? '<strong>'.$lang_delete['Topic warning'].'</strong>' : '<strong>'.$lang_delete['Warning'].'</strong>' ?><br /><?php echo $lang_delete['Delete info'] ?></p>
106                                </div>
107                        </div>
108                        <p class="buttons"><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>
109                </form>
110        </div>
111</div>
112
113<div id="postreview">
114        <div class="blockpost">
115                <div class="box">
116                        <div class="inbox">
117                                <div class="postbody">
118                                        <div class="postleft">
119                                                <dl>
120                                                        <dt><strong><?php echo pun_htmlspecialchars($cur_post['poster']) ?></strong></dt>
121                                                        <dd><span><?php echo format_time($cur_post['posted']) ?></span></dd>
122                                                </dl>
123                                        </div>
124                                        <div class="postright">
125                                                <div class="postmsg">
126                                                        <?php echo $cur_post['message']."\n" ?>
127                                                </div>
128                                        </div>
129                                </div>
130                                <div class="clearer"></div>
131                        </div>
132                </div>
133        </div>
134</div>
135<?php
136
137require PUN_ROOT.'footer.php';
Note: See TracBrowser for help on using the repository browser.