/**
  * 当同步接口访问的时候,添加用户验证逻辑
  * @param type $action
  * @return boolean
  */
 public function beforeAction($action)
 {
     parent::beforeAction($action);
     //如果是授权请求,返回true;否则false
     $this->hasAuthorize();
     return true;
 }
 public function beforeAction($action)
 {
     parent::beforeAction($action);
     if (!in_array($action->id, ['login', 'error', 'captcha', 'upfile'])) {
         $url = Url::toRoute('/site/login');
         if (empty($this->user)) {
             $this->helpGo($url);
         }
         $pass_flag = $this->hasSecurity();
         if (!$pass_flag && $this->user->is_super !== 1) {
             $this->helpRefresh($url, '请确认是否有权限访问');
         }
     }
     return true;
 }
Example #3
0
 /**
  * 生成 404 静态页面
  * @author gaoqing
  * @date 2016-04-20
  * @param string $cacheKey 缓存的唯一标识
  * @return boolean$generateFlag是否生成成功
  */
 public static function cache404Page($cacheKey, $param = [], $forceCache = false)
 {
     $generateFlag = false;
     $frontend = \Yii::getAlias('@frontend');
     $page404FileName = $frontend . '/web/404.shtml';
     if (!file_exists($page404FileName)) {
         $forceCache = true;
     }
     if ($forceCache) {
         $view = "404";
         //获取最新的资讯文章
         $article = new Article();
         $where = ' status=20';
         $order = ' articleid DESC';
         $lastestNews = $article->List_Articles($where, $order, 5, 0);
         //获取 疾病健康 文章
         $darticle = new \common\models\disease\Article();
         $lastestJibingArticle = $darticle->getLatestArticle(5, 0);
         //精彩问答
         $ask = new Ask();
         $where1 = ' 1';
         $order1 = ' id DESC';
         $lastestAsk = $ask->getList($where1, $order1, 5, 0);
         //字母部分
         $letters = range('A', 'Z');
         $condition = array('typeid' => array(0, 2, 3, 4, 5, 6, 7, 8, 9));
         $rand_words = KeyWords::getCacheRandWords(100, $condition);
         //热门疾病、热门部位
         $commonDisDep = CacheHelper::getCache('frontend_article_detail_rmksbw_404', []);
         $params = ['lastestNews' => $lastestNews, 'lastestJibingArticle' => $lastestJibingArticle, 'lastestAsk' => $lastestAsk, 'letters' => $letters, 'rand_words' => $rand_words, 'commonDisDep' => $commonDisDep, 'searchurl' => 'http://www.9939.com/zhuanti/'];
         $controller = new BaseController('base404', null);
         $controller->id = "base404";
         $page404FilePath = $frontend . '/views/site';
         $controller->viewPath = $page404FilePath;
         $page404 = $controller->renderPartial($view, $params);
         if (isset($page404) && !empty($page404)) {
             if (file_put_contents($page404FileName, $page404)) {
                 $generateFlag = true;
             }
         }
     }
     return $generateFlag;
 }
 public function init()
 {
     $this->fillSuffix();
     parent::init();
     $this->initVariables();
 }
 public function init()
 {
     parent::init();
     $this->disableLayout();
 }
 public function init()
 {
     $this->mobile_redirect();
     parent::init();
     $this->initVariables();
 }