From 968a206dff4631e1ecc8a489f7884d08648113aa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:13:17 +0200 Subject: Adding upstream version 1.0.2. Signed-off-by: Daniel Baumann --- application/controllers/ConfigController.php | 23 +++++++++++++ application/controllers/LogController.php | 51 ++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 application/controllers/ConfigController.php create mode 100644 application/controllers/LogController.php (limited to 'application/controllers') 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 @@ +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 @@ +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' => '/(?[0-9]{4}(?:-[0-9]{2}){2}' // date + . 'T[0-9]{2}(?::[0-9]{2}){2}(?:[\+\-][0-9]{2}:[0-9]{2})?)' // time + . ' - (?.+)' // identity + . ' - (?.+)' // type + . ' - (?.+)' // message + . '(?!.)/msSU' // $ can't handle multilines, don't ... + ])); + + $this->view->logData = $resource->select()->order('DESC'); + + $this->setupLimitControl(); + $this->setupPaginationControl($this->view->logData); + } +} -- cgit v1.2.3