admincp_recyclebin.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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: admincp_recyclebin.php 31045 2012-07-12 01:55:00Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. require_once libfile('function/post');
  12. require_once libfile('function/discuzcode');
  13. cpheader();
  14. if(!$operation) {
  15. shownav('topic', 'nav_recyclebin');
  16. if(!submitcheck('delsubmit') && !submitcheck('undelsubmit')) {
  17. showsubmenu('nav_recyclebin', array(
  18. array('recyclebin_list', 'recyclebin', 1),
  19. array('search', 'recyclebin&operation=search', 0),
  20. array('clean', 'recyclebin&operation=clean', 0)
  21. ));
  22. $lpp = empty($_GET['lpp']) ? 20 : $_GET['lpp'];
  23. $start = ($page - 1) * $lpp;
  24. $start_limit = ($page - 1) * $lpp;
  25. $checklpp = array();
  26. $checklpp[$lpp] = 'selected="selected"';
  27. showformheader('recyclebin');
  28. showtableheader($lang['recyclebin_list'].
  29. '&nbsp<select onchange="if(this.options[this.selectedIndex].value != \'\') {window.location=\''.ADMINSCRIPT.'?action=recyclebin&lpp=\'+this.options[this.selectedIndex].value }">
  30. <option value="20" '.$checklpp[20].'> '.$lang[perpage_20].' </option><option value="50" '.$checklpp[50].'>'.$lang[perpage_50].'</option><option value="100" '.$checklpp[100].'>'.$lang[perpage_100].'</option></select>');
  31. showsubtitle(array('', 'thread', 'recyclebin_list_thread', 'recyclebin_list_author', 'recyclebin_list_status', 'recyclebin_list_lastpost', 'recyclebin_list_operation', 'reason'));
  32. $fids = $threadlist = array();
  33. $threads = C::t('forum_thread')->fetch_all_by_tid_fid_displayorder(0, 0, -1, 'dateline', $start_limit, $lpp, '=');
  34. foreach($threads as $tid => $value) {
  35. $fids[$value['fid']] = $value['fid'];
  36. }
  37. if($fids) {
  38. $forums = C::t('forum_forum')->fetch_all_name_by_fid($fids);
  39. foreach($threads as $tid => $thread) {
  40. $thread['forumname'] = $forums[$thread['fid']]['name'];
  41. $thread['modthreadkey'] = modauthkey($thread['tid']);
  42. $threadlist[$thread['tid']] = $thread;
  43. }
  44. }
  45. if($threadlist) {
  46. $tids = array_keys($threadlist);
  47. foreach(C::t('forum_threadmod')->fetch_all_by_tid($tids) as $row) {
  48. if(empty($threadlist[$row['tid']]['moduid'])) {
  49. $threadlist[$row['tid']]['moduid'] = $row['uid'];
  50. $threadlist[$row['tid']]['modusername'] = $row['username'];
  51. $threadlist[$row['tid']]['moddateline'] = $row['dateline'];
  52. $threadlist[$row['tid']]['modaction'] = $row['action'];
  53. $threadlist[$row['tid']]['reason'] = $row['reason'];
  54. }
  55. }
  56. foreach($threadlist as $tid => $thread) {
  57. showtablerow('', array('class="td25"', '', '', 'class="td28"', 'class="td28"'), array(
  58. "<input type=\"checkbox\" class=\"checkbox\" name=\"threadlist[]\" value=\"$thread[tid]\">",
  59. '<a href="forum.php?mod=viewthread&tid='.$thread['tid'].'&modthreadkey='.$thread['modthreadkey'].'" target="_blank">'.$thread['subject'].'</a>',
  60. '<a href="forum.php?mod=forumdisplay&fid='.$thread['fid'].'" target="_blank">'.$thread['forumname'].'</a>',
  61. '<a href="home.php?mod=space&uid='.$thread['authorid'].'" target="_blank">'.$thread['author'].'</a><br /><em style="font-size:9px;color:#999999;">'.dgmdate($thread['dateline'], 'd').'</em>',
  62. $thread['replies'].' / '.$thread['views'],
  63. $thread['lastposter'].'<br /><em style="font-size:9px;color:#999999;">'.dgmdate($thread['lastpost'], 'd').'</em>',
  64. $thread['modusername'] ? $thread['modusername'].'<br /><em style="font-size:9px;color:#999999;">'.dgmdate($thread['moddateline'], 'd').'</em>' : '',
  65. $thread['reason']
  66. ));
  67. }
  68. }
  69. $threadcount = C::t('forum_thread')->count_by_displayorder(-1);
  70. $multipage = multi($threadcount, $lpp, $page, ADMINSCRIPT."?action=recyclebin&lpp=$lpp", 0, 6);
  71. showsubmit('', '', '', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'threadlist\')" /><label for="chkall">'.cplang('select_all').'</label>&nbsp;&nbsp;<input type="submit" class="btn" name="delsubmit" value="'.cplang('recyclebin_delete').'" />&nbsp;<input type="submit" class="btn" name="undelsubmit" value="'.cplang('recyclebin_undelete').'" />', $multipage);
  72. showtablefooter();
  73. showformfooter();
  74. } else {
  75. $threadlist = $_GET['threadlist'];
  76. if(empty($threadlist)) {
  77. cpmsg('recyclebin_none_selected', 'action=recyclebin', 'error');
  78. }
  79. $threadsundel = $threadsdel = 0;
  80. if(submitcheck('undelsubmit')) {
  81. $threadsundel = undeletethreads($threadlist);
  82. } elseif(submitcheck('delsubmit')) {
  83. require_once libfile('function/delete');
  84. $threadsdel = deletethread($threadlist);
  85. }
  86. cpmsg('recyclebin_succeed', 'action=recyclebin', 'succeed', array('threadsdel' => $threadsdel, 'threadsundel' => $threadsundel));
  87. }
  88. } elseif($operation == 'search') {
  89. if(!submitcheck('rbsubmit')) {
  90. $inforum = $_GET['inforum'];
  91. $authors = $_GET['authors'];
  92. $keywords = $_GET['keywords'];
  93. $admins = $_GET['admins'];
  94. $pstarttime = $_GET['pstarttime'];
  95. $pendtime = $_GET['pendtime'];
  96. $mstarttime = $_GET['mstarttime'];
  97. $mendtime = $_GET['mendtime'];
  98. $appService = Cloud::loadClass('Service_App');
  99. $secStatus = $appService->getCloudAppStatus('security');
  100. if($secStatus){
  101. $security = $_GET['security'];
  102. }
  103. $searchsubmit = $_GET['searchsubmit'];
  104. require_once libfile('function/forumlist');
  105. $forumselect = '<select name="inforum"><option value="">&nbsp;&nbsp;> '.$lang['select'].'</option>'.
  106. '<option value="">&nbsp;</option><option value="groupthread">'.$lang['group_thread'].'</option>'.forumselect(FALSE, 0, 0, TRUE).'</select>';
  107. if($inforum) {
  108. $forumselect = preg_replace("/(\<option value=\"$inforum\")(\>)/", "\\1 selected=\"selected\" \\2", $forumselect);
  109. }
  110. shownav('topic', 'nav_recyclebin');
  111. showsubmenu('nav_recyclebin', array(
  112. array('recyclebin_list', 'recyclebin', 0),
  113. array('search', 'recyclebin&operation=search', 1),
  114. array('clean', 'recyclebin&operation=clean', 0)
  115. ));
  116. echo <<<EOT
  117. <script type="text/javascript" src="static/js/calendar.js"></script>
  118. <script type="text/JavaScript">
  119. function page(number) {
  120. $('rbsearchform').page.value=number;
  121. $('rbsearchform').searchsubmit.click();
  122. }
  123. </script>
  124. EOT;
  125. showtagheader('div', 'threadsearch', !$searchsubmit);
  126. showformheader('recyclebin&operation=search', '', 'rbsearchform');
  127. showhiddenfields(array('page' => $page));
  128. showtableheader('recyclebin_search');
  129. showsetting('recyclebin_search_forum', '', '', $forumselect);
  130. showsetting('recyclebin_search_author', 'authors', $authors, 'text');
  131. showsetting('recyclebin_search_keyword', 'keywords', $keywords, 'text');
  132. showsetting('recyclebin_search_admin', 'admins', $admins, 'text');
  133. showsetting('recyclebin_search_post_time', array('pstarttime', 'pendtime'), array($pstarttime, $pendtime), 'daterange');
  134. showsetting('recyclebin_search_mod_time', array('mstarttime', 'mendtime'), array($mstarttime, $mendtime), 'daterange');
  135. if($secStatus){
  136. showsetting('recyclebin_search_security_thread', 'security', $security, 'radio');
  137. }
  138. showsubmit('searchsubmit');
  139. showtablefooter();
  140. showformfooter();
  141. showtagfooter('div');
  142. if(submitcheck('searchsubmit')) {
  143. $sql = '';
  144. $isgroup = $fid = 0;
  145. if($inforum == 'groupthread') {
  146. $isgroup = 1;
  147. } else {
  148. $fid = $inforum ? $inforum : 0;
  149. }
  150. $author = $authors != '' ? explode(' ', $authors) : '';
  151. $admins = $admins != '' ? explode(' ', $admins) : '';
  152. $pstarttime = $pstarttime != '' ? strtotime($pstarttime) : '';
  153. $pendtime = $pendtime != '' ? strtotime($pendtime) : '';
  154. $mstarttime = $mstarttime != '' ? strtotime($mstarttime) : '';
  155. $mendtime = $mendtime != '' ? strtotime($mendtime) : '';
  156. $security = $secStatus && $security;
  157. if($security){
  158. $threadcount = C::t('#security#security_evilpost')->count_by_recyclebine($fid, $isgroup, $author, $admins, $pstarttime, $pendtime, $mstarttime, $mendtime, $keywords);
  159. }else{
  160. $threadcount = C::t('forum_thread')->count_by_recyclebine($fid, $isgroup, $author, $admins, $pstarttime, $pendtime, $mstarttime, $mendtime, $keywords);
  161. }
  162. $pagetmp = $page;
  163. $multi = multi($threadcount, $_G['ppp'], $page, ADMINSCRIPT."?action=recyclebin");
  164. $multi = preg_replace("/href=\"".ADMINSCRIPT."\?action=recyclebin&amp;page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
  165. $multi = str_replace("window.location='".ADMINSCRIPT."?action=recyclebin&amp;page='+this.value", "page(this.value)", $multi);
  166. echo '<script type="text/JavaScript">var replyreload;function attachimg() {}</script>';
  167. showtagheader('div', 'threadlist', $searchsubmit);
  168. showformheader('recyclebin&operation=search&frame=no', 'target="rbframe"', 'rbform');
  169. showtableheader(cplang('recyclebin_result').' '.$threadcount.' <a href="#" onclick="$(\'threadlist\').style.display=\'none\';$(\'threadsearch\').style.display=\'\';" class="act lightlink normal">'.cplang('research').'</a>', 'fixpadding');
  170. if($threadcount) {
  171. if($security){
  172. $searchresult = C::t('#security#security_evilpost')->fetch_all_by_recyclebine($fid, $isgroup, $author, $admins, $pstarttime, $pendtime, $mstarttime, $mendtime, $keywords, ($pagetmp - 1) * $_G['ppp'], $_G['ppp']);
  173. }else{
  174. $searchresult = C::t('forum_thread')->fetch_all_by_recyclebine($fid, $isgroup, $author, $admins, $pstarttime, $pendtime, $mstarttime, $mendtime, $keywords, ($pagetmp - 1) * $_G['ppp'], $_G['ppp']);
  175. }
  176. $issettids = array();
  177. foreach($searchresult as $thread) {
  178. $disabledstr = '';
  179. if(isset($issettids[$thread['tid']])) {
  180. $disabledstr = 'disabled';
  181. } else {
  182. $issettids[$thread['tid']] = $thread['tid'];
  183. }
  184. $post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
  185. $thread = array_merge($thread, $post);
  186. $thread['message'] = discuzcode($thread['message'], $thread['smileyoff'], $thread['bbcodeoff'], sprintf('%00b', $thread['htmlon']), $thread['allowsmilies'], $thread['allowbbcode'], $thread['allowimgcode'], $thread['allowhtml']);
  187. $thread['moddateline'] = dgmdate($thread['moddateline']);
  188. $thread['dateline'] = dgmdate($thread['dateline']);
  189. if($thread['attachment']) {
  190. require_once libfile('function/attachment');
  191. foreach(C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$thread['tid'], 'tid', $thread['tid']) as $attach) {
  192. $_G['setting']['attachurl'] = $attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl'];
  193. $attach['url'] = $attach['isimage']
  194. ? " $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;}\">"
  195. : "<a href=\"".$_G['setting']['attachurl']."forum/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
  196. $thread['message'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($attach['filename'])."\t").$attach['url'];
  197. }
  198. }
  199. showtablerow("id=\"mod_$thread[tid]_row1\"", array('rowspan="3" class="rowform threadopt" style="width:80px;"', 'class="threadtitle"'), array(
  200. "<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"moderate[$thread[tid]]\" id=\"mod_$thread[tid]_1\" value=\"delete\" ".(empty($disabledstr) ? "checked=\"checked\"" : '')." $disabledstr /><label for=\"mod_$thread[tid]_1\">$lang[delete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[$thread[tid]]\" id=\"mod_$thread[tid]_2\" value=\"undelete\" $disabledstr/><label for=\"mod_$thread[tid]_2\">$lang[undelete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[$thread[tid]]\" id=\"mod_$thread[tid]_3\" value=\"ignore\" $disabledstr/><label for=\"mod_$thread[tid]_3\">$lang[ignore]</label></li></ul>",
  201. "<h3><a href=\"forum.php?mod=forumdisplay&fid=$thread[fid]\" target=\"_blank\">$thread[forumname]</a> &raquo; $thread[subject]</h3><p><span class=\"bold\">$lang[author]:</span> <a href=\"home.php?mod=space&uid=$thread[authorid]\" target=\"_blank\">$thread[author]</a> &nbsp;&nbsp; <span class=\"bold\">$lang[time]:</span> $thread[dateline] &nbsp;&nbsp; $lang[threads_replies]: $thread[replies] $lang[threads_views]: $thread[views]</p>"
  202. ));
  203. showtablerow("id=\"mod_$thread[tid]_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;">'.$thread['message'].'</div>');
  204. showtablerow("id=\"mod_$thread[tid]_row3\"", 'class="threadopt threadtitle" colspan="2"', "$lang[operator]: <a href=\"home.php?mod=space&uid=$thread[moduid]\" target=\"_blank\">$thread[modusername]</a> &nbsp;&nbsp; $lang[recyclebin_delete_time]: $thread[moddateline]&nbsp;&nbsp; $lang[reason]: $thread[reason]");
  205. }
  206. }
  207. showsubmit('rbsubmit', 'submit', '', '<a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'delete\')">'.cplang('recyclebin_all_delete').'</a> &nbsp;<a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'undelete\')">'.cplang('recyclebin_all_undelete').'</a> &nbsp;<a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'ignore\')">'.cplang('recyclebin_all_ignore').'</a> &nbsp;', $multi);
  208. showtablefooter();
  209. showformfooter();
  210. echo '<iframe name="rbframe" style="display:none"></iframe>';
  211. showtagfooter('div');
  212. }
  213. } else {
  214. $moderate = $_GET['moderate'];
  215. $moderation = array('delete' => array(), 'undelete' => array(), 'ignore' => array());
  216. if(is_array($moderate)) {
  217. foreach($moderate as $tid => $action) {
  218. $moderation[$action][] = intval($tid);
  219. }
  220. }
  221. require_once libfile('function/delete');
  222. $threadsdel = deletethread($moderation['delete']);
  223. $threadsundel = undeletethreads($moderation['undelete']);
  224. if($threadsdel || $threadsundel) {
  225. $cpmsg = cplang('recyclebin_succeed', array('threadsdel' => $threadsdel, 'threadsundel' => $threadsundel));
  226. } else {
  227. $cpmsg = cplang('recyclebin_nothread');
  228. }
  229. ?>
  230. <script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('rbsearchform').searchsubmit.click();</script>
  231. <?php
  232. }
  233. } elseif($operation == 'clean') {
  234. if(!submitcheck('rbsubmit', 1)) {
  235. shownav('topic', 'nav_recyclebin');
  236. showsubmenu('nav_recyclebin', array(
  237. array('recyclebin_list', 'recyclebin', 0),
  238. array('search', 'recyclebin&operation=search', 0),
  239. array('clean', 'recyclebin&operation=clean', 1)
  240. ));
  241. showformheader('recyclebin&operation=clean');
  242. showtableheader('recyclebin_clean');
  243. showsetting('recyclebin_clean_days', 'days', '30', 'text');
  244. showsubmit('rbsubmit');
  245. showtablefooter();
  246. showformfooter();
  247. } else {
  248. $deletetids = array();
  249. $timestamp = TIMESTAMP;
  250. $pernum = 500;
  251. $threadsdel = intval($_GET['threadsdel']);
  252. $days = intval($_GET['days']);
  253. foreach(C::t('forum_threadmod')->fetch_all_recyclebin_by_dateline($timestamp-($days * 86400), 0, $pernum) as $thread) {
  254. $deletetids[] = $thread['tid'];
  255. }
  256. if($deletetids) {
  257. require_once libfile('function/delete');
  258. $delcount = deletethread($deletetids);
  259. $threadsdel += $delcount;
  260. $startlimit += $pernum;
  261. cpmsg('recyclebin_clean_next', 'action=recyclebin&operation=clean&rbsubmit=1&threadsdel='.$threadsdel.'&days='.$days, 'succeed', array('threadsdel' => $threadsdel));
  262. } else {
  263. cpmsg('recyclebin_succeed', 'action=recyclebin&operation=clean', 'succeed', array('threadsdel' => $threadsdel, 'threadsundel' => 0));
  264. }
  265. }
  266. }
  267. ?>