当前位置:主页 > 查看内容

asp 根据IP地址自动判断转向分站的代码

发布时间:2021-06-17 00:00| 位朋友查看

简介:Function getIpvalue(clientIP)'得到客户端的IP转换成长整型,返回值getIpvalue On Error Resume Next Dim strIp, array_Ip strIp=0 array_Ip = Split(clientIP,".") If UBound(array_Ip)3 Then getIpvalue=0 Exit Function End If For i=0 To 3 strIp=strIp……
Function getIpvalue(clientIP)'得到客户端的IP转换成长整型,返回值getIpvalue
On Error Resume Next
Dim strIp, array_Ip
strIp=0
array_Ip = Split(clientIP,".")
If UBound(array_Ip)<>3 Then
getIpvalue=0
Exit Function
End If
For i=0 To 3
strIp=strIp+(CInt(array_Ip(i))*(256^(3-i)))
Next
getIpvalue=strIp
If Err Then getIpvalue=0
End Function
clientIP=request.ServerVariables("REMOTE_HOST")
IpValue=getIpvalue(clientIP)
strSql="select top 1 City from [Ipaddress] where "&IpValue&"
between Ip1 and Ip2"
Set RsIp=conn.execute(strSql)
If RsIp.bof and RsIp.eof then
UrlCity="未知"
Else
UrlCity=RsIp.Fields.Item("City").Value
End If
if instr(UrlCity,"广州")<>0 then
response.Redirect("https://www.jb51.net")
end if
if instr(UrlCity,"深圳")<>0 then
response.Redirect("http://img.jb51.net")
end if
if instr(UrlCity,"上海")<>0 then
response.Redirect("http://xiazai.jb51.net")
end if
所用到的IP数据库可以去网上down一个回来

原文链接:https://m.jb51.net/article/16628.htm
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!

推荐图文


随机推荐