==========================================================
聊天室插件 hack for discuz! 4.x
==========================================================
功能介紹:整合到Discuz! ,註冊會員才能使用,可以使用表情符號,可以私聊、拒絕指定會員進入,首頁顯示聊天室使用情況。
參考程序:King_of_Dragons的xmbchat 1.01.04
整合修改:雪狼 (伊樂園中文論壇) http://www.e-traderland.net
日期: 2003年12月12日
D4修改者:jay0909 (全球科技研究院) http://www.goolly.com
日期: 2005年02月07日
安裝說明:
1. 按壓縮包內的目錄結構將全部文件文件上傳到論壇根目錄,
- chatstyle.css
- chat.php
- chatinput.php
- chatinputadd.php
- chatmessages.php
- chatrefresh.php
- chatusers.php
將/chatlogs目錄下的 2 個文件上傳到 ./chatlogs,並且屬性設為 666。
- messages.log
- users.log
將/images/default目錄的 2 個圖■文件上傳到 ./images/default
- wisper.gif
- chatting.gif
========================================
2. 在後台升級據數庫,指令如下:
ALTER TABLE `cdb_members` ADD `allowchat` TINYINT( 1 ) DEFAULT '1' NOT NULL ;
註:這是以後拒絕某會員進入聊天室的設定,默認為 「1」,即允許進入聊天室,「0」 則是拒絕進入。
據數表的前綴 「cdb」 根據您自己 config.php 的作修改。
========================================
3. 打開 index.php 查找:
$onlineinfo = explode("\t", $onlinerecord);
在後面加入:
// 聊天室 hacked by 雪狼
$LINES = file("chatlogs/users.log");
sort($LINES);
$chattally = "";
$howmanychatters = 0;
$now = time();
$whileago = $now - 30;
foreach ($LINES as $lines){
chop($lines);
list($chatonlinename, $chatonlineactive) = split("==W==",$lines);
if($whileago <= $chatonlineactive){
$chattally = "$chattally, <a href=\"viewpro.php?username=$chatonlinename\">$chatonlinename</a>";
$howmanychatters++;
}
}
if($howmanychatters == 0){
$howmanychatters = "當前無人聊天";
$chattally = " ";
} elseif ($howmanychatters == 1){
$howmanychatters = "當前有 <b>$howmanychatters</b> 人在發呆.";
$chattally = substr($chattally,2,strlen($chattally)-2);
} elseif ($howmanychatters >= 2){
$howmanychatters = "當前有 <b>$howmanychatters</b> 人在聊天.";
$chattally = substr($chattally,2,strlen($chattally)-2);
}
// 聊天室 hack 完畢
========================================
4. 編輯 header.htm 模板,
查找:
<script language="JavaScript" src="include/common.js"></script>
在後面添加:
<script language="JavaScript">
function chatlaunch() {window.open("chat.php","chat","width=800,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no");}
</script>
接著查找:
<!--{if $allowviewstats}-->| <a href="stats.php" id="stats">{lang statistics}</a><!--{/if}-->
在後面添加:
| <a href="javascript: chatlaunch();"><font class="navtd">聊天室</font></a>
========================================
5. 編輯 index.htm 模板,
查找:
<!--{if $whosonlinestatus}-->
<!--{if $detailstatus}-->
在前面添加:
<!--{if empty($gid)}-->
<tr><td colspan="3" class="header"><img src="{IMGDIR}/indexicon.gif" align="absmiddle"> <span class="bold"><a href="javascript: chatlaunch();" style="color: {HEADERTEXT}">聊天室</a></span> - $howmanychatters</td>
</tr>
<tr class="smalltxt" style="color: {HEADERTEXT}">
<td bgcolor="{ALTBG1}" width="5%" align="center" valign="middle"><img src="images/default/chatting.gif" align="absmiddle"></td>
<td bgcolor="{ALTBG2}" colspan="2" valign="middle" onMouseOver="this.style.backgroundColor='{ALTBG1}'" onMouseOut="this.style.backgroundColor='{ALTBG2}'">$chattally</td>
</tr>
<!--{/if}-->
========================================
OK!完成!
========================================