dim ip,jcip,jcrs,jcsql,jcconn
ip=request.ServerVariables("REMOTE_ADDR") '获取来访的IP地址
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &Server.MapPath(db)
sql="select * from ip2009 where userip='"&ip&"'"'改的第一处
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.open sql,conn,1,2
if not rs.eof and rs.bof then '改的第二处
rs.close
conn.close
set conn=nothing
%>
数据库路径错误!
<%
elsers.addnew
rs("userip")=ip
rs.update
%>
已经成功添加纪录!
<% rs.close
conn.close
set conn=nothing
end if '改的第三处
%>
<%'自动获得IP
Dim uip,cip,ip
uip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If uip = "" Then uip = Request.ServerVariables("REMOTE_ADDR") '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim conn,connstr,db
db="ip.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0Data Source=" & Server.MapPath(db)
conn.Open connstr
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
cip=split(uip,".")
if ubound(cip)<3 then '如果提交的IP数据不足4位,就补齐
redim Preserve cip(3) '重新定义数组,并保留原来的值
for i=3 to ubound(cip) step -1
cip(i)=0
Next
End If
for i=0 to 3
if not IsNumeric(cip(i)) then cip(i)=0
Next
ip=256*256*256*cip(0)+256*256*cip(1)+256*cip(2)+cip(3)-1
dim rs,sql,Country,City
Set rs=Server.CreateObject("ADODB.Recordset")
'自己改下相应字段名等
sql="select * from Address where startip<="&ip&" and endip>="&ip
rs.open sql,conn,1,1
if rs.eof Then
City="未知"
Country="未知"
Else
City=rs("ip_city")
Country=rs("ip_county")
end If
response.write Err.description
rs.close
set rs=Nothing
response.write "你要查询的IP是"&uip&",来自"&city&"-"&country
%>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)