Author |
Topic  |
|
jessica
New Member

USA
58 Posts |
|
jessica
New Member

USA
58 Posts |
Posted - 21 November 2000 : 09:37:28
|
<b>global.asa</b> <pre id=code><font face=courier size=2 id=code> <script language=vbscript runat=server>
SUB Application_OnStart application("vSessions") = 0 application("vResetDate") = date() application("vResetTime") = now() application("vToday") = now() application("vSessionsToday") = 0 application("vSessionsYesterday") = 0 application("vSessionsSinceReset") = application("vSessions") application("vPeakSessions") = application("vSessions") application("vPeakSessionsDate") = now() application("vSessionTimeout") = 20 'set vUseCounterFile to no to turn logging off 'set vLogFile and vCounterFile to the path and filename of the log files application("vUseLogFile") = "yes" ' yes or no application("vLogFile") = "\db\amstats.log" application("vCounterFile") = "\db\amcounter.log" if application("vUseLogFile") = "yes" then Set vFileSystem = server.createobject("Scripting.FileSystemObject") if vFileSystem.FileExists(server.mappath("\") & application("vCounterFile")) = false then set vFile = vFileSystem.CreateTextFile (server.mappath("\") & application("vCounterFile")) vFile.WriteLine("0") vFile.WriteLine(now()) vFile.Close end if Set vFileSystem = nothing end if END SUB
SUB Application_OnEnd END SUB </font id=code></pre id=code>
Still too long will break into more parts, next part is still the global.asa file:
|
 |
|
jessica
New Member

USA
58 Posts |
Posted - 21 November 2000 : 09:38:19
|
<pre id=code><font face=courier size=2 id=code> SUB Session_OnStart
application.lock if application("vUseLogFile") = "yes" then Set vFileSystem = server.createobject("Scripting.FileSystemObject") if vFileSystem.FileExists(server.mappath("\") & application("vLogFile")) = false then set vFile = vFileSystem.CreateTextFile (server.mappath("\") & application("vLogFile")) vFile.Close end if 'open or create counter file Set vFileSystem = server.createobject("Scripting.FileSystemObject") if vFileSystem.FileExists(server.mappath("\") & application("vCounterFile")) = true then set vFile = vFileSystem.getFile(server.mappath("\") & application("vCounterFile")) set vTextStrm = vFile.openAsTextStream(1,-2) vCount = vTextStrm.readline vDate = vTextStrm.readline vTextStrm.close set vTextStrm = vFile.openAsTextStream(2,-2) vTextStrm.writeline vCount + 1 vTextStrm.writeline vDate vTextStrm.close end if set vFile = vFileSystem.OpenTextFile((server.mappath("\") & application("vLogFile")), 8) vLogString = ("[" & now & "]") & vbcrlf vLogString = vLogString & request.servervariables("SERVER_NAME") & vbcrlf vLogString = vLogString & request.servervariables("SERVER_PORT") & vbcrlf vLogString = vLogString & request.servervariables("SCRIPT_NAME") & vbcrlf vLogString = vLogString & request.servervariables("HTTP_REFERER") & vbcrlf vLogString = vLogString & request.servervariables("HTTP_USER_AGENT") & vbcrlf vLogString = vLogString & request.servervariables("REMOTE_ADDR") & vbcrlf vLogString = vLogString & request.servervariables("SERVER_PROTOCOL") & vbcrlf vLogString = vLogString & request.servervariables("HTTPS") & vbcrlf vFile.writeline vLogString vFile.Close Set vFileSystem = nothing end if session.timeout = application("vSessionTimeout") application("vSessionsSinceReset") = application("vSessionsSinceReset") + 1 application("vSessions") = application("vSessions") + 1 application("vSessionsToday") = application("vSessionsToday") + 1 if application("vSessions") >= application("vPeakSessions") then application("vPeakSessions") = application("vSessions") application("vPeakSessionDate") = now() end if if not datepart("d", application("vToday")) = datepart("d", date()) then application("vToday") = date() application("vSessionsYesterday") = application("vSessionsToday") application("vSessionsToday") = application("vSessions") end if application.unlock
END SUB
SUB Session_OnEnd application.lock application("vSessions") = application("vSessions") - 1 application.unlock END SUB
</script> </font id=code></pre id=code>
|
 |
|
jessica
New Member

USA
58 Posts |
Posted - 21 November 2000 : 09:39:09
|
in the begining of the <b>default.asp</b> file add this:
<pre id=code><font face=courier size=2 id=code> <%
vDaysSinceReset = datediff("d", application("vResetTime"), date()) vSecondsSinceReset = datediff("s", application("vResetTime"), now()) vRemainingSeconds = formatnumber((vSecondsSinceReset mod 60),1) vWholeMinutesSinceReset = ((vSecondsSinceReset - vRemainingSeconds) / 60) vRemainingMinutes = formatnumber((vWholeMinutesSinceReset mod 60),1) vWholeHoursSinceReset = ((vWholeMinutesSinceReset - vRemainingMinutes) / 60) vRemainingHours = formatnumber((vWholeHoursSinceReset mod 24),1) vWholeDaysSinceReset = ((vWholeHoursSinceReset - vRemainingHours) / 24)
vAvgSessionsPerSec = application("vSessionsSinceReset") / (vSecondsSinceReset + 1) vAvgSessionsPerMin = vAvgSessionsPerSec * 60 vAvgSessionsPerHour = vAvgSessionsPerMin * 60 vAvgSessionsPerDay = vAvgSessionsPerHour * 24
'*******GET COUNTER TOTAL********** if application("vUseLogFile") = "yes" then Set vFileSystem = server.createobject("Scripting.FileSystemObject") if vFileSystem.FileExists(server.mappath("/") & application("vCounterFile")) = true then 'set vFile = vFileSystem.CreateTextFile (server.mappath("/") & application("vCounterFile")) set vFile = vFileSystem.getFile(server.mappath("/") & application("vCounterFile")) set vTextStrm = vFile.openAsTextStream(1,-2) vCount = vTextStrm.readline vDate = vTextStrm.readline vTextStrm.close end if Set vFileSystem = nothing else vCount = "Not Logged" vDate = "Not Logged" end if %> </font id=code></pre id=code>
|
 |
|
jessica
New Member

USA
58 Posts |
Posted - 21 November 2000 : 09:39:31
|
You can than add the following to anywhere on the <b>default.asp</b> page you wish to show the stats:
<pre id=code><font face=courier size=2 id=code> <tr> <td rowspan="<% if ShowLastHere then Response.Write("5") else Response.Write("4") end if %>" bgcolor="<%= strForumCellColor %>"> </td> <td bgcolor="<%= strForumCellColor %>" colspan="<% if ((strShowModerators = "1") or (mlev = "4" or mlev = "3")) then Response.Write("6") else Response.Write("4") end if%>"> <font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>">Current users on the site: <% =application("vSessions") %></font> </td> </tr> <tr> <td bgcolor="<%= strForumCellColor %>" colspan="<% if ((strShowModerators = "1") or (mlev = "4" or mlev = "3")) then Response.Write("6") else Response.Write("4") end if%>"> <font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>">Site peak sessions: <% =application("vPeakSessions") %></font> </td> </tr> <tr> <td bgcolor="<%= strForumCellColor %>" colspan="<% if ((strShowModerators = "1") or (mlev = "4" or mlev = "3")) then Response.Write("6") else Response.Write("4") end if%>"> <font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>">Avg. Sessions Per Day: <% =formatnumber(vAvgSessionsPerDay,2) %></font> </td> </tr> <tr> <td bgcolor="<%= strForumCellColor %>" colspan="<% if ((strShowModerators = "1") or (mlev = "4" or mlev = "3")) then Response.Write("6") else Response.Write("4") end if%>"> <font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>">Server up time: <%if vWholeDaysSinceReset > 0 then response.write vWholeDaysSinceReset & "d " if vRemainingHours > 0 then response.write formatnumber(vRemainingHours,0) & "h " if vRemainingMinutes > 0 then response.write formatnumber(vRemainingMinutes,0) & "m " response.write formatnumber(vRemainingSeconds,0) & "s" %> </font> </td> </tr> <tr> <td bgcolor="<%= strForumCellColor %>" colspan="<% if ((strShowModerators = "1") or (mlev = "4" or mlev = "3")) then Response.Write("6") else Response.Write("4") end if%>"> <font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>">Site Peak date/time: <% =application("vPeakSessionDate") %></font> </td> </tr> </font id=code></pre id=code>
|
 |
|
jessica
New Member

USA
58 Posts |
Posted - 21 November 2000 : 09:40:29
|
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote> In reguardance to
http://forum.snitz.com/forum/topic.asp?TOPIC_ID=2228&FORUM_ID=77&CAT_ID=5&Topic_Title=Statistics&Forum_Title=Suggest forum%2Esnitz%2Ecom Content
There are a couple of way to do this, I currently use the global.asa file. It also can be done other ways, but I like this the best:
I have found that Snitz Forums will not handle this long of a code, so I will break it down into replys, being of the 2 files, global.asa and default.asp
You can see a working copy of it at http://www.webzonecomplete.com/forum/default.asp
Good luck and you can post a question there if you have problems getting it installed.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I think I have cut & pasted everything, if I forgot something go to my site and let me know...
Thanks
|
 |
|
jessica
New Member

USA
58 Posts |
Posted - 21 November 2000 : 16:38:32
|
Although when I have made this code and post, I was unaware of that there was one already in progress of this nature... I will promise to make sure I watch more closly next time not to step on anybodies toes....
|
 |
|
gor
Retired Admin
    
Netherlands
5511 Posts |
Posted - 21 November 2000 : 16:45:10
|
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote> Although when I have made this code and post, I was unaware of that there was one already in progress of this nature... I will promise to make sure I watch more closly next time not to step on anybodies toes.... <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
<img src=icon_smile_question.gif border=0 align=middle> I don't see a problem with this post <img src=icon_smile_question.gif border=0 align=middle> Maybe that there might be some complications for people that can't use global.asa or don't know how to tweak it so the creation of the log-files takes place in a directory at their site were IIS can write.
But that is what this forum (also) is for: anyone who feels like it, can take the code, try it, and if it doesn't work for him/her comes back for help. That helps to debug the code or make it more general usable.
Thank you for posting it <img src=icon_smile.gif border=0 align=middle>
<b>Pierre Gorissen</b>
<font color=blue><font size=1>Even if you're on the right track, you'll get run over if you just sit there.</font id=blue></font id=size1> <font size=1><font color=black>Will Rogers</font id=size1></font id=black> |
 |
|
|
Topic  |
|