如何在社区建立一个寻呼台?
来源:asp之家 发布时间:2009-11-08 18:59:00
bbssend.asp
'寻呼台页面,向在线网友发送寻呼信息
<%@ Language=VBScript %>
<%
users=split(application("OnlineUser"),",")
' 分割得到当前在线用户的列表,保存到一个数组中
If trim(request("act"))="wantsend" then
' 判断操作状态
who=trim(Request.Form("who"))
' 获取被寻呼网友昵称
content=trim(Request.Form("content"))
' 呼叫内容
meme=trim(request("userid"))
' 获取发送寻呼的网友昵称
If who="" or content="" then
Response.Redirect "error.asp?msg=噢,姓名或者讯息内容不能为空,请重新输入!"
' error.asp为错误信息提示页面,可自己定制
end if
' 以下将发送信息送到寻呼信息队列
If trim(application("Message"))="" then
Application.Lock
application("Message")=who & "$" & content & "$" & meme
' 放置到寻呼信息队列当中
Application.UnLock
else
Application.Lock
' 放置到寻呼信息队列当中
application("Message")=application("message") & "&" & who & "$" & content & "$" & meme
Application.UnLock
end if
Response.Write "<script language=javascript>self.close();</script>"
' 发送完毕,关闭页面
end if
%>
<html>
<title>精彩春风之网络寻呼我的宝贝</title>
<head>
<script language="javascript">
function check()
{
if(document.send.content.value.length<1)
{
alert("您必须说两句哦!");
return;
}
document.send.action="bbsSendBegin.asp?act=wantsend&userid=<%=trim(request ("userid"))%>";
document.send.submit();
}
</script>
</head>
<body bgcolor=GhostWhite >
<br>
<center>精彩春风之寻呼机</center>
<br>
<%If Ubound(users)>=2 then%>
<center>
<form name="send" method="post">
<table>
<tr>
<td>我想给发送讯息:</td>
<!-- 得到当前在线用户的列表,并放到下拉列表框中 -->
<td>
<select name="who">
<%For i=0 to ubound(users)%>
<%If trim(users(i))<>trim(meme) then%>
<%if i>1 then%>
<%if users(i)<>users(i-1) then%>
<option><%=users(i)%>
<%end if%>
<%else%>
<%if users(i)<>meme then%>
<option><%=users(i)%>
<%end if%>
<%end if%>
<%end if%>
<%Next%>
</select>
</td>
</tr>
<tr>
<td>讯息内容:</td>
<td>
<input type="text" name="content" size="20" maxlength="50">
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2">
<a href="javascript:check()"><img src="images/sendinfo.jpg” ></a>
<a href="javascript:document.send.reset()"><img src="images/rewrite.jpg" ></a>
<a href="javascript:self.close()"><img src="images/close.jpg" ></a>
</td>
</tr>
</table>
</form>
</center>
<%else%>
<br>
<br>
<br>
<center>嘿嘿,寻呼谁呀?这会儿社区就您一个人!</center>
<center>
<a href="javascript:self.close()"><img src="images/close.jpg" ></a>
</center>
<%end if%>
</body>
</html>
bbssendinfo.asp页面在有人寻呼时,弹出来显示寻呼内容,并可选择即时回复、稍候回复、删除这条信息。
通过分析寻呼信息队列,提取出来发送到Request.QueryString ("userid")的信息,这样就得到了寻呼信息。在回复方式上,依靠了传递过来的参数:
Request.QueryString("act")
这个参数的值有三个:1、send:即时回复 ;
2、closeme:关闭当前寻呼机;
3、wait:稍后回复。
如果选择了回复,在代码中是使用Replace()函数替换为空格,在功能上表现出来就是将寻呼信息队列里的该寻呼信息区清除掉。
我们还使用了一个隐藏的Input框,用于保存发送寻呼的用户名称,以便在同一个页面当中进行处理。
bbssendinfo.asp
<%@ Language=VBScript %>
<%
id=trim(Request.QueryString("userid"))
' 得到当前的网友昵称,当然就是你自己了,等于Session (" UserID")
if Request.QueryString("act")="send" then
' 获取当前操作状态
who=trim(Request.Form("who"))
' 如果是发送状态,就获取发送到的网友昵称
content=trim(Request.Form("content"))
' 获取发送的内容
if who="" or content="" then
Response.Redirect "error.asp?msg=噢,姓名或者讯息内容不能为空,请重新输入!"
end if
if instr(1,who,"&")>=1 or instr(1,who,"$")>=1 or instr(1,content,"&")>=1 or instr(1,content,"$")>=1 then
' 过滤掉用户输入的&、$,因为这是寻呼信息区的分割符号
Response.Redirect "error.asp?msg=噢,姓名或者讯息内容包含非法字符 ($/&),不能发送!"
end if
if trim(application("Message"))="" then
Application.Lock
application("Message")=who & "$" & content & "$" & trim(Request.QueryString("userid"))
' 将寻呼信息放到寻呼信息队列当中
Application.UnLock
else
Application.Lock
application("Message")="&" & who & "$" & content & "$" & trim(Request.QueryString("userid"))
' 将寻呼信息放到寻呼信息队列当中
Application.UnLock
end if
Response.Write "<script language=javascript>self.close()</script>"
Response.End
else
' 下面处理寻呼信息队列,以取得属于网友自己的寻呼信息
if trim(application("Message"))<>"" then
msg=split(application("Message"),"&")
' 分割得到寻呼信息区,并保存到数组
for i=0 to ubound(msg)
if instr(1,trim(msg(i)),trim(Request.QueryString("userid")))>=1 then
mymsg=split(msg(i),"$")
' 分割得到每个寻呼信息区的详细信息
if trim(mymsg(0))=trim(Request.QueryString("userid")) then
' 发给自己的寻呼信息
msgok=1
' 其他网友呼叫自己的表记置为1
from=trim(mymsg(2))
' 获得寻呼的详细内容
content=trim(mymsg(1))
sendto=trim(mymsg(0))
end if
end if
next
end if
end if
%>
<html>
<title>精彩春风之寻呼机</title>
<head>
<script language="javascript">
function nosend()
{
document.frmmail.action="bbssendinfo.asp?act=wait&userid=<%=trim(Request.QueryString ("userid"))%>"
document.frmmail.submit();
}
function meclose()
{
document.frmmail.action="bbssendinfo.asp?act=closeme&userid=<%=trim (Request.QueryString("userid"))%>"
document.frmmail.submit();
}
function destory()
{
<% if trim(request("act"))="closeme" then
cancelme=trim(Request.QueryString("userid")) & "$" & content & "$" & trim(from)
application.lock
application("Message")=replace(application("Message"),cancelme,"")
application.unlock %>
self.close()
<% end if%>
}
function chkok()
{
if (document.frmmail.content.value=="")
{
alert("嘿嘿,您还没发言呢!");
return;
}
document.frmmail.submit();
}
</script>
</head>
<body bgcolor="GhostWhite" onload="javascript:destory();" topmargin="0">
<br>
<form name="frmmail" action="bbssendinfo.asp?act=send&userid=<%=trim (Request.QueryString("userid"))%>" method="post">
<table border="0" width="200" align="center" cellspacing="1" cellpadding="1">
<tr>
<td colspan="2" align="center">嗨,可有人呼你了……
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td nowrap><%=from%>说:</td>
<td><%=content%></td>
</tr>
<tr>
<td nowrap>回复内容:</td>
<td><input name="content" size="34" maxlength="35"></td>
</tr>
</table>
<br><br>
<center>
<a href="javascript:chkok();"><img src="images/sendinfo.jpg"></a>
<a href="javascript:document.frmmail.reset()"><img src="images/rewrite.jpg"></a>
<a href="javascript:self.close();"><img src="images/waitsend.jpg"></a>
<a href="javascript:meclose();"><img src="images/close.jpg"></a>
<input name="who" type="hidden" value="<%=from%>">
</center>
</body>
</html>
bbsautosearch.asp页面与寻呼信息显示(bbssendinfo.asp)页面关联。只有在bbsautosearch.asp页面中分析“寻呼信息队列”,捕捉到了属于网友自己的寻呼信息后,才会调用bbssendinfo.asp页面显示。
显然,bbsautosearch.asp 页面是一直运行的,这我们可用一个 META标签来实现,,我们将当前用户的名称保存在一个Session变量里:
Session(“UserID”)
然后利用META标签实现随时刷新,语句如下:
<meta HTTP-EQUIV="refresh" CONTENT="60;URL=bbsautosearch.asp" >
表示每隔 60秒重复刷新自身页面,我们将这个页面放置到一个隐藏的帧里面,就可以实现随时分析和处理属于我们的信息了。代码和说明如下:
bbsautosearch.asp
' 在线接收页面
<%@ Language=VBScript %>
<%
user=split(application("OnlineUser"),",")
' 获得在线用户列表
for i=0 to ubound(user)
' 获得非空的在线用户列表
if user(i)<>"" then
nowcount=nowcount+1
' 统计在线人数
if trim(temp)="" then
temp=user(i)
else
temp=temp+","+user(i)
end if
end if
next
if trim(temp)<>"" then
Application.Lock
application("OnlineUser")=temp
' 重新整理在线用户列表
Application.UnLock
end if
%>
<%
dim quit
' 下面代码是处理寻呼信息队列中的信息,并分割出来是自己的信息
if trim(application("Message"))<>"" then
msg=split(application("Message"),"&")
' 分割得到寻呼信息区,并保存到数组
for i=0 to ubound(msg)
if instr(1,trim(msg(i)),trim(session("userid")))>=1 then
mymsg=split(msg(i),"$")
' 分割得到每个寻呼信息区的详细信息
if trim(mymsg(0))=trim(session("userid")) then
' 发给自己的寻呼信息
msgok=1
' 其他网友呼叫自己的表记置为1
from=trim(mymsg(2))
' 获得寻呼的详细内容
content=trim(mymsg(1))
sendto=trim(mymsg(0))
end if
end if
next
end if
quit=0
if (trim(session("UserID"))="" or instr(1,application("OnlineUser"),session("UserID"))<1) and trim(session("UserID"))<>"guest" then
quit=1
else
if trim(application("OnlineUser"))="" then
counts=0
else
counts=ubound(split(application("OnlineUser"),","))+1
end if
end if
%>
<HTML>
<HEAD>
<meta HTTP-EQUIV="refresh" CONTENT="60;URL=bbsAutoSearch.asp" charset=gb2312 >
<script language=javascript>
function window_onload()
{
<%if msgok=1 then%>
mail="精彩春风之传呼机\n\n"+"<%=from%>"+"有话和您说:\n\n"+"<%=content%>";
sendinfo=window.open("bbssendinfo.asp?userid=<%=session("UserID")% >","SendInfo","toolbar=no,width=360,height=200,top=0,left=0");
<%end if%>
' 上面语句是调用bbssendinfo.asp(寻呼信息显示)页面显示提示信息
<%if quit=1 then%>
alert("因超时或者操作非法,您被踢出系统了!哈哈…请重新登录哦.");
document.kickout.target="_top";
document.kickout.submit();
<%end if%>
' 以上语句是如果当前用户超时,踢出系统
}
</script>
</HEAD>
<BODY style="BACKGROUND-color:#ccccff" onload="javascript:window_onload() ">
<%if quit=1 then%>
<center>
您已超时或操作非法!
</center>
<%else%>
<%if session("UserID")<>"guest" then%>
<center>
当前共有在线网友<font color=red><b><%=counts%></b></font>人
</center>
<%else%>
<center>
噢,只有注册用户才能寻呼!
</center>
<%end if%>
<%end if%>
<form name=kickout method=post action="bbslogin.asp"></form>
</BODY>
</HTML>


猜你喜欢
- 本文实例讲述了Go语言写入字符串到文件的方法。分享给大家供大家参考。具体实现方法如下:package mainimport &q
- 解决方法:1。 改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql
- 本文实例讲述了PHP函数按引用传递参数及函数可选参数用法。分享给大家供大家参考,具体如下:一、函数按引用传递参数1. 代码<!DOCT
- 很多jsp程序员都遇到过这样的情况,jsp页面传递参数到servlet,只要参数有中文就是乱码,且大多数是??????乱码,尝试了网上比较普
- 提示:以下是本篇文章正文内容,下面案例可供参考一、uni-app中自带的弹窗示例:在前端开发中,为了优化用户的交互体验,常需要用到弹窗来进行
- 简介程序中的数在计算机内存中都是以二进制的形式存在的,位运算就是直接对整数在内存中对应的二进制位进行操作,一般是将数字化为二进制数后进行操作
- 正确使用字体和颜色可以让网页内容更易阅读,下面我们来看看具体的优化措施。留意颜色的对比对于视力不太好的人或者对于不太好的显示设备来说,黑地白
- 在mysql中利用select语句的一个特性就可以很方便地实现查询结果的分页,select语句的语法:SELECT [STRAIGHT_JO
- 摘要: 阐述一种全新的ASP模板引擎,实现代码(逻辑)层与HTML(表现)层的分离.这种模板实现方法避免了一般ASP模板加载模板文件(加载组
- ⛳️ 本次反反爬实战案例背景本篇博客选择的案例是由 VX 好友提出,他希望有一篇博客能简单的介绍清楚下面这个问题。快速定位加密参数逻辑,快速
- 前言要想让手机app自动登录,也就是让app自己操作。所以在脚本中我们需要对app控件进行操作,那么我们需要获取控件的信息。可以使用..\a
- Golang Goroutine和线程的区别 Golang,轻松学习一、Golang Goroutine?当使用者分配足够多的任务,系统能自
- 我们经常遇到各种字典套字典的数据,例如:nest_dict = { 'a': 1, 'b
- <form name="frm"><select name=school onchange="
- 案例以论坛为例,有个接口返回帖子(posts)信息,然后呢,来了新需求,说需要显示帖子的 author 信息。此时会有两种选择:在 post
- 本文实例讲述了python抽象基类用法。分享给大家供大家参考。具体如下:定义抽象类,需要使用abc模块,该模块定义了一个元类(ABCMeat
- 如果你需要一个PDF文件合并工具,那么本文章完全可以满足您的要求。哈喽,大家好呀,这里是滑稽研究所。不多废话,本期我们利用Python合
- 最近用pymysql把一些质量不是很高的数据源导入mysql数据库的时候遇到一点问题,主要是遇到像 \ 这样的具有特殊意义的字符时比较难处理
- 不知道工商银行帐号是否是这样的格式, 如果错了请大家见谅!<script language="javascript"
- 概述 -------------------------------------------------------------------