No thats true that aint going to fix it, but I think there was a " missing there
Here is the code
<?php
/**
* @package ChronoForms
* @copyright Copyright (C) 2010 Bob Janes. All rights reserved.
* @license GNU/GPL, see LICENSE.php
*/
/* ensure that this file is not called directly */
// uncomment the following line if you include this code from a file
defined('_JEXEC') or die('Restricted access');
$gh_session =& JFactory::getSession();
$gh_ip =& $gh_session->get('gh_ip', '000.000.000.000', 'gh');
$gh_pages =& $gh_session->get('gh_pages', array(), 'gh');
$gh_referers =& $gh_session->get('gh_referers', array(), 'gh');
// add the user IP address
$message = "";
$message .= "<div >IP: $gh_ip</div>";
// add the referer URL
if ( count($gh_referers) ) {
$i = 1;
$temp = $keywords = array();
foreach ( $gh_referers as $referer ) {
$temp[] = "<p>Referer $i: $referer</p>";
$keywords_used = getKeywords($referer);
if ( $keywords_used ) {
$keywords[] = $keywords_used;
}
$i++;
}
$message .= "<div>".implode('br />', $temp)."</div>";
// add the pages visited
if ( count($gh_pages) ) {
$i = 1;
$temp = array();
foreach ( $gh_pages as $page ) {
if ( $page ) {
$temp[] = "<p>Page visited $i: $page</p>";
$i++;
}
}
$message .= "<div>".implode('br />', $temp)."</div>";
}
// add the search engine keywords
if ( count($keywords) ) {
$i = 1;
$temp = array();
foreach ( $keywords as $keyword ) {
$temp[] = "<p>Keyword $i: $keyword</p>";
$i++;
}
$message .= "<div>".implode('br />', $temp)."</div>";
}
JRequest::setVar('tracker_message', $message, 'post');
// function to extract keyword form a search engine URI
function getKeywords($query)
{
if ( strpos($query, "google.") ) {
$pattern = '%^.*/(?:search|maps).*[?&]q=(.*)%';
} elseif ( strpos($query, "msn.") || strpos($query, "live") ) {
$pattern = '/^.*q=(.*)$/';
} elseif ( strpos($query, "yahoo.") ) {
$pattern = '/^.*[?&]p=(.*)$/';
} elseif ( strpos($query, "ask.") ) {
$pattern = '/^.*[?&]q=(.*)$/';
} elseif ( strpos($query, "bing.") ) {
$pattern = '/^.*[?&]q=(.*)$/';
} else {
return false;
}
preg_match($pattern, $query, $matches);
if ( strpos($matches[1], '&') ) {
$querystr = substr($matches[1], 0, strpos($matches[1], '&'));
} else {
$querystr = $matches[1];
}
return urldecode($querystr);
}
?>