summaryrefslogtreecommitdiffstats
path: root/modules-available/syslog/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2017-07-06 14:39:06 +0200
committerSimon Rettberg2017-07-06 14:39:06 +0200
commit75c4c1c22c9f44b93602270e5b0cb521ec2aad3b (patch)
treedb7e0fecf3199bd496232e430edf8910eba8d980 /modules-available/syslog/page.inc.php
parent[roomplanner] Support : in mac search, use small display of client (diff)
downloadslx-admin-75c4c1c22c9f44b93602270e5b0cb521ec2aad3b.tar.gz
slx-admin-75c4c1c22c9f44b93602270e5b0cb521ec2aad3b.tar.xz
slx-admin-75c4c1c22c9f44b93602270e5b0cb521ec2aad3b.zip
[syslog] Improved filtering with suggestions from existing log
Diffstat (limited to 'modules-available/syslog/page.inc.php')
-rw-r--r--modules-available/syslog/page.inc.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/modules-available/syslog/page.inc.php b/modules-available/syslog/page.inc.php
index 486e0248..f2bc4854 100644
--- a/modules-available/syslog/page.inc.php
+++ b/modules-available/syslog/page.inc.php
@@ -15,6 +15,12 @@ class Page_SysLog extends Page
protected function doRender()
{
+ $cutoff = strtotime('-1 month');
+ $res = Database::simpleQuery("SELECT logtypeid, Count(*) AS counter FROM clientlog WHERE dateline > $cutoff GROUP BY logtypeid ORDER BY counter ASC");
+ $types = array();
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $types[$row['logtypeid']] = $row;
+ }
if (isset($_GET['filter'])) {
$filter = $_GET['filter'];
$not = isset($_GET['not']) ? 'NOT' : '';
@@ -35,6 +41,9 @@ class Page_SysLog extends Page
$filterItem = preg_replace('/[^a-z0-9_\-]/', '', trim($filterItem));
if (empty($filterItem) || in_array($filterItem, $whereClause)) continue;
$whereClause[] = "'$filterItem'";
+ if (!isset($types[$filterItem])) {
+ $types[$filterItem] = ['logtypeid' => $filterItem, 'counter' => ''];
+ }
}
if (!empty($whereClause)) $whereClause = ' WHERE logtypeid ' . $not . ' IN (' . implode(', ', $whereClause) . ')';
}
@@ -67,7 +76,8 @@ class Page_SysLog extends Page
$paginate->render('page-syslog', array(
'filter' => $filter,
'not' => $not,
- 'list' => $lines
+ 'list' => $lines,
+ 'types' => json_encode(array_values($types)),
));
}