shop->id)) { $sql = ' INSERT INTO '._DB_PREFIX_.'newsletter (id_shop, id_shop_group, email, newsletter_date_add, ip_registration_newsletter, http_referer, active) VALUES ('.$context->shop->id.', '.$context->shop->id_shop_group.', \''.pSQL($email).'\', NOW(), \''.pSQL(Tools::getRemoteAddr()).'\', ( SELECT c.http_referer FROM '._DB_PREFIX_.'connections c WHERE c.id_guest = '.(int)$context->customer->id.' ORDER BY c.date_add DESC LIMIT 1 ), 1 )'; Db::getInstance()->execute($sql); } } $comments = new CmsComments(); $comments->published = 0; $comments->name = $name; $comments->email = $email; $comments->comments = $commentaire; $comments->id_element = $cmsps->id; if ($comments->add()) { $result['errors'] = false; Mail::Send( Context::getContext()->language->id, 'commentaire', Mail::l('Nouveau commentaire'), array( '{comments}' => $commentaire, '{name}' => $name, '{email}' => $email, '{title}' => $cmsps->title[(int) $context->language->id] ), 'claudine@toutpratique.com' ); } } else { $result['errors'] = true; } die(Tools::jsonEncode($result)); function isValid($code) { if (empty($code)) { return false; } $params = array( 'secret' => '6LchYwsTAAAAAFSK4EEtSJV3kJon6H7bEgOTpLA0', 'response' => $code ); $url = "https://www.google.com/recaptcha/api/siteverify?" . http_build_query($params); if (function_exists('curl_version')) { $curl = curl_init($url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); } else { $response = file_get_contents($url); } if (empty($response) || is_null($response)) { return false; } $json = json_decode($response); return (bool) $json->success; } function isNewsletterRegistered($customer_email, $id_shop) { $sql = 'SELECT `email` FROM '._DB_PREFIX_.'newsletter WHERE `email` = \''.pSQL($customer_email).'\' AND id_shop = '.$id_shop; if (Db::getInstance()->getRow($sql)) return TRUE; return FALSE; }