下面的 function dengji 函数方法,放在主题目录 Joe/functions.php 文件里面,函数的规则都可以自行定义更改。
// 评论者等级
function dengji($email){
$db = Typecho_Db::get();
$mail = $db->fetchAll($db->select(array('COUNT(cid)'=>'nums'))->from('table.comments')->where('mail = ?', $email)->where('authorId != ?','1'));
foreach ($mail as $v){
$nums = $v['nums'];
}
if($nums<1)
echo '';
else if($nums>=1 && $nums<20)
echo '<object><a class="vip1" title="剑士"></a></object> <span class="level le1">♙LV.'.$nums.' </span> ';
else if($nums>=20 && $nums<50)
echo '<object><a class="vip2" title="骑士"></a></object> <span class="level le2">♘LV.'.$nums.' </span> ';
else if($nums>=50 && $nums<100)
echo '<object><a class="vip3" title="领主"></a></object> <span class="level le3">♗LV.'.$nums.' </span> ';
else if($nums>=100 && $nums<200)
echo '<object><a class="vip4" title="公爵"></a></object> <span class="level le4">♖LV.'.$nums.' </span> ';
else if($nums>=200 && $nums<350)
echo '<object><a class="vip5" title="君王"></a></object> <span class="level le5">♕LV.'.$nums.' </span> ';
else if($nums>=350 && $nums<600)
echo '<object><a class="vip6" title="帝皇"></a></object> <span class="level le6">♔LV.'.$nums.' </span> ';
else if($nums>=600)
echo '<object><a class="vip7" title="超神"></a></object> <span class="level le7">㊣LV.'.$nums.' </span> ';
}
<?php
/**
* 读者墙
*
* @package custom
*/
?>
<!--
* 读者墙
* 放入主题目录下即可。
*
* @Author:小天博客[Feng Tianxiang]
* @Email:tianxiang.feng@qq.com
* @Date:2021/12/29
* @site:https://www.xtboke.com
-->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<style>
/*小天自定义*/
@media (max-width: 1400px){
html .xt-reader-top{grid-template-columns: repeat(3, 1fr);}
html .xt-reader-list{grid-template-columns: repeat(10, 1fr);}
}
@media (max-width: 1200px){
html .xt-reader-top{grid-template-columns: repeat(3, 1fr);}
html .xt-reader-list{grid-template-columns: repeat(10, 1fr);}
}
@media (max-width: 992px){
html .xt-reader-top{grid-template-columns: repeat(1, 1fr);}
html .xt-reader-list{grid-template-columns: repeat(4, 1fr);}
}
@media (max-width: 768px){
html .xt-reader-top{grid-template-columns: repeat(1, 1fr);}
html .xt-reader-list{grid-template-columns: repeat(4, 1fr);}
}
.xt-read-box{background: var(--background);padding:15px 5px;border-radius:5px;}
.xt-read-box h2{margin:15px 0;}
.xt-reader-top{display: grid;gap: 15px;grid-template-columns: repeat(3, 1fr);}
.xt-reader-top a.contain {
display: block;
border-radius: 5px;
overflow: hidden;
padding: 15px;
color: #fff;
word-break: break-word;
transition: box-shadow 0.35s, -webkit-transform 0.35s;
transition: transform 0.35s, box-shadow 0.35s;
transition: transform 0.35s, box-shadow 0.35s, -webkit-transform 0.35s;
}
.xt-reader-top a.contain .title {
position: relative;
}
.xt-reader-top a.contain .content {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 15px;
}
.xt-reader-top a.contain .content .desc {
margin-right: 10px;
}
.xt-reader-top a.contain .title::after {
content: '';
position: absolute;
bottom: -5px;
left: 0;
width: 100%;
height: 1px;
background: #fff;
}
.xt-reader-top a.contain .avatar{border-radius:50%;}
.xt-reader-top a.contain:hover{-webkit-transform:translateY(-5px) scale(1.025);transform:translateY(-5px) scale(1.025);box-shadow:0 34px 20px -24px rgba(136,161,206,0.3)}
hr{margin:15px 0;}
/*列表*/
.xt-reader-list{display: grid;gap: 15px;grid-template-columns: repeat(10, 1fr);}
.xt-reader-list li{text-align:center;cursor:pointer;color:var(--main);}
.xt-reader-list .avatar{border:1px solid #eee;border-radius:5px;margin-bottom:5px;}
</style>
<?php $this->need('public/include.php'); ?>
</head>
<body>
<div id="Joe">
<?php $this->need('public/header.php'); ?>
<div class="joe_container">
<div class="joe_main">
<div class="xt-read-box">
<center><p><h2>读者墙</h2></p></center>
<ul class="xt-reader-top">
<?php
$change = array(0=>array('color'=>'#FF5E52','tit'=>'金牌读者'),1=>array('color'=>'#7CCD38','tit'=>'银牌读者'),2=>array('color'=>'#52BAF5','tit'=>'铜牌读者'));
$db = Typecho_Db::get();
$sql = $db->select('COUNT(cid) AS cnt', 'author', 'url', 'mail')
->from('table.comments')
->where('status = ?', 'approved')
->where('type = ?', 'comment')
->where('authorId != ?', '1')
->where('mail != ?', 'tianxiang.feng@qq.com') //排除自己上墙
->group('mail')
->order('cnt', Typecho_Db::SORT_DESC)
->limit('100'); //读取几位用户的信息
$result = $db->fetchAll($sql);
if (count($result) > 0) {
$maxNum = $result[0]['cnt'];
for($i=0; $i<3; $i++){
$url = $result[$i]['url']?$result[$i]['url']:'————';
if($result[$i]){
?>
<li>
<a class="contain" href="javascript:;" rel="noopener noreferrer" style="background: <?php echo $change[$i]['color'];?>">
<span class="title">【<?php echo $change[$i]['tit'];?>】 评论:<?php echo $result[$i]['cnt'];?></span>
<div class="content">
<div class="desc"><?php dengji($result[$i]['mail']);?><?php echo $result[$i]['author']; ?><br/><?php echo $url;?></div>
<img width="40" height="40" class="avatar lazyloaded" src="<?php _getAvatarByMail($result[$i]['mail']); ?>" title="<?php echo $result[$i]['author']; ?>">
</div>
</a>
</li>
<?php }else{break;} } ?>
</ul>
<hr/>
<ul class="xt-reader-list">
<?php for($j=3; $j<98; $j++){ if($result[$j]){?>
<li title="【第<?php echo $j+1;?>名】评论:<?php echo $result[$j]['cnt'];?>"><img width="40" height="40" class="avatar lazyloaded" src="<?php _getAvatarByMail($result[$j]['mail']); ?>"><br/><?php echo $result[$j]['author']; ?></li>
<?php }else{break;} }?>
</ul>
<?php }
?>
</div>
</div>
<?php $this->need('public/aside.php'); ?>
</div>
<?php $this->need('public/footer.php'); ?>
</div>
</body>
</html>
滴!贵宾卡!打卡时间:下午11:09:03,请上车的乘客系好安全带~
已经更新
该怎么搞呢?
已经更新