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

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[插件] 首页四格(访客信息+论坛档案+最新主题+最新回复)+新手DIY方案 For Discuz! 5.0.0

[复制链接]
hydeist 发表于 2006-10-4 21:33:10 | 显示全部楼层
原帖由 bvtc 于 2006-10-3 23:26 发表
你的论坛搞得不错哦!!!!


过将了……

我搞成白色,居然也会被你点到。汗
回复

使用道具 举报

 楼主| Clwarm 发表于 2006-10-4 21:53:04 | 显示全部楼层
原帖由 hydeist 于 2006-10-4 21:22 发表

太强了,我就要这样的,那个123456789那个图标不要,也没事的。

能发出修改的方案出来不?


我对代码不是很了解,基本是从stats.php照搬过来的,可能搬的有点罗嗦,谁有时间给改改。

index.php
  1. } else {
  2.         $showoldetails = false;
  3. }
复制代码

下面加(个人认为这部分可能还可以优化,简洁的余地
  1. //--首页四格增加 Start--
  2. //24小时发帖排行
  3. $postsrank = '';
  4. $statvars = array();
  5. $query = $db->query("SELECT * FROM {$tablepre}statvars WHERE type='postsrank'");
  6. while($variable = $db->fetch_array($query)) {
  7.   $statvars[$variable['variable']] = $variable['value'];
  8. }
  9. if($timestamp - $statvars['lastupdate'] > $statscachelife) {
  10.   $statvars = array('lastupdate' => $timestamp);
  11.   $db->query("REPLACE INTO {$tablepre}statvars (type, variable, value)
  12.    VALUES ('postsrank', 'lastupdate', '$timestamp')");
  13. }
  14. $posts = $digestposts = $thismonth = $today = array();
  15. if(isset($statvars['today'])) {
  16.   $today = unserialize($statvars['today']);
  17. } else {
  18.   $query = $db->query("SELECT DISTINCT(author) AS username, COUNT(pid) AS posts
  19.    FROM {$tablepre}posts WHERE dateline >='$timestamp'-86400 AND invisible='0' AND authorid>'0'
  20.    GROUP BY author ORDER BY posts DESC LIMIT 0, 20");
  21.   while($member = $db->fetch_array($query)) {
  22.    $today[] = $member;
  23.   }
  24.   $db->query("REPLACE INTO {$tablepre}statvars (type, variable, value)
  25.    VALUES ('postsrank', 'today', '".addslashes(serialize($today))."')");
  26. }
  27. for($i = 0; $i < 10; $i++) {
  28.   $postsrank .= "<tr><td width="60%"><li type="square"> <a href="viewpro.php?username=".rawurlencode($today[$i]['username'])."" target="_blank">{$today[$i][username]}</a></td><td align="right" width="40%">[<font color="red">{$today[$i][posts]}</font>]</td></tr>\n";
  29. }
  30. //
  31. //在线时间排行
  32. $onlines = '';
  33. $statvars = array();
  34. $query = $db->query("SELECT * FROM {$tablepre}statvars WHERE type='onlines'");
  35. while($variable = $db->fetch_array($query)) {
  36.   $statvars[$variable['variable']] = $variable['value'];
  37. }
  38. $total = $thismonth = array();
  39. if(isset($statvars['total'])) {
  40.   $total = unserialize($statvars['total']);
  41. } else {
  42.   $query = $db->query("SELECT o.uid, m.username, o.total AS time
  43.    FROM {$tablepre}onlinetime o
  44.    LEFT JOIN {$tablepre}members m USING (uid)
  45.    ORDER BY o.total DESC LIMIT 20");
  46.   while($online = $db->fetch_array($query)) {
  47.    $online['time'] = round($online['time'] / 60, 2);
  48.    $total[] = $online;
  49.   }
  50.   $db->query("REPLACE INTO {$tablepre}statvars (type, variable, value)
  51.    VALUES ('onlines', 'total', '".addslashes(serialize($total))."')");
  52. }
  53. for($i = 0; $i < 10; $i++) {
  54.   $onlines .= "<tr><td width="60%"><li type="square"> <a href="viewpro.php?uid={$total[$i][uid]}" target="_blank">{$total[$i][username]}</a></td><td align="right" width="40%">{$total[$i][time]} 时</td>\n";
  55. }
  56. //
  57. $hack_subject_len=30; //标题最多显示的字数
  58. $hack_subject_num=10; //最新主题与回复显示的数量
  59. //最新主题
  60. $query = $db->query("SELECT dateline,tid,subject,author,views,replies FROM {$tablepre}threads ORDER BY dateline DESC LIMIT 0, $hack_subject_num");
  61. while($thread = $db->fetch_array($query)) {
  62.          $thread[subject0]=$thread[subject];
  63.         $thread['subject'] = cutstr($thread['subject'], $hack_subject_len);
  64.         $hack_newthreads_threadlist[] = $thread;
  65. }
  66. $threadview = $threadreply = array();
  67. //最新回复
  68. $query = $db->query("SELECT replies, tid, subject,author,views,lastposter FROM {$tablepre}threads where replies !=0 ORDER BY lastpost DESC LIMIT 0, $hack_subject_num");
  69.         while($thread = $db->fetch_array($query)) {
  70.                  $thread[subject0]=$thread[subject];
  71.                 $thread[subject] = cutstr($thread[subject], $hack_subject_len);
  72.                 $threadreply[] = $thread;
  73.         }
  74. //--首页四格增加 End--
复制代码



hot_topics.htm


  1. <table cellspacing="0" cellpadding="0" border="0" width="{TABLEWIDTH}" align="center" class="tableborder">
  2.   <tr>
  3.     <td>
  4.     <table border="0" cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="100%" style="table-layout: fixed; word-wrap: break-word"  >
  5.       <tr class="header">
  6.         <td width="27%" align="center">最新发表主题</td>
  7.         <td width="23%" align="center">最新回复主题</td>
  8.         <td width="25%" align="center">24小时发帖排行</td>
  9.         <td width="25%" align="center">在线时间排行</td>
  10.       </tr>
  11.       <tr>
  12.         <td bgcolor="{ALTBG2}" onMouseOver ="this.style.backgroundColor='{ALTBG1}'" onMouseOut ="this.style.backgroundColor='{ALTBG2}'">
  13. <table width="100%" cellpadding="{TABLESPACE}" cellspacing="{INNERBORDERWIDTH}">
  14. <!--{loop $hack_newthreads_threadlist $thread}-->
  15.         <tr><td><li><a href="viewthread.php?tid=$thread[tid]" title="主题:$thread[subject0]{LF}作者:$thread[author]{LF}浏览:$thread[views] 次 回复:$thread[replies] 次">$thread[subject]</a><!--{if $thread[creditsrequire]}--> - [{lang credit_title}<span class="bold">$thread[creditsrequire]</span>{lang credit_unit}] <!--{/if}-->$thread[multipage]</li></tr></td>
  16. <!--{/loop}-->
  17. </table>
  18.         </td>
  19.         <td bgcolor="{ALTBG2}" onMouseOver ="this.style.backgroundColor='{ALTBG1}'" onMouseOut ="this.style.backgroundColor='{ALTBG2}'">
  20. <table width="100%" cellpadding="{TABLESPACE}" cellspacing="{INNERBORDERWIDTH}">
  21. <!--{loop $threadreply $thread}-->
  22.         <tr><td><li><a href="redirect.php?tid=$thread[tid]&goto=lastpost#lastpost" title="主题:$thread[subject0]{LF}作者:$thread[author]{LF}浏览:$thread[views] 次{LF}回复:$thread[replies] 次{LF}{lang lastpost}:$thread[lastposter]">$thread[subject]</a><!--{if $thread[creditsrequire]}--> - [{lang credit_title}<span class="bold">$thread[creditsrequire]</span>{lang
  23. credit_unit}] <!--{/if}--> $thread[multipage]</li></tr></td>
  24. <!--{/loop}-->
  25. </table>
  26.         </td>
  27.         <td bgcolor="{ALTBG2}" onMouseOver ="this.style.backgroundColor='{ALTBG1}'" onMouseOut ="this.style.backgroundColor='{ALTBG2}'">
  28. <table width="100%" cellpadding="{TABLESPACE}" cellspacing="{INNERBORDERWIDTH}">
  29. $postsrank
  30. </table>
  31.         </td>
  32.         <td bgcolor="{ALTBG2}" onMouseOver ="this.style.backgroundColor='{ALTBG1}'" onMouseOut ="this.style.backgroundColor='{ALTBG2}'">
  33. <table width="100%" cellpadding="{TABLESPACE}" cellspacing="{INNERBORDERWIDTH}">
  34. $onlines
  35. </table>
  36.         </td>
  37.       </tr>
  38.     </table>
  39.   </td>
  40. </tr>
  41. </table><br />
复制代码



discuz.htm

  1. $lastmember</span></a>
  2. </div>

  3. </div><br>
复制代码

后面加上
  1. {template hot_topics}
复制代码



这个出来的效果比上面的图要好看点,后来把最新主题/回复放左边了,也加了<li></li>


看一下这个方案的图吧。

[ 本帖最后由 Clwarm 于 2006-10-4 22:33 编辑 ]
回复

使用道具 举报

hydeist 发表于 2006-10-4 22:07:34 | 显示全部楼层
原帖由 Clwarm 于 2006-10-4 01:53 发表


我对代码不是很了解,基本是从stats.php照搬过来的,可能搬的有点罗嗦,谁有时间给改改。

index.php} else {
        $showoldetails = false;
}下面加(这部分可能还可以优化,简洁)//--首页四格增加 ...



不错,太感谢你了,我先用着,如果你优化了,我会再更新代码的。

回复

使用道具 举报

hydeist 发表于 2006-10-4 22:15:48 | 显示全部楼层

昏,居然出错了

Warning: main(/home/arklive/public_html/./forumdata/templates/1_hot_topics.tpl.php): failed to open stream: No such file or directory in /home/arklive/public_html/forumdata/templates/2_discuz.tpl.php on line 47

Warning: main(/home/arklive/public_html/./forumdata/templates/1_hot_topics.tpl.php): failed to open stream: No such file or directory in /home/arklive/public_html/forumdata/templates/2_discuz.tpl.php on line 47

Warning: main(): Failed opening '/home/arklive/public_html/./forumdata/templates/1_hot_topics.tpl.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/arklive/public_html/forumdata/templates/2_discuz.tpl.php on line 47
回复

使用道具 举报

 楼主| Clwarm 发表于 2006-10-4 22:18:08 | 显示全部楼层
hot_topics.htm

这个模板没弄?
放到templates/default下。

[ 本帖最后由 Clwarm 于 2006-10-4 22:22 编辑 ]
回复

使用道具 举报

hydeist 发表于 2006-10-4 22:19:02 | 显示全部楼层
原帖由 Clwarm 于 2006-10-4 02:18 发表
hot_topic.htm

这个模板没弄?
放到templates/default下。


用FTP放进去了
回复

使用道具 举报

hydeist 发表于 2006-10-4 22:19:57 | 显示全部楼层
discuz.htm

那个调用模板,是改这个文件吧,不是INDEX.HTM
回复

使用道具 举报

 楼主| Clwarm 发表于 2006-10-4 22:22:12 | 显示全部楼层
原帖由 hydeist 于 2006-10-4 22:19 发表
discuz.htm

那个调用模板,是改这个文件吧,不是INDEX.HTM

..恩。。。顺手了。。。过去都是index 现在用discuz 很不习惯 谢谢提醒!
楼主那帖的时候开始我也写的index。。后来审了一遍改正了。。刚才又顺手写了。。晕。。


那个。。
hot_topics.htm
模板的文件名应该是这个。。刚才少了个S,抱歉!

[ 本帖最后由 Clwarm 于 2006-10-4 22:23 编辑 ]
回复

使用道具 举报

hydeist 发表于 2006-10-4 22:23:21 | 显示全部楼层
原帖由 Clwarm 于 2006-10-4 02:22 发表

..恩。。。顺手了。。。过去都是index 现在用discuz 很不习惯


那个。。
hot_topics.htm
模板的文件名应该是这个。。刚才少了个S,抱歉!


哦,我试哈,应该能正常了
回复

使用道具 举报

hydeist 发表于 2006-10-4 22:25:41 | 显示全部楼层
太强啦,安装成功!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-3-29 19:43 , Processed in 0.107603 second(s), 15 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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