moderate_comment.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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_comment.php 31996 2012-10-30 06:15:14Z liulanbo $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. if(!submitcheck('modsubmit') && !$_GET['fast']) {
  12. shownav('topic', $lang['moderate_comments']);
  13. showsubmenu('nav_moderate_posts', $submenu);
  14. $select[$_GET['tpp']] = $_GET['tpp'] ? "selected='selected'" : '';
  15. $tpp_options = "<option value='20' $select[20]>20</option><option value='50' $select[50]>50</option><option value='100' $select[100]>100</option>";
  16. $tpp = !empty($_GET['tpp']) ? $_GET['tpp'] : '20';
  17. $start_limit = ($page - 1) * $ppp;
  18. $dateline = $_GET['dateline'] ? $_GET['dateline'] : '604800';
  19. $dateline_options = '';
  20. foreach(array('all', '604800', '2592000', '7776000') as $v) {
  21. $selected = '';
  22. if($dateline == $v) {
  23. $selected = "selected='selected'";
  24. }
  25. $dateline_options .= "<option value=\"$v\" $selected>".cplang("dateline_$v");
  26. }
  27. $idtype_select = '<option value="">'.$lang['all'].'</option>';
  28. foreach(array('uid', 'blogid', 'picid', 'sid') as $v) {
  29. $selected = '';
  30. if($_GET['idtype'] == $v) {
  31. $selected = 'selected="selected"';
  32. }
  33. $idtype_select .= "<option value=\"$v\" $selected>".$lang["comment_$v"]."</option>";
  34. }
  35. $comment_status = 1;
  36. if($_GET['filter'] == 'ignore') {
  37. $comment_status = 2;
  38. }
  39. showformheader("moderate&operation=comments");
  40. showtableheader('search');
  41. showtablerow('', array('width="60"', 'width="160"', 'width="60"'),
  42. array(
  43. cplang('username'), "<input size=\"15\" name=\"username\" type=\"text\" value=\"$_GET[username]\" />",
  44. cplang('moderate_content_keyword'), "<input size=\"15\" name=\"keyword\" type=\"text\" value=\"$_GET[keyword]\" />",
  45. )
  46. );
  47. showtablerow('', array('width="60"', 'width="160"', 'width="60"'),
  48. array(
  49. "$lang[perpage]",
  50. "<select name=\"tpp\">$tpp_options</select><label><input name=\"showcensor\" type=\"checkbox\" class=\"checkbox\" value=\"yes\" ".($showcensor ? ' checked="checked"' : '')."/> $lang[moderate_showcensor]</label>",
  51. "$lang[moderate_bound]",
  52. "<select name=\"filter\">$filteroptions</select>
  53. <select name=\"idtype\">$idtype_select</select>
  54. <select name=\"dateline\">$dateline_options</select>
  55. <input class=\"btn\" type=\"submit\" value=\"$lang[search]\" />"
  56. )
  57. );
  58. showtablefooter();
  59. $pagetmp = $page;
  60. $modcount = C::t('common_moderate')->count_by_search_for_commnet($_GET['idtype'], $moderatestatus, $_GET['username'], (($dateline && $dateline != 'all') ? (TIMESTAMP - $dateline) : null), $_GET['keyword']);
  61. do {
  62. $start_limit = ($pagetmp - 1) * $tpp;
  63. $commentarr = C::t('common_moderate')->fetch_all_by_search_for_comment($_GET['idtype'], $moderatestatus, $_GET['username'], (($dateline && $dateline != 'all') ? (TIMESTAMP - $dateline) : null), $_GET['keyword'], $start_limit, $tpp);
  64. $pagetmp = $pagetmp - 1;
  65. } while($pagetmp > 0 && empty($commentarr));
  66. $page = $pagetmp + 1;
  67. $multipage = multi($modcount, $tpp, $page, ADMINSCRIPT."?action=moderate&operation=comments&filter=$filter&dateline={$_GET['dateline']}&username={$_GET['username']}&keyword={$_GET['keyword']}&idtype={$_GET['idtype']}&ppp=$tpp&showcensor=$showcensor");
  68. 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>';
  69. showtableheader();
  70. $censor = & discuz_censor::instance();
  71. $censor->highlight = '#FF0000';
  72. require_once libfile('function/misc');
  73. foreach($commentarr as $comment) {
  74. $comment['dateline'] = dgmdate($comment['dateline']);
  75. $short_desc = cutstr($comment['message'], 75);
  76. if($showcensor) {
  77. $censor->check($short_desc);
  78. $censor->check($comment['message']);
  79. }
  80. $comment_censor_words = $censor->words_found;
  81. if(count($comment_censor_words) > 3) {
  82. $comment_censor_words = array_slice($comment_censor_words, 0, 3);
  83. }
  84. $comment['censorwords'] = implode(', ', $comment_censor_words);
  85. $comment['ip'] = $comment['ip'] . ' - ' . convertip($comment['ip']);
  86. $comment['modkey'] = modauthkey($comment['id']);
  87. $comment['modcommentkey'] = modauthkey($comment['cid']);
  88. if($showcensor) {
  89. if(count($comment_censor_words)) {
  90. $comment_censor_text = "<span style=\"color: red;\">({$comment['censorwords']})</span>";
  91. } else {
  92. $comment_censor_text = lang('admincp', 'no_censor_word');
  93. }
  94. }
  95. $viewurl = '';
  96. $commenttype = '';
  97. $editurl = "home.php?mod=spacecp&ac=comment&op=edit&cid=$comment[cid]&modcommentkey=$comment[modcommentkey]";
  98. switch($comment['idtype']) {
  99. case 'uid':
  100. $commenttype = lang('admincp', 'comment_uid');
  101. $viewurl = "home.php?mod=space&uid=$comment[uid]&do=wall#comment_anchor_$comment[cid]";
  102. break;
  103. case 'blogid':
  104. $commenttype = lang('admincp', 'comment_blogid');
  105. $viewurl = "home.php?mod=space&uid=$comment[uid]&do=blog&id=$comment[id]&modblogkey=$comment[modkey]#comment_anchor_$comment[cid]";
  106. break;
  107. case 'picid':
  108. $commenttype = lang('admincp', 'comment_picid');
  109. $viewurl = "home.php?mod=space&uid=$comment[uid]&do=album&picid=$comment[id]&modpickey=$comment[modkey]#comment_anchor_$comment[cid]";
  110. break;
  111. case 'sid':
  112. $commenttype = lang('admincp', 'comment_sid');
  113. $viewurl = "home.php?mod=space&uid=$comment[uid]&do=share&id=$comment[id]#comment_anchor_$comment[cid]";
  114. break;
  115. }
  116. showtagheader('tbody', '', true, 'hover');
  117. showtablerow("id=\"mod_$comment[cid]_row1\"", array("id=\"mod_$comment[cid]_row1_op\" rowspan=\"3\" class=\"rowform threadopt\" style=\"width:80px;\"", '', 'width="120"', 'width="120"', 'width="55"', 'width="55"'), array(
  118. "<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"moderate[$comment[cid]]\" id=\"mod_$comment[cid]_1\" value=\"validate\" onclick=\"mod_setbg($comment[cid], 'validate');\"><label for=\"mod_$comment[cid]_1\">$lang[validate]</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[$comment[cid]]\" id=\"mod_$comment[cid]_2\" value=\"delete\" onclick=\"mod_setbg($comment[cid], 'delete');\"><label for=\"mod_$comment[cid]_2\">$lang[delete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[$comment[cid]]\" id=\"mod_$comment[cid]_3\" value=\"ignore\" onclick=\"mod_setbg($comment[cid], 'ignore');\"><label for=\"mod_$comment[cid]_3\">$lang[ignore]</label></li></ul>",
  119. "<h3><a href=\"javascript:;\" onclick=\"display_toggle({$comment[cid]});\"> $short_desc $comment_censor_text</a></h3><p>$comment[ip]</p>",
  120. $commenttype.'<input name="idtypes['.$comment['cid'].']" type="hidden" value="'.$comment['idtype'].'">',
  121. "<p><a target=\"_blank\" href=\"".ADMINSCRIPT."?action=members&operation=search&uid=$comment[authorid]&submit=yes\">$comment[author]</a></p> <p>$comment[dateline]</p>",
  122. "<a target=\"_blank\" href=\"$viewurl\">$lang[view]</a>&nbsp;<a href=\"$editurl\" target=\"_blank\">$lang[edit]</a>",
  123. ));
  124. showtablerow("id=\"mod_$comment[cid]_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;">'.$comment['message'].'</div>');
  125. showtablerow("id=\"mod_$comment[cid]_row3\"", 'class="threadopt threadtitle" colspan="4"', "<a href=\"?action=moderate&operation=comments&fast=1&cid=$comment[cid]&moderate[$comment[cid]]=validate&idtypes[$comment[cid]]=$comment[idtype]&page=$page&frame=no\" target=\"fasthandle\">$lang[validate]</a> | <a href=\"?action=moderate&operation=comments&fast=1&cid=$comment[cid]&moderate[$comment[cid]]=delete&idtypes[$comment[cid]]=$comment[idtype]&page=$page&frame=no\" target=\"fasthandle\">$lang[delete]</a> | <a href=\"?action=moderate&operation=comments&fast=1&cid=$comment[cid]&moderate[$comment[cid]]=ignore&idtypes[$comment[cid]]=$comment[idtype]&page=$page&frame=no\" target=\"fasthandle\">$lang[ignore]</a>");
  126. showtagfooter('tbody');
  127. }
  128. 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>', $multipage, false);
  129. showtablefooter();
  130. showformfooter();
  131. } else {
  132. $moderation = array('validate' => array(), 'delete' => array(), 'ignore' => array());
  133. $validates = $deletes = $ignores = 0;
  134. $moderatedata = array();
  135. if(is_array($moderate)) {
  136. foreach($moderate as $cid => $act) {
  137. $moderation[$act][] = $cid;
  138. $moderatedata[$act][$_GET['idtypes'][$cid]][] = $cid;
  139. }
  140. }
  141. foreach($moderatedata as $act => $typeids) {
  142. foreach($typeids as $idtype => $ids) {
  143. $op = $act == 'ignore' ? 1 : 2;
  144. updatemoderate($idtype.'_cid', $ids, $op);
  145. }
  146. }
  147. if($moderation['validate']) {
  148. $validates = C::t('home_comment')->update($moderation['validate'], array('status' => '0'));
  149. }
  150. if(!empty($moderation['delete'])) {
  151. require_once libfile('function/delete');
  152. $comments = deletecomments($moderation['delete']);
  153. $deletes = count($comments);
  154. }
  155. if($moderation['ignore']) {
  156. $ignores = C::t('home_comment')->update($moderation['ignore'], array('status' => '2'));
  157. }
  158. if($_GET['fast']) {
  159. echo callback_js($_GET['cid']);
  160. exit;
  161. } else {
  162. cpmsg('moderate_comments_succeed', "action=moderate&operation=comments&page=$page&filter=$filter&dateline={$_GET['dateline']}&username={$_GET['username']}&keyword={$_GET['keyword']}&idtype={$_GET['idtype']}&tpp={$_GET['tpp']}&showcensor=$showcensor", 'succeed', array('validates' => $validates, 'ignores' => $ignores, 'deletes' => $deletes));
  163. }
  164. }
  165. ?>