华纳云香港服务器
boke112百科 » Z-Blog » 正文

纯代码实现PHP版本的Zblog年月周读者墙

在前面已经介绍了WordPress版本的《纯代码实现按年、月、周评论排行的读者墙》和《PHP版本的Zblog年月周读者墙插件》,但是有些博友是使用Zblog建站的,导致有机会成为本站合作博客但没有办法推出周评论排行榜的读者墙而被取消享受上首页推荐一个月的福利,为此,本站特意推出Zblog版本的年月周排行榜的读者墙,今天就分享给大家,希望大家有空的时候折腾一下,从而推进按年、月、周评论排行的读者墙。

纯代码实现PHP版本的Zblog年月周读者墙-第1张-boke112百科(boke112.com)

PHP版本的Zblog年、月、周排行榜读者墙的实现步骤如下:

1、把以下代码添加到所使用主题的include.php文件最后一个?>前面(如果没有include.php,就自己新建一个,记得加上<?php和?>):

  1. function YMWreaderwall($num,$adminemail){
  2.     global $zbp;
  3.     if($num){
  4.         $i = $num;
  5.     }else{
  6.         $i=6;
  7.     }
  8.     if($adminemail){
  9.         $bozhuemail = $adminemail;
  10.     }else{
  11.         $bozhuemail=’22265…[email protected]’;
  12.     }
  13.     $dy =date(‘Y’);
  14.     $dm =date(‘m’);
  15.     $dw =strftime(“%U”);
  16.     $sqly = $zbp->db->sql->Select(
  17.         $zbp->table[‘Comment’],
  18.         array(‘COUNT(comm_ID) AS cnt,  comm_Name, comm_HomePage , comm_Email’),
  19.         array(
  20.             array(‘=’, ‘year(from_unixtime(comm_PostTime))’, $dy),
  21.             array(‘<>’, ‘comm_Email’, $bozhuemail),
  22.             array(‘=’, ‘comm_AuthorID’, 0),
  23.             array(‘CUSTOM’, ‘1=1 GROUP BY comm_Email’)
  24.         ),
  25.         array(‘cnt’ => ‘DESC’),
  26.         $i,
  27.     null
  28.     );
  29.     $arrayy=$zbp->db->Query($sqly);
  30. $sy=“本年评论排行榜 TOP$i<ul class=’readers-list’>”;
  31. $sy .=“\r\n”;
  32.     foreach ($arrayy as $commenty) {
  33.         $sy .= ‘<li><a href=“‘.$commenty[‘comm_HomePage’] . ‘” rel=“external nofollow” target=“_blank”><img src=“http://cn.gravatar.com/avatar/’ .md5(strtolower($commenty[‘comm_Email’])).’ &r=X&s=80” alt=“avatar” class=“avatar avatar-36 photo” height=“36” width=“36” /><em>’.$commenty[‘comm_Name’] .'</em><strong>+’.$commenty[‘cnt’].'</strong></br>’.$commenty[‘comm_HomePage’] . ‘</a></li>’;
  34.         $sy .=“\r\n”;
  35.     }
  36. $sy .=“</ul>”;
  37. $sy .=“\r\n”;
  38. echo $sy;
  39. $sqlm = $zbp->db->sql->Select(
  40.         $zbp->table[‘Comment’],
  41.         array(‘COUNT(comm_ID) AS cnt,  comm_Name, comm_HomePage , comm_Email’),
  42.         array(
  43.             array(‘=’, ‘year(from_unixtime(comm_PostTime))’, $dy),
  44.             array(‘=’, ‘month(from_unixtime(comm_PostTime))’, $dm),
  45.             array(‘<>’, ‘comm_Email’, $bozhuemail),
  46.             array(‘=’, ‘comm_AuthorID’, 0),
  47.             array(‘CUSTOM’, ‘1=1 GROUP BY comm_Email’)
  48.         ),
  49.         array(‘cnt’ => ‘DESC’),
  50.         $i,
  51.     null
  52.     );
  53.     $arraym=$zbp->db->Query($sqlm);
  54. $sm=“本月评论排行榜 TOP$i<ul class=’readers-list’>”;
  55. $sm .=“\r\n”;
  56.     foreach ($arraym as $commentm) {
  57.         $sm .= ‘<li><a href=“‘.$commentm[‘comm_HomePage’] . ‘” rel=“external nofollow”  target=“_blank”><img src=“http://cn.gravatar.com/avatar/’ .md5(strtolower($commentm[‘comm_Email’])).’ &r=X&s=80” alt=“avatar” class=“avatar avatar-36 photo” height=“36” width=“36” /><em>’.$commentm[‘comm_Name’] .'</em><strong>+’.$commentm[‘cnt’].'</strong></br>’.$commentm[‘comm_HomePage’] . ‘</a></li>’;
  58.         $sm .=“\r\n”;
  59.     }
  60. $sm .=“</ul>”;
  61. $sm .=“\r\n”;
  62. echo $sm;
  63. $sqlw = $zbp->db->sql->Select(
  64.         $zbp->table[‘Comment’],
  65.         array(‘COUNT(comm_ID) AS cnt,  comm_Name, comm_HomePage , comm_Email’),
  66.         array(
  67.             array(‘=’, ‘year(from_unixtime(comm_PostTime))’, $dy),
  68.             array(‘=’, ‘week(from_unixtime(comm_PostTime))’, $dw),
  69.             array(‘<>’, ‘comm_Email’, $bozhuemail),
  70.             array(‘=’, ‘comm_AuthorID’, 0),
  71.             array(‘CUSTOM’, ‘1=1 GROUP BY comm_Email’)
  72.         ),
  73.         array(‘cnt’ => ‘DESC’),
  74.         $i,
  75.     null
  76.     );
  77.     $arrayw=$zbp->db->Query($sqlw);
  78. $sw=“本周评论排行榜 TOP$i<ul class=’readers-list’>”;
  79. $sw .=“\r\n”;
  80.     foreach ($arrayw as $commentw) {
  81.         $sw .= ‘<li><a href=“‘.$commentw[‘comm_HomePage’] . ‘”  rel=“external nofollow”  target=“_blank”><img src=“http://cn.gravatar.com/avatar/’ .md5(strtolower($commentw[‘comm_Email’])).’ &r=X&s=80” alt=“avatar” class=“avatar avatar-36 photo” height=“36” width=“36” /><em>’.$commentw[‘comm_Name’] .'</em><strong>+’.$commentw[‘cnt’].'</strong></br>’.$commentw[‘comm_HomePage’] . ‘</a></li>’;
  82.         $sw .=“\r\n”;
  83.     }
  84. $sw .=“</ul>”;
  85. $sw .=“\r\n”;
  86. echo $sw;
  87. }

2、把以下代码添加到所使用主题的style文件夹内的default.css文件中:

  1. /* 读者墙 */
  2. #dzq  h3{margin:10px 0 5px;}
  3. #dzq ul{margin:0px 0px 1px 24px;}
  4. #dzq .readers-list{font-size:12px;line-height:18px;text-align:left;_zoom:1;overflow:hidden;text-overflow:ellipsis;whitewhite-space:nowrap;}
  5. #dzq .readers-list li{width:200px;float:left;*margin-right:-1px;margin:0 5px 0 0;}
  6. #dzq .readers-list a,#dzq .readers-list a:hover strong{background-color:#f2f2f2;background-image:-webkit-linear-gradient(#f8f8f8,#f2f2f2);background-image:-moz-linear-gradient(#f8f8f8,#f2f2f2);background-image:linear-gradient(#f8f8f8,#f2f2f2)}
  7. #dzq .readers-list a{position:relative;display:block;height:36px;margin:4px;padding:4px 4px 4px 44px;color:#999;overflow:hidden;border:#ccc 1px solid;border-radius:2px;box-shadow:#eee 0 0 2px}
  8. #dzq .readers-list img,#dzq .readers-list em,#dzq .readers-list strong{-webkit-transition:all .2s ease-out;-moz-transition:all .2s ease-out;transition:all .2s ease-out}
  9. #dzq .readers-list img{width:36px;height:36px;float:left;margin:0 8px 0 –40px;border-radius:2px}
  10. #dzq .readers-list em{color:#666;font-style:normal;margin-right:10px}
  11. #dzq .readers-list strong{color:#ddd;width:40px;text-align:rightright;position:absolute;rightright:6px;top:4px;font:bold 14px/16px microsoft yahei}
  12. #dzq .readers-list a:hover{border-color:#BA4C32;box-shadow:#ccc 0 0 2px;background-color:#fff;background-image:none}
  13. #dzq .readers-list a:hover img{opacity:.6;margin-left:0}
  14. #dzq .readers-list a:hover em{color:#BA4C32;font:bold 14px/36px microsoft yahei}
  15. #dzq .readers-list a:hover strong{color:#BA4C32;rightright:150px;top:0;text-align:center;border-right:#ccc 1px solid;height:44px;line-height:40px}

3、下载本站的YMWreaderwall.php文件模板,修改YMWreaderwall.php文件模板代码中的排行榜现实数量及博主的邮箱地址,如:{YMWreaderwall(6,’22265…[email protected]’)},其中6表示显示6个读者,后面的邮箱是博主自己的邮箱,排行榜将会排除博主自己的上榜。

4、把修改好的YMWreaderwall.php文件模板,存放到所使用主题的template文件夹内。登录后台后,可以直接新建一个页面或直接编辑留言本页面, 在模板中选择我们这个YMWreaderwall模板,然后提交更新即可。

纯代码实现PHP版本的Zblog年月周读者墙-第2张-boke112百科(boke112.com)

YMWreaderwall.php文件模板及本站所使用的代码和使用说明下载地址(提取码:0cbe):

此时,刷新我们的留言本看看,是否已经实现了年、月、周排行榜的读者墙???大家赶紧试一试吧!

本文地址:https://boke112.com/post/1023.html

赞 (0) 打赏
版权声明:本文为原创文章,版权归 boke112百科 所有,欢迎分享本文,转载请保留出处!发布此文是出于传递更多信息之目的,若有来源标注错误或侵犯了您的合法权益,请联系我们,确认后马上更正或删除,谢谢!
wu