Hi Bob,
now i have put the code into the jumi compo directly and in the Module i set *4 for the ID. No Error were display but the tracking didn´t work😟
this is the Code that i use in for Jumi:
<?php
/**
* @package Jumi
* @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");
// load the user session
$gh_session =& JFactory::getSession();
// store ip address
if ( !$gh_session->has('gh_ip', 'gh') ) {
$gh_session->set('gh_ip', gh_getip(), 'gh');
}// store referer
$gh_referers =& $gh_session->get('gh_referers', array(), 'gh');
$gh_referer = JRequest::getString('HTTP_REFERER', 'HTTP_REFERER not set', 'server');
if ( (strpos($gh_referer, JURI::base()) === false )
&& !in_array($gh_referer, $gh_referers) ) {
$gh_referers[] = $gh_referer;
$gh_session->set('gh_referers', $gh_referers, 'gh');
}
// store page
$gh_uri =& JFactory::getURI();
$gh_pages =& $gh_session->get('gh_pages', array(), 'gh');
if ( end($gh_pages) != $gh_uri->toString() ) {
$gh_pages[] = $gh_uri->toString();
$gh_session->set('gh_pages', $gh_pages, 'gh');
}
function gh_getip() {
if ( isset($_SERVER) ) {
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$ip_addr = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
$ip_addr = $_SERVER["HTTP_CLIENT_IP"];
} else {
$ip_addr = $_SERVER["REMOTE_ADDR"];
}
} else {
if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
$ip_addr = getenv( 'HTTP_X_FORWARDED_FOR' );
} else if ( getenv( 'HTTP_CLIENT_IP' ) ) {
$ip_addr = getenv( 'HTTP_CLIENT_IP' );
} else {
$ip_addr = getenv( 'REMOTE_ADDR' );
}
}
return $ip_addr;
}
?>
And this is the Code i put into the chronofrom (before HTML):
<?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[] = "Keyword $i: $keyword";
$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);
}
?>
You know that is the Code out of the v3 and i use the v4. It´s very important for me to have a tracking for my forms. I use one form in many sites and i must know from where the form was sending!
regards
chevron08