asp 根据IP地址自动判断转向分站的代码
程序员文章站
2023-01-24 23:19:25
function getipvalue(clientip)'得到客户端的ip转换成长整型,返回值getipvalue on error resume next dim st...
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.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一个回来
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.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生成html的新方法
下一篇: asp获取当前网页地址的代码