This version is a replacement of the old count_visitor class. There are lot of good systems like this class but most of them are really complex and difficult to modify. You have to use this kind of systems like provided. This class is not an alternative if you look for the same amount functions, but it's a light weight solution to integrate into your website.
This class requires a PHP enabled Apache (virtual) host. I tested this class with PHP 4.3 and MySQL 3.23 on Windows and Linux.
You can use this class with the php setting register_globals = off.
It's simple, place only a few rows of code in the top of a script and every (unique) visit is counted. Run the visitor_statistics file for all information about the counted visits.
Next all import
and variables are explained.
var $referer; (string)
holds the http referer information if exists. Variable is set by the class constructor
var $delay; (default =1, integer)
The amount of time in hours before a visitor is counted again. Use a value of 24 to count unique visitor only ones day.
Before a new visit is
registered, a check is done by this method. This function will search the database for records where the visitor with an ip-address has visited the site between the current time and the number of hours defined by $delay.
Before a new visit is written to a table, the class will search for the country with this method. This query is possible with the ip2nation tables from Per Gustafson, visit his home for later updates: http://www.ip2nation.com/
After the last visit check is done (and the boolean is true) the visit will be registered with this method. The class uses some server variables inside the query.
show_all_visits(), show_visits_today(), first_last_visit($type = "last")
are used to query the
for simple visit statistics, like all visits, all visits today and the last (first visit). You can use the result of these methods on your website. Examples
This method shows the top 10 visitors grouped by a country. Together with the method res_country_top() it's possible to create a quick view for this data.
With this method is it possible to show visitor data over a period of max 12 month. The
are all visits grouped by a month.
Use this method results as the daily visits. You can post the month and year to this method and you get a table with visit data.
This method is used in the most
reporting methods, the two parameters are used for the label (example: the day) and the value (example: visits a day). This method is only to use with other methods.
There is a lot coding work to do, to make this class really powerful. I started with this script because in need my statistics a little different than in webalizer. That’s why these functions are more important to me: