topicadmin_warn.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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_warn.php 30872 2012-06-27 10:11:44Z liulanbo $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(!$_G['group']['allowwarnpost']) {
  12. showmessage('no_privilege_warnpost');
  13. }
  14. $topiclist = $_GET['topiclist'];
  15. if(!($warnpids = dimplode($topiclist))) {
  16. showmessage('admin_warn_invalid');
  17. } elseif(!$_G['group']['allowbanpost'] || !$_G['tid']) {
  18. showmessage('admin_nopermission', NULL);
  19. }
  20. $posts = $authors = array();
  21. $authorwarnings = $warningauthor = $warnstatus = '';
  22. $postlist = C::t('forum_post')->fetch_all('tid:'.$_G['tid'], $topiclist);
  23. foreach($postlist as $post) {
  24. $uids[] = $post['authorid'];
  25. }
  26. $memberlist = C::t('common_member')->fetch_all($uids);
  27. foreach($postlist as $post) {
  28. if($post['tid'] != $_G['tid']) {
  29. continue;
  30. }
  31. $post['adminid'] = $memberlist[$post['authorid']]['adminid'];
  32. if($_G['adminid'] == 1 && $post['adminid'] != 1 ||
  33. $_G['adminid'] == 2 && !in_array($post['adminid'], array(1, 2)) ||
  34. $_G['adminid'] == 3 && in_array($post['adminid'], array(0, -1))) {
  35. $warnstatus = ($post['status'] & 2) || $warnstatus;
  36. $authors[$post['authorid']] = 1;
  37. $posts[] = $post;
  38. }
  39. }
  40. unset($memberlist, $postlist, $uids);
  41. if(!$posts) {
  42. showmessage('admin_warn_nopermission');
  43. }
  44. $authorcount = count(array_keys($authors));
  45. $modpostsnum = count($posts);
  46. if($modpostsnum == 1 || $authorcount == 1) {
  47. $authorwarnings = C::t('forum_warning')->count_by_authorid_dateline($posts[0][authorid]);
  48. $warningauthor = $posts[0]['author'];
  49. }
  50. if(!submitcheck('modsubmit')) {
  51. $warnpid = $checkunwarn = $checkwarn = '';
  52. foreach($topiclist as $id) {
  53. $warnpid .= '<input type="hidden" name="topiclist[]" value="'.$id.'" />';
  54. }
  55. $warnstatus ? $checkunwarn = 'checked="checked"' : $checkwarn = 'checked="checked"';
  56. include template('forum/topicadmin_action');
  57. } else {
  58. $warned = intval($_GET['warned']);
  59. $modaction = $warned ? 'WRN' : 'UWN';
  60. $reason = checkreasonpm();
  61. include_once libfile('function/member');
  62. $pids = $comma = '';
  63. foreach($posts as $k => $post) {
  64. if($warned && !($post['status'] & 2)) {
  65. C::t('forum_post')->increase_status_by_pid('tid:'.$_G['tid'], $post['pid'], 2, '|', true);
  66. $reason = cutstr(dhtmlspecialchars($_GET['reason']), 40);
  67. C::t('forum_warning')->insert(array(
  68. 'pid' => $post['pid'],
  69. 'operatorid' => $_G['uid'],
  70. 'operator' => $_G['username'],
  71. 'authorid' => $post['authorid'],
  72. 'author' => $post['author'],
  73. 'dateline' => $_G['timestamp'],
  74. 'reason' => $reason,
  75. ));
  76. $authorwarnings = C::t('forum_warning')->count_by_authorid_dateline($post['authorid'], $_G['timestamp'] - $_G['setting']['warningexpiration'] * 86400);
  77. if($authorwarnings >= $_G['setting']['warninglimit']) {
  78. $member = getuserbyuid($post[authorid]);
  79. $memberfieldforum = C::t('common_member_field_forum')->fetch($post[authorid]);
  80. $groupterms = dunserialize($memberfieldforum['groupterms']);
  81. unset($memberfieldforum);
  82. if($member && $member['groupid'] != 4) {
  83. $banexpiry = TIMESTAMP + $_G['setting']['warningexpiration'] * 86400;
  84. $groupterms['main'] = array('time' => $banexpiry, 'adminid' => $member['adminid'], 'groupid' => $member['groupid']);
  85. $groupterms['ext'][4] = $banexpiry;
  86. C::t('common_member')->update($post['authorid'], array('groupid' => 4, 'adminid' => -1, 'groupexpiry' => groupexpiry($groupterms)));
  87. C::t('common_member_field_forum')->update($post['authorid'], array('groupterms' => serialize($groupterms)));
  88. }
  89. }
  90. $pids .= $comma.$post['pid'];
  91. $comma = ',';
  92. crime('recordaction', $post['authorid'], 'crime_warnpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $_G['tid'], 'pid' => $post['pid'])));
  93. } elseif(!$warned && ($post['status'] & 2)) {
  94. C::t('forum_post')->increase_status_by_pid('tid:'.$_G['tid'], $post['pid'], 2, '^', true);
  95. C::t('forum_warning')->delete_by_pid($post['pid']);
  96. $pids .= $comma.$post['pid'];
  97. $comma = ',';
  98. }
  99. }
  100. $resultarray = array(
  101. 'redirect' => "forum.php?mod=viewthread&tid=$_G[tid]&page=$page",
  102. 'reasonpm' => ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_warn_post', 'notictype' => 'post') : array()),
  103. 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason,
  104. 'warningexpiration' => $_G['setting']['warningexpiration'], 'warninglimit' => $_G['setting']['warninglimit'], 'warningexpiration' => $_G['setting']['warningexpiration'],
  105. 'authorwarnings' => $authorwarnings),
  106. 'modtids' => 0,
  107. 'modlog' => $thread
  108. );
  109. }
  110. ?>