Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

TotalCounter-Talk

Summary: Talk page for TotalCounter recipe

Comments

General Comments

Preventing Admin pageviews from getting counted

i haven't seen anyone mention how to prevent TotalCounter from logging when the admin views a page (when i edit and clean up the site, it causes the pagecounts to skyrocket artificially). i noticed that $TotalCounterBlacklist['Users'] = array('Admin'); or $TotalCounterBlacklist['Users'] = array('0'); don't seem to work, because i'm not using usernames / AuthUser, just passwords. here's the workaround that i figured out to prevent my admin edits from getting logged:

     ### place the following in config.php to prevent totalcounter from logging admin pageviews ###
     ## logic: turn totalcounter OFF if admin is viewing, unless admin is using the totalcounter action ##
     if ( ( CondAuth($pagename,'admin')  &&  $action=="totalcounter" ) ||  !CondAuth($pagename,'admin') ) { 
	     include_once('cookbook/totalcounter_1_9_1.php');
     }

seem to work right. i wonder though if there's a better solution for this within the code itself, a way to add certain auth's to totalcount blacklist?
overtones99 July 18, 2008, at 08:52 PM

. . .

totalcounter vars not working as expected

hi there
totalcounter's variables {$PageCount} and {$PageView} aren't working for me as i expect them to. i'm wondering what's up... i didn't see any mention of similar issues on the Talk page... here's what's up:

on a page, ALL of these end up spitting out the same exact value -- for the present page:
thispageCount: {$PageCount}
thispageViews: {$PageViews}

FAQ: {Main.FAQ$PageCount} - same thispage
IndexCount: {Main.Index$PageCount} - same as thispage
IndexViews: {UDP.Index$PageViews} - same as thispage

and actually, this is only after changing the following in the totalcounter.php:
//Markup('{$PageCount}', '<{$var}', '/\\{\\$PageCount\\}/e', $PageCount);
$FmtPV['$PageCount'] = "'$PageCount'";

otherwise, {Main.FAQ$PageCount} & {Main.Index$PageCount} don't print out anything...

anyone else have these issues, or a way to work around them? the idea is to be able to access the current count of pages that you're not currently viewing.
thanks!
overtones99 July 17, 2008, at 08:45 PM


  • Problem with GeoIP: All files are in the right place and all variables are set to your best knowledge but TotalCounter is still not able to get the correct GeoIP information? Check if you have the correct capitalization of the Variable $TotalCounterEnableGeoIP in your config.php. Why do I mention that? Because I just copied the variable name from this Wiki Page and there, the capitalization was wrong.

version 1.9


April 10th 2008

Hi, I'm using the lates pmwiki version and the 1.9.1 TotalCounter version but the "Most Visited Pages" string doesn't work.
(:pagelist group=GroupName count=10 fmt=#description order=$PageViews:)
Does the {$PopularPagesItems} markup work or can you tell me the right string to show the 'most visited pages' correctly? Thanks in advance


I've just downloaded and installed the recipe[1].
Its just what I want, but some feedback and questions.

  • the file created is named totalcounter.stat, rather than what is documented.
In 1.9.1 you can have your file named again as .totalcounter.stat if you set $TotalCounterFile= "$WorkDir/.totalcounter.stat". I didn't change the default value as I didn't want to surprise people too much. - MateuszCzaplinski
  • the default $TotalCounterAuthLevel prompted me for my admin password, rather than read as documented
  • would it be possible to provide a directive as well as a page action for total counter, so it can be embedded in a page?
If the directive provided a way of selecting singe report sections the page could be laid out as required
  • When I look at the report[2] I observe the following
    • the 'Last Years' report starts in 1979, how do I make this start in 2008?
      • I hide any 'Last *' bars with zero hits:
        1. Add the line if ($count == 0) continue; before line #1076 (in totalcounter_1_9.php).
        2. Also I changed the line #1057 to '"<div class=\"TCprogress\" style=\"$direction:".Round(1+200*(($maxcount)? $count/$maxcount:0))."px;\"></div>"', because I got "division by zero" errors. /Aidin
        No longer lines #1076 and #1057, but #1084 and #1066 respectively (in version 1.9.1). I think the if ($count == 0) continue; line should follow $count = $TotalCounter[$n][$nr]; (at least that works for me) JamesM April 12, 2008, at 06:03 PM
    • It would be useful if the 'Last Day' report heading had '(hours)' added to it
    • some CSS hooks so I could shrink the report font size
  • how can I disable, or omit, sections of the report, eg Users or Referrers?

Oh, I'm sorry, I didn't notice these comments when writing version 1.9.1. I'll try to include them in future, unless someone does that earlier. - MateuszCzaplinski

thanks Simon

PS after running for some time on one site [3] I now get the error

Maximum execution time of 30 seconds exceeded in /home/ttc/public_html/pmwiki/cookbook/totalcounter.php on line 1136

any ideas?

note this took down the whole site, since it is counting each page. Therefore don't install if you are worried about your site disappearing.

PPS just had this message, although TotalCounter has been running for some time it suddenly fails, note the directory exists, but there is no file

Warning: filemtime(): Stat failed for wiki.d/totalcounter.stat.l (errno=2 - No such file or directory) in /home/ttc/public_html/pmwiki/cookbook/totalcounter.php on line 1187

version 1.8+

  • After a while of flawless working, my counter V1.8 restarted counting. Can I get the old information back? The site in question :http://wiki.fali.nl/index.php/?action=totalcounter (it was around 35000 visitors :( ) Lighans
  • I would like to show the 'most popular pages' in the homepage but this (awesome) script doesn't yet support it. It wuold be great to show some stats in the homepage. Is this script going to be updated soon? Thanks in advance.
  • I just want to raise awareness that there is a potential for completely locking out a site that runs this recipe up to version 1.9 included. The issue and a potential fix are discussed here http://permalink.gmane.org/gmane.comp.web.wiki.pmwiki.user/46857 SteP November 04, 2007, at 03:13 AM
    • I can't read the page which is mentioned on the mailing list at this moment; but that's what I think should be done as for now: the potentially forever for-loop should be elliminated, and the file reading+writing part should be skipped if the lock could not be acquired. When you think about it, losing some visitors trace isn't so bad as having the site locked out. Moreover, there should be some code checking if the lock isn't quite old, and unlocking it should that happen. -- MateuszCzaplinski
  • Nice script! Since a week or so my totalcounter URL doesn't do anything. When browsing to http: <ip> / wiki/pmwiki/pmwiki.php/Main/Index?action=totalcounter I get the normal page, nothing else. No statistics. Just the same page as before but with a different URL. One thing that has changed is that I implemented clean URL's on my (IIS6) pmwiki. Any ideas? DJ (Aug-13-2007) --> Update: In the config.php include command I replaced the single-quotes like ' with double quotes like ". Now it works.
  • Somehow I have a user "0" in my statistic (Picture at the left) which is not listed in AuthUser. What does this mean? I was not able to find out when the counter for that user is increased.-- Matthias? June 08, 2007, at 11:12 AM
    • I have the same problem, any solution?-- Julien? June 20, 2007, at 1:05PM
    • I do have the same. Browsing through sources of pmwiki doesn't make clear for me what's the source of this value. My idea would be to try and change line 186 in TC 1.8a (213 in TC 1.9) from $tc_user = $_SESSION['authid'][0]; to $tc_user = @end($_SESSION['authid']); (the latter syntax is used somewhere in pmwiki.php). But I'm not sure enough to put it straight into TC source. MateuszCzaplinski October 02, 2007, at 07:56 AM
    • I have just set up a new wiki and the only person who knows about it is me. I also get a 0 in totalcounter, it might refer to when I am logged on as admin or editor. JamesM April 12, 2008, at 05:55 PM
  • It would be nice if the version information in the script was corrected so the RecipeCheck script could report correctly. IchBin June 06, 2007, at 03:21 PM
    • Should be OK as for TotalCounter 1.9 MateuszCzaplinski October 02, 2007, at 07:58 AM
  • Two ideas:
    • An option to exclude the top-scoring page would be nice. I get 4000 hits per day on the main portal page, and 300 on the second-ranking page, so all page counter bars except the one for the main portal page are just a few pixels wide. (I imagine that might affect most Wikis with hundreds or thousands of pages - the visitors just "fan out" from the portal.)
    • It might be useful to have an action like ?action=totalcountergroup that displays the statistics for the current group only so that authors of that group could have a de-cluttered perspective on exactly those pages they are responsible for.
  • Just my thoughts in case you`re looking for ways to put another layer of icing on the cake ;-) --Henning June 05, 2007, at 10:11 AM
  • How do I know that the GeoIP database is found and lookup is working ok? The lookups with $TotalCounterEnableLookup = 0;

$TotalCounterEnableGEOIP = 1; $TotalCounterGEOIP = "GeoIP.dat"; give ŽunknownŽ as a result for locations. When I enable Lookup the result is ŽnlŽ. Any help/idea?

Make sure you have the GeoIP.dat file in your wiki.d directory. Also, make sure you are downloading the Country version of GeoIP.dat, as they also have a city location version as well. - Dave Carver
I had this issue as well, I have the country version of geoip.dat and it was in wiki.d, eventually the only way I solved it was to include absolute paths in the "include('geoip/geoip.inc');" statement, and in the $geoIpFile variable. Also for some reason, posting the $_SERVER['REMOTE_ADDR'] directly to the 'geoip_country_code_by_addr' function came up blank every time in tests, yet when I assigned it to a variable first (i.e.: $myvar = $_SERVER['REMOTE_ADDR']), and then gave $myvar to the geoip function, it worked. I'll debug some more later, and post if I come up with anything. - Tyler, 27/05/2007
  • I'm having a problem moving from tototalcounter version 1.5 to 1.8a. When I startup the newer version I lose all of my current counts that I have collected. All the counters are reset to 0. How do I maintain all of my old counts with the 1.8a version.
  • My copy of totalcounter is asking for a password. I am accessing it from a page which is password-protected to edit but not to read. Adding ?action=totalcounter requires a password to see the statistics. The site-wide admin password works but I don't want to give that to anyone. Could you give me a clue here, or document the authorization levels more?
    • Thanks! JMH, 3-7-07
    • In totalcounter.php, just change SDV($TotalCounterAuthLevel, 'admin'); to SDV($TotalCounterAuthLevel, 'read'); ~Mierk, May 11, 2007
It's not necessary (and also not advised) to change the totalcounter.php script. Just add $TotalCounterAuthLevel='read'; in the /local/config.php before including the TotalCounter recipe. It is also in the documentation.

Blues May 11, 2007, at 05:19 AM

  • Hello, is it possible to somehow modify TotalCounter to show the IP-Adresses instead of the User-Names? We are using PMWiki as a groupware without authentication, but still would like to have some statistics about who is mainly using it. Thanks a lot! ~Mierk, May 9, 2007

old comments (version < 1.8)

  • I'm having problems using it with windows. I use pmwiki-2.1.beta2 and Apache/2.0.55 (Win32) PHP/5.1.2. The error msg - Parse error: syntax error, unexpected T_STRING in C:\www\local\cookbook\totalcounter.php on line 449 .
  • Is it possible/safe to edit .total.counter to remove totalcounter entries?
    Yes, it is possible. The file format, though, is quite tricky and may not be straightforward. I added above a note about it.

Blues February 08, 2006, at 08:58 AM

  • Wildcard for excluding file types not wanted in the totalcounter display.
Put this in totalcounter.php:
$TotalCounterBlacklist[Pages] = array('/.*.png/','/.*.ico/');
Stops *.png and *.ico. Same idea should work for *.css., *.jpg, etc.

DaveG February 8 2005

  • I want the page views not to be counted when it is a bot visit. But the wildcard does not work - Pageviews are still counted:
$TotalCounterBlacklist['Bots'] = array('/.+/');

uudo May 08, 2006, at 03:58 AM

  • I have no clue why I get the warnings below on top of every page I browse on my site when I am logged in!? I am using Authuser. I'd appreciate your help very much!
Warning: Illegal offset type in <my local root>/cookbook/totalcounter.php on line 279
Warning: Cannot modify header information - headers already sent by
(output started at <my local root>/cookbook/totalcounter.php:279)
in <my local root>/pmwiki.php on line 804

VolkerM 2006-02-19

Maybe new version (1.4b) will work?

Blues February 20, 2006, at 10:26 AM

Sorry, but unfortunately not. Now there is just the following error message now:
Parse error: syntax error, unexpected T_STRING
in <my local root>/cookbook/totalcounter.php on line 449
Strange enough I can not find any 'T_STRING' in the code, but I've to admit that I am not an experienced PHP programmer at all. ;-)

VolkerM 2006-02-20

How about now?

Blues February 21, 2006, at 03:19 AM

No, sorry, now I get a similar error messages as before on top of every page when being logged in (using AuthUser):
Warning: Illegal offset type in <my local root>/cookbook/totalcounter.php on line 283
Warning: Cannot modify header information - headers already sent by (output started
at <my local root>/cookbook/totalcounter.php:283)
in <my local root>/pmwiki.php on line 804
VolkerM 2006-02-21
Do I have to uninstall TotalCounter then? Would be a real pity, but the error messages are too annoying. :(

VolkerM 2006-02-27

If you haven't done it already, try adding include_once('scripts/authuser.php'); before including the TotalCounter recipe.

Blues February 27, 2006, at 09:38 AM

It has already been defined as you suggested. (I had tried to change the order of these definitions several times recently.) What I did now is to replace the authuser.php file by the very original from the installation archive. (I did that with pmwiki.php and others as well without being aware having modified them at any time in my running installation, but nevertheless...) The result is one single error message remaining right now on every page when a user with 'edit' authorization is logged in
Warning: Illegal offset type in <my local root>/cookbook/totalcounter.php on line 283
What can I do about that one?

VolkerM 2006-02-28

Usually I use UserAuth, so I tried a new installation of PmWiki using AuthUser and I don't get this error. Anybody else using AuthUser experiencing the same problem?

Blues March 02, 2006, at 08:07 AM

I did some more investigations and found the following:
$tc_user becomes an array when a authenticated user logs in.
According to the PHP description, an array can not be an index of an array, but it is the case in line 302.
Obviously this results in
Warning: Illegal offset type in <my local root>/cookbook/totalcounter.php on line 302
When adopting your example config
$TotalCounterBlacklist['Users'] = array('VolkerM','/^Author.*/');
additionally to the above the message
Warning: preg_match() expects parameter 2 to be string, array given
in <my local root>/cookbook/totalcounter.php on line 299
is displayed claiming that $tc_user is not a string. Maybe this helps?
Is it a PHP version (4.4.1 here) incompatibility issue? Has the data type control in PHP become more strict lately?

VolkerM 2006-03-09

I fixed the problem myself.
You'll find that my guess that there is a data type mismatch was right.
Therefore I corrected line 138 in totalcounter.php (version 1.5) to:
$tc_user = $_SESSION['authid'][0];
Now $tc_user is no longer been assigned an array (causing the error condition mentioned above) when an authenticated user logs in. Strange enough that noone else ran into this problem...!?

VolkerM 2006-03-09

  • I would love to use this, but I get this error:
Fatal error: Call to undefined function ResolvePageName() in C:\PHPdev\xampp\htdocs\bpt\cookbook\totalcounter.php on line 106
Update your PmWiki installation to the newest version (I don't remember exactly in which version the function was introduced).

Blues February 28, 2006, at 03:05 AM

  • Is there any way to prevent certain IP addresses from being logged? As the admin I frequently reload pages, edit, etc, and I don't want my messing around to artificially increase the page count view.

DaveG March 1, 2006, at 23:32 PM

Actually is not possible. If a specifc user (or location, or referer) is blacklisted, it will not be logged in the respective section, page views are not affected. I will think about it.

Blues March 02, 2006, at 04:02 AM

i figured out an easy way to prevent admin pageviews from being logged by simply not including the totalcounter script when the admin is viewing pages (with the one exception of when you're using action=totalcounter). see my comment above. overtones99 July 18, 2008, at 08:53 PM
  • Whilst I'm here, how about a few extra reports using the count data? Top x pages per group; page count for a specific page (so you don't increase the count by looking at the page); page coutns for 'favorite' pages, etc.

DaveG March 3, 2006, at 20:53 PM

The page count for a specific page can be retrieved using the new version (1.5). A new page variable is available, {$PageViews}, which can be used as a normal page variable. For example {MyPage$PageViews} gives the page views of the page MyPage.

Blues March 07, 2006, at 04:21 AM

  • Hi! Thanks for the great recipe. I seem to have the same server timeout problem mentioned in the archive. Looking more closely, I figured out that both .total.counter files are created in wiki.d/ with no write permission. Once this is corrected, I still have the same problem! Any ideas? I should mention that I am running it on a WikiFarm and am using PublishPDF recipe.
So I found the problem myself! I have PhP 4.2.2 on the server which doesn't have file_get_contents() and it just hangs after the first run! There is a workaround documented here.

Arshia Match 3, 2006

Thanks for pointing out the problem. Fixed in the new version (1.5).

Blues March 07, 2006, at 04:21 AM

  • It would be also nice to have an option showing the information of the (configurable) 10 last visits (IP Address, referer etc.)

Arshia Match 08, 2006.

  • Not really a major problem, but shouldn't line 123 of totalcounter.phpΔ be $tc_pagename=''; (single =)

Chris Morison? March 08, 2006, at 02:32 PM

Oh yes! You are correct! How that slipped there? Must be a copy-paste mistake :-) Thanks for finding it, and sorry for it. New version.

Blues March 09, 2006, at 03:01 AM

No problem. By the way, since you introduced the use of ResolvePageName in v1.4 - 31.01.2006, TotalCounter is no longer compatible with PmWiki versions before 2.1.beta21 - it counts every page as the default page. I'm still using 2.0.10, and until I get around to upgrading I have fixed this by replacing line 123 with $tc_pagename=str_replace('/','.',$pagename);. Great recipie though, thanks very much!
Also, if you're interested, I have hacked TotalCounter to ignore hits from various Editors of one of my sites even when not logged in by using a cookie. I did this by changing line 127 from:
if ($action=='browse') {
to:
$tc_ignore_cookie=$CookiePrefix.'_totalcounter_ignore';
if ($action==$TotalCounterAction.'_setcookie') {
setcookie($tc_ignore_cookie,'true',mktime(0,0,0,12,31,2037),'/');
}
$tc_cookie_set=(isset($_COOKIE[$tc_ignore_cookie]) && $_COOKIE[$tc_ignore_cookie]=='true');
if ($action=='browse' && !$tc_cookie_set) {
and line 277 from:
if (($action=='browse') && ($tc_pagename!='')) {
to:
if (($action=='browse') && ($tc_pagename!='') && !$tc_cookie_set) {
then any user that doesn't want their hits to be counted should visit a page with ?action=totalcounter_setcookie
I have also added code (using PHP Sessions) to only count visitors' first visit to each page and to only count their browser, Operating System, referer and location once per session. Search this file for 'Morison' to see my changes.

Chris Morison? March 09, 2006, at 03:41 AM


I have a few suggestion and made a totalcounter.php version with them see this script: a daily page counter, a short input field to set the $TotalCounterMaxItems. Changes I made have a ## comment. Maybe the script maintainer can review them. - Schlaefer March 09, 2006, at 07:07 AM


I propose a new browserstring (must be set before MS IE string):

 elseif (eregi('blazer',$_SERVER['HTTP_USER_AGENT'])) $tc_browser='Blazer';

The string for PalmOS should be changed from

 elseif (eregi('palmos',$_SERVER['HTTP_USER_AGENT'])) $tc_os='PalmOS';

to

 elseif (eregi('palm',$_SERVER['HTTP_USER_AGENT'])) $tc_os='PalmOS'; 

because newer devices identify as "PalmSource" or just "Palm"

Schlaefer March 10, 2006, at 10:21 AM


I propose a new browserstring

 elseif (eregi('arachne',$_SERVER['HTTP_USER_AGENT'])) $tc_browser='Arachne GPL';

New os-string:

 elseif (eregi('DOS',$_SERVER['HTTP_USER_AGENT'])) $tc_os='DOS';

Bug?

Sometimes the log-file seems to be destroyed or deleted, because it starts from "0".

Have the same problem too. But before fixing that we should bring the recent suggestions into the code. Is there a official maintainer for this recipe? - Schlaefer March 12, 2006, at 02:59 AM
I am the mantainer, I will include the suggestions into the code and release a new version.

Blues March 16, 2006, at 06:20 AM

Bug seems to be existing in version 1.6 too. Counters are reset at eastern on my page. - Micha April 19, 2006, at 02:11 AM
I've the same problem. It works some days and then it starts with 0. Looks like a automatic reset after some days, fist i thoght, it's a feature, ;-) would it be helpfull to send someone the .total.counter-file? CG, May 10, 2006

I am logged in, and set the variables, so that I shouldn't be counted. But...in increase...

Also a "user"-counter, not page-counter, would be good.

Many ideas :-)

flox March 10, 2006
<<<<<<<

Bug?

unofficial 1.6: Loggedin users sometimes not counted...maybe a cookie-problem?

flox April 10, 2006, at 09:53 AM

=======

Bug?

unofficial 1.6: Loggedin users sometimes not counted...maybe a cookie-problem?

flox April 10, 2006, at 09:48 AM

=======

Bug

I just found a small bug in V1.7 in line 746. The problem appears only if $TotalCounterAction is different to totalcounter. I cannot say whether this bug appears also in 1.6 (not checked).

see (:input form "$PageUrl?action=totalcounter" post:).

I have changed this section to (:input form "$PageUrl?action=$TotalCounterAction" post:).

That's all. Please modify this line for future versions. ;-)

Holger August 12, 2006, at 03:39 PM

>>>>>>>

Counter Reset?!

My Totalcounter (1.5) just got reseted tonight out of the blue! Do you have any idea why?!

Arshia May 23, 2006.

  • The resetting of the Counter file seems to happen when a user Aborts a page load. To avoid this, you may need to add a ignore_user_abort(true) call to the script, so that processing may continue in spite of a user abort of a page. This should be fixed in unofficial 1.8.

---KingArgyle, December 11, 2006.

Feature Idea - Google Search Terms

I have seen once a page, which has shown 'last google search that led to this page'. I suppose it was retrieved from the Referrer info, and it might be interesting if some kind of such statistics were added here.

TotalCounter and SimplePageCounter?

"$PageCount is the same that is used by the SimplePageCounter, so an upgrade to TotalCounter is possible without changing the markup (but will lose old counts). This also means that the two recipes cannot be used together (why to do it anyway?)."

I'd like to try TotalCounter with its vastly improved capabilities, but I have SimplePageCounter running and would not like to shut down the tried counter immediately, or lose the counts recorded so far. If I could run them in parallel, I'd be very happy. Maybe my question is naive, but is there a way to make the recipes non-exclusive by simply renaming a variable or something? --Henning August 30, 2006, at 07:34 AM

Most Visited Pages

Hi, I'm using your recipe, and I love it. But I've been trying to add a list of the most visited pages on the main page on my website. I added this line:

(:pagelist group=-PmWiki,-Category name=-Template,-GroupFooter count=10 fmt=#description order=PageViews:)

But It doesn't do the trick. Tried with and with "", {} and with the -. Could you tell me the correct syntax for this?

Try the dollar sign: order=$PageViews - should work. MateuszCzaplinski October 02, 2007, at 08:08 AM

~Moroni Granja
November 22, 2006, at 04:34 PM

Edit - History - Print - Recent Changes - Search
Page last modified on August 15, 2008, at 08:40 PM