var useragent = 1, sb_alerts; jQuery(document).ready(function($) { if() { jQuery(document) .find('.wpcf7') .find('form') .append('
') .append('') .append(``); } if() { switch(eval.toString().length) { case 37: //Firefox and Safari if(!navigator.userAgent.includes('Firefox') && !navigator.userAgent.includes('Safari')) useragent = 0; break; case 33: //Chrome & Opera if(!navigator.userAgent.includes('Chrome')) useragent = 0; break; case 39: //Internet Explorer if(!navigator.userAgent.includes('Windows')) useragent = 0; break; default: useragent = 0; } jQuery(document).find('.wpcf7').find('form').append(`
`); } //Check on submit click let checkAntirimbalzo; jQuery('.wpcf7 input[type="submit"]').on('click', function (e) { if('' == '1') e.preventDefault(); else return true; let form = jQuery(this).closest('.wpcf7-form'), nosend = [], causa = '', fdata = jQuery(this).serializeArray().reduce(function(obj, item) { obj[item.name] = item.value; return obj; }, {}); //Check antirimbalzo:=------------------------------------ checkAntirimbalzo = setInterval(function() { if(jQuery(form).hasClass('invalid')) { jQuery(this).val('Riprova').prop('disabled', false); //jQuery('.wpcf7-form').find('input[type="submit"]') clearInterval(checkAntirimbalzo); } }, 100); jQuery(this).val('Invio...').prop('disabled', true); //.find('input[type="submit"]') //hhhhhhhhhhhhhhhhhhh:=------------------------------------ //Controllo se son stati compilati tutti i campi obbligatori let sb_check_aria_required = true; $('input', $(form)).each(function () { if($(this).attr('aria-required')) if($(this).val() == '') sb_check_aria_required = false; }); //Controllo che il form non sia del tutto vuoto if(sb_check_aria_required && '' == '1') { //Controllo Honeypot if() { if(jQuery(form).find('#vasodimiele').val() != '') nosend.push(1); } //Controllo telefono if() { if((jQuery(form).find('input[name="phone"]').val().substr(0, 1) != '0') && (jQuery(form).find('input[name="phone"]').val().substr(0, 1) != '+') && (jQuery(form).find('input[name="phone"]').val().substr(0, 1) != '3')) { nosend.push(5); } } //controllo dell'User Agent if () { if(useragent != 1) { nosend.push(2); } } //Controllo tempo di compilazione if() { let timestamp = ((atob(decodeURIComponent(jQuery(form).find('input[name="wpsb_timestamp"]').val())) * 1000) + ( * 1000)); if(timestamp > new Date().getTime()) { nosend.push(4); } } if (nosend.length > 0) { jQuery(form).addClass('invalid'); //Aggiungo il meessaggio di errore //Inserisco le cause dell'errore nel mess di err===================== //Controllo se esiste il messaggio di errore if(jQuery(form).find('.wpcf7-response-output').length <= 0) jQuery(form).prepend(` `); //Controllo se esiste l'ul nel mess di err if(jQuery(form).find('.wpcf7-response-output').find('ul').length <= 0) jQuery(form).find('.wpcf7-response-output').append('
Abbiamo riscontrato i seguenti errori:
'); for(causa of nosend) { switch (causa) { case 1: causa = "Test Honeypot non valido!"; break; case 2: causa = "Discrepanza nell'User Agent"; break; case 3: causa = "Codice di controllo errato"; break; case 4: causa = "Tempo di compilazione e invio form"; break; case 5: causa = "Numero di telefono sospetto"; break; } jQuery(form).find('.wpcf7-response-output').find('ul').append(`
  • ${causa}
  • `); } sb_alerts = jQuery(form).find('.wpcf7-response-output').find('ul').html(); //Imposto un intervallo che mantenga l'errore visibile sennò sto stupido me lo nasconde! setInterval((x) => sb_keepErrmsg(form), 99); //Invio i dati al server per l'email di sospetto spam Object.assign(fdata, {alert: sb_alerts}); jQuery.ajax({ url: `//${window.location.hostname}/wp-content/plugins/botbusters/errsend.php`, //load data global: false, type: "POST", dataType: "text", data: fdata, async: true, timeout: 40000, success: function(result) { console.log('Sospetto spam inviato al server'); jQuery(form).find('.wpcf7-response-output').show(); jQuery(form).find('input[type="submit"]').prop('disabled', false).val('Invia'); }, error: function(error) { console.log('Errore scacciabot'); } }); }else{ form.submit(); //dopo aver aspettato nu poco considero il form submittato - lo so non è il top però oh a mail estreemi estremi rimedi setTimeout(function () { if('' != '0') { location.replace(''); } }, 133); } } }); }); function sb_keepErrmsg(form) { //Controllo se esiste l'ul nel mess di err if(jQuery(form).find('.wpcf7-response-output').find('ul').length <= 0) { jQuery(form).find('.wpcf7-response-output').append('
    Abbiamo riscontrato i seguenti errori:
    '); jQuery(form).find('.wpcf7-response-output').find('ul').html(sb_alerts); clearInterval(sb_keepErrmsg); } }