Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[美化] AL8 首页四格显示 作者:alan888 最后更新:06-02-13

[复制链接]
freddy 发表于 2006-2-9 10:40:16 | 显示全部楼层 |阅读模式
作  者: alan888
适用版本: Discuz 4
修改文件: index.php, logging.php, topicadmin.php, include/newthread.inc.php, include/newreply.inc.php, include/counter.inc.php, include/cache.func.php, index 模板
加入文件: foruminfo 模板 (附件 1)
演  示: http://www.alan888.com/Discuz
技术支持: http://www.alan888.com/Discuz


本插件因是按al8的条件编写, 在其他 Discuz Forum 使用可能出现一些问题, 故原本不打算发放, 但修到不少会员的查询, 所以将部份较易出问题的部份修改后发放

在所见的现有 cache 版 4 格插件, 因参考以前al8 2.2 版的修改, 做成每次更新快取时大量数据库查询次数, 例如将 cache.func.php 改成 "'index'=> array('announcements', 'onlinelist', 'forumlinks', 'newthread', 'replythread');" 每次发帖回帖等更新快取档 "updatecache" 动作时便增加 5 次数据库查询, 本插件使用独立快取档, 只会更新需要的部份, 所以在下列动作时只会增加数据库查询 1-2 次:
1. 会员注册: 1次 (当天注册人数更新)
2. 会员登陆: 1次 (当天到访人数更新)
3. 发新帖: 1次 (最新发表文章更新)
4. 回帖: 2次 (最新发表文章及最新回覆文章更新)
5. 管理动作执行: 2次 (最新发表文章及最新回覆文章更新)
本站曾经尝试使用 Discuz 4 的 JS 调用功能, 但更新不及时而速度也跟本插件相若, 故最后还是使用此插件的办法

注意:
1. 安装此插件非常繁琐, 对初学者不建议使用;
2. "是日到访会员" 的数据是根据会员执行登入程序后更新, 如会员使用 cookies 登入, 数据会在下次其他会员使用登入程序后才更新;
3. 请子细阅读每个安装程序, 尤其修改 cache.func.php 部份
4. 四格显示只提供快速登陆口, 但有安全登录连接
5. 积分政策按两种而设, 超过两种左手边第一格会较高, 可增加发帖及回帖的显示数量平衡, 在 include/cache.func.php 内找 "DESC LIMIT 0, 11" 将 11 (显示 11 行) 改为修改后的行数
6. 本插件在使用新版本的 MySQL 4.1 (含 4.1)以上 或 PHP 5.x系统时可能出现错误

安装程序
1. 修改 include/cache.func.php

修改完成此文件后请即时到后台→更新缓存



  1. 'medals'        => array('medals')
复制代码


更换为


  1.                 'medals'        => array('medals'),
  2.                 'newtopic'        => array('newtopic'),
  3.                 'newreply'        => array('newreply'),
  4.                 'todayvisit'        => array('todayvisit')
复制代码


再找

  1.                 case 'medals':
  2.                         $table = 'medals';
  3.                         $cols = 'medalid, name, image';
  4.                         $conditions = "WHERE available='1'";
  5.                         break;
复制代码


在下面加上 (注意先填妥红字部份)
由于使用快取档型式, 故某些私密区不能判断会员权限来显示发帖及回帖, 所以要先修改及取代下红字部份 "填上需要显示回帖区域的 fid 编号, 以逗号作分格, 最后一个不用加上逗号" 部份, 例如希望显示 fid 1,3,5 便填上 "$fids="1,3,5";"

  1.                 case newtopic:
  2.                         $table = 'threads t, cdb_forums f';
  3.                         $cols = "t.tid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name";
  4.                         $fids="填上需要显示发新帖区域的 fid 编号, 以逗号作分格, 最后一个不用加上逗号";//例如 "1,2,3";
  5.                         $conditions = "WHERE t.fid<>'$fid' AND f.fid=t.fid AND f.fid IN ($fids) ORDER BY t.dateline DESC LIMIT 0, 11";
  6.                         break;
  7.                 case newreply:
  8.                         $table = 'threads t, cdb_forums f';
  9.                         $cols = "t.tid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name";
  10.                         $fids="填上需要显示回帖区域的 fid 编号, 以逗号作分格, 最后一个不用加上逗号";//例如 "1,2,3";
  11.                         $conditions = "WHERE t.fid<>'$fid' AND f.fid=t.fid AND f.fid IN ($fids) AND  t.replies !=0 ORDER BY t.lastpost DESC LIMIT 0, 11";
  12.                         break;
  13.                 case todayvisit:
  14.                         $table = 'members';
  15.                         $cols = "COUNT(*)";
  16.                         $datecut = time() - (3600 * 24);
  17.                         $conditions = "WHERE lastactivity>='$datecut' ORDER BY lastvisit DESC";
  18.                         break;
复制代码





  1. $GLOBALS['totlamembers'] = $data['totalmembers'] = $db->result($query, 0);
复制代码


在下面加上

  1.                         $datecut = time() - (3600 * 24);
  2.                         $query = $db->query("SELECT COUNT(*) FROM {$tablepre}members WHERE regdate>='$datecut'");
  3.                         $GLOBALS['todaynewmems'] = $data['todaynewmems'] = $db->result($query, 0);
复制代码


2. 修改 include/newthread.inc.php



  1. $allowuseblog && $isblog && $blog ? showmessage('post_newthread_blog_succeed', "blog.php?tid=$tid")
复制代码


在上面加上

  1.         require $discuz_root.'./include/cache.func.php';
  2.         updatecache('newtopic');
复制代码


3. 修改 include/newreply.inc.php



  1. !$allowuseblog || empty($isblog) ? showmessage('post_reply_succeed',
复制代码


在上面加上

  1.         require $discuz_root.'./include/cache.func.php';
  2.         updatecache('newreply');
  3.         updatecache('newtopic');
复制代码


4. 修改 include/counter.inc.php



  1. if(!$sessionexists) {
  2.         if(strpos($visitor['agent'], 'MSIE')) {
  3.                 $visitor['browser'] = 'MSIE';
  4.         } elseif(strpos($visitor['agent'], 'Netscape')) {
  5.                 $visitor['browser'] = 'Netscape';
  6.         } elseif(strpos($visitor['agent'], 'Lynx')) {
  7.                 $visitor['browser'] = 'Lynx';
  8.         } elseif(strpos($visitor['agent'], 'Opera')) {
  9.                 $visitor['browser'] = 'Opera';
  10.         } elseif(strpos($visitor['agent'], 'Konqueror')) {
  11.                 $visitor['browser'] = 'Konqueror';
  12.         } elseif(substr($visitor['agent'], 0, 7) == 'Mozilla') {
  13.                 $visitor['browser'] = 'Mozilla';
  14.         } else {
  15.                 $visitor['browser'] = 'Other';
  16.         }

  17.         if(strpos($visitor['agent'], 'Win')) {
  18.                 $visitor['os'] = 'Windows';
  19.         } elseif(strpos($visitor['agent'], 'Mac')) {
  20.                 $visitor['os'] = 'Mac';
  21.         } elseif(strpos($visitor['agent'], 'Linux')) {
  22.                 $visitor['os'] = 'Linux';
  23.         } elseif(strpos($visitor['agent'], 'FreeBSD')) {
  24.                 $visitor['os'] = 'FreeBSD';
  25.         } elseif(strpos($visitor['agent'], 'SunOS')) {
  26.                 $visitor['os'] = 'SunOS';
  27.         } elseif(strpos($visitor['agent'], 'OS/2')) {
  28.                 $visitor['os'] = 'OS/2';
  29.         } elseif(strpos($visitor['agent'], 'AIX')) {
  30.                 $visitor['os'] = 'AIX';
  31.         } elseif(preg_match("/(Bot|Crawl|Spider)/i", $visitor['agent'])) {
  32.                 $visitor['os'] = 'Spiders';
  33.         } else {
  34.                 $visitor['os'] = 'Other';
  35.         }
复制代码


更换为

  1. if(!$sessionexists || $discuz_uid) {
  2. if(strpos($visitor['agent'], "MSIE 7.0")) {
  3.                 $visitor_browser = "Internet Explorer 7.0";
  4.                 $visitor['browser'] = 'MSIE';
  5.         } elseif(strpos($visitor['agent'], "MSIE 6.0")) {
  6.                 $visitor_browser = "Internet Explorer 6.0";
  7.                 $visitor['browser'] = 'MSIE';
  8.         } elseif(strpos($visitor['agent'], "MSIE 5.5")) {
  9.                 $visitor_browser = "Internet Explorer 5.5";
  10.                 $visitor['browser'] = 'MSIE';
  11.         } elseif(strpos($visitor['agent'], "MSIE 5.0")) {
  12.                 $visitor_browser = "Internet Explorer 5.0";
  13.                 $visitor['browser'] = 'MSIE';
  14.         } elseif(strpos($visitor['agent'], "MSIE 4.01")) {
  15.                 $visitor_browser = "Internet Explorer 4.01";
  16.                 $visitor['browser'] = 'MSIE';
  17.         } elseif(strpos($visitor['agent'], "Netscape")) {
  18.                 $visitor_browser = "Netscape";
  19.                 $visitor['browser'] = 'Netscape';
  20.         } elseif(strpos($visitor['agent'], "Lynx")) {
  21.                 $visitor_browser = "Lynx";
  22.                 $visitor['browser'] = 'Lynx';
  23.         } elseif(strpos($visitor['agent'], "Opera")) {
  24.                 $visitor_browser = "Opera";
  25.                 $visitor['browser'] = 'Opera';
  26.         } elseif(strpos($visitor['agent'], "Konqueror")) {
  27.                 $visitor_browser = "Konqueror";
  28.                 $visitor['browser'] = 'Konqueror';
  29.         } elseif(strpos($visitor['agent'], "Firefox")) {
  30.                 $visitor_browser = "Firefox";
  31.                 $visitor['browser'] = 'Mozilla';
  32.         } elseif(strpos($visitor['agent'], "Mozilla/5.0")) {
  33.                 $visitor_browser = "Mozilla";
  34.                 $visitor['browser'] = 'Mozilla';
  35.         } else {
  36.                 $visitor_browser = "其它";
  37.                 $visitor['browser'] = 'Other';
  38.         }

  39.         if(strpos($visitor['agent'], "NT 5.1")) {
  40.         if(strpos($visitor['agent'], "SV1")){
  41.                 $visitor_os = "Windows XP SP2";
  42.                 $visitor['os'] = 'Windows';
  43.         }else{
  44.                 $visitor_os = "Windows XP";
  45.                 $visitor['os'] = 'Windows';
  46.         }
  47.         }elseif(strpos($visitor['agent'], "NT 6.0")) {
  48.                 $visitor_os = "Win Vista";
  49.                 $visitor['os'] = 'Windows';
  50.         }elseif(strpos($visitor['agent'], "NT 5.2")) {
  51.                 $visitor_os = "Windows Server 2003";
  52.                 $visitor['os'] = 'Windows';
  53.         }elseif(strpos($visitor['agent'], "NT 5")) {
  54.                 $visitor_os = "Windows 2000";
  55.                 $visitor['os'] = 'Windows';
  56.         } elseif(strpos($visitor['agent'], "4.9")) {
  57.                 $visitor_os = "Windows ME";
  58.                 $visitor['os'] = 'Windows';
  59.         } elseif(strpos($visitor['agent'], "NT 4")) {
  60.                 $visitor_os = "Windows NT 4.0";
  61.                 $visitor['os'] = 'Windows';
  62.         } elseif(strpos($visitor['agent'], "98")) {
  63.                 $visitor_os = "Windows 98";
  64.                 $visitor['os'] = 'Windows';
  65.         } elseif(strpos($visitor['agent'], "95")) {
  66.                 $visitor_os = "Windows 95";
  67.                 $visitor['os'] = 'Windows';
  68.         } elseif(strpos($visitor['agent'], "Mac")) {
  69.                 $visitor_os = "Mac";
  70.                 $visitor['os'] = 'Mac';
  71.         } elseif(strpos($visitor['agent'], "Linux")) {
  72.                 $visitor_os = "Linux";
  73.                 $visitor['os'] = 'Linux';
  74.         } elseif(strpos($visitor['agent'], "Unix")) {
  75.                 $visitor_os = "Unix";
  76.                 $visitor['os'] = 'Other';
  77.         } elseif(strpos($visitor['agent'], "FreeBSD")) {
  78.                 $visitor_os = "FreeBSD";
  79.                 $visitor['os'] = 'FreeBSD';
  80.         } elseif(strpos($visitor['agent'], "SunOS")) {
  81.                 $visitor_os = "SunOS";
  82.                 $visitor['os'] = 'SunOS';
  83.         } elseif(strpos($visitor['agent'], "OS/2")) {
  84.                 $visitor_os = "OS/2";
  85.                 $visitor['os'] = 'OS/2';
  86.         }elseif(strpos($visitor['agent'], "AIX")) {
  87.                 $visitor_os = "AIX";
  88.                 $visitor['os'] = 'AIX';
  89.         } elseif(preg_match("/(Bot|Crawl|Spider)/i", $visitor['agent'])) {
  90.                 $visitor_os = "Spiders";
  91.                 $visitor['os'] = 'Spiders';
  92.         } else {
  93.                 $visitor_os = "其他";
  94.                 $visitor['os'] = 'Other';
  95.         }
复制代码


5. 修改 topicadmin.php

找到及删除 (共三处)

  1. require_once DISCUZ_ROOT.'./include/cache.func.php';
复制代码




  1. require_once './include/common.inc.php';
复制代码


在下面加上

  1. require_once DISCUZ_ROOT.'./include/cache.func.php';
复制代码




  1. $db->query("UPDATE {$tablepre}threads SET author='$fpost[author]', authorid='$fpost[authorid]', dateline='$fpost[dateline]', rate='".intval(@($fpost['rate'] / abs($fpost['rate'])))."', moderated='1' WHERE tid='$newtid'");
复制代码


在下面加上

  1.                         updatecache('newreply');
  2.                         updatecache('newtopic');
复制代码




  1. showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'), $resultarray['redirect']);
复制代码


在上面加上

  1.                         updatecache('newreply');
  2.                         updatecache('newtopic');
复制代码


6. 修改 logging.php



  1. $sessionexists = 0;
复制代码


在下面加上

  1.                                 require_once DISCUZ_ROOT.'./include/cache.func.php';
  2.                                 updatecache('todayvisit');
复制代码


7. 修改 index.php



  1. $newthreads = round(($timestamp - $lastvisit + 600) / 1000) * 1000;
复制代码


在下面加上

  1. //-----------hack AL8 Info
  2. require_once DISCUZ_ROOT.'./include/counter.inc.php';
  3. require_once DISCUZ_ROOT.'./include/misc.func.php';
  4. $mem_home = convertip($onlineip, $datadir = "./");
  5. require_once DISCUZ_ROOT.'./forumdata/cache/cache_todayvisit.php';
  6. $todayvisit=$_DCACHE['todayvisit']['0']['COUNT(*)'] ;
  7. $hack_cut_str = 26;
  8. $new_post_threadlist = array();
  9. $nthread = array();
  10. $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
  11. require_once './forumdata/cache/cache_newtopic.php';
  12. foreach($_DCACHE['newtopic'] as $nthread) {
  13.         $nthread['forumname'] = $nthread['name'];
  14.         $nthread['view_subject'] = cutstr($nthread['subject'],$hack_cut_str);
  15.         $nthread['subject'] = cutstr($nthread['subject'],46);
  16. $nthread['date']= gmdate("$dateformat $timeformat", $nthread['dateline'] + $timeoffset * 3600);
  17.         $nthread['lastreplytime']= gmdate("$dateformat $timeformat", $nthread[lastpost] + ($timeoffset * 3600));
  18. if($nthread['highlight']) {
  19.         $string = sprintf('%02d', $nthread['highlight']);
  20.         $stylestr = sprintf('%03b', $string[0]);
  21.         $nthread['highlight'] = 'style="';
  22.         $nthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
  23.         $nthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
  24.         $nthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
  25.         $nthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
  26.         $nthread['highlight'] .= '"';
  27.     } else {
  28.         $nthread['highlight'] = '';
  29.     }
  30.         $new_post_threadlist[] = $nthread;
  31. }
  32.         unset($_DCACHE['newtopic']);


  33. $hack_cut_str = 26;
  34. $new_reply_threadlist = array();
  35. $rthread = array();
  36. $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');

  37. require_once './forumdata/cache/cache_newreply.php';
  38. foreach($_DCACHE['newreply'] as $rthread) {
  39.         $rthread['forumname'] = $rthread['name'];
  40.         $rthread['view_subject'] = cutstr($rthread['subject'],$hack_cut_str);
  41.         $rthread['subject'] = cutstr($rthread['subject'],46);
  42. $rthread['date']= gmdate("$dateformat $timeformat", $rthread['dateline'] + $timeoffset * 3600);
  43.         $rthread['lastreplytime']= gmdate("$dateformat $timeformat", $rthread[lastpost] + ($timeoffset * 3600));
  44. if($rthread['highlight']) {
  45.         $string = sprintf('%02d', $rthread['highlight']);
  46.         $stylestr = sprintf('%03b', $string[0]);
  47.         $rthread['highlight'] = 'style="';
  48.         $rthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
  49.         $rthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
  50.         $rthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
  51.         $rthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
  52.         $rthread['highlight'] .= '"';
  53.     } else {
  54.         $rthread['highlight'] = '';
  55.     }
  56.         $new_reply_threadlist[] = $rthread;
  57. }
  58.         unset($_DCACHE['newreply']);
  59. //-----------hack AL8 Info End
复制代码


8. 修改 index 模板



  1. <table cellspacing="{TABLESPACE}" cellpadding="0" border="0" width="{TABLEWIDTH}" align="center" class="outertxt">
  2. <tr><td class="smalltxt">
  3. {lang timenow} $currenttime, {lang your_lastvisit} $lastvisittime<br>
  4. {lang credits}: <span class="bold">$credits</span>
  5. <!--{loop $extcredits $id $credit}-->
  6.         $credit[title]: <span class="bold">$GLOBALS[extcredits.$id]</span>$credit[unit]
  7. <!--{/loop}-->
  8. / {lang index_status}:
  9. <!--{if $validdays}--><a href="member.php?action=groupexpiry"><span class="bold">$grouptitle</span>($validdays)</a><!--{else}--><span class="bold">$grouptitle</span><!--{/if}-->
  10. <!--{if !empty($invisible)}--> / {lang login_invisible_mode}<!--{/if}-->
  11. </td><td align="right" nowrap class="smalltxt">
  12. <a href="search.php?srchfrom=$newthreads&searchsubmit=yes">{lang show_newthreads}</a> |
  13. <!--{if $discuz_uid}-->
  14.         <a href="search.php?srchuid=$discuz_uid&mytopics=yes&searchsubmit=yes">{lang show_mytopics}</a> |
  15.         <!--{if $allowuseblog}-->
  16.                 <a href="blog.php?uid=$discuz_uid" target="_blank">{lang blog}</a> |
  17.         <!--{/if}-->
  18. <!--{/if}-->
  19. <a href="digest.php">{lang digest}</a> |
  20. <a href="member.php?action=markread">{lang mark_read}</a>
  21. | {lang welcome_newmember} <a href="viewpro.php?username=$memberenc"><span class="bold">$lastmember</span></a><br>
  22. {lang total} <span class="bold">$threads</span> {lang index_threads} / <span class="bold">$posts</span> {lang index_posts} / {lang index_today} <span class="bold">$todayposts</span> {lang index_posts} / <span class="bold">$totalmembers</span> {lang index_members}
  23. </td></tr></table>

  24. <!--{if empty($gid)}-->
  25.         <table cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="{TABLEWIDTH}" align="center" class="tableborder">
  26.         <tr class="header"><td colspan="3">$bbname {lang index_announcements}</td></tr>
  27.         <tr class="altbg2" align="center">
  28.         <td colspan="3" align="center">
  29.         <!--{if empty($announcements)}-->
  30.                 {lang index_noannouncement}
  31.         <!--{else}-->
  32.                 <marquee direction="left" scrollamount="3" onMouseOver="this.stop();" onMouseOut="this.start();">
  33.                 $announcements
  34.                 </marquee>
  35.         <!--{/if}-->
  36.         </td></tr></table><br>
  37. <!--{/if}-->
复制代码


更换为

  1. <!--{if empty($gid)}-->
  2. {template foruminfo}<br>
  3. <!--{/if}-->
复制代码


9. 下载附件 foruminfo.rar 及解压为 foruminfo.htm, 并打开

a. 根据自身讨论区对下一段作出调整



来自 $mem_home 的访客, 现{lang register}成为会员即获赠现金 100 点, 用作参予本讨论区的活动之用。




b. 上载至 templates/default 目录下

~完成~

[ 本帖最后由 freddy 于 2006-2-13 12:44 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
 楼主| freddy 发表于 2006-2-9 10:40:49 | 显示全部楼层
更新用
回复

使用道具 举报

麦田-1979 发表于 2006-2-9 10:41:13 | 显示全部楼层
支持先~~


我现在用的增加查询,缓存版的降低发回帖速度。。。各有利弊,真是难以取舍阿

[ 本帖最后由 kwxbbs 于 2006-2-9 10:50 编辑 ]
回复

使用道具 举报

麦田-1979 发表于 2006-2-9 10:43:24 | 显示全部楼层
差一秒钟没坐到沙发,下次努力~~~
回复

使用道具 举报

紫云杉 发表于 2006-2-9 10:44:06 | 显示全部楼层
支持下

[ 本帖最后由 紫云杉 于 2006-2-9 10:47 编辑 ]
回复

使用道具 举报

tianyo 发表于 2006-2-9 10:51:27 | 显示全部楼层
先支持一下先!
回复

使用道具 举报

孤情一刀 发表于 2006-2-9 10:53:06 | 显示全部楼层
支持!
回复

使用道具 举报

hklcf 发表于 2006-2-9 11:02:46 | 显示全部楼层
占位
回复

使用道具 举报

karl907 发表于 2006-2-9 11:05:36 | 显示全部楼层
地下停車場。。廣告位1!
回复

使用道具 举报

magicdream 发表于 2006-2-9 11:37:43 | 显示全部楼层
麻烦啊,不用了,支持一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-5-19 05:34 , Processed in 0.114204 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表