summaryrefslogtreecommitdiffstats
path: root/modules-available/syslog
diff options
context:
space:
mode:
authorSimon Rettberg2016-05-03 19:03:09 +0200
committerSimon Rettberg2016-05-03 19:03:09 +0200
commit50404f3b23b7fd6aeae4c9d2f6df0ea25e984e66 (patch)
tree05e99fdffa696434960d7c77966c0bc36d6339e8 /modules-available/syslog
parentSecond half of merge.... (diff)
downloadslx-admin-50404f3b23b7fd6aeae4c9d2f6df0ea25e984e66.tar.gz
slx-admin-50404f3b23b7fd6aeae4c9d2f6df0ea25e984e66.tar.xz
slx-admin-50404f3b23b7fd6aeae4c9d2f6df0ea25e984e66.zip
WIP
Diffstat (limited to 'modules-available/syslog')
-rw-r--r--modules-available/syslog/config.json4
-rw-r--r--modules-available/syslog/lang/de/module.json4
-rw-r--r--modules-available/syslog/lang/de/templates/page-syslog.json10
-rw-r--r--modules-available/syslog/lang/en/module.json11
-rw-r--r--modules-available/syslog/lang/en/templates/page-syslog.json10
-rw-r--r--modules-available/syslog/lang/pt/module.json11
-rw-r--r--modules-available/syslog/page.inc.php94
-rw-r--r--modules-available/syslog/templates/page-syslog.html58
8 files changed, 202 insertions, 0 deletions
diff --git a/modules-available/syslog/config.json b/modules-available/syslog/config.json
new file mode 100644
index 00000000..650ab2fe
--- /dev/null
+++ b/modules-available/syslog/config.json
@@ -0,0 +1,4 @@
+{
+ "category":"main.status",
+ "enabled":"true"
+}
diff --git a/modules-available/syslog/lang/de/module.json b/modules-available/syslog/lang/de/module.json
new file mode 100644
index 00000000..b9e8de49
--- /dev/null
+++ b/modules-available/syslog/lang/de/module.json
@@ -0,0 +1,4 @@
+{
+ "module_name": "Client-Log",
+ "page_title": "Lognachrichten gebooteter Clients"
+}
diff --git a/modules-available/syslog/lang/de/templates/page-syslog.json b/modules-available/syslog/lang/de/templates/page-syslog.json
new file mode 100644
index 00000000..49e94602
--- /dev/null
+++ b/modules-available/syslog/lang/de/templates/page-syslog.json
@@ -0,0 +1,10 @@
+{
+ "lang_client": "Client",
+ "lang_clientLog": "Client Log",
+ "lang_details": "Details",
+ "lang_event": "Ereignis",
+ "lang_filter": "Filter",
+ "lang_go": "Go",
+ "lang_not": "not",
+ "lang_when": "Wann"
+} \ No newline at end of file
diff --git a/modules-available/syslog/lang/en/module.json b/modules-available/syslog/lang/en/module.json
new file mode 100644
index 00000000..70107d9c
--- /dev/null
+++ b/modules-available/syslog/lang/en/module.json
@@ -0,0 +1,11 @@
+{
+ "lang_client": "Client",
+ "lang_clientLog": "Client Log",
+ "lang_details": "Details",
+ "lang_event": "Event",
+ "lang_filter": "Filter",
+ "lang_go": "go",
+ "lang_not": "no",
+ "lang_when": "When",
+ "module_name": "Server Log"
+} \ No newline at end of file
diff --git a/modules-available/syslog/lang/en/templates/page-syslog.json b/modules-available/syslog/lang/en/templates/page-syslog.json
new file mode 100644
index 00000000..71f61693
--- /dev/null
+++ b/modules-available/syslog/lang/en/templates/page-syslog.json
@@ -0,0 +1,10 @@
+{
+ "lang_client": "Client",
+ "lang_clientLog": "Client Log",
+ "lang_details": "Details",
+ "lang_event": "Event",
+ "lang_filter": "Filter",
+ "lang_go": "Go",
+ "lang_not": "not",
+ "lang_when": "When"
+} \ No newline at end of file
diff --git a/modules-available/syslog/lang/pt/module.json b/modules-available/syslog/lang/pt/module.json
new file mode 100644
index 00000000..0f7c5356
--- /dev/null
+++ b/modules-available/syslog/lang/pt/module.json
@@ -0,0 +1,11 @@
+{
+ "lang_client": "Cliente",
+ "lang_clientLog": "Log dos Clientes",
+ "lang_details": "Detalhes",
+ "lang_event": "Evento",
+ "lang_filter": "Filtro",
+ "lang_go": "Ir",
+ "lang_not": "n\u00e3o",
+ "lang_when": "Quando",
+ "module_name": "Log do Servidor"
+} \ No newline at end of file
diff --git a/modules-available/syslog/page.inc.php b/modules-available/syslog/page.inc.php
new file mode 100644
index 00000000..43a9bd28
--- /dev/null
+++ b/modules-available/syslog/page.inc.php
@@ -0,0 +1,94 @@
+<?php
+
+class Page_SysLog extends Page
+{
+
+ protected function doPreprocess()
+ {
+ User::load();
+
+ if (!User::isLoggedIn()) {
+ Message::addError('no-permission');
+ Util::redirect('?do=Main');
+ }
+ }
+
+ protected function doRender()
+ {
+ Render::setTitle('Client Log');
+ Render::addScriptBottom('bootstrap-tagsinput.min');
+
+ if (isset($_GET['filter'])) {
+ $filter = $_GET['filter'];
+ $not = isset($_GET['not']) ? 'NOT' : '';
+ } elseif (isset($_POST['filter'])) {
+ $filter = $_POST['filter'];
+ $not = isset($_POST['not']) ? 'NOT' : '';
+ Session::set('log_filter', $filter);
+ Session::set('log_not', $not);
+ Session::save();
+ } else {
+ $filter = Session::get('log_filter');
+ $not = Session::get('log_not') ? 'NOT' : '';
+ }
+ if (!empty($filter)) {
+ $filterList = explode(',', $filter);
+ $whereClause = array();
+ foreach ($filterList as $filterItem) {
+ $filterItem = preg_replace('/[^a-z0-9_\-]/', '', trim($filterItem));
+ if (empty($filterItem) || in_array($filterItem, $whereClause)) continue;
+ $whereClause[] = "'$filterItem'";
+ }
+ if (!empty($whereClause)) $whereClause = ' WHERE logtypeid ' . $not . ' IN (' . implode(', ', $whereClause) . ')';
+ }
+ if (!isset($whereClause) || empty($whereClause)) $whereClause = '';
+ if (Request::get('ip')) {
+ if (empty($whereClause))
+ $whereClause .= ' WHERE ';
+ else
+ $whereClause .= ' AND ';
+ $whereClause .= "clientip LIKE '" . preg_replace('/[^0-9\.\:]/', '', Request::get('ip')) . "%'";
+ }
+
+ $today = date('d.m.Y');
+ $yesterday = date('d.m.Y', time() - 86400);
+ $lines = array();
+ $paginate = new Paginate("SELECT logid, dateline, logtypeid, clientip, description, extra FROM clientlog $whereClause ORDER BY logid DESC", 50);
+ $res = $paginate->exec();
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $day = date('d.m.Y', $row['dateline']);
+ if ($day === $today) {
+ $day = Dictionary::translate('today');
+ } elseif ($day === $yesterday) {
+ $day = Dictionary::translate('yesterday');
+ }
+ $row['date'] = $day . date(' H:i', $row['dateline']);
+ $row['icon'] = $this->eventToIconName($row['logtypeid']);
+ $lines[] = $row;
+ }
+
+ $paginate->render('page-syslog', array(
+ 'filter' => $filter,
+ 'not' => $not,
+ 'list' => $lines
+ ));
+ }
+
+ private function eventToIconName($event)
+ {
+ switch ($event) {
+ case 'session-open':
+ return 'glyphicon-log-in';
+ case 'session-close':
+ return 'glyphicon-log-out';
+ case 'partition-swap':
+ return 'glyphicon-info-sign';
+ case 'partition-temp':
+ case 'smartctl-realloc':
+ return 'glyphicon-exclamation-sign';
+ default:
+ return 'glyphicon-minus';
+ }
+ }
+
+}
diff --git a/modules-available/syslog/templates/page-syslog.html b/modules-available/syslog/templates/page-syslog.html
new file mode 100644
index 00000000..98e94291
--- /dev/null
+++ b/modules-available/syslog/templates/page-syslog.html
@@ -0,0 +1,58 @@
+<h1>{{lang_clientLog}}</h1>
+<form method="post" action="?do=SysLog">
+ <input type="hidden" name="token" value="{{token}}">
+ <div class="input-group">
+ <span class="input-group-addon">{{lang_filter}}</span>
+ <input id="filterstring" type="text" placeholder="id" value="{{filter}}" name="filter" data-role="tagsinput" />
+ <span class="input-group-addon">
+ <input type="checkbox" name="not" {{#not}}checked="checked"{{/not}}> {{lang_not}}
+ </span>
+ <span class="input-group-btn">
+ <button class="btn btn-default" type="submit">{{lang_go}}</button>
+ </span>
+ </div>
+</form>
+{{{pagenav}}}
+<table class="table table-striped table-condensed">
+ <thead>
+ <th width="1"></th>
+ <th>{{lang_when}}</th>
+ <th>{{lang_client}}</th>
+ <th>{{lang_event}}</th>
+ <th width="1">{{lang_details}}</th>
+ </thead>
+ <tbody>
+ {{#list}}
+ <tr>
+ <td><span class="glyphicon {{icon}}" title="{{logtypeid}}" onclick="$('#filterstring').tagsinput('add', '{{logtypeid}}')"></span></td>
+ <td class="text-right" nowrap="nowrap">{{date}}</td>
+ <td>{{clientip}}</td>
+ <td>{{description}}</td>
+ <td>{{#extra}}
+ <a class="btn btn-default btn-xs pull-left" onclick="$('#details-body').html($('#extra-{{logid}}').html())" data-toggle="modal" data-target="#myModal">&raquo;</a>
+ <div class="hidden" id="extra-{{logid}}">{{extra}}</div>
+ {{/extra}}</td>
+ </tr>
+ {{/list}}
+ </tbody>
+</table>
+{{{pagenav}}}
+
+<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+ <div class="modal-dialog modal-lg">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+ <h4 class="modal-title" id="myModalLabel">{{lang_details}}</h4>
+ </div>
+ <div class="modal-body">
+ <pre id="details-body"></pre>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ </div>
+ </div>
+ </div>
+</div>
+
+