topicadmin_banpost.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: topicadmin_banpost.php 30872 2012-06-27 10:11:44Z liulanbo $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(!$_G['group']['allowbanpost']) {
  12. showmessage('no_privilege_banpost');
  13. }
  14. $topiclist = $_GET['topiclist'];
  15. $modpostsnum = count($topiclist);
  16. if(!($banpids = dimplode($topiclist))) {
  17. showmessage('admin_banpost_invalid');
  18. } elseif(!$_G['group']['allowbanpost'] || !$_G['tid']) {
  19. showmessage('admin_nopermission');
  20. }
  21. $posts = $authors = array();
  22. $banstatus = 0;
  23. foreach(C::t('forum_post')->fetch_all('tid:'.$_G['tid'], $topiclist) as $post) {
  24. if($post['tid'] != $_G['tid']) {
  25. continue;
  26. }
  27. $banstatus = ($post['status'] & 1) || $banstatus;
  28. $authors[$post['authorid']] = 1;
  29. $posts[] = $post;
  30. }
  31. $authorcount = count(array_keys($authors));
  32. if(!submitcheck('modsubmit')) {
  33. $banid = $checkunban = $checkban = '';
  34. foreach($topiclist as $id) {
  35. $banid .= '<input type="hidden" name="topiclist[]" value="'.$id.'" />';
  36. }
  37. $banstatus ? $checkunban = 'checked="checked"' : $checkban = 'checked="checked"';
  38. if($modpostsnum == 1 || $authorcount == 1) {
  39. include_once libfile('function/member');
  40. $crimenum = crime('getcount', $posts[0]['authorid'], 'crime_banpost');
  41. $crimeauthor = $posts[0]['author'];
  42. }
  43. include template('forum/topicadmin_action');
  44. } else {
  45. $banned = intval($_GET['banned']);
  46. $modaction = $banned ? 'BNP' : 'UBN';
  47. $reason = checkreasonpm();
  48. include_once libfile('function/member');
  49. $pids = $comma = '';
  50. foreach($posts as $k => $post) {
  51. if($banned) {
  52. C::t('forum_postcomment')->delete_by_rpid($post['pid']);
  53. C::t('forum_post')->increase_status_by_pid('tid:'.$_G['tid'], $post['pid'], 1, '|', true);
  54. crime('recordaction', $post['authorid'], 'crime_banpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $_G['tid'], 'pid' => $post['pid'])));
  55. } else {
  56. C::t('forum_post')->increase_status_by_pid('tid:'.$_G['tid'], $post['pid'], 1, '^', true);
  57. }
  58. $pids .= $comma.$post['pid'];
  59. $comma = ',';
  60. }
  61. $resultarray = array(
  62. 'redirect' => "forum.php?mod=viewthread&tid=$_G[tid]&page=$page",
  63. 'reasonpm' => ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_ban_post', 'notictype' => 'post') : array()),
  64. 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
  65. 'modtids' => 0,
  66. 'modlog' => $thread
  67. );
  68. }
  69. ?>