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'循環(huán)查詢用戶該刪除時則刪除
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
'檢查是否已經(jīng)登錄了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'循環(huán)每一個用戶
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
'轉(zhuǎn)載%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
'過程信息檢查是否已經(jīng)超過了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是新登錄的用戶如果已經(jīng)登錄則顯示已經(jīng)登錄,否則沒有登錄
response.write "已經(jīng)登錄"
Else
response.write "沒有登錄"
End If
%>
更多信息請查看IT技術(shù)專欄