summaryrefslogtreecommitdiffstats
path: root/modules/syslog.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2013-12-17 15:22:57 +0100
committerSimon Rettberg2013-12-17 15:22:57 +0100
commit4981c766a8a1b74e119e9f3d5cc38c3b8210568a (patch)
tree595cb32b215a0b719f7f401e6e7ddb12ee8efbb6 /modules/syslog.inc.php
parentAdded client log feature/view (diff)
downloadslx-admin-4981c766a8a1b74e119e9f3d5cc38c3b8210568a.tar.gz
slx-admin-4981c766a8a1b74e119e9f3d5cc38c3b8210568a.tar.xz
slx-admin-4981c766a8a1b74e119e9f3d5cc38c3b8210568a.zip
Remote client logging
Diffstat (limited to 'modules/syslog.inc.php')
-rw-r--r--modules/syslog.inc.php36
1 files changed, 33 insertions, 3 deletions
diff --git a/modules/syslog.inc.php b/modules/syslog.inc.php
index ccbf1b32..348c40bd 100644
--- a/modules/syslog.inc.php
+++ b/modules/syslog.inc.php
@@ -9,14 +9,44 @@ if (!User::isLoggedIn()) {
function render_module()
{
Render::setTitle('Client Log');
+
+ $filter = '';
+ $not = '';
+ if (isset($_POST['filter'])) $filter = $_POST['filter'];
+ if (!empty($filter)) {
+ $parts = explode(' ', $filter);
+ $opt = array();
+ foreach ($parts as $part) {
+ $part = preg_replace('/[^a-z0-9_\-]/', '', trim($part));
+ if (empty($part) || in_array($part, $opt)) continue;
+ $opt[] = "'$part'";
+ }
+ if (isset($_POST['not'])) $not = 'NOT';
+ if (!empty($opt)) $opt = ' WHERE logtypeid ' . $not . ' IN (' . implode(', ', $opt) . ')';
+ }
+ if (!isset($opt) || empty($opt)) $opt = '';
+ $today = date('d.m.Y');
+ $yesterday = date('d.m.Y', time() - 86400);
$lines = array();
- $res = Database::simpleQuery('SELECT logid, dateline, logtypeid, clientip, description, extra FROM clientlog ORDER BY logid DESC LIMIT 200');
+ $res = Database::simpleQuery("SELECT logid, dateline, logtypeid, clientip, description, extra FROM clientlog $opt ORDER BY logid DESC LIMIT 200");
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $row['date'] = date('d.m.Y H:i', $row['dateline']);
+ $day = date('d.m.Y', $row['dateline']);
+ // TODO: No output strings in source files!
+ if ($day === $today) {
+ $day = 'Heute ';
+ } elseif ($day === $yesterday) {
+ $day = 'Gestern ';
+ }
+ $row['date'] = $day . date('H:i', $row['dateline']);
$lines[] = $row;
}
- Render::addTemplate('page-syslog', array('token' => Session::get('token'), 'list' => $lines));
+ Render::addTemplate('page-syslog', array(
+ 'token' => Session::get('token'),
+ 'filter' => $filter,
+ 'not' => $not,
+ 'list' => $lines
+ ));
}