Sure here a general rundown of the tracking script:
PHP Code:
<?PHP
//Track.php
//Track and log page load
require_once('includes/traffic.conf');
require_once('includes/TrafficDatabase.class.php');
require_once('includes/rc_SEReferer.class.php');
require_once('includes/Libfunctions.class.php');
function getUserIp()
{
$ipParts = explode(".", $_SERVER['REMOTE_ADDR']);
if ($ipParts[0] == "165" && $ipParts[1] == "21")
{
if (getenv("HTTP_CLIENT_IP")) {
$ip = getenv("HTTP_CLIENT_IP");
} elseif (getenv("HTTP_X_FORWARDED_FOR"))
{
$ip = getenv("HTTP_X_FORWARDED_FOR");
} elseif (getenv("REMOTE_ADDR"))
{
$ip = getenv("REMOTE_ADDR");
}
} else
{
return $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
function getReferer()
{
global $LibFunctions;
$strReferer = getenv('HTTP_REFERER');
if (!$strReferer)
{
return "Direct Request";
}
return $LibFunctions->clean_var($strReferer);
}
function getServerName()
{
global $LibFunctions;
$strServerName = $_SERVER['SERVER_NAME'];
return $LibFunctions->clean_var($strServerName);
}
function getQueryString()
{
global $LibFunctions;
$strQueryString = $_SERVER['QUERY_STRING'];
return $LibFunctions->clean_var($strQueryString);
}
function getUserAgent()
{
global $LibFunctions;
$strUserAgent = getenv('HTTP_USER_AGENT');
return $LibFunctions->clean_var($strUserAgent);
}
function getRemoteHost()
{
global $LibFunctions;
$strRemoteHost = $_SERVER['REMOTE_HOST'];
return $LibFunctions->clean_var($strRemoteHost);
}
$TrafficDataBase = new TrafficDatabase();
$LibFunctions = new LibFunctions();
if($TrafficDataBase)
{
$strSearchEngine = '';
$strSearchString = '';
$SEReferer = new rc_SEReferer(getReferer() . "?" .getQueryString());
if($SEReferer->isSearchEngine())
{
$strSearchEngine = $SEReferer->getSearchEngine();
$strSearchString = $SEReferer->getSearchQuery();
}
$TrafficDataBase->logHit(getServerName(), getUserIp(), $_SERVER['PHP_SELF'], getReferer(), getQueryString(), getUserAgent(), getRemoteHost(), $strSearchEngine, $strSearchString);
}
?>
The call is simply:
PHP Code:
<?
include_once('/full/path/to/script/Track.php');
?>
This include directive has been added to all of our generic header files,and is incorporated into the default template of vbulletin.
Rather than return valid data we get our own server IP back and the name of the header file rather than the end user IP and the name of the forum page.