开放源码 - 访客统计查询(五)
发表于:2007-06-30来源:作者:点击数:
标签:
% Script Language = VB Script 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
<%
<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, str
SQL
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
‘’
数据库连接,字符串自定
.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 >= " & IPAddressDeal
.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("IsRecorded
CCCNet") = 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>
%>
原文转自:http://www.ltesting.net