给emlog读者评论添加VIP等级和博主认证 本文是 - Assbbs
给emlog读者评论添加VIP等级和博主认证 本文是介绍emlog利用查询数据库本留言者的邮箱评论过几次然后输出等级函数的添加和使用。 效果预览图: 修改模板 module.php,新增下面的内容: <?php //comment:输出等级 function echo levels $comment author email,$comment auth…
给emlog读者评论添加VIP等级和博主认证 本文是介绍emlog利用查询数据库本留言者的邮箱评论过几次然后输出等级函数的添加和使用。 效果预览图: 修改模板 module.php,新增下面的内容: <?php //comment:输出等级 function echo levels $comment author email,$comment author url { $DB = MySql::getInstance ; $adminEmail = ’"infreesu@hotmail.com"’; if $comment author email==$adminEmail { echo ’<a class="vp" href="mailto:infreesu@hotmail.com" title="管理员认证"></a><a class="vip7" title="特别认证"></a>’; } $sql = "SELECT cid as author count FROM emlog comment WHERE mail = ".$comment author email; $res = $DB->query $sql ; $author count = mysql num rows $res ; if $author count>=5 && $author count<10 && $comment author email!=$adminEmail echo ’<a class="vip1" title="评论之星 LV.1"></a>’; else if $author count>=10 && $author count<20 && $comment author email!=$adminEmail echo ’<a class="vip2" title="评论之星 LV.2"></a>’; else if $author count>=20 && $author count<40 && $comment author email!=$adminEmail echo ’<a class="vip3" title="评论之星 LV.3"></a>’; else if $author count>=40 && $author count<80 && $comment author email!=$adminEmail echo ’<a class="vip4" title="评论之星 LV.4"></a>’; else if $author count>=80 &&$author count<160 && $comment author email!=$adminEmail echo ’<a class="vip5" title="评论之星 LV.5"></a>’; else if $author count>=160 && $author coun<320 && $comment author email!=$adminEmail echo ’<a class="vip6" title="评论之星 LV.6"></a>’; else if $author count>=320 && $comment author email!=$adminEmail echo ’<a class="vip7" title="评论之星 LV.7"></a>’; } ?> 上面的 infreesu@hotmail.com 改成自己管理员邮箱, author count>=5 ,这后面的数字是当前VIP等级最低和最高的评论数。 然后在需要显示等级的地方添加下面这些代码就OK。 <?php $mail str=""".strip tags $comment ’mail’ .""";echo levels $mail str,""".$comment ’url’ .""" ; ?> 然后加入css样式代码: vp,.vip,.vip1,.vip2,.vip3,.vip4,.vip5,.vip6,.vip7{background: url images/vip.png no-repeat;display: inline-block;overflow: hidden;border: none;} .vp{background-position:-494px -3px;width: 16px;height: 16px;margin-bottom: -3px;} .vp:hover{background-position:-491px -19px;width: 19px;height: 18px;margin-top: -3px;margin-left: -3px;margin-bottom: -3px;} .vip{background-position:-515px -2px;width: 16px;height: 16px;margin-bottom: -3px;} .vip:hover{background-position:-515px -22px;width: 16px;height: 16px;margin-bottom: -3px;} .vip1{background-position:-1px -2px;width: 46px;height: 14px;margin-bottom: -1px;} .vip1:hover{background-position:-1px -22px;width: 46px;height: 14px;margin-bottom: -1px;} .vip2{background-position:-63px -2px;width: 46px;height: 14px;margin-bottom: -1px;} .vip2:hover{background-position:-63px -22px;width: 46px;height: 14px;margin-bottom: -1px;} .vip3{background-position:-144px -2px;width: 46px;height: 14px;margin-bottom: -1px;} .vip3:hover{background-position:-144px -22px;width: 46px;height: 14px;margin-bottom: -1px;} .v…