作 者: 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
修改完成此文件后请即时到后台→更新缓存
找
- 'medals' => array('medals')
复制代码
更换为
- 'medals' => array('medals'),
- 'newtopic' => array('newtopic'),
- 'newreply' => array('newreply'),
- 'todayvisit' => array('todayvisit')
复制代码
再找
- case 'medals':
- $table = 'medals';
- $cols = 'medalid, name, image';
- $conditions = "WHERE available='1'";
- break;
复制代码
在下面加上 (注意先填妥红字部份)
由于使用快取档型式, 故某些私密区不能判断会员权限来显示发帖及回帖, 所以要先修改及取代下红字部份 "填上需要显示回帖区域的 fid 编号, 以逗号作分格, 最后一个不用加上逗号" 部份, 例如希望显示 fid 1,3,5 便填上 "$fids="1,3,5";"
- case newtopic:
- $table = 'threads t, cdb_forums f';
- $cols = "t.tid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name";
- $fids="填上需要显示发新帖区域的 fid 编号, 以逗号作分格, 最后一个不用加上逗号";//例如 "1,2,3";
- $conditions = "WHERE t.fid<>'$fid' AND f.fid=t.fid AND f.fid IN ($fids) ORDER BY t.dateline DESC LIMIT 0, 11";
- break;
- case newreply:
- $table = 'threads t, cdb_forums f';
- $cols = "t.tid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name";
- $fids="填上需要显示回帖区域的 fid 编号, 以逗号作分格, 最后一个不用加上逗号";//例如 "1,2,3";
- $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";
- break;
- case todayvisit:
- $table = 'members';
- $cols = "COUNT(*)";
- $datecut = time() - (3600 * 24);
- $conditions = "WHERE lastactivity>='$datecut' ORDER BY lastvisit DESC";
- break;
复制代码
找
- $GLOBALS['totlamembers'] = $data['totalmembers'] = $db->result($query, 0);
复制代码
在下面加上
- $datecut = time() - (3600 * 24);
- $query = $db->query("SELECT COUNT(*) FROM {$tablepre}members WHERE regdate>='$datecut'");
- $GLOBALS['todaynewmems'] = $data['todaynewmems'] = $db->result($query, 0);
复制代码
2. 修改 include/newthread.inc.php
找
- $allowuseblog && $isblog && $blog ? showmessage('post_newthread_blog_succeed', "blog.php?tid=$tid")
复制代码
在上面加上
- require $discuz_root.'./include/cache.func.php';
- updatecache('newtopic');
复制代码
3. 修改 include/newreply.inc.php
找
- !$allowuseblog || empty($isblog) ? showmessage('post_reply_succeed',
复制代码
在上面加上
- require $discuz_root.'./include/cache.func.php';
- updatecache('newreply');
- updatecache('newtopic');
复制代码
4. 修改 include/counter.inc.php
找
- if(!$sessionexists) {
- if(strpos($visitor['agent'], 'MSIE')) {
- $visitor['browser'] = 'MSIE';
- } elseif(strpos($visitor['agent'], 'Netscape')) {
- $visitor['browser'] = 'Netscape';
- } elseif(strpos($visitor['agent'], 'Lynx')) {
- $visitor['browser'] = 'Lynx';
- } elseif(strpos($visitor['agent'], 'Opera')) {
- $visitor['browser'] = 'Opera';
- } elseif(strpos($visitor['agent'], 'Konqueror')) {
- $visitor['browser'] = 'Konqueror';
- } elseif(substr($visitor['agent'], 0, 7) == 'Mozilla') {
- $visitor['browser'] = 'Mozilla';
- } else {
- $visitor['browser'] = 'Other';
- }
- if(strpos($visitor['agent'], 'Win')) {
- $visitor['os'] = 'Windows';
- } elseif(strpos($visitor['agent'], 'Mac')) {
- $visitor['os'] = 'Mac';
- } elseif(strpos($visitor['agent'], 'Linux')) {
- $visitor['os'] = 'Linux';
- } elseif(strpos($visitor['agent'], 'FreeBSD')) {
- $visitor['os'] = 'FreeBSD';
- } elseif(strpos($visitor['agent'], 'SunOS')) {
- $visitor['os'] = 'SunOS';
- } elseif(strpos($visitor['agent'], 'OS/2')) {
- $visitor['os'] = 'OS/2';
- } elseif(strpos($visitor['agent'], 'AIX')) {
- $visitor['os'] = 'AIX';
- } elseif(preg_match("/(Bot|Crawl|Spider)/i", $visitor['agent'])) {
- $visitor['os'] = 'Spiders';
- } else {
- $visitor['os'] = 'Other';
- }
复制代码
更换为
- if(!$sessionexists || $discuz_uid) {
- if(strpos($visitor['agent'], "MSIE 7.0")) {
- $visitor_browser = "Internet Explorer 7.0";
- $visitor['browser'] = 'MSIE';
- } elseif(strpos($visitor['agent'], "MSIE 6.0")) {
- $visitor_browser = "Internet Explorer 6.0";
- $visitor['browser'] = 'MSIE';
- } elseif(strpos($visitor['agent'], "MSIE 5.5")) {
- $visitor_browser = "Internet Explorer 5.5";
- $visitor['browser'] = 'MSIE';
- } elseif(strpos($visitor['agent'], "MSIE 5.0")) {
- $visitor_browser = "Internet Explorer 5.0";
- $visitor['browser'] = 'MSIE';
- } elseif(strpos($visitor['agent'], "MSIE 4.01")) {
- $visitor_browser = "Internet Explorer 4.01";
- $visitor['browser'] = 'MSIE';
- } elseif(strpos($visitor['agent'], "Netscape")) {
- $visitor_browser = "Netscape";
- $visitor['browser'] = 'Netscape';
- } elseif(strpos($visitor['agent'], "Lynx")) {
- $visitor_browser = "Lynx";
- $visitor['browser'] = 'Lynx';
- } elseif(strpos($visitor['agent'], "Opera")) {
- $visitor_browser = "Opera";
- $visitor['browser'] = 'Opera';
- } elseif(strpos($visitor['agent'], "Konqueror")) {
- $visitor_browser = "Konqueror";
- $visitor['browser'] = 'Konqueror';
- } elseif(strpos($visitor['agent'], "Firefox")) {
- $visitor_browser = "Firefox";
- $visitor['browser'] = 'Mozilla';
- } elseif(strpos($visitor['agent'], "Mozilla/5.0")) {
- $visitor_browser = "Mozilla";
- $visitor['browser'] = 'Mozilla';
- } else {
- $visitor_browser = "其它";
- $visitor['browser'] = 'Other';
- }
- if(strpos($visitor['agent'], "NT 5.1")) {
- if(strpos($visitor['agent'], "SV1")){
- $visitor_os = "Windows XP SP2";
- $visitor['os'] = 'Windows';
- }else{
- $visitor_os = "Windows XP";
- $visitor['os'] = 'Windows';
- }
- }elseif(strpos($visitor['agent'], "NT 6.0")) {
- $visitor_os = "Win Vista";
- $visitor['os'] = 'Windows';
- }elseif(strpos($visitor['agent'], "NT 5.2")) {
- $visitor_os = "Windows Server 2003";
- $visitor['os'] = 'Windows';
- }elseif(strpos($visitor['agent'], "NT 5")) {
- $visitor_os = "Windows 2000";
- $visitor['os'] = 'Windows';
- } elseif(strpos($visitor['agent'], "4.9")) {
- $visitor_os = "Windows ME";
- $visitor['os'] = 'Windows';
- } elseif(strpos($visitor['agent'], "NT 4")) {
- $visitor_os = "Windows NT 4.0";
- $visitor['os'] = 'Windows';
- } elseif(strpos($visitor['agent'], "98")) {
- $visitor_os = "Windows 98";
- $visitor['os'] = 'Windows';
- } elseif(strpos($visitor['agent'], "95")) {
- $visitor_os = "Windows 95";
- $visitor['os'] = 'Windows';
- } elseif(strpos($visitor['agent'], "Mac")) {
- $visitor_os = "Mac";
- $visitor['os'] = 'Mac';
- } elseif(strpos($visitor['agent'], "Linux")) {
- $visitor_os = "Linux";
- $visitor['os'] = 'Linux';
- } elseif(strpos($visitor['agent'], "Unix")) {
- $visitor_os = "Unix";
- $visitor['os'] = 'Other';
- } elseif(strpos($visitor['agent'], "FreeBSD")) {
- $visitor_os = "FreeBSD";
- $visitor['os'] = 'FreeBSD';
- } elseif(strpos($visitor['agent'], "SunOS")) {
- $visitor_os = "SunOS";
- $visitor['os'] = 'SunOS';
- } elseif(strpos($visitor['agent'], "OS/2")) {
- $visitor_os = "OS/2";
- $visitor['os'] = 'OS/2';
- }elseif(strpos($visitor['agent'], "AIX")) {
- $visitor_os = "AIX";
- $visitor['os'] = 'AIX';
- } elseif(preg_match("/(Bot|Crawl|Spider)/i", $visitor['agent'])) {
- $visitor_os = "Spiders";
- $visitor['os'] = 'Spiders';
- } else {
- $visitor_os = "其他";
- $visitor['os'] = 'Other';
- }
复制代码
5. 修改 topicadmin.php
找到及删除 (共三处)
- require_once DISCUZ_ROOT.'./include/cache.func.php';
复制代码
找
- require_once './include/common.inc.php';
复制代码
在下面加上
- require_once DISCUZ_ROOT.'./include/cache.func.php';
复制代码
找
- $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'");
复制代码
在下面加上
- updatecache('newreply');
- updatecache('newtopic');
复制代码
找
- showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'), $resultarray['redirect']);
复制代码
在上面加上
- updatecache('newreply');
- updatecache('newtopic');
复制代码
6. 修改 logging.php
找
在下面加上
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('todayvisit');
复制代码
7. 修改 index.php
找
- $newthreads = round(($timestamp - $lastvisit + 600) / 1000) * 1000;
复制代码
在下面加上
- //-----------hack AL8 Info
- require_once DISCUZ_ROOT.'./include/counter.inc.php';
- require_once DISCUZ_ROOT.'./include/misc.func.php';
- $mem_home = convertip($onlineip, $datadir = "./");
- require_once DISCUZ_ROOT.'./forumdata/cache/cache_todayvisit.php';
- $todayvisit=$_DCACHE['todayvisit']['0']['COUNT(*)'] ;
- $hack_cut_str = 26;
- $new_post_threadlist = array();
- $nthread = array();
- $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
- require_once './forumdata/cache/cache_newtopic.php';
- foreach($_DCACHE['newtopic'] as $nthread) {
- $nthread['forumname'] = $nthread['name'];
- $nthread['view_subject'] = cutstr($nthread['subject'],$hack_cut_str);
- $nthread['subject'] = cutstr($nthread['subject'],46);
- $nthread['date']= gmdate("$dateformat $timeformat", $nthread['dateline'] + $timeoffset * 3600);
- $nthread['lastreplytime']= gmdate("$dateformat $timeformat", $nthread[lastpost] + ($timeoffset * 3600));
- if($nthread['highlight']) {
- $string = sprintf('%02d', $nthread['highlight']);
- $stylestr = sprintf('%03b', $string[0]);
- $nthread['highlight'] = 'style="';
- $nthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
- $nthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
- $nthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
- $nthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
- $nthread['highlight'] .= '"';
- } else {
- $nthread['highlight'] = '';
- }
- $new_post_threadlist[] = $nthread;
- }
- unset($_DCACHE['newtopic']);
- $hack_cut_str = 26;
- $new_reply_threadlist = array();
- $rthread = array();
- $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
- require_once './forumdata/cache/cache_newreply.php';
- foreach($_DCACHE['newreply'] as $rthread) {
- $rthread['forumname'] = $rthread['name'];
- $rthread['view_subject'] = cutstr($rthread['subject'],$hack_cut_str);
- $rthread['subject'] = cutstr($rthread['subject'],46);
- $rthread['date']= gmdate("$dateformat $timeformat", $rthread['dateline'] + $timeoffset * 3600);
- $rthread['lastreplytime']= gmdate("$dateformat $timeformat", $rthread[lastpost] + ($timeoffset * 3600));
- if($rthread['highlight']) {
- $string = sprintf('%02d', $rthread['highlight']);
- $stylestr = sprintf('%03b', $string[0]);
- $rthread['highlight'] = 'style="';
- $rthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
- $rthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
- $rthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
- $rthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
- $rthread['highlight'] .= '"';
- } else {
- $rthread['highlight'] = '';
- }
- $new_reply_threadlist[] = $rthread;
- }
- unset($_DCACHE['newreply']);
- //-----------hack AL8 Info End
复制代码
8. 修改 index 模板
找
- <table cellspacing="{TABLESPACE}" cellpadding="0" border="0" width="{TABLEWIDTH}" align="center" class="outertxt">
- <tr><td class="smalltxt">
- {lang timenow} $currenttime, {lang your_lastvisit} $lastvisittime<br>
- {lang credits}: <span class="bold">$credits</span>
- <!--{loop $extcredits $id $credit}-->
- $credit[title]: <span class="bold">$GLOBALS[extcredits.$id]</span>$credit[unit]
- <!--{/loop}-->
- / {lang index_status}:
- <!--{if $validdays}--><a href="member.php?action=groupexpiry"><span class="bold">$grouptitle</span>($validdays)</a><!--{else}--><span class="bold">$grouptitle</span><!--{/if}-->
- <!--{if !empty($invisible)}--> / {lang login_invisible_mode}<!--{/if}-->
- </td><td align="right" nowrap class="smalltxt">
- <a href="search.php?srchfrom=$newthreads&searchsubmit=yes">{lang show_newthreads}</a> |
- <!--{if $discuz_uid}-->
- <a href="search.php?srchuid=$discuz_uid&mytopics=yes&searchsubmit=yes">{lang show_mytopics}</a> |
- <!--{if $allowuseblog}-->
- <a href="blog.php?uid=$discuz_uid" target="_blank">{lang blog}</a> |
- <!--{/if}-->
- <!--{/if}-->
- <a href="digest.php">{lang digest}</a> |
- <a href="member.php?action=markread">{lang mark_read}</a>
- | {lang welcome_newmember} <a href="viewpro.php?username=$memberenc"><span class="bold">$lastmember</span></a><br>
- {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}
- </td></tr></table>
- <!--{if empty($gid)}-->
- <table cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="{TABLEWIDTH}" align="center" class="tableborder">
- <tr class="header"><td colspan="3">$bbname {lang index_announcements}</td></tr>
- <tr class="altbg2" align="center">
- <td colspan="3" align="center">
- <!--{if empty($announcements)}-->
- {lang index_noannouncement}
- <!--{else}-->
- <marquee direction="left" scrollamount="3" onMouseOver="this.stop();" onMouseOut="this.start();">
- $announcements
- </marquee>
- <!--{/if}-->
- </td></tr></table><br>
- <!--{/if}-->
复制代码
更换为
- <!--{if empty($gid)}-->
- {template foruminfo}<br>
- <!--{/if}-->
复制代码
9. 下载附件 foruminfo.rar 及解压为 foruminfo.htm, 并打开
a. 根据自身讨论区对下一段作出调整
来自 $mem_home 的访客, 现{lang register}成为会员即获赠现金 100 点, 用作参予本讨论区的活动之用。
b. 上载至 templates/default 目录下
~完成~
[ 本帖最后由 freddy 于 2006-2-13 12:44 编辑 ] |