Open source-Visitor statistics Query (v)

Source: Internet
Author: User
Tags query servervariables
Statistical <%
<script Language = "VBScript" RunAt = "Server" >
Function Dealip (SRCIP)
Dim Lngip, Aryip, I

LNGIP = 0
Aryip = Split (Srcip, ".")
If UBound (ARYIP) <> 3 Then
Dealip = 0
Exit Function
End If

For I = 0 to 3
LNGIP = Lngip + (CInt (Aryip (I)) * (256 ^ (3-i))
Next

Dealip = lngIP-1
If Err Then dealip = 0
End Function

<!--METADATA type= "typelib" uuid= "00000205-0000-0010-8000-00AA006D2EA4"-->

Sub Statistics_add ()
Session ("isrecorded") = False

Session ("sttpage") = Request.ServerVariables ("Script_name")
Session ("refpage") = Request.ServerVariables ("Http_referer")

If not session ("isrecorded") Then
Dim objconn, objRS, strSQL
Dim ieversion, IPAddress, Visitdate, Visittime, Ipaddressdeal, Tmpid
Dim Sttpage, Refpage

Ieversion = Request.ServerVariables ("Http_user_agent")
IPAddress = Request.ServerVariables ("REMOTE_ADDR")
Visitdate = Date ()
Visittime = Time ()
Sttpage = Session ("Sttpage")
Refpage = Session ("Refpage")

Set objconn = Server.CreateObject ("ADODB. Connection ")
With objconn
' Database connection, string self-determined
. ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("...")
. Open
End With

Ipaddressdeal = Dealip (CStr (IPAddress))
Set objRS = Server.CreateObject ("ADODB. Recordset ")
With objRS
. ActiveConnection = objconn
. CursorType = adOpenForwardOnly
. LockType = adLockReadOnly
. Source = "SELECT * from Ipdatas Where ip_lower <=" & Ipaddressdeal & "and Ip_upper >=" & Ipaddressdea L
. Open
End With
If objrs.eof Then
Tmpid = 29510
Else
Tmpid = objRS ("ip_id")
End If
Objrs.close

With objRS
. ActiveConnection = objconn
. CursorType = adOpenForwardOnly
. LockType = adLockPessimistic
. Source = "SELECT * FROM IPs"
. Open
. AddNew
. Fields.item ("ieversion") = Ieversion
. Fields.item ("ipaddress") = IPAddress
. Fields.item ("ip_id") = Tmpid
. Fields.item ("visitdate") = Visitdate
. Fields.item ("visittime") = Visittime
. Fields.item ("sttpage") = Sttpage
. Fields.item ("refpage") = Refpage
. Update
End With

Objrs.close
Set objRS = Nothing
Objconn.close
Set objconn = Nothing

Session ("isrecorded") = True
End If
End Sub

Sub Application_OnStart ()
Application ("nowonline") = 0
End Sub

Sub Session_OnStart ()
Session.Timeout = 20

Session ("isrecordedcccnet") = False

Call Statistics_add

Application.Lock
Application ("nowonline") = Application ("Nowonline") + 1
Application.UnLock
End Sub

Sub Session_OnEnd ()
Application.Lock
Application ("nowonline") = Application ("Nowonline")-1
Application.UnLock
End Sub
</Script>
%>



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.