<%
set my_conn= Server.CreateObject("ADODB.Connection")
ConnString = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("tj_data.mdb")
my_Conn.Open ConnString
function address(sip)
dim str1,str2,str3,str4
dim num
dim city
dim irs

if not isnumeric(left(sip,2)) then
address="未知"
else
str1=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str2=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str3=left(sip,instr(sip,".")-1)
str4=mid(sip,instr(sip,".")+1)
num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
sql="select Top 1 city from ip_address where ip1 <="&num&" and ip2 >="&num&""
set irs=server.createobject("adodb.recordset")
irs.open sql,my_conn,1,1
if irs.eof and irs.bof then 
city="未知"
else
city=irs("city")
end if
irs.close
set irs=nothing
end if
address=city
if instr(sip,"211.158") then address="未知"
end function

ip=request("ip")
if ip<>"" then
response.write "<b>搜索IP地址的地理位置</b><br><br>您查询的IP是："& ip & "<br>查询结果：" & address(ip)
end if
%>