topicadmin_delpost.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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_delpost.php 36334 2017-01-03 01:32:35Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(!$_G['group']['allowdelpost']) {
  12. showmessage('no_privilege_delpost');
  13. }
  14. $topiclist = $_GET['topiclist'];
  15. $modpostsnum = count($topiclist);
  16. $authorcount = $crimenum = 0;
  17. $crimeauthor = '';
  18. $pids = $posts = $authors = array();
  19. if(!($deletepids = dimplode($topiclist))) {
  20. showmessage('admin_delpost_invalid');
  21. } elseif(!$_G['group']['allowdelpost'] || !$_G['tid']) {
  22. showmessage('admin_nopermission');
  23. } else {
  24. $posttable = getposttablebytid($_G['tid']);
  25. foreach(C::t('forum_post')->fetch_all('tid:'.$_G['tid'], $topiclist, false) as $post) {
  26. if($post['tid'] != $_G['tid']) {
  27. continue;
  28. }
  29. if($post['first'] == 1) {
  30. dheader("location: $_G[siteurl]forum.php?mod=topicadmin&action=moderate&operation=delete&optgroup=3&fid=$_G[fid]&moderate[]=$thread[tid]&inajax=yes".($_GET['infloat'] ? "&infloat=yes&handlekey={$_GET['handlekey']}" : ''));
  31. } else {
  32. $authors[$post['authorid']] = 1;
  33. $pids[] = $post['pid'];
  34. $posts[] = $post;
  35. }
  36. }
  37. }
  38. if(!submitcheck('modsubmit')) {
  39. $deleteid = '';
  40. foreach($topiclist as $id) {
  41. $deleteid .= '<input type="hidden" name="topiclist[]" value="'.$id.'" />';
  42. }
  43. $authorcount = count(array_keys($authors));
  44. if($modpostsnum == 1 || $authorcount == 1) {
  45. include_once libfile('function/member');
  46. $crimenum = crime('getcount', $posts[0]['authorid'], 'crime_delpost');
  47. $crimeauthor = $posts[0]['author'];
  48. }
  49. include template('forum/topicadmin_action');
  50. } else {
  51. $reason = checkreasonpm();
  52. $uidarray = $puidarray = $auidarray = array();
  53. $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0;
  54. if($pids) {
  55. require_once libfile('function/delete');
  56. if($_G['forum']['recyclebin']) {
  57. deletepost($pids, 'pid', true, false, true);
  58. manage_addnotify('verifyrecyclepost', $modpostsnum);
  59. } else {
  60. $logs = array();
  61. $ratelog = C::t('forum_ratelog')->fetch_all_by_pid($pids);
  62. $rposts = C::t('forum_post')->fetch_all('tid:'.$_G['tid'], $pids, false);
  63. foreach(C::t('forum_ratelog')->fetch_all_by_pid($pids) as $rpid => $author) {
  64. if($author['score'] > 0) {
  65. $rpost = $rposts[$rpid];
  66. updatemembercount($rpost['authorid'], array($author['extcredits'] => -$author['score']));
  67. $author['score'] = $_G['setting']['extcredits'][$id]['title'].' '.-$author['score'].' '.$_G['setting']['extcredits'][$id]['unit'];
  68. $logs[] = dhtmlspecialchars("$_G[timestamp]\t{$_G[member][username]}\t$_G[adminid]\t$rpost[author]\t$author[extcredits]\t$author[score]\t$thread[tid]\t$thread[subject]\t$delpostsubmit");
  69. }
  70. }
  71. if(!empty($logs)) {
  72. writelog('ratelog', $logs);
  73. unset($logs);
  74. }
  75. deletepost($pids, 'pid', true);
  76. }
  77. if($_G['group']['allowbanuser'] && ($_GET['banuser'] || $_GET['userdelpost']) && $_G['deleteauthorids']) {
  78. $members = C::t('common_member')->fetch_all($_G['deleteauthorids']);
  79. $banuins = array();
  80. foreach($members as $member) {
  81. if(($_G['cache']['usergroups'][$member['groupid']]['type'] == 'system' &&
  82. in_array($member['groupid'], array(1, 2, 3, 6, 7, 8))) || $_G['cache']['usergroups'][$member['groupid']]['type'] == 'special') {
  83. continue;
  84. }
  85. $banuins[$member['uid']] = $member['uid'];
  86. }
  87. if($banuins) {
  88. if($_GET['banuser']) {
  89. C::t('common_member')->update($banuins, array('groupid' => 4));
  90. }
  91. if($_GET['userdelpost']) {
  92. deletememberpost($banuins);
  93. }
  94. }
  95. }
  96. if($_GET['crimerecord']) {
  97. include_once libfile('function/member');
  98. foreach($posts as $post) {
  99. crime('recordaction', $post['authorid'], 'crime_delpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $post['tid'], 'pid' => $post['pid'])));
  100. }
  101. }
  102. }
  103. updatethreadcount($_G['tid'], 1);
  104. updateforumcount($_G['fid']);
  105. $_G['forum']['threadcaches'] && deletethreadcaches($thread['tid']);
  106. $modaction = 'DLP';
  107. $resultarray = array(
  108. 'redirect' => "forum.php?mod=viewthread&tid=$_G[tid]&page=$_GET[page]",
  109. 'reasonpm' => ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_delete_post', 'notictype' => 'post') : array()),
  110. 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
  111. 'modtids' => 0,
  112. 'modlog' => $thread
  113. );
  114. }
  115. ?>