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

时间:2020-08-01   阅读:270

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

<?php
//comment:输出评论人等级
function echo_levels($comment_author_email,$comment_author_url){
  $DB = MySql::getInstance();
  $adminEmail = '"[email protected]"';
  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']."\""); ?>

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

上一篇:分享PHP防刷新代码从此网站不再被F5刷死

下一篇:Emlog教程:修改微语限制字数的方法

网友评论