加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

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

发布时间:2023-07-14 13:14:59 所属栏目:Asp教程 来源:
导读:Function getIpvalue(clientIP)&#39;得到客户端的IP转换成长整型,返回值getIpvalueOn Error Resume NextDim strIp, array_IpstrIp=0array_Ip = Split(clientIP,".")If UBound(array_Ip)<>3 ThengetIpvalue=0Exit Fu

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("//www.Cuoxin.com")

end if

if instr(UrlCity,"深圳")<>0 then

response.Redirect("http://img.Cuoxin.com")

end if

if instr(UrlCity,"上海")<>0 then

response.Redirect("http://xiazai.Cuoxin.com")

end if

所用到的IP数据库可以去网上down一个回来。

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章