/** * @param CFilterChain $filterChain * @return bool */ protected function preFilter($filterChain) { return parent::preFilter($filterChain); /** * code beyond crashes from time to time because of some mistake in either yii or php regexp engine. */ if (Yii::app()->request->getIsAjaxRequest()) { return parent::preFilter($filterChain); } /** @var $session CHttpSession */ $session = Yii::app()->session; $action = new LogUserAction(); $action->userId = Yii::app()->user->id; $action->method = Yii::app()->request->getRequestType(); $action->get_data = serialize($_GET); $action->post_data = serialize($_POST); $action->session = Yii::app()->session->sessionID; $action->request = Yii::app()->request->getRequestUri(); $action->controller = Yii::app()->controller->id; $action->action = Yii::app()->controller->action->id; $action->ip = Yii::app()->request->getUserHostAddress(); $action->referer = Yii::app()->request->getUrlReferrer(); $action->previousActionId = $session->contains('lastActionId') ? $session->get('lastActionId') : '0'; $action->save(false); $session->add('lastActionId', $action->id); return parent::preFilter($filterChain); }
function run() { try { $this->_filter->routeStartup(); //路由开始 $action = $this->_router->route(); $action = $this->_filter->routeShutdown($action); //路由关闭 $action = $this->_filter->dispatchStartup($action); //方法调度 $method = $action->_method; $action->{$method}(); $this->_filter->dispatchShutdown(); //方法调度完成 $action->response(); $this->_filter->endReturn(); //返回结果 } catch (CException $e) { //异常处理 if ($e->exceptionType == 'biz') { //业务逻辑异常--抛到业务层处理 $actionclass = $e->exActionMethod . '_Action'; $action = CFactory::instance($actionclass, $e->params, true, true); $method = $action->_method; $action->{$method}(); $action->response(); $this->_filter->endReturn(); //返回结果 } else { //核心异常--直接抛出异常 throw new Exception($e); } } }
protected function preFilter($filterChain) { /** @var CHttpSession */ self::$session = Yii::app()->session; if (self::$session->get('appointmentBuilder')) { self::$current = self::$session->get('appointmentBuilder'); } return parent::preFilter($filterChain); }
/** * @param CFilterChain $filterChain * @return bool * @throws CHttpException */ protected function preFilter($filterChain) { $app = Yii::app(); /** @var AuditModule $audit */ $audit = $app->getModule('audit'); if (!in_array($app->getUser()->getName(), $audit->adminUsers)) { throw new CHttpException(403, 'You are not allowed to access this page.'); } return parent::preFilter($filterChain); }
/** * Performs the pre-action filtering. * @param CFilterChain $filterChain the filter chain that the filter is on. * @return boolean whether the filtering process should continue and the action * should be executed. */ protected function preFilter($filterChain) { $controller = $filterChain->controller; if (isset($_GET['id']) && method_exists($controller, 'loadModel')) { $model = $controller->loadModel($_GET['id']); $url = $model->getUrl(); if (strpos(Yii::app()->request->getRequestUri(), $url) === false) { $controller->redirect($url, true, 301); } } return parent::preFilter($filterChain); }
/** * @param CFilterChain $filterChain * @return bool * @throws CHttpException */ protected function preFilter($filterChain) { $app = Yii::app(); /** @var EmailModule $email */ $email = $app->getModule('email'); $user = $app->getUser(); $ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : Yii::app()->request->userHostAddress; if (!$this->allowUser($email, $user) || !$this->allowIp($email, $ip)) { throw new CHttpException(403, 'You are not allowed to access this page.'); } return parent::preFilter($filterChain); }
protected function postFilter($filterChain) { if ($this->doCompress) { if (!$this->gzip) { $content = ob_get_clean(); if ($this->doStripNewlines) { $content = str_replace(array("\n", "\r"), '', $content); } echo $this->compressHtml($content); } } parent::postFilter($filterChain); }
/** * @param CFilterChain $filterChain * @return bool * @throws CHttpException */ protected function preFilter($filterChain) { $app = Yii::app(); $bIsAdmin = false; if (function_exists('isAdminUser')) { $bIsAdmin = isAdminUser(); } else { /** @var emailModule $email */ $email = $app->getModule('email'); if (in_array($app->getUser()->getName(), $email->adminUsers)) { $bIsAdmin = true; } } if (!$bIsAdmin) { throw new CHttpException(403, 'You are not allowed to access this page.'); } return parent::preFilter($filterChain); }
public function init() { parent::init(); }
function __construct() { parent::__construct(); }
** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $hostInventoryWidget = (new CWidget())->setTitle(_('Host inventory')); $hostInventoryWidget->setControls($rForm = (new CForm('get'))->addItem((new CList())->addItem([_('Group') . SPACE, $this->data['pageFilter']->getGroupsCB()]))); // filter $filterForm = new CFilter('web.hostinventories.filter.state'); $filterColumn = new CFormList(); // getting inventory fields to make a drop down $inventoryFields = getHostInventories(true); // 'true' means list should be ordered by title $inventoryFieldsComboBox = new CComboBox('filter_field', $this->data['filterField']); foreach ($inventoryFields as $inventoryField) { $inventoryFieldsComboBox->addItem($inventoryField['db_field'], $inventoryField['title']); } $filterColumn->addRow(_('Field'), [$inventoryFieldsComboBox, (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), new CComboBox('filter_exact', $this->data['filterExact'], null, [0 => _('like'), 1 => _('exactly')]), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), (new CTextBox('filter_field_value', $this->data['filterFieldValue']))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH)]); $filterForm->addColumn($filterColumn); $hostInventoryWidget->addItem($filterForm); $table = (new CTableInfo())->setHeader([make_sorting_header(_('Host'), 'name', $this->data['sort'], $this->data['sortorder']), _('Group'), make_sorting_header(_('Name'), 'pr_name', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Type'), 'pr_type', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('OS'), 'pr_os', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Serial number A'), 'pr_serialno_a', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Tag'), 'pr_tag', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('MAC address A'), 'pr_macaddress_a', $this->data['sort'], $this->data['sortorder'])]); foreach ($this->data['hosts'] as $host) { $hostGroups = []; foreach ($host['groups'] as $group) {
protected function postFilter($filterChain) { $out = ob_get_clean(); echo preg_replace("~>(\\s+|\t+|\n+)<~", "><", $out); parent::postFilter($filterChain); }
$historyWidget->addItem([new CSpan($text), BR()]); } $screen = $screen->get(); $pre = new CPre(); foreach ($screen as $text) { $pre->addItem([$text, BR()]); } $historyWidget->addItem($pre); } else { $historyWidget->setTitle($header['left'])->setControls($header['right']); if (isset($this->data['iv_string'][$this->data['value_type']])) { $filterForm->addNavigator(); } if (in_array($this->data['action'], [HISTORY_VALUES, HISTORY_GRAPH, HISTORY_BATCH_GRAPH])) { if (!isset($filterForm)) { $filterForm = new CFilter('web.history.filter.state'); } // display the graph type filter for graphs with multiple items if ($this->data['action'] == HISTORY_BATCH_GRAPH) { $filterForm->addColumn((new CFormList())->addRow(_('Graph type'), (new CRadioButtonList('graphtype', (int) $this->data['graphtype']))->addValue(_('Normal'), GRAPH_TYPE_NORMAL)->addValue(_('Stacked'), GRAPH_TYPE_STACKED)->setModern(true))); $filterForm->removeButtons(); $filterForm->addVar('fullscreen', $this->data['fullscreen']); $filterForm->addVar('action', $this->data['action']); $filterForm->addVar('itemids', $this->data['itemids']); } $filterForm->addNavigator(); $historyWidget->addItem($filterForm); } $historyWidget->addItem($screen->get()); CScreenBuilder::insertScreenStandardJs(['timeline' => $screen->timeline, 'profileIdx' => $screen->profileIdx]); }
** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $auditWidget = (new CWidget())->setTitle(_('Action log')); // create filter $filterForm = new CFilter('web.auditacts.filter.state'); $filterColumn = new CFormList(); $filterColumn->addRow(_('Recipient'), [(new CTextBox('alias', $this->data['alias']))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), (new CButton('btn1', _('Select')))->addClass(ZBX_STYLE_BTN_GREY)->onClick('return PopUp("popup.php?dstfrm=zbx_filter&dstfld1=alias&srctbl=users&srcfld1=alias");')]); $filterForm->addColumn($filterColumn); $filterForm->addNavigator(); $auditWidget->addItem($filterForm); // create form $auditForm = (new CForm('get'))->setName('auditForm'); // create table $auditTable = (new CTableInfo())->setHeader([_('Time'), _('Action'), _('Type'), _('Recipient(s)'), _('Message'), _('Status'), _('Info')]); foreach ($this->data['alerts'] as $alert) { $mediatype = array_pop($alert['mediatypes']); if ($alert['status'] == ALERT_STATUS_SENT) { $status = $alert['alerttype'] == ALERT_TYPE_MESSAGE ? (new CSpan(_('Sent')))->addClass(ZBX_STYLE_GREEN) : (new CSpan(_('Executed')))->addClass(ZBX_STYLE_GREEN); } elseif ($alert['status'] == ALERT_STATUS_NOT_SENT) { $status = (new CSpan([_('In progress') . ':', BR(), _n('%1$s retry left', '%1$s retries left', ALERT_MAX_RETRIES - $alert['retries'])]))->addClass(ZBX_STYLE_YELLOW);
public function init() { parent::init(); $this->attachBehaviors(array('class' => 'ext.behavior.JsonBehavior')); }