ASP instance: Instant Display current page browsing number

Source: Internet
Author: User
Tags current time servervariables time interval

online.asp file

<!--#include file= "dbconn.asp"-->
<%
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" ")"%>
Related Article

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.