From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- .../controllers/ApplicationStateController.php | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 application/controllers/ApplicationStateController.php (limited to 'application/controllers/ApplicationStateController.php') diff --git a/application/controllers/ApplicationStateController.php b/application/controllers/ApplicationStateController.php new file mode 100644 index 0000000..b828ca2 --- /dev/null +++ b/application/controllers/ApplicationStateController.php @@ -0,0 +1,95 @@ +_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + } + + public function indexAction() + { + if ($this->Auth()->isAuthenticated()) { + if (isset($_COOKIE['icingaweb2-session'])) { + $last = (int) $_COOKIE['icingaweb2-session']; + } else { + $last = 0; + } + $now = time(); + if ($last + 600 < $now) { + Session::getSession()->write(); + $params = session_get_cookie_params(); + setcookie( + 'icingaweb2-session', + $now, + 0, + $params['path'], + $params['domain'], + $params['secure'], + $params['httponly'] + ); + $_COOKIE['icingaweb2-session'] = $now; + } + $announcementCookie = new AnnouncementCookie(); + $announcementRepo = new AnnouncementIniRepository(); + if ($announcementCookie->getEtag() !== $announcementRepo->getEtag()) { + $announcementCookie + ->setEtag($announcementRepo->getEtag()) + ->setNextActive($announcementRepo->findNextActive()); + $this->getResponse()->setCookie($announcementCookie); + $this->getResponse()->setHeader('X-Icinga-Announcements', 'refresh', true); + } else { + $nextActive = $announcementCookie->getNextActive(); + if ($nextActive && $nextActive <= $now) { + $announcementCookie->setNextActive($announcementRepo->findNextActive()); + $this->getResponse()->setCookie($announcementCookie); + $this->getResponse()->setHeader('X-Icinga-Announcements', 'refresh', true); + } + } + } + + RememberMe::removeExpired(); + } + + public function summaryAction() + { + if ($this->Auth()->isAuthenticated()) { + $this->getResponse()->setBody((string) Widget::create('ApplicationStateMessages')); + } + } + + public function acknowledgeMessageAction() + { + if (! $this->Auth()->isAuthenticated()) { + $this->getResponse() + ->setHttpResponseCode(401) + ->sendHeaders(); + exit; + } + + $this->assertHttpMethod('POST'); + + $this->getResponse()->setHeader('X-Icinga-Container', 'ignore', true); + + (new AcknowledgeApplicationStateMessageForm())->handleRequest(); + } +} -- cgit v1.2.3