CNStats logo
What is CNStats
Download
Pricing and ordering
View demo
Support



Download Now

You can download and run a full working version of CNStats, free of charge, using a trial registration key. The trial key differs from the commercial one only in a limited usage period. At the end of the trial period you can purchase a key and continue using CNStats without data loss.
CNStats Box  
CNStats PRO 3.2
CNStats STD 3.2


Related links
Presentation
Our Awards
Screenshots

home contacts demo

Counter appearance modification

Requirements: CNStats 2.7 and later; GD 1.0 and later.

During CNStats installation you are offered two types of a code for allocation at the site ("Configuration - Counter type" section):

  • Mandatory statistics code - the one that counts the visitors;
  • Optional counter code - it creates a picture displaying the attendance data - graphical counter.

The counter appearance can be changed. Different variants of CNStats graphical counter are described in this article.

By default CNStats counter look as follows:

graphical counter CNStats

There are three figures: the uppermost denotes total pageviews, the middle one - pageviews for the current day, the lowermost - hosts for the current day. Further various means of counter appearance modification and ways of displaying other useful information will be considered.

At the end of the article you will be able to examine all the abovementioned counter types and to download them for usage.


Source data

CNStats is able to provide the following information for counter display:

  • Hits for the current day, for the previous day and total hits quantity;
  • Hosts for the current day, for the previous day and total hosts quantity;
  • Visitors for the current day, for the previous day and total visitors quantity;
  • Currently on-line.

Since CNStats can count robots, it's also possible to display these data:

  • Robots for the current day, for the previous day and total quantity;
  • Robots/users percentage.

Besides, you can make various graphical counters displaying attendance dynamics.


CNStats counters display

By default, the counter displaying script is located in CNStats root directory under the name cnts.php (abbr. Counter-Show). It is advisable to name your counter files likewise, for instance, cnts-big.php, cnts-ttf.php etc.

Let's begin with a certain standard template, which is mandatory for each CNStats counter code:

<?
error_reporting(E_ALL & ~E_NOTICE);

// Inserting the configuration file.
include "config.php";

// Creating images from the preset template.
$im=ImageCreateFromPng("button.png");

// Connecting to MySql server.
$CONN=@mysql_connect($STATS_CONF["sqlhost"],
                     $STATS_CONF["sqluser"],
                     $STATS_CONF["sqlpassword"]);
if (mysql_errno()==0) {

    // Selecting database
    @mysql_select_db($STATS_CONF["dbname"]);

    if (mysql_errno()==0) {
        // .. performing all necessary actions 
        // for image creation...       
        }
    }

// Sending HTTP header Content-Type
Header("Content-type: image/png");

// Generating images
ImagePng($im);

// Clearing the memory
ImageDestroy($im);
?>

Further this code will be inserted without comments.


Counter 1 - the standard one


counter 1 CNStats

The most significant part of the code is SQL query, which fetches the displayed data from the table:

SELECT t_hits,hits,hosts FROM cns_counter

The following features can also be fetched from CNStats tables without overloading the server:

SELECT hits, hosts, users,
       t_hits, t_hosts, t_users,
       u_hits, u_hosts,
       u_t_hits, u_t_hosts
FROM cns_counter;

Herein:

  • hits - hits for the current day
  • hosts - hosts for the current day
  • users - users for the current day
  • t_hits - total hits
  • t_hosts - total hosts
  • t_users - total users
  • u_hits - users hits for the current day (robots excluded)
  • u_hosts - users hosts for the current day (robots excluded)
  • u_t_hits - total users hits (robots excluded)
  • u_t_hosts - total users hosts (robots excluded)
  • u_hits-hits - robots hits for the current day
  • u_hosts-hosts - robots hosts for the current day
  • u_t_hits-t_hits - total robots hits
  • u_t_hosts-t_hosts - total robots hosts

Note! Robots are considered only with "PHP-Include" and "Combined" counters.

Below is the query received by "currently on-line" users (conventionally):

SELECT count(DISTINCT hid) as online
   FROM cns_log
   WHERE date>NOW() - INTERVAL 3 MINUTE;

Counter 2 - total hits, hits for the current day, users for the current day and currently on-line


counter 2 CNStats счетчик CNStats

As it can be seen from the counter display, another basic image has been used here to put in "Currently on-line" data (marked by red colour)

Counter 3 - True-Type fonts usage for counter generation


counter 3 CNStats

Unfortunately, TrueType fonts are not supported at some servers, therefore this counter is not included into the distribution kit.

There are hits, hosts and users for the current day displayed at this counter (for a change).

Counter 4 - total hits, hits for the current day, users for the current day, robots percentage


counter 4 CNStats

The counter appearance will be changed slightly: shadows will be added; figures will be made more readable by means of indents.

Counter 5 - all included


counter 5 CNStats counter 5 CNStats

The counter presents itself amount of all the previous.

Download

ExampleReferenceSystem requirements
counter 1 CNStats Download GD, PNG support
counter 2 CNStats Download GD, PNG support
counter 3 CNStats Download GD 2.0+, PNG support, TrueType support
counter 4 CNStats Download GD 2.0+, PNG support, TrueType support
counter 5 CNStats Download GD 2.0+, PNG support, TrueType support

In case you have any difficulties or would like to suggest something, please, e-mail us. We are ready to answer all your questions.




What is CNStats Download Now Pricing & Ordering View Demo Support

home contacts demo

© 2002-2008 "CN-Software" Ltd. All rights reserved.