praiadeseselle/site/templates/contacto.php

146 lines
No EOL
7.1 KiB
PHP

<?php namespace ProcessWire;
/** @var Page $page API variable */
define("RECAPTCHA_V3_SECRET_KEY", '6LexXqYiAAAAAOoFqs4kfWd7zW6stVRK0aViyiQo');
$menu = '';
$contido = '';
if($configuracion['mantemento']['activo'] && !$user->isLoggedin())
{
$menu = renderMenu($pages->get('/noticias')->and($pages->get('/contacto')));
}
else
{
$menu = renderMenu($inicio->children);
}
if(isset($_POST['enviar']))
{
$correo = wireMail();
$correo->to($configuracion['contacto_correo']);
$correo->from($sanitizer->email($input->post->correo));
$correo->fromName($sanitizer->text($input->post->nome));
$correo->subject($sanitizer->text($input->post->asunto));
$correo->body($sanitizer->text($input->post->mensaxe));
$token = $input->post->token;
$action = $input->post->action;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.google.com/recaptcha/api/siteverify");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('secret' => RECAPTCHA_V3_SECRET_KEY, 'response' => $token)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$arrResponse = json_decode($response, true);
if($arrResponse["success"] == '1' && $arrResponse["action"] == $action && $arrResponse["score"] >= 0.5)
{
$correo->send();
$enviado = $correo->getResult();
}
else
{
$mensaxe_tipo = "alerta";
$mensaxe = _x('Wrong reCaptcha', 'Wrong reCaptcha');
}
}
$contido .= renderMigasPan($page) . "\n";
$contido .= '<article id="' . $page->name .'" class="container">' . "\n";
$contido .= '<h2 class="visually-hidden">' . ucfirst($page->title) . '</h2>' . "\n";
$contido .= '<div class="row align-items-lg-stretch mb-5">' . "\n";
$contido .= '<div class="col-lg-7">' . "\n";
$contido .= '<div class="h-100 p-5 text-bg-light border rounded-3">' . "\n";
$contido .= '<form method="POST" id="formulario-contacto" name="formulario-contacto" onSubmit="getContact(event)" action="#">' . "\n";
$contido .= '<div class="row mb-3">' . "\n";
$contido .= '<div class="col-md-6">' . "\n";
$contido .= '<label class="form-label" for="nome">' . _x('Name', 'name') . '</label>' . "\n";
$contido .= '<input type="text" class="form-control" name="nome" id="nome" placeholder="' . _x('Name', 'name') . '" required>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '<div class="col-md-6">' . "\n";
$contido .= '<label class="form-label" for="correo">' . _x('E-Mail', 'email') . '</label>' . "\n";
$contido .= '<input type="email" class="form-control" name="correo" id="correo" placeholder="' . _x('E-Mail', 'email') . '" required>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '<div class="row mb-3">' . "\n";
$contido .= '<div class="col-md-12">' . "\n";
$contido .= '<label class="form-label" for="asunto">' . _x('Subject', 'subject') . '</label>' . "\n";
$contido .= '<input type="text" class="form-control" name="asunto" id="asunto" placeholder="' . _x('Subject', 'subject') . '" required>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '<div class="row mb-3">' . "\n";
$contido .= '<div class="col-md-12">' . "\n";
$contido .= '<label class="form-label" for="mensaxe">' . _x('Message', 'message') . '</label>' . "\n";
$contido .= '<textarea class="form-control" name="mensaxe" id="mensaxe" cols="30" rows="4" placeholder="' . _x('Message', 'message') . '" required></textarea>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '<div class="row mb-3">' . "\n";
$contido .= '<div class="col-md-12">' . "\n";
$contido .= '<input type="submit" id="enviar" name="enviar" value="' . _x('Send message', 'send message') . '" class="btn btn-primary">' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
if(isset($enviado) && count($enviado['recipientsSuccess']))
{
$contido .= '<div class="row mb-3">' . "\n";
$contido .= '<div class="col-md-12 alert alert-success" role="alert">' . "\n";
$contido .= 'Correo enviado.' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
}
if(isset($enviado) && count($enviado['recipientsFailed']))
{
$contido .= '<div class="row mb-3">' . "\n";
$contido .= '<div class="col-md-12 alert alert-danger" role="alert">' . "\n";
$contido .= 'Error enviado correo.' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
}
$contido .= '</form>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '<div class="col-lg-5">' . "\n";
$contido .= '<div class="h-100 p-3 text-bg-primary border rounded-3">' . "\n";
$contido .= '<div class="row m-0 mb-3 position-relative w-100 h-100" style="padding-bottom: 56.25%;">' . "\n";
$contido .= '<iframe class="p-0 rounded position-absolute top-0 start-0 bottom-0 end-0 w-100 h-100" src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d167.88206925427303!2d-8.223339!3d43.43177!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd2e759aa6d41317%3A0x25ccd67bb4c850ab!2sApartamentos%20tur%C3%ADsticos%20Praia%20de%20Seselle!5e1!3m2!1ses!2ses!4v1676985980478!5m2!1ses!2ses" style="border:0" allowfullscreen="" loading="lazy"></iframe>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '<div class="row row-cols-1 row-cols-sm-2 row-cols-lg-3 py-5 justify-content-center">' . "\n";
$contido .= '<div class="feature col text-center">' . "\n";
$contido .= '<div class="feature-icon d-inline-flex align-items-center justify-content-center text-bg-primary bg-gradient fs-2 mb-3">' . "\n";
$contido .= '<i class="icon-map-pin"></i>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '<div class="text">' . "\n";
$contido .= '<p class="fs-4">' . _x('Address', 'address') . ':</p>' . "\n";
$contido .= '<p>' . $configuracion['contacto_direccion'] . '</p>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '<div class="feature col text-center">' . "\n";
$contido .= '<div class="feature-icon d-inline-flex align-items-center justify-content-center text-bg-primary bg-gradient fs-2 mb-3">' . "\n";
$contido .= '<i class="icon-phone"></i>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '<div class="text">' . "\n";
$contido .= '<p class="fs-4">' . _x('Phone', 'phone') . '</p>' . "\n";
$contido .= '<p><a href="tel://' . $configuracion['contacto_telefono'] . '">' . $configuracion['contacto_telefono'] . '</a></p>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '<div class="feature col text-center">' . "\n";
$contido .= '<div class="feature-icon d-inline-flex align-items-center justify-content-center text-bg-primary bg-gradient fs-2 mb-3">' . "\n";
$contido .= '<i class="icon-mail"></i>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '<div class="text">' . "\n";
$contido .= '<p class="fs-4">' . _x('E-Mail', 'email') . ':</p>' . "\n";
$contido .= '<p><a href="mailto:' . $configuracion['contacto_correo'] . '">' . $configuracion['contacto_correo'] . '</a></p>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</div>' . "\n";
$contido .= '</article>' . "\n";