给你网站博客添加一个读者墙

给你网站博客添加一个读者墙

小天
2023-04-04 / 0 评论 / 33 阅读 / 搜一下 / 正在检测是否收录...


给你网站博客添加一个读者墙

<?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>
2

评论 (0)

打卡
取消