Show online number _asp basics

Source: Internet
Author: User
<%
Nowurl=request.servervariables ("Http_referer")
UserName = Session ("Wenday_sys_user")
If Username= "" Then
Username= "Guest"
End If
Call Sqlonline ()
Response.Write "document.write (& CHR) &" <font color= #000000 > Current Online "& Online () &" People &LT;/FONT&G t; " & Chr (+) & ")"
' Response.Write ' document.write ("& Chr () &" <a href=count/showonline.asp title= view online list ><font #000000 > Current Online "& Online () &" People </font></a> "& Chr (+) &") "
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 Rs=conn.execute (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.execute (SQL)
Set rs=nothing
Rem Delete 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 Tmprs=conn.execute (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.