include('includes/inc_config.php');?>
$db = new database();?>
if(($_POST['send']) && !empty($_POST['nom']) && !empty($_POST['mail']) && !empty($_POST['msg'])) {
function post_captcha($user_response) {
$fields_string = '';
$fields = array(
'secret' => '6Ldu7n8UAAAAAPdnX_gDrjQol-_12SLYGVksUOYb',
'response' => $user_response
);
foreach($fields as $key=>$value)
$fields_string .= $key . '=' . $value . '&';
$fields_string = rtrim($fields_string, '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result, true);
}
// Call the function post_captcha
$res = post_captcha($_POST['g-recaptcha-response']);
if (!$res['success']) {
// What happens when the reCAPTCHA is not properly set up
header('Location: ?e=2');
exit();
}else {
$html = file_get_contents('acuse/tmp_contacto.html');
$html = str_replace('{FECHA}',date('d/m/Y H:s'), $html);
$html = str_replace('{ASUNTO}', $_POST['asunto'],$html);
$html = str_replace('{NOM}', $_POST['nom'],$html);
$html = str_replace('{EMP}', $_POST['emp'],$html);
$html = str_replace('{TEL}', $_POST['tel'],$html);
$html = str_replace('{DIR}', $_POST['dir'],$html);
$html = str_replace('{MAIL}', $_POST['mail'],$html);
$html = str_replace('{MSG}', $_POST['msg'],$html);
$html = str_replace('{IP}',$_POST['ip'],$html);
$html = str_replace('{EXPLORADOR}',$_POST['explorador'],$html);
//----
$mail = new Mailer();
$mail->AddReplyTo($_POST['mail'],$_POST['nom']);
$mail->Subject = $mail->Empresa.' : Contacto';
$mail->Body = $html;
$e = 'o';
if(!$mail->Send()){
$e = 1;$mail->Enviar();
}
//------ EMAIL ACUSE CONTACTO.-------------------------------------------------------
$html = file_get_contents('acuse/tmp_acuse_contacto.html');
$html = str_replace('{FECHA}',date('d/m/Y H:i\h\s'),$html);
$html = str_replace('{NOM}',$_POST['nom'],$html);
$html = str_replace('{MSG}','Recibimos su contacto, le enviaremos una respuesta a la brevedad.
Saludos cordiales.',$html);
$mail = new Mailer();
$mail->ClearAllRecipients();
$mail->AddAddress($_POST['mail'],$_POST['nom']);
$mail->Subject = $mail->Empresa.' : Acuse de mail';
$mail->Body = $html;
if(!$mail->Send()){
$e = 1;$mail->Enviar();
}
header('Location: '.$_SERVER['PHP_SELF'].'?e='.$e);
exit();
}
}
if($_REQUEST['id']){
$SQL = 'SELECT t1.nombre FROM productos t1 WHERE 1 AND t1.borrado = "N" AND t1.estado ="Y" AND md5(t1.id) = "'.$_REQUEST['id'].'"';
$rs = $db->db_query($SQL);
$f = $db->db_fetch_assoc($rs);
if($f){
$asunto = $f['nombre'];
}
}
?>
Su mensaje fue enviado con exito, a la brevedad nos comunicaremos con usted.
}else{?>Complete el formulario de contacto, a la brevedad nos comunicaremos con usted.
Muchas gracias!