Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[已答复] 增加游客评论审核功能

[复制链接]
ykjzg 发表于 2009-1-23 04:20:34 | 显示全部楼层 |阅读模式
  我的网站用的是supesite6.0,开放游客评论后经常有垃圾广告,为此我自己对程序进行了修改,为游客评论增加了审核功能。(登录后前台审核)
  先为资讯增加游客评论审核功能:
  1、给数据表supe_spacecomments增加一个字段,字段名canshow,类型int,长度1,默认值0。
  2、修改以下文件(6、7个文件):(注:本人英文不好,用词不一定恰当,大家可作相应的修改)


viewnews.php中修改:


$listcount = $news['replynum'];
if($listcount) {
        $query = $_SGLOBAL['db']->query('SELECT c.* FROM '.tname('spacecomments').' c WHERE c.canshow=1 and c.itemid=\''.$news['itemid'].'\' ORDER BY c.dateline DESC LIMIT 0, 20');
        while ($value = $_SGLOBAL['db']->fetch_array($query)) {
                $value['message'] = snl2br($value['message']);
                if(empty($value['author'])) $value['author'] = 'Guest';
                $commentlist[] = $value;
        }
}



红色是加的,作用是canshow不为1的不显示。
 楼主| ykjzg 发表于 2009-1-23 04:22:04 | 显示全部楼层
本帖最后由 ykjzg 于 2009-1-23 04:59 编辑

batch.comment.php中修改:



} elseif ($action == 'canshow') {

getcookie(1);
$cid = empty($_GET['cid'])?0:intval($_GET['cid']);
if(empty($cid) || empty($_SGLOBAL['supe_uid'])) showxml($blang['message_no_permission']);

$query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('spacecomments').' WHERE cid=\''.$cid.'\'');
if($value = $_SGLOBAL['db']->fetch_array($query)) {

  //检查权限
  if($value['uid'] != $_SGLOBAL['supe_uid'] && empty($_SGLOBAL['group']['allowcheckitem'])) showxml($blang['message_no_permission']);
  updatetable('spacecomments', array('canshow'=>1,'subject'=>''), array('cid'=>$cid));
  if($value['type'] != 'news') clearspacecache($_SGLOBAL['supe_uid'], 'comment');
  showxml($blang['message_canshow_ok']);
} else {
  showxml($blang['message_no_permission']);
}
} elseif ($action == 'notshow') {

getcookie(1);
$cid = empty($_GET['cid'])?0:intval($_GET['cid']);
if(empty($cid) || empty($_SGLOBAL['supe_uid'])) showxml($blang['message_no_permission']);

$query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('spacecomments').' WHERE cid=\''.$cid.'\'');
if($value = $_SGLOBAL['db']->fetch_array($query)) {

  //检查权限
  if($value['uid'] != $_SGLOBAL['supe_uid'] && empty($_SGLOBAL['group']['allowcheckitem'])) showxml($blang['message_no_permission']);
  updatetable('spacecomments', array('canshow'=>0,'subject'=>'新游客评论 未审核'), array('cid'=>$cid));
  if($value['type'] != 'news') clearspacecache($_SGLOBAL['supe_uid'], 'comment');
  showxml($blang['message_notshow_ok']);
} else {
  showxml($blang['message_no_permission']);
}

} elseif ($action == 'rate') {

//快捷评分



$listcount = $item['replynum'] + $item['trackbacknum'];
getcookie(1);
if($_SGLOBAL['supe_uid'] == '0' )
{
  if($listcount) {
   $query = $_SGLOBAL['db']->query('SELECT u.*, c.* FROM '.tname('spacecomments').' c LEFT JOIN '.tname('userspaces').' u ON u.uid=c.authorid WHERE c.itemid=\''.$itemid.'\' ORDER BY c.dateline DESC LIMIT '.$start.','.$perpage);
   while ($value = $_SGLOBAL['db']->fetch_array($query)) {
    if($value['canshow'] == '0' ){
     $value['message'] = '经审核后才能显示';
     $value['rates'] = '';
    }
    $value['photo'] = getphoto($value['authorid'], $value['photo']);
    $commentlist[] = $value;
   }
  $multipage = multi($listcount, $perpage, $page, 'PAGE');
  }
} else {
  if($listcount) {
   $query = $_SGLOBAL['db']->query('SELECT u.*, c.* FROM '.tname('spacecomments').' c LEFT JOIN '.tname('userspaces').' u ON u.uid=c.authorid WHERE c.itemid=\''.$itemid.'\' ORDER BY c.dateline DESC LIMIT '.$start.','.$perpage);
   while ($value = $_SGLOBAL['db']->fetch_array($query)) {
    $value['photo'] = getphoto($value['authorid'], $value['photo']);
    $commentlist[] = $value;
   }
  $multipage = multi($listcount, $perpage, $page, 'PAGE');
  }
}
if($multipage) {
  $multipage = preg_replace("/\"PAGE\?page\=(\d+?)\"/", '"javascript:;"file://\\1);"'">\\1);"', $multipage);
}
$html = '';
if($commentlist) {
  include_once(S_ROOT.'./include/common.inc.php');
  include_once(S_ROOT.'./include/supe_bbcode.inc.php');
  include_once(S_ROOT.'./function/common.func2.php');
  $html = getcommenthtml2($commentlist);
  $html .= "<div id=\"xspace-multipage-div\" class=\"xspace-multipage\">$multipage</div>";
} else {
  $html .= "<div id=\"xspace-multipage-div\" class=\"xspace-multipage\">$blang[message_no_reply]</div>";
}
return $html;
}


红色为增加的,
还要在function目录下增加一文件common.func2.php,主要是提供一函数getcommenthtml2,(因为common.func.php是加密的,只能用这种方法绕过它),文件中的内容是:
function getcommenthtml2( $commentlist )
{
global $_SGLOBAL;
global $lang;
$html = "";
foreach ( $commentlist as $value )
{
  if ( !empty( $value['message'] ) )
  {
   $value['message'] = bbcode( $value['message'] );
  }
  if ( empty( $value['authorid'] ) )
  {
   if ( $value['url'] )
   {
    $value['photo'] = S_URL."/images/base/pic_trackback.gif";
    $value['message'] = "<p><a href=\"{$value['url']}\" target=\"_blank\">{$value['subject']}</a></p>".$value['message'];
   }
   $value['photo'] = "<img src=\"{$value['photo']}\" class=\"xspace-signavatar xspace-imgstyle\" />";
  }
  else
  {
   $url = geturl( "uid/{$value['authorid']}" );
   $value['photo'] = "<a href=\"".$url."\" target=\"_blank\"><img src=\"{$value['photo']}\" class=\"xspace-signavatar xspace-imgstyle\" alt=\"".$value['spacename']."\" /></a>";
   $value['author'] = "<a href=\"".$url."\" target=\"_blank\">{$value['author']}</a>";
  }
  $value['dateline'] = sgmdate( $value['dateline'] );
  if ( !empty( $value['rates'] ) )
  {
   $value['message'] = "{$lang['rate_pre']} <span style=\"font-size:18px;font-weight:bold;\">{$value['rates']}</span> {$lang['fen']}<br />".$value['message'];
  }
  if($value['canshow']=='0')
  {
  $html .= "\r\n\t\t<dl id=\"xspace-comment{$value['cid']}\">\r\n\t\t<dt>\r\n\t\t{$value['photo']}\r\n\r\n\t\t<a href=\"javascript:;\" onclick=\"javascript:canshowcomment({$value['cid']});\" class=\"xspace-del\">{$lang['canshow']}</a>\r\n\t\t<a href=\"javascript:;\" onclick=\"getQuote({$value['cid']})\" class=\"xspace-quote\">{$lang['quote']}</a>\r\n\t\t<a href=\"javascript:;\" onclick=\"javascript:deletecomment({$value['cid']});\" class=\"xspace-del\">{$lang['delete']}</a>\r\n\r\n\t\t{$value['author']} <span class=\"xspace-smalltxt\"> &nbsp; / &nbsp; {$value['dateline']}</span>\r\n\t\t</dt>\r\n\t\t<dd>\r\n\t\t{$value['message']}\r\n\t\t</dd>\r\n\t\t</dl>\r\n\t\t";
  } else {
  $html .= "\r\n\t\t<dl id=\"xspace-comment{$value['cid']}\">\r\n\t\t<dt>\r\n\t\t{$value['photo']}\r\n\r\n\t\t<a href=\"javascript:;\" onclick=\"javascript:notshowcomment({$value['cid']});\" class=\"xspace-del\">{$lang['notshow']}</a>\r\n\t\t<a href=\"javascript:;\" onclick=\"getQuote({$value['cid']})\" class=\"xspace-quote\">{$lang['quote']}</a>\r\n\t\t<a href=\"javascript:;\" onclick=\"javascript:deletecomment({$value['cid']});\" class=\"xspace-del\">{$lang['delete']}</a>\r\n\r\n\t\t{$value['author']} <span class=\"xspace-smalltxt\"> &nbsp; / &nbsp; {$value['dateline']}</span>\r\n\t\t</dt>\r\n\t\t<dd>\r\n\t\t{$value['message']}\r\n\t\t</dd>\r\n\t\t</dl>\r\n\t\t";
  }
}
return $html;
}

回复

使用道具 举报

 楼主| ykjzg 发表于 2009-1-23 04:30:31 | 显示全部楼层
在viewcomment.php中增加以下代码:

  //回复词语屏蔽
$_POST['message'] = censor($_POST['message']);
if(!empty($_POST['nickname'])) {
  $author = addslashes(cutstr(shtmlspecialchars(stripslashes($_POST['nickname'])), 15));
}
if(empty($_SGLOBAL['supe_uid'])) {
$setsqlarr = array(
  'itemid' => $itemid,
  'type' => 'news',
  'uid' => '0',
  'authorid' => $_SGLOBAL['supe_uid'],
  'author' =>  $author,
  'ip' => $_SGLOBAL['onlineip'],
  'dateline' => $_SGLOBAL['timestamp'],
  'rates' => $_POST['rates'],
  'message' => $_POST['message']
);
} else {
$setsqlarr = array(
  'itemid' => $itemid,
  'type' => 'news',
  'uid' => '0',
  'authorid' => $_SGLOBAL['supe_uid'],
  'author' => $_SGLOBAL['supe_username'],
  'ip' => $_SGLOBAL['onlineip'],
  'dateline' => $_SGLOBAL['timestamp'],
  'rates' => $_POST['rates'],
  'message' => $_POST['message'],
  'canshow' => '1'
);






if(!empty($_SGET['op']) && $_SGET['op'] == 'canshow') {

$cid = empty($_SGET['cid'])?0:intval($_SGET['cid']);
if(empty($cid)) messagebox('error', 'not_found', S_URL);
$itemid = empty($_SGET['itemid'])?0:intval($_SGET['itemid']);
if(empty($itemid)) messagebox('error', 'not_found', S_URL);

$canshowflag = false;
getcookie(1);
if(empty($_SGLOBAL['group'])) {
  messagebox('error', 'no_permission');
}

if($cid && $itemid && $_SGLOBAL['supe_uid']) {
  $query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('spacecomments').' WHERE cid=\''.$cid.'\'');
  if($comment = $_SGLOBAL['db']->fetch_array($query)) {
   if($_SGLOBAL['group']['groupid'] == 1 ) {
    $_SGLOBAL['db']->query('UPDATE '.tname('spacecomments').' SET canshow=1 WHERE cid=\''.$cid.'\'');
    $canshowflag = true;
   }
  }
}
if($canshowflag) {
  messagebox('ok', 'succeed', geturl('action/viewcomment/itemid/'.$itemid));
} else {
  messagebox('error', 'no_permission');
}
}

if(!empty($_SGET['op']) && $_SGET['op'] == 'notshow') {

$cid = empty($_SGET['cid'])?0:intval($_SGET['cid']);
if(empty($cid)) messagebox('error', 'not_found', S_URL);
$itemid = empty($_SGET['itemid'])?0:intval($_SGET['itemid']);
if(empty($itemid)) messagebox('error', 'not_found', S_URL);

$canshowflag = false;
getcookie(1);
if(empty($_SGLOBAL['group'])) {
  messagebox('error', 'no_permission');
}

if($cid && $itemid && $_SGLOBAL['supe_uid']) {
  $query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('spacecomments').' WHERE cid=\''.$cid.'\'');
  if($comment = $_SGLOBAL['db']->fetch_array($query)) {
   if($_SGLOBAL['group']['groupid'] == 1 ) {
    $_SGLOBAL['db']->query('UPDATE '.tname('spacecomments').' SET canshow=0 WHERE cid=\''.$cid.'\'');
    $canshowflag = true;
   }
  }
}
if($canshowflag) {
  messagebox('ok', 'succeed', geturl('action/viewcomment/itemid/'.$itemid));
} else {
  messagebox('error', 'no_permission');
}
}




if($listcount) {
$i = ($page-1)*$perpage + 1;
getcookie(1);
$query = $_SGLOBAL['db']->query('SELECT * FROM '.tname('spacecomments').' WHERE itemid=\''.$itemid.'\' ORDER BY dateline DESC LIMIT '.$start.','.$perpage);
if($_SGLOBAL['group']['groupid'] == 1 ){
  while ($comment = $_SGLOBAL['db']->fetch_array($query)) {
   $comment['message'] = snl2br($comment['message']);        
   $comment['num'] = $i;
   $i++;
   $iarr[] = $comment;
  }
} else {
  while ($comment = $_SGLOBAL['db']->fetch_array($query)) {   
   if($comment['canshow'] == 0){
    $comment['message'] = '经审核后才能显示' ;
    $comment['rates'] = '' ;
   } else {
    $comment['message'] = snl2br($comment['message']);
   }

   $comment['num'] = $i;
   $i++;
   $iarr[] = $comment;
  }
}
$urlarr = array('action'=>'viewcomment', 'itemid' => $itemid);
$multipage = multi($listcount, $perpage, $page, $urlarr, 0);
}

红色是增加的,这个文件改动比较多
回复

使用道具 举报

 楼主| ykjzg 发表于 2009-1-23 04:40:56 | 显示全部楼层
本帖最后由 ykjzg 于 2009-1-23 05:14 编辑

还要修改模板里的两个文件:
news_view.html.php   news_viewcomment.html.php

改动较多,上传文件自己看。
我是修改softsea里的文件的。

再修改language中文件:batch.lang.php

'message_delete_ok' => '恭喜,删除成功了,页面信息将在下次浏览时更新',
'message_canshow_ok' => '恭喜,已更改为显示了,页面信息将在下次浏览时更新',
'message_notshow_ok' => '恭喜,已更改为隐藏了,页面信息将在下次浏览时更新',

红色是增加的

文件修改后还要删除cache\tpl\ 里的相关文件再试
全部文件上传:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

cx36 发表于 2009-2-14 13:16:06 | 显示全部楼层
太棒了!!!!!!
回复

使用道具 举报

 楼主| ykjzg 发表于 2009-2-20 07:52:17 | 显示全部楼层
我管理的网站:
永康教研网
回复

使用道具 举报

yunings 发表于 2009-2-20 08:50:55 | 显示全部楼层
收藏了,谢谢楼主分享。
回复

使用道具 举报

 楼主| ykjzg 发表于 2009-2-20 13:07:26 | 显示全部楼层
本帖最后由 ykjzg 于 2009-2-20 13:09 编辑

游客评论开放后,博客的评论也随着开放,所以还要修改X-space的相关文件,改动方法差不多,需要的话我把这部分也上传。也可以先到我管理的网站看看效果。www.jys.ykedu.net
回复

使用道具 举报

rjcn 发表于 2009-2-20 18:35:49 | 显示全部楼层
收藏
谢谢楼主分享
回复

使用道具 举报

 楼主| ykjzg 发表于 2009-4-21 07:20:35 | 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-11-16 13:28 , Processed in 0.033901 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表