获取应用概况列表
@return bool
@throws \yii\web\HttpException
358097
public function getAgentList()
    {
        $result = $this->httpGet(self::WECHAT_AGENT_SET_PREFIX, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok' ? $result['agentlist'] : $this->dump($result);
    }
1183704
public function run()
    {
        /* @var $model \yii\db\ActiveRecord */
        $model = new $this->modelClass;
        $model->setScenario( $this->scenario );
        $request=yii::$app->getRequest();
        if ($request->getIsPost()) {
            if ($model->load($request->post()) && $model->save()) {
                yii::$app->getSession()->setFlash('success', yii::t('app', 'Created Success'));
                if($request->isAjax){
                    return ['status'=>true,'msg'=>yii::t('app','Created Success')];
                }else{
                    return $this->controller->redirect([$this->indexView]);
                }
            } else {
                $errors = $model->getErrors();
                $err = '';
                foreach ($errors as $v) {
                    $err .= Yii::t('app',$v[0]) . '<br>';
                }
                Yii::$app->getSession()->setFlash('error', $err);
                if($request->isAjax){
                    return ['status'=>false,'msg'=>$err];
                }
            }
        }
        $model->loadDefaultValues();
        $data = [
            'model' => $model,
        ];
        if( is_array($this->data) ){
            $data = array_merge($data, $this->data);
        }elseif ($this->data instanceof \Closure){
            $data = call_user_func_array($this->data, [$model, $this]);
        }
        $this->viewFile === null && $this->viewFile = $this->id;
        return $this->controller->render($this->viewFile, $data);
    }
778431
public function actionRecord()
    {
        $wechat = $this->getWechat();
        $fans = $this->getFans();
        if (!$fans) { // 存储粉丝信息
            $fans = Yii::createObject(Fans::className());
            $fans->setAttributes([
                'wid' => $wechat->id,
                'open_id' => $this->message['FromUserName'],
                'status' => Fans::STATUS_SUBSCRIBED
            ]);
            if ($fans->save() && $wechat->status > Wechat::TYPE_SUBSCRIBE) { // 更新用户详细数据, 普通订阅号无权限获取
                $fans->updateUser();
            }
        } elseif ($fans->status != Fans::STATUS_SUBSCRIBED) { // 更新关注状态
            $fans->subscribe();
        }

//        $history = new MessageHistory();
//        $attributes = [
//            'wid' => $wechat->id,
//            'module' => $this->getModuleName($this->api->lastProcessController),
//        ];
    }
562064
public function getWechat()
    {
        if ($this->_wechat === null) {
            $wid = Yii::$app->session->get(self::SESSION_MANAGE_WECHAT_KEY);
            if (!$wid || ($wechat = Wechat::findOne($wid)) === null) {
                return false;
            }
            $this->setWechat($wechat);
        }
        return $this->_wechat;
    }
530127
public function run()
    {
        $url = Yii::$app->request->getUrl();

        $out = '';
        switch ($this->what) {
            case 'forum':
                $out .= Yii::t('podium/view', 'Browsing this forum') . ': ';
                break;
            case 'topic':
                $out .= Yii::t('podium/view', 'Reading this thread') . ': ';
                break;
            case 'unread':
                $out .= Yii::t('podium/view', 'Browsing unread threads') . ': ';
                break;
            case 'members':
                $out .= Yii::t('podium/view', 'Browsing the members') . ': ';
                break;
        }

        $out .= $this->getNamedUsersList($url);

        $anonymous = $this->getAnonymousUsers($url);
        if ($anonymous) {
            $out .= Html::button(
                Yii::t('podium/view', '{n, plural, =1{# anonymous user} other{# anonymous users}}', [
                    'n' => $anonymous
                ]),
                ['class' => 'btn btn-xs btn-default disabled']
            ) . ' ';
        }
        $guests = $this->getGuestUsers($url);
        if ($guests) {
            $out .= Html::button(
                Yii::t('podium/view', '{n, plural, =1{# guest} other{# guests}}', [
                    'n' => $guests
                ]),
                ['class' => 'btn btn-xs btn-default disabled']
            );
        }

        return $out;
    }
635418
public function login()
    {
        if ($this->validate()) {
            $loginHistory = new LoginHistory(['ip' => Yii::$app->request->userIP ?: '127.0.0.1']);
            $loginHistory->link('user', $this->user);
            return Yii::$app->user->login($this->user, $this->rememberMe ? $this->getSetting('rememberFor') : 0);
        } else {
            return false;
        }
    }
976102
public function login()
    {
        if ($this->validate()) {
            UserLoginHistory::createAsync(['user_id' => $this->user->getId(), 'ip' => Yii::$app->request->userIP]);
            return Yii::$app->user->login($this->user, $this->rememberMe ? Yii::$app->settings->get('rememberFor', 'user') : 0);
        } else {
            return false;
        }
    }
782218
public function run()
    {
        $model = $this->model;

        if ($model->delete()) {

            Yii::$app->getSession()->setFlash('success', $this->successMsg);

            Yii::$app->response->format = Response::FORMAT_JSON;
            return [
                'success' => true,
            ];
        }

        Yii::$app->getSession()->setFlash('error', $this->errorMsg);

        Yii::$app->response->format = Response::FORMAT_JSON;
        return [
            'success' => false,
            'error' => print_r($model->getErrors()),
        ];
    }
726597
protected function _ensureUrl()
    {
        /*if (!\Yii::$app->urlManager->enablePrettyUrl) {
            return true;
        }*/

        if (\Yii::$app->urlManager->rules) {
            foreach (\Yii::$app->urlManager->rules as $rule) {
                if ($rule instanceof BackendUrlRule) {
                    $request = \Yii::$app->request;
                    $pathInfo = $request->getPathInfo();
                    $params = $request->getQueryParams();

                    //Если например нужно на главной странице сделать бэкенд
                    if (!$pathInfo) {
                        return true;
                    }

                    $firstPrefix = StringHelper::substr($pathInfo, 0, StringHelper::strlen($rule->urlPrefix));

                    if ($firstPrefix == $rule->urlPrefix) {
                        return true;
                    }
                }
            }
        }

        throw new NotFoundHttpException("This is controller allow only with urlPrefix!");
    }
392247
public function saveLocal()
    {
        $file = file_get_contents($this->fileField);
        $this->oriName = basename($this->fileField);
        $this->fileSize = strlen($file);
        $this->fileType = $this->getExtension();
        $this->fullName = $this->getFullName();
        $this->filePath = $this->getFilePath();
        $this->fileName = $this->getFileName();
        $dirName = dirname($this->filePath);

        if (!is_dir($dirName)) {//递归创建保存目录
            FileHelper::createDirectory($dirName, $this->dirMode, true);
        }
        //检查文件大小是否超出限制
        if (!$this->checkSize()) {
            $this->stateInfo = Yii::t('attachment', 'The file size exceeds the site limit.');
            return false;
        }

        //移动文件
        if (!(file_put_contents($this->filePath, $file) && file_exists($this->filePath))) { //移动失败
            $this->stateInfo = Yii::t('attachment', 'An error occurred while saving the file.');
            return false;
        } else { //移动成功
            @unlink($this->fileField);
            $this->saveModel();
            $this->stateInfo = 'SUCCESS';
            return true;
        }
    }
249287
public function parseUrl()
    {
        if (self::PATH_FORMAT === $this->urlFormat) {
            $pathInfo = $this->removeUrlSuffix(Request::httpRequest()->getPathInfo(), $this->urlSuffix);
        } elseif (isset($_GET[$this->routeVar])) {
            $pathInfo = $this->removeUrlSuffix($_GET[$this->routeVar], $this->urlSuffix);
        } elseif (isset($_POST[$this->routeVar])) {
            $pathInfo = $_POST[$this->routeVar];
        } else {
            $pathInfo = '';
        }
        foreach ($this->_rules as $i => $rule) {
            $_pathinfo = $rule->parsePathInfo($this, $pathInfo);
            if (false !== $_pathinfo) {
                return $_pathinfo;
            }
        }
        if ($this->throwNotMatchRule) {
            // 不匹配规则时抛出异常
            throw new Exception(str_cover('"{pathInfo}"找不到对应的URL解析规则，不能确定路由', [
                '{pathInfo}' => $pathInfo,
            ]), 100900101);
        } else {
            // 没有匹配的规则，直接返回pathinfo本身
            return $pathInfo;
        }
    }
1077858
public function actionLoad()
    {
        if (!Yii::$app->request->isAjax) {
            return $this->redirect(['forum/index']);
        }

        $result = ['messages' => '', 'more' => 0];

        if (!Podium::getInstance()->user->isGuest) {
            $loggedId = User::loggedId();
            $id = Yii::$app->request->post('message');
            $message = Message::find()->where(['id' => $id])->limit(1)->one();
            if ($message && ($message->sender_id == $loggedId || $message->isMessageReceiver($loggedId))) {
                $stack = 0;
                $reply = clone $message;
                while ($reply->reply && $stack < 5) {
                    $result['more'] = 0;
                    if ($reply->reply->sender_id == $loggedId && $reply->reply->sender_status == Message::STATUS_DELETED) {
                        $reply = $reply->reply;
                        continue;
                    }
                    $result['messages'] .= $this->renderPartial('load', ['reply' => $reply]);
                    $reply = $reply->reply;
                    if ($reply) {
                        $result['more'] = $reply->id;
                    }
                    $stack++;
                }
            }
        }
        return Json::encode($result);
    }
442869
public function verify()
    {
        $data = file_get_contents("php://input");
        $data = Xml::xmlToArr($data);
        if ($data['sign'] != Helper::signature($data, Datasheet::get('md5_key'))) {
            throw new \Exception('微信异步通信签名验证失败');
        }
        return $data;
    }
544865
public function getIsOnline()
    {
        $time = \Yii::$app->formatter->asTimestamp(time()) - $this->last_activity_at;
        if ($time <= \Yii::$app->cms->userOnlineTime)
        {
            return true;
        } else
        {
            return false;
        }
    }
1355266
public function getIsConsoleRequest()
    {
        if ($this->_isConsoleRequest === null && \Yii::$app !== null) {
            if (\Yii::$app->getRequest() instanceof ConsoleRequest) {
                $this->_isConsoleRequest = true;
            } elseif (\Yii::$app->getRequest() instanceof WebRequest) {
                $this->_isConsoleRequest = false;
            }
        }
        if ($this->_isConsoleRequest === null) {
            throw new InvalidConfigException('Unable to determine if the application is a console or web application.');
        }

        return $this->_isConsoleRequest;
    }
541227
private function login(){
        extract($this->config);
        $this->link = ftp_connect($host, $port, $timeout);
        if($this->link) {
            if (ftp_login($this->link, $username, $password)) {
               return true;
            } else {
                $this->error = "无法登录到FTP服务器：username - {$username}";
            }
        } else {
            $this->error = "无法连接到FTP服务器：{$host}";
        }
        return false;
    }
91001
public function authenticate()
	{
		if (!empty($_REQUEST['openid_mode'])) {
			switch ($_REQUEST['openid_mode']) {
				case 'id_res':
					$this->id_res();
					return true;
					break;

				case 'cancel':
					$this->cancel();
					break;

				default:
					throw new HttpException(400, Yii::t('yii', 'Your request is invalid.'));
					break;
			}
		} else {
			$this->processRequest();
		}

		return false;
	}