/home/simp499cl/public_html
Edit: /home/simp499cl/public_html/send_email.php (2439B)
$turnstileSecret,
'response' => $turnstileToken,
'remoteip' => $_SERVER['REMOTE_ADDR'] ?? null,
]);
$ch = curl_init($verifyUrl);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $verifyData,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded'],
]);
$verifyResponse = curl_exec($ch);
$curlError = curl_errno($ch);
curl_close($ch);
if ($curlError || !$verifyResponse) {
redirect_contact(false);
}
$turnstileResult = json_decode($verifyResponse, true);
if (empty($turnstileResult['success'])) {
redirect_contact(false);
}
$name = trim($_POST['name'] ?? '');
$email = trim($_POST['email'] ?? '');
$subjectInput = trim($_POST['subject'] ?? 'Contacto desde Simple Systems');
$message = trim($_POST['message'] ?? '');
if ($name === '' || $email === '' || $message === '' || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
redirect_contact(false);
}
// Evita inyección de headers en mail().
$name = str_replace(["\r", "\n"], ' ', $name);
$email = str_replace(["\r", "\n"], '', $email);
$subjectInput = str_replace(["\r", "\n"], ' ', $subjectInput);
$to = 'contacto@simplesystems.cl';
$subject = 'Contacto Web: ' . $subjectInput;
$body = "Nombre: {$name}\n";
$body .= "Correo: {$email}\n";
$body .= "Asunto: {$subjectInput}\n\n";
$body .= "Mensaje:\n{$message}\n";
$headers = [];
$headers[] = 'From: Simple Systems
';
$headers[] = 'Reply-To: ' . $email;
$headers[] = 'Content-Type: text/plain; charset=UTF-8';
if (mail($to, $subject, $body, implode("\r\n", $headers))) {
redirect_contact(true);
}
redirect_contact(false);
?>