]> _ Git - cubeextranet.git/commitdiff
#4016
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 24 Nov 2020 17:08:47 +0000 (17:08 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 24 Nov 2020 17:08:47 +0000 (17:08 +0000)
fluidbook/mailer/index.php

index 4d35fc776c24abadc2e4617dfaf0ffd6fa23b7f9..0cf68fceb78397b7e40d35e578dc6fe08f5fbaff 100644 (file)
@@ -26,6 +26,7 @@ function process()
         return $result;
     }
 
+
     // Check that important fields are present
     if (empty($_POST['_formID']) || empty($_POST['_recipient']) || empty($_POST['_verification'])) {
         $result['message'] = 'Error: missing form configuration data';
@@ -40,6 +41,29 @@ function process()
         return $result;
     }
 
+    // Check captcha if enabled
+    $recaptcha = ['toysrus-2020' => '6LfXYeEZAAAAABhZuPNOCTYgcW5svieZKPYBrOYb'];
+    if (isset($recaptcha[$_POST['_formID']])) {
+        $url = 'https://www.google.com/recaptcha/api/siteverify';
+        $data = array(
+            'secret' => $recaptcha[$_POST['_formID']],
+            'response' => $_POST["g-recaptcha-response"]
+        );
+        $options = array(
+            'http' => array(
+                'method' => 'POST',
+                'content' => http_build_query($data)
+            )
+        );
+        $context = stream_context_create($options);
+        $verify = file_get_contents($url, false, $context);
+        $captcha_success = json_decode($verify);
+        if ($captcha_success->success === false) {
+            $result['message'] = 'Error: catcha failed';
+            return $result;
+        }
+    }
+
     // If we get to here, the form can be processed and the email sent.
     // First, build the email body
     $content = buildEmail($_POST);
@@ -108,6 +132,10 @@ function buildEmail($data)
         'organization' => ['fr' => 'Organization', 'en' => 'Organization'],
         'best_time_to_contact' => ['fr' => 'Heure de contact préférée', 'en' => 'Best time to contact'],
         'more_info' => ['fr' => 'Plus d\'information', 'en' => 'More info'],
+        'product_1' => ['fr' => 'Produit 1', 'en' => 'Product 1'],
+        'product_2' => ['fr' => 'Produit 2', 'en' => 'Product 2'],
+        'product_3' => ['fr' => 'Produit 3', 'en' => 'Product 3'],
+        'subscribe' => ['fr' => 'Inscription', 'en' => 'Subscribe'],
     ];
 
     $locale = $data['_locale'] ?? 'en';