<marquee width=358>欢迎来到月影社区,希望这里可以成为您美丽的梦幻花园,如果你觉得这里好请分享给您的朋友!- wf66.com</marquee> 将月影社区设置为您的首页将月影社区地址加入到您的收藏栏
月影社区时尚音乐音乐查询IP手机许愿之瓶最新更新文件加密访客留言爱音乐
欢迎您,首页 >> 信息中心 >> 来访者地址统计,很好的一个程序!

请输入您关键字:


来访者地址统计,很好的一个程序!

推荐查看本文HTML版本


In your global.asa, Session_OnStart, add:
'Update user database
set conntemp=server.createobject("adodb.connection")
cnpath="DBQ=" & server.mappath
("/stevesmith/data/timesheet.mdb")
conntemp.Open "DRIVER={Microsoft Access Driver (*.mdb)}; "
& cnpath
sqlString = "INSERT INTO user_log " & _
" [月影读书频道 http://wf66.com/]
(user_id,log_date,action_code,browser,ip_address) " & _
" VALUES ('Unknown',now,'L','" & _
Request.ServerVariables("HTTP_USER_AGENT") & "','"
& _
Request.ServerVariables("REMOTE_HOST") & "')"
Set logRS=conntemp.execute(sqlString)
Set logRS=nothing


Include on any page whose hits you wish to track:
'Update pagelog
Dim hdrconntemp
Dim hdrcnpath
Dim hdrsqlString
Dim hdrlogRS
set hdrconntemp=server.createobject("adodb.connection")
hdrcnpath="DBQ=" & server.mappath
("/stevesmith/data/timesheet.mdb")
hdrconntemp.Open "DRIVER={Microsoft Access Driver
(*.mdb)}; " & hdrcnpath
hdrsqlString = "INSERT INTO page_log " & _
" (page,log_date,action_code,browser,ip_address) "
& _
" VALUES ('" & Request.ServerVariables
("SCRIPT_NAME") & "',now,'L','" & _
Request.ServerVariables("HTTP_USER_AGENT") & "','"
& _
Request.ServerVariables("REMOTE_HOST") & "')"
Set hdrlogRS= hdrconntemp.execute(hdrsqlString)
Set hdrlogRS=nothing

Naturally, you'll need to create the tables and the DSN yourself for
your own site. The table setup should be fairly obvious from the
INSERT statements. I called the tables user_log and page_log. Lastly,
you will need to display your statistics somewhere. Here is the
source code for usage.asp:

1<% OPTION EXPLICIT %>
2<!--#include virtual="stevesmith/top.asp"-->
3<%
4' Initialize Variables
5Dim MyServer 'Address Server Portion
6Dim MyPath 'Address Path Portion
7Dim MySelf 'Full HTTP Address
8Dim starttime 'Time page began
9Dim objConnect 'Default Connection Object
10Dim cnpath 'Connection path
11Dim objCmd 'Default Command Object
12Dim objRst 'Default Recordset Object
13Dim total 'Total logins
14Dim totalhits 'Total page hits
15Dim successfullogins 'Number of Successful logins
16Dim failedlogins 'Number of failed logins
17Dim IE 'Number of Internet Explorer Hits
18Dim Net 'Number of Netscape Navigator Hits
19Dim I 'Loop control variable
20Dim hourhits 'Hits in last hour
21Dim hourusers 'Users in last hour
22Dim dayhits 'Hits in last day
23Dim dayusers 'Users in last day
24Dim weekhits 'Hits in last week
25Dim weekusers 'Users in last week
26Dim monthhits 'Hits in last month
27Dim monthusers 'Users in last month
28Dim tmpDate,tmpDate2 'Date
29 
30 MyServer=Request.ServerVariables("SERVER_NAME")
31 MyPath=Request.ServerVariables("SCRIPT_NAME")
32 MySelf="HTTP://" & MyServer & MyPath
33 %>
34 <html>
35 <head>
36 <title>Usage</title>
37 <meta HTTP-EQUIV="REFRESH" CONTENT="300;<%=Myself%>">
38 </head>
39 <body background="http://<%=Request.ServerVariables
("SERVER_NAME")%>/stevesmith/images/whtmarb.jpg">
40 <a HREF="http://<%=Request.ServerVariables("SERVER_NAME")%
>/stevesmith/index.asp">
41 <img SRC="http://<%=Request.ServerVariables("SERVER_NAME")%
>/stevesmith/images/return.gif"
42 ALIGN="LEFT" ALT="Return to Stevenator's ASP Page" WIDTH="40"
HEIGHT="40"></a>
43 
44 <center><h1>Usage (May 1998 to February 1999)</h1></center>
45 <%
46 starttime = now
47 
48'Establish connection
49Set objConnect = Server.CreateObject("ADODB.Connection")
50cnpath="DBQ=" & server.mappath("/stevesmith/data/timesheet.mdb")
51objConnect.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " &
cnpath
52 
53'Create Command object
54Set objCmd = Server.CreateObject("ADODB.Command")
55Set objCmd.ActiveConnection=objConnect
56objCmd.CommandType = adCmdText
57 
58'Set up objRst
59Set objRst = Server.CreateObject("ADODB.Recordset")
60Set objRst.ActiveConnection=objConnect
61Set objRst.Source = objCmd
62 
63'Get users/hits in last hour
64tmpDate = DateAdd("h",-1,now())
65objCmd.CommandText = "SELECT count(user_id) as cnt FROM
user_log " & _
66" WHERE log_date between #" & now & "# AND #"& tmpDate & "#"
67objRst.Open
68hourusers = objRst("cnt")
69objRst.Close
70objCmd.CommandText = "SELECT count(ip_address) as cnt FROM
page_log " & _
71" WHERE log_date between #" & now & "# AND #"& tmpDate & "#"
72objRst.Open
73hourhits = objRst("cnt")
74objRst.Close
75
76'Get users/hits in last day
77tmpDate = DateAdd("d",-1,now())
78objCmd.CommandText = "SELECT count(user_id) as cnt FROM
user_log " & _
79" WHERE log_date between #" & now & "# AND #"& tmpDate & "#"
80objRst.Open
81dayusers = objRst("cnt")
82objRst.Close
83objCmd.CommandText = "SELECT count(ip_address) as cnt FROM
page_log " & _
84" WHERE log_date between #" & now & "# AND #"& tmpDate & "#"
85objRst.Open
86dayhits = objRst("cnt")
87objRst.Close
88
89'Get users/hits in last week
90tmpDate = DateAdd("d",-7,now())
91objCmd.CommandText = "SELECT count(user_id) as cnt FROM
user_log " & _
92" WHERE log_date between #" & now & "# AND #"& tmpDate & "#"
93objRst.Open
94weekusers = objRst("cnt")
95objRst.Close
96objCmd.CommandText = "SELECT count(ip_address) as cnt FROM
page_log " & _
97" WHERE log_date between #" & now & "# AND #"& tmpDate & "#"
98objRst.Open
99weekhits = objRst("cnt")
100objRst.Close
101
102'Get users/hits in last month
103tmpDate = DateAdd("m",-1,now())
104objCmd.CommandText = "SELECT count(user_id) as cnt FROM
user_log " & _
105" WHERE log_date between #" & now & "# AND #"& tmpDate & "#"
106objRst.Open
107monthusers = objRst("cnt")
108objRst.Close
109objCmd.CommandText = "SELECT count(ip_address) as cnt FROM
page_log " & _
110" WHERE log_date between #" & now & "# AND #"& tmpDate & "#"
111objRst.Open
112monthhits = objRst("cnt")
113objRst.Close
114 
115objCmd.CommandText = "SELECT count(user_id) as cnt FROM
user_log " & _
116" WHERE action_code = 'L'"
117objRst.Open
118total = objRst("cnt")
119objRst.Close
120objCmd.CommandText = "SELECT count(*) as cnt" & _
121" FROM page_log "
122objRst.Open
123totalhits = objRst("cnt")
124 %>
125 <center>
126 <b>Your IP: <font COLOR="RED"><%=Session("IP")%></font></b>
127 <table BORDER bgColor="#f3efd0">
128 <tr bgColor="#dfcba0">
129<th>Item</th>
130<th>Last Hour</th>
131<th>Last Day</th>
132<th>Last Week</th>
133<th>Last Month</th>
134<th>Total</th>
135 </tr>
136 <tr>
137 <td align="left"><b>Logins:</b></td>
138 <td><%=hourusers%></td>
139 <td><%=dayusers%></td>
140 <td><%=weekusers%></td>
141 <td><%=monthusers%></td>
142 <td align="CENTER"><font color="red"><%=total%></font></td>
143 </tr>
144 <tr>
145 <td align="left"><b>Page Hits:</b></td>
146 <td><%=hourhits%></td>
147 <td><%=dayhits%></td>
148 <td><%=weekhits%></td>
149 <td><%=monthhits%></td>
150 <td align="CENTER"><font color="red"><%=totalhits%></font></td>
151 </tr>
152 
153 </table>
154 <hr>
155 <!-- Display Total Hits by UserID, with IP Address -->
156 <%
157objRst.Close
158objCmd.CommandText = "SELECT count(user_id) as cnt, user_id,
ip_address, max(log_date) as ld" & _
159" FROM user_log WHERE " & _
160" action_code = 'L' " & _
161" GROUP BY ip_address,user_id " & _
162" ORDER BY ip_address "
163objRst.Open
164 %>
165 <table border>
166 <caption><b>Hits by User</b></caption>
167 <tr bgColor="#dfcba0">
168 <td><b>Name</b></td>
169 <td><b>IP Address</b></td>
170 <td><b># of Logins</b></td>
171 <td><b>Last Login</b></td>
172 </tr>
173 <tr>
174 <td COLSPAN="4"><font COLOR="RED">Chopped for Brevity. Source
code available
175 <a
HREF="http://www.aspalliance.com/stevesmith/samples/sitestats.asp">her
e.</a></font></td>
176 </tr>
177 <!--<%' Do While Not objRst.EOF%><tr bgColor="#f3efd0"><td
align="CENTER"> <%=objRst("user_id")%> </td><td align="CENTER"> <%
=objRst("ip_address")%> </td><td align="CENTER"> <%=objRst("cnt")%> (
<%=fix(CInt(objRst("cnt"))*100/total)%> %) </td><td> <%=objRst("ld")%
></td></tr> <%' objRst.MoveNext' Loop%>-->
178 </table><hr>
179 <!-- Display Total Hits by Page, with IP Address -->
180 <%
181objRst.Close
182objCmd.CommandText = "SELECT count(page) as cnt, page, max
(log_date) as ld" & _
183" FROM page_log WHERE " & _
184" action_code = 'L' " & _
185" GROUP BY page " & _
186" ORDER BY count(page) DESC "
187objRst.Open
188 %>
189 <table border>
190 <caption><b>Hits by Page</b></caption>
191 <tr bgColor="#dfcba0">
192 <td><b>Page</b></td>
193 <td><b># of Hits</b></td>
194 <td><b>Last Hit</b></td>
195 </tr>
196<%
197Do While Not objRst.EOF
198 %>
199 <tr bgColor="#f3efd0">
200 <td align="left">
201<%=objRst("page")%>
202</td>
203 <td align="CENTER">
204<%=objRst("cnt")%>
205(
206<%=fix(CInt(objRst("cnt"))*100/totalhits)%>
207%) </td>
208 <td>
209<%=objRst("ld")%>
210 </td>
211 </tr>
212<%
213objRst.MoveNext
214Loop
215 %>
216
217 </table>
218 
219 <hr>
220 <!-- Display total hits by Browser type -->
221 <%
222objRst.Close
223objCmd.CommandText = "SELECT browser, count(*) as cnt " & _
224" FROM user_log " & _
225" WHERE browser is not null " & _
226" GROUP BY browser " & _
227" ORDER BY count(browser) desc"
228objRst.Open
229 %>
230 <table border>
231 <caption><b>Hits by
232Browser</b></caption>
233 <tr bgColor="#dfcba0">
234 <td><b>Browser</b></td>
235 <td><b>Hits</b></td>
236 </tr>
237<%
238IE = 0
239Net = 0
240Do While Not objRst.EOF
241If InStr(objRst("browser"),"MSIE") Then
242IE = IE + CInt(objRst("cnt"))
243ElseIf InStr(objRst("browser"),"Mozilla") Then
244Net = Net + CInt(objRst("cnt"))
245End If
246 %>
247 <tr bgColor="#f3efd0">
248 <td>
249<%=objRst("browser")%>
250</td>
251 <td>
252<%=objRst("cnt")%>
253(
254<%=fix(CInt(objRst("cnt"))*100/total)%>
255%)
256 </td>
257 </tr>
258<%
259objRst.MoveNext
260Loop
261 %>
262
263 </table>
264 <hr>
265 <!-- Display percent Explorer vs Netscape users --> [月影社区 http://wf66.com/]
266 <table BORDER BGCOLOR="#f3efd0">
267 <caption><b>Hits by
268Browser</b></caption>
269 <tr bgColor="#dfcba0">
270 <td><b>Netscape</b></td>
271 <td><b>Explorer</b></td>
272 <td><b>Other</b></td>
273 </tr>
274 
275 <tr>
276 <td>
277<%=Net%>
278(
279<%=fix(Net*100/total)%>
280%)</td>
281 <td>
282<%=IE%>
283(
284<%=fix(IE*100/total)%>
285%)</td>
286 <td>
287<%=total-Net-IE%>
288(
289<%=fix((total-Net-IE)*100/total)%>
290%)</td>
291 </tr>
292 
293 </table>
294 <hr>
295 <!-- Display total hits by IP and browser - what browser does
each user prefer -->
296 <%
297objRst.Close
298objCmd.CommandText = "SELECT ip_address, browser, count(*) as
cnt " & _
299" FROM user_log " & _
300" WHERE action_code = 'L' " & _
301" GROUP BY browser, ip_address " & _
302" ORDER BY ip_address"
303objRst.Open
304 %>
305 <table border>
306 <caption><b>Browser Hits by
307User</b></caption>
308 <tr bgColor="#dfcba0">
309 <td><b>User</b></td>
310 <td><b>Browser</b></td>
311 <td><b>Hits</b></td>
312 </tr>
313 <tr>
314 <td COLSPAN="3"><font COLOR="RED">Chopped for Brevity(10 lines
shown). Source code available
315 <a
HREF="http://www.aspalliance.com/stevesmith/samples/sitestats.asp">her
e.</a></font></td>
316 </tr>
317<%
318I = 0
319Do While I < 10
320I = I + 1
321 %>
322 <tr bgColor="#f3efd0">
323 <td><%=objRst("ip_address")%>
324 </td>
325 <td>
326<%=objRst("browser")%>
327</td>
328 <td>
329<%=objRst("cnt")%>
330(
331<%=fix(CInt(objRst("cnt"))*100/total)%>
332%)
333 </td>
334 </tr>
335<%
336objRst.MoveNext
337Loop
338 %>
339
340 </table>
341 <hr>
342 <!-- Display last ten users and time of use -->
343 <%
344objRst.Close
345objCmd.CommandText = "SELECT ip_address, " & _
346" log_date FROM user_log WHERE " & _
347" action_code = 'L' " & _
348" ORDER BY log_date DESC"
349objRst.Open
350 %>
351 <table border>
352 <caption><b>Last 10
353Users</b></caption>
354 <tr bgColor="#dfcba0">
355 <td> </td>
356 <td><b>Date</b></td>
357 <td><b>IP Address</b></td>
358 </tr>
359<%
360I = 0
361Do While (Not objRst.EOF) AND (I < 10)
362I = I + 1
363 %>
364 <tr bgColor="#f3efd0">
365 <td> [月影社区 http://wf66.com/]
366<%=I%>
367 <td>
368<%=objRst("log_date")%>
369</td>
370 <td>
371<%=objRst("ip_address")%>
372</td>
373 </tr>
374 <% objRst.MoveNext
375Loop %>
376 <!-- Display Total Server time to generate this data -->
377 </table>
378 <b>Total load time:
379 <font color="red">
380 <%=datediff("s",starttime,now)%>
381 </font>seconds</b>
382 </center>
383 <!--#INCLUDE VIRTUAL="/stevesmith/bottom.asp"-->
384 </body>
385 </html>


来访者地址统计,很好的一个程序! 2006-8-28
转到本主题第:[ 1 ]
相关评论

暂无评论

总计0页 [ ]上一页 下一页
发表评论(揪错)
呢称: * 您尚未登陆,请登录
来自: *
内容:
 

(为防止非法信息,您的言论提交后需要审核才能正常显示)

文学
精品文萃 情感天地 言情小说
网络小说 玄幻小说 悬疑恐怖
武侠小说 古典品谈 外国名著
儿童文学 会员原创 学习园地
杂谈其它
娱乐
爆笑网文 星座占卜 影音动漫
娱乐新闻 影视剧情
诗词
青竹诗歌 个人诗集 宋词雅赏
全唐诗录
新闻
国际新闻 国内新闻 科技新闻
体育新闻
图片
图文专区 艺术长廊 桌面壁纸
精品素材 像素图片
漫画
单幅漫画 爆笑四格 连环漫画
电脑
电脑入门 图形图像 编程开发
游戏
我爱Q宠 最新攻略 最新秘籍
游戏新闻 技巧心得
经济
帕格节电 财经资讯 股市证券
生活
百科知识 外语学院 潮流时尚
健康医疗 宠物花卉 汽车地带
行走天下
美食
面食甜点 家常菜品 药膳食疗
美食天下 烹饪技巧 松辽风味
燕京风味 巴蜀风味 滇黔风味
赣江风味 徽皖风味 闽台风味
齐鲁风味 中州风味 岭南风味
荆楚风味 三晋风味 淞沪风味
苏扬风味 潇湘风味 钱塘风味
民族风味 素斋仿荤
营销
管理杂谈 谈经论道 培训激励
经营战略 职场生涯 公关交际
关于我们版权声明本站导航友情连结作品演示 TOP↑
本论坛言论纯属发表者个人意见,与£月影社区£立场无关。 皖ICP备16024038号-1
禁止发布任何色情/政治/反动相关信息让我们共同来营造一个属于我们的梦幻家园
Copyright ©2001-2006 MoonShadow. All rights reserved.  Version 4.0  Licence 2006.4.2
建站天数:7144天 本站基于ASP+JS构建,完全自主开发,版权归属月影社区 管理员QQ:23165062 Time:125ms