Teach you to build an ASP voice chat room

zhaozj2021-02-16  54

Step 1: Download the voice chat room server server, we want to use BChat Server in the BCHAT studio.

1. Enter http://bchat.yinsha.com/ page; 2. "Hot Headline" in the right side of the page "BCHAT launches 10 users free download version", what we need is it; 3. Click "BCHAT launched After 10 users free download version, I went to the free version of the download page; 4. Download "Windows Version" in the download page (other version I have not used it, I will use the Windows version); 5. Download the file It is bChat.zip to decompress him into a directory (in order to use it in the ASP program on the website, this directory should be a directory of your website, such as c: / inetpub / wwwroot /); 6. Press above After the operation, BCHAT Server is installed in a c: / inetpub / wwwroot / bchat / directory; . Copy all the files in the GB subdirectory to the current directory (the current directory is also a c: / inetpub / wwwroot / bchat / directory), which is installed with a voice chat room with a Simplified Chinese interface. (If you want to install your English interface, copy the files under the English subdirectory to the current directory; if you want to install the traditional Chinese interface, copy the files under the BIG5 subdirectory to the current directory.)

Step 2: Create a database. (Although the voice chat room can be used without building a database, we want the "ASP" voice chat room of the function, so we must use the database!)

1. Run Access to create an empty database, the database name is budd.mdb, the database is saved in the C: / INETPUB / WWWROOT / BCHAT / directory; 2. Select "Use Designer Creating Table"; 3. Add a field. Field Name BNAME, Data Type Select Text; 4. Add a field. Field Name BPORT, Data Type Select Number; 5. Close this (Designer Window). After the point is closed, you prompt you "Whether to save your changes", select "Yes Y", then let you enter the table name, enter Room, and determine. The Access will then prompt "No primary key has not been defined", do not use him, choose No n ". 6. Now the ROOM table is established, but there is no data in it, and we have a few data to him. 7. Double-click the ROOM table to add data; BNAME Enter "One Room" (this is the name of the room, you can write it), enter 5100 there (this is the port number running in BCHAT Server, you can also write. But this The port number cannot be a port that has been used in the system. If you are not familiar with the port, then you should write 5100, 5100 is generally idle); 8. Add a data; BNAME fill in "2 room", bPort fill in 5200; 9. Turn off Access.

Step 3: Write an ASP program. (I have written the program, you will copy the following code, then save the file into index.asp and save it to the c: / inetpub / wwwroot / bchat / directory.)

<% @Language = "vbscript" CODEPAGE = "936"%> <% Option Explicit%> <% '********************************** *********************************** The program name: ASP voice chat room 'program implementation: must rely on bchat Server, download address http://bchat.yinsha.com 'program: Madpolice' Completion time: 2003-2-23 17:36:00 'Description: 1. Test it on your own Windows 2000 Advanced Server,' No Ensure that it can operate normally in other environments. '2. I don't ask for any copyright, but please keep the name, don't you? '********************************************************** ************* DIM DB, CONNSTR, CONN, RS, SQL, Serveripdb = "bchat.mdb" connStr = "provider = microsoft.jet.Oledb.4.0; data source =" & Server. Mappath (DB) 'If your server uses an older version access driver, use the following connection method' connStr = "driver = {Microsoft Access Driver (* .mdb)}; dbq =" & server.mappath (db) set conn = Server.CreateObject ( "ADODB.Connection") conn.Open connStrSet rs = Server.CreateObject ( "ADODB.RecordSet") serverIP = Request.ServerVariables ( "LOCAL_ADDR") sql = "SELECT * FROM room ORDER BY bPort"

Rs.open SQL, CONN, 1, 1IF RS.EOF THEN RS.CLOSE SET RS = Nothing conn.close set conn = nothing response.write "There is no record in the database!" response.endende

IF Application ("BCHAT_STATUS") <> "Running" the call startbchat () rs.movefirstnd IF%> voice chat room </ 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.eferences [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 ("Please enter your name, the name cannot be empty ! "); 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);</p> <p>IF (prot_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> Please lose the big name first: <input type = "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 =" "οnclick =" go ('<% = rs ("BPORT")%>') "type =" button "value =" into "> </ td> </ tr> <% rs.movenextLooprs.closset = Nothing %> <Input type = "hidden" name = "pass" value = "bchat"> </ td> </ tr> </ table> </ div> </ center> </ form> </ body> </ HTML> <% conn.closset conn = NothingSub StartBChat () DIM F1, F2, WSH, CurrentPath, Sourcefile, TargetFile, Tempstring, TempCommand</p> <p>CurrentPath = Server.mappath (".") SourceFile = CurrentPath & "2000.ini"</p> <p>Do While Not Rs.eof TargetFile = CURRENTPATH ​​& "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, "talk round", 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 TEMGETFILE, 2 F2.Close Set F2 = NothingSet 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 &" BPORT ") &". TXT ", 2 F2.Close set f2 = Nothing</p> <p>TempCommand = CurrentPath & "/ bchat.exe" & targetfile set wsh = server.createObject ("wscript.shell") wsh.run tempcommand, 0, false set wsh = Nothing</p> <p>rs.Movenext loop application ("bchat_status") = "Running" End Sub</p> <p>%></p> <p>Step 4: Is it possible to see the result in http://localhost/bchat/index.asp in the browser?</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-24165.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="24165" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.054</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = '1oZ_2FcJjyCfIPMiGtRwpKOzx80bkXx0KrDkQGGqLE4yiB9_2B6KYTNlU6XUPhWszf_2BeOTEWhA6gfLOjsETK5HnFOg_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>