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

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[发布] 完美的首页4格_CACHE版 [附件图片+新帖+回复+精华+天气预报]FOR6.0_12月24日最后更新

[复制链接]
9944 发表于 2007-8-29 02:08:54 | 显示全部楼层 |阅读模式
===================================================
插件名称:TOPLIST_首页四格_全CACHE版(GBK)
代码作者:oytktk (靖飒)     界面作者:9944
安装难度:易
插件功能:首页4格[随机调用附件图片+最新帖子+最新回复+精华帖子+天气预报]   
演示地址: http://www.liefeng.net




12月24日更新说明:1,修正本周热门的一些代码错误,加入实用的天气预报功能。2,修正无图版本周热门HTML代码过滤问题。

10月18日更新说明:美化界面,调整图片展示文字位置,天气预报加入时间显示,界面显示更协调,加入最新帖和精华帖的链接(直接使用官方代码)具体请看演示站。

9月30日更新说明:

根据网友jzzz 提醒,修正“无图版”的一些错误,并加入天气预报。

9月18日更新说明:
应网友rogerxu的要求,本人也需要,将最新回复中的链接改为指向最后回复的帖子。

9月17日更新说明:
应网友要求,将天气预报的插件补充发上了,可以完美配合这个首页4格。建议只在本插件上使用:)

说明:
1、由于页面调用使用了缓存,首页不增加查询,可极大的提高首页显示速度。CACHE版只在发帖时进行查询生成缓存,可降低服务器负担。非CACHE版每次打开首页都会进行一次查询。
2、新帖和回复数量特别大的站使用本插件会增加服务器负担。
3、增加收缩开关,收缩状时不读取缓存。
4、解决分辨率小时,版面换行问题。
5、直接使用官方CSS,读取更快,更完美的搭配官方6.0风格(自己添加的风格也可完美搭配)。
附件图片调用比较消耗资源,速度很慢的论坛建议使用无图版。
6、提问题的朋友请同时贴出网址,以便于查看问题。
7、版主TaRot! 对首页N格的问题已经整理成帖,有问题可先查看https://discuz.dismall.com/thread-655317-1-1.html
8、关于天气预报显示是北京的问题:由于这个插件并不能显示所以的地方的天气预报,所以对应IP段里没有地方就显示默认的北京。
9、由于代码编写的缺陷,请定时在后台更新缓存以更新精华帖。
10、没有修改过论坛文件的可直接下载附件覆盖即可。覆盖前请先打开后台管理界面,用二进制上传覆盖后直接在后台更新缓存即可。 安装成功后请跟帖。
11、如果discuz.htm已经修改过,上传时可以不上传discuz.htm文件,参照2楼的修改方法修改discuz.htm文件即可。

[ 本帖最后由 9944 于 2007-12-24 17:40 编辑 ]

本帖子中包含更多资源

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

x

评分

2

查看全部评分

 楼主| 9944 发表于 2007-8-29 02:09:45 | 显示全部楼层

修改方法步骤:

更新至9月9日版。前面步骤一样, 省略步骤8,9。 更简洁,速度更快。


1。打开include/cache.func.php

查找
  1. 'medals' => array('medals'),
复制代码
如果搜不到,可搜索 array('medals'),  
的上面加
  1. 'toplist'   => array('newthread', 'newreply','topdigest'),//TOPLIST_首页4格_全Cache版_代码by oytktk
复制代码
继续查找:
  1.           case 'medals':
  2.                         $table = 'medals';
  3.                         $cols = 'medalid, name, image';
  4.                         $conditions = "WHERE available='1'";
  5.                         break;
复制代码
上面加:
  1.         //TOPLIST_CACHE版
  2.         case 'newthread':
  3.             $table = 'threads t';
  4.             $cols = 't.tid, t.fid, t.author, t.subject, t.dateline, t.lastpost, t.lastposter, t.views, t.replies, t.highlight, f.name';
  5.             $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE t.displayorder!='-1' ORDER BY t.dateline DESC LIMIT 0, 8";
  6.             break;

  7.         case 'newreply':
  8.             $table = 'threads t';
  9.             $cols = 't.tid, t.fid, t.author, t.subject, t.dateline, t.lastpost, t.lastposter, t.views, t.replies, t.highlight, f.name';
  10.             $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, 8";
  11.             break;
  12.                         
  13.         case 'topdigest':
  14.              $table = 'threads t';
  15.              $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';
  16.              $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE digest>0 ORDER BY rand() LIMIT 0, 8";
  17.              break;
  18.          //TOPLIST_CACHE版
复制代码
----------------------------------
再找:
  1. case 'settings':
  2. while($setting = $db->fetch_array($query))
复制代码
上面加:
  1. //TOPLIST_CACHE版_代码by oytktk starts,improve(9944)

  2.         case 'newthread':
  3.             $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
  4.             while($topthread = $db->fetch_array($query)) {
  5.             $threadcolor = sprintf('%02d', $topthread['highlight']);
  6.             $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
  7.             $topthread['subjectc'] = cutstr($topthread['subject'], 26);
  8.             $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
  9.             $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $GLOBALS['timeoffset'] * 3600 );
  10.             $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $GLOBALS['timeoffset'] * 3600 );
  11.             $topthread['name'] =  AddSlashes(strip_tags(trim($topthread['name'])));
  12.             $data[] = $topthread;
  13.                                 }
  14.             break;        
  15.        case 'newreply':
  16.             $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
  17.                                 while($topthread = $db->fetch_array($query)) {
  18.             $threadcolor = sprintf('%02d', $topthread['highlight']);
  19.             $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
  20.             $topthread['subjectc'] = cutstr($topthread['subject'], 26);
  21.             $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
  22.             $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $GLOBALS['timeoffset'] * 3600 );
  23.             $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $GLOBALS['timeoffset'] * 3600 );
  24.             $topthread['name'] =  AddSlashes(strip_tags(trim($topthread['name'])));
  25.             $data[] = $topthread;
  26.                                 }
  27.             break;
  28.       
  29.     case 'topdigest':
  30.             $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
  31.                   while($topthread = $db->fetch_array($query)) {
  32.             $threadcolor = sprintf('%02d', $topthread['highlight']);
  33.             $digest = array('1'=>'[Ⅰ]','2'=>'[Ⅱ]','3'=>'[Ⅲ]');
  34.             $topthread['subjectc'] = $digest[$topthread['digest']]."-".cutstr($topthread['subject'], 23);
  35.             $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
  36.             $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
  37.             $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $timeoffset * 3600);
  38.             $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $timeoffset * 3600);
  39.             $topthread['name'] =  AddSlashes(strip_tags(trim($topthread['name'])));
  40.             $data[] = $topthread;
  41.              }
  42.             break;

  43. //TOPLIST_CACHE版
复制代码
2。打开include/newthread.inc.php

查找:
  1. updatepostcredits('+', $discuz_uid, $postcredits);
复制代码
下面加:
  1. require_once DISCUZ_ROOT.'./include/cache.func.php';
  2.                 updatecache('newthread');
复制代码
3。打开 include/newreply.inc.php

查找:
  1. updatepostcredits('+', $discuz_uid, $replycredits);
复制代码
下面加:
  1. require_once DISCUZ_ROOT.'./include/cache.func.php';
  2.                 updatecache('newreply');
复制代码
4。打开 include/editpost.inc.php

查找:
  1. updatepostcredits('-', $orig['authorid'], ($isfirstpost ? $postcredits : $replycredits));
复制代码
下面加:
  1. require_once DISCUZ_ROOT.'./include/cache.func.php';
  2.                 updatecache('newthread');
复制代码
5。论坛根目录 index.php

查找:
  1. $threads = $posts = $todayposts = $fids = $announcepm = 0;
复制代码
下面加
  1. //首页4格TOPLIST_CACHE版
  2. if(!isset($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], 'category_hk2 ') === FALSE) {
  3.         $categorys_hk2 = 'collapsed_no.gif';
  4.         $collapse['category_hk2'] = '';
  5.         } else {
  6.         $categorys_hk2 = 'collapsed_yes.gif';
  7.         $collapse['category_hk2'] = 'display: none';
  8.         }
  9.         
  10. if($categorys_hk2 == 'collapsed_no.gif'){
  11.         require_once DISCUZ_ROOT.'./forumdata/cache/cache_toplist.php';
  12.         $toplistloop = $_DCACHE['newthread'];
  13.         }
  14. //首页4格TOPLIST_CACHE版
复制代码
6。 根目录 topicadmin.php

查找:
  1. showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'), $resultarray['redirect']);
复制代码
上面加:
  1. require_once DISCUZ_ROOT.'./include/cache.func.php';
  2.         updatecache('newthread');
复制代码
7。templates\default\discuz.htm

查找:
  1. <!--{loop $catlist $key $cat}-->
  2.         <!--{if $cat['forumscount']}-->
复制代码
在上面添加:
  1. <!--{if empty($gid)}-->
  2.         {template toplist}
  3. <!--{/if}-->
复制代码
8。
9。
10。上传附件1中的文件到网站根目录,后台更新缓存(不更新就不能打开首页)

结束!

[ 本帖最后由 9944 于 2007-9-9 12:17 编辑 ]

本帖子中包含更多资源

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

x
回复

使用道具 举报

lovesammi 发表于 2007-8-29 02:09:59 | 显示全部楼层
谢谢咯!
回复

使用道具 举报

 楼主| 9944 发表于 2007-8-29 02:12:58 | 显示全部楼层
如何只显示指定的版块:
  1. 在cache.func.php 找到 $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE t.replies>0 and t.displayorder!='-1' (共3个) 后面加上AND f.fid IN (4,6,48,49,51,11,13) 括号里面的数字就是要显示的版块FID,改成你论坛版块的FID就可以了。
复制代码
如何修改FLSAH图片的显示张数
  1. 打开论坛根目录下的PIC.PHP 找到
  2. //---设置---start
  3. $shownums = 4;//FLSAH图片演示个数,不能超过6,否则无法使用导航条.
  4. 将4改成你想要的数字,但是不能超过6。
复制代码
如何显示最新图片:
  1. 在论坛根目录里的PIC.php 里查找 $orderby = 'rand'  然后将rand 改为 dateline 。更新缓存,OK。
复制代码
如何显示FLASH时钟:
在templates/default/discuz.htm 里找到
  1. <!--{/if}-->
  2.         


  3. <!--{if empty($gid)}-->
  4.         {template toplist}
复制代码
在上面添加:
<td id="hottags" style="width:99px;"><object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="97" height="26" title="clock" align="absbottom">
        <param name="movie" value="../../images/clock.swf" />
        <param name="wmode" value="transparent" />
        <embed src="../../images/clock.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="97" height="34" align="bottom"></embed>
     </object><br />
     </td>
然后在后台开启奇虎搜索,一个漂亮的时钟就出现了。

如何设置截取标题的字数:
在cache.func.php 找到
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'], 26);
     
红色的数字就是。修改成你想要的字数, 下面的case 'newreply':与case 'topdigest' 同样。


如何加入WWW.LIEFENG.NET里面的天气预报!
1,找到templates/default/toplist.htm 里的
  1. <h3>$sitename</h3>
复制代码
在上面加上:
  1. <span class="headactions">{template weather}</span>
复制代码
下载附件 上传 到 templates/default/  。。 OK.

如何将最新回复的链接指向最后回的帖?
在toplist.htm里找到最新回复里面href="viewthread.php?tid=$toploop[tid]  改成 href="redirect.php?tid=$toploop[tid]&goto=lastpost#lastpost

[ 本帖最后由 9944 于 2007-9-18 22:37 编辑 ]

本帖子中包含更多资源

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

x
回复

使用道具 举报

有心人 发表于 2007-8-29 02:16:26 | 显示全部楼层
不错不错不错不错不错不错
回复

使用道具 举报

 楼主| 9944 发表于 2007-8-29 02:40:32 | 显示全部楼层
把精华帖子改成热门帖子:

打开include/cache.func.php

查找:

  1.         case 'topdigest':
  2.              $table = 'threads t';
  3.              $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';
  4.              $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE digest>0 ORDER BY rand() LIMIT 0, 8";
  5.              break;
复制代码

替换成:

  1.             case 'topviews':
  2.             $table = 'threads t';
  3.             $view = rand(1,3)==1 ? 'views' : 'replies';
  4.             $cols = 't.tid, t.fid, t.author, t.subject, t.dateline, t.lastpost, t.lastposter, t.views, t.replies, t.highlight, f.name';
  5.             $conditions = "LEFT JOIN {$tablepre}forums f ON f.fid=t.fid WHERE t.displayorder!='-1' ORDER BY t.$view DESC LIMIT 0, 8";
  6.             break;
复制代码


再找:
  1. case 'topdigest':
  2. $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
  3. while($topthread = $db->fetch_array($query)) {
  4. $threadcolor = sprintf('%02d', $topthread['highlight']);
  5. $digest = array('1'=>'[Ⅰ]','2'=>'[Ⅱ]','3'=>'[Ⅲ]');
  6. $topthread['subjectc'] = $digest[$topthread['digest']]."-".cutstr($topthread['subject'], 23);
  7. $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
  8. $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
  9. $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $timeoffset * 3600);
  10. $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $timeoffset * 3600);
  11. $topthread['name'] = AddSlashes(strip_tags(trim($topthread['name'])));
  12. $data[] = $topthread;
  13. }
  14. break;
复制代码


替换成:

  1.       case 'topviews':
  2.             $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
  3.                         while($topthread = $db->fetch_array($query)) {
  4.             $threadcolor = sprintf('%02d', $topthread['highlight']);
  5.             $topthread['subjectc'] = cutstr($topthread['subject'], 23);
  6.             $topthread['threadcolor'] = $threadcolor[1] ? " style="color: ".$colorarray[$threadcolor[1]].""" : NULL;
  7.             $topthread['author'] = $topthread['author'] ? $topthread['author'] : '游客';
  8.             $topthread['dateline'] = gmdate("Y-m-d H:i", $topthread['dateline'] + $timeoffset * 3600);
  9.             $topthread['lastpost'] = gmdate("Y-m-d H:i", $topthread['lastpost'] + $timeoffset * 3600);
  10.             $topthread['name'] =  AddSlashes(strip_tags(trim($topthread['name'])));
  11.             $data[] = $topthread;
  12.                         }
复制代码

[ 本帖最后由 9944 于 2007-9-9 15:02 编辑 ]
回复

使用道具 举报

jkjoy 发表于 2007-8-29 03:39:31 | 显示全部楼层
顶啊啊```

嘿嘿``
回复

使用道具 举报

⒈薪 发表于 2007-8-29 05:41:53 | 显示全部楼层
:) :) :)
回复

使用道具 举报

雪撒罗拉 发表于 2007-8-29 05:47:37 | 显示全部楼层
支持下~~
回复

使用道具 举报

jinziyu2000 发表于 2007-8-29 07:08:26 | 显示全部楼层
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-9-21 22:06 , Processed in 0.221893 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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