_s('General questions/comments'), 'dmca' => _s('DMCA complaint'), ]; if (is_captcha_needed() || (CHV\getSetting('recaptcha') && CHV\getSetting('force_recaptcha_contact_page'))) { G\Handler::setCond('captcha_show', true); G\Handler::setVar(...CHV\Render\get_recaptcha_component()); } if ($_POST) { if (!G\Handler::checkAuthToken($_REQUEST['auth_token'])) { die(_s("Request denied")); } // Validate post data if (strlen($_POST['name']) == 0) { $input_errors['name'] = _s('Invalid name'); } if (strlen($_POST['message']) == 0) { $input_errors['message'] = _s('Invalid message'); } if (!array_key_exists($_POST['subject'], $allowed_subjects)) { $input_errors['subject'] = _s('Invalid subject'); } if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $input_errors['email'] = _s('Invalid email'); } if (G\Handler::getCond('captcha_show')) { $captcha = CHV\recaptcha_check(); if (!$captcha->is_valid) { $input_errors['recaptcha'] = _s('%s says you are a robot', 'reCAPTCHA'); } } if (count($input_errors) > 0) { $is_error = true; } else { $email = trim($_POST['email']); $subject = CHV\getSettings()['website_name'] . ' contact form'; $name = $_POST['name']; $send_mail = [ 'to' => CHV\getSettings()['email_incoming_email'], 'from' => [CHV\getSettings()['email_from_email'], $name . ' (' . CHV\getSettings()['website_name'] . ' contact form)'], 'reply-to' => [$email] ]; $body_arr = [ // Mail body array (easier to edit) 'Name' => $name, 'E-mail' => $email, 'User' => (CHV\Login::isLoggedUser() ? CHV\Login::getUser()['url'] : 'not user'), 'Subject' => $_POST['subject'] . "\n", 'Message' => strip_tags($_POST['message']) . "\n", 'IP' => G\get_client_ip(), 'Browser' => getenv("HTTP_USER_AGENT"), 'URL' => G\get_base_url() . "\n" ]; // Format body message $body = ''; foreach ($body_arr as $k => $v) { $body .= $k . ': ' . $v . "\n"; } // Mail send handle try { CHV\send_mail($send_mail, $subject, $body); $is_sent = true; } catch (Exception $e) { $is_error = true; $error = _s('Mail error') . ': ' . $e->getMessage(); } } } G\Render\include_theme_header(); ?>