Skip to content

Commit a40d6fb

Browse files
committed
stats improvements
1 parent 9702b7a commit a40d6fb

File tree

2 files changed

+97
-61
lines changed

2 files changed

+97
-61
lines changed

app/site/controllers/Admin/Stats.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ protected function getTemplateData()
5757
'top_visitors' => 'SELECT ip_address, COUNT(id) AS cnt FROM request_log GROUP BY ip_address ORDER BY cnt DESC LIMIT 10',
5858
'most_viewed' => 'SELECT url, COUNT(id) AS cnt FROM request_log GROUP BY url ORDER BY cnt DESC LIMIT 10',
5959
'top_errors' => 'SELECT response_code, url, ip_address, COUNT(id) AS cnt FROM request_log WHERE response_code NOT IN (200, 301, 302) GROUP BY url, response_code, ip_address ORDER BY cnt DESC LIMIT 10',
60+
'top_scanners' => 'SELECT ip_address, GROUP_CONCAT(DISTINCT(response_code)) AS codes, COUNT(id) AS cnt FROM request_log WHERE response_code NOT IN (200, 301, 302) GROUP BY ip_address ORDER BY cnt DESC LIMIT 10',
6061
];
6162

6263
foreach ($queries as $key => $query) {

templates/admin/stats.php

Lines changed: 96 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,99 @@
11
<?php
22
$this->layout('admin::layout', ['title' => $controller->getPageTitle()] + get_defined_vars()) ?>
33

4-
5-
<h3>Top Visitors</h3>
6-
<table class="table table-striped" width="100%" cellpadding="0" cellspacing="0">
7-
<thead>
8-
<tr>
9-
<th>Ip Address</th>
10-
<th>Visits</th>
11-
</tr>
12-
</thead>
13-
<tbody>
14-
<?php foreach ($top_visitors as $row) : ?>
15-
<tr>
16-
<td><?= $row['ip_address'];?></td>
17-
<td><?= $row['cnt'];?></td>
18-
</tr>
19-
<?php endforeach;?>
20-
</tbody>
21-
</table>
22-
23-
24-
<h3>Most viewed</h3>
25-
<table class="table table-striped" width="100%" cellpadding="0" cellspacing="0">
26-
<thead>
27-
<tr>
28-
<th>Url</th>
29-
<th>Visits</th>
30-
</tr>
31-
</thead>
32-
<tbody>
33-
<?php foreach ($most_viewed as $row) : ?>
34-
<tr>
35-
<td><?= $row['url'];?></td>
36-
<td><?= $row['cnt'];?></td>
37-
</tr>
38-
<?php endforeach;?>
39-
</tbody>
40-
</table>
41-
42-
43-
<h3>Top Errors</h3>
44-
<table class="table table-striped" width="100%" cellpadding="0" cellspacing="0">
45-
<thead>
46-
<tr>
47-
<th>Url</th>
48-
<th>Ip Address</th>
49-
<th>Response code</th>
50-
<th>Visits</th>
51-
</tr>
52-
</thead>
53-
<tbody>
54-
<?php foreach ($top_errors as $row) : ?>
55-
<tr>
56-
<td><?= $row['url'];?></td>
57-
<td><?= $row['ip_address'];?></td>
58-
<td><?= $row['response_code'];?></td>
59-
<td><?= $row['cnt'];?></td>
60-
</tr>
61-
<?php endforeach;?>
62-
</tbody>
63-
</table>
64-
4+
<nav>
5+
<div class="nav nav-tabs" id="nav-tab" role="tablist">
6+
<a class="nav-item nav-link active" id="nav-visitors-tab" data-toggle="tab" href="#nav-visitors" role="tab" aria-controls="nav-visitors" aria-selected="true">Top Visitors</a>
7+
<a class="nav-item nav-link" id="nav-viewed-tab" data-toggle="tab" href="#nav-viewed" role="tab" aria-controls="nav-viewed" aria-selected="false">Most viewed</a>
8+
<a class="nav-item nav-link" id="nav-errors-tab" data-toggle="tab" href="#nav-errors" role="tab" aria-controls="nav-errors" aria-selected="false">Top Errors</a>
9+
<a class="nav-item nav-link" id="nav-scanners-tab" data-toggle="tab" href="#nav-scanners" role="tab" aria-controls="nav-scanners" aria-selected="false">Top Scanners</a>
10+
</div>
11+
</nav>
12+
<div class="tab-content" id="nav-tabContent">
13+
<div class="tab-pane fade show active" id="nav-visitors" role="tabpanel" aria-labelledby="nav-visitors-tab">
14+
<br />
15+
<h3>Top Visitors</h3>
16+
<table class="table table-striped" width="100%" cellpadding="0" cellspacing="0">
17+
<thead>
18+
<tr>
19+
<th>Ip Address</th>
20+
<th>Visits</th>
21+
</tr>
22+
</thead>
23+
<tbody>
24+
<?php foreach ($top_visitors as $row) : ?>
25+
<tr>
26+
<td><?= $row['ip_address'];?></td>
27+
<td><?= $row['cnt'];?></td>
28+
</tr>
29+
<?php endforeach;?>
30+
</tbody>
31+
</table>
32+
</div>
33+
<div class="tab-pane fade show" id="nav-viewed" role="tabpanel" aria-labelledby="nav-viewed-tab">
34+
<br />
35+
<h3>Most viewed</h3>
36+
<table class="table table-striped" width="100%" cellpadding="0" cellspacing="0">
37+
<thead>
38+
<tr>
39+
<th>Url</th>
40+
<th>Visits</th>
41+
</tr>
42+
</thead>
43+
<tbody>
44+
<?php foreach ($most_viewed as $row) : ?>
45+
<tr>
46+
<td><?= $row['url'];?></td>
47+
<td><?= $row['cnt'];?></td>
48+
</tr>
49+
<?php endforeach;?>
50+
</tbody>
51+
</table>
52+
</div>
53+
<div class="tab-pane fade" id="nav-errors" role="tabpanel" aria-labelledby="nav-errors-tab">
54+
<br />
55+
<h3>Top Errors</h3>
56+
<table class="table table-striped" width="100%" cellpadding="0" cellspacing="0">
57+
<thead>
58+
<tr>
59+
<th>Url</th>
60+
<th>Ip Address</th>
61+
<th>Response code</th>
62+
<th>Visits</th>
63+
</tr>
64+
</thead>
65+
<tbody>
66+
<?php foreach ($top_errors as $row) : ?>
67+
<tr>
68+
<td><?= $row['url'];?></td>
69+
<td><?= $row['ip_address'];?></td>
70+
<td><?= $row['response_code'];?></td>
71+
<td><?= $row['cnt'];?></td>
72+
</tr>
73+
<?php endforeach;?>
74+
</tbody>
75+
</table>
76+
</div>
77+
<div class="tab-pane fade" id="nav-scanners" role="tabpanel" aria-labelledby="nav-scanners-tab">
78+
<br />
79+
<h3>Top Scanners</h3>
80+
<table class="table table-striped" width="100%" cellpadding="0" cellspacing="0">
81+
<thead>
82+
<tr>
83+
<th>Ip Address</th>
84+
<th>Response codes</th>
85+
<th>Visits</th>
86+
</tr>
87+
</thead>
88+
<tbody>
89+
<?php foreach ($top_scanners as $row) : ?>
90+
<tr>
91+
<td><?= $row['ip_address'];?></td>
92+
<td><?= $row['codes'];?></td>
93+
<td><?= $row['cnt'];?></td>
94+
</tr>
95+
<?php endforeach;?>
96+
</tbody>
97+
</table>
98+
</div>
99+
</div>

0 commit comments

Comments
 (0)