Function getIpvalue(clientIP) '获取客户端的IP转换成整型,返回值getIpvalue
出错时继续下一步
暗淡 strIp,array_Ip
条带=0
array_Ip = Split(客户端IP,".")
如果 UBound(array_Ip)<>3 那么
获取IP值=0
退出功能
结束如果
对于 i=0 到 3
strIp=strIp+(CInt(array_Ip(i))*(256^(3-i)))
下一个
获取Ip值=strIp
如果出错则 getIpvalue=0
结束功能
clientIP=request.ServerVariables("REMOTE_HOST")
IpValue=getIpvalue(clientIP)
strSql="从 [Ipaddress] 中选择前 1 个城市,其中“&IpValue&”位于 Ip1 和 Ip2 之间”
设置 RsIp=conn.execute(strSql)
如果 RsIp.bof 和 RsIp.eof 那么
UrlCity=“未知”
别的
UrlCity=RsIp.Fields.Item("城市").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就有下载。上面只是其中一种方法。