Board logo

標題: AL8 首頁四格 加入 最多人瀏覽 (四格延伸應用系列) [列印本頁]

作者: Linux0911    時間: 2007-12-8 09:14 PM     標題: AL8 首頁四格 加入 最多人瀏覽 (四格延伸應用系列)

安裝前請先安裝:AL8 首頁四格顯示 for Discuz 6.0.0
http://linux0911.no-ip.info/Discuz/thread-9664-1-1.html

效果如下:
[attach]6018[/attach]

整理:Linux0911
功能:顯示最多人瀏覽的文章列表


開始安裝

1. 修改 ./include/cache.func.php

找到 (加入紅字)
引用:
// AL8 首頁四格顯示 - START
        'newtopic'=> array('newtopic'),
        'newreply'=> array('newreply'),
        'todayvisit'        => array('todayvisit'),
        'topview'=> array('topview'),
// AL8 首頁四格顯示 - END
找到 (加入紅字)
引用:
// AL8 首頁四格顯示 - START
                case 'newtopic':
                        $table = 'threads t, '.$tablepre.'forums f';
                        $cols = "t.tid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name";
                        $fids="填上不需要顯示發新帖區域的 fid 編號, 以逗號作分格, 最後一個不用加上逗號";//例如 "1,2,3";
                        $conditions = "WHERE t.fid<>'$fid' AND f.fid=t.fid AND f.fid NOT IN ($fids) ORDER BY t.dateline DESC LIMIT 0, 11";
                        break;
                case 'newreply':
                        $table = 'threads t, '.$tablepre.'forums f';
                        $cols = "t.tid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name";
                        $fids="填上不需要顯示發新帖區域的 fid 編號, 以逗號作分格, 最後一個不用加上逗號";//例如 "1,2,3";
                        $conditions = "WHERE t.fid<>'$fid' AND f.fid=t.fid AND f.fid NOT IN ($fids) AND  t.replies !=0 ORDER BY t.lastpost DESC LIMIT 0, 11";
                        break;
                case 'todayvisit':
                        $table = 'members';
                        $cols = "COUNT(*)";
                        $datecut = time() - (3600 * 24);
                        $conditions = "WHERE lastactivity>='$datecut' ORDER BY lastvisit DESC";
                        break;
                case 'topview':
                        $table = 'threads t, cdb_forums f';
                        $cols = "t.tid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name";
                        $fids="填上不需要顯示發新帖區域的 fid 編號, 以逗號作分格, 最後一個不用加上逗號"; // 例如 "1,2,3";
                        $conditions = "WHERE t.fid<>'$fid' AND f.fid=t.fid  AND t.closed NOT LIKE 'moved|%' AND f.fid NOT IN ($fids) AND t.replies !=0 ORDER BY t.views DESC LIMIT 0, 11";
                        break;

// AL8 首頁四格顯示 - END
找到 (加入紅字)
引用:
// AL8 首頁四格顯示 - START
                case 'newreply':
                        $hack_cut_str = 26;
                        $new_reply_threadlist = array();
                        $rthread = array();
                        $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
                                while($rthread = $db->fetch_array($query))
                                {
                                $rthread['forumname'] = $rthread['name'];
                                $rthread['view_subject'] = cutstr($rthread['subject'],$hack_cut_str);
                                $rthread['subject'] = cutstr($rthread['subject'],46);
                                $rthread['date']= gmdate('Y-n-j G:i', $rthread['dateline'] + 8 * 3600);
                                $rthread['lastreplytime']= gmdate('Y-n-j G:i', $rthread['lastpost'] + 8 * 3600);
                                if($rthread['highlight'])
                                {
                                        $string = sprintf('%02d', $rthread['highlight']);
                                        $stylestr = sprintf('%03b', $string[0]);
                                        $rthread['highlight'] = 'style="';
                                        $rthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
                                        $rthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
                                        $rthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
                                        $rthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
                                        $rthread['highlight'] .= '"';
                                } else {
                                        $rthread['highlight'] = '';
                                }
                                        $new_reply_threadlist = "<a href=\"redirect.php?tid=$rthread[tid]&goto=lastpost#lastpost\" title=\"論壇: $rthread[forumname]\r\n標題: $rthread[subject]\r\n作者: $rthread[author]\r\n發表時間: $rthread[date]\r\n瀏覽次數: $rthread[views] 次\r\n回覆: $rthread[replies] 次\r\n最後回覆: $rthread[lastreplytime]\r\n最後發表: $rthread[lastposter]\" $rthread[highlight]>$rthread[view_subject]</a><br />";
                                        $data[] = array('content' => $new_reply_threadlist);
                                }
                        break;
                case 'newtopic':
                        $hack_cut_str = 26;
                        $new_post_threadlist = array();
                        $nthread = array();
                        $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
                                while($nthread = $db->fetch_array($query))
                                {
                                        $nthread['forumname'] = $nthread['name'];
                                        $nthread['view_subject'] = cutstr($nthread['subject'],$hack_cut_str);
                                        $nthread['subject'] = cutstr($nthread['subject'],46);
                                        $nthread['date']= gmdate('Y-n-j G:i', $nthread['dateline'] + 8 * 3600);
                                        $nthread['lastreplytime']= gmdate('Y-n-j G:i', $nthread[lastpost] + 8 * 3600);
                                                if($nthread['highlight'])
                                                {
                                                        $string = sprintf('%02d', $nthread['highlight']);
                                                        $stylestr = sprintf('%03b', $string[0]);
                                                        $nthread['highlight'] = 'style="';
                                                        $nthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
                                                        $nthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
                                                        $nthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
                                                        $nthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
                                                        $nthread['highlight'] .= '"';
                                                } else {
                                                        $nthread['highlight'] = '';
                                                }
                                        $new_post_threadlist = $nthread[replies] ? "<a href=\"redirect.php?tid=$nthread[tid]&goto=lastpost#lastpost\" title=\"論壇: $nthread[forumname]\r\n標題: $nthread[subject]\r\n作者: $nthread[author]\r\n發表時間: $nthread[date]\r\n瀏覽次數: $nthread[views] 次 \r\n回覆: $nthread[replies] 次\r\n最後回覆: $nthread[lastreplytime]\r\n最後發表: $nthread[lastposter]\" $nthread[highlight] >$nthread[view_subject]</a><br />" : "<a href=\"redirect.php?tid=$nthread[tid]&goto=lastpost#lastpost\" title=\"論壇: $nthread[forumname]\r\n標題: $nthread[subject]\r\n作者: $nthread[author]\r\n發表時間: $nthread[date]\r\n瀏覽次數: $nthread[views] 次\r\n回覆: 暫時沒有回覆\" $nthread[highlight] >$nthread[view_subject]</a><br />";
                                        $data[] = array('content' => $new_post_threadlist);
                                }
                        break;
                case 'topview':
                        $hack_cut_str = 26;
                        $topview_threadlist = array();
                        $topthread = array();
                        $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
                                while($topthread = $db->fetch_array($query))
                                {
                                        $topthread['forumname'] = $topthread['name'];
                                        $topthread['view_subject'] = cutstr($topthread['subject'],$hack_cut_str);
                                        $topthread['subject'] = cutstr($topthread['subject'],46);
                                        $topthread['date']= gmdate('Y-n-j G:i', $topthread['dateline'] + 8 * 3600);
                                        $topthread['lastreplytime']= gmdate('Y-n-j G:i', $topthread[lastpost] + 8 * 3600);
                                                if($topthread['highlight'])
                                                {
                                                        $string = sprintf('%02d', $topthread['highlight']);
                                                        $stylestr = sprintf('%03b', $string[0]);
                                                        $topthread['highlight'] = 'style="';
                                                        $topthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
                                                        $topthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
                                                        $topthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
                                                        $topthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
                                                        $topthread['highlight'] .= '"';
                                                } else {
                                                        $topthread['highlight'] = '';
                                                }
                                        $topview_threadlist = $topthread[replies] ? "<a href=\"redirect.php?tid=$topthread[tid]&goto=lastpost#lastpost\" title=\"論壇: $topthread[forumname]\r\n標題: $topthread[subject]\r\n作者: $topthread[author]\r\n發表時間: $topthread[date]\r\n瀏覽次數: $topthread[views] 次 \r\n回覆: $topthread[replies] 次\r\n最後回覆: $topthread[lastreplytime]\r\n最後發表: $topthread[lastposter]\" $topthread[highlight] >$topthread[view_subject]</a><br />" : "<a href=\"redirect.php?tid=$topthread[tid]&goto=lastpost#lastpost\" title=\"論壇: $topthread[forumname]\r\n標題: $topthread[subject]\r\n作者: $topthread[author]\r\n發表時間: $topthread[date]\r\n瀏覽次數: $topthread[views] 次\r\n回覆: 暫時沒有回覆\" $topthread[highlight] >$topthread[view_subject]</a><br />";
                                        $data[] = array('content' => $topview_threadlist);
                                }
                        break;

// AL8 首頁四格顯示 - END
更新快取


2. 修改 ./include/newthread.inc.php

找到 (加入紅字)
引用:
// AL8 首頁四格顯示 - START
        require_once DISCUZ_ROOT.'./include/cache.func.php';
                updatecache('newtopic');
                updatecache('topview');
// AL8 首頁四格顯示 - END
3. 修改 ./include/newreply.inc.php

找到 (加入紅字)
引用:
// AL8 首頁四格顯示 - START
        require_once DISCUZ_ROOT.'./include/cache.func.php';
                updatecache('newreply');
                updatecache('newtopic');
                updatecache('topview');
// AL8 首頁四格顯示 - END
3. 修改 topicadmin.php

找到 (加入紅字)
引用:
// AL8 首頁四格顯示 - START
        updatecache('newreply');
        updatecache('newtopic');
        updatecache('topview');
// AL8 首頁四格顯示 - END
4. 修改 index.php

找到 (加入紅字)
引用:
// AL8 首頁四格顯示 - START
if(!$statstatus && $discuz_uid) {
        require_once DISCUZ_ROOT.'./include/counter.inc.php';
}
require_once DISCUZ_ROOT.'./include/misc.func.php';
$mem_home = convertip($onlineip, $datadir = "./");
require_once DISCUZ_ROOT.'./forumdata/cache/cache_todayvisit.php';
$todayvisit=$_DCACHE['todayvisit']['0']['COUNT(*)'] ;
@include './forumdata/cache/cache_newtopic.php';
@include './forumdata/cache/cache_newreply.php';
@include './forumdata/cache/cache_topview.php';
// AL8 首頁四格顯示 - END
5. 修改 foruminfo.htm

找到 (修改紅字為 5)
引用:
<td colspan="4">
找到 (使用者欄, 修改其比例適合自己論壇風格)
引用:
<td style="width: 25%">
找到 (論壇資料欄, 修改其比例適合自己論壇風格)
引用:
<td style="width: 21%">
找到 (最新文章欄, 修改其比例適合自己論壇風格)
引用:
<td style="width: 27%">
找到 (最新回覆欄, 修改其比例適合自己論壇風格)
引用:
<td style="width: 27%">
找到
複製內容到剪貼簿
代碼:
                                <h4 style="font-size: 11pt">最新回覆文章</h4>
                                <table cellspacing="0" cellpadding="0">
                                        <!--{loop $_DCACHE['newreply'] $newreply}-->
                                                $newreply[content]
                                        <!--{/loop}-->
                                </table>
                        </td>
下面添加 (修改紅字比例適合自己論壇風格)
引用:
<!--// 最多人瀏覽 - START-->
                        <td style="width: 21%">
                                <h4 style="font-size: 11pt">最多人瀏覽</h4>
                                <table cellspacing="0" cellpadding="0">
                                        <!--{loop $_DCACHE['topview'] $topview}-->
                                                $topview[content]
                                        <!--{/loop}-->
                                </table>
                        </td>
<!--// 最多人瀏覽 - END-->
完成
作者: hses    時間: 2009-7-31 07:08 PM

我遇到的錯誤 修正辦法 麻煩看一下
第一步的
複製內容到剪貼簿
代碼:
                case 'topview':
                        $table = 'threads t, cdb_forums f';
                        $cols = "t.tid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name";
                        $fids="填上不需要顯示發新帖區域的 fid 編號, 以逗號作分格, 最後一個不用加上逗號"; // 例如 "1,2,3";
                        $conditions = "WHERE t.fid<>'$fid' AND f.fid=t.fid  AND t.closed NOT LIKE 'moved|%' AND f.fid NOT IN ($fids) AND t.replies !=0 ORDER BY t.views DESC LIMIT 0, 11";
                        break;
改成
複製內容到剪貼簿
代碼:
                case 'topview':
                        $table = 'threads t, cdb_forums f';
                        $cols = "t.tid, t.subject, t.author, t.dateline, t.views, t.replies, t.lastpost, t.lastposter, t.highlight, f.name";
                        $fids="填上不需要顯示發新帖區域的 fid 編號, 以逗號作分格, 最後一個不用加上逗號"; // 例如 "1,2,3";
                        $conditions = "WHERE t.fid<>'$fid' AND f.fid=t.fid  AND t.closed NOT LIKE 'moved|%' AND f.fid AND t.replies !=0 ORDER BY t.views DESC LIMIT 0, 11";
                        break;
要把 NOT IN ($fids) 哪掉才可以




歡迎光臨 Linux0911 Forum (http://linux0911.no-ip.info/Discuz/) Powered by Discuz! 6.0.0