Stats Tracker and Hit Counter
-------------------------------------------------
Author: Geoff A. Virgo <gvirgo@mithril.ca>
Release Date: Sept. 28, 2001
Application: Stats Tracker and Hit Counter
Licensing: Lesser Gnu Public License
-------------------------------------------------
This library is a set of classes which allow you to implement a hit counter and statistical tracking on your site. The administrator's browser(s) is identitifed by a cookie and is not counted in either hits or stats.
Features:
Hit Counter
- can be configured to increment on every page load, or only on the initial page load in a user session
Stats Tracking
- users are identified by an 11 digit number which is randomly generated and stored on the browser using a cookie
- stats for external navigation into your site records:
- the user's ip
- browser type
- date/time of first and last visits
- number of visits
- point of entry
- referring url
- search engine
- search query keywords
- external navigation stats can be viewed either in raw html or graphical (if your PHP installation has GD with PNG support) mode
- the graphs are created by month and stored on the server to reduce server load
- graphs for the current month are re-created for every request ensuring the most recent data is represented
- sample graphs can be viewed here
- internal navigation stores:
- the requested file
- the address within your site from which it was requested
- the date/time of the request
- the user's 11 digit identifier is not used for internal navigation tracking
Search Engines
- search engine referral stats displays:
- keywords used
- number of times that keyword combination was used
- last date/time the keyword combo was used
- a link to the search query on the referring engine allowing you to determine what other sites show up for the same search
- stats are broken down by search engine
- you can specify 2 query identifiers per engine to allow for more flexibility
- public statistic's displays:
- the current date/time on your server
- your server software, PHP, and MySQL version
- total number of hits
- rough percentages of browser usage (IE 4+, Netscape 4+, and other)
- admin browsers can be removed from both hit count and stats tracking to give more accurate results
- admin section allows for full manipulation of the app's behaviour and appearance (table and image colour schemes)
- default colour schemes for both tables and images can be overridden on a per script basis using the appropriate set() methods
- database records can be searched for new referring search engines, and common non-engine url's/ip's can be blocked from showing up in this search
- full API documentation (in the JavaDoc style) is included in the download package
Installation:
- Create a database and execute the sql query in the /database_schema folder
- Copy the files and folders in the /htdocs folder to somewhere in your web document tree (I'd recommend a password protected location)
- Copy all the files in the /includes folder to a location within your php_includes directory
- Edit the /includes/globalSettings.inc file to reflect your setup
- Edit the /htdocs/actions.php and /htdocs/stats.php file to reflect your setup
- Open /htdocs/admin.php and select the "Edit the stats application's settings" link to configure the stats tracker
- Click the "README - Stats Tracker" link and read the README for usage examples.
- If you're using an RDBMS other than MySQL, you may need to edit some of the sql queries used by this class
Usage:
Place the following code at the top of any page (above all whitescape and html output) which you want including in stats tracking:
require("database.inc");
require("globalSettings.inc");
require("stats.inc");
To simply track stats:
$statsObj = &new usageTrack();
$statsObj->updateHitCount();
$statsObj->updateStats();
To display stats:
$statsObj = &new viewStats();
// display publically accessible stats
$statsObj->displayPublicStats();
// display admin-only stats
$statsObj->displayStats($HTTP_GET_VARS["view"],$HTTP_GET_VARS["type"],$HTTP_GET_VARS["display"], $HTTP_GET_VARS["date"]);
Both table and graph colours can be overridden by calling a set method in your scripts. The appropriate methods are: setGraphColours() and setTableVisuals().
N.B. Depending on your PHP config, the "= &new" syntax may cause a parse error. If this is the case, use "= new" instead.
Database Abstraction Layer
-------------------------------------------------
Authors: Frank M. Kromann <frank@frontbase.com>
Geoff A. Virgo <gvirgo@mithril.ca>
Release Date: November 11, 2001
Application: Database Abstraction Layer
Licensing: Lesser Gnu Public License
-------------------------------------------------
This is a relatively simple database abstraction layer written originally by Frank M. Kromann <frank@frontbase.com> and modified by Geoff A. Virgo <gvirgo@mithril.ca>.
Features:
- Support for the following databases:
- FrontBase
- PostgreSQL
- Microsoft SQL Server
- MySQL
- all databases supported by PHP's Unified ODBC Functions
- Adabas D
- IBM DB2
- iODBC
- Solid
- Sybase SQL Anywhere
- MS Access
- Designed to provide a common interface for all supported db's
- Limited amount of sql debugging in the form of emails sent to a designated administrator account.
- Debugging emails are sent whenever a connection error, database selection error, or sql statement failure occurs. The email debugging requires that mail() support be properly installed on your system.
Installation:
1) Copy the database.inc and globalSettings.inc files from the distribution archive to your php_includes directory.
2) Edit the globalSettings.inc file to match your setup.
Usage:
Place the following code at the top of any page which needs database connectivity:
require("database.inc");
require("globalSettings.inc");
Method #1 - Native Access
$dataObj = &new cDatabases();
$dataObj->Set($defaultRDBMS);
$dataObj->Connect($defaultHost,$defaultUsername,$defaultPassword,$defaultDB);
Method #2 - Object Spawning
$databases = &new cDatabases();
$dataObj = $databases->Get($defaultRDBMS);
$dataObj->Connect($defaultHost,$defaultUsername,$defaultPassword,$defaultDB);
You can of course specify string values as arguments in the Set() and Connect() methods, this example merely uses the defaults you specified in the globalSettings.inc file. By creating multiple database objects with the Get() method, you have the ablity to easily connect one script to multiple databases severs and/or platforms if need be.
Once created, $dataObj has access to all the methods specified in the RDBMS interface classes (cFrontBase, cPostgreSQL, cMSSQL, cODBC, cMYSQL):
Connect();
Disconnect();
Query();
FetchRow();
NextResult();
NumRows();
FreeResult();
ColumnLength();
ColumnName();
ColumnType();
GetLastMessage();
For details on each of these methods, consult the appropriate section in this API Manual.