var useragent = 1, sb_alerts, inviato = false, sb_workdir = 'botbusters'; jQuery(document).ready(function($) { if(1) { jQuery(document) .find('.wpcf7') .find('form') .append('
') .append('') .append(``); } if(1) { 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, textSubmit = ''; jQuery('.wpcf7 input[type="submit"]').on('click', function (e) { //Controllo se i controlli lato client sono abilitati if('0' == '1') { e.preventDefault(); e.stopImmediatePropagation(); } //creo una div che sovrapponga tutto il form così da non permettere nessun ulteriore click textSubmit = jQuery(this).val(); jQuery(this).val('').addClass('wpsb-loader').closest('form').append('
'); let form = jQuery(this).closest('form'); let formData = new FormData(); formData.append('servertime', 1); //javascript fetch post //ottengoo l'url di questo script fetch(`//${window.location.hostname}/wp-content/plugins/${sb_workdir}/js/main.js.php`, { method: 'POST', body: formData, }) .then(response => response.text()) .then(result => { if(result != '') { result = JSON.parse(result); //Check antirimbalzo:=------------------------------------ checkAntirimbalzo = setInterval(function() { if(jQuery('.wpcf7 form').hasClass('invalid') && jQuery('.wpcf7 form').attr('data-status') != 'sent') { console.log('invalid compiled form'); jQuery('.wpcf7 input[type="submit"]').val(textSubmit).removeClass('wpsb-loader'); //jQuery('.wpcf7-form').find('input[type="submit"]') jQuery('.sovrappogo').remove(); clearInterval(checkAntirimbalzo); } }, 100); //hhhhhhhhhhhhhhhhhhh:=------------------------------------ let nosend = [], causa = '', fdata = jQuery(form).serializeArray().reduce(function(obj, item) { obj[item.name] = item.value; return obj; }, {}); //Controllo se son stati compilati tutti i campi obbligatori let sb_check_aria_required = true; $('input', $(form)).each(function () { if($(this).attr('aria-required') || $(this).attr('required') || ($(this).attr('type') == 'checkbox' && $(this).attr('aria-invalid') == 'false')) { if($(this).val() == '' && $(this).attr('type') != 'checkbox') sb_check_aria_required = false; if(!$(this).is(':checked') && $(this).attr('type') == 'checkbox') sb_check_aria_required = false; } }); //Controllo che il form non sia del tutto vuoto if(sb_check_aria_required && '0' == '1') { //Controllo Honeypot if(1) { if(jQuery(form).find('#vasodimiele').val() != '') nosend.push(1); } //Controllo telefono if(1) { 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 (1) { if(useragent != 1) { nosend.push(2); } } //Controllo tempo di compilazione if(1) { let timestamp = ((atob(decodeURIComponent(jQuery(form).find('input[name="wpsb_timestamp"]').val())) * 1000) + (3 * 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).find('.wpcf7-response-output').remove(); jQuery(form).append(` `); } //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(`
${msg_error('errors')}
`); for(causa of nosend) { switch (causa) { case 1: causa = msg_error('honeypot'); break; case 2: causa = msg_error('user_agent'); break; case 3: causa = msg_error("code"); break; case 4: causa = msg_error("time"); break; case 5: causa = msg_error("phone"); 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/${sb_workdir}/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(textSubmit).removeClass('wpsb-loader'); let cf7_id = jQuery(form).closest('.wpcf7').attr('id').split('-')[1].replace(/\D/g,''); sb_redirect_after_submit('err', cf7_id); }, error: function(error) { console.log('Errore scacciabot'); let cf7_id = jQuery(form).closest('.wpcf7').attr('id').split('-')[1].replace(/\D/g,''); sb_redirect_after_submit('err', cf7_id); } }); }else{ if(!inviato) { form.submit(); //dopo aver aspettato nu poco considero il form submittato - lo so non è il top però oh a mali estremi estremi rimedi //ricavo l'id del contact form let cf7_id = jQuery(form).closest('.wpcf7').attr('id').split('-')[1].replace(/\D/g,''); console.log('ricavo pagina redirect', cf7_id); sb_redirect_after_submit('ok', cf7_id); inviato = true; } return false; } }else{ setTimeout(function () { let cf7_id = jQuery(form).closest('.wpcf7').attr('id').split('-')[1].replace(/\D/g,''); if(jQuery(form).html().includes('not-valid') || (jQuery(form).attr('data-status') == 'sent' && !jQuery(form).attr('data-status') == 'sent')) { if(jQuery(form).html().includes('not-valid')) console.log('contiene not-valid'); if(jQuery(form).attr('data-status') == 'sent') console.log('contiene invalid'); jQuery('.sovrappogo').remove(); jQuery(form).find('.wpcf7-response-output').remove(); jQuery(form).append(` `); sb_redirect_after_submit('err', cf7_id); }else{ console.log('non contiene errore'); sb_redirect_after_submit('ok', cf7_id); } //TIMOUT CHE NAASDISCE IL MESSAGGIO DI ERRORE // jQuery(form).find('.wpcf7-response-output').hide(); }, 1500); // jQuery(form).find('input[type="submit"]').prop('disabled', false).val('Invia'); // let cf7_id = jQuery(form).closest('.wpcf7').attr('id').split('-')[1].replace(/\D/g,''); // sb_redirect_after_submit('err', cf7_id); } } }).catch(function (error) { jQuery('.sovrappogo').remove(); jQuery(form).find('input[type="submit"]').prop('disabled', false).val(textSubmit).removeClass('wpsb-loader'); console.log(error); return false; }); }); }); 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').remove(); jQuery(form).find('.wpcf7-response-output').append(`
    ${msg_error('errors')}
    `); jQuery(form).find('.wpcf7-response-output').find('ul').html(sb_alerts); clearInterval(sb_keepErrmsg); } } function sb_redirect_after_submit(type, formid) { console.log('siamo qua'); let formData = new FormData(); formData.append('action', 'get-action-page'); formData.append('formname', formid); formData.append('type', type); fetch(`//${window.location.hostname}/wp-content/plugins/${sb_workdir}/sb_main.php`, { method: 'POST', body: formData }) .then(response => response.json()) .then(data => { console.log('Success:', data); if(data.status == 'ok') location.replace(data.redirect); }) .catch(error => { console.error('Error:', error); }); } function msg_error(msg_id) { //Prima ottengo la lingua del sito let lang = jQuery('html').attr('lang').split('-')[0]; let msg = { 'it': { 'err': 'Errore', 'missing_field': 'Uno o più campi hanno degli errori. Controlla e riprova.', 'errors': 'Abbiamo riscontrato i seguenti errori:', 'honeypot': 'Test Honeypot non valido!', 'user_agent': "Discrepanza nell'User Agent", "code": "Codice di controllo errato", "time": "Tempo di compilazione e invio form", "phone": "Numero di telefono sospetto", }, 'en': { 'err': 'Error', 'missing_field': 'One or more fields have errors. Check and try again.', 'errors': 'We have found the following errors:', 'honeypot': 'Honeypot test not valid!', 'user_agent': "Discrepancy in the User Agent", "code": "Wrong control code", "time": "Form filling and sending time", "phone": "Suspicious phone number" } } console.log(lang); //se esiste la traduzione la ritorno altrimenti la ritorno in inglese if(msg[lang] !== undefined) return msg[lang][msg_id]; else return msg['en'][msg_id]; }