ip138数据判断地区归属

[ 2009-11-07 11:14:42 | 作者: admin ]
字号: | |
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
' http://www.nantiahu.com
tempstr = ""
'转换为字符串函数
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

'提交IP到http://www.ip138.com/ips8.asp,并得到查询的地址
Function returnIPAddress(ip)
dim xmlHttp
set xmlHttp=server.createobject("MSXML2.XMLHTTP")
str = "ip="&ip&"&action=2" 'str为POST的数据,既要查询的表单的内容提交。
xmlHttp.open "POST","http://www.ip138.com/ips8.asp",false
xmlHttp.setRequestHeader"Content-Length",Len(str)
xmlHttp.setRequestHeader"CONTENT-TYPE","application/x-www-form-urlencoded"
xmlHttp.send(str)
returnIPAddress=BytesToBstr(xmlHttp.responseBody,"GB2312") '使用responseBody方法获取返回值
End Function

'取得访问用户的IP
Function isHuzhou()
  visitorIP = request("ip")
  if InStr( returnIPAddress(visitorIP) ,"湖州") > 0 then
                    isHuzhou = true
               else
                    isHuzhou= false
               end if

end function

response.write( cstr(ishuzhou() ))
%>
评论Feed 评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=1312

这篇日志没有评论。

此日志不可发表评论。