主题:大家进来帮帮忙,在线等。
tianlebest
[专家分:50] 发布于 2007-02-06 16:17:00
现在正在做一个网站,要实现根据访问者的IP,让页面自动跳转到他所在城市的页面。
现在急需一个IP地址比较全的数据库,那位有的话发一个给我啊,小弟在此也谢谢了。
qq:694389067
最后更新于:2007-02-06 16:35:00
回复列表 (共5个回复)
沙发
yijun [专家分:3580] 发布于 2007-02-06 20:16:00
下个动网的
板凳
tianlebest [专家分:50] 发布于 2007-02-07 12:38:00
下了,但动网里面的IP是个整数,那我要怎样转换自己IP去和他比较啊
3 楼
yijun [专家分:3580] 发布于 2007-02-07 13:38:00
有个转换程序
正好刚做过 粘给你了
<%
Set Connip = Server.CreateObject("ADODB.Connection")
ConnipStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & server.mappath("inc/IPaddress.mdb")
Connip.Open ConnipStr
''''GET ip
function Ip_Address(sip)
Dim str1,str2,str3,str4
Dim num
Dim irs
If isnumeric(left(sip,2)) Then
If sip="127.0.0.1" Then sip="192.168.0.1"
str1=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str2=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str3=left(sip,instr(sip,".")-1)
str4=mid(sip,instr(sip,".")+1)
If isNumeric(str1)=0 Or isNumeric(str2)=0 Or isNumeric(str3)=0 Or isNumeric(str4)=0 Then
Else
num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
sql="select * from address where ip1 <="&num&" and ip2 >="&num
Set rsip=Connip.Execute(sql)
If rsip.eof And rs.bof Then
Ip_Address="没有数据"
Else
Do While Not rsip.eof
Ip_Address=Ip_Address &rsip("country") & rsip("city")
rsip.movenext
Loop
End If
End If
Else
Ip_Address="无效IP"
End If
rsip.close
Set rsip=nothing
Connip.close
Set Connip=Nothing
End Function
%>
4 楼
tianlebest [专家分:50] 发布于 2007-02-07 14:11:00
谢谢,谢谢,
5 楼
穿鞋子的树 [专家分:10] 发布于 2007-02-07 14:47:00
罗嗦
直接split(sip,".")不就行了
我来回复