Beispiel #1
0
 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]);
 }
Beispiel #2
0
 /**
  * Finds the BFeedback model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BFeedback the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BFeedback::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }