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