|
作者: freebsd [freebsd] 论坛用户 | 登录 |
1.建立access数据库库web,添加一个表ipcount.ipcount字段如下 ip(15字节) num(长整数) lastvisit(时间:默认Now()) 2.编写record.asp文件: <% userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR") If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR") %> <% db="web.mdb" Set conn = Server.CreateObject("ADODB.Connection") connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db) conn.Open connstr sqlcmd = "select ip from ipcount where ip='"&userip&"'" Set RS = conn.Execute(sqlcmd) if RS.EOF then sqlcmd = "insert into ipcount (ip,num) values('"&userip&"','1')" else sqlcmd = "update ipcount set num=num+1,lastvisit='"&now()&"' where ip='"&useri p&"'" end if conn.Execute sqlcmd RS.close conn.close %> 3.编写显示ip地址情况的文件(从ipcount.mdb中读出ip访问情况) <html> <head> <title>IP统计</title> </head> <body> <% db="web.mdb" Set conn = Server.CreateObject("ADODB.Connection") connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db) conn.Open connstr sqlcmd = "ipcount" Set RS = conn.Execute(sqlcmd) %> <table align = "center" > <tr bgcolor = #D8D8D8> <%For i=0 To RS.Fields.Count-1%> <td><%=RS(i).Name%></td> <%Next%> </tr> <% DO While Not RS.EOF%> <tr> <%For i=0 To RS.Fields.Count-1%> <td><%=RS(i)%></td> <%Next%> </tr> <% RS.MoveNext Loop RS.Close conn.close %> </table> </body> </html> 4.在需要统计的页面加入如下语句: <!--#include file="record.asp"--> 5.这样你就可以访问ipcount.asp查看来访者访问次数/他的ip地址/最后登陆时间了. 6.看看效果 先访问 http://114002.com 然后看看 http://114002.com/ipcount.asp 是不是有你的ip了? |
地主 发表时间: 06/04 23:13 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号