<% onlinetimeout=10 ' defines the time interval function for online activity userip () Getclientip = Request.ServerVariables ("Http_x_forwarded_for" "" "" "" "" "," "" to obtain the user's virtual IP address
<%
Onlinetimeout=10 ' defines the time interval for online activity time
Function Userip ()
Getclientip = Request.ServerVariables ("http_x_forwarded_for") ' "," "'", "'", "" "", "" "," "" to obtain the user's virtual IP address
If Getclientip = "" or IsNull (Getclientip) or IsEmpty (Getclientip) Then
Getclientip = Request.ServerVariables ("remote_addr") "'" ' If no proxy server is used, obtain the IP address of the source
End If
Userip = Getclientip
End Function
Sql= ' Select o_id from c_online where o_ip= ' ' &userip () & ' ' To find the ID of the IP address obtained in the database
Set rs=conn.execute (SQL)
If rs.eof and Rs.bof Then
sql= INSERT INTO C_online (O_IP) VALUES (' "&userip () &" ")" if the database does not indicate a new IP, the insert operation
Conn.execute (SQL)
Else
sql= "Update c_online set O_ltime=now () where o_ip= '" &userip () & "" "More Database Current time
Conn.execute (SQL)
End If
Sql= "Delete from C_online where DATEADD (' s '," &onlineTimeout*60& ", O_ltime) < Now ()" defines a 10-minute refresh
Conn.execute (SQL)
Rs.close
Set rs=nothing
Function Allonline ()
Tmprs=conn.execute ("SELECT count (o_id) from C_online")
Allonline=tmprs (0)
Set tmprs=nothing
End Function
%>
<%response.write "document.write" ("Online" &allonline () & "Person" ")"%>