moderate_reply.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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_reply.php 32501 2013-01-29 09:51:00Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. loadcache('posttableids');
  12. $posttable = in_array($_GET['posttableid'], $_G['cache']['posttableids']) ? $_GET['posttableid'] : 0;
  13. if(!submitcheck('modsubmit') && !$_GET['fast']) {
  14. require_once libfile('function/discuzcode');
  15. $select[$_GET['ppp']] = $_GET['ppp'] ? "selected='selected'" : '';
  16. $ppp_options = "<option value='20' $select[20]>20</option><option value='50' $select[50]>50</option><option value='100' $select[100]>100</option>";
  17. $ppp = !empty($_GET['ppp']) ? $_GET['ppp'] : '20';
  18. $start_limit = ($page - 1) * $ppp;
  19. $dateline = $_GET['dateline'] ? $_GET['dateline'] : '604800';
  20. $dateline_options = '';
  21. foreach(array('all', '604800', '2592000', '7776000') as $v) {
  22. $selected = '';
  23. if($dateline == $v) {
  24. $selected = "selected='selected'";
  25. }
  26. $dateline_options .= "<option value=\"$v\" $selected>".cplang("dateline_$v");
  27. }
  28. $posttableselect = getposttableselect();
  29. shownav('topic', $lang['moderate_replies']);
  30. showsubmenu('nav_moderate_posts', $submenu);
  31. showformheader("moderate&operation=replies");
  32. showtableheader('search');
  33. showtablerow('', array('width="60"', 'width="160"', 'width="60"', $posttableselect ? 'width="160"' : '', $posttableselect ? 'width="60"' : ''),
  34. array(
  35. cplang('username'), "<input size=\"15\" name=\"username\" type=\"text\" value=\"$_GET[username]\" />",
  36. cplang('moderate_content_keyword'), "<input size=\"15\" name=\"title\" type=\"text\" value=\"$_GET[title]\" />",
  37. $posttableselect ? cplang('postsplit_select') : '',
  38. $posttableselect
  39. )
  40. );
  41. showtablerow('', array('width="60"', 'width="160"', 'width="60"', 'colspan="3"'),
  42. array(
  43. "$lang[perpage]",
  44. "<select name=\"ppp\">$ppp_options</select><label><input name=\"showcensor\" type=\"checkbox\" class=\"checkbox\" value=\"yes\" ".($showcensor ? ' checked="checked"' : '')."/> $lang[moderate_showcensor]</label>",
  45. "$lang[moderate_bound]",
  46. "<select name=\"filter\">$filteroptions</select>
  47. <select name=\"modfid\">$forumoptions</select>
  48. <select name=\"dateline\">$dateline_options</select>
  49. <input class=\"btn\" type=\"submit\" value=\"$lang[search]\" />"
  50. )
  51. );
  52. showtablefooter();
  53. showtableheader();
  54. $fidadd = array();
  55. $sqlwhere = '';
  56. if(!empty($_GET['username'])) {
  57. $sqlwhere .= " AND p.author='{$_GET['username']}'";
  58. }
  59. if(!empty($dateline) && $dateline != 'all') {
  60. $sqlwhere .= " AND p.dateline>'".(TIMESTAMP - $dateline)."'";
  61. }
  62. if(!empty($_GET['title'])) {
  63. $sqlwhere .= " AND t.subject LIKE '%{$_GET['title']}%'";
  64. }
  65. if($modfid > 0) {
  66. $fidadd['fids'] = $modfid;
  67. }
  68. $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']);
  69. $start_limit = ($page - 1) * $ppp;
  70. $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);
  71. if($postarr) {
  72. $_tids = $_fids = array();
  73. foreach($postarr as $_post) {
  74. $_fids[$_post['fid']] = $_post['fid'];
  75. $_tids[$_post['tid']] = $_post['tid'];
  76. }
  77. $_forums = C::t('forum_forum')->fetch_all($_fids);
  78. $_threads = C::t('forum_thread')->fetch_all($_tids);
  79. }
  80. $checklength = C::t('common_moderate')->fetch_all_by_idtype('pid', $moderatestatus, null);
  81. if($modcount != $checklength && !$srcdate && !$modfid && !$_GET['username'] && !$_GET['title'] && !$posttable) {
  82. moderateswipe('pid', array_keys($checklength));
  83. }
  84. $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");
  85. 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>';
  86. $censor = & discuz_censor::instance();
  87. $censor->highlight = '#FF0000';
  88. require_once libfile('function/misc');
  89. foreach($postarr as &$post) {
  90. $_forum = $_forums[$post['fid']];
  91. $_arr = array(
  92. 'forumname' => $_forum['name'],
  93. 'allowsmilies' => $_forum['allowsmilies'],
  94. 'allowhtml' => $_forum['allowhtml'],
  95. 'allowbbcode' => $_forum['allowbbcode'],
  96. 'allowimgcode' => $_forum['allowimgcode'],
  97. );
  98. $post = array_merge($post, $_arr);
  99. if(getstatus($post['status'], 5)) {
  100. $post['authorid'] = 0;
  101. $post['author'] = cplang('moderate_t_comment');
  102. }
  103. $post['dateline'] = dgmdate($post['dateline']);
  104. $post['tsubject'] = $_threads[$post['tid']]['subject'];
  105. $post['subject'] = $post['subject'] ? '<b>'.$post['subject'].'</b>' : '';
  106. $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $post['allowsmilies'], $post['allowbbcode'], $post['allowimgcode'], $post['allowhtml']);
  107. if($showcensor) {
  108. $censor->check($post['subject']);
  109. $censor->check($post['message']);
  110. }
  111. $post_censor_words = $censor->words_found;
  112. if(count($post_censor_words) > 3) {
  113. $post_censor_words = array_slice($post_censor_words, 0, 3);
  114. }
  115. $post['censorwords'] = implode(', ', $post_censor_words);
  116. $post['modthreadkey'] = modauthkey($post['tid']);
  117. $post['useip'] = $post['useip'] . '-' . convertip($post['useip']);
  118. if($post['attachment']) {
  119. require_once libfile('function/attachment');
  120. foreach(C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$post['tid'], 'pid', $post['pid']) as $attach) {
  121. $_G['setting']['attachurl'] = $attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl'];
  122. $attach['url'] = $attach['isimage']
  123. ? " $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;}\">"
  124. : "<a href=\"".$_G['setting']['attachurl']."forum/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
  125. $post['message'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($attach['filename'])).$attach['url'];
  126. }
  127. }
  128. if(count($post_censor_words)) {
  129. $post_censor_text = "<span style=\"color: red;\">({$post['censorwords']})</span>";
  130. } else {
  131. $post_censor_text = '';
  132. }
  133. showtagheader('tbody', '', true, 'hover');
  134. 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(
  135. "<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>",
  136. "<h3>$post[tsubject] &rsaquo; <a href=\"javascript:;\" onclick=\"display_toggle('$post[pid]');\">$post[subject]</a> $post_censor_text</h3><p>$post[useip]</p>",
  137. "<a href=\"forum.php?mod=forumdisplay&fid=$post[fid]\">$post[forumname]</a>",
  138. "<p><a target=\"_blank\" href=\"".ADMINSCRIPT."?action=members&operation=search&uid=$post[authorid]&submit=yes\">$post[author]</a></p> <p>$post[dateline]</p>",
  139. "<a target=\"_blank\" href=\"forum.php?mod=redirect&goto=findpost&ptid=$post[tid]&pid=$post[pid]\">$lang[view]</a>&nbsp;<a href=\"forum.php?mod=viewthread&tid=$post[tid]&modthreadkey=$post[modthreadkey]\" target=\"_blank\">$lang[edit]</a>",
  140. ));
  141. 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>');
  142. 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>&nbsp;&nbsp;|&nbsp;&nbsp; ".$lang['moderate_reasonpm']."&nbsp; <input type=\"text\" class=\"txt\" name=\"pm_$post[pid]\" id=\"pm_$post[pid]\" style=\"margin: 0px;\"> &nbsp; <select style=\"margin: 0px;\" onchange=\"$('pm_$post[pid]').value=this.value\">$modreasonoptions</select>");
  143. showtagfooter('tbody');
  144. }
  145. 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);
  146. showtablefooter();
  147. showformfooter();
  148. } else {
  149. $moderation = array('validate' => array(), 'delete' => array(), 'ignore' => array());
  150. $pmlist = array();
  151. $validates = $ignores = $deletes = 0;
  152. if(is_array($moderate)) {
  153. foreach($moderate as $pid => $act) {
  154. $moderation[$act][] = intval($pid);
  155. }
  156. }
  157. if($_GET['apply_all']) {
  158. $apply_all_action = $_GET['apply_all'];
  159. $first = '0';
  160. if($filter == 'ignore') {
  161. $invisible = '-3';
  162. } else {
  163. $invisible = '-2';
  164. }
  165. if($modfid > 0) {
  166. $modfid = $modfid;
  167. }
  168. if(!empty($_GET['dateline']) && $_GET['dateline'] != 'all') {
  169. $starttime = $_GET['dateline'];
  170. }
  171. if(!empty($_GET['username'])) {
  172. $author = $_GET['username'];
  173. }
  174. if(!empty($_GET['title'])) {
  175. $title = str_replace(array('_', '%'), array('\_', '\%'), $_GET['title']);
  176. $keywords = $title;
  177. }
  178. foreach(C::t('forum_post')->fetch_all_by_search($posttable, null, $keywords, $invisible, $modfid, null, $author, $starttime, null, null, $first) as $post) {
  179. switch($apply_all_action) {
  180. case 'validate':
  181. $moderation['validate'][] = $post['pid'];
  182. break;
  183. case 'delete':
  184. $moderation['delete'][] = $post['pid'];
  185. break;
  186. case 'ignore':
  187. $moderation['ignore'][] = $post['pid'];
  188. break;
  189. }
  190. }
  191. }
  192. if($ignorepids = dimplode($moderation['ignore'])) {
  193. $ignores = C::t('forum_post')->update($posttable, $moderation['ignore'], array('invisible' => -3), false, false, 0, -2, $fidadd[fids]);
  194. updatemoderate('pid', $moderation['ignore'], 1);
  195. }
  196. if($deletepids = dimplode($moderation['delete'])) {
  197. $pids = $recyclebinpids = array();
  198. foreach(C::t('forum_post')->fetch_all($posttable, $moderation['delete']) as $post) {
  199. if($post['invisible'] != $displayorder || $post['first'] != 0 || ($fidadd['fids'] && $post['fid'] != $fidadd['fids'])) {
  200. continue;
  201. }
  202. if($recyclebins[$post['fid']]) {
  203. $recyclebinpids[] = $post['pid'];
  204. } else {
  205. $pids[] = $post['pid'];
  206. }
  207. $pm = 'pm_'.$post['pid'];
  208. if($post['authorid'] && $post['authorid'] != $_G['uid']) {
  209. $pmlist[] = array(
  210. 'action' => 'modreplies_delete',
  211. 'notevar' => array('pid' => $post['pid'], 'post' => dhtmlspecialchars(cutstr($post['message'], 30)), 'reason' => dhtmlspecialchars($_GET[''.$pm])),
  212. 'authorid' => $post['authorid'],
  213. );
  214. }
  215. }
  216. require_once libfile('function/delete');
  217. if($recyclebinpids) {
  218. deletepost($recyclebinpids, 'pid', false, $posttable, true);
  219. }
  220. if($pids) {
  221. $deletes = deletepost($pids, 'pid', false, $posttable);
  222. }
  223. $deletes += count($recyclebinpids);
  224. updatemodworks('DLP', count($moderation['delete']));
  225. updatemoderate('pid', $moderation['delete'], 2);
  226. }
  227. if($validatepids = dimplode($moderation['validate'])) {
  228. $forums = $threads = $attachments = $pidarray = $authoridarray = array();
  229. $tids = $postlist = array();
  230. foreach(C::t('forum_post')->fetch_all($posttable, $moderation['validate']) as $post) {
  231. if($post['first'] != 0) {
  232. continue;
  233. }
  234. $tids[$post['tid']] = $post['tid'];
  235. $postlist[] = $post;
  236. }
  237. $threadlist = C::t('forum_thread')->fetch_all($tids);
  238. $log_handler = Cloud::loadClass('Cloud_Service_SearchHelper');
  239. foreach($postlist as $post) {
  240. $post['lastpost'] = $threadlist[$post['tid']]['lastpost'];
  241. $pidarray[] = $post['pid'];
  242. $log_handler->myPostLog('validate', array('pid' => $post['pid']));
  243. if(getstatus($post['status'], 3) == 0) {
  244. updatepostcredits('+', $post['authorid'], 'reply', $post['fid']);
  245. $attachcount = C::t('forum_attachment_n')->count_by_id('tid:'.$post['tid'], 'pid', $post['pid']);
  246. updatecreditbyaction('postattach', $post['authorid'], array(), '', $attachcount, 1, $post['fid']);
  247. }
  248. $forums[] = $post['fid'];
  249. $threads[$post['tid']]['replies']++;
  250. if($post['dateline'] > $post['lastpost']) {
  251. $threads[$post['tid']]['lastpost'] = array($post['dateline']);
  252. $threads[$post['tid']]['lastposter'] = array($post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : $post['author']);
  253. }
  254. if($threads[$post['tid']]['attachadd'] || $post['attachment']) {
  255. $threads[$post['tid']]['attachment'] = array(1);
  256. }
  257. $pm = 'pm_'.$post['pid'];
  258. if($post['authorid'] && $post['authorid'] != $_G['uid']) {
  259. $pmlist[] = array(
  260. 'action' => 'modreplies_validate',
  261. 'notevar' => array('pid' => $post['pid'], 'tid' => $post['tid'], 'post' => dhtmlspecialchars(cutstr($post['message'], 30)), 'reason' => dhtmlspecialchars($_GET[''.$pm]), 'from_id' => 0, 'from_idtype' => 'modreplies'),
  262. 'authorid' => $post['authorid'],
  263. );
  264. }
  265. }
  266. unset($postlist, $tids, $threadlist);
  267. foreach($threads as $tid => $thread) {
  268. C::t('forum_thread')->increase($tid, $thread);
  269. }
  270. foreach(array_unique($forums) as $fid) {
  271. updateforumcount($fid);
  272. }
  273. if(!empty($pidarray)) {
  274. C::t('forum_post')->update($posttable, $pidarray, array('status' => 4), false, false, null, -2, null, 0);
  275. $validates = C::t('forum_post')->update($posttable, $pidarray, array('invisible' => 0));
  276. updatemodworks('MOD', $validates);
  277. updatemoderate('pid', $pidarray, 2);
  278. } else {
  279. require_once libfile('function/forum');
  280. updatemodworks('MOD', 1);
  281. }
  282. }
  283. if($pmlist) {
  284. foreach($pmlist as $pm) {
  285. notification_add($pm['authorid'], 'system', $pm['action'], $pm['notevar'], 1);
  286. }
  287. }
  288. if($_GET['fast']) {
  289. echo callback_js($_GET['pid']);
  290. exit;
  291. } else {
  292. 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));
  293. }
  294. }
  295. ?>