手机
当前位置:查字典教程网 >编程开发 >ASP教程 >asp 根据IP地址自动判断转向分站的代码
asp 根据IP地址自动判断转向分站的代码
摘要:FunctiongetIpvalue(clientIP)'得到客户端的IP转换成长整型,返回值getIpvalueOnErrorResume...

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("http://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一个回来

【asp 根据IP地址自动判断转向分站的代码】相关文章:

在asp中通过getrows实现数据库记录分页的一段代码

ASP与数据库,有用的代码(转贴,摘贴)

图片自动保存到本地并利用aspjpeg为图片加水印

ASP辅助代码

asp中实现随机分组程序的代码

asp动态级联菜单代码

asp中通过getrows实现数据库记录分页的一段代码

asp防止刷新功能实现代码

Asp获取url地址的实例

asp的通用数据分页类

精品推荐
分类导航