选择显示字体大小

手把手教你建asp语音聊天室(2)


第三步:写一个asp程序。(程序我都写好了,你把下面的代码拷贝一下就行了,然后把文件保存成index.asp,并保存到c:\.netpub\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 inte.net 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

%>

  第四步:在浏览器中输入

   http://localhost/bchat/index.asp

  看到结果了吗?


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons