28,404
社区成员
发帖
与我相关
我的任务
分享<%
'通过查询IP数据库返回IP地址对应的物理地址
Function lookaddress(sip)
Dim str1,str2,str3,str4
Dim num
Dim irs,SQL
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
'计算IP地址数字值
num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
Dim adb,aConnStr,AConn
adb = "ipaddress.mdb"
aConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(adb)
Set AConn = Server.CreateObject("ADODB.Connection")
aConn.Open aConnStr
'查询IP地址对应物理地区
sql="select country,city from dv_address where ip1 <="&num&" and ip2 >="&num
Set irs=aConn.Execute(sql)
If irs.eof And irs.bof Then
lookaddress="--" 'template.Strings(12)
Else
Do While Not irs.eof
lookaddress=lookaddress &irs(0) & irs(1)
irs.movenext
Loop
End If
irs.close
Set irs=nothing
Set AConn=Nothing
End If
Else
lookaddress="--" 'template.Strings(12)
End If
End Function
%>
''''''''''''''''以上为IP地址到物理地址的查询函数
''''''''''''''''以下为统计数据查询结果界面
<%
sql = "select * from bbs order by id desc"
set rs=Server.Createobject("ADODB.RECORDSET")
rs.Open sql, conn, 1, 1
if rs.EOF and rs.BOF then
response.write("暂时还没有数据!")
else
for i=1 to rs.pagesize
if rs.eof then exit for
%>
<tr height="20" onMouseOut="this.bgColor=''" onMouseOver="this.bgColor='#cccccc'">
<td width="30"><%=rs("id")%></td>
<td width="80"> <%=rs("ip")%></td>
<td width="80"> <%=rs("ip_client")%></td>
<td width="200"> <%=lookaddress(rs("ip"))%></td>
<td width="155"> <%=rs("ip_time")%></td>
</tr>
<%
rs.movenext
next
end if
%>
<% set rs=nothing %>
<% end if %>