Chinaunix首页 | 论坛 | 博客
  • 博客访问: 91308
  • 博文数量: 78
  • 博客积分: 4400
  • 博客等级: 上校
  • 技术积分: 1090
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-29 11:10
文章分类

全部博文(78)

文章存档

2011年(1)

2009年(1)

2008年(76)

我的朋友

分类:

2008-10-15 11:40:14

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("")
        if instr(UrlCity,"深圳")<>0 then response.Redirect("")
        if instr(UrlCity,"上海")<>0 then response.Redirect("")
由于IP库超过1M,所以上传不了,IP库网上很多,code.knowsky.com 就有下载。上面只是其中一种方法
资料引用:
阅读(347) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~