asp检查在线类
2014-08-26来源:易贤网

Private Function add(ByVal u,ByVal t,ByVal ip)

Dim temp_u_str

temp_u_str = get_u()

temp_u_str = temp_u_str &"$"&u&"#"&t&"#"&ip

Set_u(temp_u_str)

End function

'删除某个登录信息

Private Function delu(ByVal u)

Dim u_str,num,temp_u_str

u_str = get_u()

If Len(u_str)>0 Then

u_str_arr = Split(u_str,"$",-1,1)

num = UBound(u_str_arr)

If num >0 then

For i = 1 To num'循环查询用户该删除时则删除

If(Split(u_str_arr(i),"#",-1,1)(0)<>u) then

temp_u_str = temp_u_str & "$" & u_str_arr(i)

End if

Next

set_u(temp_u_str)

End if

End if

End function

'检查是否已经登录了Forasp.cn

'刷新用户信息

Private Function flash()

Dim u_str,now_time,num'定义用户字符串

now_time = now

u_str = get_u()

If len(u_str)>0 Then'如果存在用户则刷新用户

u_str_arr = Split(u_str,"$",-1,1)

num = UBound(u_str_arr)

If num>0 then

For i = 1 To num'循环每一个用户

u_str_info_arr = Split(u_str_arr(i),"#",-1,1)'获取用户登录时间

'response.write DateDiff("s",u_str_info_arr(1),now_time)

If DateDiff("s",u_str_info_arr(1),now_time) > (20*60) then'这里定义过期时间,设置为20分钟20*60秒

'delu(u_str_info_arr(0))

End if

Next

End if

End if

End Function

'获取所有的用户信息

Public Function get_u()

application.lock

get_u = application("forasp_cn")

application.unlock

End Function

'设置所有用户信息

Private Function set_u(ByVal str)

application.lock

application("forasp_cn") = str

application.unlock

End function

'更新登录时间

Function changet(ByVal u)

Dim t,u_str,num,temp_u_str

'转载%77%77%77请%2E%66%6F%72%61%73%70%2E%63%6E注

t= Now()

u_str = get_u()

If Len(u_str)>0 then

u_str_arr = Split(u_str,"$",-1,1)

num = UBound(u_str_arr)

If num>0 Then

For i =1 To num

If Split(u_str_arr(i),"#")(0) = u Then

temp_u_str = temp_u_str&"$"&u&"#"&t&"#"&Split(u_str_arr(i),"#")(2)

Else

temp_u_str = temp_u_str&u_str_arr(i)

End If

Next

set_u(temp_u_str)

End if

End if

End Function

Public function t()

t =Now()

End function

'清空所有的登录信息

Private Function clearu(ByVal u)

application.lock

application("forasp_cn") = ""

application.unlock

End Function

'过程信息检查是否已经超过了application大小了

Private Sub clear_application()

Dim application_size

application_size = 1024 *1024 '大小为1M

If Len(application("forasp_cn"))>application_size Then

clearu()

Else

flash()

End if

End sub

End Class

Set a = new user_online

If(a.checku("d",Now(),a.getip())) Then'假设这里的b是新登录的用户如果已经登录则显示已经登录,否则没有登录

response.write "已经登录"

Else

response.write "没有登录"

End If

%>

更多信息请查看IT技术专栏

推荐信息