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 | |
---|
9 | define('PUN_ROOT', dirname(__FILE__).'/'); |
---|
10 | require PUN_ROOT.'include/common.php'; |
---|
11 | |
---|
12 | |
---|
13 | // This particular function doesn't require forum-based moderator access. It can be used |
---|
14 | // by all moderators and admins |
---|
15 | if (isset($_GET['get_host'])) |
---|
16 | { |
---|
17 | if (!$pun_user['is_admmod']) |
---|
18 | message($lang_common['No permission']); |
---|
19 | |
---|
20 | // Is get_host an IP address or a post ID? |
---|
21 | if (@preg_match('%^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$%', $_GET['get_host']) || @preg_match('%^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$%', $_GET['get_host'])) |
---|
22 | $ip = $_GET['get_host']; |
---|
23 | else |
---|
24 | { |
---|
25 | $get_host = intval($_GET['get_host']); |
---|
26 | if ($get_host < 1) |
---|
27 | message($lang_common['Bad request']); |
---|
28 | |
---|
29 | $result = $db->query('SELECT poster_ip FROM '.$db->prefix.'posts WHERE id='.$get_host) or error('Unable to fetch post IP address', __FILE__, __LINE__, $db->error()); |
---|
30 | if (!$db->num_rows($result)) |
---|
31 | message($lang_common['Bad request']); |
---|
32 | |
---|
33 | $ip = $db->result($result); |
---|
34 | } |
---|
35 | |
---|
36 | // Load the misc.php language file |
---|
37 | require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php'; |
---|
38 | |
---|
39 | message(sprintf($lang_misc['Host info 1'], $ip).'<br />'.sprintf($lang_misc['Host info 2'], @gethostbyaddr($ip)).'<br /><br /><a href="admin_users.php?show_users='.$ip.'">'.$lang_misc['Show more users'].'</a>'); |
---|
40 | } |
---|
41 | |
---|
42 | |
---|
43 | // All other functions require moderator/admin access |
---|
44 | $fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0; |
---|
45 | if ($fid < 1) |
---|
46 | message($lang_common['Bad request']); |
---|
47 | |
---|
48 | $result = $db->query('SELECT moderators FROM '.$db->prefix.'forums WHERE id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error()); |
---|
49 | |
---|
50 | $moderators = $db->result($result); |
---|
51 | $mods_array = ($moderators != '') ? unserialize($moderators) : array(); |
---|
52 | |
---|
53 | if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_moderator'] == '0' || !array_key_exists($pun_user['username'], $mods_array))) |
---|
54 | message($lang_common['No permission']); |
---|
55 | |
---|
56 | // Get topic/forum tracking data |
---|
57 | if (!$pun_user['is_guest']) |
---|
58 | $tracked_topics = get_tracked_topics(); |
---|
59 | |
---|
60 | // Load the misc.php language file |
---|
61 | require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php'; |
---|
62 | |
---|
63 | |
---|
64 | // All other topic moderation features require a topic ID in GET |
---|
65 | if (isset($_GET['tid'])) |
---|
66 | { |
---|
67 | $tid = intval($_GET['tid']); |
---|
68 | if ($tid < 1) |
---|
69 | message($lang_common['Bad request']); |
---|
70 | |
---|
71 | // Fetch some info about the topic |
---|
72 | $result = $db->query('SELECT t.subject, t.num_replies, t.first_post_id, f.id AS forum_id, forum_name FROM '.$db->prefix.'topics AS t 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 f.id='.$fid.' AND t.id='.$tid.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error()); |
---|
73 | if (!$db->num_rows($result)) |
---|
74 | message($lang_common['Bad request']); |
---|
75 | |
---|
76 | $cur_topic = $db->fetch_assoc($result); |
---|
77 | |
---|
78 | // Delete one or more posts |
---|
79 | if (isset($_POST['delete_posts']) || isset($_POST['delete_posts_comply'])) |
---|
80 | { |
---|
81 | $posts = isset($_POST['posts']) ? $_POST['posts'] : array(); |
---|
82 | if (empty($posts)) |
---|
83 | message($lang_misc['No posts selected']); |
---|
84 | |
---|
85 | if (isset($_POST['delete_posts_comply'])) |
---|
86 | { |
---|
87 | confirm_referrer('moderate.php'); |
---|
88 | |
---|
89 | if (@preg_match('%[^0-9,]%', $posts)) |
---|
90 | message($lang_common['Bad request']); |
---|
91 | |
---|
92 | // Verify that the post IDs are valid |
---|
93 | $result = $db->query('SELECT 1 FROM '.$db->prefix.'posts WHERE id IN('.$posts.') AND topic_id='.$tid) or error('Unable to check posts', __FILE__, __LINE__, $db->error()); |
---|
94 | |
---|
95 | if ($db->num_rows($result) != substr_count($posts, ',') + 1) |
---|
96 | message($lang_common['Bad request']); |
---|
97 | |
---|
98 | // Delete the posts |
---|
99 | $db->query('DELETE FROM '.$db->prefix.'posts WHERE id IN('.$posts.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error()); |
---|
100 | |
---|
101 | require PUN_ROOT.'include/search_idx.php'; |
---|
102 | strip_search_index($posts); |
---|
103 | |
---|
104 | // Get last_post, last_post_id, and last_poster for the topic after deletion |
---|
105 | $result = $db->query('SELECT id, poster, posted FROM '.$db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
---|
106 | $last_post = $db->fetch_assoc($result); |
---|
107 | |
---|
108 | // How many posts did we just delete? |
---|
109 | $num_posts_deleted = substr_count($posts, ',') + 1; |
---|
110 | |
---|
111 | // Update the topic |
---|
112 | $db->query('UPDATE '.$db->prefix.'topics SET last_post='.$last_post['posted'].', last_post_id='.$last_post['id'].', last_poster=\''.$db->escape($last_post['poster']).'\', num_replies=num_replies-'.$num_posts_deleted.' WHERE id='.$tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error()); |
---|
113 | |
---|
114 | update_forum($fid); |
---|
115 | |
---|
116 | redirect('viewtopic.php?id='.$tid, $lang_misc['Delete posts redirect']); |
---|
117 | } |
---|
118 | |
---|
119 | |
---|
120 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']); |
---|
121 | define('PUN_ACTIVE_PAGE', 'index'); |
---|
122 | require PUN_ROOT.'header.php'; |
---|
123 | |
---|
124 | ?> |
---|
125 | <div class="blockform"> |
---|
126 | <h2><span><?php echo $lang_misc['Delete posts'] ?></span></h2> |
---|
127 | <div class="box"> |
---|
128 | <form method="post" action="moderate.php?fid=<?php echo $fid ?>&tid=<?php echo $tid ?>"> |
---|
129 | <div class="inform"> |
---|
130 | <fieldset> |
---|
131 | <legend><?php echo $lang_misc['Confirm delete legend'] ?></legend> |
---|
132 | <div class="infldset"> |
---|
133 | <input type="hidden" name="posts" value="<?php echo implode(',', array_map('intval', array_keys($posts))) ?>" /> |
---|
134 | <p><?php echo $lang_misc['Delete posts comply'] ?></p> |
---|
135 | </div> |
---|
136 | </fieldset> |
---|
137 | </div> |
---|
138 | <p class="buttons"><input type="submit" name="delete_posts_comply" value="<?php echo $lang_misc['Delete'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p> |
---|
139 | </form> |
---|
140 | </div> |
---|
141 | </div> |
---|
142 | <?php |
---|
143 | |
---|
144 | require PUN_ROOT.'footer.php'; |
---|
145 | } |
---|
146 | else if (isset($_POST['split_posts']) || isset($_POST['split_posts_comply'])) |
---|
147 | { |
---|
148 | $posts = isset($_POST['posts']) ? $_POST['posts'] : array(); |
---|
149 | if (empty($posts)) |
---|
150 | message($lang_misc['No posts selected']); |
---|
151 | |
---|
152 | if (isset($_POST['split_posts_comply'])) |
---|
153 | { |
---|
154 | confirm_referrer('moderate.php'); |
---|
155 | |
---|
156 | if (@preg_match('%[^0-9,]%', $posts)) |
---|
157 | message($lang_common['Bad request']); |
---|
158 | |
---|
159 | $move_to_forum = isset($_POST['move_to_forum']) ? intval($_POST['move_to_forum']) : 0; |
---|
160 | if ($move_to_forum < 1) |
---|
161 | message($lang_common['Bad request']); |
---|
162 | |
---|
163 | // How many posts did we just split off? |
---|
164 | $num_posts_splitted = substr_count($posts, ',') + 1; |
---|
165 | |
---|
166 | // Verify that the post IDs are valid |
---|
167 | $result = $db->query('SELECT 1 FROM '.$db->prefix.'posts WHERE id IN('.$posts.') AND topic_id='.$tid) or error('Unable to check posts', __FILE__, __LINE__, $db->error()); |
---|
168 | if ($db->num_rows($result) != $num_posts_splitted) |
---|
169 | message($lang_common['Bad request']); |
---|
170 | |
---|
171 | // Verify that the move to forum ID is valid |
---|
172 | $result = $db->query('SELECT 1 FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.group_id='.$pun_user['g_id'].' AND fp.forum_id='.$move_to_forum.') WHERE f.redirect_url IS NULL AND (fp.post_topics IS NULL OR fp.post_topics=1)') or error('Unable to fetch forum permissions', __FILE__, __LINE__, $db->error()); |
---|
173 | if (!$db->num_rows($result)) |
---|
174 | message($lang_common['Bad request']); |
---|
175 | |
---|
176 | // Load the post.php language file |
---|
177 | require PUN_ROOT.'lang/'.$pun_user['language'].'/post.php'; |
---|
178 | |
---|
179 | // Check subject |
---|
180 | $new_subject = isset($_POST['new_subject']) ? pun_trim($_POST['new_subject']) : ''; |
---|
181 | |
---|
182 | if ($new_subject == '') |
---|
183 | message($lang_post['No subject']); |
---|
184 | else if (pun_strlen($new_subject) > 70) |
---|
185 | message($lang_post['Too long subject']); |
---|
186 | |
---|
187 | // Get data from the new first post |
---|
188 | $result = $db->query('SELECT p.id, p.poster, p.posted FROM '.$db->prefix.'posts AS p WHERE id IN('.$posts.') ORDER BY p.id ASC LIMIT 1') or error('Unable to get first post', __FILE__, __LINE__, $db->error()); |
---|
189 | $first_post_data = $db->fetch_assoc($result); |
---|
190 | |
---|
191 | // Create the new topic |
---|
192 | $db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, first_post_id, forum_id) VALUES (\''.$db->escape($first_post_data['poster']).'\', \''.$db->escape($new_subject).'\', '.$first_post_data['posted'].', '.$first_post_data['id'].', '.$move_to_forum.')') or error('Unable to create new topic', __FILE__, __LINE__, $db->error()); |
---|
193 | $new_tid = $db->insert_id(); |
---|
194 | |
---|
195 | // Move the posts to the new topic |
---|
196 | $db->query('UPDATE '.$db->prefix.'posts SET topic_id='.$new_tid.' WHERE id IN('.$posts.')') or error('Unable to move posts into new topic', __FILE__, __LINE__, $db->error()); |
---|
197 | |
---|
198 | // Get last_post, last_post_id, and last_poster from the topic and update it |
---|
199 | $result = $db->query('SELECT id, poster, posted FROM '.$db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
---|
200 | $last_post_data = $db->fetch_assoc($result); |
---|
201 | $db->query('UPDATE '.$db->prefix.'topics SET last_post='.$last_post_data['posted'].', last_post_id='.$last_post_data['id'].', last_poster=\''.$db->escape($last_post_data['poster']).'\', num_replies=num_replies-'.$num_posts_splitted.' WHERE id='.$tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error()); |
---|
202 | |
---|
203 | // Get last_post, last_post_id, and last_poster from the new topic and update it |
---|
204 | $result = $db->query('SELECT id, poster, posted FROM '.$db->prefix.'posts WHERE topic_id='.$new_tid.' ORDER BY id DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
---|
205 | $last_post_data = $db->fetch_assoc($result); |
---|
206 | $db->query('UPDATE '.$db->prefix.'topics SET last_post='.$last_post_data['posted'].', last_post_id='.$last_post_data['id'].', last_poster=\''.$db->escape($last_post_data['poster']).'\', num_replies='.($num_posts_splitted-1).' WHERE id='.$new_tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error()); |
---|
207 | |
---|
208 | update_forum($fid); |
---|
209 | update_forum($move_to_forum); |
---|
210 | |
---|
211 | redirect('viewtopic.php?id='.$new_tid, $lang_misc['Split posts redirect']); |
---|
212 | } |
---|
213 | |
---|
214 | $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_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.post_topics IS NULL OR fp.post_topics=1) AND f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); |
---|
215 | |
---|
216 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']); |
---|
217 | $focus_element = array('subject','new_subject'); |
---|
218 | define('PUN_ACTIVE_PAGE', 'index'); |
---|
219 | require PUN_ROOT.'header.php'; |
---|
220 | |
---|
221 | ?> |
---|
222 | <div class="blockform"> |
---|
223 | <h2><span><?php echo $lang_misc['Split posts'] ?></span></h2> |
---|
224 | <div class="box"> |
---|
225 | <form id="subject" method="post" action="moderate.php?fid=<?php echo $fid ?>&tid=<?php echo $tid ?>"> |
---|
226 | <div class="inform"> |
---|
227 | <fieldset> |
---|
228 | <legend><?php echo $lang_misc['Confirm split legend'] ?></legend> |
---|
229 | <div class="infldset"> |
---|
230 | <input type="hidden" name="posts" value="<?php echo implode(',', array_map('intval', array_keys($posts))) ?>" /> |
---|
231 | <label class="required"><strong><?php echo $lang_misc['New subject'] ?> <span><?php echo $lang_common['Required'] ?></span></strong><br /><input type="text" name="new_subject" size="80" maxlength="70" /><br /></label> |
---|
232 | <label><?php echo $lang_misc['Move to'] ?> |
---|
233 | <br /><select name="move_to_forum"> |
---|
234 | <?php |
---|
235 | |
---|
236 | $cur_category = 0; |
---|
237 | while ($cur_forum = $db->fetch_assoc($result)) |
---|
238 | { |
---|
239 | if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
---|
240 | { |
---|
241 | if ($cur_category) |
---|
242 | echo "\t\t\t\t\t\t\t".'</optgroup>'."\n"; |
---|
243 | |
---|
244 | echo "\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($cur_forum['cat_name']).'">'."\n"; |
---|
245 | $cur_category = $cur_forum['cid']; |
---|
246 | } |
---|
247 | |
---|
248 | echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'"'.($fid == $cur_forum['fid'] ? ' selected="selected"' : '').'>'.pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n"; |
---|
249 | } |
---|
250 | |
---|
251 | ?> |
---|
252 | </optgroup> |
---|
253 | </select> |
---|
254 | <br /></label> |
---|
255 | <p><?php echo $lang_misc['Split posts comply'] ?></p> |
---|
256 | </div> |
---|
257 | </fieldset> |
---|
258 | </div> |
---|
259 | <p class="buttons"><input type="submit" name="split_posts_comply" value="<?php echo $lang_misc['Split'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p> |
---|
260 | </form> |
---|
261 | </div> |
---|
262 | </div> |
---|
263 | <?php |
---|
264 | |
---|
265 | require PUN_ROOT.'footer.php'; |
---|
266 | } |
---|
267 | |
---|
268 | |
---|
269 | // Show the moderate posts view |
---|
270 | |
---|
271 | // Load the viewtopic.php language file |
---|
272 | require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php'; |
---|
273 | |
---|
274 | // Used to disable the Move and Delete buttons if there are no replies to this topic |
---|
275 | $button_status = ($cur_topic['num_replies'] == 0) ? ' disabled="disabled"' : ''; |
---|
276 | |
---|
277 | |
---|
278 | // Determine the post offset (based on $_GET['p']) |
---|
279 | $num_pages = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']); |
---|
280 | |
---|
281 | $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']); |
---|
282 | $start_from = $pun_user['disp_posts'] * ($p - 1); |
---|
283 | |
---|
284 | // Generate paging links |
---|
285 | $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'moderate.php?fid='.$fid.'&tid='.$tid); |
---|
286 | |
---|
287 | |
---|
288 | if ($pun_config['o_censoring'] == '1') |
---|
289 | $cur_topic['subject'] = censor_words($cur_topic['subject']); |
---|
290 | |
---|
291 | |
---|
292 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), pun_htmlspecialchars($cur_topic['forum_name']), pun_htmlspecialchars($cur_topic['subject'])); |
---|
293 | define('PUN_ACTIVE_PAGE', 'index'); |
---|
294 | require PUN_ROOT.'header.php'; |
---|
295 | |
---|
296 | ?> |
---|
297 | <div class="linkst"> |
---|
298 | <div class="inbox crumbsplus"> |
---|
299 | <ul class="crumbs"> |
---|
300 | <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li> |
---|
301 | <li><span>» </span><a href="viewforum.php?id=<?php echo $fid ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li> |
---|
302 | <li><span>» </span><a href="viewtopic.php?id=<?php echo $tid ?>"><?php echo pun_htmlspecialchars($cur_topic['subject']) ?></a></li> |
---|
303 | <li><span>» </span><strong><?php echo $lang_misc['Moderate'] ?></strong></li> |
---|
304 | </ul> |
---|
305 | <div class="pagepost"> |
---|
306 | <p class="pagelink conl"><?php echo $paging_links ?></p> |
---|
307 | </div> |
---|
308 | <div class="clearer"></div> |
---|
309 | </div> |
---|
310 | </div> |
---|
311 | |
---|
312 | <form method="post" action="moderate.php?fid=<?php echo $fid ?>&tid=<?php echo $tid ?>"> |
---|
313 | <?php |
---|
314 | |
---|
315 | require PUN_ROOT.'include/parser.php'; |
---|
316 | |
---|
317 | $post_count = 0; // Keep track of post numbers |
---|
318 | |
---|
319 | // Retrieve a list of post IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data |
---|
320 | $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id LIMIT '.$start_from.','.$pun_user['disp_posts']) or error('Unable to fetch post IDs', __FILE__, __LINE__, $db->error()); |
---|
321 | |
---|
322 | $post_ids = array(); |
---|
323 | for ($i = 0;$cur_post_id = $db->result($result, $i);$i++) |
---|
324 | $post_ids[] = $cur_post_id; |
---|
325 | |
---|
326 | // Retrieve the posts (and their respective poster) |
---|
327 | $result = $db->query('SELECT u.title, u.num_posts, g.g_id, g.g_user_title, p.id, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE p.id IN ('.implode(',', $post_ids).') ORDER BY p.id', true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
---|
328 | |
---|
329 | while ($cur_post = $db->fetch_assoc($result)) |
---|
330 | { |
---|
331 | $post_count++; |
---|
332 | |
---|
333 | // If the poster is a registered user |
---|
334 | if ($cur_post['poster_id'] > 1) |
---|
335 | { |
---|
336 | if ($pun_user['g_view_users'] == '1') |
---|
337 | $poster = '<a href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'; |
---|
338 | else |
---|
339 | $poster = pun_htmlspecialchars($cur_post['poster']); |
---|
340 | |
---|
341 | // get_title() requires that an element 'username' be present in the array |
---|
342 | $cur_post['username'] = $cur_post['poster']; |
---|
343 | $user_title = get_title($cur_post); |
---|
344 | |
---|
345 | if ($pun_config['o_censoring'] == '1') |
---|
346 | $user_title = censor_words($user_title); |
---|
347 | } |
---|
348 | // If the poster is a guest (or a user that has been deleted) |
---|
349 | else |
---|
350 | { |
---|
351 | $poster = pun_htmlspecialchars($cur_post['poster']); |
---|
352 | $user_title = $lang_topic['Guest']; |
---|
353 | } |
---|
354 | |
---|
355 | // Perform the main parsing of the message (BBCode, smilies, censor words etc) |
---|
356 | $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']); |
---|
357 | |
---|
358 | ?> |
---|
359 | |
---|
360 | <div id="p<?php echo $cur_post['id'] ?>" class="blockpost<?php if($cur_post['id'] == $cur_topic['first_post_id']) echo ' firstpost' ?><?php echo ($post_count % 2 == 0) ? ' roweven' : ' rowodd' ?><?php if ($post_count == 1) echo ' blockpost1' ?>"> |
---|
361 | <h2><span><span class="conr">#<?php echo ($start_from + $post_count) ?></span> <a href="viewtopic.php?pid=<?php echo $cur_post['id'].'#p'.$cur_post['id'] ?>"><?php echo format_time($cur_post['posted']) ?></a></span></h2> |
---|
362 | <div class="box"> |
---|
363 | <div class="inbox"> |
---|
364 | <div class="postbody"> |
---|
365 | <div class="postleft"> |
---|
366 | <dl> |
---|
367 | <dt><strong><?php echo $poster ?></strong></dt> |
---|
368 | <dd class="usertitle"><strong><?php echo $user_title ?></strong></dd> |
---|
369 | </dl> |
---|
370 | </div> |
---|
371 | <div class="postright"> |
---|
372 | <h3 class="nosize"><?php echo $lang_common['Message'] ?></h3> |
---|
373 | <div class="postmsg"> |
---|
374 | <?php echo $cur_post['message']."\n" ?> |
---|
375 | <?php if ($cur_post['edited'] != '') echo "\t\t\t\t\t\t".'<p class="postedit"><em>'.$lang_topic['Last edit'].' '.pun_htmlspecialchars($cur_post['edited_by']).' ('.format_time($cur_post['edited']).')</em></p>'."\n"; ?> |
---|
376 | </div> |
---|
377 | </div> |
---|
378 | </div> |
---|
379 | </div> |
---|
380 | <div class="inbox"> |
---|
381 | <div class="postfoot clearb"> |
---|
382 | <div class="postfootright"><?php echo ($cur_post['id'] != $cur_topic['first_post_id']) ? '<p class="multidelete"><label><strong>'.$lang_misc['Select'].'</strong> <input type="checkbox" name="posts['.$cur_post['id'].']" value="1" /></label></p>' : '<p>'.$lang_misc['Cannot select first'].'</p>' ?></div> |
---|
383 | </div> |
---|
384 | </div> |
---|
385 | </div> |
---|
386 | </div> |
---|
387 | |
---|
388 | <?php |
---|
389 | |
---|
390 | } |
---|
391 | |
---|
392 | ?> |
---|
393 | <div class="postlinksb"> |
---|
394 | <div class="inbox crumbsplus"> |
---|
395 | <div class="pagepost"> |
---|
396 | <p class="pagelink conl"><?php echo $paging_links ?></p> |
---|
397 | <p class="conr modbuttons"><input type="submit" name="split_posts" value="<?php echo $lang_misc['Split'] ?>"<?php echo $button_status ?> /> <input type="submit" name="delete_posts" value="<?php echo $lang_misc['Delete'] ?>"<?php echo $button_status ?> /></p> |
---|
398 | <div class="clearer"></div> |
---|
399 | </div> |
---|
400 | <ul class="crumbs"> |
---|
401 | <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li> |
---|
402 | <li><span>» </span><a href="viewforum.php?id=<?php echo $fid ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li> |
---|
403 | <li><span>» </span><a href="viewtopic.php?id=<?php echo $tid ?>"><?php echo pun_htmlspecialchars($cur_topic['subject']) ?></a></li> |
---|
404 | <li><span>» </span><strong><?php echo $lang_misc['Moderate'] ?></strong></li> |
---|
405 | </ul> |
---|
406 | <div class="clearer"></div> |
---|
407 | </div> |
---|
408 | </div> |
---|
409 | </form> |
---|
410 | <?php |
---|
411 | |
---|
412 | require PUN_ROOT.'footer.php'; |
---|
413 | } |
---|
414 | |
---|
415 | |
---|
416 | // Move one or more topics |
---|
417 | if (isset($_REQUEST['move_topics']) || isset($_POST['move_topics_to'])) |
---|
418 | { |
---|
419 | if (isset($_POST['move_topics_to'])) |
---|
420 | { |
---|
421 | confirm_referrer('moderate.php'); |
---|
422 | |
---|
423 | if (@preg_match('%[^0-9,]%', $_POST['topics'])) |
---|
424 | message($lang_common['Bad request']); |
---|
425 | |
---|
426 | $topics = explode(',', $_POST['topics']); |
---|
427 | $move_to_forum = isset($_POST['move_to_forum']) ? intval($_POST['move_to_forum']) : 0; |
---|
428 | if (empty($topics) || $move_to_forum < 1) |
---|
429 | message($lang_common['Bad request']); |
---|
430 | |
---|
431 | // Verify that the topic IDs are valid |
---|
432 | $result = $db->query('SELECT 1 FROM '.$db->prefix.'topics WHERE id IN('.implode(',',$topics).') AND forum_id='.$fid) or error('Unable to check topics', __FILE__, __LINE__, $db->error()); |
---|
433 | |
---|
434 | if ($db->num_rows($result) != count($topics)) |
---|
435 | message($lang_common['Bad request']); |
---|
436 | |
---|
437 | // Verify that the move to forum ID is valid |
---|
438 | $result = $db->query('SELECT 1 FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.group_id='.$pun_user['g_id'].' AND fp.forum_id='.$move_to_forum.') WHERE f.redirect_url IS NULL AND (fp.post_topics IS NULL OR fp.post_topics=1)') or error('Unable to fetch forum permissions', __FILE__, __LINE__, $db->error()); |
---|
439 | if (!$db->num_rows($result)) |
---|
440 | message($lang_common['Bad request']); |
---|
441 | |
---|
442 | // Delete any redirect topics if there are any (only if we moved/copied the topic back to where it was once moved from) |
---|
443 | $db->query('DELETE FROM '.$db->prefix.'topics WHERE forum_id='.$move_to_forum.' AND moved_to IN('.implode(',',$topics).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error()); |
---|
444 | |
---|
445 | // Move the topic(s) |
---|
446 | $db->query('UPDATE '.$db->prefix.'topics SET forum_id='.$move_to_forum.' WHERE id IN('.implode(',',$topics).')') or error('Unable to move topics', __FILE__, __LINE__, $db->error()); |
---|
447 | |
---|
448 | // Should we create redirect topics? |
---|
449 | if (isset($_POST['with_redirect'])) |
---|
450 | { |
---|
451 | foreach ($topics as $cur_topic) |
---|
452 | { |
---|
453 | // Fetch info for the redirect topic |
---|
454 | $result = $db->query('SELECT poster, subject, posted, last_post FROM '.$db->prefix.'topics WHERE id='.$cur_topic) or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error()); |
---|
455 | $moved_to = $db->fetch_assoc($result); |
---|
456 | |
---|
457 | // Create the redirect topic |
---|
458 | $db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, last_post, moved_to, forum_id) VALUES(\''.$db->escape($moved_to['poster']).'\', \''.$db->escape($moved_to['subject']).'\', '.$moved_to['posted'].', '.$moved_to['last_post'].', '.$cur_topic.', '.$fid.')') or error('Unable to create redirect topic', __FILE__, __LINE__, $db->error()); |
---|
459 | } |
---|
460 | } |
---|
461 | |
---|
462 | update_forum($fid); // Update the forum FROM which the topic was moved |
---|
463 | update_forum($move_to_forum); // Update the forum TO which the topic was moved |
---|
464 | |
---|
465 | $redirect_msg = (count($topics) > 1) ? $lang_misc['Move topics redirect'] : $lang_misc['Move topic redirect']; |
---|
466 | redirect('viewforum.php?id='.$move_to_forum, $redirect_msg); |
---|
467 | } |
---|
468 | |
---|
469 | if (isset($_POST['move_topics'])) |
---|
470 | { |
---|
471 | $topics = isset($_POST['topics']) ? $_POST['topics'] : array(); |
---|
472 | if (empty($topics)) |
---|
473 | message($lang_misc['No topics selected']); |
---|
474 | |
---|
475 | $topics = implode(',', array_map('intval', array_keys($topics))); |
---|
476 | $action = 'multi'; |
---|
477 | } |
---|
478 | else |
---|
479 | { |
---|
480 | $topics = intval($_GET['move_topics']); |
---|
481 | if ($topics < 1) |
---|
482 | message($lang_common['Bad request']); |
---|
483 | |
---|
484 | $action = 'single'; |
---|
485 | } |
---|
486 | |
---|
487 | $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_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.post_topics IS NULL OR fp.post_topics=1) AND f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); |
---|
488 | if ($db->num_rows($result) < 2) |
---|
489 | message($lang_misc['Nowhere to move']); |
---|
490 | |
---|
491 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']); |
---|
492 | define('PUN_ACTIVE_PAGE', 'index'); |
---|
493 | require PUN_ROOT.'header.php'; |
---|
494 | |
---|
495 | ?> |
---|
496 | <div class="blockform"> |
---|
497 | <h2><span><?php echo ($action == 'single') ? $lang_misc['Move topic'] : $lang_misc['Move topics'] ?></span></h2> |
---|
498 | <div class="box"> |
---|
499 | <form method="post" action="moderate.php?fid=<?php echo $fid ?>"> |
---|
500 | <div class="inform"> |
---|
501 | <input type="hidden" name="topics" value="<?php echo $topics ?>" /> |
---|
502 | <fieldset> |
---|
503 | <legend><?php echo $lang_misc['Move legend'] ?></legend> |
---|
504 | <div class="infldset"> |
---|
505 | <label><?php echo $lang_misc['Move to'] ?> |
---|
506 | <br /><select name="move_to_forum"> |
---|
507 | <?php |
---|
508 | |
---|
509 | $cur_category = 0; |
---|
510 | while ($cur_forum = $db->fetch_assoc($result)) |
---|
511 | { |
---|
512 | if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
---|
513 | { |
---|
514 | if ($cur_category) |
---|
515 | echo "\t\t\t\t\t\t\t".'</optgroup>'."\n"; |
---|
516 | |
---|
517 | echo "\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($cur_forum['cat_name']).'">'."\n"; |
---|
518 | $cur_category = $cur_forum['cid']; |
---|
519 | } |
---|
520 | |
---|
521 | if ($cur_forum['fid'] != $fid) |
---|
522 | echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n"; |
---|
523 | } |
---|
524 | |
---|
525 | ?> |
---|
526 | </optgroup> |
---|
527 | </select> |
---|
528 | <br /></label> |
---|
529 | <div class="rbox"> |
---|
530 | <label><input type="checkbox" name="with_redirect" value="1"<?php if ($action == 'single') echo ' checked="checked"' ?> /><?php echo $lang_misc['Leave redirect'] ?><br /></label> |
---|
531 | </div> |
---|
532 | </div> |
---|
533 | </fieldset> |
---|
534 | </div> |
---|
535 | <p class="buttons"><input type="submit" name="move_topics_to" value="<?php echo $lang_misc['Move'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p> |
---|
536 | </form> |
---|
537 | </div> |
---|
538 | </div> |
---|
539 | <?php |
---|
540 | |
---|
541 | require PUN_ROOT.'footer.php'; |
---|
542 | } |
---|
543 | |
---|
544 | // Merge two or more topics |
---|
545 | else if (isset($_POST['merge_topics']) || isset($_POST['merge_topics_comply'])) |
---|
546 | { |
---|
547 | if (isset($_POST['merge_topics_comply'])) |
---|
548 | { |
---|
549 | confirm_referrer('moderate.php'); |
---|
550 | |
---|
551 | if (@preg_match('%[^0-9,]%', $_POST['topics'])) |
---|
552 | message($lang_common['Bad request']); |
---|
553 | |
---|
554 | $topics = explode(',', $_POST['topics']); |
---|
555 | if (count($topics) < 2) |
---|
556 | message($lang_misc['Not enough topics selected']); |
---|
557 | |
---|
558 | // Verify that the topic IDs are valid (redirect links will point to the merged topic after the merge) |
---|
559 | $result = $db->query('SELECT id FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $topics).') AND forum_id='.$fid.' ORDER BY id ASC') or error('Unable to check topics', __FILE__, __LINE__, $db->error()); |
---|
560 | if ($db->num_rows($result) != count($topics)) |
---|
561 | message($lang_common['Bad request']); |
---|
562 | |
---|
563 | // The topic that we are merging into is the one with the smallest ID |
---|
564 | $merge_to_tid = $db->result($result); |
---|
565 | |
---|
566 | // Make any redirect topics point to our new, merged topic |
---|
567 | $query = 'UPDATE '.$db->prefix.'topics SET moved_to='.$merge_to_tid.' WHERE moved_to IN('.implode(',', $topics).')'; |
---|
568 | |
---|
569 | // Should we create redirect topics? |
---|
570 | if (isset($_POST['with_redirect'])) |
---|
571 | $query .= ' OR (id IN('.implode(',', $topics).') AND id != '.$merge_to_tid.')'; |
---|
572 | |
---|
573 | $db->query($query) or error('Unable to make redirection topics', __FILE__, __LINE__, $db->error()); |
---|
574 | |
---|
575 | // Merge the posts into the topic |
---|
576 | $db->query('UPDATE '.$db->prefix.'posts SET topic_id='.$merge_to_tid.' WHERE topic_id IN('.implode(',', $topics).')') or error('Unable to merge the posts into the topic', __FILE__, __LINE__, $db->error()); |
---|
577 | |
---|
578 | // Delete any subscriptions |
---|
579 | $db->query('DELETE FROM '.$db->prefix.'topic_subscriptions WHERE topic_id IN('.implode(',', $topics).') AND topic_id != '.$merge_to_tid) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error()); |
---|
580 | |
---|
581 | // Without redirection the old topics are removed |
---|
582 | if (!isset($_POST['with_redirect'])) |
---|
583 | $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $topics).') AND id != '.$merge_to_tid) or error('Unable to delete old topics', __FILE__, __LINE__, $db->error()); |
---|
584 | |
---|
585 | // Count number of replies in the topic |
---|
586 | $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'posts WHERE topic_id='.$merge_to_tid) or error('Unable to fetch post count for topic', __FILE__, __LINE__, $db->error()); |
---|
587 | $num_replies = $db->result($result, 0) - 1; |
---|
588 | |
---|
589 | // Get last_post, last_post_id and last_poster |
---|
590 | $result = $db->query('SELECT posted, id, poster FROM '.$db->prefix.'posts WHERE topic_id='.$merge_to_tid.' ORDER BY id DESC LIMIT 1') or error('Unable to get last post info', __FILE__, __LINE__, $db->error()); |
---|
591 | list($last_post, $last_post_id, $last_poster) = $db->fetch_row($result); |
---|
592 | |
---|
593 | // Update topic |
---|
594 | $db->query('UPDATE '.$db->prefix.'topics SET num_replies='.$num_replies.', last_post='.$last_post.', last_post_id='.$last_post_id.', last_poster=\''.$db->escape($last_poster).'\' WHERE id='.$merge_to_tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error()); |
---|
595 | |
---|
596 | // Update the forum FROM which the topic was moved and redirect |
---|
597 | update_forum($fid); |
---|
598 | redirect('viewforum.php?id='.$fid, $lang_misc['Merge topics redirect']); |
---|
599 | } |
---|
600 | |
---|
601 | $topics = isset($_POST['topics']) ? $_POST['topics'] : array(); |
---|
602 | if (count($topics) < 2) |
---|
603 | message($lang_misc['Not enough topics selected']); |
---|
604 | |
---|
605 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']); |
---|
606 | define('PUN_ACTIVE_PAGE', 'index'); |
---|
607 | require PUN_ROOT.'header.php'; |
---|
608 | |
---|
609 | ?> |
---|
610 | <div class="blockform"> |
---|
611 | <h2><span><?php echo $lang_misc['Merge topics'] ?></span></h2> |
---|
612 | <div class="box"> |
---|
613 | <form method="post" action="moderate.php?fid=<?php echo $fid ?>"> |
---|
614 | <input type="hidden" name="topics" value="<?php echo implode(',', array_map('intval', array_keys($topics))) ?>" /> |
---|
615 | <div class="inform"> |
---|
616 | <fieldset> |
---|
617 | <legend><?php echo $lang_misc['Confirm merge legend'] ?></legend> |
---|
618 | <div class="infldset"> |
---|
619 | <div class="rbox"> |
---|
620 | <label><input type="checkbox" name="with_redirect" value="1" /><?php echo $lang_misc['Leave redirect'] ?><br /></label> |
---|
621 | </div> |
---|
622 | </div> |
---|
623 | </fieldset> |
---|
624 | </div> |
---|
625 | <p class="buttons"><input type="submit" name="merge_topics_comply" value="<?php echo $lang_misc['Merge'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p> |
---|
626 | </form> |
---|
627 | </div> |
---|
628 | </div> |
---|
629 | <?php |
---|
630 | |
---|
631 | require PUN_ROOT.'footer.php'; |
---|
632 | } |
---|
633 | |
---|
634 | // Delete one or more topics |
---|
635 | else if (isset($_POST['delete_topics']) || isset($_POST['delete_topics_comply'])) |
---|
636 | { |
---|
637 | $topics = isset($_POST['topics']) ? $_POST['topics'] : array(); |
---|
638 | if (empty($topics)) |
---|
639 | message($lang_misc['No topics selected']); |
---|
640 | |
---|
641 | if (isset($_POST['delete_topics_comply'])) |
---|
642 | { |
---|
643 | confirm_referrer('moderate.php'); |
---|
644 | |
---|
645 | if (@preg_match('%[^0-9,]%', $topics)) |
---|
646 | message($lang_common['Bad request']); |
---|
647 | |
---|
648 | require PUN_ROOT.'include/search_idx.php'; |
---|
649 | |
---|
650 | // Verify that the topic IDs are valid |
---|
651 | $result = $db->query('SELECT 1 FROM '.$db->prefix.'topics WHERE id IN('.$topics.') AND forum_id='.$fid) or error('Unable to check topics', __FILE__, __LINE__, $db->error()); |
---|
652 | |
---|
653 | if ($db->num_rows($result) != substr_count($topics, ',') + 1) |
---|
654 | message($lang_common['Bad request']); |
---|
655 | |
---|
656 | // Delete the topics and any redirect topics |
---|
657 | $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.$topics.') OR moved_to IN('.$topics.')') or error('Unable to delete topic', __FILE__, __LINE__, $db->error()); |
---|
658 | |
---|
659 | // Delete any subscriptions |
---|
660 | $db->query('DELETE FROM '.$db->prefix.'topic_subscriptions WHERE topic_id IN('.$topics.')') or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error()); |
---|
661 | |
---|
662 | // Create a list of the post IDs in this topic and then strip the search index |
---|
663 | $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to fetch posts', __FILE__, __LINE__, $db->error()); |
---|
664 | |
---|
665 | $post_ids = ''; |
---|
666 | while ($row = $db->fetch_row($result)) |
---|
667 | $post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0]; |
---|
668 | |
---|
669 | // We have to check that we actually have a list of post IDs since we could be deleting just a redirect topic |
---|
670 | if ($post_ids != '') |
---|
671 | strip_search_index($post_ids); |
---|
672 | |
---|
673 | // Delete posts |
---|
674 | $db->query('DELETE FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error()); |
---|
675 | |
---|
676 | update_forum($fid); |
---|
677 | |
---|
678 | redirect('viewforum.php?id='.$fid, $lang_misc['Delete topics redirect']); |
---|
679 | } |
---|
680 | |
---|
681 | |
---|
682 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']); |
---|
683 | define('PUN_ACTIVE_PAGE', 'index'); |
---|
684 | require PUN_ROOT.'header.php'; |
---|
685 | |
---|
686 | ?> |
---|
687 | <div class="blockform"> |
---|
688 | <h2><span><?php echo $lang_misc['Delete topics'] ?></span></h2> |
---|
689 | <div class="box"> |
---|
690 | <form method="post" action="moderate.php?fid=<?php echo $fid ?>"> |
---|
691 | <input type="hidden" name="topics" value="<?php echo implode(',', array_map('intval', array_keys($topics))) ?>" /> |
---|
692 | <div class="inform"> |
---|
693 | <fieldset> |
---|
694 | <legend><?php echo $lang_misc['Confirm delete legend'] ?></legend> |
---|
695 | <div class="infldset"> |
---|
696 | <p><?php echo $lang_misc['Delete topics comply'] ?></p> |
---|
697 | </div> |
---|
698 | </fieldset> |
---|
699 | </div> |
---|
700 | <p class="buttons"><input type="submit" name="delete_topics_comply" value="<?php echo $lang_misc['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p> |
---|
701 | </form> |
---|
702 | </div> |
---|
703 | </div> |
---|
704 | <?php |
---|
705 | |
---|
706 | require PUN_ROOT.'footer.php'; |
---|
707 | } |
---|
708 | |
---|
709 | |
---|
710 | // Open or close one or more topics |
---|
711 | else if (isset($_REQUEST['open']) || isset($_REQUEST['close'])) |
---|
712 | { |
---|
713 | $action = (isset($_REQUEST['open'])) ? 0 : 1; |
---|
714 | |
---|
715 | // There could be an array of topic IDs in $_POST |
---|
716 | if (isset($_POST['open']) || isset($_POST['close'])) |
---|
717 | { |
---|
718 | confirm_referrer('moderate.php'); |
---|
719 | |
---|
720 | $topics = isset($_POST['topics']) ? @array_map('intval', @array_keys($_POST['topics'])) : array(); |
---|
721 | if (empty($topics)) |
---|
722 | message($lang_misc['No topics selected']); |
---|
723 | |
---|
724 | $db->query('UPDATE '.$db->prefix.'topics SET closed='.$action.' WHERE id IN('.implode(',', $topics).') AND forum_id='.$fid) or error('Unable to close topics', __FILE__, __LINE__, $db->error()); |
---|
725 | |
---|
726 | $redirect_msg = ($action) ? $lang_misc['Close topics redirect'] : $lang_misc['Open topics redirect']; |
---|
727 | redirect('moderate.php?fid='.$fid, $redirect_msg); |
---|
728 | } |
---|
729 | // Or just one in $_GET |
---|
730 | else |
---|
731 | { |
---|
732 | confirm_referrer('viewtopic.php'); |
---|
733 | |
---|
734 | $topic_id = ($action) ? intval($_GET['close']) : intval($_GET['open']); |
---|
735 | if ($topic_id < 1) |
---|
736 | message($lang_common['Bad request']); |
---|
737 | |
---|
738 | $db->query('UPDATE '.$db->prefix.'topics SET closed='.$action.' WHERE id='.$topic_id.' AND forum_id='.$fid) or error('Unable to close topic', __FILE__, __LINE__, $db->error()); |
---|
739 | |
---|
740 | $redirect_msg = ($action) ? $lang_misc['Close topic redirect'] : $lang_misc['Open topic redirect']; |
---|
741 | redirect('viewtopic.php?id='.$topic_id, $redirect_msg); |
---|
742 | } |
---|
743 | } |
---|
744 | |
---|
745 | |
---|
746 | // Stick a topic |
---|
747 | else if (isset($_GET['stick'])) |
---|
748 | { |
---|
749 | confirm_referrer('viewtopic.php'); |
---|
750 | |
---|
751 | $stick = intval($_GET['stick']); |
---|
752 | if ($stick < 1) |
---|
753 | message($lang_common['Bad request']); |
---|
754 | |
---|
755 | $db->query('UPDATE '.$db->prefix.'topics SET sticky=\'1\' WHERE id='.$stick.' AND forum_id='.$fid) or error('Unable to stick topic', __FILE__, __LINE__, $db->error()); |
---|
756 | |
---|
757 | redirect('viewtopic.php?id='.$stick, $lang_misc['Stick topic redirect']); |
---|
758 | } |
---|
759 | |
---|
760 | |
---|
761 | // Unstick a topic |
---|
762 | else if (isset($_GET['unstick'])) |
---|
763 | { |
---|
764 | confirm_referrer('viewtopic.php'); |
---|
765 | |
---|
766 | $unstick = intval($_GET['unstick']); |
---|
767 | if ($unstick < 1) |
---|
768 | message($lang_common['Bad request']); |
---|
769 | |
---|
770 | $db->query('UPDATE '.$db->prefix.'topics SET sticky=\'0\' WHERE id='.$unstick.' AND forum_id='.$fid) or error('Unable to unstick topic', __FILE__, __LINE__, $db->error()); |
---|
771 | |
---|
772 | redirect('viewtopic.php?id='.$unstick, $lang_misc['Unstick topic redirect']); |
---|
773 | } |
---|
774 | |
---|
775 | |
---|
776 | // No specific forum moderation action was specified in the query string, so we'll display the moderator forum |
---|
777 | |
---|
778 | // Load the viewforum.php language file |
---|
779 | require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php'; |
---|
780 | |
---|
781 | // Fetch some info about the forum |
---|
782 | $result = $db->query('SELECT f.forum_name, f.redirect_url, f.num_topics, f.sort_by FROM '.$db->prefix.'forums AS f 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 f.id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error()); |
---|
783 | if (!$db->num_rows($result)) |
---|
784 | message($lang_common['Bad request']); |
---|
785 | |
---|
786 | $cur_forum = $db->fetch_assoc($result); |
---|
787 | |
---|
788 | // Is this a redirect forum? In that case, abort! |
---|
789 | if ($cur_forum['redirect_url'] != '') |
---|
790 | message($lang_common['Bad request']); |
---|
791 | |
---|
792 | switch ($cur_forum['sort_by']) |
---|
793 | { |
---|
794 | case 0: |
---|
795 | $sort_by = 'last_post DESC'; |
---|
796 | break; |
---|
797 | case 1: |
---|
798 | $sort_by = 'posted DESC'; |
---|
799 | break; |
---|
800 | case 2: |
---|
801 | $sort_by = 'subject ASC'; |
---|
802 | break; |
---|
803 | default: |
---|
804 | $sort_by = 'last_post DESC'; |
---|
805 | break; |
---|
806 | } |
---|
807 | |
---|
808 | // Determine the topic offset (based on $_GET['p']) |
---|
809 | $num_pages = ceil($cur_forum['num_topics'] / $pun_user['disp_topics']); |
---|
810 | |
---|
811 | $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']); |
---|
812 | $start_from = $pun_user['disp_topics'] * ($p - 1); |
---|
813 | |
---|
814 | // Generate paging links |
---|
815 | $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'moderate.php?fid='.$fid); |
---|
816 | |
---|
817 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), pun_htmlspecialchars($cur_forum['forum_name'])); |
---|
818 | define('PUN_ACTIVE_PAGE', 'index'); |
---|
819 | require PUN_ROOT.'header.php'; |
---|
820 | |
---|
821 | ?> |
---|
822 | <div class="linkst"> |
---|
823 | <div class="inbox crumbsplus"> |
---|
824 | <ul class="crumbs"> |
---|
825 | <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li> |
---|
826 | <li><span>» </span><a href="viewforum.php?id=<?php echo $fid ?>"><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></a></li> |
---|
827 | <li><span>» </span><strong><?php echo $lang_misc['Moderate'] ?></strong></li> |
---|
828 | </ul> |
---|
829 | <div class="pagepost"> |
---|
830 | <p class="pagelink conl"><?php echo $paging_links ?></p> |
---|
831 | </div> |
---|
832 | <div class="clearer"></div> |
---|
833 | </div> |
---|
834 | </div> |
---|
835 | |
---|
836 | <form method="post" action="moderate.php?fid=<?php echo $fid ?>"> |
---|
837 | <div id="vf" class="blocktable"> |
---|
838 | <h2><span><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></span></h2> |
---|
839 | <div class="box"> |
---|
840 | <div class="inbox"> |
---|
841 | <table cellspacing="0"> |
---|
842 | <thead> |
---|
843 | <tr> |
---|
844 | <th class="tcl" scope="col"><?php echo $lang_common['Topic'] ?></th> |
---|
845 | <th class="tc2" scope="col"><?php echo $lang_common['Replies'] ?></th> |
---|
846 | <?php if ($pun_config['o_topic_views'] == '1'): ?> <th class="tc3" scope="col"><?php echo $lang_forum['Views'] ?></th> |
---|
847 | <?php endif; ?> <th class="tcr"><?php echo $lang_common['Last post'] ?></th> |
---|
848 | <th class="tcmod" scope="col"><?php echo $lang_misc['Select'] ?></th> |
---|
849 | </tr> |
---|
850 | </thead> |
---|
851 | <tbody> |
---|
852 | <?php |
---|
853 | |
---|
854 | |
---|
855 | // Retrieve a list of topic IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data |
---|
856 | $result = $db->query('SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$fid.' ORDER BY sticky DESC, '.$sort_by.', id DESC LIMIT '.$start_from.', '.$pun_user['disp_topics']) or error('Unable to fetch topic IDs', __FILE__, __LINE__, $db->error()); |
---|
857 | |
---|
858 | // If there are topics in this forum |
---|
859 | if ($db->num_rows($result)) |
---|
860 | { |
---|
861 | $topic_ids = array(); |
---|
862 | for ($i = 0;$cur_topic_id = $db->result($result, $i);$i++) |
---|
863 | $topic_ids[] = $cur_topic_id; |
---|
864 | |
---|
865 | // Select topics |
---|
866 | $result = $db->query('SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $topic_ids).') ORDER BY sticky DESC, '.$sort_by.', id DESC') or error('Unable to fetch topic list for forum', __FILE__, __LINE__, $db->error()); |
---|
867 | |
---|
868 | $button_status = ''; |
---|
869 | $topic_count = 0; |
---|
870 | while ($cur_topic = $db->fetch_assoc($result)) |
---|
871 | { |
---|
872 | |
---|
873 | ++$topic_count; |
---|
874 | $status_text = array(); |
---|
875 | $item_status = ($topic_count % 2 == 0) ? 'roweven' : 'rowodd'; |
---|
876 | $icon_type = 'icon'; |
---|
877 | |
---|
878 | if ($cur_topic['moved_to'] == null) |
---|
879 | { |
---|
880 | $last_post = '<a href="viewtopic.php?pid='.$cur_topic['last_post_id'].'#p'.$cur_topic['last_post_id'].'">'.format_time($cur_topic['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['last_poster']).'</span>'; |
---|
881 | $ghost_topic = false; |
---|
882 | } |
---|
883 | else |
---|
884 | { |
---|
885 | $last_post = '- - -'; |
---|
886 | $ghost_topic = true; |
---|
887 | } |
---|
888 | |
---|
889 | if ($pun_config['o_censoring'] == '1') |
---|
890 | $cur_topic['subject'] = censor_words($cur_topic['subject']); |
---|
891 | |
---|
892 | if ($cur_topic['sticky'] == '1') |
---|
893 | { |
---|
894 | $item_status .= ' isticky'; |
---|
895 | $status_text[] = '<span class="stickytext">'.$lang_forum['Sticky'].'</span>'; |
---|
896 | } |
---|
897 | |
---|
898 | if ($cur_topic['moved_to'] != 0) |
---|
899 | { |
---|
900 | $subject = '<a href="viewtopic.php?id='.$cur_topic['moved_to'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>'; |
---|
901 | $status_text[] = '<span class="movedtext">'.$lang_forum['Moved'].'</span>'; |
---|
902 | $item_status .= ' imoved'; |
---|
903 | } |
---|
904 | else if ($cur_topic['closed'] == '0') |
---|
905 | $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>'; |
---|
906 | else |
---|
907 | { |
---|
908 | $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>'; |
---|
909 | $status_text[] = '<span class="closedtext">'.$lang_forum['Closed'].'</span>'; |
---|
910 | $item_status .= ' iclosed'; |
---|
911 | } |
---|
912 | |
---|
913 | if (!$ghost_topic && $cur_topic['last_post'] > $pun_user['last_visit'] && (!isset($tracked_topics['topics'][$cur_topic['id']]) || $tracked_topics['topics'][$cur_topic['id']] < $cur_topic['last_post']) && (!isset($tracked_topics['forums'][$fid]) || $tracked_topics['forums'][$fid] < $cur_topic['last_post'])) |
---|
914 | { |
---|
915 | $item_status .= ' inew'; |
---|
916 | $icon_type = 'icon icon-new'; |
---|
917 | $subject = '<strong>'.$subject.'</strong>'; |
---|
918 | $subject_new_posts = '<span class="newtext">[ <a href="viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.$lang_common['New posts info'].'">'.$lang_common['New posts'].'</a> ]</span>'; |
---|
919 | } |
---|
920 | else |
---|
921 | $subject_new_posts = null; |
---|
922 | |
---|
923 | // Insert the status text before the subject |
---|
924 | $subject = implode(' ', $status_text).' '.$subject; |
---|
925 | |
---|
926 | $num_pages_topic = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']); |
---|
927 | |
---|
928 | if ($num_pages_topic > 1) |
---|
929 | $subject_multipage = '<span class="pagestext">[ '.paginate($num_pages_topic, -1, 'viewtopic.php?id='.$cur_topic['id']).' ]</span>'; |
---|
930 | else |
---|
931 | $subject_multipage = null; |
---|
932 | |
---|
933 | // Should we show the "New posts" and/or the multipage links? |
---|
934 | if (!empty($subject_new_posts) || !empty($subject_multipage)) |
---|
935 | { |
---|
936 | $subject .= !empty($subject_new_posts) ? ' '.$subject_new_posts : ''; |
---|
937 | $subject .= !empty($subject_multipage) ? ' '.$subject_multipage : ''; |
---|
938 | } |
---|
939 | |
---|
940 | ?> |
---|
941 | <tr class="<?php echo $item_status ?>"> |
---|
942 | <td class="tcl"> |
---|
943 | <div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo forum_number_format($topic_count + $start_from) ?></div></div> |
---|
944 | <div class="tclcon"> |
---|
945 | <div> |
---|
946 | <?php echo $subject."\n" ?> |
---|
947 | </div> |
---|
948 | </div> |
---|
949 | </td> |
---|
950 | <td class="tc2"><?php echo (!$ghost_topic) ? forum_number_format($cur_topic['num_replies']) : '-' ?></td> |
---|
951 | <?php if ($pun_config['o_topic_views'] == '1'): ?> <td class="tc3"><?php echo (!$ghost_topic) ? forum_number_format($cur_topic['num_views']) : '-' ?></td> |
---|
952 | <?php endif; ?> <td class="tcr"><?php echo $last_post ?></td> |
---|
953 | <td class="tcmod"><input type="checkbox" name="topics[<?php echo $cur_topic['id'] ?>]" value="1" /></td> |
---|
954 | </tr> |
---|
955 | <?php |
---|
956 | |
---|
957 | } |
---|
958 | } |
---|
959 | else |
---|
960 | { |
---|
961 | $colspan = ($pun_config['o_topic_views'] == '1') ? 5 : 4; |
---|
962 | $button_status = ' disabled="disabled"'; |
---|
963 | echo "\t\t\t\t\t".'<tr><td class="tcl" colspan="'.$colspan.'">'.$lang_forum['Empty forum'].'</td></tr>'."\n"; |
---|
964 | } |
---|
965 | |
---|
966 | ?> |
---|
967 | </tbody> |
---|
968 | </table> |
---|
969 | </div> |
---|
970 | </div> |
---|
971 | </div> |
---|
972 | |
---|
973 | <div class="linksb"> |
---|
974 | <div class="inbox crumbsplus"> |
---|
975 | <div class="pagepost"> |
---|
976 | <p class="pagelink conl"><?php echo $paging_links ?></p> |
---|
977 | <p class="conr modbuttons"><input type="submit" name="move_topics" value="<?php echo $lang_misc['Move'] ?>"<?php echo $button_status ?> /> <input type="submit" name="delete_topics" value="<?php echo $lang_misc['Delete'] ?>"<?php echo $button_status ?> /> <input type="submit" name="merge_topics" value="<?php echo $lang_misc['Merge'] ?>"<?php echo $button_status ?> /> <input type="submit" name="open" value="<?php echo $lang_misc['Open'] ?>"<?php echo $button_status ?> /> <input type="submit" name="close" value="<?php echo $lang_misc['Close'] ?>"<?php echo $button_status ?> /></p> |
---|
978 | <div class="clearer"></div> |
---|
979 | </div> |
---|
980 | <ul class="crumbs"> |
---|
981 | <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li> |
---|
982 | <li><span>» </span><a href="viewforum.php?id=<?php echo $fid ?>"><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></a></li> |
---|
983 | <li><span>» </span><strong><?php echo $lang_misc['Moderate'] ?></strong></li> |
---|
984 | </ul> |
---|
985 | <div class="clearer"></div> |
---|
986 | </div> |
---|
987 | </div> |
---|
988 | </form> |
---|
989 | <?php |
---|
990 | |
---|
991 | require PUN_ROOT.'footer.php'; |
---|