admincp_recyclebinpost.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <?php
  2. /*
  3. [Discuz!] (C)2001-2007 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: admincp_recyclebinpost.php 28728 2012-03-09 03:15:48Z songlixin $
  6. */
  7. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  8. exit('Access Denied');
  9. }
  10. require_once libfile('function/post');
  11. require_once libfile('function/discuzcode');
  12. $posttableid = intval($_GET['posttableid']);
  13. cpheader();
  14. if(submitcheck('rbsubmit')) {
  15. $moderate = $_GET['moderate'];
  16. $moderation = array('delete' => array(), 'undelete' => array(), 'ignore' => array());
  17. if(is_array($moderate)) {
  18. foreach($moderate as $pid => $action) {
  19. $moderation[$action][] = intval($pid);
  20. }
  21. }
  22. $postsdel = $postsundel = 0;
  23. if($moderation['delete']) {
  24. $postsdel = recyclebinpostdelete($moderation['delete'], $posttableid);
  25. }
  26. if($moderation['undelete']) {
  27. $postsundel = recyclebinpostundelete($moderation['undelete'], $posttableid);
  28. }
  29. if($operation == 'search') {
  30. $cpmsg = cplang('recyclebinpost_succeed', array('postsdel' => $postsdel, 'postsundel' => $postsundel));
  31. ?>
  32. <script type="text/JavaScript">alert('<?php echo $cpmsg;?>');parent.$('rbsearchform').searchsubmit.click();</script>
  33. <?php
  34. } else {
  35. cpmsg('recyclebinpost_succeed', 'action=recyclebinpost&operation='.$operation, 'succeed', array('postsdel' => $postsdel, 'postsundel' => $postsundel));
  36. }
  37. }
  38. $lpp = empty($_GET['lpp']) ? 20 : $_GET['lpp'];
  39. $start = ($page - 1) * $lpp;
  40. $start_limit = ($page - 1) * $lpp;
  41. $multi = '';
  42. if(!$operation) {
  43. shownav('topic', 'nav_recyclebinpost');
  44. showsubmenu('nav_recyclebinpost', array(
  45. array('recyclebinpost_list', 'recyclebinpost', 1),
  46. array('search', 'recyclebinpost&operation=search', 0),
  47. array('clean', 'recyclebinpost&operation=clean', 0)
  48. ));
  49. showtagheader('div', 'postlist', 1);
  50. showformheader('recyclebinpost', '', 'rbform');
  51. showhiddenfields(array('posttableid' => $posttableid));
  52. showtableheader('recyclebinpost');
  53. $postlistcount = C::t('forum_post')->count_by_invisible($posttableid, '-5');
  54. if($postlistcount && recyclebinpostshowpostlist(null, null, null, null, null, $start_limit, $lpp)) {
  55. $multi = multi($postlistcount, $lpp, $page, ADMINSCRIPT."?action=recyclebinpost");
  56. }
  57. 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);
  58. showtablefooter();
  59. showformfooter();
  60. echo '<iframe name="rbframe" style="display:none"></iframe>';
  61. showtagfooter('div');
  62. } elseif($operation == 'search') {
  63. $inforum = $_GET['inforum'];
  64. $authors = $_GET['authors'];
  65. $keywords = $_GET['keywords'];
  66. $pstarttime = $_GET['pstarttime'];
  67. $pendtime = $_GET['pendtime'];
  68. $appService = Cloud::loadClass('Service_App');
  69. $secStatus = $appService->getCloudAppStatus('security');
  70. if($secStatus){
  71. $security = $_GET['security'];
  72. }
  73. $searchsubmit = $_GET['searchsubmit'];
  74. require_once libfile('function/forumlist');
  75. $forumselect = '<select name="inforum"><option value="">&nbsp;&nbsp;> '.$lang['allthread'].'</option>'.
  76. '<option value="">&nbsp;</option>'.forumselect(FALSE, 0, 0, TRUE).'</select>';
  77. if($inforum) {
  78. $forumselect = preg_replace("/(\<option value=\"$inforum\")(\>)/", "\\1 selected=\"selected\" \\2", $forumselect);
  79. }
  80. shownav('topic', 'nav_recyclebinpost');
  81. showsubmenu('nav_recyclebinpost', array(
  82. array('recyclebinpost_list', 'recyclebinpost', 0),
  83. array('search', 'recyclebinpost&operation=search', 1),
  84. array('clean', 'recyclebinpost&operation=clean', 0)
  85. ));
  86. echo <<<EOT
  87. <script type="text/javascript" src="static/js/calendar.js"></script>
  88. <script type="text/JavaScript">
  89. function page(number) {
  90. $('rbsearchform').page.value=number;
  91. $('rbsearchform').searchsubmit.click();
  92. }
  93. </script>
  94. EOT;
  95. showtagheader('div', 'postsearch', !$searchsubmit);
  96. showformheader('recyclebinpost&operation=search', '', 'rbsearchform');
  97. showhiddenfields(array('page' => $page));
  98. showtableheader('recyclebinpost_search');
  99. showsetting('recyclebinpost_search_forum', '', '', $forumselect);
  100. showsetting('recyclebinpost_search_author', 'authors', $authors, 'text');
  101. showsetting('recyclebinpost_search_keyword', 'keywords', $keywords, 'text');
  102. showsetting('recyclebin_search_post_time', array('pstarttime', 'pendtime'), array($pstarttime, $pendtime), 'daterange');
  103. showsetting('postsplit', '', '', getposttableselect());
  104. if($secStatus){
  105. showsetting('recyclebin_search_security_thread', 'security', $security, 'radio');
  106. }
  107. showsubmit('searchsubmit');
  108. showtablefooter();
  109. showformfooter();
  110. showtagfooter('div');
  111. if(submitcheck('searchsubmit')) {
  112. $security = $secStatus && $security;
  113. if($security){
  114. $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));
  115. }else{
  116. $postlistcount = C::t('forum_post')->count_by_search($posttableid, null, $keywords, -5, $inforum, null, ($authors ? explode(',', str_replace(' ', '', $authors)) : null), strtotime($pstarttime), strtotime($pendtime));
  117. }
  118. showtagheader('div', 'postlist', $searchsubmit);
  119. showformheader('recyclebinpost&operation=search&frame=no', 'target="rbframe"', 'rbform');
  120. showtableheader(cplang('recyclebinpost_result').' '.$postlistcount.' <a href="#" onclick="$(\'postlist\').style.display=\'none\';$(\'postsearch\').style.display=\'\';" class="act lightlink normal">'.cplang('research').'</a>', 'fixpadding');
  121. if($postlistcount && recyclebinpostshowpostlist($inforum, $authors, $pstarttime, $pendtime, $keywords, $start_limit, $lpp)) {
  122. $multi = multi($postlistcount, $lpp, $page, ADMINSCRIPT."?action=recyclebinpost");
  123. $multi = preg_replace("/href=\"".ADMINSCRIPT."\?action=recyclebinpost&amp;page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
  124. $multi = str_replace("window.location='".ADMINSCRIPT."?action=recyclebinpost&amp;page='+this.value", "page(this.value)", $multi);
  125. }
  126. 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);
  127. showtablefooter();
  128. showformfooter();
  129. echo '<iframe name="rbframe" style="display:none"></iframe>';
  130. showtagfooter('div');
  131. }
  132. } elseif($operation == 'clean') {
  133. if(!submitcheck('cleanrbsubmit', 1)) {
  134. shownav('topic', 'nav_recyclebinpost');
  135. showsubmenu('nav_recyclebinpost', array(
  136. array('recyclebinpost_list', 'recyclebinpost', 0),
  137. array('search', 'recyclebinpost&operation=search', 0),
  138. array('clean', 'recyclebinpost&operation=clean', 1)
  139. ));
  140. showformheader('recyclebinpost&operation=clean');
  141. showtableheader('recyclebinpost_clean');
  142. showsetting('recyclebinpost_clean_days', 'days', '30', 'text');
  143. showsubmit('cleanrbsubmit');
  144. showtablefooter();
  145. showformfooter();
  146. } else {
  147. $deletetids = array();
  148. $pernum = 200;
  149. $postsdel = intval($_GET['postsdel']);
  150. $days = intval($_GET['days']);
  151. $timestamp = TIMESTAMP - max(0, $days * 86400);
  152. $postlist = array();
  153. loadcache('posttableids');
  154. $posttables = !empty($_G['cache']['posttableids']) ? $_G['cache']['posttableids'] : array(0);
  155. foreach($posttables as $ptid) {
  156. foreach(C::t('forum_post')->fetch_all_pid_by_invisible_dateline($ptid, -5, $timestamp, 0, $pernum) as $post) {
  157. $postlist[$ptid][] = $post['pid'];
  158. }
  159. }
  160. $postsundel = 0;
  161. if($postlist) {
  162. foreach($postlist as $ptid => $deletepids) {
  163. $postsdel += recyclebinpostdelete($deletepids, $ptid);
  164. }
  165. $startlimit += $pernum;
  166. cpmsg('recyclebinpost_clean_next', 'action=recyclebinpost&operation=clean&cleanrbsubmit=1&days='.$days.'&postsdel='.$postsdel, 'succeed', array('postsdel' => $postsdel));
  167. } else {
  168. cpmsg('recyclebinpost_succeed', 'action=recyclebinpost&operation=clean', 'succeed', array('postsdel' => $postsdel, 'postsundel' => $postsundel));
  169. }
  170. }
  171. }
  172. function recyclebinpostshowpostlist($fid, $authors, $starttime, $endtime, $keywords, $start_limit, $lpp) {
  173. global $_G, $lang, $posttableid, $security;
  174. $tids = $fids = array();
  175. if($security){
  176. $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);
  177. }else{
  178. $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);
  179. }
  180. if(empty($postlist)) return false;
  181. foreach($postlist as $key => $post) {
  182. $tids[$post['tid']] = $post['tid'];
  183. $fids[$post['fid']] = $post['fid'];
  184. }
  185. foreach(C::t('forum_thread')->fetch_all_by_tid($tids) as $thread) {
  186. $thread['tsubject'] = $thread['subject'];
  187. $threadlist[$thread['tid']] = $thread;
  188. }
  189. $query = C::t('forum_forum')->fetch_all_by_fid($fids);
  190. foreach($query as $val) {
  191. $forum = array('fid' => $val['fid'],
  192. 'forumname' => $val['name'],
  193. 'allowsmilies' => $val['allowsmilies'],
  194. 'allowhtml' => $val['allowhtml'],
  195. 'allowbbcode' => $val['allowbbcode'],
  196. 'allowimgcode' => $val['allowimgcode']
  197. );
  198. $forumlist[$forum['fid']] = $forum;
  199. }
  200. foreach($postlist as $key => $post) {
  201. $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']);
  202. $post['dateline'] = dgmdate($post['dateline']);
  203. if($post['attachment']) {
  204. require_once libfile('function/attachment');
  205. foreach(C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$post['tid'], 'pid', $post['pid']) as $attach) {
  206. $_G['setting']['attachurl'] = $attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl'];
  207. $attach['url'] = $attach['isimage']
  208. ? " $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;}\">"
  209. : "<a href=\"".$_G['setting']['attachurl']."forum/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
  210. $post['message'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($attach['filename'])."\t").$attach['url'];
  211. }
  212. }
  213. showtablerow("id=\"mod_$post[pid]_row1\"", array('rowspan="3" class="rowform threadopt" style="width:80px;"', 'class="threadtitle"'), array(
  214. "<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>",
  215. "<h3><a href=\"forum.php?mod=forumdisplay&fid=$post[fid]\" target=\"_blank\">".$forumlist[$post['fid']]['forumname']."</a> &raquo; <a href=\"forum.php?mod=viewthread&tid=$post[tid]\" target=\"_blank\">".$threadlist[$post['tid']]['tsubject']."</a>".($post['subject'] ? ' &raquo; '.$post['subject'] : '')."</h3><p><span class=\"bold\">$lang[author]:</span> <a href=\"home.php?mod=space&uid=$post[authorid]\" target=\"_blank\">$post[author]</a> &nbsp;&nbsp; <span class=\"bold\">$lang[time]:</span> $post[dateline] &nbsp;&nbsp; IP: $post[useip]</p>"
  216. ));
  217. 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>');
  218. showtablerow("id=\"mod_$post[pid]_row3\"", 'class="threadopt threadtitle" colspan="2"', "$lang[isanonymous]: ".($post['anonymous'] ? $lang['yes'] : $lang['no'])." &nbsp;&nbsp; $lang[ishtmlon]: ".($post['htmlon'] ? $lang['yes'] : $lang['no']));
  219. }
  220. return true;
  221. }
  222. ?>