IP地址的问题

chinamnli 2005-04-25 03:13:44
我下载了IP数据库,,,在ASP里,得到的IP地址,,怎么去判断是哪个地方的呢?

比如讲: 广州: 214.12.12.1 至 214.12.12.10
那我得到的ip是:214.12.12.5,,那怎么来判断是广州的呢??
...全文
89 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hsman 2005-04-25
  • 打赏
  • 举报
回复
Function PubFgdy(Test,Tag,Bh)
PubFgdy=""
if Test<>"" and isnumeric(Bh)=true Then
Dim Tests
Tests=split(Test&Tag,Tag)
if Bh<Ubound(Tests) then
PubFgdy=Tests(Bh)
end if
else
PubFgdy=""
exit function
end if
end function
hsman 2005-04-25
  • 打赏
  • 举报
回复
这是我写的两个函数,可以判断一个ip地址是否在给定的ip地址段内,还算好用, 你可以试试.

'//********************************************************************
' 判断 ip地址的范围, IpCheck=1时,ipThis在ipStart和ipEnd 之间,IpCheck=0时否
//********************************************************************
Function IpCheck(ipStart,ipEnd,ipThis)

IpCheck=0
dim diffSE, diffST
diffSE=IpDiffNum(ipStart, ipEnd)
diffST=IpDiffNum(ipStart,ipThis)
diffET=IpDiffNum(ipEnd,ipThis)
if diffSE=0 then
if diffST>0 then IpCheck=1
if diffSE>0 then IpCheck=1
if PubFgdy(ipStart,".",0)< PubFgdy(ipThis,".",0) and PubFgdy(ipEnd,".",0)>PubFgdy(ipStart,".",0) then IpCheck=1
exit function
end if

if diffSE=1 then
if diffST>1 then IpCheck=1
if diffSE>1 then IpCheck=1
if diffST=1 then
if PubFgdy(ipStart,".",1)<PubFgdy(ipThis,".",1) and PubFgdy(ipEnd,".",1)>PubFgdy(ipThis,".",1) then IpCheck=1
end if
exit function
end if

if diffSE=2 then
if diffST>2 then IpCheck=1
if diffSE>2 then IpCheck=1
if diffST=2 then
if PubFgdy(ipStart,".",2)<PubFgdy(ipThis,".",2) and PubFgdy(ipEnd,".",2)>PubFgdy(ipThis,".",2) then IpCheck=1
end if
exit function
end if

if diffSE=3 then
if diffST=4 then IpCheck=1
if diffET=4 then IpCheck=1
if diffST=3 then
if PubFgdy(ipStart,".",3)<PubFgdy(ipThis,".",3) and PubFgdy(ipEnd,".",3)>PubFgdy(ipThis,".",3) then IpCheck=1
end if
exit function
end if

if diffSE=4 then
if diffST=4 then IpCheck=1
end if
End Function

'//********************************************************************
判断两个 ip地址 第一个不相同的位置
'//********************************************************************
Function IpDiffNum(ipStart, ipEnd)
dim i
i=0
IpDiffNum=4 'IpDiffNum Ϊ4ʱ£¬Á½¸öµØÖ·Ïàͬ #####
For i=0 to 3
if PubFgdy(ipStart,".",i)<>PubFgdy(ipEnd,".",i) then
IpDiffNum=i
exit for
end if
Next

End Function

%>
  • 打赏
  • 举报
回复
你要下个ip地址的数据库的

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧