木子屋 Dnawo's BLOG

动网IP库使用方法

👤 dnawo 📅 2008-06-05 👁 4524 👍 0 💬 0 🔄 来源:本站原创
下边函数摘自Dvbbs8.2.0_Rc1_ac版inc/Dv_ClsMain.asp文件:

Function address(sip)
	Dim aConnStr,aConn,adb
	Dim str1,str2,str3,str4
	Dim  num
	Dim country,city
	Dim irs,SQL
	address="未知"
	If IsNumeric(Left(sip,2)) Then
		If sip="127.0.0.1" Then sip="192.168.0.1"
		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)
		If isNumeric(str1)=0 or isNumeric(str2)=0 or isNumeric(str3)=0 or isNumeric(str4)=0 Then
		Else		
			num=CLng(str1)*16777216+CLng(str2)*65536+CLng(str3)*256+CLng(str4)-1
			adb = "data/ipaddress.mdb"
			aConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(adb)
			Set AConn = Dvbbs.iCreateObject("ADODB.Connection")
			aConn.Open aConnStr
			country="亚洲"
			city=""
			sql="select top 1 country,city from dv_address where ip1 <="& num &" and ip2 >="& num 
			Set irs=aConn.execute(sql)
			If Not(irs.EOF And irs.bof) Then
				country=irs(0)
				city=irs(1)
			End If
			irs.close
			Set irs=Nothing
			aConn.Close
			Set aConn = Nothing 
			SqlQueryNum = SqlQueryNum+1
		End If
		address=country&city
	End If
End Function

评论(0)

暂无评论。

验证码
评论需审核通过后显示
← 上一篇 让电脑裸奔 制作百毒不侵的Windows系统 下一篇 → 值得称道的浏览器十二大功能