show = Request::any('show', false, 'string'); if ($this->show === false && Request::isGet()) { if (User::hasPermission('view')) { $this->show = 'log'; } elseif (User::hasPermission('filter.rules.view')) { $this->show = 'rules'; } else { User::assertPermission('filter.transports.view'); $this->show = 'transports'; } } if ($this->show !== false) { $this->show = preg_replace('/[^a-z0-9_\-]/', '', $this->show); if (!file_exists('modules/eventlog/pages/' . $this->show . '.inc.php')) { Message::addError('main.invalid-action', $this->show); Util::redirect('?do=eventlog'); } else { require_once 'modules/eventlog/pages/' . $this->show . '.inc.php'; SubPage::doPreprocess(); } } if (Request::isPost()) { Util::redirect('?do=eventlog&show=' . $this->show); } } protected function doRender() { Render::addTemplate('page-header', ['active_' . $this->show => 'active']); if ($this->show !== false) { SubPage::doRender(); } } protected function doAjax() { // XXX Should go into rules.inc.php User::assertPermission('filter.rules.edit'); if (Request::any('show') === 'rules') { $type = Request::any('type', Request::REQUIRED, 'string'); $res = Database::simpleQuery('SELECT data FROM notification_sample WHERE type = :type ORDER BY dateline DESC LIMIT 5', ['type' => $type]); $output = []; foreach ($res as $row) { $row = json_decode($row['data'], true); if (is_array($row)) { $output += $row; } } ksort($output); Header('Content-Type: application/json'); echo json_encode($output); } } }