public function getKeywords($generateIfEmpty = true, $data = null) { $keywords = parent::getKeywords(); if (!$generateIfEmpty) { return $keywords; } if ($keywords == null && $data != null) { $preg = '/<h[123456].*?>(.*?)<\\/h[123456]>/i'; $content = str_replace("\n", "", str_replace("\r", "", $data)); $pregCount = preg_match_all($preg, $content, $headers); $keywords = ''; for ($i = 0; $i < $pregCount; $i++) { if ($keywords != '') { $keywords .= ', '; } $item = trim(strip_tags($headers[0][$i])); if ($item == '') { continue; } $keywords .= $item; if (mb_strlen($keywords) > 200) { break; } } } if ($keywords == null && isset(Yii::app()->domain)) { $keywords = Yii::app()->domain->model->keywords; } return str_replace('@', '[at]', $keywords); }
protected function beforeAction($action) { if (parent::beforeAction($action)) { //print_r(Yii::app()->authManager->checkObject('list', Yii::app()->user->id)); $loginPage = $this->getModule() != null && $this->getModule()->getId() == 'user' && $this->getId() == 'user' && $action->getId() == 'login'; if (!Yii::app()->user->checkAccess('showAdminPanel')) { if (!$loginPage) { $errorPage = $this->getModule() == null && $this->getId() == 'static' && $action->getId() == 'error'; $logoutPage = $this->getModule() != null && $this->getModule()->getId() == 'user' && $this->getId() == 'user' && $action->getId() == 'logout'; if (Yii::app()->user->isGuest && !Yii::app()->request->isAjaxRequest && $action->getId() != 'captcha') { Yii::app()->user->setReturnUrl(Yii::app()->request->url); Yii::app()->user->loginRequired(); } else { if (!$errorPage && !$logoutPage) { $link = CHtml::link('авторизоваться заново', Yii::app()->createUrl('logout')); throw new CHttpException(403, '<div style="text-align: center;" class="alert alert-danger col-lg-7">Доступ к странице запрещен, попробуйте ' . $link . '.</div>'); } } } else { if (Yii::app()->user->returnUrl == '/') { Yii::app()->user->returnUrl = Yii::app()->createUrl(''); } } } else { if ($loginPage) { // переходим на главную Yii::app()->getRequest()->redirect(Yii::app()->createUrl('')); } } } return true; }