SoFunction
Updated on 2025-03-02

Example of ASP production online user statistics

Let's create a new ACESS database first

The content is

Table name: zai

The field is

1.ip

Create a file as

Then the following procedure!

<%
'===================================================================================================
'
'*************************** Bingling Online Number of People Statistics Program V2.0 ***************************
'
'This site program is independently produced by "Bingling Studio"-Ice Cream Swordsman! Please respect your labor results
'  
' 『Bingling Studio』━╃→Use strength to create personality
'
'* Author: Ice Cream Swordsman
'* Website:
'* Email:bingqilinjianke@
'* QQ:68156987
'* Address: Wuxi, Jiangsu
'******************************************************************************
'
' All rights reserved · Plagiarism and misappropriation will be investigated
'
'===================================================================================================


'-----------------------------------------------------------------------------------------------------------------------------
dim rs
dim ip
dim timeout
dim x
dim conn
dim dbpath
'-----------------------------------------------------------------------------------------------------------------------------

'-----------------------------------------------------------------------------------------------------------------------------
set conn=("")
DBPath = ("")
"driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
'-----------------------------------------------------------------------------------------------------------------------------

'------------- Create a new database RS object
set rs = ("")
'---------------Create database RS object to complete

'--------------Read the client IP address
ip = ("HTTP_X_FORWARDED_FOR") 'If the other party is using a proxy server to access the Internet, use ("HTTP_X_FORWARDED_FOR") to get the other party's real IP. If the other party does not access the Internet through a proxy server, the IP value is empty
If ip = "" Then ip = ("REMOTE_ADDR") 'If the IP value is empty, then it gets its local client address
'-----------------------------------------------------------------------------------------------------------------------------

'-----------------------------------------------------------------------------------------------------------------------------
sql="select ip from zai where time >= dateadd('n',-20,now()) group by ip"
sql,conn,1,1
zai=

'----------Get the online number

'------------ Check whether there is already the same value in the database. If there is no x="yes" and then x="no"
sql="select ip from zai where ip='" & ip & "'"
sql,conn,1,1
if and then
x="yes"
else
x="no"
end if

'------------Judgement is complete

'--------------If there is no identical value in the database, add a new value
if x="yes" then' If there is no this IP, add a record
sql="select top 1 * from zai"
sql,conn,1,3

rs("ip")=ip
rs("time")=now()


else 'If there is this IP, change the time to the current time

sql="select * from zai where ip='" & ip & "'"
sql,conn,1,3
rs("time")=now()


end if
'--------Judgement completed

'-----------------Delete the value added 20 minutes ago
timeout = dateadd("n", -20, now())
sql="delete * from zai where time < #" & timeout & "#"
sql
'-----------Delete completed

'------------Close the data object
set rs=nothing

set conn=nothing
%>
("Total <%=zai%>people online")

OK!

Completed!