root / tags / release_2_0_2 / phpBB / modcp.php
History | View | Annotate | Download (33.8 kB)
| 1 | <?php
|
|---|---|
| 2 | /***************************************************************************
|
| 3 | * modcp.php |
| 4 | * ------------------- |
| 5 | * begin : July 4, 2001 |
| 6 | * copyright : (C) 2001 The phpBB Group |
| 7 | * email : support@phpbb.com |
| 8 | * |
| 9 | * $Id: modcp.php 2845 2002-08-08 18:06:53Z $ |
| 10 | * |
| 11 | * |
| 12 | ***************************************************************************/ |
| 13 | |
| 14 | /***************************************************************************
|
| 15 | * |
| 16 | * This program is free software; you can redistribute it and/or modify |
| 17 | * it under the terms of the GNU General Public License as published by |
| 18 | * the Free Software Foundation; either version 2 of the License, or |
| 19 | * (at your option) any later version. |
| 20 | * |
| 21 | ***************************************************************************/ |
| 22 | |
| 23 | /**
|
| 24 | * Moderator Control Panel |
| 25 | * |
| 26 | * From this 'Control Panel' the moderator of a forum will be able to do |
| 27 | * mass topic operations (locking/unlocking/moving/deleteing), and it will |
| 28 | * provide an interface to do quick locking/unlocking/moving/deleting of |
| 29 | * topics via the moderator operations buttons on all of the viewtopic pages. |
| 30 | */ |
| 31 | |
| 32 | define('IN_PHPBB', true); |
| 33 | $phpbb_root_path = './'; |
| 34 | include($phpbb_root_path . 'extension.inc'); |
| 35 | include($phpbb_root_path . 'common.'.$phpEx); |
| 36 | include($phpbb_root_path . 'includes/bbcode.'.$phpEx); |
| 37 | include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); |
| 38 | |
| 39 | //
|
| 40 | // Obtain initial var settings
|
| 41 | //
|
| 42 | if ( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) ) |
| 43 | {
|
| 44 | $forum_id = (isset($HTTP_POST_VARS[POST_FORUM_URL])) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]); |
| 45 | } |
| 46 | else
|
| 47 | {
|
| 48 | $forum_id = ''; |
| 49 | } |
| 50 | |
| 51 | if ( isset($HTTP_GET_VARS[POST_POST_URL]) || isset($HTTP_POST_VARS[POST_POST_URL]) ) |
| 52 | {
|
| 53 | $post_id = (isset($HTTP_POST_VARS[POST_POST_URL])) ? intval($HTTP_POST_VARS[POST_POST_URL]) : intval($HTTP_GET_VARS[POST_POST_URL]); |
| 54 | } |
| 55 | else
|
| 56 | {
|
| 57 | $post_id = ''; |
| 58 | } |
| 59 | |
| 60 | if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) || isset($HTTP_POST_VARS[POST_TOPIC_URL]) ) |
| 61 | {
|
| 62 | $topic_id = (isset($HTTP_POST_VARS[POST_TOPIC_URL])) ? intval($HTTP_POST_VARS[POST_TOPIC_URL]) : intval($HTTP_GET_VARS[POST_TOPIC_URL]); |
| 63 | } |
| 64 | else
|
| 65 | {
|
| 66 | $topic_id = ''; |
| 67 | } |
| 68 | |
| 69 | $confirm = ( $HTTP_POST_VARS['confirm'] ) ? TRUE : 0; |
| 70 | |
| 71 | //
|
| 72 | // Continue var definitions
|
| 73 | //
|
| 74 | $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0; |
| 75 | |
| 76 | $delete = ( isset($HTTP_POST_VARS['delete']) ) ? TRUE : FALSE; |
| 77 | $move = ( isset($HTTP_POST_VARS['move']) ) ? TRUE : FALSE; |
| 78 | $lock = ( isset($HTTP_POST_VARS['lock']) ) ? TRUE : FALSE; |
| 79 | $unlock = ( isset($HTTP_POST_VARS['unlock']) ) ? TRUE : FALSE; |
| 80 | |
| 81 | if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) |
| 82 | {
|
| 83 | $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; |
| 84 | } |
| 85 | else
|
| 86 | {
|
| 87 | if ( $delete ) |
| 88 | {
|
| 89 | $mode = 'delete'; |
| 90 | } |
| 91 | else if ( $move ) |
| 92 | {
|
| 93 | $mode = 'move'; |
| 94 | } |
| 95 | else if ( $lock ) |
| 96 | {
|
| 97 | $mode = 'lock'; |
| 98 | } |
| 99 | else if ( $unlock ) |
| 100 | {
|
| 101 | $mode = 'unlock'; |
| 102 | } |
| 103 | else
|
| 104 | {
|
| 105 | $mode = ''; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | //
|
| 110 | // Obtain relevant data
|
| 111 | //
|
| 112 | if ( !empty($topic_id) ) |
| 113 | {
|
| 114 | $sql = "SELECT f.forum_id, f.forum_name, f.forum_topics |
| 115 | FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f |
| 116 | WHERE t.topic_id = " . $topic_id . " |
| 117 | AND f.forum_id = t.forum_id";
|
| 118 | if ( !($result = $db->sql_query($sql)) ) |
| 119 | {
|
| 120 | message_die(GENERAL_MESSAGE, 'Topic_post_not_exist'); |
| 121 | } |
| 122 | $topic_row = $db->sql_fetchrow($result); |
| 123 | |
| 124 | $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics']; |
| 125 | $forum_id = $topic_row['forum_id']; |
| 126 | $forum_name = $topic_row['forum_name']; |
| 127 | } |
| 128 | else if ( !empty($forum_id) ) |
| 129 | {
|
| 130 | $sql = "SELECT forum_name, forum_topics |
| 131 | FROM " . FORUMS_TABLE . " |
| 132 | WHERE forum_id = " . $forum_id; |
| 133 | if ( !($result = $db->sql_query($sql)) ) |
| 134 | {
|
| 135 | message_die(GENERAL_MESSAGE, 'Forum_not_exist'); |
| 136 | } |
| 137 | $topic_row = $db->sql_fetchrow($result); |
| 138 | |
| 139 | $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics']; |
| 140 | $forum_name = $topic_row['forum_name']; |
| 141 | } |
| 142 | else
|
| 143 | {
|
| 144 | message_die(GENERAL_MESSAGE, 'Forum_not_exist'); |
| 145 | } |
| 146 | |
| 147 | //
|
| 148 | // Start session management
|
| 149 | //
|
| 150 | $userdata = session_pagestart($user_ip, $forum_id); |
| 151 | init_userprefs($userdata);
|
| 152 | //
|
| 153 | // End session management
|
| 154 | //
|
| 155 | |
| 156 | //
|
| 157 | // Check if user did or did not confirm
|
| 158 | // If they did not, forward them to the last page they were on
|
| 159 | //
|
| 160 | if ( isset($HTTP_POST_VARS['cancel']) ) |
| 161 | {
|
| 162 | if ( $topic_id ) |
| 163 | {
|
| 164 | $redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id"; |
| 165 | } |
| 166 | else if ( $forum_id ) |
| 167 | {
|
| 168 | $redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"; |
| 169 | } |
| 170 | else
|
| 171 | {
|
| 172 | $redirect = "index.$phpEx"; |
| 173 | } |
| 174 | |
| 175 | $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: '; |
| 176 | header($header_location . append_sid($redirect, true)); |
| 177 | exit;
|
| 178 | } |
| 179 | |
| 180 | //
|
| 181 | // Start auth check
|
| 182 | //
|
| 183 | $is_auth = auth(AUTH_ALL, $forum_id, $userdata); |
| 184 | |
| 185 | if ( !$is_auth['auth_mod'] ) |
| 186 | {
|
| 187 | message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised']); |
| 188 | } |
| 189 | //
|
| 190 | // End Auth Check
|
| 191 | //
|
| 192 | |
| 193 | //
|
| 194 | // Do major work ...
|
| 195 | //
|
| 196 | switch( $mode ) |
| 197 | {
|
| 198 | case 'delete': |
| 199 | $page_title = $lang['Mod_CP']; |
| 200 | include($phpbb_root_path . 'includes/page_header.'.$phpEx); |
| 201 | |
| 202 | if ( $confirm ) |
| 203 | {
|
| 204 | include($phpbb_root_path . 'includes/functions_search.'.$phpEx); |
| 205 | |
| 206 | $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id); |
| 207 | |
| 208 | $topic_id_sql = ''; |
| 209 | for($i = 0; $i < count($topics); $i++) |
| 210 | {
|
| 211 | $topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . $topics[$i]; |
| 212 | } |
| 213 | |
| 214 | $sql = "SELECT poster_id, COUNT(post_id) AS posts |
| 215 | FROM " . POSTS_TABLE . " |
| 216 | WHERE topic_id IN ($topic_id_sql) |
| 217 | GROUP BY poster_id";
|
| 218 | if ( !($result = $db->sql_query($sql)) ) |
| 219 | {
|
| 220 | message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql); |
| 221 | } |
| 222 | |
| 223 | $count_sql = array(); |
| 224 | while ( $row = $db->sql_fetchrow($result) ) |
| 225 | {
|
| 226 | $count_sql[] = "UPDATE " . USERS_TABLE . " |
| 227 | SET user_posts = user_posts - " . $row['posts'] . " |
| 228 | WHERE user_id = " . $row['poster_id']; |
| 229 | } |
| 230 | $db->sql_freeresult($result); |
| 231 | |
| 232 | if ( sizeof($count_sql) ) |
| 233 | {
|
| 234 | for($i = 0; $i < sizeof($count_sql); $i++) |
| 235 | {
|
| 236 | if ( !$db->sql_query($count_sql[$i]) ) |
| 237 | {
|
| 238 | message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql); |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | $sql = "SELECT post_id |
| 244 | FROM " . POSTS_TABLE . " |
| 245 | WHERE topic_id IN ($topic_id_sql)"; |
| 246 | if ( !($result = $db->sql_query($sql)) ) |
| 247 | {
|
| 248 | message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql); |
| 249 | } |
| 250 | |
| 251 | $post_id_sql = ''; |
| 252 | while ( $row = $db->sql_fetchrow($result) ) |
| 253 | {
|
| 254 | $post_id_sql .= ( ( $post_id_sql != '' ) ? ', ' : '' ) . $row['post_id']; |
| 255 | } |
| 256 | $db->sql_freeresult($result); |
| 257 | |
| 258 | $sql = "SELECT vote_id |
| 259 | FROM " . VOTE_DESC_TABLE . " |
| 260 | WHERE topic_id IN ($topic_id_sql)"; |
| 261 | if ( !($result = $db->sql_query($sql)) ) |
| 262 | {
|
| 263 | message_die(GENERAL_ERROR, 'Could not get vote id information', '', __LINE__, __FILE__, $sql); |
| 264 | } |
| 265 | |
| 266 | $vote_id_sql = ''; |
| 267 | while ( $row = $db->sql_fetchrow($result) ) |
| 268 | {
|
| 269 | $vote_id_sql .= ( ( $vote_id_sql != '' ) ? ', ' : '' ) . $row['vote_id']; |
| 270 | } |
| 271 | $db->sql_freeresult($result); |
| 272 | |
| 273 | //
|
| 274 | // Got all required info so go ahead and start deleting everything
|
| 275 | //
|
| 276 | $sql = "DELETE |
| 277 | FROM " . TOPICS_TABLE . " |
| 278 | WHERE topic_id IN ($topic_id_sql) |
| 279 | OR topic_moved_id IN ($topic_id_sql)"; |
| 280 | if ( !$db->sql_query($sql, BEGIN_TRANSACTION) ) |
| 281 | {
|
| 282 | message_die(GENERAL_ERROR, 'Could not delete topics', '', __LINE__, __FILE__, $sql); |
| 283 | } |
| 284 | |
| 285 | if ( $post_id_sql != '' ) |
| 286 | {
|
| 287 | $sql = "DELETE |
| 288 | FROM " . POSTS_TABLE . " |
| 289 | WHERE post_id IN ($post_id_sql)"; |
| 290 | if ( !$db->sql_query($sql) ) |
| 291 | {
|
| 292 | message_die(GENERAL_ERROR, 'Could not delete posts', '', __LINE__, __FILE__, $sql); |
| 293 | } |
| 294 | |
| 295 | $sql = "DELETE |
| 296 | FROM " . POSTS_TEXT_TABLE . " |
| 297 | WHERE post_id IN ($post_id_sql)"; |
| 298 | if ( !$db->sql_query($sql) ) |
| 299 | {
|
| 300 | message_die(GENERAL_ERROR, 'Could not delete posts text', '', __LINE__, __FILE__, $sql); |
| 301 | } |
| 302 | |
| 303 | remove_search_post($post_id_sql);
|
| 304 | } |
| 305 | |
| 306 | if ( $vote_id_sql != '' ) |
| 307 | {
|
| 308 | $sql = "DELETE |
| 309 | FROM " . VOTE_DESC_TABLE . " |
| 310 | WHERE vote_id IN ($vote_id_sql)"; |
| 311 | if ( !$db->sql_query($sql) ) |
| 312 | {
|
| 313 | message_die(GENERAL_ERROR, 'Could not delete vote descriptions', '', __LINE__, __FILE__, $sql); |
| 314 | } |
| 315 | |
| 316 | $sql = "DELETE |
| 317 | FROM " . VOTE_RESULTS_TABLE . " |
| 318 | WHERE vote_id IN ($vote_id_sql)"; |
| 319 | if ( !$db->sql_query($sql) ) |
| 320 | {
|
| 321 | message_die(GENERAL_ERROR, 'Could not delete vote results', '', __LINE__, __FILE__, $sql); |
| 322 | } |
| 323 | |
| 324 | $sql = "DELETE |
| 325 | FROM " . VOTE_USERS_TABLE . " |
| 326 | WHERE vote_id IN ($vote_id_sql)"; |
| 327 | if ( !$db->sql_query($sql) ) |
| 328 | {
|
| 329 | message_die(GENERAL_ERROR, 'Could not delete vote users', '', __LINE__, __FILE__, $sql); |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | $sql = "DELETE |
| 334 | FROM " . TOPICS_WATCH_TABLE . " |
| 335 | WHERE topic_id IN ($topic_id_sql)"; |
| 336 | if ( !$db->sql_query($sql, END_TRANSACTION) ) |
| 337 | {
|
| 338 | message_die(GENERAL_ERROR, 'Could not delete watched post list', '', __LINE__, __FILE__, $sql); |
| 339 | } |
| 340 | |
| 341 | sync('forum', $forum_id); |
| 342 | |
| 343 | if ( !empty($topic_id) ) |
| 344 | {
|
| 345 | $redirect_page = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"); |
| 346 | $l_redirect = sprintf($lang['Click_return_forum'], '<a href="' . $redirect_page . '">', '</a>'); |
| 347 | } |
| 348 | else
|
| 349 | {
|
| 350 | $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id"); |
| 351 | $l_redirect = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>'); |
| 352 | } |
| 353 | |
| 354 | $template->assign_vars(array( |
| 355 | 'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">') |
| 356 | ); |
| 357 | |
| 358 | message_die(GENERAL_MESSAGE, $lang['Topics_Removed'] . '<br /><br />' . $l_redirect); |
| 359 | } |
| 360 | else
|
| 361 | {
|
| 362 | // Not confirmed, show confirmation message
|
| 363 | if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) ) |
| 364 | {
|
| 365 | message_die(GENERAL_MESSAGE, $lang['None_selected']); |
| 366 | } |
| 367 | |
| 368 | $hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />'; |
| 369 | |
| 370 | if ( isset($HTTP_POST_VARS['topic_id_list']) ) |
| 371 | {
|
| 372 | $topics = $HTTP_POST_VARS['topic_id_list']; |
| 373 | for($i = 0; $i < count($topics); $i++) |
| 374 | {
|
| 375 | $hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />'; |
| 376 | } |
| 377 | } |
| 378 | else
|
| 379 | {
|
| 380 | $hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />'; |
| 381 | } |
| 382 | |
| 383 | //
|
| 384 | // Set template files
|
| 385 | //
|
| 386 | $template->set_filenames(array( |
| 387 | 'confirm' => 'confirm_body.tpl') |
| 388 | ); |
| 389 | |
| 390 | $template->assign_vars(array( |
| 391 | 'MESSAGE_TITLE' => $lang['Confirm'], |
| 392 | 'MESSAGE_TEXT' => $lang['Confirm_delete_topic'], |
| 393 | |
| 394 | 'L_YES' => $lang['Yes'], |
| 395 | 'L_NO' => $lang['No'], |
| 396 | |
| 397 | 'S_CONFIRM_ACTION' => append_sid("modcp.$phpEx"), |
| 398 | 'S_HIDDEN_FIELDS' => $hidden_fields) |
| 399 | ); |
| 400 | |
| 401 | $template->pparse('confirm'); |
| 402 | |
| 403 | include($phpbb_root_path . 'includes/page_tail.'.$phpEx); |
| 404 | } |
| 405 | break;
|
| 406 | |
| 407 | case 'move': |
| 408 | $page_title = $lang['Mod_CP']; |
| 409 | include($phpbb_root_path . 'includes/page_header.'.$phpEx); |
| 410 | |
| 411 | if ( $confirm ) |
| 412 | {
|
| 413 | if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) ) |
| 414 | {
|
| 415 | message_die(GENERAL_MESSAGE, $lang['None_selected']); |
| 416 | } |
| 417 | |
| 418 | $new_forum_id = $HTTP_POST_VARS['new_forum']; |
| 419 | $old_forum_id = $forum_id; |
| 420 | |
| 421 | if ( $new_forum_id != $old_forum_id ) |
| 422 | {
|
| 423 | $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id); |
| 424 | |
| 425 | $topic_list = ''; |
| 426 | for($i = 0; $i < count($topics); $i++) |
| 427 | {
|
| 428 | $topic_list .= ( ( $topic_list != '' ) ? ', ' : '' ) . intval($topics[$i]); |
| 429 | } |
| 430 | |
| 431 | $sql = "SELECT * |
| 432 | FROM " . TOPICS_TABLE . " |
| 433 | WHERE topic_id IN ($topic_list) |
| 434 | AND topic_status <> " . TOPIC_MOVED; |
| 435 | if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) ) |
| 436 | {
|
| 437 | message_die(GENERAL_ERROR, 'Could not select from topic table', '', __LINE__, __FILE__, $sql); |
| 438 | } |
| 439 | |
| 440 | $row = $db->sql_fetchrowset($result); |
| 441 | $db->sql_freeresult($result); |
| 442 | |
| 443 | for($i = 0; $i < count($row); $i++) |
| 444 | {
|
| 445 | $topic_id = $row[$i]['topic_id']; |
| 446 | |
| 447 | if ( isset($HTTP_POST_VARS['move_leave_shadow']) ) |
| 448 | {
|
| 449 | // Insert topic in the old forum that indicates that the forum has moved.
|
| 450 | $sql = "INSERT INTO " . TOPICS_TABLE . " (forum_id, topic_title, topic_poster, topic_time, topic_status, topic_type, topic_vote, topic_views, topic_replies, topic_first_post_id, topic_last_post_id, topic_moved_id) |
| 451 | VALUES ($old_forum_id, '" . addslashes(str_replace("\'", "''", $row[$i]['topic_title'])) . "', '" . str_replace("\'", "''", $row[$i]['topic_poster']) . "', " . $row[$i]['topic_time'] . ", " . TOPIC_MOVED . ", " . POST_NORMAL . ", " . $row[$i]['topic_vote'] . ", " . $row[$i]['topic_views'] . ", " . $row[$i]['topic_replies'] . ", " . $row[$i]['topic_first_post_id'] . ", " . $row[$i]['topic_last_post_id'] . ", $topic_id)"; |
| 452 | if ( !$db->sql_query($sql) ) |
| 453 | {
|
| 454 | message_die(GENERAL_ERROR, 'Could not insert shadow topic', '', __LINE__, __FILE__, $sql); |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | $sql = "UPDATE " . TOPICS_TABLE . " |
| 459 | SET forum_id = $new_forum_id |
| 460 | WHERE topic_id = $topic_id"; |
| 461 | if ( !$db->sql_query($sql) ) |
| 462 | {
|
| 463 | message_die(GENERAL_ERROR, 'Could not update old topic', '', __LINE__, __FILE__, $sql); |
| 464 | } |
| 465 | |
| 466 | $sql = "UPDATE " . POSTS_TABLE . " |
| 467 | SET forum_id = $new_forum_id |
| 468 | WHERE topic_id = $topic_id"; |
| 469 | if ( !$db->sql_query($sql) ) |
| 470 | {
|
| 471 | message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | // Sync the forum indexes
|
| 476 | sync('forum', $new_forum_id); |
| 477 | sync('forum', $old_forum_id); |
| 478 | |
| 479 | $message = $lang['Topics_Moved'] . '<br /><br />'; |
| 480 | |
| 481 | } |
| 482 | else
|
| 483 | {
|
| 484 | $message = $lang['No_Topics_Moved'] . '<br /><br />'; |
| 485 | } |
| 486 | |
| 487 | if ( !empty($topic_id) ) |
| 488 | {
|
| 489 | $redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id"); |
| 490 | $message .= sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>'); |
| 491 | } |
| 492 | else
|
| 493 | {
|
| 494 | $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id"); |
| 495 | $message .= sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>'); |
| 496 | } |
| 497 | |
| 498 | $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$old_forum_id") . '">', '</a>'); |
| 499 | |
| 500 | $template->assign_vars(array( |
| 501 | 'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">') |
| 502 | ); |
| 503 | |
| 504 | message_die(GENERAL_MESSAGE, $message); |
| 505 | } |
| 506 | else
|
| 507 | {
|
| 508 | if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) ) |
| 509 | {
|
| 510 | message_die(GENERAL_MESSAGE, $lang['None_selected']); |
| 511 | } |
| 512 | |
| 513 | $hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />'; |
| 514 | |
| 515 | if ( isset($HTTP_POST_VARS['topic_id_list']) ) |
| 516 | {
|
| 517 | $topics = $HTTP_POST_VARS['topic_id_list']; |
| 518 | |
| 519 | for($i = 0; $i < count($topics); $i++) |
| 520 | {
|
| 521 | $hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />'; |
| 522 | } |
| 523 | } |
| 524 | else
|
| 525 | {
|
| 526 | $hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />'; |
| 527 | } |
| 528 | |
| 529 | //
|
| 530 | // Set template files
|
| 531 | //
|
| 532 | $template->set_filenames(array( |
| 533 | 'movetopic' => 'modcp_move.tpl') |
| 534 | ); |
| 535 | |
| 536 | $template->assign_vars(array( |
| 537 | 'MESSAGE_TITLE' => $lang['Confirm'], |
| 538 | 'MESSAGE_TEXT' => $lang['Confirm_move_topic'], |
| 539 | |
| 540 | 'L_MOVE_TO_FORUM' => $lang['Move_to_forum'], |
| 541 | 'L_LEAVESHADOW' => $lang['Leave_shadow_topic'], |
| 542 | 'L_YES' => $lang['Yes'], |
| 543 | 'L_NO' => $lang['No'], |
| 544 | |
| 545 | 'S_FORUM_SELECT' => make_forum_select('new_forum', $forum_id), |
| 546 | 'S_MODCP_ACTION' => append_sid("modcp.$phpEx"), |
| 547 | 'S_HIDDEN_FIELDS' => $hidden_fields) |
| 548 | ); |
| 549 | |
| 550 | $template->pparse('movetopic'); |
| 551 | |
| 552 | include($phpbb_root_path . 'includes/page_tail.'.$phpEx); |
| 553 | } |
| 554 | break;
|
| 555 | |
| 556 | case 'lock': |
| 557 | if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) ) |
| 558 | {
|
| 559 | message_die(GENERAL_MESSAGE, $lang['None_selected']); |
| 560 | } |
| 561 | |
| 562 | $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id); |
| 563 | |
| 564 | $topic_id_sql = ''; |
| 565 | for($i = 0; $i < count($topics); $i++) |
| 566 | {
|
| 567 | $topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . $topics[$i]; |
| 568 | } |
| 569 | |
| 570 | $sql = "UPDATE " . TOPICS_TABLE . " |
| 571 | SET topic_status = " . TOPIC_LOCKED . " |
| 572 | WHERE topic_id IN ($topic_id_sql) |
| 573 | AND topic_moved_id = 0";
|
| 574 | if ( !($result = $db->sql_query($sql)) ) |
| 575 | {
|
| 576 | message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql); |
| 577 | } |
| 578 | |
| 579 | if ( !empty($topic_id) ) |
| 580 | {
|
| 581 | $redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id"); |
| 582 | $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>'); |
| 583 | } |
| 584 | else
|
| 585 | {
|
| 586 | $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id"); |
| 587 | $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>'); |
| 588 | } |
| 589 | |
| 590 | $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>'); |
| 591 | |
| 592 | $template->assign_vars(array( |
| 593 | 'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">') |
| 594 | ); |
| 595 | |
| 596 | message_die(GENERAL_MESSAGE, $lang['Topics_Locked'] . '<br /><br />' . $message); |
| 597 | |
| 598 | break;
|
| 599 | |
| 600 | case 'unlock': |
| 601 | if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) ) |
| 602 | {
|
| 603 | message_die(GENERAL_MESSAGE, $lang['None_selected']); |
| 604 | } |
| 605 | |
| 606 | $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id); |
| 607 | |
| 608 | $topic_id_sql = ''; |
| 609 | for($i = 0; $i < count($topics); $i++) |
| 610 | {
|
| 611 | $topic_id_sql .= ( ( $topic_id_sql != "") ? ', ' : '' ) . $topics[$i]; |
| 612 | } |
| 613 | |
| 614 | $sql = "UPDATE " . TOPICS_TABLE . " |
| 615 | SET topic_status = " . TOPIC_UNLOCKED . " |
| 616 | WHERE topic_id IN ($topic_id_sql) |
| 617 | AND topic_moved_id = 0";
|
| 618 | if ( !($result = $db->sql_query($sql)) ) |
| 619 | {
|
| 620 | message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql); |
| 621 | } |
| 622 | |
| 623 | if ( !empty($topic_id) ) |
| 624 | {
|
| 625 | $redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id"); |
| 626 | $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>'); |
| 627 | } |
| 628 | else
|
| 629 | {
|
| 630 | $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id"); |
| 631 | $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>'); |
| 632 | } |
| 633 | |
| 634 | $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>'); |
| 635 | |
| 636 | $template->assign_vars(array( |
| 637 | 'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">') |
| 638 | ); |
| 639 | |
| 640 | message_die(GENERAL_MESSAGE, $lang['Topics_Unlocked'] . '<br /><br />' . $message); |
| 641 | |
| 642 | break;
|
| 643 | |
| 644 | case 'split': |
| 645 | $page_title = $lang['Mod_CP']; |
| 646 | include($phpbb_root_path . 'includes/page_header.'.$phpEx); |
| 647 | |
| 648 | if ( isset($HTTP_POST_VARS['split_type_all']) || isset($HTTP_POST_VARS['split_type_beyond']) ) |
| 649 | {
|
| 650 | $posts = $HTTP_POST_VARS['post_id_list']; |
| 651 | |
| 652 | $sql = "SELECT poster_id, topic_id, post_time |
| 653 | FROM " . POSTS_TABLE . " |
| 654 | WHERE post_id = " . $posts[0]; |
| 655 | if ( !($result = $db->sql_query($sql)) ) |
| 656 | {
|
| 657 | message_die(GENERAL_ERROR, 'Could not get post information', '', __LINE__, __FILE__, $sql); |
| 658 | } |
| 659 | |
| 660 | $post_rowset = $db->sql_fetchrow($result); |
| 661 | $first_poster = str_replace("\'", "''", $post_rowset['poster_id']); |
| 662 | $topic_id = $post_rowset['topic_id']; |
| 663 | $post_time = $post_rowset['post_time']; |
| 664 | |
| 665 | $post_subject = trim(htmlspecialchars($HTTP_POST_VARS['subject'])); |
| 666 | if ( empty($post_subject) ) |
| 667 | {
|
| 668 | message_die(GENERAL_MESSAGE, $lang['Empty_subject']); |
| 669 | } |
| 670 | |
| 671 | $new_forum_id = intval($HTTP_POST_VARS['new_forum_id']); |
| 672 | $topic_time = time(); |
| 673 | |
| 674 | $sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type) |
| 675 | VALUES ('" . str_replace("\'", "''", $post_subject) . "', $first_poster, " . $topic_time . ", $new_forum_id, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")";
|
| 676 | if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) ) |
| 677 | {
|
| 678 | message_die(GENERAL_ERROR, 'Could not insert new topic', '', __LINE__, __FILE__, $sql); |
| 679 | } |
| 680 | |
| 681 | $new_topic_id = $db->sql_nextid(); |
| 682 | |
| 683 | if( !empty($HTTP_POST_VARS['split_type_all']) ) |
| 684 | {
|
| 685 | $post_id_sql = ''; |
| 686 | for($i = 0; $i < count($posts); $i++) |
| 687 | {
|
| 688 | $post_id_sql .= ( ( $post_id_sql != '' ) ? ', ' : '' ) . $posts[$i]; |
| 689 | } |
| 690 | |
| 691 | $sql = "UPDATE " . POSTS_TABLE . " |
| 692 | SET topic_id = $new_topic_id, forum_id = $new_forum_id |
| 693 | WHERE post_id IN ($post_id_sql)"; |
| 694 | } |
| 695 | else if( !empty($HTTP_POST_VARS['split_type_beyond']) ) |
| 696 | {
|
| 697 | $sql = "UPDATE " . POSTS_TABLE . " |
| 698 | SET topic_id = $new_topic_id, forum_id = $new_forum_id |
| 699 | WHERE post_time >= $post_time |
| 700 | AND topic_id = $topic_id"; |
| 701 | } |
| 702 | |
| 703 | if( !$db->sql_query($sql, END_TRANSACTION) ) |
| 704 | {
|
| 705 | message_die(GENERAL_ERROR, 'Could not update posts table', '', __LINE__, __FILE__, $sql); |
| 706 | } |
| 707 | |
| 708 | sync('topic', $new_topic_id); |
| 709 | sync('topic', $topic_id); |
| 710 | sync('forum', $new_forum_id); |
| 711 | sync('forum', $forum_id); |
| 712 | |
| 713 | $template->assign_vars(array( |
| 714 | 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">') |
| 715 | ); |
| 716 | |
| 717 | $message = $lang['Topic_split'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>'); |
| 718 | message_die(GENERAL_MESSAGE, $message); |
| 719 | } |
| 720 | else
|
| 721 | {
|
| 722 | //
|
| 723 | // Set template files
|
| 724 | //
|
| 725 | $template->set_filenames(array( |
| 726 | 'split_body' => 'modcp_split.tpl') |
| 727 | ); |
| 728 | |
| 729 | $sql = "SELECT u.username, p.*, pt.post_text, pt.bbcode_uid, pt.post_subject, p.post_username |
| 730 | FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt |
| 731 | WHERE p.topic_id = $topic_id |
| 732 | AND p.poster_id = u.user_id |
| 733 | AND p.post_id = pt.post_id |
| 734 | ORDER BY p.post_time ASC";
|
| 735 | if ( !($result = $db->sql_query($sql)) ) |
| 736 | {
|
| 737 | message_die(GENERAL_ERROR, 'Could not get topic/post information', '', __LINE__, __FILE__, $sql); |
| 738 | } |
| 739 | |
| 740 | $s_hidden_fields = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" /><input type="hidden" name="mode" value="split" />'; |
| 741 | |
| 742 | if( ( $total_posts = $db->sql_numrows($result) ) > 0 ) |
| 743 | {
|
| 744 | $postrow = $db->sql_fetchrowset($result); |
| 745 | |
| 746 | $template->assign_vars(array( |
| 747 | 'L_SPLIT_TOPIC' => $lang['Split_Topic'], |
| 748 | 'L_SPLIT_TOPIC_EXPLAIN' => $lang['Split_Topic_explain'], |
| 749 | 'L_AUTHOR' => $lang['Author'], |
| 750 | 'L_MESSAGE' => $lang['Message'], |
| 751 | 'L_SELECT' => $lang['Select'], |
| 752 | 'L_SPLIT_SUBJECT' => $lang['Split_title'], |
| 753 | 'L_SPLIT_FORUM' => $lang['Split_forum'], |
| 754 | 'L_POSTED' => $lang['Posted'], |
| 755 | 'L_SPLIT_POSTS' => $lang['Split_posts'], |
| 756 | 'L_SUBMIT' => $lang['Submit'], |
| 757 | 'L_SPLIT_AFTER' => $lang['Split_after'], |
| 758 | 'L_POST_SUBJECT' => $lang['Post_subject'], |
| 759 | 'L_MARK_ALL' => $lang['Mark_all'], |
| 760 | 'L_UNMARK_ALL' => $lang['Unmark_all'], |
| 761 | 'L_POST' => $lang['Post'], |
| 762 | |
| 763 | 'FORUM_NAME' => $forum_name, |
| 764 | |
| 765 | 'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"), |
| 766 | |
| 767 | 'S_SPLIT_ACTION' => append_sid("modcp.$phpEx"), |
| 768 | 'S_HIDDEN_FIELDS' => $s_hidden_fields, |
| 769 | 'S_FORUM_SELECT' => make_forum_select("new_forum_id", false, $forum_id)) |
| 770 | ); |
| 771 | |
| 772 | for($i = 0; $i < $total_posts; $i++) |
| 773 | {
|
| 774 | $post_id = $postrow[$i]['post_id']; |
| 775 | $poster_id = $postrow[$i]['user_id']; |
| 776 | $poster = $postrow[$i]['username']; |
| 777 | |
| 778 | $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']); |
| 779 | |
| 780 | $bbcode_uid = $postrow[$i]['bbcode_uid']; |
| 781 | $message = $postrow[$i]['post_text']; |
| 782 | $post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : $topic_title; |
| 783 | |
| 784 | //
|
| 785 | // If the board has HTML off but the post has HTML
|
| 786 | // on then we process it, else leave it alone
|
| 787 | //
|
| 788 | if ( !$board_config['allow_html'] ) |
| 789 | {
|
| 790 | if ( $postrow[$i]['enable_html'] ) |
| 791 | {
|
| 792 | $message = preg_replace('#(<)([\/]?.*?)(>)#is', '<\\2>', $message); |
| 793 | } |
| 794 | } |
| 795 | |
| 796 | if ( $bbcode_uid != '' ) |
| 797 | {
|
| 798 | $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message); |
| 799 | } |
| 800 | |
| 801 | //
|
| 802 | // Define censored word matches
|
| 803 | //
|
| 804 | $orig_word = array(); |
| 805 | $replacement_word = array(); |
| 806 | obtain_word_list($orig_word, $replacement_word); |
| 807 | |
| 808 | if ( count($orig_word) ) |
| 809 | {
|
| 810 | $post_subject = preg_replace($orig_word, $replacement_word, $post_subject); |
| 811 | $message = preg_replace($orig_word, $replacement_word, $message); |
| 812 | } |
| 813 | |
| 814 | $message = make_clickable($message); |
| 815 | |
| 816 | if ( $board_config['allow_smilies'] && $postrow[$i]['enable_smilies'] ) |
| 817 | {
|
| 818 | $message = smilies_pass($message); |
| 819 | } |
| 820 | |
| 821 | $message = str_replace("\n", '<br />', $message); |
| 822 | |
| 823 | $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; |
| 824 | $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; |
| 825 | |
| 826 | $checkbox = ( $i > 0 ) ? '<input type="checkbox" name="post_id_list[]" value="' . $post_id . '" />' : ' '; |
| 827 | |
| 828 | $template->assign_block_vars('postrow', array( |
| 829 | 'ROW_COLOR' => '#' . $row_color, |
| 830 | 'ROW_CLASS' => $row_class, |
| 831 | 'POSTER_NAME' => $poster, |
| 832 | 'POST_DATE' => $post_date, |
| 833 | 'POST_SUBJECT' => $post_subject, |
| 834 | 'MESSAGE' => $message, |
| 835 | 'POST_ID' => $post_id, |
| 836 | |
| 837 | 'S_SPLIT_CHECKBOX' => $checkbox) |
| 838 | ); |
| 839 | } |
| 840 | |
| 841 | $template->pparse('split_body'); |
| 842 | } |
| 843 | } |
| 844 | break;
|
| 845 | |
| 846 | case 'ip': |
| 847 | $page_title = $lang['Mod_CP']; |
| 848 | include($phpbb_root_path . 'includes/page_header.'.$phpEx); |
| 849 | |
| 850 | $rdns_ip_num = ( isset($HTTP_GET_VARS['rdns']) ) ? $HTTP_GET_VARS['rdns'] : ""; |
| 851 | |
| 852 | if ( !$post_id ) |
| 853 | {
|
| 854 | message_die(GENERAL_MESSAGE, $lang['No_such_post']); |
| 855 | } |
| 856 | |
| 857 | //
|
| 858 | // Set template files
|
| 859 | //
|
| 860 | $template->set_filenames(array( |
| 861 | 'viewip' => 'modcp_viewip.tpl') |
| 862 | ); |
| 863 | |
| 864 | // Look up relevent data for this post
|
| 865 | $sql = "SELECT poster_ip, poster_id |
| 866 | FROM " . POSTS_TABLE . " |
| 867 | WHERE post_id = $post_id"; |
| 868 | if ( !($result = $db->sql_query($sql)) ) |
| 869 | {
|
| 870 | message_die(GENERAL_ERROR, 'Could not get poster IP information', '', __LINE__, __FILE__, $sql); |
| 871 | } |
| 872 | |
| 873 | if ( !($post_row = $db->sql_fetchrow($result)) ) |
| 874 | {
|
| 875 | message_die(GENERAL_MESSAGE, $lang['No_such_post']); |
| 876 | } |
| 877 | |
| 878 | $ip_this_post = decode_ip($post_row['poster_ip']); |
| 879 | $ip_this_post = ( $rdns_ip_num == $ip_this_post ) ? gethostbyaddr($ip_this_post) : $ip_this_post; |
| 880 | |
| 881 | $poster_id = $post_row['poster_id']; |
| 882 | |
| 883 | $template->assign_vars(array( |
| 884 | 'L_IP_INFO' => $lang['IP_info'], |
| 885 | 'L_THIS_POST_IP' => $lang['This_posts_IP'], |
| 886 | 'L_OTHER_IPS' => $lang['Other_IP_this_user'], |
| 887 | 'L_OTHER_USERS' => $lang['Users_this_IP'], |
| 888 | 'L_LOOKUP_IP' => $lang['Lookup_IP'], |
| 889 | 'L_SEARCH' => $lang['Search'], |
| 890 | |
| 891 | 'SEARCH_IMG' => $images['icon_search'], |
| 892 | |
| 893 | 'IP' => $ip_this_post, |
| 894 | |
| 895 | 'U_LOOKUP_IP' => append_sid("modcp.$phpEx?mode=ip&" . POST_POST_URL . "=$post_id&" . POST_TOPIC_URL . "=$topic_id&rdns=" . $ip_this_post)) |
| 896 | ); |
| 897 | |
| 898 | //
|
| 899 | // Get other IP's this user has posted under
|
| 900 | //
|
| 901 | $sql = "SELECT poster_ip, COUNT(*) AS postings |
| 902 | FROM " . POSTS_TABLE . " |
| 903 | WHERE poster_id = $poster_id |
| 904 | GROUP BY poster_ip |
| 905 | ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC"; |
| 906 | if ( !($result = $db->sql_query($sql)) ) |
| 907 | {
|
| 908 | message_die(GENERAL_ERROR, 'Could not get IP information for this user', '', __LINE__, __FILE__, $sql); |
| 909 | } |
| 910 | |
| 911 | if ( $row = $db->sql_fetchrow($result) ) |
| 912 | {
|
| 913 | $i = 0; |
| 914 | do
|
| 915 | {
|
| 916 | if ( $row['poster_ip'] == $post_row['poster_ip'] ) |
| 917 | {
|
| 918 | $template->assign_vars(array( |
| 919 | 'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] )) |
| 920 | ); |
| 921 | continue;
|
| 922 | } |
| 923 | |
| 924 | $ip = decode_ip($row['poster_ip']); |
| 925 | $ip = ( $rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? gethostbyaddr($ip) : $ip; |
| 926 | |
| 927 | $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; |
| 928 | $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; |
| 929 | |
| 930 | $template->assign_block_vars('iprow', array( |
| 931 | 'ROW_COLOR' => '#' . $row_color, |
| 932 | 'ROW_CLASS' => $row_class, |
| 933 | 'IP' => $ip, |
| 934 | 'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ), |
| 935 | |
| 936 | 'U_LOOKUP_IP' => append_sid("modcp.$phpEx?mode=ip&" . POST_POST_URL . "=$post_id&" . POST_TOPIC_URL . "=$topic_id&rdns=" . $row['poster_ip'])) |
| 937 | ); |
| 938 | |
| 939 | $i++;
|
| 940 | } |
| 941 | while ( $row = $db->sql_fetchrow($result) ); |
| 942 | } |
| 943 | |
| 944 | //
|
| 945 | // Get other users who've posted under this IP
|
| 946 | //
|
| 947 | $sql = "SELECT u.user_id, u.username, COUNT(*) as postings |
| 948 | FROM " . USERS_TABLE ." u, " . POSTS_TABLE . " p |
| 949 | WHERE p.poster_id = u.user_id |
| 950 | AND p.poster_ip = '" . $post_row['poster_ip'] . "' |
| 951 | GROUP BY u.user_id, u.username |
| 952 | ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC"; |
| 953 | if ( !($result = $db->sql_query($sql)) ) |
| 954 | {
|
| 955 | message_die(GENERAL_ERROR, 'Could not get posters information based on IP', '', __LINE__, __FILE__, $sql); |
| 956 | } |
| 957 | |
| 958 | if ( $row = $db->sql_fetchrow($result) ) |
| 959 | {
|
| 960 | $i = 0; |
| 961 | do
|
| 962 | {
|
| 963 | $id = $row['user_id']; |
| 964 | $username = ( $id == ANONYMOUS ) ? $lang['Guest'] : $row['username']; |
| 965 | |
| 966 | $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; |
| 967 | $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; |
| 968 | |
| 969 | $template->assign_block_vars('userrow', array( |
| 970 | 'ROW_COLOR' => '#' . $row_color, |
| 971 | 'ROW_CLASS' => $row_class, |
| 972 | 'USERNAME' => $username, |
| 973 | 'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ), |
| 974 | 'L_SEARCH_POSTS' => sprintf($lang['Search_user_posts'], $username), |
| 975 | |
| 976 | 'U_PROFILE' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$id"), |
| 977 | 'U_SEARCHPOSTS' => append_sid("search.$phpEx?search_author=" . urlencode($username) . "&showresults=topics")) |
| 978 | ); |
| 979 | |
| 980 | $i++;
|
| 981 | } |
| 982 | while ( $row = $db->sql_fetchrow($result) ); |
| 983 | } |
| 984 | |
| 985 | $template->pparse('viewip'); |
| 986 | |
| 987 | break;
|
| 988 | |
| 989 | default:
|
| 990 | $page_title = $lang['Mod_CP']; |
| 991 | include($phpbb_root_path . 'includes/page_header.'.$phpEx); |
| 992 | |
| 993 | $template->assign_vars(array( |
| 994 | 'FORUM_NAME' => $forum_name, |
| 995 | |
| 996 | 'L_MOD_CP' => $lang['Mod_CP'], |
| 997 | 'L_MOD_CP_EXPLAIN' => $lang['Mod_CP_explain'], |
| 998 | 'L_SELECT' => $lang['Select'], |
| 999 | 'L_DELETE' => $lang['Delete'], |
| 1000 | 'L_MOVE' => $lang['Move'], |
| 1001 | 'L_LOCK' => $lang['Lock'], |
| 1002 | 'L_UNLOCK' => $lang['Unlock'], |
| 1003 | 'L_TOPICS' => $lang['Topics'], |
| 1004 | 'L_REPLIES' => $lang['Replies'], |
| 1005 | 'L_LASTPOST' => $lang['Last_Post'], |
| 1006 | 'L_SELECT' => $lang['Select'], |
| 1007 | |
| 1008 | 'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"), |
| 1009 | 'S_HIDDEN_FIELDS' => '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">', |
| 1010 | 'S_MODCP_ACTION' => append_sid("modcp.$phpEx")) |
| 1011 | ); |
| 1012 | |
| 1013 | $template->set_filenames(array( |
| 1014 | 'body' => 'modcp_body.tpl') |
| 1015 | ); |
| 1016 | |
| 1017 | //
|
| 1018 | // Define censored word matches
|
| 1019 | //
|
| 1020 | $orig_word = array(); |
| 1021 | $replacement_word = array(); |
| 1022 | obtain_word_list($orig_word, $replacement_word); |
| 1023 | |
| 1024 | $sql = "SELECT t.*, u.username, u.user_id, p.post_time |
| 1025 | FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p |
| 1026 | WHERE t.forum_id = $forum_id |
| 1027 | AND t.topic_poster = u.user_id |
| 1028 | AND p.post_id = t.topic_last_post_id |
| 1029 | ORDER BY t.topic_type DESC, p.post_time DESC |
| 1030 | LIMIT $start, " . $board_config['topics_per_page']; |
| 1031 | if ( !($result = $db->sql_query($sql)) ) |
| 1032 | {
|
| 1033 | message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql); |
| 1034 | } |
| 1035 | |
| 1036 | while ( $row = $db->sql_fetchrow($result) ) |
| 1037 | {
|
| 1038 | $topic_title = ''; |
| 1039 | |
| 1040 | if ( $row['topic_status'] == TOPIC_LOCKED ) |
| 1041 | {
|
| 1042 | $folder_img = $images['folder_locked']; |
| 1043 | $folder_alt = $lang['Topic_locked']; |
| 1044 | } |
| 1045 | else
|
| 1046 | {
|
| 1047 | if ( $row['topic_type'] == POST_ANNOUNCE ) |
| 1048 | {
|
| 1049 | $folder_img = $images['folder_announce']; |
| 1050 | $folder_alt = $lang['Topic_Announcement']; |
| 1051 | } |
| 1052 | else if ( $row['topic_type'] == POST_STICKY ) |
| 1053 | {
|
| 1054 | $folder_img = $images['folder_sticky']; |
| 1055 | $folder_alt = $lang['Topic_Sticky']; |
| 1056 | } |
| 1057 | else
|
| 1058 | {
|
| 1059 | $folder_img = $images['folder']; |
| 1060 | $folder_alt = $lang['No_new_posts']; |
| 1061 | } |
| 1062 | } |
| 1063 | |
| 1064 | $topic_id = $row['topic_id']; |
| 1065 | $topic_type = $row['topic_type']; |
| 1066 | $topic_status = $row['topic_status']; |
| 1067 | |
| 1068 | if ( $topic_type == POST_ANNOUNCE ) |
| 1069 | {
|
| 1070 | $topic_type = $lang['Topic_Announcement'] . ' '; |
| 1071 | } |
| 1072 | else if ( $topic_type == POST_STICKY ) |
| 1073 | {
|
| 1074 | $topic_type = $lang['Topic_Sticky'] . ' '; |
| 1075 | } |
| 1076 | else if ( $topic_status == TOPIC_MOVED ) |
| 1077 | {
|
| 1078 | $topic_type = $lang['Topic_Moved'] . ' '; |
| 1079 | } |
| 1080 | else
|
| 1081 | {
|
| 1082 | $topic_type = ''; |
| 1083 | } |
| 1084 | |
| 1085 | if ( $row['topic_vote'] ) |
| 1086 | {
|
| 1087 | $topic_type .= $lang['Topic_Poll'] . ' '; |
| 1088 | } |
| 1089 | |
| 1090 | $topic_title = $row['topic_title']; |
| 1091 | if ( count($orig_word) ) |
| 1092 | {
|
| 1093 | $topic_title = preg_replace($orig_word, $replacement_word, $topic_title); |
| 1094 | } |
| 1095 | |
| 1096 | $u_view_topic = append_sid("modcp.$phpEx?mode=split&" . POST_TOPIC_URL . "=$topic_id"); |
| 1097 | $topic_replies = $row['topic_replies']; |
| 1098 | |
| 1099 | $last_post_time = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']); |
| 1100 | |
| 1101 | $template->assign_block_vars('topicrow', array( |
| 1102 | 'U_VIEW_TOPIC' => $u_view_topic, |
| 1103 | |
| 1104 | 'TOPIC_FOLDER_IMG' => $folder_img, |
| 1105 | 'TOPIC_TYPE' => $topic_type, |
| 1106 | 'TOPIC_TITLE' => $topic_title, |
| 1107 | 'REPLIES' => $topic_replies, |
| 1108 | 'LAST_POST_TIME' => $last_post_time, |
| 1109 | 'TOPIC_ID' => $topic_id, |
| 1110 | |
| 1111 | 'L_TOPIC_FOLDER_ALT' => $folder_alt) |
| 1112 | ); |
| 1113 | } |
| 1114 | |
| 1115 | $template->assign_vars(array( |
| 1116 | 'PAGINATION' => generate_pagination("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id", $forum_topics, $board_config['topics_per_page'], $start), |
| 1117 | 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $forum_topics / $board_config['topics_per_page'] )), |
| 1118 | 'L_GOTO_PAGE' => $lang['Goto_page']) |
| 1119 | ); |
| 1120 | |
| 1121 | $template->pparse('body'); |
| 1122 | |
| 1123 | break;
|
| 1124 | } |
| 1125 | |
| 1126 | include($phpbb_root_path . 'includes/page_tail.'.$phpEx); |
| 1127 | |
| 1128 | ?> |

