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

所属分类: 网络编程 / ASP编程 阅读数: 769
收藏 0 赞 0 分享
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一个回来
更多精彩内容其他人还在看

IIS访问ASP页面时报错The requested resource is in use.的解决办法

IIS访问ASP页面时报错The requested resource is in use.的解决办法
收藏 0 赞 0 分享

错误类型:Provider (0x80004005)未指定的错误 的一个处理方法

一般情况下asp可以正常运行,但只要连接数据库就提示,Microsoft JET Database Engine 错误'80004005'
收藏 0 赞 0 分享

关于“未指定的错误”的问题 的比较正解的解决方法

关于“未指定的错误”的问题 的比较正解的解决方法
收藏 0 赞 0 分享

关于asp+access的安全问题分析

关于asp+access的安全问题分析
收藏 0 赞 0 分享

把RS.GetRows看得更清楚

把RS.GetRows看得更清楚
收藏 0 赞 0 分享

ASP面向对象编程探讨及比较

ASP面向对象编程探讨及比较
收藏 0 赞 0 分享

ASP错误处理

ASP错误处理
收藏 0 赞 0 分享

web文件管理器的后续开发

web文件管理器的后续开发
收藏 0 赞 0 分享

上一篇,下一篇过程代码

上一篇,下一篇过程代码
收藏 0 赞 0 分享

一小偷类!!有兴趣的可以看看

一小偷类!!有兴趣的可以看看
收藏 0 赞 0 分享
查看更多