PageRenderTime 56ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/other/punbb-modified-forum/moderate.php

https://bitbucket.org/Balancer/projects-balancer
PHP | 749 lines | 509 code | 161 blank | 79 comment | 116 complexity | e83d619dfa29e738e3178d9641b679c6 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /***********************************************************************
  3. Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org)
  4. This file is part of PunBB.
  5. PunBB is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published
  7. by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. PunBB is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  16. MA 02111-1307 USA
  17. ************************************************************************/
  18. define('PUN_ROOT', dirname(__FILE__).'/');
  19. require PUN_ROOT.'include/common.php';
  20. require PUN_ROOT.'include/attach/attach_incl.php'; //Attachment Mod row, loads variables, functions and lang file
  21. if(bors_stop_bots('__nobots_testing', 'moderate'))
  22. return;
  23. foreach(explode(' ', 'topics move_to_forum move_topics_to') as $key)
  24. {
  25. if(isset($_GET[$key]) && !isset($_POST[$key]))
  26. {
  27. $_POST[$key] = $_GET[$key];
  28. unset($_GET[$key]);
  29. }
  30. }
  31. // This particular function doesn't require forum-based moderator access. It can be used
  32. // by all moderators and admins.
  33. if (isset($_GET['get_host']))
  34. {
  35. if ($pun_user['g_id'] > PUN_MOD && $pun_user['g_id'] != 5 && $pun_user['g_id'] != 21)
  36. message($lang_common['No permission']);
  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. $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());
  46. if (!$db->num_rows($result))
  47. message($lang_common['Bad request']);
  48. $ip = $db->result($result);
  49. }
  50. message('The IP address is: '.$ip.'<br />The host name is: '.@gethostbyaddr($ip)."<br /><br /><a href=\"{$pun_config['root_uri']}/admin_users.php?show_users=$ip\">Show more users for this IP</a>");
  51. }
  52. // All other functions require moderator/admin access
  53. $fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
  54. if ($fid < 1)
  55. message($lang_common['Bad request']);
  56. $result = $db->query('SELECT moderators FROM '.$db->prefix.'forums WHERE id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
  57. $moderators = $db->result($result);
  58. $mods_array = ($moderators != '') ? unserialize($moderators) : array();
  59. //if ($pun_user['g_id'] != 5 && $pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_id'] != PUN_MOD || !array_key_exists($pun_user['username'], $mods_array)))
  60. if ($pun_user['g_id'] != 5 && $pun_user['g_id'] != 21 && $pun_user['g_id'] != PUN_ADMIN && $pun_user['g_id'] != PUN_MOD)
  61. message($lang_common['No permission']);
  62. // Load the misc.php language file
  63. require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php';
  64. // All other topic moderation features require a topic id in GET
  65. if (isset($_GET['tid']))
  66. {
  67. $tid = intval($_GET['tid']);
  68. if ($tid < 1)
  69. message($lang_common['Bad request']);
  70. if ($pun_user['g_id'] > PUN_MOD && $pun_user['g_id'] != 5 && $pun_user['g_id'] != 21)
  71. message($lang_common['No permission']);
  72. // Fetch some info about the topic
  73. $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());
  74. if (!$db->num_rows($result))
  75. message($lang_common['Bad request']);
  76. $cur_topic = $db->fetch_assoc($result);
  77. // Delete one or more posts
  78. if (isset($_POST['delete_posts']) || isset($_POST['delete_posts_comply']))
  79. {
  80. $posts = $_POST['posts'];
  81. if (empty($posts))
  82. message($lang_misc['No posts selected']);
  83. if (isset($_POST['delete_posts_comply']))
  84. {
  85. confirm_referrer('moderate.php');
  86. if (preg_match('/[^0-9,]/', $posts))
  87. message($lang_common['Bad request']);
  88. //Attachment Mod Block Start
  89. foreach(explode(',',$posts) as $value)
  90. attach_delete_post($value);
  91. //Attachment Mod Block End
  92. // Delete the posts
  93. $db->query('DELETE FROM '.$db->prefix.'posts WHERE id IN('.$posts.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error());
  94. $db->query('DELETE FROM '.$db->prefix.'messages WHERE id IN('.$posts.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error());
  95. require PUN_ROOT.'include/search_idx.php';
  96. strip_search_index($posts);
  97. // Get last_post, last_post_id, and last_poster for the topic after deletion
  98. $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());
  99. $last_post = $db->fetch_assoc($result);
  100. // How many posts did we just delete?
  101. $num_posts_deleted = substr_count($posts, ',') + 1;
  102. // Update the topic
  103. $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());
  104. update_forum($fid);
  105. redirect('viewtopic.php?id='.$tid, $lang_misc['Delete posts redirect']);
  106. }
  107. $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate'];
  108. require PUN_ROOT.'header.php';
  109. ?>
  110. <div class="blockform">
  111. <h2><span><?php echo $lang_misc['Delete posts'] ?></span></h2>
  112. <div class="box">
  113. <form method="post" action="moderate.php?fid=<?php echo $fid ?>&amp;tid=<?php echo $tid /*"*/ ?>">
  114. <div class="inform">
  115. <fieldset>
  116. <legend><?php echo $lang_misc['Confirm delete legend'] ?></legend>
  117. <div class="infldset">
  118. <input type="hidden" name="posts" value="<?php echo implode(',', array_keys($posts)) /*"*/ ?>" />
  119. <p><?php echo $lang_misc['Delete posts comply'] ?></p>
  120. </div>
  121. </fieldset>
  122. </div>
  123. <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>
  124. </form>
  125. </div>
  126. </div>
  127. <?php
  128. require PUN_ROOT.'footer.php';
  129. }
  130. // Show the delete multiple posts view
  131. // Load the viewtopic.php language file
  132. require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
  133. // Used to disable the Move and Delete buttons if there are no replies to this topic
  134. $button_status = ($cur_topic['num_replies'] == 0) ? ' disabled' : '';
  135. // Determine the post offset (based on $_GET['p'])
  136. $num_pages = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
  137. $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
  138. $start_from = $pun_user['disp_posts'] * ($p - 1);
  139. // Generate paging links
  140. $paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'moderate.php?fid='.$fid.'&amp;tid='.$tid);
  141. if ($pun_config['o_censoring'] == '1')
  142. $cur_topic['subject'] = censor_words($cur_topic['subject']);
  143. $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$cur_topic['subject'];
  144. require PUN_ROOT.'header.php';
  145. ?>
  146. <div class="linkst">
  147. <div class="inbox">
  148. <p class="pagelink conl"><?php echo $paging_links ?></p>
  149. <ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li>&nbsp;&raquo;&nbsp;<a href="viewforum.php?id=<?php echo $fid /*"*/ ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li><li>&nbsp;&raquo;&nbsp;<?php echo pun_htmlspecialchars($cur_topic['subject']) ?></li></ul>
  150. <div class="clearer"></div>
  151. </div>
  152. </div>
  153. <form method="post" action="moderate.php?fid=<?php echo $fid ?>&amp;tid=<?php echo $tid /*"*/ ?>">
  154. <?php
  155. require PUN_ROOT.'include/parser.php';
  156. $bg_switch = true; // Used for switching background color in posts
  157. $post_count = 0; // Keep track of post numbers
  158. // Retrieve the posts (and their respective poster)
  159. $result = $db->query('SELECT u.title, u.num_posts, g.g_id, g.g_user_title, p.id, p.poster, p.poster_id, 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());
  160. while ($cur_post = $db->fetch_assoc($result))
  161. {
  162. $cur_post['message'] = $cms_db->get("SELECT message FROM messages WHERE id = ".intval($cur_post['id']));
  163. $post_count++;
  164. // If the poster is a registered user.
  165. if ($cur_post['poster_id'] > 0)
  166. {
  167. $poster = '<a href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>';
  168. // get_title() requires that an element 'username' be present in the array
  169. $cur_post['username'] = $cur_post['poster'];
  170. $user_title = get_title($cur_post);
  171. if ($pun_config['o_censoring'] == '1')
  172. $user_title = censor_words($user_title);
  173. }
  174. // If the poster is a guest (or a user that has been deleted)
  175. else
  176. {
  177. $poster = pun_htmlspecialchars($cur_post['poster']);
  178. $user_title = $lang_topic['Guest'];
  179. }
  180. // Switch the background color for every message.
  181. $bg_switch = ($bg_switch) ? $bg_switch = false : $bg_switch = true;
  182. $vtbg = ($bg_switch) ? ' roweven' : ' rowodd';
  183. $cur_post['message'] = $cms_db->get("SELECT message FROM messages WHERE id = ".intval($cur_post['id']));
  184. // Perform the main parsing of the message (BBCode, smilies, censor words etc)
  185. $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
  186. ?>
  187. <div class="blockpost<?php echo $vtbg /*"*/ ?>">
  188. <a name="<?php echo $cur_post['id'] ?>"></a>
  189. <h2><span><span class="conr">#<?php echo ($start_from + $post_count) ?>&nbsp;</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>
  190. <div class="box">
  191. <div class="inbox">
  192. <div class="postleft">
  193. <dl>
  194. <dt><strong><?php echo $poster ?></strong></dt>
  195. <dd><strong><?php echo $user_title ?></strong></dd>
  196. </dl>
  197. </div>
  198. <div class="postright">
  199. <h3 class="nosize"><?php echo $lang_common['Message'] ?></h3>
  200. <div class="postmsg">
  201. <?php echo $cur_post['message']."\n" ?>
  202. <?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"; ?>
  203. </div>
  204. <?php if ($start_from + $post_count > 1) echo '<p class="multidelete"><label><strong>'.$lang_misc['Select'].'</strong>&nbsp;&nbsp;<input type="checkbox" name="posts['.$cur_post['id'].']" value="1" /></label></p>'."\n" ?>
  205. </div>
  206. <div class="clearer"></div>
  207. </div>
  208. </div>
  209. </div>
  210. <?php
  211. }
  212. ?>
  213. <div class="postlinksb">
  214. <div class="inbox">
  215. <p class="pagelink conl"><?php echo $paging_links ?></p>
  216. <p class="conr"><input type="submit" name="delete_posts" value="<?php echo $lang_misc['Delete'] /*"*/ ?>"<?php echo $button_status ?> /></p>
  217. <div class="clearer"></div>
  218. </div>
  219. </div>
  220. </form>
  221. <?php
  222. require PUN_ROOT.'footer.php';
  223. }
  224. // Move one or more topics
  225. if (isset($_REQUEST['move_topics']) || isset($_POST['move_topics_to']))
  226. {
  227. if (isset($_POST['move_topics_to'])) // Это кнопка Submit, так определяем, что не страница открылась, а реальный перенос начался.
  228. {
  229. confirm_referrer('moderate.php');
  230. if (preg_match('/[^0-9,]/', $_POST['topics']))
  231. message($lang_common['Bad request']);
  232. $topics = explode(',', $_POST['topics']);
  233. $move_to_forum = isset($_POST['move_to_forum']) ? intval($_POST['move_to_forum']) : 0;
  234. if (empty($topics) || $move_to_forum < 1)
  235. message($lang_common['Bad request']);
  236. $x_topics = bors_find_all('balancer_board_topic', array('id IN' => $topics));
  237. foreach($x_topics as $xt)
  238. $xt->move_to_forum($move_to_forum);
  239. // 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)
  240. $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());
  241. // Move the topic(s)
  242. $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());
  243. // Should we create redirect topics?
  244. if (isset($_POST['with_redirect']))
  245. {
  246. while (list(, $cur_topic) = @each($topics))
  247. {
  248. // Fetch info for the redirect topic
  249. $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());
  250. $moved_to = $db->fetch_assoc($result);
  251. // Create the redirect topic
  252. $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());
  253. }
  254. }
  255. update_forum($fid); // Update the forum FROM which the topic was moved
  256. update_forum($move_to_forum); // Update the forum TO which the topic was moved
  257. $redirect_msg = (count($topics) > 1) ? $lang_misc['Move topics redirect'] : $lang_misc['Move topic redirect'];
  258. redirect('viewforum.php?id='.$move_to_forum, $redirect_msg);
  259. }
  260. if (isset($_POST['move_topics']))
  261. {
  262. $topics = isset($_POST['topics']) ? $_POST['topics'] : array();
  263. if (empty($topics))
  264. message($lang_misc['No topics selected']);
  265. $topics = implode(',', array_keys($topics));
  266. $action = 'multi';
  267. }
  268. else
  269. {
  270. $topics = intval($_GET['move_topics']);
  271. if ($topics < 1)
  272. message($lang_common['Bad request']);
  273. $action = 'single';
  274. }
  275. $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Moderate';
  276. require PUN_ROOT.'header.php';
  277. ?>
  278. <div class="blockform">
  279. <h2><span><?php echo ($action == 'single') ? $lang_misc['Move topic'] : $lang_misc['Move topics'] ?></span></h2>
  280. <div class="box">
  281. <form method="post" action="moderate.php?fid=<?php echo $fid /*"*/?>">
  282. <div class="inform">
  283. <input type="hidden" name="topics" value="<?php echo $topics ?>" />
  284. <fieldset>
  285. <legend><?php echo $lang_misc['Move legend'] ?></legend>
  286. <div class="infldset">
  287. <label><?php echo $lang_misc['Move to'] ?>
  288. <br /><select name="move_to_forum">
  289. <?php
  290. $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)
  291. or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
  292. $cur_category = 0;
  293. $last_fid = -1;
  294. while ($cur_forum = $db->fetch_assoc($result))
  295. {
  296. if ($cur_forum['cid'] != $cur_category) // A new category since last iteration?
  297. {
  298. if ($cur_category)
  299. echo "\t\t\t\t\t\t\t".'</optgroup>'."\n";
  300. echo "\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($cur_forum['cat_name']).'">'."\n";
  301. $cur_category = $cur_forum['cid'];
  302. }
  303. /*"*/
  304. if ($cur_forum['fid'] != $fid)
  305. echo "<option value=\"{$cur_forum['fid']}\"".($fid == $last_fid ? ' selected="true"' : '').">".pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n";
  306. $last_fid = $cur_forum['fid'];
  307. }
  308. ?>
  309. </optgroup>
  310. </select>
  311. <br /></label>
  312. <div class="rbox">
  313. <label><input type="checkbox" name="with_redirect" value="1" /><?php echo $lang_misc['Leave redirect'] ?><br /></label>
  314. </div>
  315. </div>
  316. </fieldset>
  317. </div>
  318. <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>
  319. </form>
  320. </div>
  321. </div>
  322. <?php
  323. require PUN_ROOT.'footer.php';
  324. }
  325. // Delete one or more topics
  326. if (isset($_REQUEST['delete_topics']) || isset($_POST['delete_topics_comply']))
  327. {
  328. $topics = isset($_POST['topics']) ? $_POST['topics'] : array();
  329. if (empty($topics))
  330. message($lang_misc['No topics selected']);
  331. if (isset($_POST['delete_topics_comply']))
  332. {
  333. confirm_referrer('moderate.php');
  334. if (preg_match('/[^0-9,]/', $topics))
  335. message($lang_common['Bad request']);
  336. require PUN_ROOT.'include/search_idx.php';
  337. //Attachment Mod Block Start
  338. foreach(explode(',',$topics) as $value)
  339. attach_delete_thread($value);
  340. //Attachment Mod Block End
  341. // Delete the topics and any redirect topics
  342. $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());
  343. // Delete any subscriptions
  344. $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE topic_id IN('.$topics.')') or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());
  345. // Create a list of the post ID's in this topic and then strip the search index
  346. $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
  347. $post_ids = '';
  348. while ($row = $db->fetch_row($result))
  349. $post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0];
  350. // We have to check that we actually have a list of post ID's since we could be deleting just a redirect topic
  351. if ($post_ids != '')
  352. strip_search_index($post_ids);
  353. // Delete posts "
  354. $posts = join(",", $cms_db->get_array("SELECT id FROM posts WHERE topic_id IN ($topic_id)"));
  355. $db->query('DELETE FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error());
  356. $db->query('DELETE FROM '.$db->prefix.'messages WHERE id IN('.$posts.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error());
  357. update_forum($fid);
  358. redirect('viewforum.php?id='.$fid, $lang_misc['Delete topics redirect']);
  359. }
  360. $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate'];
  361. require PUN_ROOT.'header.php';
  362. ?>
  363. <div class="blockform">
  364. <h2><?php echo $lang_misc['Delete topics'] ?></h2>
  365. <div class="box">
  366. <form method="post" action="moderate.php?fid=<?php echo $fid;/*"*/ ?>">
  367. <input type="hidden" name="topics" value="<?php echo implode(',', array_keys($topics)) ?>" />
  368. <div class="inform">
  369. <fieldset>
  370. <legend><?php echo $lang_misc['Confirm delete legend'] ?></legend>
  371. <div class="infldset">
  372. <p><?php echo $lang_misc['Delete topics comply'] ?></p>
  373. </div>
  374. </fieldset>
  375. </div>
  376. <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>
  377. </form>
  378. </div>
  379. </div>
  380. <?php
  381. require PUN_ROOT.'footer.php';
  382. }
  383. // Open or close one or more topics
  384. else if (isset($_REQUEST['open']) || isset($_REQUEST['close']))
  385. {
  386. $action = (isset($_REQUEST['open'])) ? 0 : 1;
  387. // There could be an array of topic ID's in $_POST
  388. if (isset($_POST['open']) || isset($_POST['close']))
  389. {
  390. confirm_referrer('moderate.php');
  391. $topics = isset($_POST['topics']) ? @array_map('intval', @array_keys($_POST['topics'])) : array();
  392. if (empty($topics))
  393. message($lang_misc['No topics selected']);
  394. foreach($topics as $topic_id)
  395. {
  396. $topic = class_load('balancer_board_topic', $topic_id);
  397. $topic->set_closed($action, true);
  398. }
  399. // $db->query('UPDATE '.$db->prefix.'topics SET closed='.$action.' WHERE id IN('.implode(',', $topics).')') or error('Unable to close topics', __FILE__, __LINE__, $db->error());
  400. $redirect_msg = ($action) ? $lang_misc['Close topics redirect'] : $lang_misc['Open topics redirect'];
  401. redirect('moderate.php?fid='.$fid, $redirect_msg);
  402. }
  403. // Or just one in $_GET
  404. else
  405. {
  406. confirm_referrer('viewtopic.php');
  407. $topic_id = ($action) ? intval($_GET['close']) : intval($_GET['open']);
  408. if ($topic_id < 1)
  409. message($lang_common['Bad request']);
  410. $topic = class_load('balancer_board_topic', $topic_id);
  411. $topic->set_closed($action, true);
  412. balancer_board_action::add($topic, "Тема ".($action?'закрыта':'открыта'), true);
  413. $redirect_msg = ($action) ? $lang_misc['Close topic redirect'] : $lang_misc['Open topic redirect'];
  414. redirect('viewtopic.php?id='.$topic_id, $redirect_msg);
  415. }
  416. }
  417. // Stick a topic
  418. else if (isset($_GET['stick']))
  419. {
  420. confirm_referrer('viewtopic.php');
  421. $stick = intval($_GET['stick']);
  422. if ($stick < 1)
  423. message($lang_common['Bad request']);
  424. $topic = class_load('balancer_board_topic', $stick);
  425. $topic->set_sticky(1, true);
  426. redirect('viewtopic.php?id='.$stick, $lang_misc['Stick topic redirect']);
  427. }
  428. // Unstick a topic
  429. else if (isset($_GET['unstick']))
  430. {
  431. confirm_referrer('viewtopic.php');
  432. $unstick = intval($_GET['unstick']);
  433. if ($unstick < 1)
  434. message($lang_common['Bad request']);
  435. $topic = class_load('balancer_board_topic', $unstick);
  436. $topic->set_sticky(0, true);
  437. redirect('viewtopic.php?id='.$unstick, $lang_misc['Unstick topic redirect']);
  438. }
  439. // No specific forum moderation action was specified in the query string, so we'll display the moderator forum
  440. // Load the viewforum.php language file
  441. require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';
  442. // Fetch some info about the forum
  443. $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());
  444. if (!$db->num_rows($result))
  445. message($lang_common['Bad request']);
  446. $cur_forum = $db->fetch_assoc($result);
  447. // Is this a redirect forum? In that case, abort!
  448. if ($cur_forum['redirect_url'] != '')
  449. message($lang_common['Bad request']);
  450. $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.pun_htmlspecialchars($cur_forum['forum_name']);
  451. require PUN_ROOT.'header.php';
  452. // Determine the topic offset (based on $_GET['p'])
  453. $num_pages = ceil($cur_forum['num_topics'] / $pun_user['disp_topics']);
  454. $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : $_GET['p'];
  455. $start_from = $pun_user['disp_topics'] * ($p - 1);
  456. // Generate paging links
  457. $paging_links = $lang_common['Pages'].': '.paginate($num_pages, $p, 'moderate.php?fid='.$fid)
  458. ?>
  459. <div class="linkst">
  460. <div class="inbox">
  461. <p class="pagelink conl"><?php echo $paging_links ?></p>
  462. <ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a>&nbsp;</li><li>&raquo;&nbsp;<?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></li></ul>
  463. <div class="clearer"></div>
  464. </div>
  465. </div>
  466. <form method="post" action="moderate.php?fid=<?php echo $fid ?>">
  467. <div id="vf" class="blocktable">
  468. <h2><span><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></span></h2>
  469. <div class="box">
  470. <div class="inbox">
  471. <table cellspacing="0">
  472. <thead>
  473. <tr>
  474. <th class="tcl" scope="col"><?php echo $lang_common['Topic'] ?></th>
  475. <th class="tc2" scope="col"><?php echo $lang_common['Replies'] ?></th>
  476. <th class="tc3" scope="col"><?php echo $lang_forum['Views'] ?></th>
  477. <th class="tcr"><?php echo $lang_common['Last post'] ?></th>
  478. <th class="tcmod" scope="col"><?php echo $lang_misc['Select'] ?></th>
  479. </tr>
  480. </thead>
  481. <tbody>
  482. <?php
  483. // Select topics
  484. $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());
  485. // If there are topics in this forum.
  486. if ($db->num_rows($result))
  487. {
  488. $button_status = '';
  489. while ($cur_topic = $db->fetch_assoc($result))
  490. {
  491. $icon_text = $lang_common['Normal icon'];
  492. $item_status = '';
  493. $icon_type = 'icon';
  494. if ($cur_topic['moved_to'] == null)
  495. {
  496. $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']);
  497. $ghost_topic = false;
  498. }
  499. else
  500. {
  501. $last_post = '&nbsp;';
  502. $ghost_topic = true;
  503. }
  504. if ($pun_config['o_censoring'] == '1')
  505. $cur_topic['subject'] = censor_words($cur_topic['subject']);
  506. if ($cur_topic['moved_to'] != 0)
  507. $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>';
  508. else if ($cur_topic['closed'] == '0')
  509. $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span>'.$lang_common['by'].'&nbsp;'.pun_htmlspecialchars($cur_topic['poster']).'</span>';
  510. else
  511. {
  512. $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>';
  513. $icon_text = $lang_common['Closed icon'];
  514. $item_status = 'iclosed';
  515. }
  516. if ($cur_topic['last_post'] > $pun_user['last_visit'] && !$ghost_topic)
  517. {
  518. $icon_text .= ' '.$lang_common['New icon'];
  519. $item_status .= ' inew';
  520. $icon_type = 'icon inew';
  521. $subject = '<strong>'.$subject.'</strong>';
  522. $subject_new_posts = '<span class="newtext">[&nbsp;<a href="viewtopic.php?id='.$cur_topic['id'].'&amp;action=new" title="'.$lang_common['New posts info'].'">'.$lang_common['New posts'].'</a>&nbsp;]</span>';
  523. }
  524. else
  525. $subject_new_posts = null;
  526. // We won't display "the dot", but we add the spaces anyway
  527. if ($pun_config['o_show_dot'] == '1')
  528. $subject = '&nbsp;&nbsp;'.$subject;
  529. if ($cur_topic['sticky'] == '1')
  530. {
  531. $subject = '<span class="stickytext">'.$lang_forum['Sticky'].': </span>'.$subject;
  532. $item_status .= ' isticky';
  533. $icon_text .= ' '.$lang_forum['Sticky'];
  534. }
  535. $num_pages_topic = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
  536. if ($num_pages_topic > 1)
  537. $subject_multipage = '[ '.paginate($num_pages_topic, -1, 'viewtopic.php?id='.$cur_topic['id']).' ]';
  538. else
  539. $subject_multipage = null;
  540. // Should we show the "New posts" and/or the multipage links?
  541. if (!empty($subject_new_posts) || !empty($subject_multipage))
  542. {
  543. $subject .= '&nbsp; '.(!empty($subject_new_posts) ? $subject_new_posts : '');
  544. $subject .= !empty($subject_multipage) ? ' '.$subject_multipage : '';
  545. }
  546. ?>
  547. <tr<?php if ($item_status != '') echo ' class="'.trim($item_status).'"'; ?>>
  548. <td class="tcl">
  549. <div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo trim($icon_text) ?></div></div>
  550. <div class="tclcon">
  551. <?php echo $subject."\n" ?>
  552. </div>
  553. </td>
  554. <td class="tc2"><?php echo (!$ghost_topic) ? $cur_topic['num_replies'] : '&nbsp;' ?></td>
  555. <td class="tc3"><?php echo (!$ghost_topic) ? $cur_topic['num_views'] : '&nbsp;' ?></td>
  556. <td class="tcr"><?php echo $last_post ?></td>
  557. <td class="tcmod"><input type="checkbox" name="topics[<?php echo $cur_topic['id'] ?>]" value="1" /></td>
  558. </tr>
  559. <?php
  560. }
  561. }
  562. else
  563. {
  564. $button_status = ' disabled';
  565. echo "\t\t\t\t\t".'<tr><td class="tcl" colspan="5">'.$lang_forum['Empty forum'].'</td></tr>'."\n";
  566. }
  567. ?>
  568. </tbody>
  569. </table>
  570. </div>
  571. </div>
  572. </div>
  573. <div class="linksb">
  574. <div class="inbox">
  575. <p class="pagelink conl"><?php echo $paging_links ?></p>
  576. <p class="conr"><input type="submit" name="move_topics" value="<?php echo $lang_misc['Move'] ?>"<?php echo $button_status ?> />&nbsp;&nbsp;<input type="submit" name="delete_topics" value="<?php echo $lang_misc['Delete'] ?>"<?php echo $button_status ?> />&nbsp;&nbsp;<input type="submit" name="open" value="<?php echo $lang_misc['Open'] ?>"<?php echo $button_status ?> />&nbsp;&nbsp;<input type="submit" name="close" value="<?php echo $lang_misc['Close'] ?>"<?php echo $button_status ?> /></p>
  577. <div class="clearer"></div>
  578. </div>
  579. </div>
  580. </form>
  581. <?php
  582. require PUN_ROOT.'footer.php';