moderate_reply.php
16.2 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: moderate_reply.php 32501 2013-01-29 09:51:00Z chenmengshu $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
loadcache('posttableids');
$posttable = in_array($_GET['posttableid'], $_G['cache']['posttableids']) ? $_GET['posttableid'] : 0;
if(!submitcheck('modsubmit') && !$_GET['fast']) {
require_once libfile('function/discuzcode');
$select[$_GET['ppp']] = $_GET['ppp'] ? "selected='selected'" : '';
$ppp_options = "<option value='20' $select[20]>20</option><option value='50' $select[50]>50</option><option value='100' $select[100]>100</option>";
$ppp = !empty($_GET['ppp']) ? $_GET['ppp'] : '20';
$start_limit = ($page - 1) * $ppp;
$dateline = $_GET['dateline'] ? $_GET['dateline'] : '604800';
$dateline_options = '';
foreach(array('all', '604800', '2592000', '7776000') as $v) {
$selected = '';
if($dateline == $v) {
$selected = "selected='selected'";
}
$dateline_options .= "<option value=\"$v\" $selected>".cplang("dateline_$v");
}
$posttableselect = getposttableselect();
shownav('topic', $lang['moderate_replies']);
showsubmenu('nav_moderate_posts', $submenu);
showformheader("moderate&operation=replies");
showtableheader('search');
showtablerow('', array('width="60"', 'width="160"', 'width="60"', $posttableselect ? 'width="160"' : '', $posttableselect ? 'width="60"' : ''),
array(
cplang('username'), "<input size=\"15\" name=\"username\" type=\"text\" value=\"$_GET[username]\" />",
cplang('moderate_content_keyword'), "<input size=\"15\" name=\"title\" type=\"text\" value=\"$_GET[title]\" />",
$posttableselect ? cplang('postsplit_select') : '',
$posttableselect
)
);
showtablerow('', array('width="60"', 'width="160"', 'width="60"', 'colspan="3"'),
array(
"$lang[perpage]",
"<select name=\"ppp\">$ppp_options</select><label><input name=\"showcensor\" type=\"checkbox\" class=\"checkbox\" value=\"yes\" ".($showcensor ? ' checked="checked"' : '')."/> $lang[moderate_showcensor]</label>",
"$lang[moderate_bound]",
"<select name=\"filter\">$filteroptions</select>
<select name=\"modfid\">$forumoptions</select>
<select name=\"dateline\">$dateline_options</select>
<input class=\"btn\" type=\"submit\" value=\"$lang[search]\" />"
)
);
showtablefooter();
showtableheader();
$fidadd = array();
$sqlwhere = '';
if(!empty($_GET['username'])) {
$sqlwhere .= " AND p.author='{$_GET['username']}'";
}
if(!empty($dateline) && $dateline != 'all') {
$sqlwhere .= " AND p.dateline>'".(TIMESTAMP - $dateline)."'";
}
if(!empty($_GET['title'])) {
$sqlwhere .= " AND t.subject LIKE '%{$_GET['title']}%'";
}
if($modfid > 0) {
$fidadd['fids'] = $modfid;
}
$modcount = C::t('common_moderate')->count_by_search_for_post(getposttable($posttable), $moderatestatus, 0, ($modfid > 0 ? $modfid : 0), $_GET['username'], (($dateline && $dateline != 'all') ? (TIMESTAMP - $dateline) : null), $_GET['title']);
$start_limit = ($page - 1) * $ppp;
$postarr = C::t('common_moderate')->fetch_all_by_search_for_post(getposttable($posttable), $moderatestatus, 0, ($modfid > 0 ? $modfid : 0), $_GET['username'], (($dateline && $dateline != 'all') ? (TIMESTAMP - $dateline) : null), $_GET['title'], $start_limit, $ppp);
if($postarr) {
$_tids = $_fids = array();
foreach($postarr as $_post) {
$_fids[$_post['fid']] = $_post['fid'];
$_tids[$_post['tid']] = $_post['tid'];
}
$_forums = C::t('forum_forum')->fetch_all($_fids);
$_threads = C::t('forum_thread')->fetch_all($_tids);
}
$checklength = C::t('common_moderate')->fetch_all_by_idtype('pid', $moderatestatus, null);
if($modcount != $checklength && !$srcdate && !$modfid && !$_GET['username'] && !$_GET['title'] && !$posttable) {
moderateswipe('pid', array_keys($checklength));
}
$multipage = multi($modcount, $ppp, $page, ADMINSCRIPT."?action=moderate&operation=replies&filter=$filter&modfid=$modfid&dateline={$_GET['dateline']}&username={$_GET['username']}&title={$_GET['title']}&ppp=$ppp&showcensor=$showcensor&posttableid=$posttable");
echo '<p class="margintop marginbot"><a href="javascript:;" onclick="expandall();">'.cplang('moderate_all_expand').'</a> <a href="javascript:;" onclick="foldall();">'.cplang('moderate_all_fold').'</a><p>';
$censor = & discuz_censor::instance();
$censor->highlight = '#FF0000';
require_once libfile('function/misc');
foreach($postarr as &$post) {
$_forum = $_forums[$post['fid']];
$_arr = array(
'forumname' => $_forum['name'],
'allowsmilies' => $_forum['allowsmilies'],
'allowhtml' => $_forum['allowhtml'],
'allowbbcode' => $_forum['allowbbcode'],
'allowimgcode' => $_forum['allowimgcode'],
);
$post = array_merge($post, $_arr);
if(getstatus($post['status'], 5)) {
$post['authorid'] = 0;
$post['author'] = cplang('moderate_t_comment');
}
$post['dateline'] = dgmdate($post['dateline']);
$post['tsubject'] = $_threads[$post['tid']]['subject'];
$post['subject'] = $post['subject'] ? '<b>'.$post['subject'].'</b>' : '';
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $post['allowsmilies'], $post['allowbbcode'], $post['allowimgcode'], $post['allowhtml']);
if($showcensor) {
$censor->check($post['subject']);
$censor->check($post['message']);
}
$post_censor_words = $censor->words_found;
if(count($post_censor_words) > 3) {
$post_censor_words = array_slice($post_censor_words, 0, 3);
}
$post['censorwords'] = implode(', ', $post_censor_words);
$post['modthreadkey'] = modauthkey($post['tid']);
$post['useip'] = $post['useip'] . '-' . convertip($post['useip']);
if($post['attachment']) {
require_once libfile('function/attachment');
foreach(C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$post['tid'], 'pid', $post['pid']) as $attach) {
$_G['setting']['attachurl'] = $attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl'];
$attach['url'] = $attach['isimage']
? " $attach[filename] (".sizecount($attach['filesize']).")<br /><br /><img src=\"".$_G['setting']['attachurl']."forum/$attach[attachment]\" onload=\"if(this.width > 400) {this.resized=true; this.width=400;}\">"
: "<a href=\"".$_G['setting']['attachurl']."forum/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
$post['message'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($attach['filename'])).$attach['url'];
}
}
if(count($post_censor_words)) {
$post_censor_text = "<span style=\"color: red;\">({$post['censorwords']})</span>";
} else {
$post_censor_text = '';
}
showtagheader('tbody', '', true, 'hover');
showtablerow("id=\"mod_$post[pid]_row1\"", array("id=\"mod_$post[pid]_row1_op\" rowspan=\"3\" class=\"rowform threadopt\" style=\"width:80px;\"", '', 'width="120"', 'width="120"', 'width="55"'), array(
"<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"moderate[$post[pid]]\" id=\"mod_$post[pid]_1\" value=\"validate\" onclick=\"mod_setbg($post[pid], 'validate');\"><label for=\"mod_$post[pid]_1\">$lang[validate]</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[$post[pid]]\" id=\"mod_$post[pid]_2\" value=\"delete\" onclick=\"mod_setbg($post[pid], 'delete');\"><label for=\"mod_$post[pid]_2\">$lang[delete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[$post[pid]]\" id=\"mod_$post[pid]_3\" value=\"ignore\" onclick=\"mod_setbg($post[pid], 'ignore');\"><label for=\"mod_$post[pid]_3\">$lang[ignore]</label></li></ul>",
"<h3>$post[tsubject] › <a href=\"javascript:;\" onclick=\"display_toggle('$post[pid]');\">$post[subject]</a> $post_censor_text</h3><p>$post[useip]</p>",
"<a href=\"forum.php?mod=forumdisplay&fid=$post[fid]\">$post[forumname]</a>",
"<p><a target=\"_blank\" href=\"".ADMINSCRIPT."?action=members&operation=search&uid=$post[authorid]&submit=yes\">$post[author]</a></p> <p>$post[dateline]</p>",
"<a target=\"_blank\" href=\"forum.php?mod=redirect&goto=findpost&ptid=$post[tid]&pid=$post[pid]\">$lang[view]</a> <a href=\"forum.php?mod=viewthread&tid=$post[tid]&modthreadkey=$post[modthreadkey]\" target=\"_blank\">$lang[edit]</a>",
));
showtablerow("id=\"mod_$post[pid]_row2\"", 'colspan="4" style="padding: 10px; line-height: 180%;"', '<div style="overflow: auto; overflow-x: hidden; max-height:120px; height:auto !important; height:100px; word-break: break-all;">'.$post['message'].'</div>');
showtablerow("id=\"mod_$post[pid]_row3\"", 'class="threadopt threadtitle" colspan="4"', "<a href=\"?action=moderate&operation=replies&fast=1&fid=$post[fid]&tid=$post[tid]&pid=$post[pid]&moderate[$post[pid]]=validate&page=$page&posttableid=$posttable&frame=no\" target=\"fasthandle\">$lang[validate]</a> | <a href=\"?action=moderate&operation=replies&fast=1&fid=$post[fid]&tid=$post[tid]&pid=$post[pid]&moderate[$post[pid]]=delete&page=$page&posttableid=$posttable&frame=no\" target=\"fasthandle\">$lang[delete]</a> | <a href=\"?action=moderate&operation=replies&fast=1&fid=$post[fid]&tid=$post[tid]&pid=$post[pid]&moderate[$post[pid]]=ignore&page=$page&posttableid=$posttable&frame=no\" target=\"fasthandle\">$lang[ignore]</a> | ".$lang['moderate_reasonpm']." <input type=\"text\" class=\"txt\" name=\"pm_$post[pid]\" id=\"pm_$post[pid]\" style=\"margin: 0px;\"> <select style=\"margin: 0px;\" onchange=\"$('pm_$post[pid]').value=this.value\">$modreasonoptions</select>");
showtagfooter('tbody');
}
showsubmit('modsubmit', 'submit', '', '<a href="#all" onclick="mod_setbg_all(\'validate\')">'.cplang('moderate_all_validate').'</a> <a href="#all" onclick="mod_setbg_all(\'delete\')">'.cplang('moderate_all_delete').'</a> <a href="#all" onclick="mod_setbg_all(\'ignore\')">'.cplang('moderate_all_ignore').'</a> <a href="#all" onclick="mod_cancel_all();">'.cplang('moderate_all_cancel').'</a> <label><input class="checkbox" type="checkbox" name="apply_all" id="chk_apply_all" value="1" disabled="disabled" />'.cplang('moderate_apply_all').'</label>', $multipage, false);
showtablefooter();
showformfooter();
} else {
$moderation = array('validate' => array(), 'delete' => array(), 'ignore' => array());
$pmlist = array();
$validates = $ignores = $deletes = 0;
if(is_array($moderate)) {
foreach($moderate as $pid => $act) {
$moderation[$act][] = intval($pid);
}
}
if($_GET['apply_all']) {
$apply_all_action = $_GET['apply_all'];
$first = '0';
if($filter == 'ignore') {
$invisible = '-3';
} else {
$invisible = '-2';
}
if($modfid > 0) {
$modfid = $modfid;
}
if(!empty($_GET['dateline']) && $_GET['dateline'] != 'all') {
$starttime = $_GET['dateline'];
}
if(!empty($_GET['username'])) {
$author = $_GET['username'];
}
if(!empty($_GET['title'])) {
$title = str_replace(array('_', '%'), array('\_', '\%'), $_GET['title']);
$keywords = $title;
}
foreach(C::t('forum_post')->fetch_all_by_search($posttable, null, $keywords, $invisible, $modfid, null, $author, $starttime, null, null, $first) as $post) {
switch($apply_all_action) {
case 'validate':
$moderation['validate'][] = $post['pid'];
break;
case 'delete':
$moderation['delete'][] = $post['pid'];
break;
case 'ignore':
$moderation['ignore'][] = $post['pid'];
break;
}
}
}
if($ignorepids = dimplode($moderation['ignore'])) {
$ignores = C::t('forum_post')->update($posttable, $moderation['ignore'], array('invisible' => -3), false, false, 0, -2, $fidadd[fids]);
updatemoderate('pid', $moderation['ignore'], 1);
}
if($deletepids = dimplode($moderation['delete'])) {
$pids = $recyclebinpids = array();
foreach(C::t('forum_post')->fetch_all($posttable, $moderation['delete']) as $post) {
if($post['invisible'] != $displayorder || $post['first'] != 0 || ($fidadd['fids'] && $post['fid'] != $fidadd['fids'])) {
continue;
}
if($recyclebins[$post['fid']]) {
$recyclebinpids[] = $post['pid'];
} else {
$pids[] = $post['pid'];
}
$pm = 'pm_'.$post['pid'];
if($post['authorid'] && $post['authorid'] != $_G['uid']) {
$pmlist[] = array(
'action' => 'modreplies_delete',
'notevar' => array('pid' => $post['pid'], 'post' => dhtmlspecialchars(cutstr($post['message'], 30)), 'reason' => dhtmlspecialchars($_GET[''.$pm])),
'authorid' => $post['authorid'],
);
}
}
require_once libfile('function/delete');
if($recyclebinpids) {
deletepost($recyclebinpids, 'pid', false, $posttable, true);
}
if($pids) {
$deletes = deletepost($pids, 'pid', false, $posttable);
}
$deletes += count($recyclebinpids);
updatemodworks('DLP', count($moderation['delete']));
updatemoderate('pid', $moderation['delete'], 2);
}
if($validatepids = dimplode($moderation['validate'])) {
$forums = $threads = $attachments = $pidarray = $authoridarray = array();
$tids = $postlist = array();
foreach(C::t('forum_post')->fetch_all($posttable, $moderation['validate']) as $post) {
if($post['first'] != 0) {
continue;
}
$tids[$post['tid']] = $post['tid'];
$postlist[] = $post;
}
$threadlist = C::t('forum_thread')->fetch_all($tids);
$log_handler = Cloud::loadClass('Cloud_Service_SearchHelper');
foreach($postlist as $post) {
$post['lastpost'] = $threadlist[$post['tid']]['lastpost'];
$pidarray[] = $post['pid'];
$log_handler->myPostLog('validate', array('pid' => $post['pid']));
if(getstatus($post['status'], 3) == 0) {
updatepostcredits('+', $post['authorid'], 'reply', $post['fid']);
$attachcount = C::t('forum_attachment_n')->count_by_id('tid:'.$post['tid'], 'pid', $post['pid']);
updatecreditbyaction('postattach', $post['authorid'], array(), '', $attachcount, 1, $post['fid']);
}
$forums[] = $post['fid'];
$threads[$post['tid']]['replies']++;
if($post['dateline'] > $post['lastpost']) {
$threads[$post['tid']]['lastpost'] = array($post['dateline']);
$threads[$post['tid']]['lastposter'] = array($post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : $post['author']);
}
if($threads[$post['tid']]['attachadd'] || $post['attachment']) {
$threads[$post['tid']]['attachment'] = array(1);
}
$pm = 'pm_'.$post['pid'];
if($post['authorid'] && $post['authorid'] != $_G['uid']) {
$pmlist[] = array(
'action' => 'modreplies_validate',
'notevar' => array('pid' => $post['pid'], 'tid' => $post['tid'], 'post' => dhtmlspecialchars(cutstr($post['message'], 30)), 'reason' => dhtmlspecialchars($_GET[''.$pm]), 'from_id' => 0, 'from_idtype' => 'modreplies'),
'authorid' => $post['authorid'],
);
}
}
unset($postlist, $tids, $threadlist);
foreach($threads as $tid => $thread) {
C::t('forum_thread')->increase($tid, $thread);
}
foreach(array_unique($forums) as $fid) {
updateforumcount($fid);
}
if(!empty($pidarray)) {
C::t('forum_post')->update($posttable, $pidarray, array('status' => 4), false, false, null, -2, null, 0);
$validates = C::t('forum_post')->update($posttable, $pidarray, array('invisible' => 0));
updatemodworks('MOD', $validates);
updatemoderate('pid', $pidarray, 2);
} else {
require_once libfile('function/forum');
updatemodworks('MOD', 1);
}
}
if($pmlist) {
foreach($pmlist as $pm) {
notification_add($pm['authorid'], 'system', $pm['action'], $pm['notevar'], 1);
}
}
if($_GET['fast']) {
echo callback_js($_GET['pid']);
exit;
} else {
cpmsg('moderate_replies_succeed', "action=moderate&operation=replies&page=$page&filter=$filter&modfid=$modfid&posttableid=$posttable&dateline={$_GET['dateline']}&username={$_GET['username']}&title={$_GET['title']}&ppp={$_GET['ppp']}&showcensor=$showcensor", 'succeed', array('validates' => $validates, 'ignores' => $ignores, 'recycles' => $recycles, 'deletes' => $deletes));
}
}
?>