Menu Content

Support

> Forums, FAQs & Paid Support
Welcome, Guest
Username Password: Remember me

PHP Issue with Google Analytics Plugin
(1 viewing) (1) Guest
Support forum for users using free edition of JoomSEF 3 (Joomla 1.5 compatible). These forums are mainly for mutual help between users.

Please note that due to our capacity limitations, we do not monitor these forums regularly.
  • Page:
  • 1

TOPIC: PHP Issue with Google Analytics Plugin

PHP Issue with Google Analytics Plugin 15 years, 9 months ago #5855

I enabled the Google Analytics plugin 1.0.0 on my livesite at www.armadalecityconcertband.org.au. I am unable even to access the back-end.The error message I get is as follows:
 
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/arm58423/public_html/plugins/system/gacode.php on line 16
 


gacode.php reads as follows:

 
<?php
/**
* @version $Id$
* @package Google Tracking
* @subpackage Module
* @author Michal Unzeitig, ARTIO s.r.o.
* @copyright Copyright (C) 2009 ARTIO s.r.o., All rights reserved.
* @license GNU/GPL
*/

// security check
defined('_JEXEC') or die('Restricted access');
 
class plgSystemGACode extends JPlugin
{
 
private $script1 =
" var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));";
private $script2 =
"
try {
var pageTracker = _gat._getTracker("%s");
pageTracker._trackPageview();%s
} catch(err) {}";
protected $uaCode;
protected $trackVM;
protected $vmCode;
protected $triggered = false;
 
function plgSystemGACode( &$subject )
{
parent::__construct($subject);
 
// load plugin parameters
$this->_plugin = & JPluginHelper::getPlugin('system', 'gacode');
$this->_params = new JParameter($this->_plugin->params);
}
 
function __destruct()
{
global $mainframe;
if ($this->triggered || $mainframe->isAdmin()) return;
 
// get configuration parameters
$this->uaCode = $this->_params->get('uaCode', '');
$this->trackVM = $this->_params->get('trackVM', '');
$this->vmCode = $this->trackVM ? "
rn".$this->getVMTrackCode() : '';
 
// output general code
$document = & JFactory::getDocument();
print("
<script type="text/javascript">rn");
print($this->script1);
print("
</script>rn");
print("
<script type="text/javascript">rn");
printf($this->script2, $this->uaCode, $this->vmCode);
print("
</script>rn");
ob_flush();
}
 
function onAfterDispatch()
{
// do not run in admin
global $mainframe;
if ($mainframe->isAdmin()) return;
 
// get configuration parameters
$this->uaCode = $this->_params->get('uaCode', '');
$this->trackVM = $this->_params->get('trackVM', '');
$this->vmCode = $this->trackVM ? $this->getVMTrackCode() : '';
 
// output general code
$document = & JFactory::getDocument();
$document->_custom[] = sprintf("
<script type="text/javascript">");
$document->_custom[] = $this->script1;
$document->_custom[] = sprintf("
</script>");
$document->_custom[] = sprintf("
<script type="text/javascript">");
$document->_custom[] = sprintf($this->script2, $this->uaCode, $this->vmCode);
$document->_custom[] = sprintf("
</script>");
 
$this->triggered = true;
}
 
function getVMTrackCode()
{
$option = JRequest::getVar('option');
$page = JRequest::getVar('page');
 
if ($option != 'com_virtuemart' || $page != 'checkout.thankyou') return '';
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'classes'.DS.'ps_database.php');
 
$db = new ps_DB;
//$order_id = $db->getEscaped(vmGet($vars, 'order_id'));
$order_id = $GLOBALS['vars']['order_id'];
//die(var_dump($order_id));
 
$q = 'SELECT order_id, affiliate_id, order_total, order_tax, order_shipping, city, state, country'
. ' FROM #__{vm}_orders LEFT JOIN #__{vm}_order_user_info USING (order_id)'
. ' LEFT JOIN #__{vm}_affiliate_sale USING (order_id)'
. ' WHERE order_id = ' . $db->getEscaped($GLOBALS['vars']['order_id']);
$db->query($q);
 
$code = sprintf('pageTracker._addTrans("
%d", "%s", "%f", "%s", "%f", "%s", "%s", "%s");',
$db->f('order_id'), $db->f('affiliate_id'), $db->f('order_total'), $db->f('order_tax'),
$db->f('order_shipping'), $db->f('city'), $db->f('state'), $db->f('country'));
 
$q = 'SELECT order_id, order_item_sku, order_item_name, GROUP_CONCAT(category_name SEPARATOR ', ') AS categories, product_final_price, product_quantity'
. ' FROM #__{vm}_order_item LEFT JOIN #__{vm}_product_category_xref USING (product_id)'
. ' LEFT JOIN #__{vm}_category AS c USING (category_id)'
. ' WHERE order_id = ' . $db->getEscaped($GLOBALS['vars']['order_id'])
. ' GROUP BY order_id, order_item_sku, order_item_name, product_final_price, product_quantity'
;
$db->query($q);
 
while ($db->next_record()) {
$code .= sprintf(' pageTracker._addItem("
%d", "%s", "%s", "%s", "%f", "%f");',
$db->f('order_id'), $db->f('order_item_sku'), $db->f('order_item_name'),
$db->f('categories'), $db->f('product_final_price'), $db->f('product_quantity'));
}
 
$code .= ' pageTracker._trackTrans();';
 
return $code;
}
}
?>

 



My server is running php 4.x I think, but I can't check as my cPanel won't load and I have no other access to it.

Anyone help me out?

Cheers,
S
Last Edit: 15 years, 9 months ago by Shades_Of_Grey.
  • Page:
  • 1
User Login Empty