moderate_portalcomment.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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_portalcomment.php 25246 2011-11-02 03:34:53Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. $idtype = $tablename = $mod = '';
  12. if($operation == 'articlecomments') {
  13. $idtype = 'aid';
  14. $tablename = 'portal_article_title';
  15. $mod = 'view';
  16. } else {
  17. $idtype = 'topicid';
  18. $tablename = 'portal_topic';
  19. $mod = 'topic';
  20. }
  21. if(!submitcheck('modsubmit') && !$_GET['fast']) {
  22. shownav('topic', $lang['moderate_articlecomments']);
  23. showsubmenu('nav_moderate_articlecomments', $submenu);
  24. $select[$_GET['tpp']] = $_GET['tpp'] ? "selected='selected'" : '';
  25. $tpp_options = "<option value='20' $select[20]>20</option><option value='50' $select[50]>50</option><option value='100' $select[100]>100</option>";
  26. $tpp = !empty($_GET['tpp']) ? $_GET['tpp'] : '20';
  27. $start_limit = ($page - 1) * $ppp;
  28. $dateline = $_GET['dateline'] ? $_GET['dateline'] : '604800';
  29. $dateline_options = '';
  30. foreach(array('all', '604800', '2592000', '7776000') as $v) {
  31. $selected = '';
  32. if($dateline == $v) {
  33. $selected = "selected='selected'";
  34. }
  35. $dateline_options .= "<option value=\"$v\" $selected>".cplang("dateline_$v");
  36. }
  37. $cat_select = '';
  38. if($operation == 'articlecomments') {
  39. $cat_select = '<option value="">'.$lang['all'].'</option>';
  40. loadcache('portalcategory');
  41. foreach($_G['cache']['portalcategory'] as $cat) {
  42. $selected = '';
  43. if($cat['catid'] == $_GET['catid']) {
  44. $selected = 'selected="selected"';
  45. }
  46. $cat_select .= "<option value=\"$cat[catid]\" $selected>$cat[catname]</option>";
  47. }
  48. $cat_select = "<select name=\"catid\">$cat_select</select>";
  49. }
  50. $articlecomment_status = 1;
  51. if($_GET['filter'] == 'ignore') {
  52. $articlecomment_status = 2;
  53. }
  54. showformheader("moderate&operation=$operation");
  55. showtableheader('search');
  56. if($operation == 'articlecomments') {
  57. showtablerow('', array('width="60"', 'width="160"', 'width="60"', 'width="200"', 'width="60"'),
  58. array(
  59. cplang('username'), "<input size=\"15\" name=\"username\" type=\"text\" value=\"$_GET[username]\" />",
  60. cplang('moderate_article_category'), $cat_select,
  61. cplang('moderate_content_keyword'), "<input size=\"15\" name=\"keyword\" type=\"text\" value=\"$_GET[keyword]\" />",
  62. )
  63. );
  64. } else {
  65. showtablerow('', array('width="60"', 'width="160"', 'width="60"'),
  66. array(
  67. cplang('username'), "<input size=\"15\" name=\"username\" type=\"text\" value=\"$_GET[username]\" />",
  68. cplang('moderate_content_keyword'), "<input size=\"15\" name=\"keyword\" type=\"text\" value=\"$_GET[keyword]\" />",
  69. )
  70. );
  71. }
  72. showtablerow('', $operation == 'articlecomments' ?
  73. array('width="60"', 'width="160"', 'width="60"', 'colspan="3"') :
  74. array('width="60"', 'width="160"', 'width="60"'),
  75. array(
  76. "$lang[perpage]",
  77. "<select name=\"tpp\">$tpp_options</select><label><input name=\"showcensor\" type=\"checkbox\" class=\"checkbox\" value=\"yes\" ".($showcensor ? ' checked="checked"' : '')."/> $lang[moderate_showcensor]</label>",
  78. "$lang[moderate_bound]",
  79. "<select name=\"filter\">$filteroptions</select>
  80. <select name=\"dateline\">$dateline_options</select>
  81. <input class=\"btn\" type=\"submit\" value=\"$lang[search]\" />"
  82. )
  83. );
  84. showtablefooter();
  85. $pagetmp = $page;
  86. $modcount = C::t('common_moderate')->fetch_all_for_portalcomment($idtype, $tablename, $moderatestatus, $_GET['catid'], $_GET['username'], $dateline, 1, $_GET['keyword']);
  87. do {
  88. $start_limit = ($pagetmp - 1) * $tpp;
  89. $query = C::t('common_moderate')->fetch_all_for_portalcomment($idtype, $tablename, $moderatestatus, $_GET['catid'], $_GET['username'], $dateline, 0, $_GET['keyword'], $start_limit, $tpp);
  90. $pagetmp = $pagetmp - 1;
  91. } while($pagetmp > 0 && count($query) == 0);
  92. $page = $pagetmp + 1;
  93. $multipage = multi($modcount, $tpp, $page, ADMINSCRIPT."?action=moderate&operation=$operation&filter=$filter&modfid=$modfid&ppp=$tpp&showcensor=$showcensor");
  94. 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>';
  95. showtableheader();
  96. $censor = & discuz_censor::instance();
  97. $censor->highlight = '#FF0000';
  98. require_once libfile('function/misc');
  99. foreach($query as $articlecomment) {
  100. $articlecomment['dateline'] = dgmdate($articlecomment['dateline']);
  101. if($showcensor) {
  102. $censor->check($articlecomment['title']);
  103. $censor->check($articlecomment['message']);
  104. }
  105. $articlecomment_censor_words = $censor->words_found;
  106. if(count($articlecomment_censor_words) > 3) {
  107. $articlecomment_censor_words = array_slice($articlecomment_censor_words, 0, 3);
  108. }
  109. $articlecomment['censorwords'] = implode(', ', $articlecomment_censor_words);
  110. $articlecomment['modarticlekey'] = modauthkey($articlecomment['aid']);
  111. $articlecomment['modarticlecommentkey'] = modauthkey($articlecomment['cid']);
  112. if(count($articlecomment_censor_words)) {
  113. $articlecomment_censor_text = "<span style=\"color: red;\">({$articlecomment['censorwords']})</span>";
  114. } else {
  115. $articlecomment_censor_text = '';
  116. }
  117. showtagheader('tbody', '', true, 'hover');
  118. showtablerow("id=\"mod_$articlecomment[cid]_row1\"", array("id=\"mod_$articlecomment[cid]_row1_op\" rowspan=\"3\" class=\"rowform threadopt\" style=\"width:80px;\"", '', 'width="120"', 'width="55"'), array(
  119. "<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"moderate[$articlecomment[cid]]\" id=\"mod_$articlecomment[cid]_1\" value=\"validate\" onclick=\"mod_setbg($articlecomment[cid], 'validate');\"><label for=\"mod_$articlecomment[cid]_1\">$lang[validate]</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[$articlecomment[cid]]\" id=\"mod_$articlecomment[cid]_2\" value=\"delete\" onclick=\"mod_setbg($articlecomment[cid], 'delete');\"><label for=\"mod_$articlecomment[cid]_2\">$lang[delete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[$articlecomment[cid]]\" id=\"mod_$articlecomment[cid]_3\" value=\"ignore\" onclick=\"mod_setbg($articlecomment[cid], 'ignore');\"><label for=\"mod_$articlecomment[cid]_3\">$lang[ignore]</label></li></ul>",
  120. "<h3><a href=\"javascript:;\" onclick=\"display_toggle({$articlecomment[cid]});\">$articlecomment[title] $articlecomment_censor_text</a></h3>",
  121. "<p><a target=\"_blank\" href=\"".ADMINSCRIPT."?action=members&operation=search&uid=$articlecomment[uid]&submit=yes\">$articlecomment[username]</a></p> <p>$articlecomment[dateline]</p>",
  122. "<a target=\"_blank\" href=\"portal.php?mod=$mod&$idtype=$articlecomment[id]&modarticlekey=$articlecomment[modarticlekey]#comment_anchor_{$articlecomment[cid]}\">$lang[view]</a>&nbsp;<a href=\"portal.php?mod=portalcp&ac=comment&op=edit&cid=$articlecomment[cid]&modarticlecommentkey=$articlecomment[modarticlecommentkey]\" target=\"_blank\">$lang[edit]</a>",
  123. ));
  124. showtablerow("id=\"mod_$articlecomment[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;">'.$articlecomment['message'].'</div>');
  125. showtablerow("id=\"mod_$articlecomment[cid]_row3\"", 'class="threadopt threadtitle" colspan="4"', "<a href=\"?action=moderate&operation=$operation&fast=1&cid=$articlecomment[cid]&moderate[$articlecomment[cid]]=validate&page=$page&frame=no\" target=\"fasthandle\">$lang[validate]</a> | <a href=\"?action=moderate&operation=$operation&fast=1&cid=$articlecomment[cid]&moderate[$articlecomment[cid]]=delete&page=$page&frame=no\" target=\"fasthandle\">$lang[delete]</a> | <a href=\"?action=moderate&operation=$operation&fast=1&cid=$articlecomment[cid]&moderate[$articlecomment[cid]]=ignore&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. if(is_array($moderate)) {
  135. foreach($moderate as $cid => $act) {
  136. $moderation[$act][] = $cid;
  137. }
  138. }
  139. if($moderation['validate']) {
  140. $validates = C::t('portal_comment')->update($moderation['validate'], array('status' => '0'));
  141. updatemoderate($idtype.'_cid', $moderation['validate'], 2);
  142. }
  143. if($moderation['delete']) {
  144. $validates = C::t('portal_comment')->delete($moderation['delete']);
  145. updatemoderate($idtype.'_cid', $moderation['delete'], 2);
  146. }
  147. if($moderation['ignore']) {
  148. $validates = C::t('portal_comment')->update($ignore_cids, array('status' => '2'));
  149. updatemoderate($idtype.'_cid', $moderation['ignore'], 1);
  150. }
  151. if($_GET['fast']) {
  152. echo callback_js($_GET['cid']);
  153. exit;
  154. } else {
  155. cpmsg('moderate_'.$operation.'_succeed', "action=moderate&operation=$operation&page=$page&filter=$filter&dateline={$_GET['dateline']}&username={$_GET['username']}&keyword={$_GET['keyword']}&catid={$_GET['catid']}&tpp={$_GET['tpp']}&showcensor=$showcensor", 'succeed', array('validates' => $validates, 'ignores' => $ignores, 'deletes' => $deletes));
  156. }
  157. }
  158. ?>