CNStats 4.2 User Manual
Update from CNStats v4.1 to CNStats v4.2
There are two major changes in CNStats v4.2, that can make the process of upgrading from the older versions more complicated. The update from v4.1 to v4.2 differs from the standard update procedure.
Location of Geographical Databases Changed
In version 4.2, support of two new geographical databases IP2Location and CNGeoIP5 was added to the already existing one of CNGeoIP, MaxMind GeoIP and MaxMind GeoIPCity. There are five supported geographical databases now, that is why they are located in a separate directory now at ./cnstats/geo/.
It is strongly recommended to make a backup copy of the available geographical databases before updating CNStats. Install CNStats according to these instructions and place the geographical database back to the new directory.
CNStats and Database Encoding Changed
Beginning with version 4.2, CNStats works in UTF-8 encoding. Other encodings are not officially supported, although they are not forbidden. In case your site supports other encoding, that is not critical, since these are different applications interacting via addressing to the counter, where any encoding is supported.
The encoding change may affect the update process. When switching to UTF-8, some algorithms have changed cardinally as well. Moreover, the correct update depends on configuration of PHP and MySql server.
In the worst case scenario, when all data that depends on encoding is lost, you can lose pages titles, filters names and cities names. All the other statistics does not depend on encodings and will be safe even in case of incorrect update.
Cities names can be fully restored using Configuration – Geographical Database – Regenerate (if geographical database is enabled). In case after you regenerated information about cities and countries, new cities still appear in wrong encoding, wait until 00.00 a.m. Cities in wrong encoding can be retrieved from the cache. That is why it is recommended to regenerate information about cities and countries the next day after update.
Updating CNStats 4.1 to CNStats 4.2
- Make a backup copy of the files (just copy CNStats files into the backup folder);
- Make a backup copy of the database (for example, using mysqldump);
- Disable CNStats using $STATS_CONF["disabled"]="yes"; option in config.php file;
This option is new in version 4.2. Earlier CNStats versions will ignore it. It will launch after you copy the files from the new version distribution kit and place them instead of old ones. If you do not enable this option, the error messages can appear on the web-site (in case you use code for PHP sites).
- Delete all CNStats files except config.php, cnt*.php
I you delete config.php file, then you will not be able to start update process. This file stores information which database contains previous version for the installer. cnt*.php files contain counter code and are enabled from the web-sites. If you delete these files, you will evidently get error messages on the web-site.
- Copy new files instead of old ones;
- Log in CNStats interface. The installer will launch. Follow the installation instructions up to the successful completion of the installation process;
- Check the $STATS_CONF["sqlinstructions"] option. If it exists and contains instructions with strict specification of the encoding, then you should delete these options:
For example, the following strings should be deleted:
$STATS_CONF["sqlinstructions"]="SET NAMES cp1251";
$STATS_CONF["sqlinstructions"]="SET CHARACTER SET cp1251";
- Delete the installer (./install directory);
- Log in CNStats interface, enter new license key. You can get free trial key at official site, and the commercial license key – at members area;
- Enable CNStats by deleting $STATS_CONF["disabled"]="yes"; option form the config.php file.