<?php 
require_once '../../../../config.php';
require_once '../../../../vendor/autoload.php';
require_once '../utils/response.php';
require_once '../utils/session.php';
require_once 'form.php';
Response::allow_method('POST');
session_start();
if (!isset($_POST['token']) || !Session::verify_token('token_form_contact', $_POST['token'])) {
    Response::json(401, 'La sesión es inválida o este formulario ya fue enviado.');
}
unset($_POST['token']);
if (!isset($_POST['recaptcha']) || !isset($_POST['recaptcha']['challenge']) || !isset($_POST['recaptcha']['response'])) {
    Response::json(400, 'Captcha requerido!');
}
// Validate captcha
$captcha = new Captcha\Captcha();
$captcha->setPublicKey(Config::$RECAPTCHA_PUBLIC);
$captcha->setPrivateKey(Config::$RECAPTCHA_SECRET);
$response = $captcha->check($_POST['recaptcha']['challenge'], $_POST['recaptcha']['response']);
if (!$response->isValid()) {
    Response::json(401, 'Captcha inválido!');
}
unset($_POST['recaptcha']);
// Form creation
$MAX_LENGTH_NAME = 30;
$MAX_LENGTH_SUBJECT = 70;
$MAX_LENGTH_MESSAGE = 250;
$REASONS = array('enquiry' => 'Consultas', 'complaint' => 'Reclamos', 'difussion' => 'Bandas/Difusión', 'other' => 'Otros');
$form = new Form(array('full_name' => array('label' => 'Nombre/s', 'type' => 'string', 'required' => true, 'maxlength' => $MAX_LENGTH_NAME), 'email' => array('label' => 'Correo electrónico', 'type' => 'email', 'required' => true), 'reason' => array('label' => 'Motivo', 'type' => 'string', 'required' => true, 'select' => $REASONS), 'subject' => array('label' => 'Asunto', 'type' => 'string', 'required' => true, 'maxlength' => $MAX_LENGTH_SUBJECT), 'message' => array('label' => 'Mensaje', 'type' => 'string', 'required' => true, 'maxlength' => $MAX_LENGTH_MESSAGE)));
$errors = $form->validate_whitelist();
  <?php 
require_once '../../../../config.php';
require_once '../../../../vendor/autoload.php';
require_once '../utils/response.php';
require_once '../utils/session.php';
require_once 'form.php';
Response::allow_method('POST');
session_start();
if (!isset($_POST['token']) || !Session::verify_token('token_form_subscription', $_POST['token'])) {
    Response::json(401, 'La sesión es inválida o este formulario ya fue enviado.');
}
unset($_POST['token']);
if (!isset($_POST['recaptcha']) || !isset($_POST['recaptcha']['challenge']) || !isset($_POST['recaptcha']['response'])) {
    Response::json(400, 'Captcha requerido!');
}
// Validate captcha
$captcha = new Captcha\Captcha();
$captcha->setPublicKey(Config::$RECAPTCHA_PUBLIC);
$captcha->setPrivateKey(Config::$RECAPTCHA_SECRET);
$response = $captcha->check($_POST['recaptcha']['challenge'], $_POST['recaptcha']['response']);
if (!$response->isValid()) {
    Response::json(401, 'Captcha inválido!');
}
unset($_POST['recaptcha']);
// Form creation
$MAX_LENGTH_FIRST_NAME = 30;
$MAX_LENGTH_LAST_NAME = 30;
$MAX_LENGTH_PROVINCE = 50;
$MAX_LENGTH_CITY = 50;
$MAX_LENGTH_ADDRESS = 70;
$MAX_LENGTH_NOTES = 250;