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

王朝other·作者佚名  2008-05-31
窄屏简体版  字體: |||超大  

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://code.knowsky.com")

if instr(UrlCity,"深圳")<>0 then response.Redirect("http://moban.knowsky.com")

if instr(UrlCity,"上海")<>0 then response.Redirect("http://font.knowsky.com")

由于IP库超过1M,所以上传不了,IP库网上很多,code.knowsky.com 就有下载。上面只是其中一种方法.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航