admincp_recyclebinpost.php
12.8 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
<?php
/*
[Discuz!] (C)2001-2007 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: admincp_recyclebinpost.php 28728 2012-03-09 03:15:48Z songlixin $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
require_once libfile('function/post');
require_once libfile('function/discuzcode');
$posttableid = intval($_GET['posttableid']);
cpheader();
if(submitcheck('rbsubmit')) {
$moderate = $_GET['moderate'];
$moderation = array('delete' => array(), 'undelete' => array(), 'ignore' => array());
if(is_array($moderate)) {
foreach($moderate as $pid => $action) {
$moderation[$action][] = intval($pid);
}
}
$postsdel = $postsundel = 0;
if($moderation['delete']) {
$postsdel = recyclebinpostdelete($moderation['delete'], $posttableid);
}
if($moderation['undelete']) {
$postsundel = recyclebinpostundelete($moderation['undelete'], $posttableid);
}
if($operation == 'search') {
$cpmsg = cplang('recyclebinpost_succeed', array('postsdel' => $postsdel, 'postsundel' => $postsundel));
?>
<script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('rbsearchform').searchsubmit.click();</script>
<?php
} else {
cpmsg('recyclebinpost_succeed', 'action=recyclebinpost&operation='.$operation, 'succeed', array('postsdel' => $postsdel, 'postsundel' => $postsundel));
}
}
$lpp = empty($_GET['lpp']) ? 20 : $_GET['lpp'];
$start = ($page - 1) * $lpp;
$start_limit = ($page - 1) * $lpp;
$multi = '';
if(!$operation) {
shownav('topic', 'nav_recyclebinpost');
showsubmenu('nav_recyclebinpost', array(
array('recyclebinpost_list', 'recyclebinpost', 1),
array('search', 'recyclebinpost&operation=search', 0),
array('clean', 'recyclebinpost&operation=clean', 0)
));
showtagheader('div', 'postlist', 1);
showformheader('recyclebinpost', '', 'rbform');
showhiddenfields(array('posttableid' => $posttableid));
showtableheader('recyclebinpost');
$postlistcount = C::t('forum_post')->count_by_invisible($posttableid, '-5');
if($postlistcount && recyclebinpostshowpostlist(null, null, null, null, null, $start_limit, $lpp)) {
$multi = multi($postlistcount, $lpp, $page, ADMINSCRIPT."?action=recyclebinpost");
}
showsubmit('rbsubmit', 'submit', '', '<a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'delete\')">'.cplang('recyclebin_all_delete').'</a> <a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'undelete\')">'.cplang('recyclebin_all_undelete').'</a> <a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'ignore\')">'.cplang('recyclebin_all_ignore').'</a> ', $multi);
showtablefooter();
showformfooter();
echo '<iframe name="rbframe" style="display:none"></iframe>';
showtagfooter('div');
} elseif($operation == 'search') {
$inforum = $_GET['inforum'];
$authors = $_GET['authors'];
$keywords = $_GET['keywords'];
$pstarttime = $_GET['pstarttime'];
$pendtime = $_GET['pendtime'];
$appService = Cloud::loadClass('Service_App');
$secStatus = $appService->getCloudAppStatus('security');
if($secStatus){
$security = $_GET['security'];
}
$searchsubmit = $_GET['searchsubmit'];
require_once libfile('function/forumlist');
$forumselect = '<select name="inforum"><option value=""> > '.$lang['allthread'].'</option>'.
'<option value=""> </option>'.forumselect(FALSE, 0, 0, TRUE).'</select>';
if($inforum) {
$forumselect = preg_replace("/(\<option value=\"$inforum\")(\>)/", "\\1 selected=\"selected\" \\2", $forumselect);
}
shownav('topic', 'nav_recyclebinpost');
showsubmenu('nav_recyclebinpost', array(
array('recyclebinpost_list', 'recyclebinpost', 0),
array('search', 'recyclebinpost&operation=search', 1),
array('clean', 'recyclebinpost&operation=clean', 0)
));
echo <<<EOT
<script type="text/javascript" src="static/js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('rbsearchform').page.value=number;
$('rbsearchform').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'postsearch', !$searchsubmit);
showformheader('recyclebinpost&operation=search', '', 'rbsearchform');
showhiddenfields(array('page' => $page));
showtableheader('recyclebinpost_search');
showsetting('recyclebinpost_search_forum', '', '', $forumselect);
showsetting('recyclebinpost_search_author', 'authors', $authors, 'text');
showsetting('recyclebinpost_search_keyword', 'keywords', $keywords, 'text');
showsetting('recyclebin_search_post_time', array('pstarttime', 'pendtime'), array($pstarttime, $pendtime), 'daterange');
showsetting('postsplit', '', '', getposttableselect());
if($secStatus){
showsetting('recyclebin_search_security_thread', 'security', $security, 'radio');
}
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
if(submitcheck('searchsubmit')) {
$security = $secStatus && $security;
if($security){
$postlistcount = C::t('#security#security_evilpost')->count_by_search($posttableid, null, $keywords, -5, $inforum, null, ($authors ? explode(',', str_replace(' ', '', $authors)) : null), strtotime($pstarttime), strtotime($pendtime));
}else{
$postlistcount = C::t('forum_post')->count_by_search($posttableid, null, $keywords, -5, $inforum, null, ($authors ? explode(',', str_replace(' ', '', $authors)) : null), strtotime($pstarttime), strtotime($pendtime));
}
showtagheader('div', 'postlist', $searchsubmit);
showformheader('recyclebinpost&operation=search&frame=no', 'target="rbframe"', 'rbform');
showtableheader(cplang('recyclebinpost_result').' '.$postlistcount.' <a href="#" onclick="$(\'postlist\').style.display=\'none\';$(\'postsearch\').style.display=\'\';" class="act lightlink normal">'.cplang('research').'</a>', 'fixpadding');
if($postlistcount && recyclebinpostshowpostlist($inforum, $authors, $pstarttime, $pendtime, $keywords, $start_limit, $lpp)) {
$multi = multi($postlistcount, $lpp, $page, ADMINSCRIPT."?action=recyclebinpost");
$multi = preg_replace("/href=\"".ADMINSCRIPT."\?action=recyclebinpost&page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
$multi = str_replace("window.location='".ADMINSCRIPT."?action=recyclebinpost&page='+this.value", "page(this.value)", $multi);
}
showsubmit('rbsubmit', 'submit', '', '<a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'delete\')">'.cplang('recyclebin_all_delete').'</a> <a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'undelete\')">'.cplang('recyclebin_all_undelete').'</a> <a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'ignore\')">'.cplang('recyclebin_all_ignore').'</a> ', $multi);
showtablefooter();
showformfooter();
echo '<iframe name="rbframe" style="display:none"></iframe>';
showtagfooter('div');
}
} elseif($operation == 'clean') {
if(!submitcheck('cleanrbsubmit', 1)) {
shownav('topic', 'nav_recyclebinpost');
showsubmenu('nav_recyclebinpost', array(
array('recyclebinpost_list', 'recyclebinpost', 0),
array('search', 'recyclebinpost&operation=search', 0),
array('clean', 'recyclebinpost&operation=clean', 1)
));
showformheader('recyclebinpost&operation=clean');
showtableheader('recyclebinpost_clean');
showsetting('recyclebinpost_clean_days', 'days', '30', 'text');
showsubmit('cleanrbsubmit');
showtablefooter();
showformfooter();
} else {
$deletetids = array();
$pernum = 200;
$postsdel = intval($_GET['postsdel']);
$days = intval($_GET['days']);
$timestamp = TIMESTAMP - max(0, $days * 86400);
$postlist = array();
loadcache('posttableids');
$posttables = !empty($_G['cache']['posttableids']) ? $_G['cache']['posttableids'] : array(0);
foreach($posttables as $ptid) {
foreach(C::t('forum_post')->fetch_all_pid_by_invisible_dateline($ptid, -5, $timestamp, 0, $pernum) as $post) {
$postlist[$ptid][] = $post['pid'];
}
}
$postsundel = 0;
if($postlist) {
foreach($postlist as $ptid => $deletepids) {
$postsdel += recyclebinpostdelete($deletepids, $ptid);
}
$startlimit += $pernum;
cpmsg('recyclebinpost_clean_next', 'action=recyclebinpost&operation=clean&cleanrbsubmit=1&days='.$days.'&postsdel='.$postsdel, 'succeed', array('postsdel' => $postsdel));
} else {
cpmsg('recyclebinpost_succeed', 'action=recyclebinpost&operation=clean', 'succeed', array('postsdel' => $postsdel, 'postsundel' => $postsundel));
}
}
}
function recyclebinpostshowpostlist($fid, $authors, $starttime, $endtime, $keywords, $start_limit, $lpp) {
global $_G, $lang, $posttableid, $security;
$tids = $fids = array();
if($security){
$postlist = C::t('#security#security_evilpost')->fetch_all_by_search($posttableid, null, $keywords, -5, $fid, null, ($authors ? explode(',', str_replace(' ', '', $authors)): null), strtotime($starttime), strtotime($endtime), null, null, $start_limit, $lpp);
}else{
$postlist = C::t('forum_post')->fetch_all_by_search($posttableid, null, $keywords, -5, $fid, null, ($authors ? explode(',', str_replace(' ', '', $authors)): null), strtotime($starttime), strtotime($endtime), null, null, $start_limit, $lpp);
}
if(empty($postlist)) return false;
foreach($postlist as $key => $post) {
$tids[$post['tid']] = $post['tid'];
$fids[$post['fid']] = $post['fid'];
}
foreach(C::t('forum_thread')->fetch_all_by_tid($tids) as $thread) {
$thread['tsubject'] = $thread['subject'];
$threadlist[$thread['tid']] = $thread;
}
$query = C::t('forum_forum')->fetch_all_by_fid($fids);
foreach($query as $val) {
$forum = array('fid' => $val['fid'],
'forumname' => $val['name'],
'allowsmilies' => $val['allowsmilies'],
'allowhtml' => $val['allowhtml'],
'allowbbcode' => $val['allowbbcode'],
'allowimgcode' => $val['allowimgcode']
);
$forumlist[$forum['fid']] = $forum;
}
foreach($postlist as $key => $post) {
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $forumlist[$post['fid']]['allowsmilies'], $forumlist[$post['fid']]['allowbbcode'], $forumlist[$post['fid']]['allowimgcode'], $forumlist[$post['fid']]['allowhtml']);
$post['dateline'] = dgmdate($post['dateline']);
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 > 100) {this.resized=true; this.width=100;}\">"
: "<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'])."\t").$attach['url'];
}
}
showtablerow("id=\"mod_$post[pid]_row1\"", array('rowspan="3" class="rowform threadopt" style="width:80px;"', 'class="threadtitle"'), array(
"<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"moderate[$post[pid]]\" id=\"mod_$post[pid]_1\" value=\"delete\" checked=\"checked\" /><label for=\"mod_$post[pid]_1\">$lang[delete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[$post[pid]]\" id=\"mod_$post[pid]_2\" value=\"undelete\" /><label for=\"mod_$post[pid]_2\">$lang[undelete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[$post[pid]]\" id=\"mod_$post[pid]_3\" value=\"ignore\" /><label for=\"mod_$post[pid]_3\">$lang[ignore]</label></li></ul>",
"<h3><a href=\"forum.php?mod=forumdisplay&fid=$post[fid]\" target=\"_blank\">".$forumlist[$post['fid']]['forumname']."</a> » <a href=\"forum.php?mod=viewthread&tid=$post[tid]\" target=\"_blank\">".$threadlist[$post['tid']]['tsubject']."</a>".($post['subject'] ? ' » '.$post['subject'] : '')."</h3><p><span class=\"bold\">$lang[author]:</span> <a href=\"home.php?mod=space&uid=$post[authorid]\" target=\"_blank\">$post[author]</a> <span class=\"bold\">$lang[time]:</span> $post[dateline] IP: $post[useip]</p>"
));
showtablerow("id=\"mod_$post[pid]_row2\"", 'colspan="2" style="padding: 10px; line-height: 180%;"', '<div style="overflow: auto; overflow-x: hidden; max-height:120px; height:auto !important; height:120px; word-break: break-all;">'.$post['message'].'</div>');
showtablerow("id=\"mod_$post[pid]_row3\"", 'class="threadopt threadtitle" colspan="2"', "$lang[isanonymous]: ".($post['anonymous'] ? $lang['yes'] : $lang['no'])." $lang[ishtmlon]: ".($post['htmlon'] ? $lang['yes'] : $lang['no']));
}
return true;
}
?>