Statistics of previous ASP versions are online. Because it is extracted from the previous system. To use this function, modify it.
If cbool (Application ("markonline") = true then checkonline ()
Function checkonline ()
Dim IP, rsprv, SQL
If dbstate = false then dbopen ()
Set rsprv = server. Createobject ("ADODB. recordset ")
If SESSION ("username") = "" then
SQL = "select * from [Online] Where sessionid = '" & session. sessionid &"'"
Rsprv. Open SQL, Conn, 1, 3
If rsprv. EOF then
Rsprv. addnew
Rsprv ("sessionid") = session. sessionid
Rsprv ("groupchargelv") =-1
Rsprv ("lastacttime") = now ()
Rsprv ("userip") = getip
Rsprv ("onlinetime") = 0
Rsprv ("userwhere") = request. servervariables ("http_referer ")
Else
Rsprv ("userwhere") = request. servervariables ("http_referer ")
Rsprv ("onlinetime") = rsprv ("onlinetime") + datediff ("N", rsprv ("lastacttime"), now ())
Rsprv ("lastacttime") = now ()
End if
Rsprv. Update
Rsprv. Close ()
'Response. Write "notlogin"
Else
'Response. Write "logined"
SQL = "select * from [Online] Where username = '" & SESSION ("username ")&"'"
Rsprv. Open SQL, Conn, 1, 3
If rsprv. EOF then
Rsprv. addnew
Rsprv ("sessionid") = session. sessionid
Rsprv ("username") = SESSION ("username ")
Rsprv ("groupchargelv") = SESSION ("groupchargelv ")
Rsprv ("lastacttime") = now ()
Rsprv ("onlinetime") = 0
Rsprv ("userip") = getip
Rsprv ("userwhere") = request. servervariables ("http_referer ")
Else
If rsprv ("sessionid") <> session. sessionid and application ("loginset") (1) = false then
Response. Write ("<SCRIPT> alert ('this account has been logged in elsewhere, and only one login ID can be set for the website \ n. You can try logging in later. '); Location. href = 'loginout. asp '")
Response. End ()
End if
Rsprv ("userwhere") = request. servervariables ("http_referer ")
Rsprv ("onlinetime") = rsprv ("onlinetime") + datediff ("N", rsprv ("lastacttime"), now ())
Rsprv ("lastacttime") = now ()
End if
Rsprv. Update
Rsprv. Close ()
End if
If datediff ("S", application ("onlinelastdelete"), now ()> int (Application ("deleteonlinediff") then
Application. Lock ()
Application ("onlinelastdelete") = now
Application. Unlock ()
Conn. execute ("delete from [Online] Where datediff ('s ', lastacttime, now ()>" & int (Application ("checkonlinediff ")&"")) 'delete no active visitor in X seconds
End if
Set rsprv = nothing
End Function