PHPCounter

5.1

brought to you by eKstreme.com

Document created 15 Jul 02. Last update 19 Aug 02.

Table of Contents

Introduction

Thank you for downloading PHPCounter 5.1!

PHPCounter is a PHP script that tracks the number of visitors to a website. It has several options, like tracking each page individually and creating a log file in the Common Log Format (CLF). You can view a full list of features below.

To use PHPCounter, you do not need a database. Everything is stored in text files, and you can view the tracking results in real time.

Features

As of version 5.1 of PHPCounter, the following features are implemented:

  1. Track any number of pages in any PHP-enabled website.
  2. Track each page individually.
  3. Track all of the pages using a single record page.
  4. Create a Common Log Format (CLF) file (can be analysed further).
  5. Tracking can be visible or invisible.
  6. Can ignore any number of IP addresses.
  7. Can ignore any number of remote hosts.
  8. Can ignore any number of user agents.
  9. Can ignore repeat hits from the same remote host within a definable time frame, so that you can ignore refreshes, and quick repeat visits.
  10. View results in real time. All of the results are stored in PHP files which you can browse using your web browser.
  11. All results are stored in text files. No databases needed.
  12. Simple installation.
  13. And much much more!

To see which of the features are the new ones, then take a look at the changelog.txt file.

You have to decide which of these features you want to use. Remember that the more features you use, the slower PHPCounter will be, and therefore, the slower your website will be. You have to test how much each feature affects the speed of loading for your pages.

The Common Log Format is a standard file format for Apache web servers that contains the tracking data. There are several programs that allow you to analyse this data further.

New Installation

If you are upgrading from an earlier version of PHPCounter, please read the section below.

NB: The following installation instructions are for version 5.1 of PHPCounter. They may seem long, but that is because they try to explain every step in great detail; the actual steps are simple :)

The installation is in two phases: Firstly you have to edit your files locally and then secondly, you have to upload them to your web space.

Once you have done the above, you have completed configuring PHPCounter. Now you need to upload it to your web space. To do that, create the directory that is your COUNTER directory as you decided earlier and upload all of the files there. Also create a directory within the COUNTER directory called 'locks' (no quotes). Once you have done that, you need to finish off by doing the following:

CHMOD is a function that allows you to change the permissions for a file or directory. Where this function is depends on the software, but usually it is in the right-click menu, or in a menu somewhere. You MUST change the permissions as stated or PHPCounter will not work!

Now you are done installing PHPCounter! To use it, see the Tracking Pages section below.

Upgrading from PHPCounter 4.0 or 4.1

If you are upgrading from an earlier version of PHPCounter, then you need to do is to only upload all of the new files of PHPCounter into the directory where the old PHPCounter resides. However, before you do that, do not forget to edit settings.php and phpcounter.php as is explained above. Also CHMOD the new locks directory to 777, and also if you over-wrote the old clf.log and all.php files, you need to CHMOD them to 777 too. All pages would now start using the new PHPCounter script.

Tracking Pages

To track a page, make sure it is a PHP page - i.e., your server recognises it as a PHP file. This is almost always done by changing the file extension to php.

Now you need to insert a single line of code that will get PHPCounter to track the webpage. The line is as follows:

require '/usr/bloggs/html/counter/phpcounter.php';

That is, you set the FULL PATH to phpcounter.php, which is in the COUNTER directory.

Note that you have to put this line within the PHP code delimiters, which are <?php and ?>. So you may have to add the following code:

<?php
require '/usr/bloggs/html/counter/phpcounter.php';
?>

Also note that, you can put this line of code anywhere you want the counter to be. If the counter is invisible, this does not matter much, but if the counter is visible, then place this code where you want the counter to show up on the page.

Results

To view the records of the hits for the website, point your browser to your COUNTER directory. So, if your COUNTER directory is '/usr/bloggs/html/counter/' and your website is eKstreme.com, then point your browser to http://ekstreme.com/counter/. You will get a nicely-formatted list.

Note: The tracking files will become VERY large with time; quickly if you have a popular site! You as the webmaster will need to maintain the tracking files. If the files get too large then your website will seem to stop working, timing out constantly. At which size this happens is variable, but if one of your log files if about 1MB in size, then you need to start thinking about cleaning up. To do this, you download all the hits files (they are an important record after all!), and then upload a fresh all.php and clf.log files. This will re-set the counter to 0.

Troubleshooting

If after following the instructions PHPCounter still does not work, then please read the latest version of the PHPCounter FAQ found on eKstreme.com. If it is still broken, then please contact me using this form.

Contacting Me

If you have any suggestions, tips, ideas, questions or comments relating to PHPCounter, then please don't hesitate to contact me using this form. Suggestions from users are what drives the development of PHPCounter, so send them in! Thank you.

Licence And Disclaimer

PHPCounter is freeware for personal and non-commercial users. All other users please contact me with details.

Use PHPCounter at your own risk. I make no garantees or warrantees of any sort. Do not blame me for anything that goes wrong.

Thanks To...

Firstly, thanks to the users who use PHPCounter! Also thanks to all those who sent in suggestions and tips. Great thanks thanks go to the numerous beta testers who made PHPCounter much better than it would have been!