前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Emlog教程 - 添加评论人等级输出

Emlog教程 - 添加评论人等级输出

作者头像
用户8099761
发布2023-05-10 21:04:00
1530
发布2023-05-10 21:04:00
举报
文章被收录于专栏:私人订制私人订制

首先在module.php中添加以下函数

<?php
//comment:输出评论人等级
function echo_levels($comment_author_email,$comment_author_url){
  $DB = MySql::getInstance();
  $adminEmail = '"sheli@shuyong.net"';
  if($comment_author_email==$adminEmail)
  {
    echo '<sy id="ys">(管理员)</sy>';
  }
  $sql = "SELECT cid as author_count,mail FROM emlog_comment WHERE mail != '' and mail = $comment_author_email and hide ='n'";
  $res = $DB->query($sql);
  $author_count = mysql_num_rows($res);
   if($author_count>=0 && $author_count<5 && $comment_author_email!=$adminEmail)
    echo '<sy id="ya">(打酱油的)</sy>';
  else if($author_count>=5 && $author_count<10 && $comment_author_email!=$adminEmail)
    echo '<sy id="yb">(匆匆过客)</sy>';
  else if($author_count>=10 && $author_count<20 && $comment_author_email!=$adminEmail)
    echo '<sy id="yc">(新生入住)</sy>';
  else if($author_count>=20 && $author_count<30 && $comment_author_email!=$adminEmail)
    echo '<sy id="yd">(常住住户)</sy>';
  else if($author_count>=30 &&$author_count<40 && $comment_author_email!=$adminEmail)
    echo '活跃住户';
  else if($author_count>=40 && $author_coun<50 && $comment_author_email!=$adminEmail)
    echo '积极住户';
  else if($author_count>=50 && $author_coun<60 && $comment_author_email!=$adminEmail)
    echo '五好住户';
 else if($author_count>=60 && $author_coun<70 && $comment_author_email!=$adminEmail)
    echo '十佳住户';
     else if($author_count>=70 && $author_coun<80 && $comment_author_email!=$adminEmail)
    echo '住户委员';
     else if($author_count>=100 && $comment_author_email!=$adminEmail)
    echo '住户代表';
}
?>

以上代码用于判断评论人所填写的e-mail统计次数,达到相应次数后输出不同的等级,所以在评论中只人e-mail不认名称。

其中上面的<sy id="y*">是给输出等级添加相应的css,一般是文字颜色,可直接写在CSS文件中。

调用代码:

<?php $mail_str="\"".strip_tags($comment['mail']).\"";echo_levels($mail_str,"\"".$comment['url']."\""); ?>

在需要调用的地方插入以上代码即可

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-9-30,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档