ASP调用纯真IP库实例(2)_ASP教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:ASP实例:ASP实现空间的最近访客
由于工作关系,在做一个用户空间。要用到空间的最近访客,见ASP代码: % username=request.QueryString(username) '地栏中的username,就是自己的用户名了 if trim(request.Cookies(user_name)) Then '首页要判断该访问是否登陆,只有登陆的访问才能记

Class TQQWry
' ============================================
' 变量声名
' ============================================
Dim Country, LocalStr, Buf, OffSet
Private StartIP, EndIP, CountryFlag
Public QQWryFile
Public FirstStartIP, LastStartIP, RecordCount
Private Stream, EndIPOff
' ============================================
' 类模块初始化
' ============================================
Private Sub Class_Initialize
Country = ""
LocalStr = ""
StartIP = 0
EndIP = 0
CountryFlag = 0
FirstStartIP = 0
LastStartIP = 0
EndIPOff = 0
QQWryFile = Server.MapPath("/DATA/QQWry.dat") 'QQ纯真IP库存放路径,要改为你的路径
End Sub
' ============================================
' IP地址转换成整数
' ============================================
Function IPToInt(IP)
Dim IPArray, i
IPArray = Split(IP, ".", -1)
FOr i = 0 to 3
If Not IsNumeric(IPArray(i)) Then IPArray(i) = 0
If CInt(IPArray(i)) < 0 Then IPArray(i) = Abs(CInt(IPArray(i)))
If CInt(IPArray(i)) > 255 Then IPArray(i) = 255
Next
IPToInt = (CInt(IPArray(0))*256*256*256) + (CInt(IPArray(1))*256*256) + (CInt(IPArray(2))*256) + CInt(IPArray(3))
End Function
' ============================================
' 整数逆转IP地址
' ============================================
Function IntToIP(IntValue)
p4 = IntValue - Fix(IntValue/256)*256
IntValue = (IntValue-p4)/256
p3 = IntValue - Fix(IntValue/256)*256
IntValue = (IntValue-p3)/256
p2 = IntValue - Fix(IntValue/256)*256
IntValue = (IntValue - p2)/256
p1 = IntValue
IntToIP = Cstr(p1) & "." & Cstr(p2) & "." & Cstr(p3) & "." & Cstr(p4)
End Function
' ============================================
' 获取开始IP位置
' ============================================
Private Function GetStartIP(RecNo)
OffSet = FirstStartIP + RecNo * 7
Stream.Position = OffSet
Buf = Stream.Read(7)

EndIPOff = AscB(MidB(Buf, 5, 1)) + (AscB(MidB(Buf, 6, 1))*256) + (AscB(MidB(Buf, 7, 1))*256*256)
StartIP = 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)
GetStartIP = StartIP
End Function

分享:ASP防止GET,Post注入和防止服务器攻击,并记录IP
% '防止GET,Post注入和防止服务器攻击 '使用方法把本文件包含到需要防注的文件就OK了,说明下,这里的post攻击和Get攻击不一定是攻击,在英文版本的时候请注意使用 '冯旭修改 session.Abandon() Dim fxjt111_Attack_post,fxjt111_Attack_Get,fxjt111_Attack_Sys

来源:模板无忧//所属分类:ASP教程/更新时间:2010-06-02
相关ASP教程