public function actionContacts() { $BContacts = BContacts::find()->where(['site' => 1])->one(); $title = $BContacts->title; $text = $BContacts->text; $keywords = $model->keywords; $description = $model->description; $model = new BFeedback(); if (Yii::$app->request->post()) { if ($_SESSION['__captcha/site/captcha'] != $_POST['BFeedback']['verifyCode']) { Yii::$app->getSession()->setFlash('captcha', 'false'); return $this->redirect(['contacts']); } if ($model->load(Yii::$app->request->post()) && $model->validate()) { $model->date = time(); $model->ip = $_SERVER['REMOTE_ADDR']; if ($model->save()) { Yii::$app->getSession()->setFlash('save', 'true'); return $this->redirect(['contacts']); } } } if (Yii::$app->getSession()->getFlash('captcha')) { $captcha = false; } else { $captcha = true; } if (Yii::$app->getSession()->getFlash('save')) { $save = true; } else { $save = false; } return $this->render('contacts', ['title' => $title, 'text' => $text, 'feedback' => $model, 'captcha' => $captcha, 'save' => $save]); }
public function actionDescription() { if (Yii::$app->user->isGuest) { $this->redirect(Yii::$app->user->loginUrl); } $model = BContacts::find()->where(['site' => 1])->one(); if (!$model) { $model = new BContacts(); $model->site = 1; } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->render('description', ['model' => $model, 'success' => true]); } return $this->render('description', ['model' => $model]); }