mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Fetch up to 20 clients and limit the list to 10 results in PHP
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
+5
-2
@@ -94,12 +94,13 @@ if (isset($_GET['topClients']) && $auth)
|
||||
{
|
||||
$limit = "WHERE timestamp <= ".$_GET["until"];
|
||||
}
|
||||
$results = $db->query('SELECT client,count(client) FROM queries '.$limit.' GROUP by client order by count(client) desc limit 10');
|
||||
$results = $db->query('SELECT client,count(client) FROM queries '.$limit.' GROUP by client order by count(client) desc limit 20');
|
||||
|
||||
$clients = array();
|
||||
$num = 0;
|
||||
|
||||
if(!is_bool($results))
|
||||
while ($row = $results->fetchArray())
|
||||
while (($row = $results->fetchArray()) && $num < 10)
|
||||
{
|
||||
// Convert client to lower case
|
||||
$c = strtolower($row[0]);
|
||||
@@ -112,6 +113,8 @@ if (isset($_GET['topClients']) && $auth)
|
||||
{
|
||||
// Entry does not yet exist
|
||||
$clients[$c] = intval($row[1]);
|
||||
// Increase number of clients
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
$result = array('top_sources' => $clients);
|
||||
|
||||
Reference in New Issue
Block a user