primer desarrollo

This commit is contained in:
2026-08-20 23:57:02 -03:00
commit d4368d3378
56 changed files with 7868 additions and 0 deletions
+165
View File
@@ -0,0 +1,165 @@
<?php
header('Content-Type: application/json');
// ============================================
// CONFIGURACIÓN - ¡CAMBIAR ESTOS VALORES!
// ============================================
// Tu Secret Key de Google reCAPTCHA (obtenida de https://www.google.com/recaptcha/admin)
$RECAPTCHA_SECRET_KEY = "6Lfim6gsAAAAAH6BpB7U09icA8bfy-kif4j1pIBn";
// Email donde recibirás los mensajes
$DESTINATION_EMAIL = "info@vettaio.com";
// ============================================
// PROCESAR EL FORMULARIO
// ============================================
// Verificar honeypot (campo oculto anti-spam)
if (!empty($_POST['_honey'])) {
// Es un bot, responder como si todo estuviera bien pero no hacer nada
echo json_encode(['success' => true, 'message' => 'Mensaje recibido (spam bloqueado)']);
exit;
}
// Validar campos requeridos
$required_fields = ['nombre', 'email', 'division', 'mensaje'];
foreach ($required_fields as $field) {
if (empty($_POST[$field])) {
echo json_encode(['success' => false, 'message' => 'Por favor, completá todos los campos obligatorios.']);
exit;
}
}
// Validar formato de email
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
echo json_encode(['success' => false, 'message' => 'El email ingresado no es válido.']);
exit;
}
// Validar reCAPTCHA
if (empty($_POST['g-recaptcha-response'])) {
echo json_encode(['success' => false, 'message' => 'Por favor, completa el reCAPTCHA.']);
exit;
}
// Verificar reCAPTCHA con Google
$recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
$recaptcha_data = [
'secret' => $RECAPTCHA_SECRET_KEY,
'response' => $_POST['g-recaptcha-response'],
'remoteip' => $_SERVER['REMOTE_ADDR']
];
$recaptcha_options = [
'http' => [
'method' => 'POST',
'content' => http_build_query($recaptcha_data)
]
];
$recaptcha_context = stream_context_create($recaptcha_options);
$recaptcha_result = file_get_contents($recaptcha_url, false, $recaptcha_context);
$recaptcha_json = json_decode($recaptcha_result, true);
if (!$recaptcha_json['success']) {
echo json_encode(['success' => false, 'message' => 'Error de verificación reCAPTCHA. Por favor, intentá de nuevo.']);
exit;
}
// ============================================
// PREPARAR Y ENVIAR EL EMAIL
// ============================================
// Sanitizar datos
$nombre = htmlspecialchars(strip_tags($_POST['nombre']));
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$empresa = isset($_POST['empresa']) ? htmlspecialchars(strip_tags($_POST['empresa'])) : 'No especificada';
$telefono = isset($_POST['telefono']) ? htmlspecialchars(strip_tags($_POST['telefono'])) : 'No especificado';
$division = htmlspecialchars(strip_tags($_POST['division']));
$tipo = isset($_POST['tipo']) && !empty($_POST['tipo']) ? htmlspecialchars(strip_tags($_POST['tipo'])) : 'No especificado';
$mensaje = htmlspecialchars(strip_tags($_POST['mensaje']));
$referencia = isset($_POST['referencia']) && !empty($_POST['referencia']) ? htmlspecialchars(strip_tags($_POST['referencia'])) : 'No especificado';
// Construir el cuerpo del email
$email_subject = "Nuevo contacto desde VettaIO - $nombre";
$email_body = "
<html>
<head>
<title>Nuevo mensaje de contacto</title>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
.container { max-width: 600px; margin: 0 auto; padding: 20px; }
.header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px; text-align: center; }
.content { padding: 20px; background: #f9f9f9; }
.field { margin-bottom: 15px; }
.label { font-weight: bold; color: #667eea; }
.value { margin-top: 5px; }
.footer { text-align: center; padding: 20px; font-size: 12px; color: #999; }
</style>
</head>
<body>
<div class='container'>
<div class='header'>
<h2>Nuevo mensaje de contacto</h2>
<p>VettaIO - Transformamos desafíos tecnológicos</p>
</div>
<div class='content'>
<div class='field'>
<div class='label'>👤 Nombre:</div>
<div class='value'>$nombre</div>
</div>
<div class='field'>
<div class='label'>📧 Email:</div>
<div class='value'>$email</div>
</div>
<div class='field'>
<div class='label'>🏢 Empresa:</div>
<div class='value'>$empresa</div>
</div>
<div class='field'>
<div class='label'>📞 Teléfono:</div>
<div class='value'>$telefono</div>
</div>
<div class='field'>
<div class='label'>🎯 División de interés:</div>
<div class='value'>$division</div>
</div>
<div class='field'>
<div class='label'>📋 Tipo de consulta:</div>
<div class='value'>$tipo</div>
</div>
<div class='field'>
<div class='label'>💬 Mensaje:</div>
<div class='value'>$mensaje</div>
</div>
<div class='field'>
<div class='label'>🔍 ¿Cómo nos encontraste?</div>
<div class='value'>$referencia</div>
</div>
</div>
<div class='footer'>
<p>Este mensaje fue enviado desde el formulario de contacto de VettaIO</p>
<p>IP: {$_SERVER['REMOTE_ADDR']} | Fecha: " . date('d/m/Y H:i:s') . "</p>
</div>
</div>
</body>
</html>
";
// Cabeceras del email
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: $email\r\n";
$headers .= "Reply-To: $email\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
// Enviar email
$mail_sent = mail($DESTINATION_EMAIL, $email_subject, $email_body, $headers);
if ($mail_sent) {
echo json_encode(['success' => true, 'message' => '¡Mensaje enviado con éxito! Te responderemos en menos de 24 horas.']);
} else {
echo json_encode(['success' => false, 'message' => 'Error al enviar el mensaje. Por favor, intentá de nuevo o escribinos directamente a info@vettaio.com.']);
}
?>