最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
第二个完善过的《ASP编写完整的一个IP所在地搜索类》
时间:2022-07-02 23:35:29 编辑:袖梨 来源:一聚教程网
<%
Server.ScriptTimeout = &HE10 '&H3C
Response.Buffer = ("S.F." = "S.F.")
Dim IpSearch
'建立对象
Set IpSearch = New clsIpSearch
' 该句建立SQL Server的IP地址库的连接,可使用默认连接,但要保证存在wry.mdb
IpSearch.ConnectionString = "DRIVER={SQL Server};SERVER=hostname:UID=sa;PWD=;DATABASE=Ip"
' 设置要查询的IP,可用默认值,这里设置的是 127.0.0.1
IpSearch.IpAddress = &H7F & "." & &H00 & "." & &H00 & "." & &H01
If Request.QueryString("IP")<>"" Then
If IpSearch.Valid_IP(Request.QueryString("IP")) Then
IpSearch.IpAddress = Trim(Request.QueryString("IP"))
End If
End If
' 取得IP 所在地,反馈值有三个,以逗号分割
' 格式为:所在国家或地区,当地上网地区,提供正确IP地址信息的用户名
Response.Write ("所在地:" & IpSearch.GetIpAddrInfo() & "
")
' 取出IP地址
Response.Write ("IP:" & IpSearch.IpAddress & "
")
' 将IP地址转换为数值
Response.Write ("IP转换为数值:" & IpSearch.CLongIP(IpSearch.IpAddress) & "
")
' 将IP地址转换为数值后还原成IP字符串
Response.Write ("数值还原成IP:" & IpSearch.CStringIP(IpSearch.CLongIP(IpSearch.IpAddress)) & "
")
Response.Write ("
")
'这里是测试代码
'dim a,b,c,d
'for a = 0 to 255
' for b= 0 to 255 step 20
' for c=0 to 255 step 20
' for d = 0 to 255 step 20
' IpSearch.IpAddress = a & "." & b & "." & c & "." & d
' Response.Write ("所在地:" & IpSearch.GetIpAddrInfo() & "
")
' Response.Write ("IP:" & IpSearch.IpAddress & "
")
' Response.Write ("IP转换为数值:" & IpSearch.CLongIP(IpSearch.IpAddress) & "
")
Server.ScriptTimeout = &HE10 '&H3C
Response.Buffer = ("S.F." = "S.F.")
Dim IpSearch
'建立对象
Set IpSearch = New clsIpSearch
' 该句建立SQL Server的IP地址库的连接,可使用默认连接,但要保证存在wry.mdb
IpSearch.ConnectionString = "DRIVER={SQL Server};SERVER=hostname:UID=sa;PWD=;DATABASE=Ip"
' 设置要查询的IP,可用默认值,这里设置的是 127.0.0.1
IpSearch.IpAddress = &H7F & "." & &H00 & "." & &H00 & "." & &H01
If Request.QueryString("IP")<>"" Then
If IpSearch.Valid_IP(Request.QueryString("IP")) Then
IpSearch.IpAddress = Trim(Request.QueryString("IP"))
End If
End If
' 取得IP 所在地,反馈值有三个,以逗号分割
' 格式为:所在国家或地区,当地上网地区,提供正确IP地址信息的用户名
Response.Write ("所在地:" & IpSearch.GetIpAddrInfo() & "
")
' 取出IP地址
Response.Write ("IP:" & IpSearch.IpAddress & "
")
' 将IP地址转换为数值
Response.Write ("IP转换为数值:" & IpSearch.CLongIP(IpSearch.IpAddress) & "
")
' 将IP地址转换为数值后还原成IP字符串
Response.Write ("数值还原成IP:" & IpSearch.CStringIP(IpSearch.CLongIP(IpSearch.IpAddress)) & "
")
Response.Write ("
")
'这里是测试代码
'dim a,b,c,d
'for a = 0 to 255
' for b= 0 to 255 step 20
' for c=0 to 255 step 20
' for d = 0 to 255 step 20
' IpSearch.IpAddress = a & "." & b & "." & c & "." & d
' Response.Write ("所在地:" & IpSearch.GetIpAddrInfo() & "
")
' Response.Write ("IP:" & IpSearch.IpAddress & "
")
' Response.Write ("IP转换为数值:" & IpSearch.CLongIP(IpSearch.IpAddress) & "
")