|
Cookbook /
TotalCounterSummary: A statistic counter - counts page views, users, languages, browsers, operating systems, referers, locations and web bots
Version: 2010-02-08 - v1.9.2
Prerequisites:
Status:
Maintainer: Blues
Discussion: TotalCounter-Talk
Question(s)
AnswerDownload unofficial version: totalcounter_1_9_2.phpΔ (see changelog, old official version 1.5. is still available: totalcounter.phpΔ ). I found that migrating from the 1.5 version to 1.8a that I lost all of my prior total counts. I saw no mention nor documentation that the files where the counts are persisted to was renamed. I found that to retain the prior version total counts you can do one of two things:
Here are the file names for the different versions:
IchBin Profiles May 15, 2007, at 11:48 AM Hmm; shouldn't the file names still start with a dot (in future versions of TC)? currently, when searching all pages (?action=search&q=/), a non-existent page named 'totalcounter.stat' is displayed because of the lack of the dot. Optionally, the filenames could be set using some configuration variables. MateuszCzaplinski October 02, 2007, at 02:13 PM
It is a simplified statistics counter which counts a variety of informations such as page views, users browsing, languages used, browsers used by visitors, languages, operating systems used by visitors, referers from which the visitors come from, locations from where the visitors come from and web bots that index the pages. It does not log single visits but just keeps the total count. NotesWARNING - i've discovered that as the totalcounter.stat file fills up, when it nears around 1MB in size, all of a sudden totalcounter stops working, and you get error msgs on your site. i think a function within it is timing-out or something. in addition, it becomes impossible to edit your totalcounter.stat file at this point b/c it's owned by 'nobody', and so trying to edit it as some other 'user' is impossible, as you don't have the right priviledges; plus, saving a new totalcounter.stat file is not an option unless you know to set $TotalCounterEnableChmods = 0, which when enabled, prevents totalcounter from writing to the totalcounter.stat file you created. kind of lame thing to discover 8 months into a medium-traffic site with hundreds of pages. am in the process of writing lots of Blacklists in order to prevent the cataloging of unnecessary pages, plus plan to write some blacklists to prevent the cataloging of other information that might be clogging the system - then cleaning out line-by-line from the old totalcounter.stat file. also - there seems to be no active maintenance of this recipe at the moment... beware : ( overtones99, 22 April 2009
and now, somehow the totalcounter.stat file has overwritten itself several times over, so that all counts have been reset so many times (without my noticing it) that it'd be pointless to retrieve a backed up copy from 6 months ago... : ( my advice: store pageviews on each page instead!! overtones99 December 22, 2009, at 06:07 AM SteP January 20, 2010, at 10:28 AM: I recall I had similar problems due to a locking issue. I know that version 1.9.1 fixed a locking issue, but I don't know if it's the same thing that I reported in (http://permalink.gmane.org/gmane.comp.web.)wiki.pmwiki.user/46857. The person who wrote the locking code posted a fix on his board, but the link is now dead. I had saved the code, so I upload it as chozo4-fix.phpΔ. I didn't test it; it needs to be studied and integrated in the latest recipe code, but I stopped using TotalCounter since version 1.8a.
InstallationDownload the script from above and place it in your cookbook directory. Then add include_once('cookbook/totalcounter.php'); in your local configuration (local/config.php).
Configuration:If you personalize $DefaultGroup and $DefaultName they must be set to the desired value before including the TotalCounter script (see notes below).
You may give a value to the following variables before including the script (e.g. $TotalCounterAuthLevel) to configure some aspects of the TotalCounter:
$TotalCounterAction can be used to change the action for the statistics page (default is 'totalcounter').ex. $TotalCounterAction = 'totalcounter';
$TotalCounterAuthLevel can be used to change the authorization level necessary to see the statistics page (default is 'admin').ex. $TotalCounterAuthLevel = 'read';
$TotalCounterMaxItems can be used to set the maximum items to be displayed under each section of the statistics page (default is 20).ex. $TotalCounterMaxItems = 10;
$TotalCounterEnableLookup can be used to enable the DNS lookup to retrieve the user's location in case the server doesn't do it automatically (default is 0, disabled). Please note that DNS lookup may be a time consuming task.ex. $TotalCounterEnableLookup = 1;
$TotalCounterBlacklist is an array (of arrays) that can be used to blacklist some items from being logged (the default blacklist is empty).
The available arrays are as follows:
$TotalCounterBlacklist['Pages'], $TotalCounterBlacklist['Users'],
$TotalCounterBlacklist['Browsers'], $TotalCounterBlacklist['OSes'],
$TotalCounterBlacklist['Referers'], $TotalCounterBlacklist['Locations'],
$TotalCounterBlacklist['Bots'], $TotalCounterBlacklist['Languages']
Regular expressions can be used for page names, users and referers, ex
$TotalCounterBlacklist['Pages'] = array('Main.HomePage','/^Site\..*/');
$TotalCounterBlacklist['Users'] = array('Admin','Paul','/^Author.*/');
$TotalCounterBlacklist['Referers'] = array('localhost');
$TotalCounterBlacklist['Locations'] = array('localhost');
$TotalCounterBarColor can be used to personalize the color of the bars in the statistics page. It is a string with the CSS syntax for color (default is '#5af').ex. $TotalCounterBarColor = '#000';$TotalCounterBarColor = '#3fca3f';
$TotalCounterShowNumbers is used to show or hide the numbers next to the items in the statistics page (default is 1, enabled).
New in 1.8: $TotalCounterDownloadManager is used to show all the download counts if you have the DownloadManager cookbook recipe installed. This contains the filename of your download manager stats file.
$TotalCounterGeoIP contains the filename for MaxMind's . This provides more accurate information on where visitors are located, and must be placed in the Wiki.d directory.
$TotalCounterEnableGeoIP set this to 1 to enable GEOIP database lookups, and set $TotalCounterEnableLookup to 0 so that the GEOIP is used, otherwise it defaults to normal behavior for trying to identify the country.
New in 1.9: $TotalCounterEnableChmods (default: 1). Set this to 0 if your server doesn't allow PHP chmod() function to be run.
(Please see here about integrating GoogleCharts http://pmichaud.com/pipermail/pmwiki-users/2008-January/048443.html (Division by zero if there isn't any visit to some page. Tested in version 1.5) Tasos Use:After the installation the variables {$TotalCount} and {$PageCount} can be used in the markup to display respectively the total pages visited and the current page views ($TotalCount and $PageCount can be used in a skin .tmpl file in PmWiki versions before 2.1).$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?).
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.
Can also be used in pagelist templates.
A new action can be used to display a statistics summary page, just add ?action=totalcounter to the url to see the statistics.
![]() i18n:The following strings are used and can be internationalized (i18n).
Notes:A single text file is saved in the wiki.d directory with the name .total.counter in which the informations are stored. Since the directory already has write permissions, no configuration is needed.
A page view is counted only when action=browse.
When $pagename is empty ('') the recipe counts a hit to the default page , so if you want to change them in your local configuration config.php file, they must be set to the desired value before including the totalcounter.php.
For users statistic count to work a user authentication recipe (UserAuth or AuthUser) must be installed.
For languages statistic count to work the MultiLanguage recipe must be installed.
The .total.counter file format is as follows:
Example:
a:2:{s:5:"Total";i:3406;s:5:"Pages";a:2:{s:13:"Main.HomePage";i:1412;s:9:"Main.Test";i:213;}}
Means:
array(
"Total"=>3406,
"Pages"=>array(
"Main.HomePage"=>1412,
"Main.Test"=>213
)
);
Examples:You can see the recipe live here, on the bottom left corner the page/total views are displayed (add ?action=totalcounter to the url to see the statistics page).
Releases
See Also
See the recipe live here, on the bottom left corner the page/total views are displayed (add What does the Count represent in the statistic Users Percent Count? Thanks for this wonderful recipe? Liz K? December 26, 2008, at 02:51 AM Contributors
User notes +4 -5: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |