summaryrefslogtreecommitdiffstats
path: root/application/controllers
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:13:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:13:17 +0000
commit968a206dff4631e1ecc8a489f7884d08648113aa (patch)
tree48747500fe157b459d74fac87e7114e6c846d215 /application/controllers
parentInitial commit. (diff)
downloadicingaweb2-module-audit-968a206dff4631e1ecc8a489f7884d08648113aa.tar.xz
icingaweb2-module-audit-968a206dff4631e1ecc8a489f7884d08648113aa.zip
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/controllers')
-rw-r--r--application/controllers/ConfigController.php23
-rw-r--r--application/controllers/LogController.php51
2 files changed, 74 insertions, 0 deletions
diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php
new file mode 100644
index 0000000..5e6a31a
--- /dev/null
+++ b/application/controllers/ConfigController.php
@@ -0,0 +1,23 @@
+<?php
+
+/* Icinga Web 2 | (c) 2018 Icinga Development Team | GPLv2+ */
+
+namespace Icinga\Module\Audit\Controllers;
+
+use Icinga\Web\Controller;
+use Icinga\Module\Audit\Forms\Config\AuditLogConfigForm;
+
+class ConfigController extends Controller
+{
+ public function indexAction()
+ {
+ $form = new AuditLogConfigForm();
+ $form->setIniConfig($this->Config());
+ $form->setSubmitLabel($this->translate('Save Configuration'));
+
+ $form->handleRequest();
+
+ $this->view->form = $form;
+ $this->view->tabs = $this->Module()->getConfigTabs()->activate('config');
+ }
+}
diff --git a/application/controllers/LogController.php b/application/controllers/LogController.php
new file mode 100644
index 0000000..fc5e17c
--- /dev/null
+++ b/application/controllers/LogController.php
@@ -0,0 +1,51 @@
+<?php
+
+/* Icinga Web 2 | (c) 2018 Icinga Development Team | GPLv2+ */
+
+namespace Icinga\Module\Audit\Controllers;
+
+use Icinga\Data\ConfigObject;
+use Icinga\Protocol\File\FileReader;
+use Icinga\Web\Controller;
+
+class LogController extends Controller
+{
+ public function indexAction()
+ {
+ $this->assertPermission('audit/log');
+
+ if ($this->Config()->get('log', 'type') !== 'file') {
+ $this->httpNotFound('Page not found');
+ }
+
+ $this->getTabs()->add('audit/log', [
+ 'active' => true,
+ 'label' => $this->translate('Audit Log'),
+ 'url' => 'audit/log',
+ ]);
+
+ $file = $this->Config()->get('log', 'path', '/var/log/icingaweb2/audit.log');
+
+ if (! @file_exists($file)) {
+ $this->render('log-empty');
+
+ return;
+ }
+
+ $resource = new FileReader(new ConfigObject([
+ 'filename' => $file,
+ 'fields' => '/(?<!.)' // ^ can't handle multilines, don't ask *me* why this works
+ . '(?<datetime>[0-9]{4}(?:-[0-9]{2}){2}' // date
+ . 'T[0-9]{2}(?::[0-9]{2}){2}(?:[\+\-][0-9]{2}:[0-9]{2})?)' // time
+ . ' - (?<identity>.+)' // identity
+ . ' - (?<type>.+)' // type
+ . ' - (?<message>.+)' // message
+ . '(?!.)/msSU' // $ can't handle multilines, don't ...
+ ]));
+
+ $this->view->logData = $resource->select()->order('DESC');
+
+ $this->setupLimitControl();
+ $this->setupPaginationControl($this->view->logData);
+ }
+}