/** * @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); }
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); }
/** * @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); }
protected function preFilter($filterChain) { $this->actions = str_replace(' ', '', strtolower($this->actions)); $actionId = $filterChain->action->id; if ($this->actions != '*' && $this->actions != 'all' && !in_array($actionId, explode(',', $this->actions))) { $this->doCompress = false; return parent::preFilter($filterChain); } if ($this->gzip) { if (!self::isBuggyIe() && substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) { @ob_start('ob_gzhandler'); header('Content-type: text/html; charset: ' . Yii::app()->charset); header('Cache-Control: must-revalidate'); header("Expires: " . gmdate('D, d M Y H:i:s', time() - 1) . ' GMT'); } else { ob_start(); $this->gzip = false; } } else { ob_start(); } return parent::preFilter($filterChain); }
protected function preFilter($filterChain) { ob_start(); return parent::preFilter($filterChain); }