找回密码
 注册
【阿里云】2核2G云新老同享 99元/年,续费同价华为云精选云产品特惠做网站就用糖果主机Jtti,新加坡服务器,美国服务器,香港服务器
楼主: sunlei

一个无须数据库查询IP所在地的函数

[复制链接]
 楼主| 发表于 2005 年 5 月 24 日 17:28:14 | 显示全部楼层

一个无须数据库查询IP所在地的函数

  <%
'------------------------------
'无须数据库查询Ip所在地函数
'By:Neeao
'------------------------------
response.write SelectIP("127.0.0.1") '测试用的语句,可以删除!

Function SelectIP(ip)
Dim wstr,str,url,start,over,city
url="http://dheart.51.net/ip/index.php?ip="&ip&""
wstr=getHTTPPage(url)
start=Newstring(wstr,"<br><br>")
over=Newstring(wstr,"<form method")
body=mid(wstr,start,over-start)
body = replace(body,"<br>","")
body = replace(body,ip,"")
response.write body
End Function

Function getHTTPPage(url)
Dim Http
Set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()

If Http.readystate<>4 then
  exit function
End If
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
Set http=nothing
If err.number<>0 then err.Clear
End Function

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

Function Newstring(wstr,strng)
Newstring=Instr(lcase(wstr),lcase(strng))
If Newstring<=0 then Newstring=Len(wstr)
End Function
%>
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

 楼主| 发表于 2005 年 5 月 24 日 17:28:14 | 显示全部楼层
【腾讯云】2核2G云服务器新老同享 99元/年,续费同价

一个无须数据库查询IP所在地的函数

  <%
'------------------------------
'无须数据库查询Ip所在地函数
'By:Neeao
'------------------------------
response.write SelectIP("127.0.0.1") '测试用的语句,可以删除!

Function SelectIP(ip)
Dim wstr,str,url,start,over,city
url="http://dheart.51.net/ip/index.php?ip="&ip&""
wstr=getHTTPPage(url)
start=Newstring(wstr,"<br><br>")
over=Newstring(wstr,"<form method")
body=mid(wstr,start,over-start)
body = replace(body,"<br>","")
body = replace(body,ip,"")
response.write body
End Function

Function getHTTPPage(url)
Dim Http
Set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()

If Http.readystate<>4 then
  exit function
End If
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
Set http=nothing
If err.number<>0 then err.Clear
End Function

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

Function Newstring(wstr,strng)
Newstring=Instr(lcase(wstr),lcase(strng))
If Newstring<=0 then Newstring=Len(wstr)
End Function
%>
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

 楼主| 发表于 2005 年 5 月 24 日 17:28:14 | 显示全部楼层

一个无须数据库查询IP所在地的函数

  <%
'------------------------------
'无须数据库查询Ip所在地函数
'By:Neeao
'------------------------------
response.write SelectIP("127.0.0.1") '测试用的语句,可以删除!

Function SelectIP(ip)
Dim wstr,str,url,start,over,city
url="http://dheart.51.net/ip/index.php?ip="&ip&""
wstr=getHTTPPage(url)
start=Newstring(wstr,"<br><br>")
over=Newstring(wstr,"<form method")
body=mid(wstr,start,over-start)
body = replace(body,"<br>","")
body = replace(body,ip,"")
response.write body
End Function

Function getHTTPPage(url)
Dim Http
Set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()

If Http.readystate<>4 then
  exit function
End If
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
Set http=nothing
If err.number<>0 then err.Clear
End Function

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

Function Newstring(wstr,strng)
Newstring=Instr(lcase(wstr),lcase(strng))
If Newstring<=0 then Newstring=Len(wstr)
End Function
%>
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

 楼主| 发表于 2005 年 5 月 24 日 17:28:14 | 显示全部楼层

一个无须数据库查询IP所在地的函数

  <%
'------------------------------
'无须数据库查询Ip所在地函数
'By:Neeao
'------------------------------
response.write SelectIP("127.0.0.1") '测试用的语句,可以删除!

Function SelectIP(ip)
Dim wstr,str,url,start,over,city
url="http://dheart.51.net/ip/index.php?ip="&ip&""
wstr=getHTTPPage(url)
start=Newstring(wstr,"<br><br>")
over=Newstring(wstr,"<form method")
body=mid(wstr,start,over-start)
body = replace(body,"<br>","")
body = replace(body,ip,"")
response.write body
End Function

Function getHTTPPage(url)
Dim Http
Set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()

If Http.readystate<>4 then
  exit function
End If
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
Set http=nothing
If err.number<>0 then err.Clear
End Function

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

Function Newstring(wstr,strng)
Newstring=Instr(lcase(wstr),lcase(strng))
If Newstring<=0 then Newstring=Len(wstr)
End Function
%>
Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|金光论坛

GMT+8, 2024 年 11 月 19 日 18:41 , Processed in 0.095062 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表