This was posted long time back but the post got lost during the server crash. So here it is again.
Mod PageHits
Counts and displays the number of visits to each page.
Author:
By GauravBhabu(Rakesh Jain)www.forumsquare.com
Posted
2001
Last Updated
August 2, 2002
Installation:
Add the following code in inc_footer.asp
<%
dim MyPageCounter, strHost, strPath, intPathLen, strDir, strPageName
Set MyPageCounter = Server.CreateObject("MSWC.PageCounter")
Rem -Do not count your own visits, Replace the part in red with your IP Address
if Request.ServerVariables("REMOTE_ADDR") <> Request.ServerVariables("SERVER_NAME")then
MyPageCounter.PageHit
end if
strHost = "http://" & Request.ServerVariables("HTTP_HOST")
strPath = Request.ServerVariables("PATH_INFO")
Rem -Let us find position of last "/"
intPathLen = InStrRev(strPath, "/", -1)
strDir = lcase(left(strPath,intPathLen))
strPageName = lcase(Right(strPath,(len(strPath)-intPathLen)))
Response.write (vbNewLine & _
"<a href=""" & strHost & """>" & strHost & "</a>" & vbNewLine & _
"<a href=""" & strDir & """>" & strDir & "</a>" & vbNewLine & _
"<a href=""" & strPath & """>" & strPageName & "</a>")
Rem -Replace YYYYMMDD with the date you want to show as the counter begining date
Response.write "<br> Viewed: " & MyPageCounter.Hits & " times since " & chkdate(YYYYMMDD)
%>
How it works:
[quote]
The Page Counter component creates a PageCounter object that counts and displays the number of times a Web page has been opened. At regular intervals the object writes the number of hits to a text file so that in the event of a server shutdown, the data is not lost. The Page Counter component uses an internal Central Management object to record how many times each page in the application has been opened.
When an instance of the PageCounter object is created on a page by using the Server.CreateObject method, the object retrieves the current hit count for the specified Web page from the Central Management object. The object can then be manipulated with the methods it exposes.
The Page Counter component uses the following files:
Pagecnt.dll
Hitcnt.cnt
MethodsHits -Displays the number of times that a specified URL has been opened.
PageHit -Increments the Hit Count.
Reset -Sets the hit count for a specified page to 0.
www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.