请大家小心小心再小心。仔细仔细再仔细。。错误的出现多半是因为你的粗心造成的.
所有代码已经重新编辑。整理,去掉多余的空格和回车.请2006年09月04号中午12点钟之前修改后有BUG的站长们重新对照修改;
请大家一定要备份需要修改的文件!!! 不想备份请不要进行任何修改。。。。。
=============================================================
插件安装步骤:
(后台"论坛功能"设置内添加开关),下面"编辑文件admin/settings.inc.php"中的代码。还有最后修改DISCUZ.HTM时候的代码都是用来在后台控制是否显示发帖冠军,而且我在后台亲自试验成功,确实是带后台的。如果你不想让他在前台显示。请在后台设定以后。记得更新缓存)
如果不想要后台控制的话,可以跳过1-3步
1.后台升级数据库(在cdb_settings添加一个show_poststar一个值)
- INSERT INTO `cdb_settings` VALUES ('show_poststar', '1');
复制代码
2.编辑文件admin/settings.inc.php
查找:- showsetting('settings_nocacheheaders', 'settingsnew[nocacheheaders]', $settings['nocacheheaders'], 'radio');
复制代码
下面添加:
- showsetting('settings_show_poststar', 'settingsnew[show_poststar]', $settings['show_poststar'], 'radio');
复制代码
3,编辑语言包admincp.lang.php(后台管理页面显示的文字)
查找:- 'settings_forumjump_comment' => '选择“是”将在列表页面下部显示快捷跳转菜单。注意: 当分论坛很多时,本功能会严重加重服务器负担',
复制代码
下面添加:
- 'settings_show_poststar' => '显示发帖冠军',
- 'settings_show_poststar_comment' => '选则“是”将在首页显示发帖冠军',
复制代码
4. 编辑文件 include/cache.func.php
查找
- 'medals' => array('medals')
复制代码
上面加
- 'toplist' => array('newthread', 'newreply', 'topdigest', 'topviews'),//TOPLIST_首页四格_全Cache版_By oytktk
- 'poststar' => array('daystar', 'yestodaystar','weekstar', 'monthstar', 'yearstar'),
复制代码
继续查找
- case 'medals':
- $table = 'medals';
- $cols = 'medalid, name, image';
- $conditions = "WHERE available='1'";
- break;
复制代码
上面加
- //首页四格TOPLIST_CACHE版, By oytktk 代码首
- case 'newthread':
- $table = 'threads t';
- $cols = 't.tid, t.fid, t.author, t.subject, t.dateline, t.lastpost, t.lastposter, t.views, t.replies, t.highlight, f.name';
- $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE t.displayorder!='-1' ORDER BY t.dateline DESC LIMIT 0, 10";
- break;
- case 'newreply':
- $table = 'threads t';
- $cols = 't.tid, t.fid, t.author, t.subject, t.dateline, t.lastpost, t.lastposter, t.views, t.replies, t.highlight, f.name';
- $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE t.replies>0 and t.displayorder!='-1' ORDER BY t.lastpost DESC LIMIT 0, 10";
- break;
- case 'topdigest':
- $table = 'threads t';
- $cols = 't.tid, t.fid, t.author, t.subject, t.digest, t.dateline, t.lastpost, t.lastposter, t.views, t.replies, t.highlight,f.name';
- $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE digest>0 ORDER BY rand() LIMIT 0, 10";
- break;
-
- case 'topviews':
- $table = 'threads t';
- $view = rand(1,3)==1 ? 'views' : 'replies';
- $cols = 't.tid, t.fid, t.author, t.subject, t.dateline, t.lastpost, t.lastposter, t.views, t.replies, t.highlight, f.name';
- $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE t.displayorder!='-1' ORDER BY t.$view DESC LIMIT 0, 10";
- break;
- //首页四格TOPLIST_CACHE版, By oytktk 代码尾
- //===============社区明星BY 33201 开始
- case 'daystar':
- $month=date(n);
- $date=date(j);
- $year=date(Y);
- $time=mktime(0,0,0,$month,$date,$year);
- $table = 'posts p';
- $cols = 'count(p.pid) as num,p.author,p.authorid,m.uid,m.credits,m.posts,m.digestposts,me.avatar,m.oltime,me.avatarwidth,me.avatarheight';
- $conditions = "left join {$tablepre}members m on p.authorid=m.uid left join {$tablepre}memberfields me on p.authorid=me.uid where p.dateline>$time group by p.authorid order by num desc limit 0,10";
- break;
- case 'yestodaystar':
- $month=date(n);
- $date=date(j);
- $year=date(Y);
- $time=mktime(0,0,0,$month,$date,$year);
- $ytime=mktime(0,0,0,$month,$date-1,$year);
- $table = 'posts p';
- $cols = 'count(p.pid) as num,p.author,p.authorid,m.uid,m.credits,m.posts,m.digestposts,me.avatar,m.oltime,me.avatarwidth,me.avatarheight';
- $conditions = "left join {$tablepre}members m on p.authorid=m.uid left join {$tablepre}memberfields me on p.authorid=me.uid where p.dateline<=$time and p.dateline>$ytime group by p.authorid order by num desc limit 0,10";
- break;
- case 'weekstar':
- $month=date(n);
- $date=date(j);
- $year=date(Y);
- $week=date(w);
- $time=mktime(0,0,0,$month,$date,$year);
- $weektime=mktime(0,0,0,$month,$date-$week,$year);
- $table = 'posts p';
- $cols = 'count(p.pid) as num,p.author,p.authorid,m.uid,m.credits,m.posts,m.digestposts,me.avatar,m.oltime,me.avatarwidth,me.avatarheight';
- $conditions = "left join {$tablepre}members m on p.authorid=m.uid left join {$tablepre}memberfields me on p.authorid=me.uid where p.dateline>=$weektime group by p.authorid order by num desc limit 0,10";
- break;
- case 'monthstar':
- $month=date(n);
- $year=date(Y);
- $monthtime=mktime(0,0,0,$month,1,$year);
- $table = 'posts p';
- $cols = 'count(p.pid) as
- num,p.author,p.authorid,m.uid,m.credits,m.posts,m.digestposts,me.avatar,m.oltime,me.avatarwidth,me.avatarheight';
- $conditions = "left join {$tablepre}members m on p.authorid=m.uid left join {$tablepre}memberfields me on p.authorid=me.uid where p.dateline>=$monthtime group by p.authorid order by num desc limit 0,10";
- break;
-
- case 'yearstar':
- $year=date(Y);
- $yeartime=mktime(0,0,0,1,1,$year);
- $table = 'posts p';
- $cols = 'count(p.pid) as num,p.author,p.authorid,m.uid,m.credits,m.posts,m.digestposts,me.avatar,m.oltime,me.avatarwidth,me.avatarheight';
- $conditions = "left join {$tablepre}members m on p.authorid=m.uid left join {$tablepre}memberfields me on p.authorid=me.uid where p.dateline>=$yeartime group by p.authorid order by num desc limit 0,10";
- break;
- //===================社区明星BY 33201 结束
复制代码
再找:- case 'settings':
- $data['qihoo_links'] = array();
- while($setting = $db->fetch_array($query))
复制代码
上面加
- //首页四格TOPLIST_CACHE版, By oytktk 代码首
- case 'newthread':
- $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
- while($topthread = $db->fetch_array($query)) {
- $threadcolor = sprintf('%02d', $topthread['highlight']);
- $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
- $topthread['subjectc'] = cutstr($topthread['subject'], 28);
- $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
- $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $timeoffset * 3600);
- $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $timeoffset * 3600);
- $topthread['name'] = AddSlashes(strip_tags(trim($topthread['name'])));
- $data[] = $topthread;
- }
- break;
- case 'newreply':
- $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
- while($topthread = $db->fetch_array($query)) {
- $threadcolor = sprintf('%02d', $topthread['highlight']);
- $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
- $topthread['subjectc'] = cutstr($topthread['subject'], 26);
- $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
- $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $timeoffset * 3600);
- $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $timeoffset * 3600);
- $topthread['name'] = AddSlashes(strip_tags(trim($topthread['name'])));
- $data[] = $topthread;
- }
- break;
- case 'topdigest':
- $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
- while($topthread = $db->fetch_array($query)) {
- $threadcolor = sprintf('%02d', $topthread['highlight']);
- $digest = array('1'=>'[Ⅰ]','2'=>'[Ⅱ]','3'=>'[Ⅲ]');
- $topthread['subjectc'] = $digest[$topthread['digest']]."-".cutstr($topthread['subject'], 23);
- $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
- $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
- $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $timeoffset * 3600);
- $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $timeoffset * 3600);
- $topthread['name'] = AddSlashes(strip_tags(trim($topthread['name'])));
- $data[] = $topthread;
- }
- break;
- case 'topviews':
- $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
- while($topthread = $db->fetch_array($query)) {
- $threadcolor = sprintf('%02d', $topthread['highlight']);
- $topthread['subjectc'] = cutstr($topthread['subject'], 32);
- $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
- $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
- $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $timeoffset * 3600);
- $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $timeoffset * 3600);
- $topthread['name'] = AddSlashes(strip_tags(trim($topthread['name'])));
- $data[] = $topthread;
- }
- break;
- //首页四格TOPLIST_CACHE版, By oytktk 代码尾
- //===================社区明星BY 33201 开始
- case 'daystar':
- while($toppost = $db->fetch_array($query)) {
- $toppost['author'] = $toppost['author'] ? $toppost['author'] : '游客';
- $toppost['authorid'] = $toppost['authorid'] ? $toppost['authorid'] : '游客';
- $toppost['avatar'] = $toppost['avatar'] ? $toppost['avatar'] : 'images/nopic.gif';
- $toppost['avatarwidth'] = $toppost['avatarwidth'] ? $toppost['avatarwidth'] : '80';
- $toppost['avatarheight'] = $toppost['avatarheight'] ? $toppost['avatarheight'] : '80';
- $data[] = $toppost;
- }
- break;
- case 'yestodaystar':
- while($toppost = $db->fetch_array($query)) {
- $toppost['author'] = $toppost['author'] ? $toppost['author'] : '游客';
- $toppost['authorid'] = $toppost['authorid'] ? $toppost['authorid'] : '游客';
- $toppost['avatar'] = $toppost['avatar'] ? $toppost['avatar'] : 'images/nopic.gif';
- $toppost['avatarwidth'] = $toppost['avatarwidth'] ? $toppost['avatarwidth'] : '80';
- $toppost['avatarheight'] = $toppost['avatarheight'] ? $toppost['avatarheight'] : '80';
- $data[] = $toppost;
- }
- break;
- case 'weekstar':
- while($toppost = $db->fetch_array($query)) {
- $toppost['author'] = $toppost['author'] ? $toppost['author'] : '游客';
- $toppost['authorid'] = $toppost['authorid'] ? $toppost['authorid'] : '游客';
- $toppost['avatar'] = $toppost['avatar'] ? $toppost['avatar'] : 'images/nopic.gif';
- $toppost['avatarwidth'] = $toppost['avatarwidth'] ? $toppost['avatarwidth'] : '80';
- $toppost['avatarheight'] = $toppost['avatarheight'] ? $toppost['avatarheight'] : '80';
- $data[] = $toppost;
- }
- break;
- case 'monthstar':
- while($toppost = $db->fetch_array($query)) {
- $toppost['author'] = $toppost['author'] ? $toppost['author'] : '游客';
- $toppost['authorid'] = $toppost['authorid'] ? $toppost['authorid'] : '游客';
- $toppost['avatar'] = $toppost['avatar'] ? $toppost['avatar'] : 'images/nopic.gif';
- $toppost['avatarwidth'] = $toppost['avatarwidth'] ? $toppost['avatarwidth'] : '80';
- $toppost['avatarheight'] = $toppost['avatarheight'] ? $toppost['avatarheight'] : '80';
- $data[] = $toppost;
- }
- break;
- case 'yearstar':
- while($toppost = $db->fetch_array($query)) {
- $toppost['author'] = $toppost['author'] ? $toppost['author'] : '游客';
- $toppost['authorid'] = $toppost['authorid'] ? $toppost['authorid'] : '游客';
- $toppost['avatar'] = $toppost['avatar'] ? $toppost['avatar'] : 'images/nopic.gif';
- $toppost['avatarwidth'] = $toppost['avatarwidth'] ? $toppost['avatarwidth'] : '80';
- $toppost['avatarheight'] = $toppost['avatarheight'] ? $toppost['avatarheight'] : '80';
- $data[] = $toppost;
- }
- break;
- //=====================社区明星BY 33201 结束
复制代码
5. include/newthread.inc.php
查找
- updatepostcredits('+', $discuz_uid, $postcredits);
复制代码
下面加
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('newthread');
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('daystar');
复制代码
6. include/newreply.inc.php
查找
- updatepostcredits('+', $discuz_uid, $replycredits);
复制代码
下面加
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('newthread');
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('daystar');
复制代码 7. include/editpost.inc.php
查找
- updatepostcredits('-', $orig['authorid'], ($isfirstpost ? $postcredits : $replycredits));
复制代码
下面加
-
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('newthread');
复制代码
8. 编辑文件index.php
8.1查找
- $threads = $posts = $todayposts = $fids = 0;
复制代码
下面加
- //首页四格TOPLIST_CACHE版, By oytktk 代码首
- if(!isset($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'],
- 'category_hk2 ') === FALSE) {
- $categorys_hk2 = 'collapsed_no.gif';
- $collapse['category_hk2'] = '';
- } else {
- $categorys_hk2 = 'collapsed_yes.gif';
- $collapse['category_hk2'] = 'display: none';
- }
-
- if($categorys_hk2 == 'collapsed_no.gif'){
- require_once DISCUZ_ROOT.'./forumdata/cache/cache_toplist.php';
- $toplistloop = $_DCACHE['newthread'];
- }
- //首页四格TOPLIST_CACHE版, By oytktk 代码尾
复制代码
8.2 查找:
- require_once DISCUZ_ROOT.'./include/forum.func.php';
复制代码
下面添加:
- require_once DISCUZ_ROOT.'./forumdata/cache/cache_poststar.php';
- $month=date(n);
- $year=date(Y);
复制代码
8.3 查找:
- unset($_DCACHE['announcements']);
复制代码
下面添加:
- //========== 社区发帖明星 开始
- $nopoststar ='<td valign=top>姓名: 虚位以待! <br>积分:空<br>精华:空<br>今日发帖:空<br>总发帖量:空<br>在线时间:空<br></td><td width=16% align=center class=altbg1><IMG height=80 src="images/nopic.gif" width=80 align=center></td>';
- if($_DCACHE['daystar']) {
- foreach($_DCACHE['daystar'] as $key => $dstar) {
- if ($key<3){
- $daystars .="<td valign=top>姓名:".$dstar[author]."<br>积分:".$dstar[credits]."<br>精华:".$dstar[digestposts]."篇<br>今日发帖:".$dstar[num]."篇<br>总发帖量:".$dstar[posts]." 篇<br>在线时间:".$dstar[oltime]." 小时<br></td><td width=16% align=center class=altbg1><IMG src=".$dstar[avatar]." width=".$dstar[avatarwidth]." height=".$dstar[avatarheight]." align=center></td>";
- $n=$key;
- }
- }
- if($n==0){$daystars .=$nopoststar.$nopoststar;}elseif($n==1){$daystars .=$nopoststar;}
- }
- if($_DCACHE['weekstar']) {
- foreach($_DCACHE['weekstar'] as $key => $wstar) {
- if ($key<3){
- $weekstars .="<td valign=top>姓名:".$wstar[author]."<br> 积分:".$wstar[credits]."<br>精华:".$wstar[digestposts]." 篇<br>本周发帖:".$wstar[num]."篇<br>总发帖量:".$wstar[posts]." 篇<br>在线时间:".$wstar[oltime]."小时</td><TD width=16% align=center class=altbg1><IMG src=".$wstar[avatar]." width=".$wstar[avatarwidth]." height=".$wstar[avatarheight]." align=center></td>";
- $weeknum=$key;
- }
- }
- if($weeknum==0){$weekstars .= $nopoststar.$nopoststar;}elseif($weeknum==1){$weekstars.=$nopoststar;}
- }
- if($_DCACHE['monthstar']) {
- foreach($_DCACHE['monthstar'] as $key => $mstar) {
- if ($key<3){
- $monthstars .="<td valign=top>姓名:".$mstar[author]."<br>积分:".$mstar[credits]."<br>精华:".$mstar[digestposts]."篇<br>".$month."月发帖:".$mstar[num]." 篇<br>总发帖量:".$mstar[posts]." 篇<br>在线时间:".$mstar[oltime]." 小时</td><TD width=16% align=center class=altbg1><IMG src=".$mstar[avatar]." width=".$mstar[avatarwidth]." height=".$mstar[avatarheight]." align=center></td>";
- }
- }
- }
- if($_DCACHE['yearstar']) {
- foreach($_DCACHE['yearstar'] as $key => $ystar) {
- if ($key<3){
- $yearstars .="<td valign=top>姓名:".$ystar[author]."<br>积分:".$ystar[credits]."<br>精华:".$ystar[digestposts]." 篇<br>".$year."年发帖:".$ystar[num]."篇<br>总发帖量:".$ystar[posts]." 篇<br>在线时间:".$ystar[oltime]." 小时</td><TD width=16% align=center class=altbg1><IMG src=".$ystar[avatar]." width=".$ystar[avatarwidth]." height=".$ystar[avatarheight]." align=center></td>";
- }
- }
- }
- //========== 社区发帖明星 结束
复制代码
9. topicadmin.php
查找
- showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'),
复制代码
上面加
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('newthread');
- require_once DISCUZ_ROOT.'./include/cache.func.php';
- updatecache('daystar');
复制代码
10. 修改文件:templates\default\discuz.htm
查找
- <!--{if !empty($newpmexists)}-->
- <div style="clear: both; margin-top: 5px">
- {template pmprompt}
- </div>
- <!--{/if}-->
复制代码
下面加
-
- <!--{if empty($gid)}-->
- <!--{if $show_poststar}-->
- <div style="clear: both; margin-top: 5px">
- {template toplist}
- </div>
- <!--{/if}-->
- <!--{/if}-->
复制代码
上传 附件里的 TOPLIST.htm到模版风格目录
11.上传附件到论坛根目录
12.后台更新缓存,一定要更新,否则可能首页无法显示
完毕!
注意:默认首页发帖状元、榜眼、探花三栏是展开的,如果你想默认改为隐藏的就将star.htm
中的
- <tbody id="poststar" style="display:yes">
复制代码
的 yes 修改为 none 即可!
由于时间仓促和本人水平有限,难免存在一些BUG,大家有什么意见和建议还望大家及时提出,谢谢!
[ 本帖最后由 PHP论坛 于 2006-10-22 09:02 编辑 ] |