Bot stats and LIMIT to top pages.
This commit is contained in:
parent
7309947a74
commit
afee40b5a9
22
stats.php
22
stats.php
|
@ -49,15 +49,15 @@ GROUP BY date', [':site_id'=>$site['id'], ':date_min'=>date('Y-m-d', strtotime('
|
||||||
FROM visits
|
FROM visits
|
||||||
WHERE site_id=?
|
WHERE site_id=?
|
||||||
GROUP BY path
|
GROUP BY path
|
||||||
ORDER BY visits DESC', [$site['id']])->fetchAll();
|
ORDER BY visits DESC LIMIT 10', [$site['id']])->fetchAll();
|
||||||
$byBrowsers = $pdo->run('SELECT browser, COUNT(*) as visits
|
$byBrowsers = $pdo->run('SELECT browser, COUNT(*) as visits
|
||||||
FROM visits
|
FROM visits
|
||||||
WHERE site_id=?
|
WHERE site_id=? AND is_bot!=1
|
||||||
GROUP BY browser
|
GROUP BY browser
|
||||||
ORDER BY visits DESC', [$site['id']])->fetchAll();
|
ORDER BY visits DESC', [$site['id']])->fetchAll();
|
||||||
$byPlatforms = $pdo->run('SELECT platform, COUNT(*) as visits
|
$byPlatforms = $pdo->run('SELECT platform, COUNT(*) as visits
|
||||||
FROM visits
|
FROM visits
|
||||||
WHERE site_id=?
|
WHERE site_id=? AND is_bot!=1
|
||||||
GROUP BY platform
|
GROUP BY platform
|
||||||
ORDER BY visits DESC', [$site['id']])->fetchAll();
|
ORDER BY visits DESC', [$site['id']])->fetchAll();
|
||||||
$byRefs = $pdo->run('SELECT ref, COUNT(*) as visits
|
$byRefs = $pdo->run('SELECT ref, COUNT(*) as visits
|
||||||
|
@ -66,6 +66,12 @@ WHERE site_id=? AND ref!=""
|
||||||
GROUP BY ref
|
GROUP BY ref
|
||||||
ORDER BY visits DESC', [$site['id']])->fetchAll();
|
ORDER BY visits DESC', [$site['id']])->fetchAll();
|
||||||
|
|
||||||
|
$byBots = $pdo->run('SELECT browser, COUNT(*) as visits
|
||||||
|
FROM visits
|
||||||
|
WHERE site_id=? AND is_bot=1
|
||||||
|
GROUP BY browser
|
||||||
|
ORDER BY visits DESC', [$site['id']])->fetchAll();
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$error = 'We do not track this site.';
|
$error = 'We do not track this site.';
|
||||||
|
@ -150,7 +156,7 @@ ORDER BY visits DESC');
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (count($byPaths)) {
|
if (count($byPaths)) {
|
||||||
echo '<h2>Top visited pages</h2>';
|
echo '<h2>Top '.count($byPaths).' visited pages</h2>';
|
||||||
foreach ($byPaths as $page) {
|
foreach ($byPaths as $page) {
|
||||||
echo '<div><a href="//' . $site['host'] . $page['path'] . '">'.$page['path'].'</a>';
|
echo '<div><a href="//' . $site['host'] . $page['path'] . '">'.$page['path'].'</a>';
|
||||||
echo ' ' . pct($page['visits'], $totalVisits) . '%<div class="progress"><div style="width: '.pct($page['visits'], $totalVisits).'%"></div></div>';
|
echo ' ' . pct($page['visits'], $totalVisits) . '%<div class="progress"><div style="width: '.pct($page['visits'], $totalVisits).'%"></div></div>';
|
||||||
|
@ -181,6 +187,14 @@ if (count($byRefs)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($byBots)) {
|
||||||
|
echo '<h2>Top bots</h2>';
|
||||||
|
foreach ($byBots as $page) {
|
||||||
|
echo '<div>'.$page['browser'];
|
||||||
|
echo ' ' . pct($page['visits'], $totalVisits) . '%<div class="progress"><div style="width: '.pct($page['visits'], $totalVisits).'%"></div></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
Loading…
Reference in New Issue