';
return $display;
}
/*
* Main Function
*/
// we use this trick to keep the connection alive
$spaces = '';
for ($i = 0; $i < 250; $i++) {
$spaces .= '';
}
GUS_save_plugin_enable_states();
echo COM_siteHeader();
echo COM_startBlock($header, $readme_url);
echo "{$spaces} "; flush();
$action = isset($_POST['action']) ? COM_applyFilter($_POST['action']) : '';
switch ($action) {
case 'import_ignored':
if (GUS_import_ignored()) {
DB_query("UPDATE {$_TABLES['gus_vars']} SET value = '1' WHERE name = 'imported'");
}
break;
case 'import_user_agents':
if (GUS_import_user_agents()) {
DB_query("UPDATE {$_TABLES['gus_vars']} SET value = '2' WHERE name = 'imported'");
}
break;
case 'import_userstats':
if (GUS_import_userstats()) {
DB_query( "UPDATE {$_TABLES['gus_vars']} SET value = '3' WHERE name = 'imported'" );
}
break;
case 'import_update':
if (GUS_import_update()) {
DB_query( "UPDATE {$_TABLES['gus_vars']} SET value = '4' WHERE name = 'imported'" );
}
break;
}
// fetch the 'imported' var since it may have changed
$rec = DB_query("SELECT value FROM {$_TABLES['gus_vars']} WHERE name = 'imported'", 1);
$row = DB_fetchArray($rec, FALSE);
$_GUS_VARS['imported'] = $row['value'];
// finally, show the main part of the page
$display = "Importing your data from the stats plugin is a four-step process.
In the first step, all the IPs, pages, and users which are ignored are imported.
In the second step, the user agents are added to the new user agent table.
In the third step, the rest of the data is added to the the userstats table.
Finally, in the fourth step, the data is updated to the lastest version of GUS.
For each of these steps, I will disable the plugins and enable them again if they were enabled originally.
If you have a lot of data this may take a long time, so be patient.";
$db_url = $_CONF['site_admin_url'] . '/database.php';
$display .= "
'
. GUS_step(1, "Import ignored lists", "import_ignored")
. GUS_step(2, "Add data to the user agents table", "import_user_agents")
. GUS_step(3, "Import data from the userstats table", "import_userstats")
. GUS_step(4, "Update data to latest version of GUS", "import_update");
if ($_GUS_VARS['imported'] == 4) {
$display .= '
Congratulations! You have imported all your data into GUS.';
}
echo $display;
echo COM_endBlock();
echo COM_siteFooter(TRUE);
gus/admin/index.php 100777 0 0 60120 12130657727 7734 0 ';
$i = 0;
foreach ($data as $item) {
if ($i % $cols == 0) {
$table .= '
';
}
$table .= "
{$item}
";
$i++;
if ($i % $cols == 0) {
$table .= '
';
}
}
if ($i === 0) {
$table .= '
';
}
if ($i < $cols) {
$table .= '
';
}
$table .= '';
return $table;
}
// GUS_create_form
function GUS_create_form($name, $id) {
global $LANG_GUS_admin;
$form = '';
return $form;
}
// GUS_create_cleanup_form
function GUS_create_cleanup_form($count_data, $action, $id, $num_msg) {
global $LANG_GUS_admin;
$form = '
';
$titles['referrer'] = $LANG_GUS_admin['referrer_title'];
$counts = GUS_get_referrer_counts();
if ($counts['list_len']) {
$i_referrer .= GUS_create_cleanup_form($counts, 'clean_referrer', 15, $LANG_GUS_admin['referrer_num_referrer']);
$titles['referrer'] .= ' *';
$at_least_one_dirty = TRUE;
}
// show our tabbed Ignore pages
$display .= '';
// handle the case where the user has javascript disabled
$display .= '';
if ($at_least_one_dirty) {
$display .= '
' . $LANG_GUS_admin['star'] . '';
}
$display .= '
';
// let's clear out all the data!
$display .= "
{$LANG_GUS_admin['remove_data']}
"
. 'Click the \'' . $LANG_GUS_admin['remove_data'] . '\' button to clear out all the data in your GUS databases. '
. 'This will not affect your settings - only the data. '
. 'I will disable the plugin, perform the operation, and enable the plugin again. '
. '
' . $LANG_GUS_admin['irreversible']
. 'You will not get a silly "Are you sure you want to do this?" message.'
. "
";
// fetch the 'imported' var since it may have changed
$rec = DB_query("SELECT value FROM {$_TABLES['gus_vars']} WHERE name = 'imported' LIMIT 1", 1);
$row = DB_fetchArray($rec, FALSE);
$_GUS_VARS['imported'] = $row['value'];
// check for old stats to see if we should add an import link
if (GUS_checkStatsInstall() AND ($_ST_plugin_name != '') AND ($_GUS_VARS['imported'] < 3)) {
$import_url = $_CONF['site_admin_url'] . '/plugins/gus/import.php';
$stats_version = DB_getItem( $_TABLES['plugins'], 'pi_version', "pi_name = '{$_ST_plugin_name}'" );
$display .= "
{$LANG_GUS_admin['import_data']}
"
. "I notice you have the stats plugin version {$stats_version} installed as '{$_ST_plugin_name}'. ";
if ($stats_version !== '1.3') {
$display .= "
If you had version 1.3 installed, I could import its data.
If you update this in the future, you can import its data from
the admin page.";
} else {
$display .= "
You may import its data into GUS using the import page.";
}
}
$img_url = $_CONF['site_url'] . '/gus/images/' . $_GUS_IMG_small_name;
$header = ' ' . $LANG_GUS_admin['admin'] . ' [v' . plugin_chkVersion_gus() .']';
$readme_url = $_CONF['site_admin_url'] . '/plugins/gus/readme.html#config';
echo COM_siteHeader();
echo COM_startBlock($header, $readme_url);
echo $display;
echo COM_endBlock();
echo COM_siteFooter();
gus/admin/install.php 100777 0 0 23477 12130657727 10311 0 'GUS Admin',
'gus.view' => 'GUS Viewer',
);
/**
* Puts the datastructures for this plugin into the Geeklog database
*
*/
function plugin_install_gus() {
global $pi_version, $gl_version, $pi_url, $_FEATURE,
$_TABLES, $_CONF, $LANG_GUS00, $LANG_GUS_wo, $_GUS_VARS;
COM_errorLog('Installing the GUS plugin', 1);
// DB_setdebug( true );
// Create the Plugin Tables
GUS_createDatabaseStructures();
// Create the plugin admin security group
$group_id = DB_getItem($_TABLES['groups'], 'grp_id ', "grp_name = 'GUS Admin'");
if ($group_id == '') {
COM_errorLog('Creating GUS admin group', 1);
DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr)
VALUES ('GUS Admin', 'Users in this group can administer the GUS plugin')", 1);
if (DB_error()) {
return FALSE;
}
$result = DB_query("SELECT LAST_INSERT_ID() AS group_id");
if (DB_error()) {
return FALSE;
}
$row = DB_fetchArray($result, FALSE);
$group_id = $row['group_id'];
} else {
DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core = 0 WHERE grp_id = {$group_id}", 1);
}
COM_errorLog(" GUS group ID is {$group_id}", 1);
// Save the group id for later uninstall
COM_errorLog('Saving group_id to vars table for use during uninstall', 1);
$sql = "INSERT INTO {$_TABLES['vars']} VALUES ('gus_group_id', {$group_id})";
// ON DUPLICATE KEY UPDATE only exists on MySQL >= 4.1
// See: http://dev.mysql.com/doc/mysql/en/insert.html
if ($_GUS_VARS['sql_version']['major'] >= 4 && $_GUS_VARS['sql_version']['minor'] >= 1) {
$sql .= " ON DUPLICATE KEY UPDATE value={$group_id} ";
}
DB_query($sql, 1);
if (DB_error()) {
return FALSE;
}
// Add plugin Features
foreach ($_FEATURE as $feature => $desc) {
$feat_id = DB_getItem($_TABLES['features'], 'ft_id ', "ft_name = '{$feature}'");
if ($feat_id == '') {
COM_errorLog("Adding {$feature} feature", 1);
DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr)
VALUES ('{$feature}','{$desc}')", 1);
if (DB_error()) {
COM_errorLog("Failure adding {$feature} feature", 1);
return FALSE;
}
$result = DB_query("SELECT LAST_INSERT_ID() AS feat_id ");
if (DB_error()) {
return FALSE;
}
$row = DB_fetchArray($result, FALSE);
$feat_id = $row['feat_id'];
} else {
DB_query("UPDATE {$_TABLES['features']} SET ft_gl_core = 0 WHERE ft_id = {$feat_id}", 1);
}
COM_errorLog("Feature '{$feature}' has ID {$feat_id}", 1);
COM_errorLog("Adding {$feature} feature to admin group", 1);
DB_query("INSERT IGNORE INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id)
VALUES ({$feat_id}, {$group_id})");
// In case the previous INSERT was IGNORED, we update the group id for the feature
DB_query("UPDATE {$_TABLES['access']} SET acc_grp_id = {$group_id} WHERE acc_ft_id = {$feat_id}", 1);
if (DB_error()) {
COM_errorLog("Failure adding {$feature} feature to admin group", 1);
return FALSE;
}
}
// add the block
/*
COM_errorLog('Adding Who\'s Online block', 1);
$block_id = DB_getItem($_TABLES['blocks'], 'bid ', "phpblockfn = 'phpblock_gusstats'");
if ($block_id == '') {
$block_title = addslashes($LANG_GUS_wo['title']);
$sql = "INSERT INTO {$_TABLES['blocks']}
( is_enabled, name, type, title, blockorder, onleft, phpblockfn, group_id, owner_id )
VALUES( 1, 'gus_block', 'phpblock', '{$block_title}', 10, 0, 'phpblock_gusstats', {$group_id}, 2 )
";
DB_query($sql, 1);
if (DB_error()) {
return FALSE;
}
} else {
DB_query("UPDATE {$_TABLES['blocks']} SET group_id = {$group_id} WHERE bid = {$block_id} LIMIT 1", 1);
}
*/
// OK, now give Root users access to this plugin now! NOTE: Root group should always be 1
COM_errorLog("Giving all users in Root group access to GUS admin group", 1);
DB_query("INSERT IGNORE INTO {$_TABLES['group_assignments']} VALUES ({$group_id}, NULL, 1)");
if (DB_error()) {
return FALSE;
}
// Register the plugin with Geeklog
COM_errorLog( "Registering GUS plugin with Geeklog", 1 );
DB_query("DELETE FROM {$_TABLES['plugins']} WHERE pi_name = 'gus'");
DB_query("INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_homepage, pi_enabled)
VALUES ('gus', '{$pi_version}', '{$gl_version}', '{$pi_url}', 1)");
if (DB_error()) {
return FALSE;
}
COM_errorLog("Succesfully installed the GUS Plugin!", 1);
return TRUE;
}
function GUS_createDatabaseStructures() {
global $_CONF, $_DB, $_TABLES, $_USER, $_GUS_VARS;
$_DB->setDisplayError(TRUE);
require_once $_CONF['path'] . 'plugins/gus/sql/gus.php';
// build tables
foreach ($_SQL as $sql) {
DB_query($sql);
}
// insert data
foreach ($_DATA as $data) {
DB_query($data);
}
}
/*
* Main Function
*/
$display = COM_siteHeader()
. COM_startBlock( $LANG_GUS00['install_header'] );
$action = isset($_GET['action']) ? COM_applyFilter($_GET['action']) : '';
if ($action === 'install') {
if (plugin_install_gus()) {
$img_url = $_CONF['site_url'] . '/gus/images/' . $_GUS_IMG_name;
$blockManager = $_CONF['site_admin_url'] . '/block.php';
$admin_url = $_CONF['site_admin_url'] . '/plugins/gus/index.php';
$import_url = $_CONF['site_admin_url'] . '/plugins/gus/import.php';
$readme_url = $_CONF['site_admin_url'] . '/plugins/gus/readme.html';
$display .= ""
. '
I have created all the necessary tables and activated the Who\'s Online block. '
. "If you do not want to use it, then you may disable it by changing the GUS config.php file located in the plugins/gus directory. "
. "
To configure GUS, go to the admin page.
Information about the various configuration options may be found in the
README file."
. "
If you would like to support development of this plugin, there are some suggestions in the
README file.";
// check for old stats to see if we should add an import link
if ($_ST_plugin_name != '') {
$stats_version = DB_getItem($_TABLES['plugins'], 'pi_version', "pi_name = '{$_ST_plugin_name}'");
$display .= "
I notice you have the stats plugin version {$stats_version} installed as '{$_ST_plugin_name}'. ";
if ($stats_version !== '1.3') {
$display .= "
If you had version 1.3 installed, I could import its data.
If you update this in the future, you can import its data from
the admin page.";
} else {
$display .= "
You may import its data into GUS using the import page.";
}
}
} else {
plugin_uninstall_gus();
$display .= 'For some reason, installation failed. Check your error logs.';
}
}
$display .= COM_endBlock()
. COM_siteFooter(TRUE);
echo $display;
gus/admin/readme.html 100777 0 0 60240 12132011777 10231 0
The Geeklog Usage Stats [GUS] plugin collects statistics on who visits your site, what browser and operating system
they are using, which pages they view, and which links they are clicking to get there. It allows the administrator
to browse these stats through a series of tables, getting right down into the data. It is based on the
venerable stats plugin v1.3
by Tom Willett and John Hughes. Some of this documentation is based on their work as well. I was using
the stats plugin for a long time and eventually decided it needed some cleanup and
updating to work with the latest version of geeklog. Tom mentioned he wasn't going to continue supporting it, so I
thought I'd make a few changes myself and release them. I figured this was going to be a quick week's work - wrong!
As I got into it, I found I wanted to fix this and... oh that while I'm here, and optimise this
a bit... oh and tweak that...
Eventually I decided to do a major overhaul.
Differences Between GUS and 'Stats'
I made the following changes to the database:
moved user agents to their own table
use the SQL date and time formats
removed redundant fields
I also changed the name of the plugin from 'stats' to 'gus', eliminated the
'name the plugin whatever you want' functionality, put all the documentation in this readme,
added the ability to import stats from the stats plugin, and changed the installation/upgrade mechanism.
I probably did some other things here and there too...
The changes to the database will improve performance and require less space. I don't have any
real statistics on this, but from the feedback I got from the testers, it reduces databases to less than
half their size and is noticeably faster when browsing the stats.
Since the initial changes to the stats plugin, many other features and tweaks have been added to GUS.
Developed Using These Tools
Geeklog 1.3.11 & Geeklog 1.4
PHP 5.0.4 [works under 4.3 or greater]
MySQL 4.1.16 [works in 4.0.x or greater - some users have reported that it works under 3.23]
FireFox 1.5.0.1
MacOS X 10.4.6
If you find GUS useful for monitoring and managing your site, please consider making a donation to support development.
How about the price of a pizza or even just a beer? Check out the Things You Can Do section.
Version History
v1.7.2 [12 Apr 2013]
[fix] fixed Who's Online block title not displaying
[fix] updated default block permissions so it doesn't display for anonymous users
[fix] fixed mistake in preg_match statement which prevented the block from displaying
[fix] updated use of the ban plugin to take into account the new version
[fix] fixed table rows not using alternate colors in most reports
v1.7.1 [08 Apr 2013]
[fix] compatible with Geeklog 1.4.1 or higher including Geeklog 2.0.0
[fix] preg_match is now used instead of eregi
[new] Who's Online block is now a dynamic block (configurable in the GUS config.php file)
v1.7.0 [09 Apr 2006]
[fix] fix paging when register_globals is off
[fix] fix several other issues when register_globals is off [thanks Randall Hand]
[fix] removes temporary tables created if MySQL TEMPORARY is not used
[new] if you are using phpbbbridge, GUS will display [most] topic and forum names
[new] if you are using easyfile, GUS will display file names for downloads
[new] made day.php more concise [based on suggestions by Adrian Crook]
[new] added config option for hiding referrers in day.php [suggested and financed by Adrian Crook]
controlled by the $_GUS_CONF['hide_in_day_summary'] option in config.php
set an array of referrers which should be hidden when displaying day.php
the data is still collected, it is just hidden in the day summary
[new] added a similar config option for hiding referrers in the Who's Online block
controlled by the $_GUS_CONF['wo_hide_referrers'] option in config.php
v1.6.0 [29 Jan 2006]
[fix] save on an SQL query if there is no referrer
[fix] eliminate some warnings and a few minor buglets
[new] now installs and works with register_globals off
[new] changed the browser stats to make them more useful by breaking it down by browser and then version
[new] optionally show bots by name [Google, Yahoo!, Ask Jeeves, Inktomi, and MSN Bot] in the Who's Online block instead of showing them as Guests [based on code by ByteEnabled]
controlled by the $_GUS_CONF['wo_show_bots'] option in config.php
v1.5.0 [13 Oct 2005]
[security fix] fixed a problem which might allow non-authorised users to view some stats pages
[fix] if you had a file outside the document root which included lib-common.php, the path would not be correct when the stats were entered in the database [introduced in 1.4]
[fix] if your $CONF['site_url'] was 'http://foo.com' and someone arrived via 'http://www.foo.com', then 'foo.com' would show up as a referrer in the Who's Online block
[fix] sorting columns on today's stats was broken [reported by Adrian Crook]
[new] added new config option $_GUS_CONF['allow_ignore_anonymous'] to optimise a bit if you do not need the ability to ignore the user 'Anonymous'
[new] added filtering of referrers [suggested and financed by Adrian Crook]
[new] added some more navigation options to some pages [required a change to the header.thtml template file, so if you've changed yours, look at this]
v1.4.0 [14 Sep 2005]
[new] new interface for the admin page [uses Javascript]
if Javascript is disabled it will still work - it's just not as nice and may produce quite a long page
[new] added filtering of user agent strings [including wildcards]
[new] added filtering of host names [including wildcards]
[new] IP address, user, and page filtering now allow wildcards
if you were using addresses such as '123.0.1.' to block a range, GUS will update your tables to the new format ['123.0.1.%'] automatically
[new] changed host name lookup to be more flexible
replaced config option $_GUS_CONF['use_nslookup'] with $_GUS_CONF['host_lookup'] which can be either 'host', 'nslookup', or 'gethostbyaddr'
if your system is set up such that you cannot execute shell commands, you can use the built-in gethostbyaddr() function again
[new] added new config option $_GUS_CONF['SQL_use_TEMPORARY']
if you know your installation of MySQL does not allow the use of TEMPORARY tables, then set this to false for a slight optimisation
if you don't know what I'm talking about, then just leave it and everything will still work fine
[new] added new config options $_GUS_CONF['show_left_blocks'] and $_GUS_CONF['show_right_blocks'] to control the visibility of left and right blocks when viewing GUS pages
[new] more info in tables showing 'Page/Title/URL'
searches using the amz plugin will now show the keyword used in the search
gallery 1.x album titles and photo names will now be shown
user name for profile links will now be shown
[new] removed extra path from page names
if you had a site located at 'http://foo.bar.com/something/blat/', then all the pages in the database would start with 'something/blat/...'
this is a waste of space [screen and db], so it's outta there
this also speeds up the creation of the page columns by eliminating the need for some regular expression matches
the updater will automatically fix the entries already in the database
[fix] when importing from the stats plugin, the data would not be updated to the current GUS format correctly
if you imported your stats before version 1.3.0, then it's not an issue
if you did it after 1.3.0, then everything will still work, you just won't have the breakout of Windows versions for old data
v1.3.3 [29 Jul 2005]
[fix] error on IP page when using MySQL 3.x
[reported by Ajay]
v1.3.2 [25 Jul 2005]
[fix] query strings were being ignored [bug introduced in 1.3.0]
v1.3.1 [22 Jul 2005]
[fix] installation failed on MySQL < 4.1.0
[reported by Curly]
[new] update the user agents table
reflect the better detection of Windows varients from 1.3.0 [i.e. change all occurrences of 'Windows NT 5.0' to 'Windows 2000', 'Windows NT 5.1' to 'Windows XP', etc.]
recognise Windows Vista
add WebTV, SymbianOS, and some bot detection
v1.3.0 [16 Jul 2005]
[fix] index now has correct numbers for links followed
[reported by Ajay]
[fix] 'robustified' the installation process
[thanks to windancer and Tino for working with me on this]
[fix] use $_GUS_table_prefix when constructing TEMPORARY TABLE names and, if it fails to
properly create it, use a regular table [suggested by B. Judson]
[fix] remove keyword TABLE from TRUNCATE statements so that they work on MySQL versions 3.23.28 to 3.23.32
[see MySQL manual]
[fix] don't allow blanks to be entered for IPs, names, and pages on the admin page
[new] added new gTLDs to the country page
[new] link in the user block now includes a link to today's stats
[new] treat 404 page specially - now show what page the user was trying to access
[inspired by machinari's question about 404s]
this only works if you use a 404 page called 404.php which includes lib-common.php, such as the GL-supplied 404.php
it changes the way 404 pages are added to the database, so previous 404 pages won't have the additional info
[new] host name lookup is controlled by two new config options $_GUS_CONF['use_nslookup'] and $_GUS_CONF['host_lookup_timeout']
Windows users will probably have to set $_GUS_CONF['use_nslookup'] to 'true' [I don't run any web servers on Windows, so I can't verify this]
[new] add links to whois and netcraft on the IP page
[new] show list of user agents associated with an IP on the IP page
[new] added config option to show only a count of registered users instead of their names
[suggested by Martinez, based on the built-in Who's Online block]
[new] remove config options $_GUS_sub and $_GUS_Whois
[new] changed some configuration option names - if you've customised yours, you will have to change it
[new] more specific detection of Windows versions [thanks to Mark van der Heijden]
[new] translations
Swedish [thanks to Markus Berg]
Dutch [thanks to Mark van der Heijden]
v1.2.0 [08 May 2005]
[fix] should now install properly on Geeklog 1.3.12cvs
[reported by ldfoo]
[fix] import now works on PHP < 4.2.0
[reported by Ajay]
[fix] fixed typo preventing cleanup in one case when the install failed
[reported by ldfoo]
[fix] various HTML cleanups and fixes
[new] clicking an IP address now takes you to a page where you can:
lookup the IP using WHOIS
turn data collection on and off for the IP
you can ban the IP if you have the ban plugin installed
see the list of hostnames associated with the IP
[new] the tables now use CSS
note that the themes have changed significantly, so if you've made changes
you should look at them carefully
GUS will look in the <public_html>/gus/css directory for a file named {theme}.css and use it
if it exists. If not, it will use default.css.
if you have created a CSS file for one of the common themes,
send it to me and I will
include it in future versions of GUS
v1.1.0 [14 Apr 2005]
[security fix] fixed a potential javascript injection through the referrer URL
Note: The format of the referrers has been changed to fix this, so all data from 1.0 is invalid
and will have to be removed and re-imported [use the remove data capability on the admin page].
fixed a problem with URLs not being decoded properly when looking at page views
fixed a problem with importing user agents containing single quotes
added proper upgrade functionality
v1.0.0 [10 Apr 2005]
initial version
Thanks!
Andy Maloney for writing and maintaining the GUS plugin up to and including version 1.7.0
Tom Willett and John Hughes for writing the original stats plugin
Rick Robinson, Richard Rodriguez, Georg Kowallek, Joseph Anthony, and Tom Willett for help testing the pre-release versions of GUS 1.0.0
All the others listed in the release notes for reporting problems or making suggestions
Installing The Plugin
Backup your Geeklog database because the GUS plugin adds and modifies tables.
You can do this with the built in database backup facility in the Admin menu.
Uncompress the GUS plugin archive while in the <geeklog_dir>/plugins directory.
The archive will create a directory called gus.
In your <public_html> directory, create a directory called gus. Under your
<public_html>/admin/plugins/ directory create a directory called gus.
Change to your <geeklog_dir>/plugins/gus/ directory.
Copy the files in the admin directory to the admin/plugins/gus/ directory you created in step 3.
Copy the files and directories in the public_html directory to the public_html/gus/
directory you created in step 3.
Go to the plugin administration page. The gus plugin
should show up with a link to install it. Click it. The install page will tell you if the install
was successful or not. If not, examine the Geeklog system errorlog in <geeklog_dir>/logs to see
what the problem was. Fix it and re-install.
The install page will offer you a link to the import page if it finds a suitable stats plugin to import from.
If you choose not to do this right away, a link will appear on the admin page.
Configuring The Plugin
In the Admin block you will find a link to the GUS admin page where you may set up ignored
IP addresses, pages, and users. By default the user and IP of the user who installed the plugin is
entered in the ignore list and statistics capture is turned on. The admin page lets you enter additional
users and IPs for which usage information will not be collected. It also allows you to enable and disable
statics capture.
Set up security. Upon install, only the root users have access to statistics admin and viewing.
You can delegate control for either of these functions through the user and group editors.
Review the privacy policy. The installation also provides a privacy policy page.
This is controlled by the $_GUS_priv variable in the config.php file. If your
site already has a privacy policy available to your site users, I would encourage you to review it and
see that it is worded so that your site users know what information is being collected about them. If you
allowed anonymous access, a link to the visitor statistics viewer is also added.
There are several variables in the config.php file which control the display of information. These are documented in the file itself.
As of version 1.2, GUS uses CSS when displaying the tables. It only includes the CSS file when you are viewing a
GUS page. It first looks in <public_html>/gus/css for a file called {theme}.css - where {theme} is the name of the
current theme. If it doesn't find it, it will use the default.css file included with the plugin. If you have created a
CSS file for one of the common themes, send it to me
and I will include it in future versions of GUS.
Importing Data From Stats
GUS will give you the option to import your data and ignored lists from the stats plugin version 1.3.
You may do this either when you are installing GUS, or from the admin page. If you are going to do this,
I recommend doing it as soon as you install GUS because if there are problems with the import, it may be
difficult to recover.
Note that GUS does not use any of the tables from the stats plugin after the data has been imported,
so it is safe to remove the stats plugin and all its tables.
Upgrading The Plugin
Upgrading GUS is very similar to installation:
Backup your Geeklog database because upgrading may add or modify database tables.
You can do this with the built in database backup facility in the Admin menu.
Disable GUS using the admin interface's plugin editor [Admin->Plugins->gus]
Make a backup of your config.php so you can update the new one with your settings.
Uncompress the GUS plugin and copy the new files over the old ones as if it were a new installation.
Enable GUS using the admin interface [Admin->Plugins->gus]
Go back to the plugin editor for GUS [Admin->Plugins->gus] and click the 'Update' button.
Removing The Plugin
Because the plugin modifies several database tables, it should always be removed through the interface provided.
Log in to your Geeklog as a root user and go to the plugin administration page. Click the 'gus'
link and then click the 'Delete' button. It will ask you to confirm it. Confirm it.
Delete the three plugin directories created in the install process:
<geeklog-dir>plugins/gus/
<public_html>/gus/
<admin>/plugins/gus/
There is no step three.
Things You Can Do
Check my PHP & SQL and tell me if there are better ways to do any of this.
[Visit]
Creating a new translation for a language we do not support.
[Contact]
License
The GUS plugin is licensed under the GPL even though I don't really understand it and all its implications.
Why do we let legalese control the world?
gus/admin/Tab.js 100777 0 0 3571 12130657727 7147 0 // This javascript came from:
// The JavaScript Source!! http://javascript.internet.com
// Original: Joar Vatnaland (joar@accelrys.com )
// Modified 7 Sep 2005 by Andy Maloney [imol00@gmail.com]
// - allow arbitrary ids
// - writeTabstrip() takes an id to make active [defaults to the first tab if not set]
// - general cleanup of code
var currentPaneStyle = 0;
var currentTab = 0;
var tabstrip = function () {
this.tabs = [];
this.add = addTab;
this.write = writeTabstrip;
}
var tab = function (strip, id, caption, content) {
this.caption = caption;
this.content = content;
this.write = writeTab;
this.writeContent = writePane;
strip.add(this, id);
}
var addTab = function (tab, id) {
tab.id = id;
this.tabs[this.tabs.length] = tab;
}
var showPane = function (div) {
if (currentTab != 0) {
currentTab.style.backgroundColor = "#CCCCFF"; // IF you change this, you'll have to edit the css to match it
}
div.style.backgroundColor = "rgb(231, 231, 231)";
currentTab = div;
if (currentPaneStyle != 0) {
currentPaneStyle.display = "none";
}
var paneId = "pn_" + div.id;
var objPaneStyle = document.getElementById(paneId ).style;
objPaneStyle.display = "block";
currentPaneStyle = objPaneStyle;
}
var writePane = function () {
document.write("
" + this.content + "
");
}
var writeTab = function () {
document.write("
" + this.caption + "
");
}
var writeTabstrip = function (id) {
document.write( "
" );
for (var i = 0; i < this.tabs.length; i++) {
this.tabs[i].write();
}
document.write("
");
for (var k = 0; k < this.tabs.length; k++) {
this.tabs[k].writeContent();
}
if (!id) {
id = this.tabs[0].id;
}
showPane(document.getElementById(id));
}
gus/config.php 100777 0 0 16751 12131076764 7012 0 ';
// The icon to use for the GUS pages - located in the public_html/gus/images/ directory
$_GUS_IMG_name = "GUS48.png";
$_GUS_IMG_small_name = "GUS24.png";
// Enable anononymous access to summary stats
$_GUS_anon_access = 0;
// Show a link in the main menu if user has permission to access the stats
$_GUS_enable_main_menu_GUS = 0;
// Show a link to the privacy policy in the main menu
$_GUS_enable_main_menu_privacy_policy = 0;
// Set to 1 to enable user stats menu option in the 'User Functions' block
$_GUS_user = 1;
// Set to 1 to extend the regular Geeklog stats page to include 'Unique Visitors' and 'Registered Users'
$_GUS_stats = 1;
// Set to 1 to enable phplinks integration
$_GUS_phplinks = 0;
// Limit on number of lines to display on certain stats reports
$_GUS_limit = 25;
// Number of months displayed on the index page
$_GUS_months = 4;
// Number of days on each page
$_GUS_days = 16;
// Enable the caching of stats
$_GUS_cache = FALSE;
// The following variables allow custom configuration of WhosOnline Block.
// If set to TRUE then the full name is displayed if available instead of username
$_GUS_CONF['wo_fullname'] = FALSE;
// If set to TRUE, show only a count of users for Who's Online, Registered Users, and New Users to anon users
$_GUS_CONF['wo_users_anonymous'] = TRUE;
// If set to TRUE, show a list of who's online
$_GUS_CONF['wo_online'] = TRUE;
// If set to TRUE, then show bots as they access your site
$_GUS_CONF['wo_show_bots'] = TRUE;
// If set to TRUE, show Registered users
$_GUS_CONF['wo_registered'] = TRUE;
// If set to TRUE, show New users
$_GUS_CONF['wo_new'] = TRUE;
// If set to TRUE, show daily usage stats
$_GUS_CONF['wo_daily'] = TRUE;
// If set to TRUE, show referrers
$_GUS_CONF['wo_refs'] = TRUE;
// Set this to the referrers you DO NOT want to show up in the Who's Online block.
// Note that the data is still collected, it is just not visible in the block.
$_GUS_CONF['wo_hide_referrers'] = array(
$_CONF['site_url']
// , 'http://images.google.com' // hide all images.google.com referrers
// , 'http://images.google.' // hide all images.google.* referrers
);
// Maximum number of referrers to show
$_GUS_CONF['wo_max_referrers'] = 100;
// DO NOT CHANGE THE STUFF BELOW UNLESS YOU KNOW WHAT YOU ARE DOING
$_GUS_table_prefix = $_DB_table_prefix . 'gus_';
$_TABLES['gus_userstats'] = $_GUS_table_prefix . 'userstats';
$_TABLES['gus_user_agents'] = $_GUS_table_prefix . 'user_agents';
$_TABLES['gus_ignore_ip'] = $_GUS_table_prefix . 'ignore_ip';
$_TABLES['gus_ignore_user'] = $_GUS_table_prefix . 'ignore_user';
$_TABLES['gus_ignore_page'] = $_GUS_table_prefix . 'ignore_page';
$_TABLES['gus_ignore_ua'] = $_GUS_table_prefix . 'ignore_ua';
$_TABLES['gus_ignore_host'] = $_GUS_table_prefix . 'ignore_host';
$_TABLES['gus_ignore_referrer'] = $_GUS_table_prefix . 'ignore_referrer';
$_TABLES['gus_vars'] = $_GUS_table_prefix . 'vars';
gus/functions.inc 100777 0 0 115245 12131102240 7530 0 0) {
// Get the GUS vars from the DB
while ($row = DB_fetchArray($rec, FALSE)) {
$_GUS_VARS[$row['name']] = $row['value'];
}
// store the MySQL version number in $_GUS_VARS['sql_version']
$version = DB_getVersion();
$_GUS_VARS['sql_version'] = array();
if (preg_match("/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/", $version, $match)) {
$_GUS_VARS['sql_version']['major'] = $match[1];
$_GUS_VARS['sql_version']['minor'] = $match[2];
$_GUS_VARS['sql_version']['patch'] = $match[3];
}
// save our parsed url for path info later on
$_GUS_VARS['parsed_site_url'] = parse_url($_CONF['site_url']);
if ($_GUS_VARS['capture'] == '1') {
// First check the IP...
$_GUS_VARS['remote_ip'] = GetIP($_SERVER['REMOTE_ADDR']);
$rec = DB_query("SELECT COUNT(*) AS ignored
FROM {$_TABLES['gus_ignore_ip']}
WHERE '{$_GUS_VARS['remote_ip']}' LIKE ip
LIMIT 1", 1);
$row = DB_fetchArray($rec, FALSE);
if ($row['ignored'] == '1') {
return;
}
// Next check the hostname...
$host_name = ip_to_hostname($_GUS_VARS['remote_ip']);
$rec = DB_query("SELECT COUNT(*) AS ignored
FROM {$_TABLES['gus_ignore_host']}
WHERE '{$host_name}' LIKE host
LIMIT 1", 1);
$row = DB_fetchArray($rec, FALSE);
if ($row['ignored'] == '1') {
return;
}
// Next check the page...
// remove extra path from the page name if necessary
$page = $_SERVER['SCRIPT_NAME'];
$len = strlen($_GUS_VARS['parsed_site_url']['path']);
if (strncmp($page, $_GUS_VARS['parsed_site_url']['path'], $len) === 0) {
$page = substr($page, $len + 1);
}
$rec = DB_query("SELECT COUNT(*) AS ignored
FROM {$_TABLES['gus_ignore_page']}
WHERE '{$page}' LIKE page
LIMIT 1", 1);
$row = DB_fetchArray($rec, false);
if ($row['ignored'] == '1') {
return;
}
// check the user...
$check_user = TRUE;
if (!isset($_USER['uid']) OR ($_USER['uid'] < 2)) {
$user_id = 1;
$user_name = 'Anonymous';
$check_user = $_GUS_CONF['allow_ignore_anonymous'];
} else {
$user_id = $_USER['uid'];
$user_name = $_USER['username'];
}
if ($check_user) {
$rec = DB_query("SELECT COUNT(*) AS ignored
FROM {$_TABLES['gus_ignore_user']}
WHERE '{$user_name}' LIKE username
LIMIT 1", 1);
$row = DB_fetchArray($rec, FALSE);
if ($row['ignored'] == '1') {
return;
}
}
// check user agent
$user_agent = addslashes(substr($_SERVER['HTTP_USER_AGENT'], 0, 128));
$rec = DB_query("SELECT COUNT(*) AS ignored
FROM {$_TABLES['gus_ignore_ua']}
WHERE '{$user_agent}' LIKE ua
LIMIT 1", 1);
$row = DB_fetchArray($rec, FALSE);
if ($row['ignored'] == '1') {
return;
}
// check the referrer
if (isset($_SERVER['HTTP_REFERER']) AND ($_SERVER['HTTP_REFERER'] != '')) {
$referrer = $_SERVER['HTTP_REFERER'];
$rec = DB_query("SELECT COUNT(*) AS ignored
FROM {$_TABLES['gus_ignore_referrer']}
WHERE '{$referrer}' LIKE referrer
LIMIT 1", 1);
$row = DB_fetchArray($rec, FALSE);
if ($row['ignored'] == '1') {
return;
}
}
// Finally, add stats
GUS_addStats($page, $user_id, $user_name, $host_name, $user_agent);
}
}
}
// adapted from code found here: http://www.php.net/getenv
function GetIP($ip) {
// commented out because it seems to give misleading results sometimes
/*
if ( $_SERVER["HTTP_CLIENT_IP"] && strcasecmp($_SERVER["HTTP_CLIENT_IP"], "unknown") )
$ip = $_SERVER["HTTP_CLIENT_IP"];
else if ( $_SERVER["HTTP_X_FORWARDED_FOR"] && strcasecmp($_SERVER["HTTP_X_FORWARDED_FOR"], "unknown") )
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
*/
// IF more than one IP, grab the first
if (strpos($ip, ', ') !== FALSE) {
$ips = explode(', ', $ip);
$ip = $ips[0];
}
return $ip;
}
// adapted from code found here: http://www.php.net/gethostbyaddr
function ip_to_hostname($ip) {
global $_GUS_CONF;
switch ($_GUS_CONF['host_lookup']) {
case 'host':
$timeout = $_GUS_CONF['host_lookup_timeout'];
$output = `host -W {$timeout} {$ip}`;
if (preg_match('/.*pointer ([A-Za-z0-9.-]+)\..*/', $output, $regs)) {
return $regs[1];
}
break;
case 'nslookup':
$timeout = $_GUS_CONF['host_lookup_timeout'];
$res = `nslookup -timeout=$timeout $ip`;
if (preg_match('/\nName:(.*)\n/', $res, $out)) {
return trim($out[1]);
}
break;
case 'gethostbyaddr':
return @gethostbyaddr($ip);
break;
default:
COM_errorLog("Invalid setting for 'host_lookup' in config.php [{$_GUS_CONF['host_lookup']}]");
break;
}
return $ip;
}
// +---------------------------------------------------------------------------+
// | Geeklog Plugin API Implementations |
// +---------------------------------------------------------------------------+
/**
* Returns the current plugin code version
*
* @return string plugin version
*/
function plugin_chkVersion_gus() {
return '1.7.2';
}
// Add the CSS file if we are browsing a GUS page
function plugin_getheadercode_gus() {
global $_CONF;
$this_dir = basename(dirname($_SERVER['SCRIPT_NAME']));
if ($this_dir !== 'gus') {
return '';
}
$header_text = '';
// check for CSS file specific to this theme
$css_file = 'css/' . $_CONF['theme'] . '.css';
$css_path = $_CONF['path_html'] . 'gus/' . $css_file;
// IF we don't find one that's readable THEN use the default
if (!is_readable($css_path)) {
$css_file = 'css/default.css';
$css_path = $_CONF['path_html'] . 'gus/' . $css_file;
// IF we still don't have anything THEN return
if (!is_readable($css_path)) {
return '';
}
}
$stylesheet = $_CONF['site_url'] . '/gus/' . $css_file;
$header_text .= '';
if (strpos($_SERVER['SCRIPT_NAME'], 'admin/plugins/gus/index.php') !== FALSE) {
$header_text .= '';
}
return $header_text;
}
/**
* Returns the items for this plugin that should appear on the main menu
*
* NOTE: this MUST return the url/value pairs in the following format
* $[