connip.asp

来自「一套企业全站」· ASP 代码 · 共 32 行

ASP
32
字号
<%
dim connIP,connIPstr

Set ConnIP=Server.CreateObject("ADODB.Connection")   

connIPstr ="Provider = Microsoft.Jet.OLEDB.4.0; Data Source ="&_
	Server.MapPath("address.mdb")
ConnIP.Open connIPstr

sub connIPclose
	connIP.close
	set conn=nothing
end sub

function getFrom(ip)
	dim arr,num, sql, rs
	arr=split(ip,".")
	if ip="" or ubound(arr)<>3 then
		getFrom=""
		exit function
	end if
	num=int(arr(0))*16777216+int(arr(1))*65536+int(arr(2))*256+int(arr(3))-1
	sql="select top 1 country,city from address where ip1<="&num&" and ip2>="&num
	set rs=connip.execute(sql)
	if not rs.eof then
		getFrom=rs(0)&rs(1)
	end if
	rs.close
	set rs=nothing
end function
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?