Show online users

Source: Internet
Author: User
Tags servervariables

<%
Nowurl = request. servervariables ("http_referer ")
Username = SESSION ("wenday_sys_user ")
If username = "" then
Username = "guest"
End if
Call sqlonline ()
Response. write "document. write ("& CHR (34) &" <font color = #000000> current online "& online () &" persons </font> "& CHR (34 )&")"
'Response. write "document. write ("& CHR (34) &" <a href = count/showonline. ASP Title = view online list> <font color = #000000> current online "& online () &" persons </font> </a> "& CHR (34) &")"
Sub sqlonline ()
Dim statuserid
Statuserid = Replace (request. servervariables ("remote_host "),".","")
Response. Cookies ("wenday_sys") ("onlineid") = statuserid
SQL = "select ID from" & categoryname & "_ online where id =" & CSTR (request. Cookies ("wenday_sys") ("onlineid "))
Set rsw.conn.exe cute (SQL)
If Rs. EOF and Rs. bof then
SQL = "insert into" & categoryname & "_ online (ID, username, IP, startime, lastimebk, browser, actforip, now_url) values (" & statuserid &", '"& username &"', '"& request. servervariables ("remote_host") & "', now (), now (),'" & request. servervariables ("http_user_agent") & "','" & request. servervariables ("http_x_forwarded_for") & "','" & request. servervariables ("http_referer ")&"')"
Else
SQL = "Update" & categoryname & "_ online set lastimebk = now (), username = '" & username & "'where id =" & CSTR (request. cookies ("wenday_sys") ("onlineid "))
End if
Conn.exe cute (SQL)
Set rs = nothing
Rem deletion timeout user
SQL = "delete from" & categoryname & "_ online where datediff ('s ', lastimebk, now ()>" & kicktime & "* 60"
Conn. Execute SQL
End sub
Function online ()
Dim tmprs
SQL = "select count (ID) from" & categoryname & "_ online"
Set tmprs1_conn.exe cute (SQL)
Online = tmprs (0)
Set tmprs = nothing
If isnull (online) then online = 0
End Function
Closedatabase
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.