投递文章投递文章 投稿指南投稿指南 RSS订阅RSS订阅

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

来源:互联网 发布时间:2007-12-12 收藏 投稿 字体:【
以下为引用的内容:
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://guangzhou.youname.com")
        if instr(UrlCity,"深圳")<>0 then response.Redirect("http://shenzhen.youname.com")
        if instr(UrlCity,"上海")<>0 then response.Redirect("http://shanghai.youname.com")

由于IP库超过1M,所以上传不了,IP库网上很多,上面只是其中一种方法.

以前用过的.
最新5条评论 查看所有评论
评论内容:请自觉遵守互联网相关政策法规。
用户名: 密码: 匿名 注册
热门文章
随机推荐
About iTtang - 联系方法  - 专题列表 - 友情链接  -  高级搜索   -  帮助中心  -