Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 Mod PageHits
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

GauravBhabu
Advanced Member

4288 Posts

Posted - 02 August 2002 :  10:33:46  Show Profile
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

Methods
Hits    -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.

Etymon
Advanced Member

United States
2385 Posts

Posted - 05 August 2002 :  18:07:28  Show Profile  Visit Etymon's Homepage

Thank you, GauravBhabu, for this!

Question: The files you mentioned Pagecnt.dll and Hitcnt.cnt. Where are they located? Do I have to create them? Are they created automatically?


Thanks again,

Etymon


Are you looking for answers at Snitz? | Searching the forums is easiest!
Basic | Advanced (Internet Explorer only)
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 05 August 2002 :  18:26:30  Show Profile  Visit dayve's Homepage
they are built in components for IIS5, if you have Windows 2000 with IIS5, they should be present.

I am using a version of this myself.

http://www.nineinchnailz.com

Snitz Exchange | Snitz Icons | Do's and Dont's
Go to Top of Page

Etymon
Advanced Member

United States
2385 Posts

Posted - 05 August 2002 :  18:49:30  Show Profile  Visit Etymon's Homepage

Thanks for the reply, dayve!

Ok, so if I don't have that setup, but instead, I have PWS on Win98 ... if I install this 1) will it crash my forum while on my PC at home, 2) even if it crashes at home, it should work ok online, right?

Thanks again,

Etymon


Are you looking for answers at Snitz? | Searching the forums is easiest!
Basic | Advanced (Internet Explorer only)
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 05 August 2002 :  19:13:17  Show Profile  Visit dayve's Homepage
this will only work on IIS5. It does not work on IIS4 nor PWS.

http://www.nineinchnailz.com

Snitz Exchange | Snitz Icons | Do's and Dont's
Go to Top of Page

Etymon
Advanced Member

United States
2385 Posts

Posted - 05 August 2002 :  19:58:12  Show Profile  Visit Etymon's Homepage

Ah, ok, thanks!

I appreciate the help.

Etymon


Are you looking for answers at Snitz? | Searching the forums is easiest!
Basic | Advanced (Internet Explorer only)
Go to Top of Page

Gato
New Member

Brazil
92 Posts

Posted - 05 August 2002 :  20:08:24  Show Profile  Visit Gato's Homepage
Do you know how to reset the hit counter???

Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 05 August 2002 :  20:56:39  Show Profile
quote:

Do you know how to reset the hit counter???




MyPageCounter.Reset("/DIRECTORYNAME/PAGENAME.asp")


www.forumSquare.com - Rakesh Jain - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.24 seconds. Powered By: Snitz Forums 2000 Version 3.4.07