【插件資訊】 插件名稱:首頁四格顯示 for Discuz 7.0 [BIG5&UTF-8繁體]
適用版本:7.0
語言編碼:UTF8-繁
插件作者:alan888
版權所屬:alan888
原帖連結:
http://www.alan888.com/Discuz/...-1-1.html### 支持網站:
http://www.al....com 【插件說明】 首頁四格顯示 for Discuz 7.0 [BIG5&UTF-8繁體][20090201 20:35更新]
繁體版 作 者︰
alan888 D7修改︰EricB
適用版本︰Discuz 7.0
修改地方︰index.php, logging.php, topicadmin.php, include/newthread.inc.php, include/newreply.inc.php, include/editpost.inc.php, include/counter.inc.php, include/cache.func.php, discuz 模板, 後台
加入文件︰foruminfo 模板 (附件 1 & 2)
免安裝版只適合全新論壇。 本貼部份代碼參考自
http://www.alan888.com/Discuz/...p?tid=160050(tengho)
安裝程序
1. 修改 include/cache.func.php (UTF-8版儲存時請將編碼改為UTF-8)
修改完成此文件後請即時到後台 -> 更新緩存 找
更換為
'medals' => array('medals'),
'newtopic' => array('newtopic'),
'newreply' => array('newreply'),
'todaynewmems' => array('todaynewmems'),
'todayvisit' => array('todayvisit'),
再找
case 'medals':
$table = 'medals';
$cols = 'medalid, name, image';
$conditions = "WHERE available='1'";
break;
在下面加上
(注意先填妥紅字部份)
填上不需要顯示帖子區域 由於使用快取檔型式, 故某些私密區不能判斷會員權限來顯示發帖及回帖, 所以要先修改及取代下紅字部份 "填上
不需要顯示帖子區域的 fid 編號, 以逗號作分格, 最後一個不用加上逗號" 部份, 例如希望不顯示 fid 1,3,5 便填上 "$fids="1,3,5";"
如果希望全部顯示者, 請將下兩段的
NOT IN ($fids) (藍色字顯示部份)刪除, 否則會出現數據錯誤的顯示
QUOTE:
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 'todaynewmems':
$table = 'members';
$cols = 'COUNT(*)';
$datecut = time() - (3600 * 24);
$conditions = "WHERE regdate>='$datecut'";
break;
case 'todayvisit':
$table = 'members';
$cols = "COUNT(*)";
$datecut = time() - (3600 * 24);
$conditions = "WHERE lastactivity>='$datecut' ORDER BY lastvisit DESC";
break;
找
case 'magics':
while($magic = $db->fetch_array($query)) {
$data[$magic['magicid']]['identifier'] = $magic['identifier'];
$data[$magic['magicid']]['available'] = $magic['available'];
$data[$magic['magicid']]['name'] = $magic['name'];
$data[$magic['magicid']]['description'] = $magic['description'];
$data[$magic['magicid']]['weight'] = $magic['weight'];
$data[$magic['magicid']]['price'] = $magic['price'];
}
break;
下面加上
case 'newreply':
$hack_cut_str = 26;
$new_reply_threadlist = array();
$rthread = array();
$colorarray = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
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('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
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 = "<a href=\"viewthread.php?tid=$nthread[tid]\" 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 />";
$data[] = array('content' => $new_post_threadlist);
}
break;
2. 修改 include/newthread.inc.php
找
showmessage('post_newthread_succeed', "viewthread.php?tid=$tid&extra=$extra");
在上面加上 require DISCUZ_ROOT.'./include/cache.func.php';
updatecache('newtopic');
3. 修改 include/newreply.inc.php
找
[table=95.01%][tr][td]
showmessage($replymessage, "viewthread.php?tid=$tid&pid=$pid&page=".(@ceil(($thread['special'] ? $thread['replies'] + 1 : $thread['replies'] + 2) / $ppp))."&extra=$extra#pid$pid"); [/td][/tr][/table]
在上面加上
4. 修改 include/editpost.inc.php
找到及刪除
找
在下面加上
找
在下面加上
找
在下面加上
5. 修改 include/counter.inc.php
找
更換為
if (!$sessionexists || $discuz_uid) {
if (ereg("MAXTHON ([a-z0-9.]+)", $visitor['agent'], $browser)) {
$browser_ver = $browser[1];
$visitor_browser = "Maxthon " . $browser_ver;
$visitor['browser'] = 'Maxthon';
} elseif (ereg("MSIE ([a-z0-9.]+)", $visitor['agent'], $browser)) {
$browser_ver = $browser[1];
$visitor_browser = "Internet Explorer " . $browser_ver;
$visitor['browser'] = 'MSIE';
} elseif (ereg("Firefox/([a-z0-9.]+)", $visitor['agent'], $browser)) {
$browser_ver = $browser[1];
$visitor_browser = "Mozilla Firefox " . $browser_ver;
$visitor['browser'] = 'Mozilla';
} elseif (ereg("Chrome/([a-z0-9.]+) Safari/", $visitor['agent'], $browser)) {
$browser_ver = $browser[1];
$visitor_browser = "Google Chrome " . $browser_ver;
$visitor['browser'] = 'Chrome';
} elseif (ereg("Version/([a-z0-9.]+)([a-zA-Z0-9/ ]*) Safari/", $visitor['agent'], $browser)) {
$browser_ver = $browser[1];
$visitor_browser = "Apple Safari " . $browser_ver;
$visitor['browser'] = 'Safari';
} elseif (strpos($visitor['agent'], "PSP")) {
$visitor_browser = "PSP Browser";
$visitor['browser'] = 'PSP Browser';
} elseif (ereg("Opera/([a-z0-9.]+)", $visitor['agent'], $browser)) {
$browser_ver = $browser[1];
$visitor_browser = "Opera " . $browser_ver;
$visitor['browser'] = 'Opera';
} elseif (strpos($visitor['agent'], "Netscape")) {
$visitor_browser = "Netscape";
$visitor['browser'] = 'Netscape';
} elseif (strpos($visitor['agent'], "Lynx")) {
$visitor_browser = "Lynx";
$visitor['browser'] = 'Lynx';
} elseif (strpos($visitor['agent'], "Konqueror")) {
$visitor_browser = "Konqueror";
$visitor['browser'] = 'Konqueror';
} elseif (strpos($visitor['agent'], "Mozilla/5.0")) {
$visitor_browser = "Mozilla";
$visitor['browser'] = 'Mozilla';
} else {
$visitor_browser = "其它";
$visitor['browser'] = 'Other';
}
if (strpos($visitor['agent'], "NT 6.1")) {
$visitor_os = "Windows 7";
$visitor['os'] = 'Windows';
} elseif (strpos($visitor['agent'], "NT 6.0")) {
$visitor_os = "Windows Vista";
$visitor['os'] = 'Windows';
} elseif (strpos($visitor['agent'], "NT 5.1")) {
$visitor_os = "Windows XP";
$visitor['os'] = 'Windows';
} elseif (strpos($visitor['agent'], "PSP")) {
if (ereg("system=(.*)\)", $_SERVER["HTTP_X_PSP_BROWSER"], $os)) {
$visitor_os = "PSP $os[1]";
$visitor['os'] = "PSP $os[1]";
}
} elseif (strpos($visitor['agent'], "NT 5.2")) {
$visitor_os = "Windows Server 2003";
$visitor['os'] = 'Windows';
} elseif (strpos($visitor['agent'], "NT 5")) {
$visitor_os = "Windows 2000";
$visitor['os'] = 'Windows';
} elseif (strpos($visitor['agent'], "4.9")) {
$visitor_os = "Windows ME";
$visitor['os'] = 'Windows';
} elseif (strpos($visitor['agent'], "NT 4")) {
$visitor_os = "Windows NT 4.0";
$visitor['os'] = 'Windows';
} elseif (strpos($visitor['agent'], "98")) {
$visitor_os = "Windows 98";
$visitor['os'] = 'Windows';
} elseif (strpos($visitor['agent'], "95")) {
$visitor_os = "Windows 95";
$visitor['os'] = 'Windows';
} elseif (strpos($visitor['agent'], "Mac")) {
$visitor_os = "Macintosh";
$visitor['os'] = 'Macintosh';
} elseif (strpos($visitor['agent'], "Linux")) {
$visitor_os = "Linux";
$visitor['os'] = 'Linux';
} elseif (strpos($visitor['agent'], "Unix")) {
$visitor_os = "Unix";
$visitor['os'] = 'Other';
} elseif (strpos($visitor['agent'], "FreeBSD")) {
$visitor_os = "FreeBSD";
$visitor['os'] = 'FreeBSD';
} elseif (strpos($visitor['agent'], "SunOS")) {
$visitor_os = "SunOS";
$visitor['os'] = 'SunOS';
} elseif (strpos($visitor['agent'], "OS/2")) {
$visitor_os = "OS/2";
$visitor['os'] = 'OS/2';
} elseif (strpos($visitor['agent'], "AIX")) {
$visitor_os = "AIX";
$visitor['os'] = 'AIX';
} elseif (preg_match("/(Bot|Crawl|Spider)/i", $visitor['agent'])) {
$visitor_os = "Spiders";
$visitor['os'] = 'Spiders';
} else {
$visitor_os = "其它";
$visitor['os'] = 'Other';
}
6. 修改 topicadmin.php
找
在下面加上
找
在上面加上
7. 修改 logging.php
找
在下面加上
8. 修改 index.php
找
在上面加上
版本1 //-----------hack AL8 Info
if(!$statstatus && $discuz_uid){
require_once DISCUZ_ROOT.'./include/counter.inc.php';
$unreadpmnum = $db->result_first("SELECT COUNT(*) FROM ".UC_DBTABLEPRE."pms WHERE msgtoid='$discuz_uid' AND new=1");
}
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(*)'];
require_once DISCUZ_ROOT.'./forumdata/cache/cache_todaynewmems.php';
$todaynewmems = $_DCACHE['todaynewmems']['0']['COUNT(*)'];
@include './forumdata/cache/cache_newtopic.php';
@include './forumdata/cache/cache_newreply.php';
//-----------hack AL8 Info End
版本2 //-----------hack AL8 Info
if(!$statstatus && $discuz_uid){
require_once DISCUZ_ROOT.'./include/counter.inc.php';
$unreadpmnum = $db->result_first("SELECT COUNT(*) FROM ".UC_DBTABLEPRE."pms WHERE msgtoid='$discuz_uid' AND new=1");
$member_avatar = $db->result_first("SELECT avatar FROM {$tablepre}memberfields WHERE uid='$discuz_uid'");
if(!$member_avatar){
$member_avatar = "images/avatars/noavatar.gif";
} else {
list($width, $height) = getimagesize($member_avatar);
$avatar['width'] = 150;
$avatar['height'] = $avatar['width'] * $width / $height;
}
}
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(*)'];
require_once DISCUZ_ROOT.'./forumdata/cache/cache_todaynewmems.php';
$todaynewmems = $_DCACHE['todaynewmems']['0']['COUNT(*)'];
@include './forumdata/cache/cache_newtopic.php';
@include './forumdata/cache/cache_newreply.php';
//-----------hack AL8 Info End
9. 修改 register.php
找
在上面加上
8. 修改 discuz 模板
找
更換為
10. 進入後台
全局 >> 優化設置 >> 搜索引擎優化
在「其他頭部信息」中加入
版本1 <style type="text/css">
<!--
#announce { border-top: 1px solid #888; line-height: 36px; height: 36px; overflow: hidden; }
#announce div { padding: 0 10px; line-height: 35px !important; height: 36px; overflow-y: hidden;}
#announce li { float: left; margin-right: 20px; padding-left: 10px; background: url('images/default/arrow_right.gif') no-repeat 0 50%; white-space: nowrap; }
#announce li em { font-size: 0.83em; margin-left: 5px; color: {TEXT}; }
.listinfo p {line-height: 1.5em; }
.listinfo a { color: {TEXT}; }
.listinfo th { border-top: 1px solid #888; vertical-align: top; color:{TEXT}; text-align: left; padding: 5px; }
.listinfo cite { font: 1em Lucia Console; font-weight: bold; }
.listinfo strong { font-weight: bold; }
.listinfo th.rborder { border-right: 1px solid {CATBORDER}; }
button.submitmini { margin-left: 0.5em; padding: 0 2px; }
#loginstatus { font-weight: normal; }
span.bold { font-weight: bold; }
//-->
</style>
版本2 <style type="text/css">
<!--
#announce { border-top: 1px solid #888; line-height: 36px; height: 36px; overflow: hidden; }
#announce div { padding: 0 10px; line-height: 35px !important; height: 36px; overflow-y: hidden;}
#announce li { float: left; margin-right: 20px; padding-left: 10px; background: url('images/default/arrow_right.gif') no-repeat 0 50%; white-space: nowrap; }
#announce li em { font-size: 0.83em; margin-left: 5px; color: {TEXT}; }
.listinfo p {line-height: 1.5em; }
.listinfo a { color: {TEXT}; }
.listinfo th { border-top: 1px solid #888; vertical-align: top; color:{TEXT}; text-align: left; padding: 5px; }
.listinfo cite { font: 1em Lucia Console; font-weight: bold; }
.listinfo strong { font-weight: bold; }
.listinfo th.rborder { border-right: 1px solid {CATBORDER}; }
button.submitmini { margin-left: 0.5em; padding: 0 2px; }
#loginstatus { font-weight: normal; }
span.bold { font-weight: bold; }
#info p {
padding: 0px 0px 0px 12px;
background: url('images/common/dot_list.gif') no-repeat 0px 2px;
}
#info p[style] {
padding: 0px;
background: none;
}
#newtopic a, #newreply a {
padding: 0px 0px 0px 14px;
}
#newtopic a {
background: url('images/common/dot_1.gif') no-repeat 0px 2px;
}
#newreply a {
background: url('images/common/dot_2.gif') no-repeat 0px 2px;
}
//-->
</style>
12. 下載附件 foruminfo.htm, 並執行
a. 根據自身討論區對下一段作出調整
CODE:來自 $mem_home 的訪客, 現{lang register}成為會員即獲贈現金 100 點, 用作參予本討論區的活動之用。
b. 上載至 templates/default 目錄下
c. 如果修改時漏了 "更新緩存"步驟, 可把 forumdata/cache 目錄下的檔案刪掉便可
~完成~