第三步:写一个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=currentPathamp;"\2000.ini"
Do While Not rs.EOF
targetFile=currentPathamp;"\"rs("bPort")amp;".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 currentPathamp;"\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 currentPathamp;"\adminpass_"rs("bPort")amp;".txt",2
f2.Close
Set f2=Nothing
tempCommand=currentPathamp;"\bchat.exe "amp;targetFile
Set wsh=Server.CreateObject("WScript.Shell")
wsh.Run tempCommand,0,false
Set wsh=Nothing
rs.MoveNext
Loop
Application("Bchat_Status")="running"
End Sub
%>
第四步:在浏览器中输入
http://localhost/bchat/index.asp
看到结果了吗?
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/