[*] MO : you can now exclude IP addresses from the online visitors module #PSCFV-9056
This commit is contained in:
@@ -57,18 +57,37 @@ class StatsLive extends Module
|
|||||||
*/
|
*/
|
||||||
private function getCustomersOnline()
|
private function getCustomersOnline()
|
||||||
{
|
{
|
||||||
$sql = 'SELECT u.id_customer, u.firstname, u.lastname, pt.name as page
|
if ($maintenance_ips = Configuration::get('PS_MAINTENANCE_IP'))
|
||||||
FROM `'._DB_PREFIX_.'connections` c
|
$maintenance_ips = implode(',', array_map('ip2long', array_map('trim', explode(',', $maintenance_ips))));
|
||||||
LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON c.id_connections = cp.id_connections
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'page` p ON p.id_page = cp.id_page
|
if (Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
|
||||||
LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON p.id_page_type = pt.id_page_type
|
{
|
||||||
INNER JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
|
$sql = 'SELECT u.id_customer, u.firstname, u.lastname, pt.name as page
|
||||||
INNER JOIN `'._DB_PREFIX_.'customer` u ON u.id_customer = g.id_customer
|
FROM `'._DB_PREFIX_.'connections` c
|
||||||
WHERE cp.`time_end` IS NULL
|
LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON c.id_connections = cp.id_connections
|
||||||
'.Shop::addSqlRestriction(false, 'c').'
|
LEFT JOIN `'._DB_PREFIX_.'page` p ON p.id_page = cp.id_page
|
||||||
AND TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900
|
LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON p.id_page_type = pt.id_page_type
|
||||||
GROUP BY c.id_connections
|
INNER JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
|
||||||
ORDER BY u.firstname, u.lastname';
|
INNER JOIN `'._DB_PREFIX_.'customer` u ON u.id_customer = g.id_customer
|
||||||
|
WHERE cp.`time_end` IS NULL
|
||||||
|
'.Shop::addSqlRestriction(false, 'c').'
|
||||||
|
AND TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900
|
||||||
|
'.($maintenance_ips ? 'AND c.ip_address NOT IN ('.preg_replace('/[^,0-9]/', '', $maintenance_ips).')' : '').'
|
||||||
|
GROUP BY u.id_customer
|
||||||
|
ORDER BY u.firstname, u.lastname';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql = 'SELECT u.id_customer, u.firstname, u.lastname, "-" as page
|
||||||
|
FROM `'._DB_PREFIX_.'connections` c
|
||||||
|
INNER JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
|
||||||
|
INNER JOIN `'._DB_PREFIX_.'customer` u ON u.id_customer = g.id_customer
|
||||||
|
WHERE TIME_TO_SEC(TIMEDIFF(NOW(), c.`date_add`)) < 900
|
||||||
|
'.Shop::addSqlRestriction(false, 'c').'
|
||||||
|
'.($maintenance_ips ? 'AND c.ip_address NOT IN ('.preg_replace('/[^,0-9]/', '', $maintenance_ips).')' : '').'
|
||||||
|
GROUP BY u.id_customer
|
||||||
|
ORDER BY u.firstname, u.lastname';
|
||||||
|
}
|
||||||
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||||
return array($results, Db::getInstance()->NumRows());
|
return array($results, Db::getInstance()->NumRows());
|
||||||
}
|
}
|
||||||
@@ -80,6 +99,9 @@ class StatsLive extends Module
|
|||||||
*/
|
*/
|
||||||
private function getVisitorsOnline()
|
private function getVisitorsOnline()
|
||||||
{
|
{
|
||||||
|
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'))
|
if (Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
|
||||||
{
|
{
|
||||||
$sql = 'SELECT c.id_guest, c.ip_address, c.date_add, c.http_referer, pt.name as page
|
$sql = 'SELECT c.id_guest, c.ip_address, c.date_add, c.http_referer, pt.name as page
|
||||||
@@ -91,18 +113,20 @@ class StatsLive extends Module
|
|||||||
WHERE (g.id_customer IS NULL OR g.id_customer = 0)
|
WHERE (g.id_customer IS NULL OR g.id_customer = 0)
|
||||||
'.Shop::addSqlRestriction(false, 'c').'
|
'.Shop::addSqlRestriction(false, 'c').'
|
||||||
AND cp.`time_end` IS NULL
|
AND cp.`time_end` IS NULL
|
||||||
AND TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900
|
AND TIME_TO_SEC(TIMEDIFF(NOW(), cp.`time_start`)) < 900
|
||||||
|
'.($maintenance_ips ? 'AND c.ip_address NOT IN ('.preg_replace('/[^,0-9]/', '', $maintenance_ips).')' : '').'
|
||||||
GROUP BY c.id_connections
|
GROUP BY c.id_connections
|
||||||
ORDER BY c.date_add DESC';
|
ORDER BY c.date_add DESC';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = 'SELECT c.id_guest, c.ip_address, c.date_add, c.http_referer
|
$sql = 'SELECT c.id_guest, c.ip_address, c.date_add, c.http_referer, "-" as page
|
||||||
FROM `'._DB_PREFIX_.'connections` c
|
FROM `'._DB_PREFIX_.'connections` c
|
||||||
INNER JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
|
INNER JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest
|
||||||
WHERE (g.id_customer IS NULL OR g.id_customer = 0)
|
WHERE (g.id_customer IS NULL OR g.id_customer = 0)
|
||||||
'.Shop::addSqlRestriction(false, 'c').'
|
'.Shop::addSqlRestriction(false, 'c').'
|
||||||
AND TIME_TO_SEC(TIMEDIFF(NOW(), c.`date_add`)) < 900
|
AND TIME_TO_SEC(TIMEDIFF(NOW(), c.`date_add`)) < 900
|
||||||
|
'.($maintenance_ips ? 'AND c.ip_address NOT IN ('.preg_replace('/[^,0-9]/', '', $maintenance_ips).')' : '').'
|
||||||
ORDER BY c.date_add DESC';
|
ORDER BY c.date_add DESC';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +192,12 @@ class StatsLive extends Module
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->html .= $this->l('There are no visitors online.');
|
$this->html .= $this->l('There are no visitors online.');
|
||||||
$this->html .= '</fieldset>';
|
$this->html .= '</fieldset>
|
||||||
|
<br />
|
||||||
|
<fieldset><legend>'.$this->l('Notice').'</legend>
|
||||||
|
'.$this->l('Maintenance IP(s) are excluded from the online visitors.').'<br />
|
||||||
|
<a href="index.php?controller=AdminMaintenance&token='.Tools::getAdminTokenLite('AdminMaintenance').'">'.$this->l('Add or remove an IP address.').'</a>
|
||||||
|
</fieldset>';
|
||||||
|
|
||||||
return $this->html;
|
return $this->html;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user