/var/www/vhosts/nabawater/frontend/controllers
Edit: /var/www/vhosts/nabawater/frontend/controllers/CmsController.php (1954B)
request->isAjax) {
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = array(
'secret' => Configuration::get(Configuration::RECAPTCHA_SECRET_KEY),
'response' => $_POST['g-recaptcha-response']
);
$options = array(
'http' => array (
'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$response = json_decode($result);
if ($response->success != true) {
print_r($response);exit;
$result= ["msg"=> Yii::t('frontend','Invalid request try again some time'),'status'=> Com::ERROR];
return $this->asJson($result);
}
$model = new Enquiry();
$post = Yii::$app->getRequest()->post();
$model->setScenario($model::ENQUIRY);
if($model->load($post) && $model->validate()){
$model->save();
$result= ["msg"=> Yii::t('frontend','Successfull'),'status'=> Com::SUCCESS];
return $this->asJson($result);
}
print_r($model->getErrors()); die;
}
}
}