Retour de l'ano 0000023 sur le Captcha : on remplace par un module qui fonctionne

This commit is contained in:
2020-06-01 19:39:33 +02:00
parent 7a37450953
commit 401fedea95
178 changed files with 15050 additions and 4938 deletions

View File

@@ -0,0 +1,104 @@
/**
* 2007-2019 ETS-Soft
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please contact us for extra customization service at an affordable price
*
* @author ETS-Soft <etssoft.jsc@gmail.com>
* @copyright 2007-2019 ETS-Soft
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of ETS-Soft
*/
var func_pa = {
renderTabs: function () {
if (typeof helper_config_tabs != 'undefined' && typeof unique_config_field_id != 'undefined') {
$.each(helper_config_tabs, function (index) {
$('#' + unique_config_field_id + 'fieldset_' + index + ' .form-wrapper').prepend('<div class="tab-content panel" />');
$('#' + unique_config_field_id + 'fieldset_' + index + ' .form-wrapper').prepend('<ul class="nav nav-tabs" />');
$.each(helper_config_tabs[index], function (key, value) {
$('#' + unique_config_field_id + 'fieldset_' + index + ' .tab-content').append('<div id="' + key + '" class="tab-pane" />');
var elemts = $('#' + unique_config_field_id + 'fieldset_' + index).find("[data-tab-id='" + key + "']");
$(elemts).appendTo('#' + key);
if (elemts.length != 0)
$('#' + unique_config_field_id + 'fieldset_' + index + ' .nav-tabs').append('<li><a href="#' + key + '" data-toggle="tab">' + value + '</a></li>');
});
$('#' + unique_config_field_id + 'fieldset_' + index + ' .tab-content div').first().addClass('active');
$('#' + unique_config_field_id + 'fieldset_' + index + ' .nav-tabs li').first().addClass('active');
});
}
},
captchaType: function (val) {
if (val == 'google' || ($('#PA_CAPTCHA_TYPE_google').length > 0 && $('#PA_CAPTCHA_TYPE_google').is(':checked'))) {
$('.row_pa_google_captcha_site_key, .row_pa_google_captcha_secret_key').show();
$('.row_pa_google_v3_captcha_site_key, .row_pa_google_v3_captcha_secret_key').hide();
} else if (val == 'google' || ($('#PA_CAPTCHA_TYPE_google_v3').length > 0 && $('#PA_CAPTCHA_TYPE_google_v3').is(':checked'))) {
$('.row_pa_google_v3_captcha_site_key, .row_pa_google_v3_captcha_secret_key').show();
$('.row_pa_google_captcha_site_key, .row_pa_google_captcha_secret_key').hide();
} else {
$('.row_pa_google_captcha_site_key, .row_pa_google_captcha_secret_key,.row_pa_google_v3_captcha_site_key, .row_pa_google_v3_captcha_secret_key').hide();
}
},
disableOverride: function () {
if ($('#PA_CAPTCHA_POSITION_contact').length > 0 && $('#PA_CAPTCHA_POSITION_contact').is(':checked')) {
$('.row_pa_captcha_tmp_contact').show();
} else if ($('#PA_CAPTCHA_POSITION_contact').length > 0) {
$('.row_pa_captcha_tmp_contact').hide();
func_pa.prop('#PA_CAPTCHA_TMP_CONTACT', false, true);
}
if ($('#PA_CAPTCHA_POSITION_login').length > 0 && $('#PA_CAPTCHA_POSITION_login').is(':checked')) {
$('.row_pa_captcha_tmp_login').show();
} else if ($('#PA_CAPTCHA_POSITION_login').length > 0) {
$('.row_pa_captcha_tmp_login').hide();
func_pa.prop('#PA_CAPTCHA_TMP_LOGIN', false, true);
}
if ($('#PA_CAPTCHA_POSITION_pwd_recovery').length > 0 && $('#PA_CAPTCHA_POSITION_pwd_recovery').is(':checked')) {
$('.row_pa_captcha_tmp_re_password').show();
} else if ($('#PA_CAPTCHA_POSITION_pwd_recovery').length > 0) {
$('.row_pa_captcha_tmp_re_password').hide();
func_pa.prop('#PA_CAPTCHA_TMP_RE_PASSWORD', false, true);
}
},
prop: function (uniqueId, on, off) {
if ($(uniqueId + '_on').length > 0) {
$(uniqueId + '_on').prop('checked', on);
}
if ($(uniqueId + '_off').length > 0) {
$(uniqueId + '_off').prop('checked', off);
}
},
}
$(document).ready(function () {
//init form.
func_pa.disableOverride();
func_pa.renderTabs();
func_pa.captchaType(false);
//event form.
$('input[name="PA_CAPTCHA_TYPE"]').change(function () {
func_pa.captchaType($(this).val());
});
$('input[id^="PA_CAPTCHA_POSITION"]').change(function () {
func_pa.disableOverride();
});
//tab ver15.
if (typeof pa_is15 !== "undefined" && pa_is15 && $('#fieldset_0 .nav-tabs li').length > 0) {
$('#fieldset_0 .nav-tabs li').click(function (e) {
e.preventDefault();
if (!$(this).hasClass('active')) {
$('#fieldset_0 .nav-tabs li').removeClass('active');
$(this).addClass('active');
$('#fieldset_0 .tab-content div').removeClass('active');
$($(this).find('a').attr('href')).addClass('active');
}
});
}
});

View File

@@ -0,0 +1,218 @@
/**
* 2007-2019 ETS-Soft
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please contact us for extra customization service at an affordable price
*
* @author ETS-Soft <etssoft.jsc@gmail.com>
* @copyright 2007-2019 ETS-Soft
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of ETS-Soft
*/
var PA_GOOGLE_V3_CAPTCHA_SITE_KEY = PA_GOOGLE_V3_CAPTCHA_SITE_KEY || false;
var func_pa = {
addNotification: function () {
var ids = $('div.js-mailalert > input[type=hidden]');
var captchaParams = '';
if ($('div.js-mailalert textarea[name=g-recaptcha-response]').length > 0) {
captchaParams += '&g-recaptcha-response=' + $('div.js-mailalert textarea[name=g-recaptcha-response]').val();
} else if ($('div.js-mailalert input[name=pa_captcha]').length > 0) {
captchaParams += '&pa_captcha=' + $('div.js-mailalert input[name=pa_captcha]').val();
}
if ($('div.js-mailalert input[name=posTo]').length > 0) {
captchaParams += '&posTo=' + $('div.js-mailalert input[name=posTo]').val();
}
$.ajax({
type: 'POST',
url: $('div.js-mailalert').data('url'),
data: 'id_product=' + ids[0].value + '&id_product_attribute=' + ids[1].value + '&customer_email=' + $('div.js-mailalert > input[type=email]').val() + (captchaParams ? captchaParams : ''),
success: function (resp) {
resp = JSON.parse(resp);
$('div.js-mailalert > span').html('<article class="alert alert-' + (resp.error ? 'danger' : 'success') + '" role="alert" data-alert="' + (resp.error ? 'error' : 'success') + '">' + resp.message + '</article>').show();
if (!resp.error) {
$('div.js-mailalert > button').hide();
$('div.js-mailalert > input[type=email]').hide();
$('div.js-mailalert > #gdpr_consent').hide();
$('div.js-mailalert > .captcha_out_of_stock').hide();
}
if ($('div.js-mailalert input[name=pa_captcha]').length > 0) {
$('div.js-mailalert input[name=pa_captcha]').val('');
}
}
});
if ($('div.js-mailalert img.pa_captcha_img_data').length > 0) {
func_pa.refreshCaptcha($('div.js-mailalert img.pa_captcha_img_data').removeClass('loaded'));
} else {
func_pa.resetReCaptcha();
}
return false;
},
addNotification16: function () {
if ($('#oosHook .gdpr_hook.receive').length > 0 && !$('.pa_notify input[name=gdpr_accept]').is(':checked')) {
$('#pa_mailalert_link').prop('disabled', true);
return false;
}
if ($('#pa_oos_customer_email').val() == mailalerts_placeholder || (typeof mailalerts_url_add == 'undefined')) {
return false;
}
var captchaParams = '';
if ($('.pa_notify textarea[name=g-recaptcha-response]').length > 0) {
captchaParams += '&g-recaptcha-response=' + $('.pa_notify textarea[name=g-recaptcha-response]').val();
} else if ($('.pa_notify input[name=pa_captcha]').length > 0) {
captchaParams += '&pa_captcha=' + $('.pa_notify input[name=pa_captcha]').val();
}
if ($('.pa_notify input[name=posTo]').length > 0) {
captchaParams += '&posTo=' + $('.pa_notify input[name=posTo]').val();
}
$.ajax({
type: 'POST',
url: mailalerts_url_add,
data: 'id_product=' + id_product + '&id_product_attribute=' + $('#idCombination').val() + '&customer_email=' + $('#pa_oos_customer_email').val() + (captchaParams ? captchaParams : ''),
success: function (json) {
if (json == '-1') {
$('#pa_oos_customer_email_result').html(mailalerts_captcha_error);
$('#pa_oos_customer_email_result').css('color', 'red').show();
} else if (json == '1') {
$('#pa_mailalert_link, #pa_oos_customer_email, .pa_notify .page_product').hide();
$('#oosHook').find('#gdpr_consent').hide();
$('#pa_oos_customer_email_result').html(mailalerts_registered);
$('#pa_oos_customer_email_result').css('color', 'green').show();
} else if (json == '2') {
$('#pa_oos_customer_email_result').html(mailalerts_already);
$('#pa_oos_customer_email_result').css('color', 'red').show();
} else {
$('#pa_oos_customer_email_result').html(mailalerts_invalid);
$('#pa_oos_customer_email_result').css('color', 'red').show();
}
if ($('.pa_notify input[name=pa_captcha]').length > 0) {
$('.pa_notify input[name=pa_captcha]').val('');
}
}
});
if ($('.pa_notify img.pa_captcha_img_data').length > 0) {
func_pa.refreshCaptcha($('.pa_notify img.pa_captcha_img_data').removeClass('loaded'));
} else {
func_pa.resetReCaptcha();
}
return false;
},
refreshCaptcha: function (img) {
if (img.length && !img.hasClass('loaded')) {
var orgLink = img.attr('src');
var orgCode = img.attr('data-rand');
var rand = Math.random();
img.attr('src', orgLink.replace(orgCode, rand));
img.attr('data-rand', rand);
if (!img.hasClass('loaded')) {
img.addClass('loaded');
}
}
},
resetReCaptcha: function () {
if (typeof recaptchaWidgets !== "undefined" && typeof grecaptcha !== "undefined") {
for (var i = 0; i < recaptchaWidgets.length; i++) {
grecaptcha.reset(recaptchaWidgets[i]);
}
}
},
loadCaptcha: function () {
var img = $('.pa_captcha_img_data:not(.loaded)').first();
if (img.length > 0) {
img.load(function () {
if (!img.hasClass('loaded')) {
func_pa.refreshCaptcha(img);
}
if (img[0].complete && img.hasClass('loaded')) {
func_pa.loadCaptcha();
}
}).filter(function () {
return this.complete;
}).load();
}
},
loadReCaptchaV3: function (form) {
if ($('form:not(.g-loaded)').length <= 0 || !PA_GOOGLE_V3_CAPTCHA_SITE_KEY) {
return false;
}
var g_captcha = form.find('input[name=g-recaptcha-response]');
if (g_captcha.length > 0 && $('body').attr('id')) {
grecaptcha.ready(function () {
grecaptcha.execute(PA_GOOGLE_V3_CAPTCHA_SITE_KEY, {action: $('body').attr('id').replace(/(?=[^A-Za-z\_])([^A-Za-z\_])/g, '_')}).then(function (token) {
if (token) {
g_captcha.val(token);
form.addClass('g-loaded');
func_pa.loadReCaptchaV3($('form:not(.g-loaded)'));
}
});
});
}
}
}
$(document).ready(function () {
if (PA_GOOGLE_V3_CAPTCHA_SITE_KEY) {
func_pa.loadReCaptchaV3($('form:not(.g-loaded)'));
}
$('.pa_captcha_img_data.loaded').removeClass('loaded');
$(document).on('click', '#pa_captcha_refesh', function (e) {
e.preventDefault();
func_pa.refreshCaptcha($(this).parents('.pa_captcha_img').find('.pa_captcha_img_data').removeClass('loaded'));
$(this).parents('.pa-captcha-inf').find('input[name=pa_captcha]').val('');
});
$(document).on('keypress', '#pa_oos_customer_email', function (e) {
if (e.keyCode == 13) {
e.preventDefault();
func_pa.addNotification16();
}
});
});
document.addEventListener("DOMContentLoaded", function (event) {
if ($('.forgot-password').length > 0 && $('.login.page_order').length > 0) {
$('.forgot-password').before($('.login.page_order').clone(true).addClass('copy'));
$('.login.page_order:not(.copy)').detach();
} else
$('.login.page_order').detach();
if ($('.pa_captcha_img_data').length > 1) {
func_pa.loadCaptcha();
}
});
$(document).ajaxComplete(function (event, xhr, options) {
if ($('.quickview').length > 0 && typeof ets_captcha_load !== "undefined") {
ets_captcha_load($('.quickview'));
} else if ($('body#authentication').length > 0 && typeof options.data !== "undefined" && options.data.indexOf('SubmitCreate') != -1) {
var time_secs = 0, sec = 150;
var intervalSet = setInterval(function () {
time_secs += sec;
if ($('#account-creation_form.g-loaded').length <= 0) {
if (PA_GOOGLE_V3_CAPTCHA_SITE_KEY) {
func_pa.loadReCaptchaV3($('form:not(.g-loaded)'));
} else if (typeof ets_captcha_load !== "undefined") {
ets_captcha_load($('#account-creation_form').addClass('g-loaded'));
}
} else if (time_secs > sec * 10) {
clearInterval(intervalSet);
}
}, sec);
} else if (($('body#order-opc').length > 0 || $('body#orderopc').length > 0) && $('[name=g-recaptcha-response]').length > 0 && typeof options.data !== "undefined" && options.data.indexOf('submitAccount') != -1) {
if (PA_GOOGLE_V3_CAPTCHA_SITE_KEY) {
func_pa.loadReCaptchaV3($('form#new_account_form').removeClass('g-loaded'));
} else if (typeof grecaptcha !== "undefined") {
grecaptcha.reset();
}
}
});
$(document).ready(function () {
if ($('input[name="captcha"]').parent().parent().length && $('.captcha_register').length) {
var div_clone = $('input[name="captcha"]').parent().parent().clone();
$('input[name="captcha"]').parent().parent().hide();
$('.captcha_register.register').after(div_clone);
}
});

View File

@@ -0,0 +1,36 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,109 @@
/**
* 2007-2019 ETS-Soft
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please contact us for extra customization service at an affordable price
*
* @author ETS-Soft <contact@etssoft.net>
* @copyright 2007-2019 ETS-Soft
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of ETS-Soft
*/
$(document).on('click','.link_othermodules',function(){
if($('.ets-mod').length > 0)
{
$('.ets-mod').removeClass('hidden');
$('body').addClass('other-modules-loaded');
}
else
if(!$(this).hasClass('active'))
{
$(this).addClass('active');
$('body').addClass('loading-modules');
$.ajax({
url: $(this).attr('href'),
type: 'post',
success: function(html){
$('body').append(html);
$('.link_othermodules').removeClass('active');
$('.ets-mod').removeClass('hidden');
$('body').addClass('other-modules-loaded').removeClass('loading-modules');
var cat_text_first = $('.ets-mod-cats > li:first').html();
$('.ets-mod-cats_mobile h4').html(cat_text_first);
stickytableft();
},
error: function()
{
$('body').removeClass('loading-modules');
$('.link_othermodules').removeClass('active');
window.open("https://addons.prestashop.com/en/207_ets-soft");
}
});
}
return false;
});
$(document).on('click','.ets-mod-close',function(){
$('.ets-mod').addClass('hidden');
$('body').removeClass('other-modules-loaded');
});
$(document).on('click','.ets-mod-cats > li',function(){
if(!$(this).hasClass('active'))
{
$('.ets-mod-cats > li').removeClass('active');
$(this).addClass('active');
$('.ets-mod-list > li').addClass('hidden');
$('.ets-mod-list > li.cat-'+$(this).attr('data-id')).removeClass('hidden');
var cattext = $(this).html();
$('.ets-mod-cats_mobile h4').html(cattext);
$(this).parent('.ets-mod-cats').removeClass('active');
}
});
$(document).on('click','.ets-mod-cats_mobile h4',function(){
$('.ets-mod-cats').toggleClass('active');
});
$(document).ready(function(){
$(document).keyup(function(e) {
if (e.key === "Escape") {
$('.ets-mod').addClass('hidden');
$('body').removeClass('other-modules-loaded');
}
});
menuheaderheight();
$(window).resize(function(){
menuheaderheight();
});
$(window).load(function(){
menuheaderheight();
});
});
function menuheaderheight(){
var menuheight = $('.cfu-top-menu').height();
$('.cfu-top-menu-height').css('height',menuheight);
}
function stickytableft(){
var sticky_navigation_offset_top = $('.ets-body').offset().top;
var sticky_navigation = function(){
var scroll_top = $('.ets-mod').scrollTop();
var tab_width = $('.ets-mod-cats').width();
$('.ets-mod-cats').width(tab_width);
if (scroll_top > sticky_navigation_offset_top) {
$('.ets-mod-left').addClass('scroll_heading');
} else {
$('.ets-mod-left').removeClass('scroll_heading');
}
};
sticky_navigation();
$('.ets-mod').scroll(function() {
sticky_navigation();
});
}