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 methods and variables are explained.
var $referer; (string) This variable 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.
check_last_visit() 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.
get_country() 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/
insert_new_visit() 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") These methods are used to query the database 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
stats_country() 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.
stats_totals() With this method is it possible to show visitor data over a period of max 12 month. The results are all visits grouped by a month.
stats_monthly($month, $year) 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.
build_rows_totals($array_labels, $array_values) 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: