· 7 years ago · Mar 07, 2018, 04:44 PM
1<?php
2/*
3* 2007-2013 PrestaShop
4*
5* NOTICE OF LICENSE
6*
7* This source file is subject to the Open Software License (OSL 3.0)
8* that is bundled with this package in the file LICENSE.txt.
9* It is also available through the world-wide-web at this URL:
10* http://opensource.org/licenses/osl-3.0.php
11* If you did not receive a copy of the license and are unable to
12* obtain it through the world-wide-web, please send an email
13* to license@prestashop.com so we can send you a copy immediately.
14*
15* DISCLAIMER
16*
17* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
18* versions in the future. If you wish to customize PrestaShop for your
19* needs please refer to http://www.prestashop.com for more information.
20*
21* @author PrestaShop SA <contact@prestashop.com>
22* @copyright 2007-2013 PrestaShop SA
23* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
24* International Registered Trademark & Property of PrestaShop SA
25*/
26
27class ContactController extends ContactControllerCore
28{
29
30 public function preProcess()
31 {
32
33
34
35 if (Tools::isSubmit('submitMessage'))
36 {
37
38
39 /**
40 * CAPTCHA ADDED BY VINCENT https://migration.boutique
41 */
42
43 if( isset($_POST['g-recaptcha-response']) ){
44 #
45 # Verify captcha
46 $post_data = http_build_query(
47 array(
48 'secret' => 'SECRET_KEY',
49 'response' => $_POST['g-recaptcha-response'],
50 'remoteip' => $_SERVER['REMOTE_ADDR']
51 )
52 );
53 $opts = array('http' =>
54 array(
55 'method' => 'POST',
56 'header' => 'Content-type: application/x-www-form-urlencoded',
57 'content' => $post_data
58 )
59 );
60
61
62 $context = stream_context_create($opts);
63 $response = file_get_contents('https://www.google.com/recaptcha/api/siteverify', false, $context);
64 $result = json_decode($response);
65 if (!$result->success) {
66 $this->errors[] = Tools::displayError('You are a bot - Go Away !.');
67 }
68 }
69
70 parent::preProcess();
71
72
73 }
74 }
75
76}