PageRenderTime 57ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/moderate.php

https://bitbucket.org/delroth/fluxbb-djangofr
PHP | 926 lines | 646 code | 196 blank | 84 comment | 150 complexity | 25fd47b384adf0f5b07934612248bfe1 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * Copyright (C) 2008-2010 FluxBB
  4. * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
  5. * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
  6. */
  7. define('PUN_ROOT', './');
  8. require PUN_ROOT.'include/common.php';
  9. // This particular function doesn't require forum-based moderator access. It can be used
  10. // by all moderators and admins
  11. if (isset($_GET['get_host']))
  12. {
  13. if (!$pun_user['is_admmod'])
  14. message($lang_common['No permission']);
  15. // Is get_host an IP address or a post ID?
  16. if (@preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $_GET['get_host']) || @preg_match('/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/', $_GET['get_host']))
  17. $ip = $_GET['get_host'];
  18. else
  19. {
  20. $get_host = intval($_GET['get_host']);
  21. if ($get_host < 1)
  22. message($lang_common['Bad request']);
  23. $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());
  24. if (!$db->num_rows($result))
  25. message($lang_common['Bad request']);
  26. $ip = $db->result($result);
  27. }
  28. // Load the misc.php language file
  29. require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php';
  30. message(sprintf($lang_misc['Host info 1'], $ip).'<br />'.sprintf($lang_misc['Host info 2'], @gethostbyaddr($ip)).'<br /><br /><a href="admin_users.php?show_users='.$ip.'">'.$lang_misc['Show more users'].'</a>');
  31. }
  32. // All other functions require moderator/admin access
  33. $fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
  34. if ($fid < 1)
  35. message($lang_common['Bad request']);
  36. $result = $db->query('SELECT moderators FROM '.$db->prefix.'forums WHERE id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
  37. $moderators = $db->result($result);
  38. $mods_array = ($moderators != '') ? unserialize($moderators) : array();
  39. if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_moderator'] == '0' || !array_key_exists($pun_user['username'], $mods_array)))
  40. message($lang_common['No permission']);
  41. // Get topic/forum tracking data
  42. if (!$pun_user['is_guest'])
  43. $tracked_topics = get_tracked_topics();
  44. // Load the misc.php language file
  45. require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php';
  46. // All other topic moderation features require a topic ID in GET
  47. if (isset($_GET['tid']))
  48. {
  49. $tid = intval($_GET['tid']);
  50. if ($tid < 1)
  51. message($lang_common['Bad request']);
  52. // Fetch some info about the topic
  53. $result = $db->query('SELECT t.subject, t.num_replies, t.first_post_id, f.id AS forum_id, forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'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());
  54. if (!$db->num_rows($result))
  55. message($lang_common['Bad request']);
  56. $cur_topic = $db->fetch_assoc($result);
  57. // Delete one or more posts
  58. if (isset($_POST['delete_posts']) || isset($_POST['delete_posts_comply']))
  59. {
  60. $posts = isset($_POST['posts']) ? $_POST['posts'] : array();
  61. if (empty($posts))
  62. message($lang_misc['No posts selected']);
  63. if (isset($_POST['delete_posts_comply']))
  64. {
  65. confirm_referrer('moderate.php');
  66. if (@preg_match('/[^0-9,]/', $posts))
  67. message($lang_common['Bad request']);
  68. // Verify that the post IDs are valid
  69. $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());
  70. if ($db->num_rows($result) != substr_count($posts, ',') + 1)
  71. message($lang_common['Bad request']);
  72. // Delete the posts
  73. $db->query('DELETE FROM '.$db->prefix.'posts WHERE id IN('.$posts.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error());
  74. require PUN_ROOT.'include/search_idx.php';
  75. strip_search_index($posts);
  76. // Get last_post, last_post_id, and last_poster for the topic after deletion
  77. $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());
  78. $last_post = $db->fetch_assoc($result);
  79. // How many posts did we just delete?
  80. $num_posts_deleted = substr_count($posts, ',') + 1;
  81. // Update the topic
  82. $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());
  83. update_forum($fid);
  84. redirect('viewtopic.php?id='.$tid, $lang_misc['Delete posts redirect']);
  85. }
  86. $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']);
  87. define('PUN_ACTIVE_PAGE', 'index');
  88. require PUN_ROOT.'header.php';
  89. ?>
  90. <div class="blockform">
  91. <h2><span><?php echo $lang_misc['Delete posts'] ?></span></h2>
  92. <div class="box">
  93. <form method="post" action="moderate.php?fid=<?php echo $fid ?>&amp;tid=<?php echo $tid ?>">
  94. <div class="inform">
  95. <fieldset>
  96. <legend><?php echo $lang_misc['Confirm delete legend'] ?></legend>
  97. <div class="infldset">
  98. <input type="hidden" name="posts" value="<?php echo implode(',', array_map('intval', array_keys($posts))) ?>" />
  99. <p><?php echo $lang_misc['Delete posts comply'] ?></p>
  100. </div>
  101. </fieldset>
  102. </div>
  103. <p class="buttons"><input type="submit" name="delete_posts_comply" value="<?php echo $lang_misc['Delete'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
  104. </form>
  105. </div>
  106. </div>
  107. <?php
  108. require PUN_ROOT.'footer.php';
  109. }
  110. else if (isset($_POST['split_posts']) || isset($_POST['split_posts_comply']))
  111. {
  112. $posts = isset($_POST['posts']) ? $_POST['posts'] : array();
  113. if (empty($posts))
  114. message($lang_misc['No posts selected']);
  115. if (isset($_POST['split_posts_comply']))
  116. {
  117. confirm_referrer('moderate.php');
  118. if (@preg_match('/[^0-9,]/', $posts))
  119. message($lang_common['Bad request']);
  120. // How many posts did we just split off?
  121. $num_posts_splitted = substr_count($posts, ',') + 1;
  122. // Verify that the post IDs are valid
  123. $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());
  124. if ($db->num_rows($result) != $num_posts_splitted)
  125. message($lang_common['Bad request']);
  126. // Load the post.php language file
  127. require PUN_ROOT.'lang/'.$pun_user['language'].'/post.php';
  128. // Check subject
  129. $new_subject = isset($_POST['new_subject']) ? pun_trim($_POST['new_subject']) : '';
  130. if ($new_subject == '')
  131. message($lang_post['No subject']);
  132. else if (pun_strlen($new_subject) > 70)
  133. message($lang_post['Too long subject']);
  134. // Get data from the new first post
  135. $result = $db->query('SELECT p.id, p.poster, p.posted FROM '.$db->prefix.'posts AS p WHERE id IN('.$posts.') ORDER BY p.id ASC LIMIT 1') or error('Unable to get first post', __FILE__, __LINE__, $db->error());
  136. $first_post_data = $db->fetch_assoc($result);
  137. // Create the new topic
  138. $db->query('INSERT INTO '.$db->prefix.'topics (poster, subject, posted, first_post_id, forum_id) VALUES (\''.$db->escape($first_post_data['poster']).'\', \''.$db->escape($new_subject).'\', '.$first_post_data['posted'].', '.$first_post_data['id'].', '.$fid.')') or error('Unable to create new topic', __FILE__, __LINE__, $db->error());
  139. $new_tid = $db->insert_id();
  140. // Move the posts to the new topic
  141. $db->query('UPDATE '.$db->prefix.'posts SET topic_id='.$new_tid.' WHERE id IN('.$posts.')') or error('Unable to move posts into new topic', __FILE__, __LINE__, $db->error());
  142. // Get last_post, last_post_id, and last_poster from the topic and update it
  143. $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());
  144. $last_post_data = $db->fetch_assoc($result);
  145. $db->query('UPDATE '.$db->prefix.'topics SET last_post='.$last_post_data['posted'].', last_post_id='.$last_post_data['id'].', last_poster=\''.$db->escape($last_post_data['poster']).'\', num_replies=num_replies-'.$num_posts_splitted.' WHERE id='.$tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
  146. // Get last_post, last_post_id, and last_poster from the new topic and update it
  147. $result = $db->query('SELECT id, poster, posted FROM '.$db->prefix.'posts WHERE topic_id='.$new_tid.' ORDER BY id DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
  148. $last_post_data = $db->fetch_assoc($result);
  149. $db->query('UPDATE '.$db->prefix.'topics SET last_post='.$last_post_data['posted'].', last_post_id='.$last_post_data['id'].', last_poster=\''.$db->escape($last_post_data['poster']).'\', num_replies='.($num_posts_splitted-1).' WHERE id='.$new_tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
  150. update_forum($fid);
  151. redirect('viewtopic.php?id='.$new_tid, $lang_misc['Split posts redirect']);
  152. }
  153. $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']);
  154. $focus_element = array('subject','new_subject');
  155. define('PUN_ACTIVE_PAGE', 'index');
  156. require PUN_ROOT.'header.php';
  157. ?>
  158. <div class="blockform">
  159. <h2><span><?php echo $lang_misc['Split posts'] ?></span></h2>
  160. <div class="box">
  161. <form id="subject" method="post" action="moderate.php?fid=<?php echo $fid ?>&amp;tid=<?php echo $tid ?>">
  162. <div class="inform">
  163. <fieldset>
  164. <legend><?php echo $lang_misc['Confirm split legend'] ?></legend>
  165. <div class="infldset">
  166. <input type="hidden" name="posts" value="<?php echo implode(',', array_map('intval', array_keys($posts))) ?>" />
  167. <label class="required"><strong><?php echo $lang_misc['New subject'] ?> <span><?php echo $lang_common['Required'] ?></span></strong><br /><input type="text" name="new_subject" size="80" maxlength="70" /><br /></label>
  168. <p><?php echo $lang_misc['Split posts comply'] ?></p>
  169. </div>
  170. </fieldset>
  171. </div>
  172. <p class="buttons"><input type="submit" name="split_posts_comply" value="<?php echo $lang_misc['Split'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
  173. </form>
  174. </div>
  175. </div>
  176. <?php
  177. require PUN_ROOT.'footer.php';
  178. }
  179. // Show the moderate posts view
  180. // Load the viewtopic.php language file
  181. require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
  182. // Used to disable the Move and Delete buttons if there are no replies to this topic
  183. $button_status = ($cur_topic['num_replies'] == 0) ? ' disabled="disabled"' : '';
  184. // Determine the post offset (based on $_GET['p'])
  185. $num_pages = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
  186. $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']);
  187. $start_from = $pun_user['disp_posts'] * ($p - 1);
  188. // Generate paging links
  189. $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'moderate.php?fid='.$fid.'&amp;tid='.$tid);
  190. if ($pun_config['o_censoring'] == '1')
  191. $cur_topic['subject'] = censor_words($cur_topic['subject']);
  192. $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), pun_htmlspecialchars($cur_topic['forum_name']), pun_htmlspecialchars($cur_topic['subject']));
  193. define('PUN_ACTIVE_PAGE', 'index');
  194. require PUN_ROOT.'header.php';
  195. ?>
  196. <div class="linkst">
  197. <div class="inbox crumbsplus">
  198. <ul class="crumbs">
  199. <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li>
  200. <li><span>»&#160;</span><a href="viewforum.php?id=<?php echo $fid ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li>
  201. <li><span>»&#160;</span><a href="viewtopic.php?id=<?php echo $tid ?>"><?php echo pun_htmlspecialchars($cur_topic['subject']) ?></a></li>
  202. <li><span>»&#160;</span><strong><?php echo $lang_misc['Moderate'] ?></strong></li>
  203. </ul>
  204. <div class="pagepost">
  205. <p class="pagelink conl"><?php echo $paging_links ?></p>
  206. </div>
  207. <div class="clearer"></div>
  208. </div>
  209. </div>
  210. <form method="post" action="moderate.php?fid=<?php echo $fid ?>&amp;tid=<?php echo $tid ?>">
  211. <?php
  212. require PUN_ROOT.'include/parser.php';
  213. $post_count = 0; // Keep track of post numbers
  214. // Retrieve a list of post IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data
  215. $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$tid.' ORDER BY id LIMIT '.$start_from.','.$pun_user['disp_posts']) or error('Unable to fetch post IDs', __FILE__, __LINE__, $db->error());
  216. $post_ids = array();
  217. for ($i = 0;$cur_post_id = $db->result($result, $i);$i++)
  218. $post_ids[] = $cur_post_id;
  219. // Retrieve the posts (and their respective poster)
  220. $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.use_bbcode, p.posted, p.edited, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE p.id IN ('.implode(',', $post_ids).') ORDER BY p.id', true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
  221. while ($cur_post = $db->fetch_assoc($result))
  222. {
  223. $post_count++;
  224. // If the poster is a registered user
  225. if ($cur_post['poster_id'] > 1)
  226. {
  227. if ($pun_user['g_view_users'] == '1')
  228. $poster = '<a href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>';
  229. else
  230. $poster = pun_htmlspecialchars($cur_post['poster']);
  231. // get_title() requires that an element 'username' be present in the array
  232. $cur_post['username'] = $cur_post['poster'];
  233. $user_title = get_title($cur_post);
  234. if ($pun_config['o_censoring'] == '1')
  235. $user_title = censor_words($user_title);
  236. }
  237. // If the poster is a guest (or a user that has been deleted)
  238. else
  239. {
  240. $poster = pun_htmlspecialchars($cur_post['poster']);
  241. $user_title = $lang_topic['Guest'];
  242. }
  243. // Perform the main parsing of the message (BBCode, smilies, censor words etc)
  244. $cur_post['message'] = parse_message($cur_post['message'], $cur_post['use_bbcode'], $cur_post['hide_smilies']);
  245. ?>
  246. <div id="p<?php echo $cur_post['id'] ?>" class="blockpost<?php if($cur_post['id'] == $cur_topic['first_post_id']) echo ' firstpost' ?><?php echo ($post_count % 2 == 0) ? ' roweven' : ' rowodd' ?><?php if ($post_count == 1) echo ' blockpost1' ?>">
  247. <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>
  248. <div class="box">
  249. <div class="inbox">
  250. <div class="postbody">
  251. <div class="postleft">
  252. <dl>
  253. <dt><strong><?php echo $poster ?></strong></dt>
  254. <dd class="usertitle"><strong><?php echo $user_title ?></strong></dd>
  255. </dl>
  256. </div>
  257. <div class="postright">
  258. <h3 class="nosize"><?php echo $lang_common['Message'] ?></h3>
  259. <div class="postmsg">
  260. <?php echo $cur_post['message']."\n" ?>
  261. <?php if ($cur_post['edited'] != '') echo "\t\t\t\t\t\t".'<p class="postedit"><em>'.$lang_topic['Last edit'].' '.pun_htmlspecialchars($cur_post['edited_by']).' ('.format_time($cur_post['edited']).')</em></p>'."\n"; ?>
  262. </div>
  263. </div>
  264. </div>
  265. </div>
  266. <div class="inbox">
  267. <div class="postfoot clearb">
  268. <div class="postfootright"><?php echo ($cur_post['id'] != $cur_topic['first_post_id']) ? '<p class="multidelete"><label><strong>'.$lang_misc['Select'].'</strong>&#160;<input type="checkbox" name="posts['.$cur_post['id'].']" value="1" /></label></p>' : '<p>'.$lang_misc['Cannot select first'].'</p>' ?></div>
  269. </div>
  270. </div>
  271. </div>
  272. </div>
  273. <?php
  274. }
  275. ?>
  276. <div class="postlinksb">
  277. <div class="inbox">
  278. <div class="pagepost">
  279. <p class="pagelink conl"><?php echo $paging_links ?></p>
  280. <p class="conr modbuttons"><input type="submit" name="split_posts" value="<?php echo $lang_misc['Split'] ?>"<?php echo $button_status ?> /> <input type="submit" name="delete_posts" value="<?php echo $lang_misc['Delete'] ?>"<?php echo $button_status ?> /></p>
  281. </div>
  282. </div>
  283. </div>
  284. </form>
  285. <?php
  286. require PUN_ROOT.'footer.php';
  287. }
  288. // Move one or more topics
  289. if (isset($_REQUEST['move_topics']) || isset($_POST['move_topics_to']))
  290. {
  291. if (isset($_POST['move_topics_to']))
  292. {
  293. confirm_referrer('moderate.php');
  294. if (@preg_match('/[^0-9,]/', $_POST['topics']))
  295. message($lang_common['Bad request']);
  296. $topics = explode(',', $_POST['topics']);
  297. $move_to_forum = isset($_POST['move_to_forum']) ? intval($_POST['move_to_forum']) : 0;
  298. if (empty($topics) || $move_to_forum < 1)
  299. message($lang_common['Bad request']);
  300. // Verify that the topic IDs are valid
  301. $result = $db->query('SELECT 1 FROM '.$db->prefix.'topics WHERE id IN('.implode(',',$topics).') AND forum_id='.$fid) or error('Unable to check topics', __FILE__, __LINE__, $db->error());
  302. if ($db->num_rows($result) != count($topics))
  303. message($lang_common['Bad request']);
  304. // Delete any redirect topics if there are any (only if we moved/copied the topic back to 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. // Move the topic(s)
  307. $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());
  308. // Should we create redirect topics?
  309. if (isset($_POST['with_redirect']))
  310. {
  311. foreach ($topics as $cur_topic)
  312. {
  313. // Fetch info for the redirect topic
  314. $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());
  315. $moved_to = $db->fetch_assoc($result);
  316. // Create the redirect topic
  317. $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());
  318. }
  319. }
  320. update_forum($fid); // Update the forum FROM which the topic was moved
  321. update_forum($move_to_forum); // Update the forum TO which the topic was moved
  322. $redirect_msg = (count($topics) > 1) ? $lang_misc['Move topics redirect'] : $lang_misc['Move topic redirect'];
  323. redirect('viewforum.php?id='.$move_to_forum, $redirect_msg);
  324. }
  325. if (isset($_POST['move_topics']))
  326. {
  327. $topics = isset($_POST['topics']) ? $_POST['topics'] : array();
  328. if (empty($topics))
  329. message($lang_misc['No topics selected']);
  330. $topics = implode(',', array_map('intval', array_keys($topics)));
  331. $action = 'multi';
  332. }
  333. else
  334. {
  335. $topics = intval($_GET['move_topics']);
  336. if ($topics < 1)
  337. message($lang_common['Bad request']);
  338. $action = 'single';
  339. }
  340. $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') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
  341. if ($db->num_rows($result) < 2)
  342. message($lang_misc['Nowhere to move']);
  343. $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']);
  344. define('PUN_ACTIVE_PAGE', 'index');
  345. require PUN_ROOT.'header.php';
  346. ?>
  347. <div class="blockform">
  348. <h2><span><?php echo ($action == 'single') ? $lang_misc['Move topic'] : $lang_misc['Move topics'] ?></span></h2>
  349. <div class="box">
  350. <form method="post" action="moderate.php?fid=<?php echo $fid ?>">
  351. <div class="inform">
  352. <input type="hidden" name="topics" value="<?php echo $topics ?>" />
  353. <fieldset>
  354. <legend><?php echo $lang_misc['Move legend'] ?></legend>
  355. <div class="infldset">
  356. <label><?php echo $lang_misc['Move to'] ?>
  357. <br /><select name="move_to_forum">
  358. <?php
  359. $cur_category = 0;
  360. while ($cur_forum = $db->fetch_assoc($result))
  361. {
  362. if ($cur_forum['cid'] != $cur_category) // A new category since last iteration?
  363. {
  364. if ($cur_category)
  365. echo "\t\t\t\t\t\t\t".'</optgroup>'."\n";
  366. echo "\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($cur_forum['cat_name']).'">'."\n";
  367. $cur_category = $cur_forum['cid'];
  368. }
  369. if ($cur_forum['fid'] != $fid)
  370. echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n";
  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 class="buttons"><input type="submit" name="move_topics_to" value="<?php echo $lang_misc['Move'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
  383. </form>
  384. </div>
  385. </div>
  386. <?php
  387. require PUN_ROOT.'footer.php';
  388. }
  389. // Merge two or more topics
  390. else if (isset($_POST['merge_topics']) || isset($_POST['merge_topics_comply']))
  391. {
  392. if (isset($_POST['merge_topics_comply']))
  393. {
  394. confirm_referrer('moderate.php');
  395. if (@preg_match('/[^0-9,]/', $_POST['topics']))
  396. message($lang_common['Bad request']);
  397. $topics = explode(',', $_POST['topics']);
  398. if (count($topics) < 2)
  399. message($lang_misc['Not enough topics selected']);
  400. // Verify that the topic IDs are valid (moved topics can not be merged?)
  401. // $result = $db->query('SELECT 1 FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $topics).') AND moved_to IS NULL AND forum_id='.$fid) or error('Unable to check topics', __FILE__, __LINE__, $db->error());
  402. $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());
  403. if ($db->num_rows($result) != count($topics))
  404. message($lang_common['Bad request']);
  405. // Fetch the topic that we're merging into
  406. $result = $db->query('SELECT t.id FROM '.$db->prefix.'topics AS t WHERE t.id IN('.implode(',', $topics).') ORDER BY posted LIMIT 1') or error('Unable to get topic', __FILE__, __LINE__, $db->error());
  407. $merge_to_tid = $db->result($result);
  408. // Make any redirect topics point to our new, merged topic
  409. $query = 'UPDATE '.$db->prefix.'topics SET moved_to='.$merge_to_tid.' WHERE moved_to IN('.implode(',', $topics).')';
  410. // Should we create redirect topics?
  411. if (isset($_POST['with_redirect']))
  412. $query .= ' OR (id IN('.implode(',', $topics).') AND id != '.$merge_to_tid.')';
  413. $db->query($query) or error('Unable to make redirection topics', __FILE__, __LINE__, $db->error());
  414. // Merge the posts into the topic
  415. $db->query('UPDATE '.$db->prefix.'posts SET topic_id='.$merge_to_tid.' WHERE topic_id IN('.implode(',', $topics).')') or error('Unable to merge the posts into the topic', __FILE__, __LINE__, $db->error());
  416. // Delete any subscriptions
  417. $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE topic_id IN('.implode(',', $topics).') AND topic_id != '.$merge_to_tid) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());
  418. // Without redirection the old topics are removed
  419. if (!isset($_POST['with_redirect']))
  420. $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $topics).') AND id != '.$merge_to_tid) or error('Unable to delete old topics', __FILE__, __LINE__, $db->error());
  421. // Count number of replies in the topic
  422. $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'posts WHERE topic_id='.$merge_to_tid) or error('Unable to fetch post count for topic', __FILE__, __LINE__, $db->error());
  423. $num_replies = $db->result($result, 0) - 1;
  424. // Get last_post, last_post_id and last_poster
  425. $result = $db->query('SELECT posted, id, poster FROM '.$db->prefix.'posts WHERE topic_id='.$merge_to_tid.' ORDER BY id DESC LIMIT 1') or error('Unable to get last post info', __FILE__, __LINE__, $db->error());
  426. list($last_post, $last_post_id, $last_poster) = $db->fetch_row($result);
  427. // Update topic
  428. $db->query('UPDATE '.$db->prefix.'topics SET num_replies='.$num_replies.', last_post='.$last_post.', last_post_id='.$last_post_id.', last_poster=\''.$db->escape($last_poster).'\' WHERE id='.$merge_to_tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
  429. // Update the thread/mail association
  430. $db->query('UPDATE '.$db->prefix.'mail_thread_assoc SET id_thread='.$merge_to_tid.' WHERE id_thread IN('.implode(',', $topics).')') or error('Unable to update the thread association', __FILE__, __LINE__, $db->error());
  431. // Update the forum FROM which the topic was moved and redirect
  432. update_forum($fid);
  433. redirect('viewforum.php?id='.$fid, $lang_misc['Merge topics redirect']);
  434. }
  435. $topics = isset($_POST['topics']) ? $_POST['topics'] : array();
  436. if (count($topics) < 2)
  437. message($lang_misc['Not enough topics selected']);
  438. $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']);
  439. define('PUN_ACTIVE_PAGE', 'index');
  440. require PUN_ROOT.'header.php';
  441. ?>
  442. <div class="blockform">
  443. <h2><span><?php echo $lang_misc['Merge topics'] ?></span></h2>
  444. <div class="box">
  445. <form method="post" action="moderate.php?fid=<?php echo $fid ?>">
  446. <input type="hidden" name="topics" value="<?php echo implode(',', array_map('intval', array_keys($topics))) ?>" />
  447. <div class="inform">
  448. <fieldset>
  449. <legend><?php echo $lang_misc['Confirm merge legend'] ?></legend>
  450. <div class="infldset">
  451. <div class="rbox">
  452. <label><input type="checkbox" name="with_redirect" value="1" /><?php echo $lang_misc['Leave redirect'] ?><br /></label>
  453. </div>
  454. </div>
  455. </fieldset>
  456. </div>
  457. <p class="buttons"><input type="submit" name="merge_topics_comply" value="<?php echo $lang_misc['Merge'] ?>" /> <a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
  458. </form>
  459. </div>
  460. </div>
  461. <?php
  462. require PUN_ROOT.'footer.php';
  463. }
  464. // Delete one or more topics
  465. else if (isset($_POST['delete_topics']) || isset($_POST['delete_topics_comply']))
  466. {
  467. $topics = isset($_POST['topics']) ? $_POST['topics'] : array();
  468. if (empty($topics))
  469. message($lang_misc['No topics selected']);
  470. if (isset($_POST['delete_topics_comply']))
  471. {
  472. confirm_referrer('moderate.php');
  473. if (@preg_match('/[^0-9,]/', $topics))
  474. message($lang_common['Bad request']);
  475. require PUN_ROOT.'include/search_idx.php';
  476. // Verify that the topic IDs are valid
  477. $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());
  478. if ($db->num_rows($result) != substr_count($topics, ',') + 1)
  479. message($lang_common['Bad request']);
  480. // Delete the topics and any redirect topics
  481. $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());
  482. // Delete any subscriptions
  483. $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE topic_id IN('.$topics.')') or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());
  484. // Create a list of the post IDs in this topic and then strip the search index
  485. $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
  486. $post_ids = '';
  487. while ($row = $db->fetch_row($result))
  488. $post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0];
  489. // We have to check that we actually have a list of post IDs since we could be deleting just a redirect topic
  490. if ($post_ids != '')
  491. strip_search_index($post_ids);
  492. // Delete posts
  493. $db->query('DELETE FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error());
  494. update_forum($fid);
  495. redirect('viewforum.php?id='.$fid, $lang_misc['Delete topics redirect']);
  496. }
  497. $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_misc['Moderate']);
  498. define('PUN_ACTIVE_PAGE', 'index');
  499. require PUN_ROOT.'header.php';
  500. ?>
  501. <div class="blockform">
  502. <h2><span><?php echo $lang_misc['Delete topics'] ?></span></h2>
  503. <div class="box">
  504. <form method="post" action="moderate.php?fid=<?php echo $fid ?>">
  505. <input type="hidden" name="topics" value="<?php echo implode(',', array_map('intval', array_keys($topics))) ?>" />
  506. <div class="inform">
  507. <fieldset>
  508. <legend><?php echo $lang_misc['Confirm delete legend'] ?></legend>
  509. <div class="infldset">
  510. <p><?php echo $lang_misc['Delete topics comply'] ?></p>
  511. </div>
  512. </fieldset>
  513. </div>
  514. <p class="buttons"><input type="submit" name="delete_topics_comply" value="<?php echo $lang_misc['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
  515. </form>
  516. </div>
  517. </div>
  518. <?php
  519. require PUN_ROOT.'footer.php';
  520. }
  521. // Open or close one or more topics
  522. else if (isset($_REQUEST['open']) || isset($_REQUEST['close']))
  523. {
  524. $action = (isset($_REQUEST['open'])) ? 0 : 1;
  525. // There could be an array of topic IDs in $_POST
  526. if (isset($_POST['open']) || isset($_POST['close']))
  527. {
  528. confirm_referrer('moderate.php');
  529. $topics = isset($_POST['topics']) ? @array_map('intval', @array_keys($_POST['topics'])) : array();
  530. if (empty($topics))
  531. message($lang_misc['No topics selected']);
  532. $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());
  533. $redirect_msg = ($action) ? $lang_misc['Close topics redirect'] : $lang_misc['Open topics redirect'];
  534. redirect('moderate.php?fid='.$fid, $redirect_msg);
  535. }
  536. // Or just one in $_GET
  537. else
  538. {
  539. confirm_referrer('viewtopic.php');
  540. $topic_id = ($action) ? intval($_GET['close']) : intval($_GET['open']);
  541. if ($topic_id < 1)
  542. message($lang_common['Bad request']);
  543. $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());
  544. $redirect_msg = ($action) ? $lang_misc['Close topic redirect'] : $lang_misc['Open topic redirect'];
  545. redirect('viewtopic.php?id='.$topic_id, $redirect_msg);
  546. }
  547. }
  548. // Stick a topic
  549. else if (isset($_GET['stick']))
  550. {
  551. confirm_referrer('viewtopic.php');
  552. $stick = intval($_GET['stick']);
  553. if ($stick < 1)
  554. message($lang_common['Bad request']);
  555. $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());
  556. redirect('viewtopic.php?id='.$stick, $lang_misc['Stick topic redirect']);
  557. }
  558. // Unstick a topic
  559. else if (isset($_GET['unstick']))
  560. {
  561. confirm_referrer('viewtopic.php');
  562. $unstick = intval($_GET['unstick']);
  563. if ($unstick < 1)
  564. message($lang_common['Bad request']);
  565. $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());
  566. redirect('viewtopic.php?id='.$unstick, $lang_misc['Unstick topic redirect']);
  567. }
  568. // No specific forum moderation action was specified in the query string, so we'll display the moderator forum
  569. // Load the viewforum.php language file
  570. require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';
  571. // Fetch some info about the forum
  572. $result = $db->query('SELECT f.forum_name, f.redirect_url, f.num_topics, f.sort_by FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
  573. if (!$db->num_rows($result))
  574. message($lang_common['Bad request']);
  575. $cur_forum = $db->fetch_assoc($result);
  576. // Is this a redirect forum? In that case, abort!
  577. if ($cur_forum['redirect_url'] != '')
  578. message($lang_common['Bad request']);
  579. // Determine the topic offset (based on $_GET['p'])
  580. $num_pages = ceil($cur_forum['num_topics'] / $pun_user['disp_topics']);
  581. $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']);
  582. $start_from = $pun_user['disp_topics'] * ($p - 1);
  583. // Generate paging links
  584. $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'moderate.php?fid='.$fid);
  585. $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), pun_htmlspecialchars($cur_forum['forum_name']));
  586. define('PUN_ACTIVE_PAGE', 'index');
  587. require PUN_ROOT.'header.php';
  588. ?>
  589. <div class="linkst">
  590. <div class="inbox crumbsplus">
  591. <ul class="crumbs">
  592. <li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li>
  593. <li><span>»&#160;</span><a href="viewforum.php?id=<?php echo $fid ?>"><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></a></li>
  594. <li><span>»&#160;</span><strong><?php echo $lang_misc['Moderate'] ?></strong></li>
  595. </ul>
  596. <div class="pagepost">
  597. <p class="pagelink conl"><?php echo $paging_links ?></p>
  598. </div>
  599. <div class="clearer"></div>
  600. </div>
  601. </div>
  602. <form method="post" action="moderate.php?fid=<?php echo $fid ?>">
  603. <div id="vf" class="blocktable">
  604. <h2><span><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></span></h2>
  605. <div class="box">
  606. <div class="inbox">
  607. <table cellspacing="0">
  608. <thead>
  609. <tr>
  610. <th class="tcl" scope="col"><?php echo $lang_common['Topic'] ?></th>
  611. <th class="tc2" scope="col"><?php echo $lang_common['Replies'] ?></th>
  612. <?php if ($pun_config['o_topic_views'] == '1'): ?> <th class="tc3" scope="col"><?php echo $lang_forum['Views'] ?></th>
  613. <?php endif; ?> <th class="tcr"><?php echo $lang_common['Last post'] ?></th>
  614. <th class="tcmod" scope="col"><?php echo $lang_misc['Select'] ?></th>
  615. </tr>
  616. </thead>
  617. <tbody>
  618. <?php
  619. // Retrieve a list of topic IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data
  620. $result = $db->query('SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$fid.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC, id DESC LIMIT '.$start_from.', '.$pun_user['disp_topics']) or error('Unable to fetch topic IDs', __FILE__, __LINE__, $db->error());
  621. // If there are topics in this forum
  622. if ($db->num_rows($result))
  623. {
  624. $topic_ids = array();
  625. for ($i = 0;$cur_topic_id = $db->result($result, $i);$i++)
  626. $topic_ids[] = $cur_topic_id;
  627. // Select topics
  628. $result = $db->query('SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $topic_ids).') ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC, id DESC') or error('Unable to fetch topic list for forum', __FILE__, __LINE__, $db->error());
  629. $button_status = '';
  630. $topic_count = 0;
  631. while ($cur_topic = $db->fetch_assoc($result))
  632. {
  633. ++$topic_count;
  634. $status_text = array();
  635. $item_status = ($topic_count % 2 == 0) ? 'roweven' : 'rowodd';
  636. $icon_type = 'icon';
  637. if ($cur_topic['moved_to'] == null)
  638. {
  639. $last_post = '<a href="viewtopic.php?pid='.$cur_topic['last_post_id'].'#p'.$cur_topic['last_post_id'].'">'.format_time($cur_topic['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['last_poster']).'</span>';
  640. $ghost_topic = false;
  641. }
  642. else
  643. {
  644. $last_post = '- - -';
  645. $ghost_topic = true;
  646. }
  647. if ($pun_config['o_censoring'] == '1')
  648. $cur_topic['subject'] = censor_words($cur_topic['subject']);
  649. if ($cur_topic['sticky'] == '1')
  650. {
  651. $item_status .= ' isticky';
  652. $status_text[] = '<span class="stickytext">'.$lang_forum['Sticky'].'</span>';
  653. }
  654. if ($cur_topic['moved_to'] != 0)
  655. {
  656. $subject = '<a href="viewtopic.php?id='.$cur_topic['moved_to'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
  657. $status_text[] = '<span class="movedtext">'.$lang_forum['Moved'].'</span>';
  658. $item_status .= ' imoved';
  659. }
  660. else if ($cur_topic['closed'] == '0')
  661. $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>';
  662. else
  663. {
  664. $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>';
  665. $status_text[] = '<span class="closedtext">'.$lang_forum['Closed'].'</span>';
  666. $item_status .= ' iclosed';
  667. }
  668. if (!$ghost_topic && $cur_topic['last_post'] > $pun_user['last_visit'] && (!isset($tracked_topics['topics'][$cur_topic['id']]) || $tracked_topics['topics'][$cur_topic['id']] < $cur_topic['last_post']) && (!isset($tracked_topics['forums'][$fid]) || $tracked_topics['forums'][$fid] < $cur_topic['last_post']))
  669. {
  670. $item_status .= ' inew';
  671. $icon_type = 'icon icon-new';
  672. $subject = '<strong>'.$subject.'</strong>';
  673. $subject_new_posts = '<span class="newtext">[ <a href="viewtopic.php?id='.$cur_topic['id'].'&amp;action=new" title="'.$lang_common['New posts info'].'">'.$lang_common['New posts'].'</a> ]</span>';
  674. }
  675. else
  676. $subject_new_posts = null;
  677. // Insert the status text before the subject
  678. $subject = implode(' ', $status_text).' '.$subject;
  679. $num_pages_topic = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
  680. if ($num_pages_topic > 1)
  681. $subject_multipage = '<span class="pagestext">[ '.paginate($num_pages_topic, -1, 'viewtopic.php?id='.$cur_topic['id']).' ]</span>';
  682. else
  683. $subject_multipage = null;
  684. // Should we show the "New posts" and/or the multipage links?
  685. if (!empty($subject_new_posts) || !empty($subject_multipage))
  686. {
  687. $subject .= !empty($subject_new_posts) ? ' '.$subject_new_posts : '';
  688. $subject .= !empty($subject_multipage) ? ' '.$subject_multipage : '';
  689. }
  690. ?>
  691. <tr class="<?php echo $item_status ?>">
  692. <td class="tcl">
  693. <div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo forum_number_format($topic_count + $start_from) ?></div></div>
  694. <div class="tclcon">
  695. <div>
  696. <?php echo $subject."\n" ?>
  697. </div>
  698. </div>
  699. </td>
  700. <td class="tc2"><?php echo (!$ghost_topic) ? forum_number_format($cur_topic['num_replies']) : '-' ?></td>
  701. <?php if ($pun_config['o_topic_views'] == '1'): ?> <td class="tc3"><?php echo (!$ghost_topic) ? forum_number_format($cur_topic['num_views']) : '-' ?></td>
  702. <?php endif; ?> <td class="tcr"><?php echo $last_post ?></td>
  703. <td class="tcmod"><input type="checkbox" name="topics[<?php echo $cur_topic['id'] ?>]" value="1" /></td>
  704. </tr>
  705. <?php
  706. }
  707. }
  708. else
  709. {
  710. $colspan = ($pun_config['o_topic_views'] == '1') ? 5 : 4;
  711. $button_status = ' disabled="disabled"';
  712. echo "\t\t\t\t\t".'<tr><td class="tcl" colspan="'.$colspan.'">'.$lang_forum['Empty forum'].'</td></tr>'."\n";
  713. }
  714. ?>
  715. </tbody>
  716. </table>
  717. </div>
  718. </div>
  719. </div>
  720. <div class="linksb">
  721. <div class="inbox">
  722. <div class="pagepost">
  723. <p class="pagelink conl"><?php echo $paging_links ?></p>
  724. <p class="conr modbuttons"><input type="submit" name="move_topics" value="<?php echo $lang_misc['Move'] ?>"<?php echo $button_status ?> /> <input type="submit" name="delete_topics" value="<?php echo $lang_misc['Delete'] ?>"<?php echo $button_status ?> /> <input type="submit" name="merge_topics" value="<?php echo $lang_misc['Merge'] ?>"<?php echo $button_status ?> /> <input type="submit" name="open" value="<?php echo $lang_misc['Open'] ?>"<?php echo $button_status ?> /> <input type="submit" name="close" value="<?php echo $lang_misc['Close'] ?>"<?php echo $button_status ?> /></p>
  725. </div>
  726. </div>
  727. </div>
  728. </form>
  729. <?php
  730. require PUN_ROOT.'footer.php';