二,首页四格+社区发帖之星
请大家小心小心再小心。仔细仔细再仔细。。错误的出现多半是因为你的粗心造成的.
请大家一定要备份需要修改的文件!!!
演示:http://bbs.0312.org.cn
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';
- $c;
- 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';
- $c;
- 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';
- $c;
- 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';
- $c;
- 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';
- $c;
- 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';
- $c;
- 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';
- $c;
- 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';
- $c;
- 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';
- $c;
- 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';
- $c;
- 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 = $announcepm = 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) || $announcepm}-->
- <div style="clear: both; margin-top: 5px" id="pmprompt">
- {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.后台更新缓存,一定要更新,否则可能首页无法显示
常见修改问题
1.Warning: main(): Unable to access d:\usr\web\www\bbs\./forumdata/cache/cache_toplist.php in d:\usr\web\www\bbs\index.php on line 97
Warning: main(d:\usr\web\www\bbs\./forumdata/cache/cache_topli ...
修改办法: 清除forumdata/cache/目录下所有文件.后台更新缓存.然后刷新首页两次。正常
2.出现如下错误提示:
Warning: main(d:\webhost\qiuqiao\web\vip\05\./forumdata/templates/1_toplist.tpl.php): failed to open stream: No such file or directory in d:\webhost\qiuqiao\web\vip\05\forumdata\templates\1_discuz.tpl.php on line 106
Warning: main(d:\webhost\qiuqiao\web\vip\05\./forumdata/templates/1_toplist.tpl.php): failed to open stream: No such file or directory in d:\webhost\qiuqiao\web\vip\05\forumdata\templates\1_discuz.tpl.php on line 106
Warning: main(): Failed opening 'd:\webhost\qiuqiao\web\vip\05\./forumdata/templates/1_toplist.tpl.php' for inclusion (include_path='.;c:\php4\pear') in d:\webhost\qiuqiao\web\vip\05\forumdata\templates\1_discuz.tpl.php on line 106
解决办法:清除\forumdata\templates目录下所有文件,然后刷新首页两次.正常..
- 如何把首页显示的“XX十大名帖 ”,更改成:“社区十大名帖”?
- 修改办法: 修改附件里面的toplist.htm中的如下代码修改:
- <td align="left" valign="top"><b> <img src={IMGDIR}/dot.gif BORDER=0> XX十大名帖</b
复制代码
不显示某个子板块:
可以在cache.func.php里面把代码中4个ORDER BY前全部加上and f.fid!=''(引号里是隐藏帖子所在论坛的fid号,例如:and f.fid!='3')
当贴子的标题过长时,会排列多出一排来,难看!! 如何长能排列整齐???(不要排到第二行的)
修改include\cache.func.php里面的语句:
$topthread['subjectc'] = cutstr($topthread['subject'], 25);
调整红色数字就行!
[ 本帖最后由 阿飞刘 于 2007-4-4 01:20 编辑 ] |