[1] | 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 | |
---|
| 26 | define('PUN_ROOT', './'); |
---|
| 27 | require PUN_ROOT.'include/common.php'; |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | // This particular function doesn't require forum-based moderator access. It can be used |
---|
| 31 | // by all moderators and admins. |
---|
| 32 | if (isset($_GET['get_host'])) |
---|
| 33 | { |
---|
| 34 | if ($pun_user['g_id'] > PUN_MOD) |
---|
| 35 | message($lang_common['No permission']); |
---|
| 36 | |
---|
| 37 | // 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'])) |
---|
| 39 | $ip = $_GET['get_host']; |
---|
| 40 | else |
---|
| 41 | { |
---|
| 42 | $get_host = intval($_GET['get_host']); |
---|
| 43 | if ($get_host < 1) |
---|
| 44 | message($lang_common['Bad request']); |
---|
| 45 | |
---|
| 46 | $result = $db->query('SELECT poster_ip FROM '.$db->prefix.'posts WHERE id='.$get_host) or error('Impossible de retrouver l\'adresse IP', __FILE__, __LINE__, $db->error()); |
---|
| 47 | if (!$db->num_rows($result)) |
---|
| 48 | message($lang_common['Bad request']); |
---|
| 49 | |
---|
| 50 | $ip = $db->result($result); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | message('L\'adresse IP est : '.$ip.'<br />Le nom de l\'hÃŽte est : '.@gethostbyaddr($ip).'<br /><br /><a href="admin_users.php?show_users='.$ip.'">Voir plus d\'utilisateurs pour cette IP</a>'); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | // All other functions require moderator/admin access |
---|
| 58 | $fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0; |
---|
| 59 | if ($fid < 1) |
---|
| 60 | message($lang_common['Bad request']); |
---|
| 61 | |
---|
| 62 | $result = $db->query('SELECT moderators FROM '.$db->prefix.'forums WHERE id='.$fid) or error('UImpossible de retrouver les informations des forums', __FILE__, __LINE__, $db->error()); |
---|
| 63 | |
---|
| 64 | $moderators = $db->result($result); |
---|
| 65 | $mods_array = ($moderators != '') ? unserialize($moderators) : array(); |
---|
| 66 | |
---|
| 67 | 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']); |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | // Load the misc.php language file |
---|
| 72 | require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php'; |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | // All other topic moderation features require a topic id in GET |
---|
| 76 | if (isset($_GET['tid'])) |
---|
| 77 | { |
---|
| 78 | $tid = intval($_GET['tid']); |
---|
| 79 | if ($tid < 1) |
---|
| 80 | message($lang_common['Bad request']); |
---|
| 81 | |
---|
| 82 | // 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('UImpossible de retrouver les informations des discussions', __FILE__, __LINE__, $db->error()); |
---|
| 84 | if (!$db->num_rows($result)) |
---|
| 85 | message($lang_common['Bad request']); |
---|
| 86 | |
---|
| 87 | $cur_topic = $db->fetch_assoc($result); |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | // Delete one or more posts |
---|
| 91 | if (isset($_POST['delete_posts']) || isset($_POST['delete_posts_comply'])) |
---|
| 92 | { |
---|
| 93 | $posts = $_POST['posts']; |
---|
| 94 | if (empty($posts)) |
---|
| 95 | message($lang_misc['No posts selected']); |
---|
| 96 | |
---|
| 97 | if (isset($_POST['delete_posts_comply'])) |
---|
| 98 | { |
---|
| 99 | confirm_referrer('moderate.php'); |
---|
| 100 | |
---|
| 101 | if (preg_match('/[^0-9,]/', $posts)) |
---|
| 102 | message($lang_common['Bad request']); |
---|
| 103 | |
---|
| 104 | // Delete the posts |
---|
| 105 | $db->query('DELETE FROM '.$db->prefix.'posts WHERE id IN('.$posts.')') or error('Impossible de supprimer les messages', __FILE__, __LINE__, $db->error()); |
---|
| 106 | |
---|
| 107 | require PUN_ROOT.'include/search_idx.php'; |
---|
| 108 | strip_search_index($posts); |
---|
| 109 | |
---|
| 110 | // Get last_post, last_post_id, and last_poster for the topic after deletion |
---|
| 111 | $result = $db->query('SELECT id, poster, posted FROM '.$db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id DESC LIMIT 1') or error('Impossible de retrouver les informations du message', __FILE__, __LINE__, $db->error()); |
---|
| 112 | $last_post = $db->fetch_assoc($result); |
---|
| 113 | |
---|
| 114 | // How many posts did we just delete? |
---|
| 115 | $num_posts_deleted = substr_count($posts, ',') + 1; |
---|
| 116 | |
---|
| 117 | // Update the topic |
---|
| 118 | $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('Impossible de modifier la discussion', __FILE__, __LINE__, $db->error()); |
---|
| 119 | |
---|
| 120 | update_forum($fid); |
---|
| 121 | |
---|
| 122 | redirect('viewtopic.php?id='.$tid, $lang_misc['Delete posts redirect']); |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate']; |
---|
| 127 | require PUN_ROOT.'header.php'; |
---|
| 128 | |
---|
| 129 | ?> |
---|
| 130 | <div class="blockform"> |
---|
| 131 | <h2><span><?php echo $lang_misc['Delete posts'] ?></span></h2> |
---|
| 132 | <div class="box"> |
---|
| 133 | <form method="post" action="moderate.php?fid=<?php echo $fid ?>&tid=<?php echo $tid ?>"> |
---|
| 134 | <div class="inform"> |
---|
| 135 | <fieldset> |
---|
| 136 | <legend><?php echo $lang_misc['Confirm delete legend'] ?></legend> |
---|
| 137 | <div class="infldset"> |
---|
| 138 | <input type="hidden" name="posts" value="<?php echo implode(',', array_keys($posts)) ?>" /> |
---|
| 139 | <p><?php echo $lang_misc['Delete posts comply'] ?></p> |
---|
| 140 | </div> |
---|
| 141 | </fieldset> |
---|
| 142 | </div> |
---|
| 143 | <p><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> |
---|
| 144 | </form> |
---|
| 145 | </div> |
---|
| 146 | </div> |
---|
| 147 | <?php |
---|
| 148 | |
---|
| 149 | require PUN_ROOT.'footer.php'; |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | // Show the delete multiple posts view |
---|
| 154 | |
---|
| 155 | // Load the viewtopic.php language file |
---|
| 156 | require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php'; |
---|
| 157 | |
---|
| 158 | // Used to disable the Move and Delete buttons if there are no replies to this topic |
---|
| 159 | $button_status = ($cur_topic['num_replies'] == 0) ? ' disabled' : ''; |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | // Determine the post offset (based on $_GET['p']) |
---|
| 163 | $num_pages = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']); |
---|
| 164 | |
---|
| 165 | $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p']; |
---|
| 166 | $start_from = $pun_user['disp_posts'] * ($p - 1); |
---|
| 167 | |
---|
| 168 | // Generate paging links |
---|
| 169 | $paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'moderate.php?fid='.$fid.'&tid='.$tid); |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | if ($pun_config['o_censoring'] == '1') |
---|
| 173 | $cur_topic['subject'] = censor_words($cur_topic['subject']); |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$cur_topic['subject']; |
---|
| 177 | require PUN_ROOT.'header.php'; |
---|
| 178 | |
---|
| 179 | ?> |
---|
| 180 | <div class="linkst"> |
---|
| 181 | <div class="inbox"> |
---|
| 182 | <p class="pagelink conl"><?php echo $paging_links ?></p> |
---|
| 183 | <ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li> » <a href="viewforum.php?id=<?php echo $fid ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li><li> » <?php echo pun_htmlspecialchars($cur_topic['subject']) ?></li></ul> |
---|
| 184 | <div class="clearer"></div> |
---|
| 185 | </div> |
---|
| 186 | </div> |
---|
| 187 | |
---|
| 188 | <form method="post" action="moderate.php?fid=<?php echo $fid ?>&tid=<?php echo $tid ?>"> |
---|
| 189 | <?php |
---|
| 190 | |
---|
| 191 | require PUN_ROOT.'include/parser.php'; |
---|
| 192 | |
---|
| 193 | $bg_switch = true; // Used for switching background color in posts |
---|
| 194 | $post_count = 0; // Keep track of post numbers |
---|
| 195 | |
---|
| 196 | // Retrieve the posts (and their respective poster) |
---|
| 197 | $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('Impossible de retrouver les informations du message', __FILE__, __LINE__, $db->error()); |
---|
| 198 | |
---|
| 199 | while ($cur_post = $db->fetch_assoc($result)) |
---|
| 200 | { |
---|
| 201 | $post_count++; |
---|
| 202 | |
---|
| 203 | // If the poster is a registered user. |
---|
| 204 | if ($cur_post['poster_id'] > 1) |
---|
| 205 | { |
---|
| 206 | $poster = '<a href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'; |
---|
| 207 | |
---|
| 208 | // get_title() requires that an element 'username' be present in the array |
---|
| 209 | $cur_post['username'] = $cur_post['poster']; |
---|
| 210 | $user_title = get_title($cur_post); |
---|
| 211 | |
---|
| 212 | if ($pun_config['o_censoring'] == '1') |
---|
| 213 | $user_title = censor_words($user_title); |
---|
| 214 | } |
---|
| 215 | // If the poster is a guest (or a user that has been deleted) |
---|
| 216 | else |
---|
| 217 | { |
---|
| 218 | $poster = pun_htmlspecialchars($cur_post['poster']); |
---|
| 219 | $user_title = $lang_topic['Guest']; |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | // Switch the background color for every message. |
---|
| 223 | $bg_switch = ($bg_switch) ? $bg_switch = false : $bg_switch = true; |
---|
| 224 | $vtbg = ($bg_switch) ? ' roweven' : ' rowodd'; |
---|
| 225 | |
---|
| 226 | // Perform the main parsing of the message (BBCode, smilies, censor words etc) |
---|
| 227 | $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']); |
---|
| 228 | |
---|
| 229 | ?> |
---|
| 230 | |
---|
| 231 | <div class="blockpost<?php echo $vtbg ?>"> |
---|
| 232 | <a name="<?php echo $cur_post['id'] ?>"></a> |
---|
| 233 | <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> |
---|
| 234 | <div class="box"> |
---|
| 235 | <div class="inbox"> |
---|
| 236 | <div class="postleft"> |
---|
| 237 | <dl> |
---|
| 238 | <dt><strong><?php echo $poster ?></strong></dt> |
---|
| 239 | <dd><strong><?php echo $user_title ?></strong></dd> |
---|
| 240 | </dl> |
---|
| 241 | </div> |
---|
| 242 | <div class="postright"> |
---|
| 243 | <h3 class="nosize"><?php echo $lang_common['Message'] ?></h3> |
---|
| 244 | <div class="postmsg"> |
---|
| 245 | <?php echo $cur_post['message']."\n" ?> |
---|
| 246 | <?php if ($cur_post['edited'] != '') echo "\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"; ?> |
---|
| 247 | </div> |
---|
| 248 | <?php if ($start_from + $post_count > 1) echo '<p class="multidelete"><label><strong>'.$lang_misc['Select'].'</strong>  <input type="checkbox" name="posts['.$cur_post['id'].']" value="1" /></label></p>'."\n" ?> |
---|
| 249 | </div> |
---|
| 250 | <div class="clearer"></div> |
---|
| 251 | </div> |
---|
| 252 | </div> |
---|
| 253 | </div> |
---|
| 254 | |
---|
| 255 | |
---|
| 256 | |
---|
| 257 | |
---|
| 258 | <?php |
---|
| 259 | |
---|
| 260 | } |
---|
| 261 | |
---|
| 262 | ?> |
---|
| 263 | <div class="postlinksb"> |
---|
| 264 | <div class="inbox"> |
---|
| 265 | <p class="pagelink conl"><?php echo $paging_links ?></p> |
---|
| 266 | <p class="conr"><input type="submit" name="delete_posts" value="<?php echo $lang_misc['Delete'] ?>"<?php echo $button_status ?> /></p> |
---|
| 267 | <div class="clearer"></div> |
---|
| 268 | </div> |
---|
| 269 | </div> |
---|
| 270 | </form> |
---|
| 271 | <?php |
---|
| 272 | |
---|
| 273 | require PUN_ROOT.'footer.php'; |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | |
---|
| 277 | // Move one or more topics |
---|
| 278 | if (isset($_REQUEST['move_topics']) || isset($_POST['move_topics_to'])) |
---|
| 279 | { |
---|
| 280 | if (isset($_POST['move_topics_to'])) |
---|
| 281 | { |
---|
| 282 | confirm_referrer('moderate.php'); |
---|
| 283 | |
---|
| 284 | if (preg_match('/[^0-9,]/', $_POST['topics'])) |
---|
| 285 | message($lang_common['Bad request']); |
---|
| 286 | |
---|
| 287 | $topics = explode(',', $_POST['topics']); |
---|
| 288 | $move_to_forum = isset($_POST['move_to_forum']) ? intval($_POST['move_to_forum']) : 0; |
---|
| 289 | if (empty($topics) || $move_to_forum < 1) |
---|
| 290 | message($lang_common['Bad request']); |
---|
| 291 | |
---|
| 292 | // 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) |
---|
| 293 | $db->query('DELETE FROM '.$db->prefix.'topics WHERE forum_id='.$move_to_forum.' AND moved_to IN('.implode(',',$topics).')') or error('Impossible de supprimer les redirections', __FILE__, __LINE__, $db->error()); |
---|
| 294 | |
---|
| 295 | // Move the topic(s) |
---|
| 296 | $db->query('UPDATE '.$db->prefix.'topics SET forum_id='.$move_to_forum.' WHERE id IN('.implode(',',$topics).')') or error('Impossible de déplacer la discussion', __FILE__, __LINE__, $db->error()); |
---|
| 297 | |
---|
| 298 | // Should we create redirect topics? |
---|
| 299 | if (isset($_POST['with_redirect'])) |
---|
| 300 | { |
---|
| 301 | while (list(, $cur_topic) = @each($topics)) |
---|
| 302 | { |
---|
| 303 | // Fetch info for the redirect topic |
---|
| 304 | $result = $db->query('SELECT poster, subject, posted, last_post FROM '.$db->prefix.'topics WHERE id='.$cur_topic) or error('Impossible de retrouver les informations de la discussions', __FILE__, __LINE__, $db->error()); |
---|
| 305 | $moved_to = $db->fetch_assoc($result); |
---|
| 306 | |
---|
| 307 | // Create the redirect topic |
---|
| 308 | $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('Impossible de créer une redirection', __FILE__, __LINE__, $db->error()); |
---|
| 309 | } |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | update_forum($fid); // Update the forum FROM which the topic was moved |
---|
| 313 | update_forum($move_to_forum); // Update the forum TO which the topic was moved |
---|
| 314 | |
---|
| 315 | $redirect_msg = (count($topics) > 1) ? $lang_misc['Move topics redirect'] : $lang_misc['Move topic redirect']; |
---|
| 316 | redirect('viewforum.php?id='.$move_to_forum, $redirect_msg); |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | if (isset($_POST['move_topics'])) |
---|
| 320 | { |
---|
| 321 | $topics = isset($_POST['topics']) ? $_POST['topics'] : array(); |
---|
| 322 | if (empty($topics)) |
---|
| 323 | message($lang_misc['No topics selected']); |
---|
| 324 | |
---|
| 325 | $topics = implode(',', array_keys($topics)); |
---|
| 326 | $action = 'multi'; |
---|
| 327 | } |
---|
| 328 | else |
---|
| 329 | { |
---|
| 330 | $topics = intval($_GET['move_topics']); |
---|
| 331 | if ($topics < 1) |
---|
| 332 | message($lang_common['Bad request']); |
---|
| 333 | |
---|
| 334 | $action = 'single'; |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate']; |
---|
| 338 | require PUN_ROOT.'header.php'; |
---|
| 339 | |
---|
| 340 | ?> |
---|
| 341 | <div class="blockform"> |
---|
| 342 | <h2><span><?php echo ($action == 'single') ? $lang_misc['Move topic'] : $lang_misc['Move topics'] ?></span></h2> |
---|
| 343 | <div class="box"> |
---|
| 344 | <form method="post" action="moderate.php?fid=<?php echo $fid ?>"> |
---|
| 345 | <div class="inform"> |
---|
| 346 | <input type="hidden" name="topics" value="<?php echo $topics ?>" /> |
---|
| 347 | <fieldset> |
---|
| 348 | <legend><?php echo $lang_misc['Move legend'] ?></legend> |
---|
| 349 | <div class="infldset"> |
---|
| 350 | <label><?php echo $lang_misc['Move to'] ?> |
---|
| 351 | <br /><select name="move_to_forum"> |
---|
| 352 | <?php |
---|
| 353 | |
---|
| 354 | $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('Impossible de retrouver la liste des catégories et des forums', __FILE__, __LINE__, $db->error()); |
---|
| 355 | |
---|
| 356 | $cur_category = 0; |
---|
| 357 | while ($cur_forum = $db->fetch_assoc($result)) |
---|
| 358 | { |
---|
| 359 | if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
---|
| 360 | { |
---|
| 361 | if ($cur_category) |
---|
| 362 | echo "\t\t\t\t\t\t\t".'</optgroup>'."\n"; |
---|
| 363 | |
---|
| 364 | echo "\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($cur_forum['cat_name']).'">'."\n"; |
---|
| 365 | $cur_category = $cur_forum['cid']; |
---|
| 366 | } |
---|
| 367 | |
---|
| 368 | if ($cur_forum['fid'] != $fid) |
---|
| 369 | echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n"; |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | ?> |
---|
| 373 | </optgroup> |
---|
| 374 | </select> |
---|
| 375 | <br /></label> |
---|
| 376 | <div class="rbox"> |
---|
| 377 | <label><input type="checkbox" name="with_redirect" value="1"<?php if ($action == 'single') echo ' checked="checked"' ?> /><?php echo $lang_misc['Leave redirect'] ?><br /></label> |
---|
| 378 | </div> |
---|
| 379 | </div> |
---|
| 380 | </fieldset> |
---|
| 381 | </div> |
---|
| 382 | <p><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> |
---|
| 383 | </form> |
---|
| 384 | </div> |
---|
| 385 | </div> |
---|
| 386 | <?php |
---|
| 387 | |
---|
| 388 | require PUN_ROOT.'footer.php'; |
---|
| 389 | } |
---|
| 390 | |
---|
| 391 | |
---|
| 392 | // Delete one or more topics |
---|
| 393 | if (isset($_REQUEST['delete_topics']) || isset($_POST['delete_topics_comply'])) |
---|
| 394 | { |
---|
| 395 | $topics = isset($_POST['topics']) ? $_POST['topics'] : array(); |
---|
| 396 | if (empty($topics)) |
---|
| 397 | message($lang_misc['No topics selected']); |
---|
| 398 | |
---|
| 399 | if (isset($_POST['delete_topics_comply'])) |
---|
| 400 | { |
---|
| 401 | confirm_referrer('moderate.php'); |
---|
| 402 | |
---|
| 403 | if (preg_match('/[^0-9,]/', $topics)) |
---|
| 404 | message($lang_common['Bad request']); |
---|
| 405 | |
---|
| 406 | require PUN_ROOT.'include/search_idx.php'; |
---|
| 407 | |
---|
| 408 | // Delete the topics and any redirect topics |
---|
| 409 | $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.$topics.') OR moved_to IN('.$topics.')') or error('Impossible de supprimer la discussion', __FILE__, __LINE__, $db->error()); |
---|
| 410 | |
---|
| 411 | // Delete any subscriptions |
---|
| 412 | $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE topic_id IN('.$topics.')') or error('Impossible de supprimer l\'abonnement', __FILE__, __LINE__, $db->error()); |
---|
| 413 | |
---|
| 414 | // Create a list of the post ID's in this topic and then strip the search index |
---|
| 415 | $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Impossible de retrouver les messages', __FILE__, __LINE__, $db->error()); |
---|
| 416 | |
---|
| 417 | $post_ids = ''; |
---|
| 418 | while ($row = $db->fetch_row($result)) |
---|
| 419 | $post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0]; |
---|
| 420 | |
---|
| 421 | // We have to check that we actually have a list of post ID's since we could be deleting just a redirect topic |
---|
| 422 | if ($post_ids != '') |
---|
| 423 | strip_search_index($post_ids); |
---|
| 424 | |
---|
| 425 | // Delete posts |
---|
| 426 | $db->query('DELETE FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Impossible de supprimer les messages', __FILE__, __LINE__, $db->error()); |
---|
| 427 | |
---|
| 428 | update_forum($fid); |
---|
| 429 | |
---|
| 430 | redirect('viewforum.php?id='.$fid, $lang_misc['Delete topics redirect']); |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | |
---|
| 434 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate']; |
---|
| 435 | require PUN_ROOT.'header.php'; |
---|
| 436 | |
---|
| 437 | ?> |
---|
| 438 | <div class="blockform"> |
---|
| 439 | <h2><?php echo $lang_misc['Delete topics'] ?></h2> |
---|
| 440 | <div class="box"> |
---|
| 441 | <form method="post" action="moderate.php?fid=<?php echo $fid ?>"> |
---|
| 442 | <input type="hidden" name="topics" value="<?php echo implode(',', array_keys($topics)) ?>" /> |
---|
| 443 | <div class="inform"> |
---|
| 444 | <fieldset> |
---|
| 445 | <legend><?php echo $lang_misc['Confirm delete legend'] ?></legend> |
---|
| 446 | <div class="infldset"> |
---|
| 447 | <p><?php echo $lang_misc['Delete topics comply'] ?></p> |
---|
| 448 | </div> |
---|
| 449 | </fieldset> |
---|
| 450 | </div> |
---|
| 451 | <p><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> |
---|
| 452 | </form> |
---|
| 453 | </div> |
---|
| 454 | </div> |
---|
| 455 | <?php |
---|
| 456 | |
---|
| 457 | require PUN_ROOT.'footer.php'; |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | |
---|
| 461 | // Open or close one or more topics |
---|
| 462 | else if (isset($_REQUEST['open']) || isset($_REQUEST['close'])) |
---|
| 463 | { |
---|
| 464 | $action = (isset($_REQUEST['open'])) ? 0 : 1; |
---|
| 465 | |
---|
| 466 | // There could be an array of topic ID's in $_POST |
---|
| 467 | if (isset($_POST['open']) || isset($_POST['close'])) |
---|
| 468 | { |
---|
| 469 | confirm_referrer('moderate.php'); |
---|
| 470 | |
---|
| 471 | $topics = isset($_POST['topics']) ? @array_map('intval', @array_keys($_POST['topics'])) : array(); |
---|
| 472 | if (empty($topics)) |
---|
| 473 | message($lang_misc['No topics selected']); |
---|
| 474 | |
---|
| 475 | $db->query('UPDATE '.$db->prefix.'topics SET closed='.$action.' WHERE id IN('.implode(',', $topics).')') or error('Impossible de fermer les discussions', __FILE__, __LINE__, $db->error()); |
---|
| 476 | |
---|
| 477 | $redirect_msg = ($action) ? $lang_misc['Close topics redirect'] : $lang_misc['Open topics redirect']; |
---|
| 478 | redirect('moderate.php?fid='.$fid, $redirect_msg); |
---|
| 479 | } |
---|
| 480 | // Or just one in $_GET |
---|
| 481 | else |
---|
| 482 | { |
---|
| 483 | confirm_referrer('viewtopic.php'); |
---|
| 484 | |
---|
| 485 | $topic_id = ($action) ? intval($_GET['close']) : intval($_GET['open']); |
---|
| 486 | if ($topic_id < 1) |
---|
| 487 | message($lang_common['Bad request']); |
---|
| 488 | |
---|
| 489 | $db->query('UPDATE '.$db->prefix.'topics SET closed='.$action.' WHERE id='.$topic_id) or error('Impossible de fermer la discussion', __FILE__, __LINE__, $db->error()); |
---|
| 490 | |
---|
| 491 | $redirect_msg = ($action) ? $lang_misc['Close topic redirect'] : $lang_misc['Open topic redirect']; |
---|
| 492 | redirect('viewtopic.php?id='.$topic_id, $redirect_msg); |
---|
| 493 | } |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | |
---|
| 497 | // Stick a topic |
---|
| 498 | else if (isset($_GET['stick'])) |
---|
| 499 | { |
---|
| 500 | confirm_referrer('viewtopic.php'); |
---|
| 501 | |
---|
| 502 | $stick = intval($_GET['stick']); |
---|
| 503 | if ($stick < 1) |
---|
| 504 | message($lang_common['Bad request']); |
---|
| 505 | |
---|
| 506 | $db->query('UPDATE '.$db->prefix.'topics SET sticky=\'1\' WHERE id='.$stick) or error('Impossible d\'épingler la discussion', __FILE__, __LINE__, $db->error()); |
---|
| 507 | |
---|
| 508 | redirect('viewtopic.php?id='.$stick, $lang_misc['Stick topic redirect']); |
---|
| 509 | } |
---|
| 510 | |
---|
| 511 | |
---|
| 512 | // Unstick a topic |
---|
| 513 | else if (isset($_GET['unstick'])) |
---|
| 514 | { |
---|
| 515 | confirm_referrer('viewtopic.php'); |
---|
| 516 | |
---|
| 517 | $unstick = intval($_GET['unstick']); |
---|
| 518 | if ($unstick < 1) |
---|
| 519 | message($lang_common['Bad request']); |
---|
| 520 | |
---|
| 521 | $db->query('UPDATE '.$db->prefix.'topics SET sticky=\'0\' WHERE id='.$unstick) or error('Impossible de détacher la discussion', __FILE__, __LINE__, $db->error()); |
---|
| 522 | |
---|
| 523 | redirect('viewtopic.php?id='.$unstick, $lang_misc['Unstick topic redirect']); |
---|
| 524 | } |
---|
| 525 | |
---|
| 526 | |
---|
| 527 | // No specific forum moderation action was specified in the query string, so we'll display the moderator forum |
---|
| 528 | |
---|
| 529 | // Load the viewforum.php language file |
---|
| 530 | require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php'; |
---|
| 531 | |
---|
| 532 | // Fetch some info about the forum |
---|
| 533 | $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('Impossible de retrouver les informations de forums', __FILE__, __LINE__, $db->error()); |
---|
| 534 | if (!$db->num_rows($result)) |
---|
| 535 | message($lang_common['Bad request']); |
---|
| 536 | |
---|
| 537 | $cur_forum = $db->fetch_assoc($result); |
---|
| 538 | |
---|
| 539 | // Is this a redirect forum? In that case, abort! |
---|
| 540 | if ($cur_forum['redirect_url'] != '') |
---|
| 541 | message($lang_common['Bad request']); |
---|
| 542 | |
---|
| 543 | $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.pun_htmlspecialchars($cur_forum['forum_name']); |
---|
| 544 | require PUN_ROOT.'header.php'; |
---|
| 545 | |
---|
| 546 | // Determine the topic offset (based on $_GET['p']) |
---|
| 547 | $num_pages = ceil($cur_forum['num_topics'] / $pun_user['disp_topics']); |
---|
| 548 | |
---|
| 549 | $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p']; |
---|
| 550 | $start_from = $pun_user['disp_topics'] * ($p - 1); |
---|
| 551 | |
---|
| 552 | // Generate paging links |
---|
| 553 | $paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'moderate.php?fid='.$fid) |
---|
| 554 | |
---|
| 555 | ?> |
---|
| 556 | <div class="linkst"> |
---|
| 557 | <div class="inbox"> |
---|
| 558 | <p class="pagelink conl"><?php echo $paging_links ?></p> |
---|
| 559 | <ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a> </li><li>» <?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></li></ul> |
---|
| 560 | <div class="clearer"></div> |
---|
| 561 | </div> |
---|
| 562 | </div> |
---|
| 563 | |
---|
| 564 | <form method="post" action="moderate.php?fid=<?php echo $fid ?>"> |
---|
| 565 | <div id="vf" class="blocktable"> |
---|
| 566 | <h2><span><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></span></h2> |
---|
| 567 | <div class="box"> |
---|
| 568 | <div class="inbox"> |
---|
| 569 | <table cellspacing="0"> |
---|
| 570 | <thead> |
---|
| 571 | <tr> |
---|
| 572 | <th class="tcl" scope="col"><?php echo $lang_common['Topic'] ?></th> |
---|
| 573 | <th class="tc2" scope="col"><?php echo $lang_common['Replies'] ?></th> |
---|
| 574 | <th class="tc3" scope="col"><?php echo $lang_forum['Views'] ?></th> |
---|
| 575 | <th class="tcr"><?php echo $lang_common['Last post'] ?></th> |
---|
| 576 | <th class="tcmod" scope="col"><?php echo $lang_misc['Select'] ?></th> |
---|
| 577 | </tr> |
---|
| 578 | </thead> |
---|
| 579 | <tbody> |
---|
| 580 | <?php |
---|
| 581 | |
---|
| 582 | // Select topics |
---|
| 583 | $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('Impossible de retrouver la liste des discussions du forum', __FILE__, __LINE__, $db->error()); |
---|
| 584 | |
---|
| 585 | // If there are topics in this forum. |
---|
| 586 | if ($db->num_rows($result)) |
---|
| 587 | { |
---|
| 588 | $button_status = ''; |
---|
| 589 | |
---|
| 590 | while ($cur_topic = $db->fetch_assoc($result)) |
---|
| 591 | { |
---|
| 592 | |
---|
| 593 | $icon_text = $lang_common['Normal icon']; |
---|
| 594 | $item_status = ''; |
---|
| 595 | $icon_type = 'icon'; |
---|
| 596 | |
---|
| 597 | if ($cur_topic['moved_to'] == null) |
---|
| 598 | { |
---|
| 599 | $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> '.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['last_poster']); |
---|
| 600 | $ghost_topic = false; |
---|
| 601 | } |
---|
| 602 | else |
---|
| 603 | { |
---|
| 604 | $last_post = ' '; |
---|
| 605 | $ghost_topic = true; |
---|
| 606 | } |
---|
| 607 | |
---|
| 608 | if ($pun_config['o_censoring'] == '1') |
---|
| 609 | $cur_topic['subject'] = censor_words($cur_topic['subject']); |
---|
| 610 | |
---|
| 611 | if ($cur_topic['moved_to'] != 0) |
---|
| 612 | $subject = $lang_forum['Moved'].': <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>'; |
---|
| 613 | else if ($cur_topic['closed'] == '0') |
---|
| 614 | $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span>'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>'; |
---|
| 615 | else |
---|
| 616 | { |
---|
| 617 | $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>'; |
---|
| 618 | $icon_text = $lang_common['Closed icon']; |
---|
| 619 | $item_status = 'iclosed'; |
---|
| 620 | } |
---|
| 621 | |
---|
| 622 | if ($cur_topic['last_post'] > $pun_user['last_visit'] && !$ghost_topic) |
---|
| 623 | { |
---|
| 624 | $icon_text .= ' '.$lang_common['New icon']; |
---|
| 625 | $item_status .= ' inew'; |
---|
| 626 | $icon_type = 'icon inew'; |
---|
| 627 | $subject = '<strong>'.$subject.'</strong>'; |
---|
| 628 | $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>'; |
---|
| 629 | } |
---|
| 630 | else |
---|
| 631 | $subject_new_posts = null; |
---|
| 632 | |
---|
| 633 | // We won't display "the dot", but we add the spaces anyway |
---|
| 634 | if ($pun_config['o_show_dot'] == '1') |
---|
| 635 | $subject = '  '.$subject; |
---|
| 636 | |
---|
| 637 | if ($cur_topic['sticky'] == '1') |
---|
| 638 | { |
---|
| 639 | $subject = '<span class="stickytext">'.$lang_forum['Sticky'].': </span>'.$subject; |
---|
| 640 | $item_status .= ' isticky'; |
---|
| 641 | $icon_text .= ' '.$lang_forum['Sticky']; |
---|
| 642 | } |
---|
| 643 | |
---|
| 644 | $num_pages_topic = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']); |
---|
| 645 | |
---|
| 646 | if ($num_pages_topic > 1) |
---|
| 647 | $subject_multipage = '[ '.paginate($num_pages_topic, -1, 'viewtopic.php?id='.$cur_topic['id']).' ]'; |
---|
| 648 | else |
---|
| 649 | $subject_multipage = null; |
---|
| 650 | |
---|
| 651 | // Should we show the "New posts" and/or the multipage links? |
---|
| 652 | if (!empty($subject_new_posts) || !empty($subject_multipage)) |
---|
| 653 | { |
---|
| 654 | $subject .= '  '.(!empty($subject_new_posts) ? $subject_new_posts : ''); |
---|
| 655 | $subject .= !empty($subject_multipage) ? ' '.$subject_multipage : ''; |
---|
| 656 | } |
---|
| 657 | |
---|
| 658 | ?> |
---|
| 659 | <tr<?php if ($item_status != '') echo ' class="'.trim($item_status).'"'; ?>> |
---|
| 660 | <td class="tcl"> |
---|
| 661 | <div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo trim($icon_text) ?></div></div> |
---|
| 662 | <div class="tclcon"> |
---|
| 663 | <?php echo $subject."\n" ?> |
---|
| 664 | </div> |
---|
| 665 | </td> |
---|
| 666 | <td class="tc2"><?php echo (!$ghost_topic) ? $cur_topic['num_replies'] : ' ' ?></td> |
---|
| 667 | <td class="tc3"><?php echo (!$ghost_topic) ? $cur_topic['num_views'] : ' ' ?></td> |
---|
| 668 | <td class="tcr"><?php echo $last_post ?></td> |
---|
| 669 | <td class="tcmod"><input type="checkbox" name="topics[<?php echo $cur_topic['id'] ?>]" value="1" /></td> |
---|
| 670 | </tr> |
---|
| 671 | <?php |
---|
| 672 | |
---|
| 673 | } |
---|
| 674 | } |
---|
| 675 | else |
---|
| 676 | { |
---|
| 677 | $button_status = ' disabled'; |
---|
| 678 | echo "\t\t\t\t\t".'<tr><td class="tcl" colspan="5">'.$lang_forum['Empty forum'].'</td></tr>'."\n"; |
---|
| 679 | } |
---|
| 680 | |
---|
| 681 | ?> |
---|
| 682 | </tbody> |
---|
| 683 | </table> |
---|
| 684 | </div> |
---|
| 685 | </div> |
---|
| 686 | </div> |
---|
| 687 | |
---|
| 688 | <div class="linksb"> |
---|
| 689 | <div class="inbox"> |
---|
| 690 | <p class="pagelink conl"><?php echo $paging_links ?></p> |
---|
| 691 | <p class="conr"><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="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> |
---|
| 692 | <div class="clearer"></div> |
---|
| 693 | </div> |
---|
| 694 | </div> |
---|
| 695 | </form> |
---|
| 696 | <?php |
---|
| 697 | |
---|
| 698 | require PUN_ROOT.'footer.php'; |
---|