+ -
当前位置:首页 → 问答吧 → 根据本地网站客户端ip 判断其在表VIEWIP中属于四个区域的哪个区域,然后网页跳转到相应区域的页面

根据本地网站客户端ip 判断其在表VIEWIP中属于四个区域的哪个区域,然后网页跳转到相应区域的页面

时间:2010-05-25

来源:互联网

请大家帮忙看看怎么写 谢谢!







VIEWIP (IP区域段表)

------------------------------------------------------------------

View_id View_name View_IP_from View_IP_to
1 北京 10.77.147.128 10.77.147.191
2 上海 10.77.144.0 10.77.147.127
3 广东 10.77.147.192 255.255.255.255
4 辽宁 10.77.192.0 10.77.192.255



想要实现的功能:


<%


getIP=获得客户端ip


if getIP 在 北京IP段组(10.77.147.128<getIP<10.77.147.191) then

response.Redirect("beijing.asp")

end if

if getIP 在 上海IP段组 then

response.Redirect("shanghai.asp")

end if


if getIP 在 广东IP段组 then

response.Redirect("guangdong.asp")

end if

if getIP 在 辽宁IP段组 then

response.Redirect("liaoning.asp")

end if


%>


作者: helloidea   发布时间: 2010-05-25

飘过`~

作者: wangxiaomo521   发布时间: 2010-05-26

例子:
HTML code

<%
Function FormatIP(IP)
IP=Split(IP,".")
FormatIP=Cint(IP(0))*256*256*256+Cint(IP(1))*256*256+Cint(IP(2))*256+Cint(IP(3))-1
End Function

Dim getIP,Url
getIP=FormatIP("10.77.147.182") '假设客户端IP是10.77.147.182
If FormatIP("10.77.147.128")<getIP And getIP<FormatIP("10.77.147.191") Then
Url="beijing.asp"
ElseIf FormatIP("10.77.144.0")<getIP And getIP<FormatIP("10.77.147.127") Then
Url="shanghai.asp"
ElseIf FormatIP("10.77.147.192")<getIP And getIP<FormatIP("255.255.255.255") Then
Url="guangdong.asp"
ElseIf FormatIP("10.77.192.0")<getIP And getIP<FormatIP("10.77.192.255") Then
Url="liaoning.asp"
End If

If Url<>"" Then Response.Redirect(Url)
%>

作者: liaitan   发布时间: 2010-05-26

MARK!

作者: hubing2008   发布时间: 2011-12-19