21 MA 02111-1307 USA |
21 MA 02111-1307 USA |
22 |
22 |
23 ************************************************************************/ |
23 ************************************************************************/ |
24 |
24 |
25 |
25 |
26 define('PUN_ROOT', './'); |
26 //define('PUN_ROOT', './'); |
27 require PUN_ROOT.'include/common.php'; |
27 //require PUN_ROOT.'include/common.php'; |
|
28 |
|
29 global $pun_db, $pun_user, $pun_config, $lang_common; |
|
30 |
28 |
31 |
29 |
32 |
30 // This particular function doesn't require forum-based moderator access. It can be used |
33 // This particular function doesn't require forum-based moderator access. It can be used |
31 // by all moderators and admins. |
34 // by all moderators and admins. |
32 if (isset($_GET['get_host'])) |
35 if (isset($_GET['get_host'])) |
33 { |
36 { |
34 if ($pun_user['g_id'] > PUN_MOD) |
37 if ($pun_user['g_id'] < PUN_MOD) |
35 message($lang_common['No permission']); |
38 message($lang_common['No permission']); |
36 |
39 |
37 // Is get_host an IP address or a post ID? |
40 // Is get_host an IP address or a post ID? |
38 if (@preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $_GET['get_host'])) |
41 if (@preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $_GET['get_host'])) |
39 $ip = $_GET['get_host']; |
42 $ip = $_GET['get_host']; |
41 { |
44 { |
42 $get_host = intval($_GET['get_host']); |
45 $get_host = intval($_GET['get_host']); |
43 if ($get_host < 1) |
46 if ($get_host < 1) |
44 message($lang_common['Bad request']); |
47 message($lang_common['Bad request']); |
45 |
48 |
46 $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()); |
49 $result = $pun_db->query('SELECT poster_ip FROM '.$pun_db->prefix.'posts WHERE id='.$get_host) or error('Unable to fetch post IP address', __FILE__, __LINE__, $pun_db->error()); |
47 if (!$db->num_rows($result)) |
50 if (!$pun_db->num_rows($result)) |
48 message($lang_common['Bad request']); |
51 message($lang_common['Bad request']); |
49 |
52 |
50 $ip = $db->result($result); |
53 $ip = $pun_db->result($result); |
51 } |
54 } |
52 |
55 |
53 message('The IP address is: '.$ip.'<br />The host name is: '.@gethostbyaddr($ip).'<br /><br /><a href="admin_users.php?show_users='.$ip.'">Show more users for this IP</a>'); |
56 message('The IP address is: '.$ip.'<br />The host name is: '.@gethostbyaddr($ip).'<br /><br /><a href="admin_users.php?show_users='.$ip.'">Show more users for this IP</a>'); |
54 } |
57 } |
55 |
58 |
57 // All other functions require moderator/admin access |
60 // All other functions require moderator/admin access |
58 $fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0; |
61 $fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0; |
59 if ($fid < 1) |
62 if ($fid < 1) |
60 message($lang_common['Bad request']); |
63 message($lang_common['Bad request']); |
61 |
64 |
62 $result = $db->query('SELECT moderators FROM '.$db->prefix.'forums WHERE id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error()); |
65 $result = $pun_db->query('SELECT moderators FROM '.$pun_db->prefix.'forums WHERE id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $pun_db->error()); |
63 |
66 |
64 $moderators = $db->result($result); |
67 $moderators = $pun_db->result($result); |
65 $mods_array = ($moderators != '') ? unserialize($moderators) : array(); |
68 $mods_array = ($moderators != '') ? unserialize($moderators) : array(); |
66 |
69 |
67 if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_id'] != PUN_MOD || !array_key_exists($pun_user['username'], $mods_array))) |
70 if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_id'] != PUN_MOD || !array_key_exists($pun_user['username'], $mods_array))) |
68 message($lang_common['No permission']); |
71 message($lang_common['No permission']); |
69 |
72 |
78 $tid = intval($_GET['tid']); |
81 $tid = intval($_GET['tid']); |
79 if ($tid < 1) |
82 if ($tid < 1) |
80 message($lang_common['Bad request']); |
83 message($lang_common['Bad request']); |
81 |
84 |
82 // Fetch some info about the topic |
85 // Fetch some info about the topic |
83 $result = $db->query('SELECT t.subject, t.num_replies, 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.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['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()); |
86 $result = $pun_db->query('SELECT t.subject, t.num_replies, f.id AS forum_id, forum_name FROM '.$pun_db->prefix.'topics AS t INNER JOIN '.$pun_db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$pun_db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['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 f.id='.$fid.' AND t.id='.$tid.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $pun_db->error()); |
84 if (!$db->num_rows($result)) |
87 if (!$pun_db->num_rows($result)) |
85 message($lang_common['Bad request']); |
88 message($lang_common['Bad request']); |
86 |
89 |
87 $cur_topic = $db->fetch_assoc($result); |
90 $cur_topic = $pun_db->fetch_assoc($result); |
88 |
91 |
89 |
92 |
90 // Delete one or more posts |
93 // Delete one or more posts |
91 if (isset($_POST['delete_posts']) || isset($_POST['delete_posts_comply'])) |
94 if (isset($_POST['delete_posts']) || isset($_POST['delete_posts_comply'])) |
92 { |
95 { |
100 |
103 |
101 if (@preg_match('/[^0-9,]/', $posts)) |
104 if (@preg_match('/[^0-9,]/', $posts)) |
102 message($lang_common['Bad request']); |
105 message($lang_common['Bad request']); |
103 |
106 |
104 // Verify that the post IDs are valid |
107 // Verify that the post IDs are valid |
105 $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()); |
108 $result = $pun_db->query('SELECT 1 FROM '.$pun_db->prefix.'posts WHERE id IN('.$posts.') AND topic_id='.$tid) or error('Unable to check posts', __FILE__, __LINE__, $pun_db->error()); |
106 |
109 |
107 if ($db->num_rows($result) != substr_count($posts, ',') + 1) |
110 if ($pun_db->num_rows($result) != substr_count($posts, ',') + 1) |
108 message($lang_common['Bad request']); |
111 message($lang_common['Bad request']); |
109 |
112 |
110 // Delete the posts |
113 // Delete the posts |
111 $db->query('DELETE FROM '.$db->prefix.'posts WHERE id IN('.$posts.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error()); |
114 $pun_db->query('DELETE FROM '.$pun_db->prefix.'posts WHERE id IN('.$posts.')') or error('Unable to delete posts', __FILE__, __LINE__, $pun_db->error()); |
112 |
115 |
113 require PUN_ROOT.'include/search_idx.php'; |
116 require PUN_ROOT.'include/search_idx.php'; |
114 strip_search_index($posts); |
117 strip_search_index($posts); |
115 |
118 |
116 // Get last_post, last_post_id, and last_poster for the topic after deletion |
119 // Get last_post, last_post_id, and last_poster for the topic after deletion |
117 $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()); |
120 $result = $pun_db->query('SELECT id, poster, posted FROM '.$pun_db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); |
118 $last_post = $db->fetch_assoc($result); |
121 $last_post = $pun_db->fetch_assoc($result); |
119 |
122 |
120 // How many posts did we just delete? |
123 // How many posts did we just delete? |
121 $num_posts_deleted = substr_count($posts, ',') + 1; |
124 $num_posts_deleted = substr_count($posts, ',') + 1; |
122 |
125 |
123 // Update the topic |
126 // Update the topic |
124 $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()); |
127 $pun_db->query('UPDATE '.$pun_db->prefix.'topics SET last_post='.$last_post['posted'].', last_post_id='.$last_post['id'].', last_poster=\''.$pun_db->escape($last_post['poster']).'\', num_replies=num_replies-'.$num_posts_deleted.' WHERE id='.$tid) or error('Unable to update topic', __FILE__, __LINE__, $pun_db->error()); |
125 |
128 |
126 update_forum($fid); |
129 update_forum($fid); |
127 |
130 |
128 redirect('viewtopic.php?id='.$tid, $lang_misc['Delete posts redirect']); |
131 pun_redirect('viewtopic.php?id='.$tid, $lang_misc['Delete posts redirect']); |
129 } |
132 } |
130 |
133 |
131 |
134 |
132 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate']; |
135 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate']; |
133 require PUN_ROOT.'header.php'; |
136 require PUN_ROOT.'header.php'; |
198 |
201 |
199 $bg_switch = true; // Used for switching background color in posts |
202 $bg_switch = true; // Used for switching background color in posts |
200 $post_count = 0; // Keep track of post numbers |
203 $post_count = 0; // Keep track of post numbers |
201 |
204 |
202 // Retrieve the posts (and their respective poster) |
205 // Retrieve the posts (and their respective poster) |
203 $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.topic_id='.$tid.' ORDER BY p.id LIMIT '.$start_from.','.$pun_user['disp_posts'], true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
206 $result = $pun_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 '.$pun_db->prefix.'posts AS p INNER JOIN '.$pun_db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$pun_db->prefix.'groups AS g ON g.g_id=u.group_id WHERE p.topic_id='.$tid.' ORDER BY p.id LIMIT '.$start_from.','.$pun_user['disp_posts'], true) or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error()); |
204 |
207 |
205 while ($cur_post = $db->fetch_assoc($result)) |
208 while ($cur_post = $pun_db->fetch_assoc($result)) |
206 { |
209 { |
207 $post_count++; |
210 $post_count++; |
208 |
211 |
209 // If the poster is a registered user. |
212 // If the poster is a registered user. |
210 if ($cur_post['poster_id'] > 1) |
213 if ($cur_post['poster_id'] > 1) |
294 $move_to_forum = isset($_POST['move_to_forum']) ? intval($_POST['move_to_forum']) : 0; |
297 $move_to_forum = isset($_POST['move_to_forum']) ? intval($_POST['move_to_forum']) : 0; |
295 if (empty($topics) || $move_to_forum < 1) |
298 if (empty($topics) || $move_to_forum < 1) |
296 message($lang_common['Bad request']); |
299 message($lang_common['Bad request']); |
297 |
300 |
298 // Verify that the topic IDs are valid |
301 // Verify that the topic IDs are valid |
299 $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()); |
302 $result = $pun_db->query('SELECT 1 FROM '.$pun_db->prefix.'topics WHERE id IN('.implode(',',$topics).') AND forum_id='.$fid) or error('Unable to check topics', __FILE__, __LINE__, $pun_db->error()); |
300 |
303 |
301 if ($db->num_rows($result) != count($topics)) |
304 if ($pun_db->num_rows($result) != count($topics)) |
302 message($lang_common['Bad request']); |
305 message($lang_common['Bad request']); |
303 |
306 |
304 // Delete any redirect topics if there are any (only if we moved/copied the topic back to where it where it was once moved from) |
307 // Delete any redirect topics if there are any (only if we moved/copied the topic back to where it where it was once moved from) |
305 $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()); |
308 $pun_db->query('DELETE FROM '.$pun_db->prefix.'topics WHERE forum_id='.$move_to_forum.' AND moved_to IN('.implode(',',$topics).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $pun_db->error()); |
306 |
309 |
307 // Move the topic(s) |
310 // Move the topic(s) |
308 $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()); |
311 $pun_db->query('UPDATE '.$pun_db->prefix.'topics SET forum_id='.$move_to_forum.' WHERE id IN('.implode(',',$topics).')') or error('Unable to move topics', __FILE__, __LINE__, $pun_db->error()); |
309 |
312 |
310 // Should we create redirect topics? |
313 // Should we create redirect topics? |
311 if (isset($_POST['with_redirect'])) |
314 if (isset($_POST['with_redirect'])) |
312 { |
315 { |
313 while (list(, $cur_topic) = @each($topics)) |
316 while (list(, $cur_topic) = @each($topics)) |
314 { |
317 { |
315 // Fetch info for the redirect topic |
318 // Fetch info for the redirect topic |
316 $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()); |
319 $result = $pun_db->query('SELECT poster, subject, posted, last_post FROM '.$pun_db->prefix.'topics WHERE id='.$cur_topic) or error('Unable to fetch topic info', __FILE__, __LINE__, $pun_db->error()); |
317 $moved_to = $db->fetch_assoc($result); |
320 $moved_to = $pun_db->fetch_assoc($result); |
318 |
321 |
319 // Create the redirect topic |
322 // Create the redirect topic |
320 $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()); |
323 $pun_db->query('INSERT INTO '.$pun_db->prefix.'topics (poster, subject, posted, last_post, moved_to, forum_id) VALUES(\''.$pun_db->escape($moved_to['poster']).'\', \''.$pun_db->escape($moved_to['subject']).'\', '.$moved_to['posted'].', '.$moved_to['last_post'].', '.$cur_topic.', '.$fid.')') or error('Unable to create redirect topic', __FILE__, __LINE__, $pun_db->error()); |
321 } |
324 } |
322 } |
325 } |
323 |
326 |
324 update_forum($fid); // Update the forum FROM which the topic was moved |
327 update_forum($fid); // Update the forum FROM which the topic was moved |
325 update_forum($move_to_forum); // Update the forum TO which the topic was moved |
328 update_forum($move_to_forum); // Update the forum TO which the topic was moved |
326 |
329 |
327 $redirect_msg = (count($topics) > 1) ? $lang_misc['Move topics redirect'] : $lang_misc['Move topic redirect']; |
330 $redirect_msg = (count($topics) > 1) ? $lang_misc['Move topics redirect'] : $lang_misc['Move topic redirect']; |
328 redirect('viewforum.php?id='.$move_to_forum, $redirect_msg); |
331 pun_redirect('viewforum.php?id='.$move_to_forum, $redirect_msg); |
329 } |
332 } |
330 |
333 |
331 if (isset($_POST['move_topics'])) |
334 if (isset($_POST['move_topics'])) |
332 { |
335 { |
333 $topics = isset($_POST['topics']) ? $_POST['topics'] : array(); |
336 $topics = isset($_POST['topics']) ? $_POST['topics'] : array(); |
361 <div class="infldset"> |
364 <div class="infldset"> |
362 <label><?php echo $lang_misc['Move to'] ?> |
365 <label><?php echo $lang_misc['Move to'] ?> |
363 <br /><select name="move_to_forum"> |
366 <br /><select name="move_to_forum"> |
364 <?php |
367 <?php |
365 |
368 |
366 $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.read_forum IS NULL OR fp.read_forum=1) AND f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); |
369 $result = $pun_db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name FROM '.$pun_db->prefix.'categories AS c INNER JOIN '.$pun_db->prefix.'forums AS f ON c.id=f.cat_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 f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $pun_db->error()); |
367 |
370 |
368 $cur_category = 0; |
371 $cur_category = 0; |
369 while ($cur_forum = $db->fetch_assoc($result)) |
372 while ($cur_forum = $pun_db->fetch_assoc($result)) |
370 { |
373 { |
371 if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
374 if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
372 { |
375 { |
373 if ($cur_category) |
376 if ($cur_category) |
374 echo "\t\t\t\t\t\t\t".'</optgroup>'."\n"; |
377 echo "\t\t\t\t\t\t\t".'</optgroup>'."\n"; |
416 message($lang_common['Bad request']); |
419 message($lang_common['Bad request']); |
417 |
420 |
418 require PUN_ROOT.'include/search_idx.php'; |
421 require PUN_ROOT.'include/search_idx.php'; |
419 |
422 |
420 // Verify that the topic IDs are valid |
423 // Verify that the topic IDs are valid |
421 $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()); |
424 $result = $pun_db->query('SELECT 1 FROM '.$pun_db->prefix.'topics WHERE id IN('.$topics.') AND forum_id='.$fid) or error('Unable to check topics', __FILE__, __LINE__, $pun_db->error()); |
422 |
425 |
423 if ($db->num_rows($result) != substr_count($topics, ',') + 1) |
426 if ($pun_db->num_rows($result) != substr_count($topics, ',') + 1) |
424 message($lang_common['Bad request']); |
427 message($lang_common['Bad request']); |
425 |
428 |
426 // Delete the topics and any redirect topics |
429 // Delete the topics and any redirect topics |
427 $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()); |
430 $pun_db->query('DELETE FROM '.$pun_db->prefix.'topics WHERE id IN('.$topics.') OR moved_to IN('.$topics.')') or error('Unable to delete topic', __FILE__, __LINE__, $pun_db->error()); |
428 |
431 |
429 // Delete any subscriptions |
432 // Delete any subscriptions |
430 $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE topic_id IN('.$topics.')') or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error()); |
433 $pun_db->query('DELETE FROM '.$pun_db->prefix.'subscriptions WHERE topic_id IN('.$topics.')') or error('Unable to delete subscriptions', __FILE__, __LINE__, $pun_db->error()); |
431 |
434 |
432 // Create a list of the post ID's in this topic and then strip the search index |
435 // Create a list of the post ID's in this topic and then strip the search index |
433 $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to fetch posts', __FILE__, __LINE__, $db->error()); |
436 $result = $pun_db->query('SELECT id FROM '.$pun_db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to fetch posts', __FILE__, __LINE__, $pun_db->error()); |
434 |
437 |
435 $post_ids = ''; |
438 $post_ids = ''; |
436 while ($row = $db->fetch_row($result)) |
439 while ($row = $pun_db->fetch_row($result)) |
437 $post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0]; |
440 $post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0]; |
438 |
441 |
439 // We have to check that we actually have a list of post ID's since we could be deleting just a redirect topic |
442 // We have to check that we actually have a list of post ID's since we could be deleting just a redirect topic |
440 if ($post_ids != '') |
443 if ($post_ids != '') |
441 strip_search_index($post_ids); |
444 strip_search_index($post_ids); |
442 |
445 |
443 // Delete posts |
446 // Delete posts |
444 $db->query('DELETE FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error()); |
447 $pun_db->query('DELETE FROM '.$pun_db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to delete posts', __FILE__, __LINE__, $pun_db->error()); |
445 |
448 |
446 update_forum($fid); |
449 update_forum($fid); |
447 |
450 |
448 redirect('viewforum.php?id='.$fid, $lang_misc['Delete topics redirect']); |
451 pun_redirect('viewforum.php?id='.$fid, $lang_misc['Delete topics redirect']); |
449 } |
452 } |
450 |
453 |
451 |
454 |
452 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate']; |
455 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate']; |
453 require PUN_ROOT.'header.php'; |
456 require PUN_ROOT.'header.php'; |
488 |
491 |
489 $topics = isset($_POST['topics']) ? @array_map('intval', @array_keys($_POST['topics'])) : array(); |
492 $topics = isset($_POST['topics']) ? @array_map('intval', @array_keys($_POST['topics'])) : array(); |
490 if (empty($topics)) |
493 if (empty($topics)) |
491 message($lang_misc['No topics selected']); |
494 message($lang_misc['No topics selected']); |
492 |
495 |
493 $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()); |
496 $pun_db->query('UPDATE '.$pun_db->prefix.'topics SET closed='.$action.' WHERE id IN('.implode(',', $topics).') AND forum_id='.$fid) or error('Unable to close topics', __FILE__, __LINE__, $pun_db->error()); |
494 |
497 |
495 $redirect_msg = ($action) ? $lang_misc['Close topics redirect'] : $lang_misc['Open topics redirect']; |
498 $redirect_msg = ($action) ? $lang_misc['Close topics redirect'] : $lang_misc['Open topics redirect']; |
496 redirect('moderate.php?fid='.$fid, $redirect_msg); |
499 pun_redirect('moderate.php?fid='.$fid, $redirect_msg); |
497 } |
500 } |
498 // Or just one in $_GET |
501 // Or just one in $_GET |
499 else |
502 else |
500 { |
503 { |
501 confirm_referrer('viewtopic.php'); |
504 confirm_referrer('viewtopic.php'); |
502 |
505 |
503 $topic_id = ($action) ? intval($_GET['close']) : intval($_GET['open']); |
506 $topic_id = ($action) ? intval($_GET['close']) : intval($_GET['open']); |
504 if ($topic_id < 1) |
507 if ($topic_id < 1) |
505 message($lang_common['Bad request']); |
508 message($lang_common['Bad request']); |
506 |
509 |
507 $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()); |
510 $pun_db->query('UPDATE '.$pun_db->prefix.'topics SET closed='.$action.' WHERE id='.$topic_id.' AND forum_id='.$fid) or error('Unable to close topic', __FILE__, __LINE__, $pun_db->error()); |
508 |
511 |
509 $redirect_msg = ($action) ? $lang_misc['Close topic redirect'] : $lang_misc['Open topic redirect']; |
512 $redirect_msg = ($action) ? $lang_misc['Close topic redirect'] : $lang_misc['Open topic redirect']; |
510 redirect('viewtopic.php?id='.$topic_id, $redirect_msg); |
513 pun_redirect('viewtopic.php?id='.$topic_id, $redirect_msg); |
511 } |
514 } |
512 } |
515 } |
513 |
516 |
514 |
517 |
515 // Stick a topic |
518 // Stick a topic |
534 |
537 |
535 $unstick = intval($_GET['unstick']); |
538 $unstick = intval($_GET['unstick']); |
536 if ($unstick < 1) |
539 if ($unstick < 1) |
537 message($lang_common['Bad request']); |
540 message($lang_common['Bad request']); |
538 |
541 |
539 $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()); |
542 $pun_db->query('UPDATE '.$pun_db->prefix.'topics SET sticky=\'0\' WHERE id='.$unstick.' AND forum_id='.$fid) or error('Unable to unstick topic', __FILE__, __LINE__, $pun_db->error()); |
540 |
543 |
541 redirect('viewtopic.php?id='.$unstick, $lang_misc['Unstick topic redirect']); |
544 pun_redirect('viewtopic.php?id='.$unstick, $lang_misc['Unstick topic redirect']); |
542 } |
545 } |
543 |
546 |
544 |
547 |
545 // No specific forum moderation action was specified in the query string, so we'll display the moderator forum |
548 // No specific forum moderation action was specified in the query string, so we'll display the moderator forum |
546 |
549 |
547 // Load the viewforum.php language file |
550 // Load the viewforum.php language file |
548 require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php'; |
551 require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php'; |
549 |
552 |
550 // Fetch some info about the forum |
553 // Fetch some info about the forum |
551 $result = $db->query('SELECT f.forum_name, f.redirect_url, f.num_topics 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()); |
554 $result = $pun_db->query('SELECT f.forum_name, f.redirect_url, f.num_topics FROM '.$pun_db->prefix.'forums AS f 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 f.id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $pun_db->error()); |
552 if (!$db->num_rows($result)) |
555 if (!$pun_db->num_rows($result)) |
553 message($lang_common['Bad request']); |
556 message($lang_common['Bad request']); |
554 |
557 |
555 $cur_forum = $db->fetch_assoc($result); |
558 $cur_forum = $pun_db->fetch_assoc($result); |
556 |
559 |
557 // Is this a redirect forum? In that case, abort! |
560 // Is this a redirect forum? In that case, abort! |
558 if ($cur_forum['redirect_url'] != '') |
561 if ($cur_forum['redirect_url'] != '') |
559 message($lang_common['Bad request']); |
562 message($lang_common['Bad request']); |
560 |
563 |
596 </thead> |
599 </thead> |
597 <tbody> |
600 <tbody> |
598 <?php |
601 <?php |
599 |
602 |
600 // Select topics |
603 // Select topics |
601 $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 forum_id='.$fid.' ORDER BY sticky DESC, last_post DESC LIMIT '.$start_from.', '.$pun_user['disp_topics']) or error('Unable to fetch topic list for forum', __FILE__, __LINE__, $db->error()); |
604 $result = $pun_db->query('SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$pun_db->prefix.'topics WHERE forum_id='.$fid.' ORDER BY sticky DESC, last_post DESC LIMIT '.$start_from.', '.$pun_user['disp_topics']) or error('Unable to fetch topic list for forum', __FILE__, __LINE__, $pun_db->error()); |
602 |
605 |
603 // If there are topics in this forum. |
606 // If there are topics in this forum. |
604 if ($db->num_rows($result)) |
607 if ($pun_db->num_rows($result)) |
605 { |
608 { |
606 $button_status = ''; |
609 $button_status = ''; |
607 |
610 |
608 while ($cur_topic = $db->fetch_assoc($result)) |
611 while ($cur_topic = $pun_db->fetch_assoc($result)) |
609 { |
612 { |
610 |
613 |
611 $icon_text = $lang_common['Normal icon']; |
614 $icon_text = $lang_common['Normal icon']; |
612 $item_status = ''; |
615 $item_status = ''; |
613 $icon_type = 'icon'; |
616 $icon_type = 'icon'; |