| Server IP : 23.111.136.34 / Your IP : 216.73.216.136 Web Server : Apache System : Linux servidor.eurohost.com.br 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : meusitei ( 1072) PHP Version : 5.6.40 Disable Function : show_source, system, shell_exec, passthru, proc_open MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/meusitei/public_html/painel/front/tema02/model/ |
Upload File : |
<?php
// require ReCaptcha class
include_once('../../front/' . $configuracoes_sis['tema'] . '/controllers/recaptcha/recaptcha-master/src/autoload.php');
//require('recaptcha-master/src/autoload.php');
// configure
//$from = ''.$_POST['form_name'].' <' . $_POST['form_email'] . '>';
$from = 'Meu Site Imobiliário <envio@meusiteimobiliario.com.br>';
$replyTo = ''.$_POST['form_name'].' <' . $_POST['form_email'] . '>';
$sendTo = '<' . $telefones['sis_email'] . '>';
$subject = 'Newsletter';
$fields = array('name' => 'Name', 'surname' => 'Surname', 'phone' => 'Phone', 'email' => 'Email', 'message' => 'Message'); // array variable name => Text to appear in the email
$okMessage = 'Formulário de contato enviado com sucesso. Obrigado, vou voltar para você em breve!';
$errorMessage = 'Ocorreu um erro ao enviar o formulário. Por favor, tente novamente mais tarde';
if($google['sis_script_ganalytics3'] != ''){
$chave = $google['sis_script_ganalytics4'];
}
$recaptchaSecret = $chave;
// let's do the sending
try
{
if (!empty($_POST)) {
// validate the ReCaptcha, if something is wrong, we throw an Exception,
// i.e. code stops executing and goes to catch() block
if($chave != ''){
if (!isset($_POST['g-recaptcha-response'])) {
throw new \Exception('ReCaptcha is not set.');
}
// do not forget to enter your secret key in the config above
// from https://www.google.com/recaptcha/admin
$recaptcha = new \ReCaptcha\ReCaptcha($recaptchaSecret, new \ReCaptcha\RequestMethod\CurlPost());
// we validate the ReCaptcha field together with the user's IP address
$response = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
if (!$response->isSuccess()) {
throw new \Exception('ReCaptcha was not validated.');
}
}
// everything went well, we can compose the message, as usually
//$emailText = "Você tem nova mensagem do formulário de contato\n=============================\n";
$emailText .= "Nome: " . $_POST['form_name'];
$emailText .= "\n";
$emailText .= "Email: " . $_POST['form_email'];
$emailText .= "\n";
$headers = array(
'MIME-Version: 1.0" . "\r\n";',
'Content-Type: text/plain; charset="UTF-8" . "\r\n";',
'From: ' . $from,
'Reply-To: ' . $replyTo,
'Return-Path: ' . $from,
);
mail($sendTo, $subject, $emailText, implode("\n", $headers));
$responseArray = array('type' => 'success', 'message' => $okMessage);
}
}
catch (\Exception $e)
{
$responseArray = array('type' => 'danger', 'message' => $errorMessage);
}
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$encoded = json_encode($responseArray);
header('Content-Type: application/json');
//echo $encoded;
}
else {
//echo $responseArray['message'];
$validar_recaptcha = $responseArray['message'];
}