<%
	function address(sip)
	if not isnumeric(left(sip,2)) then
		address="未知"
	else
		str1=left(sip,instr(sip,".")-1)
		sip1=mid(sip,instr(sip,".")+1)
		str2=left(sip1,instr(sip1,".")-1)
		sip1=mid(sip1,instr(sip1,".")+1)
		str3=left(sip1,instr(sip1,".")-1)
		str4=mid(sip1,instr(sip1,".")+1)
		num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
		sql="select Top 1 city,country from ip_address where ip1 <="&num&" and ip2 >="&num&""
		set rs1=server.createobject("adodb.recordset")
		rs1.open sql,conn,1,1
		if rs1.eof and rs1.bof then 
			country="亚洲其它地区"
		else
			country=rs1("country")
			city=rs1("city")
		end if
		rs1.close
		set rs1=nothing
	end if
	address=country+city
	if left(cstr(sip),5)="127.0" or left(cstr(sip),7)="192.168" then address="保留IP地址"
	end function
	ip=request("ip")
	if ip<>"" then
		response.write "<b>搜索IP地址的地理位置</b><br><br>您查询的IP是："& ip & "<br>查询结果：" & address(ip)
	end if
%>