// Rollback file wrongly modified by previous commit
This commit is contained in:
1 parent
cda7b225e2
commit
33405ed858
1 file changed
+55
-42
@@ -79,12 +79,14 @@ class Dashactivity extends Module
|
|||||||
$gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false;
|
$gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false;
|
||||||
if (Validate::isLoadedObject($gapi) && $gapi->isConfigured())
|
if (Validate::isLoadedObject($gapi) && $gapi->isConfigured())
|
||||||
{
|
{
|
||||||
$visits = $unique_visitors = 0;
|
$visits = $unique_visitors = $online_visitor = 0;
|
||||||
if ($result = $gapi->requestReportData('', 'ga:visits,ga:visitors', $params['date_from'], $params['date_to'], null, null, 1, 1))
|
if ($result = $gapi->requestReportData('', 'ga:visits,ga:visitors', $params['date_from'], $params['date_to'], null, null, 1, 1))
|
||||||
{
|
{
|
||||||
$visits = $result[0]['metrics']['visits'];
|
$visits = $result[0]['metrics']['visits'];
|
||||||
$unique_visitors = $result[0]['metrics']['visitors'];
|
$unique_visitors = $result[0]['metrics']['visitors'];
|
||||||
}
|
}
|
||||||
|
if ($result = $gapi->requestReportData('', 'ga:activeVisitors', null, null, null, null, 1, 1))
|
||||||
|
$online_visitor = $result[0]['metrics']['activeVisitors'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -94,6 +96,24 @@ class Dashactivity extends Module
|
|||||||
WHERE `date_add` BETWEEN "'.pSQL($params['date_from']).'" AND "'.pSQL($params['date_to']).'"
|
WHERE `date_add` BETWEEN "'.pSQL($params['date_from']).'" AND "'.pSQL($params['date_to']).'"
|
||||||
'.Shop::addSqlRestriction(false));
|
'.Shop::addSqlRestriction(false));
|
||||||
extract($row);
|
extract($row);
|
||||||
|
|
||||||
|
if ($maintenance_ips = Configuration::get('PS_MAINTENANCE_IP'))
|
||||||
|
$maintenance_ips = implode(',', array_map('ip2long', array_map('trim', explode(',', $maintenance_ips))));
|
||||||
|
if (Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
|
||||||
|
$sql = 'SELECT COUNT(DISTINCT c.id_connections)
|
||||||
|
FROM `'._DB_PREFIX_.'connections` c
|
||||||
|
LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON c.id_connections = cp.id_connections
|
||||||
|
WHERE TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900
|
||||||
|
AND cp.`time_end` IS NULL
|
||||||
|
'.Shop::addSqlRestriction(false, 'c').'
|
||||||
|
'.($maintenance_ips ? 'AND c.ip_address NOT IN ('.preg_replace('/[^,0-9]/', '', $maintenance_ips).')' : '');
|
||||||
|
else
|
||||||
|
$sql = 'SELECT COUNT(*)
|
||||||
|
FROM `'._DB_PREFIX_.'connections`
|
||||||
|
WHERE TIME_TO_SEC(TIMEDIFF(NOW(), `date_add`)) < 900
|
||||||
|
'.Shop::addSqlRestriction(false).'
|
||||||
|
'.($maintenance_ips ? 'AND ip_address NOT IN ('.preg_replace('/[^,0-9]/', '', $maintenance_ips).')' : '');
|
||||||
|
$online_visitor = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$order_nbr = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
$order_nbr = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||||
@@ -137,24 +157,6 @@ class Dashactivity extends Module
|
|||||||
WHERE cm.`date_add` BETWEEN "'.pSQL($params['date_from']).'" AND "'.pSQL($params['date_to']).'"
|
WHERE cm.`date_add` BETWEEN "'.pSQL($params['date_from']).'" AND "'.pSQL($params['date_to']).'"
|
||||||
'.Shop::addSqlRestriction(false, 'ct'));
|
'.Shop::addSqlRestriction(false, 'ct'));
|
||||||
|
|
||||||
if ($maintenance_ips = Configuration::get('PS_MAINTENANCE_IP'))
|
|
||||||
$maintenance_ips = implode(',', array_map('ip2long', array_map('trim', explode(',', $maintenance_ips))));
|
|
||||||
if (Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
|
|
||||||
$sql = 'SELECT COUNT(DISTINCT c.id_connections)
|
|
||||||
FROM `'._DB_PREFIX_.'connections` c
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON c.id_connections = cp.id_connections
|
|
||||||
WHERE TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900
|
|
||||||
AND cp.`time_end` IS NULL
|
|
||||||
'.Shop::addSqlRestriction(false, 'c').'
|
|
||||||
'.($maintenance_ips ? 'AND c.ip_address NOT IN ('.preg_replace('/[^,0-9]/', '', $maintenance_ips).')' : '');
|
|
||||||
else
|
|
||||||
$sql = 'SELECT COUNT(*)
|
|
||||||
FROM `'._DB_PREFIX_.'connections`
|
|
||||||
WHERE TIME_TO_SEC(TIMEDIFF(NOW(), `date_add`)) < 900
|
|
||||||
'.Shop::addSqlRestriction(false).'
|
|
||||||
'.($maintenance_ips ? 'AND ip_address NOT IN ('.preg_replace('/[^,0-9]/', '', $maintenance_ips).')' : '');
|
|
||||||
$online_visitor = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
|
||||||
|
|
||||||
$active_shopping_cart = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
$active_shopping_cart = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
FROM `'._DB_PREFIX_.'cart`
|
FROM `'._DB_PREFIX_.'cart`
|
||||||
@@ -248,31 +250,42 @@ class Dashactivity extends Module
|
|||||||
|
|
||||||
public function getReferer($date_from, $date_to, $limit = 10)
|
public function getReferer($date_from, $date_to, $limit = 10)
|
||||||
{
|
{
|
||||||
$directLink = $this->l('Direct link');
|
$gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false;
|
||||||
$sql = 'SELECT http_referer
|
if (Validate::isLoadedObject($gapi) && $gapi->isConfigured())
|
||||||
FROM '._DB_PREFIX_.'connections
|
|
||||||
WHERE 1
|
|
||||||
'.Shop::addSqlRestriction().'
|
|
||||||
AND date_add BETWEEN '.$date_from.' AND '.$date_to.'
|
|
||||||
LIMIT 0, '.(int)$limit;
|
|
||||||
|
|
||||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql);
|
|
||||||
$websites = array($directLink => 0);
|
|
||||||
|
|
||||||
while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result))
|
|
||||||
{
|
{
|
||||||
if (!isset($row['http_referer']) || empty($row['http_referer']))
|
$websites = array();
|
||||||
++$websites[$directLink];
|
if ($result = $gapi->requestReportData('ga:source', 'ga:visitors', $date_from, $date_to, '-ga:visitors', null, 1, 3))
|
||||||
else
|
foreach ($result as $row)
|
||||||
{
|
$websites[$row['dimensions']['source']] = $row['metrics']['visitors'];
|
||||||
$website = preg_replace('/^www./', '', parse_url($row['http_referer'], PHP_URL_HOST));
|
}
|
||||||
if (!isset($websites[$website]))
|
else
|
||||||
$websites[$website] = 1;
|
{
|
||||||
else
|
$directLink = $this->l('Direct link');
|
||||||
++$websites[$website];
|
$sql = 'SELECT http_referer
|
||||||
}
|
FROM '._DB_PREFIX_.'connections
|
||||||
|
WHERE 1
|
||||||
|
'.Shop::addSqlRestriction().'
|
||||||
|
AND date_add BETWEEN '.$date_from.' AND '.$date_to.'
|
||||||
|
LIMIT 0, '.(int)$limit;
|
||||||
|
|
||||||
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql);
|
||||||
|
$websites = array($directLink => 0);
|
||||||
|
|
||||||
|
while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result))
|
||||||
|
{
|
||||||
|
if (!isset($row['http_referer']) || empty($row['http_referer']))
|
||||||
|
++$websites[$directLink];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$website = preg_replace('/^www./', '', parse_url($row['http_referer'], PHP_URL_HOST));
|
||||||
|
if (!isset($websites[$website]))
|
||||||
|
$websites[$website] = 1;
|
||||||
|
else
|
||||||
|
++$websites[$website];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
arsort($websites);
|
||||||
}
|
}
|
||||||
arsort($websites);
|
|
||||||
return $websites;
|
return $websites;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user