[ Index ] |
|
Code source de PunBB 1.2.16 |
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('Unable to fetch post IP address', __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('Unable to fetch forum info', __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('Unable to fetch topic info', __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 // 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()); 106 107 if ($db->num_rows($result) != substr_count($posts, ',') + 1) 108 message($lang_common['Bad request']); 109 110 // 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()); 112 113 require PUN_ROOT.'include/search_idx.php'; 114 strip_search_index($posts); 115 116 // 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()); 118 $last_post = $db->fetch_assoc($result); 119 120 // How many posts did we just delete? 121 $num_posts_deleted = substr_count($posts, ',') + 1; 122 123 // 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()); 125 126 update_forum($fid); 127 128 redirect('viewtopic.php?id='.$tid, $lang_misc['Delete posts redirect']); 129 } 130 131 132 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate']; 133 require PUN_ROOT.'header.php'; 134 135 ?> 136 <div class="blockform"> 137 <h2><span><?php echo $lang_misc['Delete posts'] ?></span></h2> 138 <div class="box"> 139 <form method="post" action="moderate.php?fid=<?php echo $fid ?>&tid=<?php echo $tid ?>"> 140 <div class="inform"> 141 <fieldset> 142 <legend><?php echo $lang_misc['Confirm delete legend'] ?></legend> 143 <div class="infldset"> 144 <input type="hidden" name="posts" value="<?php echo implode(',', array_keys($posts)) ?>" /> 145 <p><?php echo $lang_misc['Delete posts comply'] ?></p> 146 </div> 147 </fieldset> 148 </div> 149 <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> 150 </form> 151 </div> 152 </div> 153 <?php 154 155 require PUN_ROOT.'footer.php'; 156 } 157 158 159 // Show the delete multiple posts view 160 161 // Load the viewtopic.php language file 162 require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php'; 163 164 // Used to disable the Move and Delete buttons if there are no replies to this topic 165 $button_status = ($cur_topic['num_replies'] == 0) ? ' disabled' : ''; 166 167 168 // Determine the post offset (based on $_GET['p']) 169 $num_pages = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']); 170 171 $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p']; 172 $start_from = $pun_user['disp_posts'] * ($p - 1); 173 174 // Generate paging links 175 $paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'moderate.php?fid='.$fid.'&tid='.$tid); 176 177 178 if ($pun_config['o_censoring'] == '1') 179 $cur_topic['subject'] = censor_words($cur_topic['subject']); 180 181 182 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$cur_topic['subject']; 183 require PUN_ROOT.'header.php'; 184 185 ?> 186 <div class="linkst"> 187 <div class="inbox"> 188 <p class="pagelink conl"><?php echo $paging_links ?></p> 189 <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> 190 <div class="clearer"></div> 191 </div> 192 </div> 193 194 <form method="post" action="moderate.php?fid=<?php echo $fid ?>&tid=<?php echo $tid ?>"> 195 <?php 196 197 require PUN_ROOT.'include/parser.php'; 198 199 $bg_switch = true; // Used for switching background color in posts 200 $post_count = 0; // Keep track of post numbers 201 202 // 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()); 204 205 while ($cur_post = $db->fetch_assoc($result)) 206 { 207 $post_count++; 208 209 // If the poster is a registered user. 210 if ($cur_post['poster_id'] > 1) 211 { 212 $poster = '<a href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'; 213 214 // get_title() requires that an element 'username' be present in the array 215 $cur_post['username'] = $cur_post['poster']; 216 $user_title = get_title($cur_post); 217 218 if ($pun_config['o_censoring'] == '1') 219 $user_title = censor_words($user_title); 220 } 221 // If the poster is a guest (or a user that has been deleted) 222 else 223 { 224 $poster = pun_htmlspecialchars($cur_post['poster']); 225 $user_title = $lang_topic['Guest']; 226 } 227 228 // Switch the background color for every message. 229 $bg_switch = ($bg_switch) ? $bg_switch = false : $bg_switch = true; 230 $vtbg = ($bg_switch) ? ' roweven' : ' rowodd'; 231 232 // Perform the main parsing of the message (BBCode, smilies, censor words etc) 233 $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']); 234 235 ?> 236 237 <div class="blockpost<?php echo $vtbg ?>"> 238 <a name="<?php echo $cur_post['id'] ?>"></a> 239 <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> 240 <div class="box"> 241 <div class="inbox"> 242 <div class="postleft"> 243 <dl> 244 <dt><strong><?php echo $poster ?></strong></dt> 245 <dd><strong><?php echo $user_title ?></strong></dd> 246 </dl> 247 </div> 248 <div class="postright"> 249 <h3 class="nosize"><?php echo $lang_common['Message'] ?></h3> 250 <div class="postmsg"> 251 <?php echo $cur_post['message']."\n" ?> 252 <?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"; ?> 253 </div> 254 <?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" ?> 255 </div> 256 <div class="clearer"></div> 257 </div> 258 </div> 259 </div> 260 261 262 263 264 <?php 265 266 } 267 268 ?> 269 <div class="postlinksb"> 270 <div class="inbox"> 271 <p class="pagelink conl"><?php echo $paging_links ?></p> 272 <p class="conr"><input type="submit" name="delete_posts" value="<?php echo $lang_misc['Delete'] ?>"<?php echo $button_status ?> /></p> 273 <div class="clearer"></div> 274 </div> 275 </div> 276 </form> 277 <?php 278 279 require PUN_ROOT.'footer.php'; 280 } 281 282 283 // Move one or more topics 284 if (isset($_REQUEST['move_topics']) || isset($_POST['move_topics_to'])) 285 { 286 if (isset($_POST['move_topics_to'])) 287 { 288 confirm_referrer('moderate.php'); 289 290 if (@preg_match('/[^0-9,]/', $_POST['topics'])) 291 message($lang_common['Bad request']); 292 293 $topics = explode(',', $_POST['topics']); 294 $move_to_forum = isset($_POST['move_to_forum']) ? intval($_POST['move_to_forum']) : 0; 295 if (empty($topics) || $move_to_forum < 1) 296 message($lang_common['Bad request']); 297 298 // 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()); 300 301 if ($db->num_rows($result) != count($topics)) 302 message($lang_common['Bad request']); 303 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) 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()); 306 307 // 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()); 309 310 // Should we create redirect topics? 311 if (isset($_POST['with_redirect'])) 312 { 313 while (list(, $cur_topic) = @each($topics)) 314 { 315 // 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()); 317 $moved_to = $db->fetch_assoc($result); 318 319 // 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()); 321 } 322 } 323 324 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 326 327 $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); 329 } 330 331 if (isset($_POST['move_topics'])) 332 { 333 $topics = isset($_POST['topics']) ? $_POST['topics'] : array(); 334 if (empty($topics)) 335 message($lang_misc['No topics selected']); 336 337 $topics = implode(',', array_keys($topics)); 338 $action = 'multi'; 339 } 340 else 341 { 342 $topics = intval($_GET['move_topics']); 343 if ($topics < 1) 344 message($lang_common['Bad request']); 345 346 $action = 'single'; 347 } 348 349 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate']; 350 require PUN_ROOT.'header.php'; 351 352 ?> 353 <div class="blockform"> 354 <h2><span><?php echo ($action == 'single') ? $lang_misc['Move topic'] : $lang_misc['Move topics'] ?></span></h2> 355 <div class="box"> 356 <form method="post" action="moderate.php?fid=<?php echo $fid ?>"> 357 <div class="inform"> 358 <input type="hidden" name="topics" value="<?php echo $topics ?>" /> 359 <fieldset> 360 <legend><?php echo $lang_misc['Move legend'] ?></legend> 361 <div class="infldset"> 362 <label><?php echo $lang_misc['Move to'] ?> 363 <br /><select name="move_to_forum"> 364 <?php 365 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()); 367 368 $cur_category = 0; 369 while ($cur_forum = $db->fetch_assoc($result)) 370 { 371 if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? 372 { 373 if ($cur_category) 374 echo "\t\t\t\t\t\t\t".'</optgroup>'."\n"; 375 376 echo "\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($cur_forum['cat_name']).'">'."\n"; 377 $cur_category = $cur_forum['cid']; 378 } 379 380 if ($cur_forum['fid'] != $fid) 381 echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n"; 382 } 383 384 ?> 385 </optgroup> 386 </select> 387 <br /></label> 388 <div class="rbox"> 389 <label><input type="checkbox" name="with_redirect" value="1"<?php if ($action == 'single') echo ' checked="checked"' ?> /><?php echo $lang_misc['Leave redirect'] ?><br /></label> 390 </div> 391 </div> 392 </fieldset> 393 </div> 394 <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> 395 </form> 396 </div> 397 </div> 398 <?php 399 400 require PUN_ROOT.'footer.php'; 401 } 402 403 404 // Delete one or more topics 405 if (isset($_REQUEST['delete_topics']) || isset($_POST['delete_topics_comply'])) 406 { 407 $topics = isset($_POST['topics']) ? $_POST['topics'] : array(); 408 if (empty($topics)) 409 message($lang_misc['No topics selected']); 410 411 if (isset($_POST['delete_topics_comply'])) 412 { 413 confirm_referrer('moderate.php'); 414 415 if (@preg_match('/[^0-9,]/', $topics)) 416 message($lang_common['Bad request']); 417 418 require PUN_ROOT.'include/search_idx.php'; 419 420 // 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()); 422 423 if ($db->num_rows($result) != substr_count($topics, ',') + 1) 424 message($lang_common['Bad request']); 425 426 // 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()); 428 429 // 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()); 431 432 // 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()); 434 435 $post_ids = ''; 436 while ($row = $db->fetch_row($result)) 437 $post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0]; 438 439 // 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 != '') 441 strip_search_index($post_ids); 442 443 // 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()); 445 446 update_forum($fid); 447 448 redirect('viewforum.php?id='.$fid, $lang_misc['Delete topics redirect']); 449 } 450 451 452 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate']; 453 require PUN_ROOT.'header.php'; 454 455 ?> 456 <div class="blockform"> 457 <h2><?php echo $lang_misc['Delete topics'] ?></h2> 458 <div class="box"> 459 <form method="post" action="moderate.php?fid=<?php echo $fid ?>"> 460 <input type="hidden" name="topics" value="<?php echo implode(',', array_keys($topics)) ?>" /> 461 <div class="inform"> 462 <fieldset> 463 <legend><?php echo $lang_misc['Confirm delete legend'] ?></legend> 464 <div class="infldset"> 465 <p><?php echo $lang_misc['Delete topics comply'] ?></p> 466 </div> 467 </fieldset> 468 </div> 469 <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> 470 </form> 471 </div> 472 </div> 473 <?php 474 475 require PUN_ROOT.'footer.php'; 476 } 477 478 479 // Open or close one or more topics 480 else if (isset($_REQUEST['open']) || isset($_REQUEST['close'])) 481 { 482 $action = (isset($_REQUEST['open'])) ? 0 : 1; 483 484 // There could be an array of topic ID's in $_POST 485 if (isset($_POST['open']) || isset($_POST['close'])) 486 { 487 confirm_referrer('moderate.php'); 488 489 $topics = isset($_POST['topics']) ? @array_map('intval', @array_keys($_POST['topics'])) : array(); 490 if (empty($topics)) 491 message($lang_misc['No topics selected']); 492 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()); 494 495 $redirect_msg = ($action) ? $lang_misc['Close topics redirect'] : $lang_misc['Open topics redirect']; 496 redirect('moderate.php?fid='.$fid, $redirect_msg); 497 } 498 // Or just one in $_GET 499 else 500 { 501 confirm_referrer('viewtopic.php'); 502 503 $topic_id = ($action) ? intval($_GET['close']) : intval($_GET['open']); 504 if ($topic_id < 1) 505 message($lang_common['Bad request']); 506 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()); 508 509 $redirect_msg = ($action) ? $lang_misc['Close topic redirect'] : $lang_misc['Open topic redirect']; 510 redirect('viewtopic.php?id='.$topic_id, $redirect_msg); 511 } 512 } 513 514 515 // Stick a topic 516 else if (isset($_GET['stick'])) 517 { 518 confirm_referrer('viewtopic.php'); 519 520 $stick = intval($_GET['stick']); 521 if ($stick < 1) 522 message($lang_common['Bad request']); 523 524 $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()); 525 526 redirect('viewtopic.php?id='.$stick, $lang_misc['Stick topic redirect']); 527 } 528 529 530 // Unstick a topic 531 else if (isset($_GET['unstick'])) 532 { 533 confirm_referrer('viewtopic.php'); 534 535 $unstick = intval($_GET['unstick']); 536 if ($unstick < 1) 537 message($lang_common['Bad request']); 538 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()); 540 541 redirect('viewtopic.php?id='.$unstick, $lang_misc['Unstick topic redirect']); 542 } 543 544 545 // No specific forum moderation action was specified in the query string, so we'll display the moderator forum 546 547 // Load the viewforum.php language file 548 require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php'; 549 550 // 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()); 552 if (!$db->num_rows($result)) 553 message($lang_common['Bad request']); 554 555 $cur_forum = $db->fetch_assoc($result); 556 557 // Is this a redirect forum? In that case, abort! 558 if ($cur_forum['redirect_url'] != '') 559 message($lang_common['Bad request']); 560 561 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.pun_htmlspecialchars($cur_forum['forum_name']); 562 require PUN_ROOT.'header.php'; 563 564 // Determine the topic offset (based on $_GET['p']) 565 $num_pages = ceil($cur_forum['num_topics'] / $pun_user['disp_topics']); 566 567 $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p']; 568 $start_from = $pun_user['disp_topics'] * ($p - 1); 569 570 // Generate paging links 571 $paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'moderate.php?fid='.$fid) 572 573 ?> 574 <div class="linkst"> 575 <div class="inbox"> 576 <p class="pagelink conl"><?php echo $paging_links ?></p> 577 <ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a> </li><li>» <?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></li></ul> 578 <div class="clearer"></div> 579 </div> 580 </div> 581 582 <form method="post" action="moderate.php?fid=<?php echo $fid ?>"> 583 <div id="vf" class="blocktable"> 584 <h2><span><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></span></h2> 585 <div class="box"> 586 <div class="inbox"> 587 <table cellspacing="0"> 588 <thead> 589 <tr> 590 <th class="tcl" scope="col"><?php echo $lang_common['Topic'] ?></th> 591 <th class="tc2" scope="col"><?php echo $lang_common['Replies'] ?></th> 592 <th class="tc3" scope="col"><?php echo $lang_forum['Views'] ?></th> 593 <th class="tcr"><?php echo $lang_common['Last post'] ?></th> 594 <th class="tcmod" scope="col"><?php echo $lang_misc['Select'] ?></th> 595 </tr> 596 </thead> 597 <tbody> 598 <?php 599 600 // 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()); 602 603 // If there are topics in this forum. 604 if ($db->num_rows($result)) 605 { 606 $button_status = ''; 607 608 while ($cur_topic = $db->fetch_assoc($result)) 609 { 610 611 $icon_text = $lang_common['Normal icon']; 612 $item_status = ''; 613 $icon_type = 'icon'; 614 615 if ($cur_topic['moved_to'] == null) 616 { 617 $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']); 618 $ghost_topic = false; 619 } 620 else 621 { 622 $last_post = ' '; 623 $ghost_topic = true; 624 } 625 626 if ($pun_config['o_censoring'] == '1') 627 $cur_topic['subject'] = censor_words($cur_topic['subject']); 628 629 if ($cur_topic['moved_to'] != 0) 630 $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>'; 631 else if ($cur_topic['closed'] == '0') 632 $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>'; 633 else 634 { 635 $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>'; 636 $icon_text = $lang_common['Closed icon']; 637 $item_status = 'iclosed'; 638 } 639 640 if ($cur_topic['last_post'] > $pun_user['last_visit'] && !$ghost_topic) 641 { 642 $icon_text .= ' '.$lang_common['New icon']; 643 $item_status .= ' inew'; 644 $icon_type = 'icon inew'; 645 $subject = '<strong>'.$subject.'</strong>'; 646 $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>'; 647 } 648 else 649 $subject_new_posts = null; 650 651 // We won't display "the dot", but we add the spaces anyway 652 if ($pun_config['o_show_dot'] == '1') 653 $subject = ' '.$subject; 654 655 if ($cur_topic['sticky'] == '1') 656 { 657 $subject = '<span class="stickytext">'.$lang_forum['Sticky'].': </span>'.$subject; 658 $item_status .= ' isticky'; 659 $icon_text .= ' '.$lang_forum['Sticky']; 660 } 661 662 $num_pages_topic = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']); 663 664 if ($num_pages_topic > 1) 665 $subject_multipage = '[ '.paginate($num_pages_topic, -1, 'viewtopic.php?id='.$cur_topic['id']).' ]'; 666 else 667 $subject_multipage = null; 668 669 // Should we show the "New posts" and/or the multipage links? 670 if (!empty($subject_new_posts) || !empty($subject_multipage)) 671 { 672 $subject .= ' '.(!empty($subject_new_posts) ? $subject_new_posts : ''); 673 $subject .= !empty($subject_multipage) ? ' '.$subject_multipage : ''; 674 } 675 676 ?> 677 <tr<?php if ($item_status != '') echo ' class="'.trim($item_status).'"'; ?>> 678 <td class="tcl"> 679 <div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo trim($icon_text) ?></div></div> 680 <div class="tclcon"> 681 <?php echo $subject."\n" ?> 682 </div> 683 </td> 684 <td class="tc2"><?php echo (!$ghost_topic) ? $cur_topic['num_replies'] : ' ' ?></td> 685 <td class="tc3"><?php echo (!$ghost_topic) ? $cur_topic['num_views'] : ' ' ?></td> 686 <td class="tcr"><?php echo $last_post ?></td> 687 <td class="tcmod"><input type="checkbox" name="topics[<?php echo $cur_topic['id'] ?>]" value="1" /></td> 688 </tr> 689 <?php 690 691 } 692 } 693 else 694 { 695 $button_status = ' disabled'; 696 echo "\t\t\t\t\t".'<tr><td class="tcl" colspan="5">'.$lang_forum['Empty forum'].'</td></tr>'."\n"; 697 } 698 699 ?> 700 </tbody> 701 </table> 702 </div> 703 </div> 704 </div> 705 706 <div class="linksb"> 707 <div class="inbox"> 708 <p class="pagelink conl"><?php echo $paging_links ?></p> 709 <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> 710 <div class="clearer"></div> 711 </div> 712 </div> 713 </form> 714 <?php 715 716 require PUN_ROOT.'footer.php';
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 22:44:38 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |