Non-refresh chat room (SMS)

xiaoxiao2021-03-06  57

Main page index.asp: <% @ language = "vbscript" codepage = "936"%> < Meta http-equiv = "content-type" content = "text / html; charSet = GB2312"> chat room </ title> <link href = "style.css" rel = "stylesheet" type = "text / css"> </ head></p> <p><body></p> <p><script language = "javascript"> var t_room, t_log, t_user; var phone, srcphone, province, content; var room, log, user, myroomid = 0, PID; log = array (); user = array (); < % SET RS = Conn.execute ("SELECT TOP 1 Chat_id As ID from chat_log where chat_id in (SELECT TOP 50 chat_id from chat_log order by chat_id") response.write ("pid =" & r ("id" ) & ";")%> </ script> <script language = "javascript" src = "function.js"> </ script> <table width = "768" border = "0" align = "center" cellpadding = "0" cellspacing = "0"> <form name = "form1" method = "post" action = "" "=" "Return False;"> <tr> <td width = "11%" Valign = "TOP"> <div align = "center"> <select id = "chat_room" onchange = "change_room ();"> </ select> <BR> <select id = "chat_user" name = "SELECT" size = "25" onchange = "Chat_user_change ();"> </ select> <br> <span onclick = "LOAD_ROOM ();" Style = "CURSOR: HAND;"> Refresh room list </ span> <br> <span onclick = "loading_user "Style =" CURSOR: HAND; "> Refresh User List </ span> </ div> </ td> <td width =" 89% "VALIGN =" TOP "> <textarea name = "log" rows = "30" wrap = "virtual" id = "log"> </ TEXTAREA> </ td> <select name = "tophone"</p> <p>Onchange = "srcphone = this.value;"> </ select> </ td> <td> <input name = "content" type = "text" id = "limited" size = "90" maxlength = "140" onkeydown = "if (event.keycode == 13) {send ();}"> <input name = "sendtoServer" type = "button" id = "sendtoServer" onclick = "Send ();" Value = "Send"> <Input Type = "Button" Name = "Submit" Value = "Exit" OnClick = "Window.Location.href = 'logout.asp';"> </ td> </ tr> </ form> </ table> </ body> </ html> Very critical function function.js: // javascript DocumentWindow.οnlοad = function init () {load_log (); loading_user (); load_room ();} function getpage (url) {var XML = NEW ActiveXObject ("Microsoft.xmlhttp"); XML.Open ("Get", URL, FALSE); XML.send (); Return Unescape (XML.ResponseText);} Function PostData (URL, Body) {var XML = New ActiveXObject ("Microsoft.xmlhttp"); XML.Open ("POST", URL, FALSE); XML.SetRequestHeader ("Content-Type", "Application / X-WWW-FORM-URLENCODED" XML.SetRequestHeader ("Content" -Length ", escape (body) .length) xml.send (body);} function load_room () {var value = getpage (" chat_room.asp "); var str = value. Split ("#"); var ID, roomname, Temp; Room = New ActiveXObject ("scripting.dictionary"); var i = str.length-1; while (i-> 0) {TEMP = STR [i] .Split ("*"); id = Temp [0]; roomname = Temp [1]; room.add (id, roomname);} show_room (); // t_room = setTimeout ("Load_room ();", 60000 } function show_room () {var i; for (i =</p> <p>Document.form1.chat_room.Options.Length; I> 0; I -) {document.form1.chat_room.Options.Remove (I-1); Document.form1.chat_room.Options.add (New Option) ", 0)); a = (NEW VBARRAY (room.items ()))). Toarray (); for (i in a) {document.form1.chat_room.Options.add (New Option (A [i], i ))); Document.form1.chat_ancy}} function load_user () {var value = getpage ("chat_user.asp"); var str = value.split ("#"); var userid, nickname, roomid , Temp; Var i; i = user.Length-1; while (i-> = 0) {user.pop ();} i = str.length-1; while (i-> 0) {TEMP = STR [i] .split ("*"); userid = Temp [0]; nickname = Temp [1]; roomid = temp [2]; user.push (userid, nickname, roomid);} show_user (); / / t_user = setTimeout ("LOAD_USER ();"} function show_user () {var i; for (i = Document.form1.chat_user.Options.Length; I> 0; I -) {document.form1 .ss_user.Options.remove (i-1); Document.form1.chat_user.Options.add (New Option ("Everyone", 278810); i = user.length-1; while (i> = 0) {IF (user [i] == myroomid || myroomid == 0) {D Ocument.form1.chat_user.Options.Add (New Option (user [i-1], user [i-2]));} i - = 3;} Document.form1.chat_user.selectedIndIndex = myroomid;} function load_log ) {Var value = getPage ("chat_log.asp? Id =" pid); var str = value.split ("#"); var ID, roomid, msgbody; var i = str.length-1; while (i -> 0) {TEMP = STR [I] .split ("*"); id = Temp [0]; roomid = Temp [1]; msgbody = temp [2]; log.push (roomid, msgbody); PID = ID;} if (str.length> 1) {show_log ();} t_log = settimeout ("LOAD_LOG ();", 5000);} function show_log () {var i =</p> <p>Log.Length-1; var str = ""; while (i> = 0) {if (log [i-1] == myroomid || myroomid == 0) {STR = log [i] .tostring () "/ n";} i - = 2;} Document.form1.log.Value = str;} function change,}} function change_room () {myroomid = document.form1.chat_room.selectedIndIndex; // cleArtimeout (t_room); // cleArtimeout T_user); // cleartimeout; show_room (); show_user (); show_log ();} function chat_user_change () {var i; for (i = 0; i <document.form1.chat_user.Options.LENGTH; i ) {If (Document.form1.chat_user.Options [i] .selected) {var j; for (j = 0; j <document.form1.tophone.Options.LENGTH; J ) IF (Document.form1.tophone.Options [J] .text == Document.form1.chat_user.Options [i] .text) Break; if (j == Document.form1.tophone.Options.Length) {document.form1.tophone.Options.add (new option (Document.form1.chat_user.Options [i] .text, document.form1.chat_user.value);} Document.form1.tophone.Options [j] .selected = true;}} srcphone = True;}} srcphone = document.form1.chat_user. Value;} Function Send () {Try {var body = "content =" escape (do Cument.form1.content.value) "& srcphone =" escape (srcphone); // body = escape (body); PostData ("chat_send.asp", body); //getpage ("chat_send.asp?" Body); Document.form1.content.Value = ""; Document.form1.content.focus ();} catch (e) {Alert (e.description);}} Return to chat content chat_log.asp: <! #include file = "conn.asp" -> <! - # include file = "chklogin.asp" -> <% response.expires = -1 response.expiresabsolute = now () - 1 response.cachecontrol = " No-cache "if ISNUMERIC (Request (" ID "</p> <p>)) The set rs = conn.execute ("SELECT TOP 50 * from chat_log where tophone is not null and chat_id>" & request ("ID") & "Order by chat_id desc") While NOT RS.EOF Response.write (escape) (RS ("chat_id") & "" "") & "" ") & rs (" msgbody ") &" # ")) rs.movenext wendend IF%> Get a list of rooms Chat_Room .asp: <! - # = = "conn.asp" -> <! - # include file = "chklogin.asp" -> <% response.expires = -1 response.expiresabsolute = now () - 1 Response.cachecontrol = "no-cache" set = conn.execute ("Select * from chat_room order by id desc") While NOT RS.EOFRESPONSE.WRITE (ESCAPE (RS ("ID") & "*" & rs ("ROOMNAME") & "#")) rs.movenextwend%> Responsible for acquiring online user chat_user.asp: <! - # include file = "conn.asp" -> <! - # include file = "chklogin .asp "-> <% response.expires = -1 Response.expiresabsolute = now () - 1 response.cachecontrol =" no-cache "set = conn.execute (" Select srcphone, userid, nickname = case left Phone, 3) WHEN '133' THEN NICKNAME '·' WHEN '130' TEN NICKNAME '·' Else Nickname end, roomid from dbo.chat_user where state = 1 Order by User ID ") WHILE NOT RS.EOFRESPONSE.WRITE (" SrcPhone ") & rs (" Nickname ") &" * "& rs (" roomid ") &" # ") rs.MovenextWend%> Responsible to send chat content chat_send.asp: <! - # include file = "conn.asp" -> <! - # include file = "chklogin.asp" -> <% 'Exec Chat '13500000000', 'ME'</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-113357.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="113357" 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.045</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 = 'sb_2FCFbtp2FbFk1D_2FROTBjlKjqmvD2V_2FRWbZdh27_2F62s274yiGzbEYEjTfwgvPgjH_2FlcL261YfZCIPbXkcGwsMA_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>