summaryrefslogtreecommitdiffstats
path: root/modules/syslog.inc.php
diff options
context:
space:
mode:
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
+ ));
}