对Discuz增加首页四格插件-Discuz教程下载

对Discuz增加首页四格插件

开通本站Svip会员,全站资源免费下
其实也很简单,不须做其它的更改,只需将附件里的文件解压后,覆盖一个原文件就OK了。要做更改的是index.php,Discuz.htm,增加了一个pic.php,及几张图片,就这些!
如果你不想覆盖的话,也可以手动分别对这几个页面进行添加代码。
index.php,找到以下代码:
Java代码
  1. $newthreads = round(($timestamp - $lastvisit + 600) / 1000) * 1000;
复制代码
在这段代码下添加如下代码:

Java代码
  1. //----首页五格代码开始  
  2. $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');  
  3. //新贴  
  4. $hack_cut_str = 28; //标题字数  
  5. $hack_cut_strauthor = 9;  
  6. $new_post_threadlist = array();  
  7. $nthread = array();  
  8. $query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid<>'$fid' AND f.fid=t.fid AND f.fid not in (0) AND t.displayorder not in (-1,-2) ORDER BY t.dateline DESC LIMIT 0, 10");  
  9. while($nthread = $db->fetch_array($query)) {  
  10. $nthread['forumname'] = ereg_replace('<[^>]*>','',$nthread['name']);  
  11. $nthread['view_subject'] = cutstr($nthread['subject'],$hack_cut_str);  
  12. $nthread['view_author'] = cutstr($nthread['author'],$hack_cut_strauthor);  
  13. $nthread['date']= gmdate("$dateformat $timeformat", $nthread['dateline'] + $timeoffset * 3600);  
  14. $nthread['lastreplytime']= gmdate("$dateformat $timeformat", $nthread[lastpost] + ($timeoffset * 3600));  
  15. if($nthread['highlight']) {  
  16. $string = sprintf('%02d', $nthread['highlight']);  
  17. $stylestr = sprintf('%03b', $string[0]);  
  18. $nthread['highlight'] = 'style="';  
  19. $nthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';  
  20. $nthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';  
  21. $nthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';  
  22. $nthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';  
  23. $nthread['highlight'] .= '"';  
  24. } else {  
  25. $nthread['highlight'] = '';  
  26. }  
  27. $new_post_threadlist[] = $nthread;  
  28. }  
  29.   
  30. //新回复  
  31. $hack_cut_str = 28; //标题字数  
  32. $hack_cut_strauthor = 9;  
  33. $new_reply_threadlist = array();  
  34. $rthread = array();  
  35. $query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid<>'$fid' AND f.fid=t.fid AND t.closed NOT LIKE 'moved|%' AND t.replies !=0 AND f.fid not in (0) AND t.displayorder not in (-1,-2) ORDER BY t.lastpost DESC LIMIT 0, 10");  
  36. while($rthread = $db->fetch_array($query)) {  
  37. $rthread['forumname'] = ereg_replace('<[^>]*>','',$rthread['name']);  
  38. $rthread['view_subject'] = cutstr($rthread['subject'],$hack_cut_str);  
  39. $rthread['view_lastposter'] = cutstr($rthread['lastposter'],$hack_cut_strauthor);  
  40. $rthread['date']= gmdate("$dateformat $timeformat", $rthread['dateline'] + $timeoffset * 3600);  
  41. $rthread['lastreplytime']= gmdate("$dateformat $timeformat", $rthread[lastpost] + ($timeoffset * 3600));  
  42. if($rthread['highlight']) {  
  43. $string = sprintf('%02d', $rthread['highlight']);  
  44. $stylestr = sprintf('%03b', $string[0]);  
  45. $rthread['highlight'] = 'style="';  
  46. $rthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';  
  47. $rthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';  
  48. $rthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';  
  49. $rthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';  
  50. $rthread['highlight'] .= '"';  
  51. } else {  
  52. $rthread['highlight'] = '';  
  53. }  
  54. $new_reply_threadlist[] = $rthread;  
  55. }  
  56.   
  57. //本月热帖  
  58. $hack_cut_str = 30; //标题字数  
  59. $hack_cut_strauthor = 9;  
  60. $new_hot_threadlist = array();  
  61. $mthread = array();  
  62. $ctime=$timestamp-3600*24*30;//最后30是天数为本月  
  63. $query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid<>'$fid' AND f.fid=t.fid AND t.closed NOT LIKE 'moved|%' AND t.replies !=0 AND t.dateline>$ctime AND f.fid not in (0) AND t.displayorder not in (-1,-2) ORDER BY t.replies DESC LIMIT 0, 10");  
  64. while($mthread = $db->fetch_array($query)) {  
  65. $mthread['forumname'] = ereg_replace('<[^>]*>','',$mthread['name']);  
  66. $mthread['view_subject'] = cutstr($mthread['subject'],$hack_cut_str);  
  67. $mthread['view_lastposter'] = cutstr($mthread['lastposter'],$hack_cut_strauthor);  
  68. $mthread['date']= gmdate("$dateformat $timeformat", $mthread['dateline'] + $timeoffset * 3600);  
  69. $mthread['lastreplytime']= gmdate("$dateformat $timeformat", $mthread[lastpost] + ($timeoffset * 3600));  
  70. if($mthread['highlight']) {  
  71. $string = sprintf('%02d', $mthread['highlight']);  
  72. $stylestr = sprintf('%03b', $string[0]);  
  73. $mthread['highlight'] = 'style="';  
  74. $mthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';  
  75. $mthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';  
  76. $mthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';  
  77. $mthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';  
  78. $mthread['highlight'] .= '"';  
  79. } else {  
  80. $mthread['highlight'] = '';  
  81. }  
  82. $new_hot_threadlist[] = $mthread;  
  83. }  
  84.   
  85. //今日发贴排行  
  86. $tomonth=date(n);  
  87. $todate=date(j);  
  88. $toyear=date(Y);  
  89. $time=mktime(0,0,0,$tomonth,$todate,$toyear);  
  90. $query=$db->query("select count(pid) as num,authorid,author from $tablepre"."posts where dateline>=$time group by authorid order by num desc limit 0,10");  
  91. while($result=$db->fetch_array($query)){  
  92. $poststar.="<a href=space.php?uid=".$result[authorid].">".cutstr($result[author],8)."</a><font color=red>[".$result[num]."]</font>  ";  
  93. }  
  94. //----首页五格代码结束  
复制代码
discuz.htm,找到以下代码:

Java代码
  1. function announcementScrollnext(time) {  
  2.    $('annbody').scrollTop++;  
  3.    anncount++;  
  4.    if(anncount != time) {  
  5.     annst = setTimeout('announcementScrollnext(' + time + ')', 10);  
  6.    } else {  
  7.     annrowcount++;  
  8.     annst = setTimeout('announcementScroll()', anndelay);  
  9.    }  
  10.   }  
  11. </script>  
  12. <!--{/if}-->  
  13. </div>  
复制代码
在这段代码下添加:

Java代码
  1. <!-- 首页五格代码开始 -->  
  2. <div class="mainbox forumlist" style="padding:0;">  
  3. <table cellspacing="0" cellpadding="0">  
  4.   <thead class="category">  
  5.   <tr>  
  6.    <td align="center" style="padding:0 1px 0 0"><h3>≡ 论坛图片 ≡</h3></td>  
  7.    <td align="center" style="padding:0"><h3>≡ 最新帖子 ≡</h3></td>  
  8.    <td align="center" style="padding:0 1px 0 1px"><h3>≡ 最新回复 ≡</h3></td>  
  9.    <td align="center" style="padding:0"><h3>≡ 本月热门 ≡</h3></td>  
  10.    <td></td>  
  11.   </tr>  
  12.   </thead>  
  13.   <tr>  
  14.    <td width="24%">  
  15.     <script type="text/javascript" src="pic.php"></script>  
  16.    </td>  
  17.    <td width="25%">  
  18.     <table border="0" cellpadding="0" cellspacing="0" width="100%">  
  19.      <tr valign="top">  
  20.       <td width="24" style="padding:0;border-top:0px;"><img src="images/list.gif" border="0" /></td>  
  21.       <td background="images/listbg.gif" style="line-height:20px;padding:0;border-top:0px;background-repeat: repeat-y" width="100%">  
  22.       <!--{loop $new_post_threadlist $nthread}-->  
  23.        <!--{if $nthread[replies]}-->  
  24.         <div style="overflow: hidden;height: 20px;width: 100%;"><a href="viewthread.php?tid=$nthread[tid]" $nthread['highlight'] title='最新帖子 {LF}所在论坛: $nthread[forumname]{LF}主题标题: $nthread[subject] {LF}主题作者: $nthread[author]{LF}发表时间: $nthread[date]{LF}浏览次数: $nthread[views] 次 {LF}回复次数: $nthread[replies] 次{LF}最后回复: $nthread[lastreplytime]{LF}{lang lastpost}: $nthread[lastposter]'>$nthread[view_subject]</a></div>  
  25.                    <!--{else}-->  
  26.         <div style="overflow: hidden;height: 20px;width: 100%;"><a href="viewthread.php?tid=$nthread[tid]" $nthread['highlight'] title='最新帖子 {LF}所在论坛: $nthread[forumname]{LF}主题标题: $nthread[subject] {LF}主题作者: $nthread[author]{LF}发表时间: $nthread[date]{LF}浏览次数: $nthread[views] 次 {LF}回复次数: $nthread[replies] 次{LF}最后回复: 暂时没有回复'>$nthread[view_subject]</a></div>  
  27.        <!--{/if}-->  
  28.       <!--{/loop}-->  
  29.       </td>  
  30.      </tr>  
  31.     </table>  
  32.    </td>  
  33.    <td width="25%">  
  34.     <table border="0" cellpadding="0" cellspacing="0" width="100%">  
  35.      <tr valign="top">  
  36.       <td width="24" style="padding:0;border-top:0px;"><img src="images/list.gif" border="0" /></td>  
  37.       <td background="images/listbg.gif" style="line-height:20px;padding:0;border-top:0px;background-repeat: repeat-y" width="100%">  
  38.       <!--{loop $new_reply_threadlist $rthread}-->  
  39.        <div style="overflow: hidden;height: 20px;width: 100%;"><a href="viewthread.php?tid=$rthread[tid]" $rthread['highlight'] title='最新回复 {LF}所在论坛: $rthread[forumname]{LF}主题标题: $rthread[subject]{LF}主题作者: $rthread[author]{LF}发表时间: $rthread[date]{LF}浏览次数: $rthread[views] 次{LF}回复次数: $rthread[replies] 次{LF}最后回复: $rthread[lastreplytime]{LF}{lang lastpost}: $rthread[lastposter]'>$rthread[view_subject]</a></div>  
  40.       <!--{/loop}-->  
  41.       </td>  
  42.      </tr>  
  43.     </table>  
  44.    </td>  
  45.    <td width="26%">  
  46.     <table border="0" cellpadding="0" cellspacing="0" width="100%">  
  47.      <tr valign="top">  
  48.       <td width="24" style="padding:0;border-top:0px;"><img src="images/list.gif" border="0" /></td>  
  49.       <td background="images/listbg.gif" style="line-height:20px;padding:0;border-top:0px;background-repeat: repeat-y" width="100%">  
  50.       <!--{loop $new_hot_threadlist $mthread}-->  
  51.        <div style="overflow: hidden;height: 20px;width: 100%;"><a href="viewthread.php?tid=$mthread[tid]" $mthread['highlight'] title='本月热门 {LF}所在论坛: $mthread[forumname]{LF}主题标题: $mthread[subject]{LF}主题作者: $mthread[author]{LF}发表时间: $mthread[date]{LF}浏览次数: $mthread[views] 次{LF}回复次数: $mthread[replies] 次{LF}最后回复: $mthread[lastreplytime]{LF}{lang lastpost}: $mthread[lastposter]'>$mthread[view_subject]</a></div>  
  52.       <!--{/loop}-->  
  53.       </td>  
  54.      </tr>  
  55.     </table>  
  56.    </td>  
  57.    <td>  
  58.     <table border="0" cellpadding="0" cellspacing="0" width="100%">  
  59.      <tr valign="top">  
  60.       <td></td>  
  61.       <td>  
  62.         
  63.       </td>  
  64.      </tr>  
  65.     </table>  
  66.    </td>  
  67.   </tr>  
  68. </table>  
  69.   
  70. <table cellspacing="2" cellpadding="2">  
  71. <tr>  
  72. <td><font color=red><b>Top10: </b></font>$poststar</td>  
  73. </tr>  
  74. </table>  
  75. </div>  
  76. <!-- 首页五格代码结束 -->  
复制代码
更新缓存,刷新论坛即可显示!
如果你是在window下提交到linux的,别忘了更改文件的权限:

Java代码
  1. chmod -R 777 /home/Discuz/upload  
复制代码




附件下载

7.0首页四格_今日TOP10.rar

27.73 KB, 下载次数: 214

全部评论 0

您需要登录后才可以回帖 立即登录
登录
0
0
0
返回顶部