9.关闭access。
第三步:写一个asp程序。(程序我都写好了,你把下面的代码拷贝一下就行了,然后把文件保存成index.asp,并保存到c:\inetpub\wwwroot\bchat\目录下。)
以下内容为程序代码:
<%@language="vbscript" codepage="936"%>
<%option explicit%>
<%
'*************************************************************
'程序名称:asp语音聊天室
'程序实现:必须依赖bchat server,下载地址http://bchat.yinsha.com
'程序设计:madpolice
'完成时间:2003-2-23 17:36:00
'说 明:1.在本人的windows 2000 advanced server上测试通过,
' 不保证在其他环境中能正常运行。
' 2.本人不要求任何版权,但是请保留俺的名字,行不?
'**************************************************************
dim db,connstr,conn,rs,sql,serverip
db="bchat.mdb"
connstr="provider=microsoft.jet.oledb.4.0;data source="&server.mappath(db)
'如果你的服务器采用较老版本access驱动,请用下面连接方法
'connstr="driver={microsoft access driver (*.mdb)};dbq="&server.mappath(db)
set conn=server.createobject("adodb.connection")
conn.open connstr
set rs=server.createobject("adodb.recordset")
serverip=request.servervariables("local_addr")
sql="select * from room order by bport"
rs.open sql,conn,1,1
if rs.eof then
rs.close
set rs=nothing
conn.close
set conn=nothing
response.write "数据库中还没有记录呢!"
response.end
end if
if application("bchat_status")<>"running" then
call startbchat()
rs.movefirst
end if
%>
<html>
<head>
<title>语音聊天室</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<script language="javascript">
var wwwhost="<%=request.servervariables("server_name")%>";
function go(pport){
if(validname(document.form1.elements[0])){
document['form1'].action='http://'+wwwhost+':'+pport+'/';
launchchat();
document['form1'].method='post';
document.form1.submit();
}
}
function validname(str1)
{
var s,i,j;
if (str1.value.length <1) {
alert("请输入您的大名,名字不能为空!");
str1.focus();
return false;
}
return true;
}
var focusok=false;
if (navigator.appname == "netscape") {
focusok=true;
}
vers = navigator.appversion;
if (navigator.appname == "microsoft internet explorer") {
pos = vers.lastindexof('.');
vers = vers.substring(pos-1,vers.length);
}
proper_version = parsefloat(vers);
if(proper_version>=5){
focusok=true;
}
function launchchat() {
var chat = window.open("","chat",
"top=0,left=0,toolbar=no,location=no,directories=no,status=no,
menubar=no,scrollbars=yes,resizable=yes,width=790,height=530");
if(focusok){
chat.focus();
}
return true;
}
</script>
</head>
<body>
<form action=/ method=post name=form1 target="chat" align="center">
<p align=center>请先输大名:<input type="text" name="user" size="10" maxlength="15" ></p>
<center><div align=center>
<table border=1 width="60%">
<%do while not rs.eof%>
<tr height=20>
<td width="70%">
<li><%=rs("bname")%></td>
<td width="30%" align="center">
<input name="r" onclick="go('<%=rs("bport")%>')" type="button" value="进入">
</td></tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<input type="hidden" name="pass" value="bchat">
</td></tr>
</table></div></center></form>
</body>
</html>
<%
conn.close
set conn = nothing
sub startbchat()
dim f1,f2,wsh,currentpath,sourcefile,targetfile,tempstring,tempcommand
currentpath=server.mappath(".")
sourcefile=currentpath&"\2000.ini"
do while not rs.eof
targetfile=currentpath&"\"&rs("bport")&".ini"
set f1=server.createobject("adodb.stream")
f1.type=2
f1.mode=3
f1.charset="gb2312"
f1.open
f1.loadfromfile sourcefile
tempstring=f1.readtext
f1.close
set f1=nothing
tempstring=replace(tempstring,"聊圆",rs("bname"))
tempstring=replace(tempstring,"d:\bchat",currentpath)
tempstring=replace(tempstring,"2000",rs("bport"))
tempstring=replace(tempstring,"0.0.0.0",serverip)
set f2=server.createobject("adodb.stream")
f2.type=2
f2.mode=3
f2.charset="gb2312"
f2.open
f2.writetext tempstring
f2.savetofile targetfile,2
f2.close
set f2=nothing
set f1=server.createobject("adodb.stream")
f1.type=2
f1.mode=3
f1.charset="gb2312"
f1.open
f1.loadfromfile currentpath&"\adminpass_2000.txt"
tempstring=f1.readtext
f1.close
set f1=nothing
set f2=server.createobject("adodb.stream")
f2.type=2
f2.mode=3
f2.charset="gb2312"
f2.open
f2.writetext tempstring
f2.savetofile currentpath&"\adminpass_"&rs("bport")&".txt",2
f2.close
set f2=nothing
tempcommand=currentpath&"\bchat.exe "&targetfile
set wsh=server.createobject("wscript.shell")
wsh.run tempcommand,0,false
set wsh=nothing
rs.movenext
loop
application("bchat_status")="running"
end sub
%> |