moderate_thread.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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: moderate_thread.php 32501 2013-01-29 09:51:00Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. if(!submitcheck('modsubmit') && !$_GET['fast']) {
  12. require_once libfile('function/discuzcode');
  13. $select[$_GET['tpp']] = $_GET['tpp'] ? "selected='selected'" : '';
  14. $tpp_options = "<option value='20' $select[20]>20</option><option value='50' $select[50]>50</option><option value='100' $select[100]>100</option>";
  15. $tpp = !empty($_GET['tpp']) ? $_GET['tpp'] : '20';
  16. $start_limit = ($page - 1) * $tpp;
  17. $dateline = $_GET['dateline'] ? $_GET['dateline'] : '604800';
  18. $dateline_options = '';
  19. foreach(array('all', '604800', '2592000', '7776000') as $v) {
  20. $selected = '';
  21. if($dateline == $v) {
  22. $selected = "selected='selected'";
  23. }
  24. $dateline_options .= "<option value=\"$v\" $selected>".cplang("dateline_$v");
  25. }
  26. shownav('topic', $lang['moderate_threads']);
  27. showsubmenu('nav_moderate_threads', $submenu);
  28. showformheader("moderate&operation=threads");
  29. showtableheader('search');
  30. showtablerow('', array('width="60"', 'width="160"', 'width="60"'),
  31. array(
  32. cplang('username'), "<input size=\"15\" name=\"username\" type=\"text\" value=\"$_GET[username]\" />",
  33. cplang('moderate_title_keyword'), "<input size=\"15\" name=\"title\" type=\"text\" value=\"$_GET[title]\" />",
  34. )
  35. );
  36. showtablerow('', array('width="60"', 'width="160"', 'width="60"'),
  37. array(
  38. "$lang[perpage]",
  39. "<select name=\"tpp\">$tpp_options</select><label><input name=\"showcensor\" type=\"checkbox\" class=\"checkbox\" value=\"yes\" ".($showcensor ? ' checked="checked"' : '')."/> $lang[moderate_showcensor]</label>",
  40. "$lang[moderate_bound]",
  41. "<select name=\"filter\">$filteroptions</select>
  42. <select name=\"modfid\">$forumoptions</select>
  43. <select name=\"dateline\">$dateline_options</select>
  44. <input class=\"btn\" type=\"submit\" value=\"$lang[search]\" />"
  45. )
  46. );
  47. showtablefooter();
  48. showtableheader();
  49. $title = '';
  50. if(!empty($_GET['title'])) {
  51. $title = str_replace(array('_', '%'), array('\_', '\%'), $_GET['title']);
  52. }
  53. if(!empty($dateline) && $dateline != 'all') {
  54. $srcdate = TIMESTAMP - $dateline;
  55. }
  56. $fids = $modfid && $modfid != -1 ? $modfid : 0;
  57. $isgroup = $modfid == -1 ? 1 : -1;
  58. $modcount = 0;
  59. $moderates = C::t('common_moderate')->fetch_all_by_idtype('tid', $moderatestatus, $srcdate);
  60. if(!empty($moderates)) {
  61. $modcount = C::t('forum_thread')->count_by_tid_fid(array_keys($moderates), $fids, $isgroup, $_GET['username'], $title);
  62. }
  63. if($modcount != count($moderates) && !$srcdate && !$fids && !$_GET['username'] && !$title) {
  64. moderateswipe('tid', array_keys($moderates));
  65. }
  66. $start_limit = ($page - 1) * $tpp;
  67. if($modcount) {
  68. $threadlist = C::t('forum_thread')->fetch_all_by_tid_fid(array_keys($moderates), $fids, $isgroup, $_GET['username'], $title, $start_limit, $tpp);
  69. $tids = C::t('forum_thread')->get_posttableid();
  70. if($tids) {
  71. foreach($tids as $posttableid => $tid) {
  72. foreach(C::t('forum_post')->fetch_all_by_tid($posttableid, $tid, true, '', 0, 0, 1) as $post) {
  73. $threadlist[$post['tid']] = array_merge($threadlist[$post['tid']], $post);
  74. }
  75. }
  76. }
  77. $multipage = multi($modcount, $tpp, $page, ADMINSCRIPT."?action=moderate&operation=threads&filter=$filter&modfid=$modfid&dateline={$_GET['dateline']}&username={$_GET['username']}&title={$_GET['title']}&tpp=$tpp&showcensor=$showcensor");
  78. }
  79. echo '<p class="margintop marginbot"><a href="javascript:;" onclick="expandall();">'.cplang('moderate_all_expand').'</a> &nbsp;<a href="javascript:;" onclick="foldall();">'.cplang('moderate_all_fold').'</a><p>';
  80. loadcache('forums');
  81. require_once libfile('function/misc');
  82. foreach($threadlist as $thread) {
  83. $threadsortinfo = '';
  84. $thread['useip'] = $thread['useip'] . '-' . convertip($thread['useip']);
  85. if($thread['authorid'] && $thread['author']) {
  86. $thread['author'] = "<a href=\"?action=members&operation=search&uid=$thread[authorid]&submit=yes\" target=\"_blank\">$thread[author]</a>";
  87. } elseif($thread['authorid'] && !$thread['author']) {
  88. $thread['author'] = "<a href=\"?action=members&operation=search&uid=$thread[authorid]&submit=yes\" target=\"_blank\">$lang[anonymous]</a>";
  89. } else {
  90. $thread['author'] = $lang['guest'];
  91. }
  92. $thread['dateline'] = dgmdate($thread['dateline']);
  93. $thread['message'] = discuzcode($thread['message'], $thread['smileyoff'], $thread['bbcodeoff']);
  94. $censor = & discuz_censor::instance();
  95. $censor->highlight = '#FF0000';
  96. if($showcensor) {
  97. $censor->check($thread['subject']);
  98. $censor->check($thread['message']);
  99. }
  100. $thread['modthreadkey'] = modauthkey($thread['tid']);
  101. $censor_words = $censor->words_found;
  102. if(count($censor_words) > 3) {
  103. $censor_words = array_slice($censor_words, 0, 3);
  104. }
  105. $thread['censorwords'] = implode(', ', $censor_words);
  106. if($thread['attachment']) {
  107. require_once libfile('function/attachment');
  108. foreach(C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$thread['tid'], 'tid', $thread['tid']) as $attach) {
  109. $_G['setting']['attachurl'] = $attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl'];
  110. $attach['url'] = $attach['isimage']
  111. ? " $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;}\">"
  112. : "<a href=\"".$_G['setting']['attachurl']."forum/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
  113. $thread['message'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($attach['filename'])).$attach['url'];
  114. }
  115. }
  116. if($thread['sortid']) {
  117. require_once libfile('function/threadsort');
  118. $threadsortshow = threadsortshow($thread['sortid'], $thread['tid']);
  119. foreach($threadsortshow['optionlist'] as $option) {
  120. $threadsortinfo .= $option['title'].' '.$option['value']."<br />";
  121. }
  122. }
  123. if(count($censor_words)) {
  124. $thread_censor_text = "<span style=\"color: red;\">($thread[censorwords])</span>";
  125. } else {
  126. $thread_censor_text = '';
  127. }
  128. $forumname = $_G['cache']['forums'][$thread['fid']]['name'];
  129. showtagheader('tbody', '', true, 'hover');
  130. showtablerow("id=\"mod_$thread[tid]_row1\"", array("id=\"mod_$thread[tid]_row1_op\" rowspan=\"3\" class=\"rowform threadopt\" style=\"width:80px;\"", '', 'width="120"', 'width="120"', 'width="55"'), array(
  131. "<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"moderate[$thread[tid]]\" id=\"mod_$thread[tid]_1\" value=\"validate\" onclick=\"mod_setbg($thread[tid], 'validate');\"><label for=\"mod_$thread[tid]_1\">$lang[validate]</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[$thread[tid]]\" id=\"mod_$thread[tid]_2\" value=\"delete\" onclick=\"mod_setbg($thread[tid], 'delete');\"><label for=\"mod_$thread[tid]_2\">$lang[delete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[$thread[tid]]\" id=\"mod_$thread[tid]_3\" value=\"ignore\" onclick=\"mod_setbg($thread[tid], 'ignore');\"><label for=\"mod_$thread[tid]_3\">$lang[ignore]</label></li></ul>",
  132. "<h3><a href=\"javascript:;\" onclick=\"display_toggle('$thread[tid]');\">$thread[subject]</a> $thread_censor_text</h3><p>$thread[useip]</p>",
  133. "<a target=\"_blank\" href=\"forum.php?mod=forumdisplay&fid=$thread[fid]\">$forumname</a>",
  134. "<p>$thread[author]</p> <p>$thread[dateline]</p>",
  135. "<a target=\"_blank\" href=\"forum.php?mod=viewthread&tid=$thread[tid]&modthreadkey=$thread[modthreadkey]\">$lang[view]</a>&nbsp;<a href=\"forum.php?mod=post&action=edit&fid=$thread[fid]&tid=$thread[tid]&pid=$thread[pid]&modthreadkey=$thread[modthreadkey]\" target=\"_blank\">$lang[edit]</a>",
  136. ));
  137. showtablerow("id=\"mod_$thread[tid]_row2\"", 'colspan="4" 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'].'<br /><br />'.$threadsortinfo.'</div>');
  138. showtablerow("id=\"mod_$thread[tid]_row3\"", 'class="threadopt threadtitle" colspan="4"', "<a href=\"?action=moderate&operation=threads&fast=1&fid=$thread[fid]&tid=$thread[tid]&moderate[$thread[tid]]=validate&page=$page&frame=no\" target=\"fasthandle\">$lang[validate]</a> | <a href=\"?action=moderate&operation=threads&fast=1&fid=$thread[fid]&tid=$thread[tid]&moderate[$thread[tid]]=delete&page=$page&frame=no\" target=\"fasthandle\">$lang[delete]</a> | <a href=\"?action=moderate&operation=threads&fast=1&fid=$thread[fid]&tid=$thread[tid]&moderate[$thread[tid]]=ignore&page=$page&frame=no\" target=\"fasthandle\">$lang[ignore]</a> | <a href=\"forum.php?mod=post&action=edit&fid=$thread[fid]&tid=$thread[tid]&pid=$thread[pid]&page=1&modthreadkey=$thread[modthreadkey]\" target=\"_blank\">".$lang['moderate_edit_thread']."</a> &nbsp;&nbsp;|&nbsp;&nbsp; ".$lang['moderate_reasonpm']."&nbsp; <input type=\"text\" class=\"txt\" name=\"pm_$thread[tid]\" id=\"pm_$thread[tid]\" style=\"margin: 0px;\"> &nbsp; <select style=\"margin: 0px;\" onchange=\"$('pm_$thread[tid]').value=this.value\">$modreasonoptions</select>");
  139. showtagfooter('tbody');
  140. }
  141. showsubmit('modsubmit', 'submit', '', '<a href="#all" onclick="mod_setbg_all(\'validate\')">'.cplang('moderate_all_validate').'</a> &nbsp;<a href="#all" onclick="mod_setbg_all(\'delete\')">'.cplang('moderate_all_delete').'</a> &nbsp;<a href="#all" onclick="mod_setbg_all(\'ignore\')">'.cplang('moderate_all_ignore').'</a> &nbsp;<a href="#all" onclick="mod_cancel_all();">'.cplang('moderate_all_cancel').'</a> &nbsp;<label><input class="checkbox" type="checkbox" name="apply_all" id="chk_apply_all" value="1" disabled="disabled" />'.cplang('moderate_apply_all').'</label>', $multipage, false);
  142. showtablefooter();
  143. showformfooter();
  144. } else {
  145. $validates = $ignores = $recycles = $deletes = 0;
  146. $validatedthreads = $pmlist = array();
  147. $moderation = array('validate' => array(), 'delete' => array(), 'ignore' => array());
  148. if(is_array($moderate)) {
  149. foreach($moderate as $tid => $act) {
  150. $moderation[$act][] = intval($tid);
  151. }
  152. }
  153. if($_GET['apply_all']) {
  154. $apply_all_action = $_GET['apply_all'];
  155. $author = $dateline = $isgroup = $displayorder = null;
  156. if($filter == 'ignore') {
  157. $displayorder = -3;
  158. } else {
  159. $displayorder = -2;
  160. }
  161. if($modfid == -1) {
  162. $isgroup = 1;
  163. }
  164. if(!empty($_GET['dateline']) && $_GET['dateline'] != 'all') {
  165. $dateline = $_GET['dateline'];
  166. }
  167. foreach(C::t('forum_thread')->fetch_all_moderate($modfid, $displayorder, $isgroup, $dateline, $_GET['username'], $_GET['title']) as $thread) {
  168. switch($apply_all_action) {
  169. case 'validate':
  170. $moderation['validate'][] = $thread['tid'];
  171. break;
  172. case 'delete':
  173. $moderation['delete'][] = $thread['tid'];
  174. break;
  175. case 'ignore':
  176. $moderation['ignore'][] = $thread['tid'];
  177. break;
  178. }
  179. }
  180. }
  181. if($moderation['ignore']) {
  182. $ignores = C::t('forum_thread')->update_displayorder_by_tid_displayorder($moderation['ignore'], -2, -3);
  183. updatemoderate('tid', $moderation['ignore'], 1);
  184. }
  185. if($moderation['delete']) {
  186. $deletetids = array();
  187. $recyclebintids = array();
  188. $log_handler = Cloud::loadClass('Cloud_Service_SearchHelper');
  189. foreach(C::t('forum_thread')->fetch_all_by_tid_displayorder($moderation['delete'], $displayorder, '>=', $fidadd[fids]) as $thread) {
  190. $log_handler->myThreadLog('delete', array('tid' => $thread['tid']));
  191. if($recyclebins[$thread['fid']]) {
  192. $recyclebintids[] = $thread['tid'];
  193. } else {
  194. $deletetids[] = $thread['tid'];
  195. }
  196. $pm = 'pm_'.$thread['tid'];
  197. if($thread['authorid'] && $thread['authorid'] != $_G['uid']) {
  198. $pmlist[] = array(
  199. 'action' => $_GET[$pm] ? 'modthreads_delete_reason' : 'modthreads_delete',
  200. 'notevar' => array('threadsubject' => $thread['subject'], 'reason' => $_GET[$pm]),
  201. 'authorid' => $thread['authorid'],
  202. );
  203. }
  204. }
  205. require_once libfile('function/delete');
  206. if($recyclebintids) {
  207. $recycles = deletethread($recyclebintids, false, false, true);
  208. updatemodworks('MOD', $recycles);
  209. updatemodlog(implode(',', $recyclebintids), 'DEL');
  210. }
  211. $deletes = deletethread($deletetids);
  212. updatemoderate('tid', $moderation['delete'], 2);
  213. }
  214. if($moderation['validate']) {
  215. require_once libfile('function/forum');
  216. $forums = array();
  217. $tids = $authoridarray = $moderatedthread = array();
  218. $log_handler = Cloud::loadClass('Cloud_Service_SearchHelper');
  219. foreach(C::t('forum_thread')->fetch_all_by_tid_fid($moderation['validate'], $fidadd['fids']) as $thread) {
  220. if($thread['displayorder'] != -2 && $thread['displayorder']!= -3) {
  221. continue;
  222. }
  223. $poststatus = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
  224. $poststatus = $poststatus['status'];
  225. $tids[] = $thread['tid'];
  226. $log_handler->myThreadLog('validate', array('tid' => $thread['tid']));
  227. if(getstatus($poststatus, 3) == 0) {
  228. updatepostcredits('+', $thread['authorid'], 'post', $thread['fid']);
  229. $attachcount = C::t('forum_attachment_n')->count_by_id('tid:'.$thread['tid'], 'tid', $thread['tid']);
  230. updatecreditbyaction('postattach', $thread['authorid'], array(), '', $attachcount, 1, $thread['fid']);
  231. }
  232. $forums[] = $thread['fid'];
  233. $validatedthreads[] = $thread;
  234. $pm = 'pm_'.$thread['tid'];
  235. if($thread['authorid'] && $thread['authorid'] != $_G['uid']) {
  236. $pmlist[] = array(
  237. 'action' => 'modthreads_validate',
  238. 'notevar' => array('tid' => $thread['tid'], 'threadsubject' => $thread['subject'], 'reason' => dhtmlspecialchars($_GET[''.$pm]), 'from_id' => 0, 'from_idtype' => 'modthreads'),
  239. 'authorid' => $thread['authorid'],
  240. );
  241. }
  242. }
  243. if($tids) {
  244. $tidstr = dimplode($tids);
  245. C::t('forum_post')->update_by_tid(0, $tids, array('status' => 4), false, false, null, -2, 0);
  246. loadcache('posttableids');
  247. $posttableids = $_G['cache']['posttableids'] ? $_G['cache']['posttableids'] : array('0');
  248. foreach($posttableids as $id) {
  249. C::t('forum_post')->update_by_tid($id, $tids, array('invisible' => '0'), false, false, 1);
  250. }
  251. $validates = C::t('forum_thread')->update($tids, array('displayorder' => 0, 'moderated' => 1));
  252. foreach(array_unique($forums) as $fid) {
  253. updateforumcount($fid);
  254. }
  255. updatemodworks('MOD', $validates);
  256. updatemodlog($tidstr, 'MOD');
  257. updatemoderate('tid', $tids, 2);
  258. }
  259. }
  260. if($pmlist) {
  261. foreach($pmlist as $pm) {
  262. notification_add($pm['authorid'], 'system', $pm['action'], $pm['notevar'], 1);
  263. }
  264. }
  265. if($_GET['fast']) {
  266. echo callback_js($_GET['tid']);
  267. exit;
  268. } else {
  269. cpmsg('moderate_threads_succeed', "action=moderate&operation=threads&page=$page&filter=$filter&modfid=$modfid&username={$_GET['username']}&title={$_GET['title']}&tpp={$_GET['tpp']}&showcensor=$showcensor&dateline={$_GET['dateline']}", 'succeed', array('validates' => $validates, 'ignores' => $ignores, 'recycles' => $recycles, 'deletes' => $deletes));
  270. }
  271. }
  272. ?>