From d99aa95046dfec2d7a5738c5e6ea93614707d7f3 Mon Sep 17 00:00:00 2001
From: Vladislav Utkin
Date: Tue, 27 Mar 2018 21:03:17 +0300
Subject: [PATCH] Finally usable form, mail link in footer
---
contact.php | 45 +++++++++++++++++++++++++++++++++++----
src/App.vue | 23 ++++++++++----------
src/translations/App.yaml | 14 ++++++++++++
3 files changed, 66 insertions(+), 16 deletions(-)
diff --git a/contact.php b/contact.php
index 9f7bc6a..031ab7c 100644
--- a/contact.php
+++ b/contact.php
@@ -1,6 +1,7 @@
Message validation failed
";
}
- if ($ok) {
- // TODO: Sendmail
- echo "Validation passed
";
+ if ($_POST['g-recaptcha-response']) {
+ $url = 'https://www.google.com/recaptcha/api/siteverify';
+ $params = array(
+ 'secret' => $grecaptcha_secret_key,
+ 'response' => $_POST['g-recaptcha-response'],
+ );
+ $result = file_get_contents($url, false, stream_context_create(array(
+ 'http' => array(
+ 'method' => 'POST',
+ 'header' => 'Content-type: application/x-www-form-urlencoded',
+ 'content' => http_build_query($params)
+ )
+ )));
+ if (!json_decode($result, true)['success']) {
+ $ok = false;
+ echo "recaptcha remote validation failed
";
+ }
} else {
- echo "Validation failed. Please check your data
";
+ $ok = false;
+ echo "recaptcha validation failed
";
+ }
+ if ($ok) {
+ $ip = $_SERVER["REMOTE_ADDR"];
+ $message = "Message from $name <$email>, ip: $ip\r\n $body";
+ $answer = (int)$_POST["answ"];
+ $headers = 'From: Contact Form ' . "\r\n" .
+ 'Reply-To: No Reply ' . "\r\n" .
+ 'Content-Type: text/plain; charset=UTF-8; format=flowed' . "\r\n" .
+ 'X-Mailer: PHP/' . phpversion();
+ mail('info@teamfnd.ru', "Contact Form on teamfnd.ru from $name <$email>", $message, $headers);
+ ?>
+
+
Success!
+
Your message has been sent.
+
We will reply you as soon as it is possilble.
+
You will be redirected back on site soon.
+
+ ';
+ } else {
+ echo 'Validation failed. Please check your data
';
}
} else {
echo 'Method not allowed';
diff --git a/src/App.vue b/src/App.vue
index 5b08a50..394b2c5 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -10,28 +10,28 @@
b-navbar-nav(class="ml-auto")
b-nav-item(@click="modalShow = !modalShow") {{$t('contact_us')}}
b-modal(id="contactus" hide-footer :title="$t('contact_us')" v-model="modalShow")
- b-form(action="http://localhost:8000/contact.php" method="post")
+ b-form(action="/contact.php" method="post")
b-form-group(id="EmailInputGroup"
- label="Email address"
+ :label="$t('email_address')"
label-for="EmailInput"
- description="We'll never share your email with anyone else.")
+ :description="$t('email_disclaimer')")
b-form-input(id="EmailInput"
type="email"
v-model="form.email"
name="email"
required
- placeholder="Enter email")
+ :placeholder="$t('email_placeholder')")
b-form-group(id="NameInputGroup"
- label="Your name:"
+ :label="$t('your_name')"
label-for="NameInput")
b-form-input(id="NameInput"
type="text"
v-model="form.name"
name="name"
required
- placeholder="Enter name")
+ :placeholder="$t('name_placeholder')")
b-form-group(id="TextInputGroup"
- label="Your Message"
+ :label="$t('your_message')"
label-for="TextInput")
b-form-textarea(id="TextInput"
v-model="form.text"
@@ -41,19 +41,18 @@
:rows="3")
vue-recaptcha(:sitekey="sitekey" @verify="captchaPass" @expired="captchaFailed")
p
- b-button(type="submit" variant="primary" :disabled="!allowsend") Submit
+ b-button(type="submit" variant="primary" :disabled="!allowsend") {{$t('submit')}}
b-nav-form
label(for="locale" style="margin: 5px") {{$t('language')}}:
b-form-select(v-model="locale")
option(value="en") English
- //option(value="jp") 日本語
+ option(value="jp") 日本語
option(value="ru") Русский
#app(class="container body-content")
router-view
hr
footer
- // TODO: Mailto
- p © 2018 TeamFND
+ p © 2018 TeamFND info@teamfnd.ru