/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = offset::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]); $query->andFilterWhere(['like', 'offset1', $this->offset1])->andFilterWhere(['like', 'offset2', $this->offset2])->andFilterWhere(['like', 'offset3', $this->offset3])->andFilterWhere(['like', 'offset4', $this->offset4])->andFilterWhere(['like', 'encKey', $this->encKey])->andFilterWhere(['like', 'mainOffset', $this->mainOffset])->andFilterWhere(['like', 'roadnumberOffset', $this->roadnumberOffset])->andFilterWhere(['like', 'cheatOffset', $this->cheatOffset])->andFilterWhere(['like', 'echoStrengthOffset', $this->echoStrengthOffset])->andFilterWhere(['like', 'roadoffsetStruct', $this->roadoffsetStruct])->andFilterWhere(['like', 'roadWeightOffset', $this->roadWeightOffset])->andFilterWhere(['like', 'roadFishOffset', $this->roadFishOffset])->andFilterWhere(['like', 'roadNumberOffsetPlus', $this->roadNumberOffsetPlus])->andFilterWhere(['like', 'hOffset', $this->hOffset])->andFilterWhere(['like', 'gOffset', $this->gOffset])->andFilterWhere(['like', 'priceOffset', $this->priceOffset])->andFilterWhere(['like', 'roadStateOffset', $this->roadStateOffset])->andFilterWhere(['like', 'fishhook1Offset', $this->fishhook1Offset])->andFilterWhere(['like', 'fishhook2Offset', $this->fishhook2Offset])->andFilterWhere(['like', 'fishhook3Offset', $this->fishhook3Offset]); return $dataProvider; }
public function actionCheckUser() { $request = Yii::$app->request; if (!($name = $request->post('action'))) { return $this->goHome(); } if ($request->post('sessionId')) { if (!($session = serverSession::findOne(['sessionId' => $request->post('sessionId')]))) { $serverAnswer = ["STATUS" => "fail", "data" => "Не удалось идентифицировать сессию,код ошибки:0x02"]; return json_encode($serverAnswer, JSON_UNESCAPED_UNICODE); } \Yii::$app->encrypter->setGlobalPassword($session->key); \Yii::$app->encrypter->setIv("sagtunsi8UHNstfu"); \Yii::$app->encrypter->setUseBase64Encoding(true); $pid = trim(\Yii::$app->encrypter->decrypt(base64_decode($request->post('pid')))); if (!($user = User::findOne(['PID' => $pid]))) { $serverAnswer = ["STATUS" => "fail", "data" => "Не удалось идентифицировать сессию,код ошибки:0х01", "pid" => $pid]; return json_encode($serverAnswer, JSON_UNESCAPED_UNICODE); } if ($user->trainerActive != 0) { $offset = offset::find()->all(); $offset1 = \Yii::$app->encrypter->encrypt($offset[0]->offset1); $offset2 = \Yii::$app->encrypter->encrypt($offset[0]->offset2); $offset3 = \Yii::$app->encrypter->encrypt($offset[0]->offset3); $serverAnswer = ["auth_suc" => \Yii::$app->encrypter->encrypt("succes"), "offset1" => $offset1, "offset2" => $offset2, "offset3" => $offset3]; return json_encode($serverAnswer, JSON_UNESCAPED_UNICODE); } else { $serverAnswer = ["auth_suc" => \Yii::$app->encrypter->encrypt("fail")]; return json_encode($serverAnswer, JSON_UNESCAPED_UNICODE); } } $serverAnswer = ["auth_suc" => "Что-то пошло не так"]; return json_encode($serverAnswer, JSON_UNESCAPED_UNICODE); }
/** * Finds the offset model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return offset the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = offset::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }