ASP調(diào)用純真IP庫實例(4)_ASP教程
推薦:ASP實例:ASP實現(xiàn)空間的最近訪客由于工作關(guān)系,在做一個用戶空間。要用到空間的最近訪客,見ASP代碼: % username=request.QueryString(username) '地欄中的username,就是自己的用戶名了 if trim(request.Cookies(user_name)) Then '首頁要判斷該訪問是否登陸,只有登陸的訪問才能記
' ============================================
' 獲取字串信息
' ============================================
Private Function GetStr()
Dim c
GetStr = ""
Do While (True)
c = AscB(Stream.Read(1))
If (c = 0) Then Exit Do
'如果是雙字節(jié),就進行高字節(jié)在結(jié)合低字節(jié)合成一個字符
If c > 127 Then
If Stream.EOS Then Exit Do
GetStr = GetStr & Chr(AscW(ChrB(AscB(Stream.Read(1))) & ChrB(C)))
Else
GetStr = GetStr & Chr(c)
End If
Loop
End Function
' ============================================
' 核心函數(shù),執(zhí)行IP搜索
' ============================================
Public Function QQWry(DotIP)
Dim IP, nRet
Dim RangB, RangE, RecNo
IP = IPToInt (DotIP)
Set Stream = CreateObject("ADodb.Stream")
Stream.Mode = 3
Stream.Type = 1
Stream.Open
Stream.LoadFromFile QQWryFile
Stream.Position = 0
Buf = Stream.Read(8)
FirstStartIP = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256) + (AscB(MidB(Buf, 4, 1))*256*256*256)
LastStartIP = AscB(MidB(Buf, 5, 1)) + (AscB(MidB(Buf, 6, 1))*256) + (AscB(MidB(Buf, 7, 1))*256*256) + (AscB(MidB(Buf, 8, 1))*256*256*256)
RecordCount = Int((LastStartIP - FirstStartIP)/7)
' 在數(shù)據(jù)庫中找不到任何IP地址
If (RecordCount <= 1) Then
Country = "未知"
QQWry = 2
Exit Function
End If
RangB = 0
RangE = RecordCount
Do While (RangB < (RangE - 1))
RecNo = Int((RangB + RangE)/2)
Call GetStartIP (RecNo)
If (IP = StartIP) Then
RangB = RecNo
Exit Do
End If
If (IP > StartIP) Then
RangB = RecNo
Else
RangE = RecNo
End If
Loop
Call GetStartIP(RangB)
Call GetEndIP()
If (StartIP <= IP) And ( EndIP >= IP) Then
' 沒有找到
nRet = 0
Else
' 正常
nRet = 3
End If
Call GetCountry(IP)
QQWry = nRet
End Function
' ============================================
' 類終結(jié)
' ============================================
Private Sub Class_Terminate
On ErrOr Resume Next
Stream.Close
If Err Then Err.Clear
Set Stream = Nothing
End Sub
End Class
%>
分享:ASP防止GET,Post注入和防止服務(wù)器攻擊,并記錄IP% '防止GET,Post注入和防止服務(wù)器攻擊 '使用方法把本文件包含到需要防注的文件就OK了,說明下,這里的post攻擊和Get攻擊不一定是攻擊,在英文版本的時候請注意使用 '馮旭修改 session.Abandon() Dim fxjt111_Attack_post,fxjt111_Attack_Get,fxjt111_Attack_Sys
- 相關(guān)鏈接:
- 教程說明:
ASP教程-ASP調(diào)用純真IP庫實例(4)
。