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::queryFirst('SELECT data FROM notification_sample WHERE type = :type LIMIT 1', ['type' => $type]); Header('Content-Type: application/json'); if ($res === false) { echo '{}'; } else { echo $res['data']; } } } }