public function actionLogin() { // $request = new Request(); // $headers = $request->getHeaders(); // $access_token = $headers->get('Authorization'); //print_r($access_token);die; /** * если авторизация успешная, * в таблицу временных токенов вставляется новый токен * на определенное время жизни, * и возвращается назад в ExtJs * * */ if (!Yii::$app->user->isGuest) { $session = new Session(); $session->createToken(Yii::$app->user->id); return $session; } // return "Облом"; // return "login - " . $_SERVER['PHP_AUTH_USER'] . " password " . $_SERVER['PHP_AUTH_PW']; // return [ // 'token' => $access_token, // 'expires_in' => 3600, // 'token_type' => 'basic', // 'scope' => null // ]; }
protected function findModel($id) { if (($model = Session::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionIndex() { $topics = Post::find()->limit(20)->where(['status' => 2])->orderBy(['created_at' => SORT_DESC])->all(); $users = UserService::findActiveUser(12); $statistics = array(); $statistics['post_count'] = Post::find()->count(); $statistics['comment_count'] = PostComment::find()->count(); $statistics['online_count'] = Session::find()->where(['>', 'expire', time()])->count(); return $this->render('index', ['topics' => $topics, 'users' => $users, 'statistics' => $statistics]); }
public function actionIndex() { $topics = Post::find()->limit(20)->where(['status' => 2])->orderBy(['created_at' => SORT_DESC])->all(); $users = UserService::findActiveUser(12); $headline = Arr::getColumn(RightLink::find()->where(['type' => RightLink::RIGHT_LINK_TYPE_HEADLINE])->all(), 'content'); $statistics = []; $statistics['post_count'] = Post::find()->count(); $statistics['comment_count'] = PostComment::find()->count(); $statistics['online_count'] = Session::find()->where(['>', 'expire', time()])->count(); return $this->render('index', ['topics' => $topics, 'users' => $users, 'statistics' => $statistics, 'headline' => Arr::arrayRandomAssoc($headline)]); }
/** * Удаление старыъ записей (сессии, логов) */ public function actionGarbageCollector() { $logMain = LogMain::deleteAll(['<=', 'created', time() - Time::SEC_TO_MONTH]); $session = Session::deleteAll(['<=', 'expire', time() - \Yii::$app->session->getTimeout()]); $this->stdout('- ' . $this->ansiFormat(LogMain::tableName(), Console::FG_YELLOW)); $this->stdout(' '); $this->stdout(Console::wrapText("удалено {$logMain} записей", 10), Console::BOLD); $this->stdout("\n"); $this->stdout('- ' . $this->ansiFormat(Session::tableName(), Console::FG_YELLOW)); $this->stdout(' '); $this->stdout(Console::wrapText("удалено {$session} записей", 10), Console::BOLD); $this->stdout("\n"); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Session::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'start_time' => $this->start_time, 'hall_id' => $this->hall_id, 'movie_id' => $this->movie_id]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getSessions() { return $this->hasMany(Session::className(), ['hall_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getKaka() { return $this->hasMany(Session::className(), ['user_id' => 'id']); }