diff --git a/inc/spbc-admin.php b/inc/spbc-admin.php index 220e97380..aac47ba8d 100644 --- a/inc/spbc-admin.php +++ b/inc/spbc-admin.php @@ -255,19 +255,25 @@ function spbc_theme_list_show_vulnerability() try { if (isset($_POST['list'])) { $list = $_POST['list']; - $safe_themes = VulnerabilityAlarm::checkThemesVulnerability($list); + + $vulnerable_themes_reports = VulnerabilityAlarm::checkThemesVulnerability($list); $data = [ 'success' => true, - 'msg' => VulnerabilityAlarm::showThemeAlarm(), 'list' => [], ]; - foreach ($list as $theme) { - if (in_array($theme, $safe_themes)) { - $data['list'][] = $theme; + + foreach ($list as $installed_theme) { + foreach ($vulnerable_themes_reports as $report) { + if ($installed_theme['slug'] = $report->slug) { + $vulnerable_theme_data = array( + 'slug' => $installed_theme['slug'], + 'msg' => VulnerabilityAlarm::showThemeAlarm($report) + ); + $data['list'][] = $vulnerable_theme_data; + } } } - wp_send_json($data); } } catch (\Exception $_exception) { diff --git a/js/spbc-admin.min.js b/js/spbc-admin.min.js index 219296c00..f3d80f71d 100644 --- a/js/spbc-admin.min.js +++ b/js/spbc-admin.min.js @@ -1,2 +1,2 @@ -function spbcGetGoogleQrCode(){var e={};let t={};return e.security=spbcSettings.ajax_nonce,e.action="spbc_get_google_qr_code",jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:e,success:function(e){t=e}}),t}function spbcCheckGoogleCode(){var e={};e.security=spbcSettings.ajax_nonce,e.action="spbc_check_google_code",e.code=jQuery("#spbct-google-qr-code input").val(),jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:e,success:function(e){e.success?(jQuery("#spbct-google-qr-code").dialog("close"),document.location.reload()):alert(e.data)}})}function spbcDisableG2fa(e){var t={};t.security=spbcSettings.ajax_nonce,t.action="spbc_disable_google_2fa",t.user_id=jQuery(e).data("user-id"),jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:t,success:function(e){e.success?document.location.reload():alert(e.data)}})}function spbcCheckVulnerability(e,t="install"){var c={};c.security=spbcSettings.ajax_nonce,c.action="install"===t?"spbc_check_vulnerability_install":"spbc_check_vulnerability_list",c.list=e,jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:c,success:function(e){e.success?("install"===t&&spbcCheckVulnerabilityInstallRender(e.list,e.msg),"list"===t&&spbcCheckVulnerabilityListRender(e.list,e.msg)):console.log(e)}})}function spbcCheckVulnerabilityListRender(e,t){let c,n;e.forEach(e=>{(n=document.createElement("div")).classList.add("notice","notice-error","error-message"),n.innerHTML="

"+t+"

",(c=document.querySelector(".themes .theme[data-slug="+e+"]"))&&c.appendChild(n)})}function spbcCheckVulnerabilityInstallRender(e,t){let c,n=document.createElement("div");n.classList.add("notice"),n.innerHTML="

"+t+"

",e.forEach(e=>{(c=document.querySelector(".theme-id-container .theme-actions a[data-slug="+e+"]"))&&c.parentNode.parentNode.parentNode.appendChild(n)})}function spbcSummaryShowCDNCheckerTable(){event.preventDefault();var e=document.getElementById("spbc_stats_cdn_checker_table");void 0!==e&&("block"===e.style.display?e.style.display="none":e.style.display="block")}jQuery(document).ready(function(){if(-1"+e.data.code+"

"),jQuery("#spbct-google-qr-code input").val(""),jQuery("#spbct-google-qr-code").dialog({modal:!0,title:"Google authenticator activation",buttons:{Cancel:function(){jQuery(this).dialog("close")},Ok:function(){spbcCheckGoogleCode()}},draggable:!1,resizable:!1})):alert(spbcGetGoogleQrCode.data)}),jQuery(document).on("click","#spbc-g2fa-disable",function(e){e.preventDefault(),confirm("Are you sure?")&&spbcDisableG2fa(this)});function e(e,t,c){setTimeout(function(){null!==e&&(jQuery(".spbc-admin_bar--user_counter").html(e.count),e.count<=3?(jQuery("#wp-admin-bar-spbc_admin_bar__online_admins").show(),jQuery(".spbc-admin_bar--online_admins").html(e.users.join(", "))):jQuery("#wp-admin-bar-spbc_admin_bar__online_admins").hide()),spbcSendAJAXRequest(t,c)},15e3)}1==+spbcSettings.admin_bar__admins_online_counter&&e(null,{action:"spbc_get_authorized_admins"},{callback:e}),jQuery("body").on("click",".spbct-notice-dismiss-link",function(e){jQuery(e.target).siblings(".notice-dismiss").click()}),jQuery("body").on("click",".spbc-notice .notice-dismiss",function(e){var t,c=jQuery(e.target).parent(".notice").attr("id");c&&(t='

'+spbcSettings.spbctNoticeDismissSuccess+"

",spbcSendAJAXRequest({action:"spbc_dismiss_banner",banner_id:c},{}),jQuery(e.target).parent(".notice").after(t),setTimeout(function(){jQuery("#spbct-notice-dismiss-success").fadeOut()},2e3))}),1==+spbcSettings.needToWhitelist&&spbcSendAJAXRequest({action:"spbc_private_list_add"},{callback:null})}); +function spbcGetGoogleQrCode(){var e={};let t={};return e.security=spbcSettings.ajax_nonce,e.action="spbc_get_google_qr_code",jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:e,success:function(e){t=e}}),t}function spbcCheckGoogleCode(){var e={};e.security=spbcSettings.ajax_nonce,e.action="spbc_check_google_code",e.code=jQuery("#spbct-google-qr-code input").val(),jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:e,success:function(e){e.success?(jQuery("#spbct-google-qr-code").dialog("close"),document.location.reload()):alert(e.data)}})}function spbcDisableG2fa(e){var t={};t.security=spbcSettings.ajax_nonce,t.action="spbc_disable_google_2fa",t.user_id=jQuery(e).data("user-id"),jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:t,success:function(e){e.success?document.location.reload():alert(e.data)}})}function spbcCheckVulnerability(e,t="install"){var c={};c.security=spbcSettings.ajax_nonce,c.action="install"===t?"spbc_check_vulnerability_install":"spbc_check_vulnerability_list",c.list=e,jQuery.ajax({type:"POST",async:!1,url:spbcSettings.ajaxurl,data:c,success:function(e){e.success?("install"===t&&spbcCheckVulnerabilityInstallRender(e.list,e.msg),"list"===t&&spbcCheckVulnerabilityListRender(e.list)):console.log(e)}})}function spbcCheckVulnerabilityListRender(e){let t,c;e.forEach(e=>{(c=document.createElement("div")).classList.add("notice","notice-error","error-message"),c.innerHTML=e.msg,(t=document.querySelector(".themes .theme[data-slug="+e.slug+"]"))&&t.appendChild(c)})}function spbcCheckVulnerabilityInstallRender(e,t){let c,s=document.createElement("div");s.classList.add("notice"),s.innerHTML="

"+t+"

",e.forEach(e=>{(c=document.querySelector(".theme-id-container .theme-actions a[data-slug="+e+"]"))&&c.parentNode.parentNode.parentNode.appendChild(s)})}function spbcSummaryShowCDNCheckerTable(){event.preventDefault();var e=document.getElementById("spbc_stats_cdn_checker_table");void 0!==e&&("block"===e.style.display?e.style.display="none":e.style.display="block")}jQuery(document).ready(function(){if(-1"+e.data.code+"

"),jQuery("#spbct-google-qr-code input").val(""),jQuery("#spbct-google-qr-code").dialog({modal:!0,title:"Google authenticator activation",buttons:{Cancel:function(){jQuery(this).dialog("close")},Ok:function(){spbcCheckGoogleCode()}},draggable:!1,resizable:!1})):alert(spbcGetGoogleQrCode.data)}),jQuery(document).on("click","#spbc-g2fa-disable",function(e){e.preventDefault(),confirm("Are you sure?")&&spbcDisableG2fa(this)});function e(e,t,c){setTimeout(function(){null!==e&&(jQuery(".spbc-admin_bar--user_counter").html(e.count),e.count<=3?(jQuery("#wp-admin-bar-spbc_admin_bar__online_admins").show(),jQuery(".spbc-admin_bar--online_admins").html(e.users.join(", "))):jQuery("#wp-admin-bar-spbc_admin_bar__online_admins").hide()),spbcSendAJAXRequest(t,c)},15e3)}1==+spbcSettings.admin_bar__admins_online_counter&&e(null,{action:"spbc_get_authorized_admins"},{callback:e}),jQuery("body").on("click",".spbct-notice-dismiss-link",function(e){jQuery(e.target).siblings(".notice-dismiss").click()}),jQuery("body").on("click",".spbc-notice .notice-dismiss",function(e){var t,c=jQuery(e.target).parent(".notice").attr("id");c&&(t='

'+spbcSettings.spbctNoticeDismissSuccess+"

",spbcSendAJAXRequest({action:"spbc_dismiss_banner",banner_id:c},{}),jQuery(e.target).parent(".notice").after(t),setTimeout(function(){jQuery("#spbct-notice-dismiss-success").fadeOut()},2e3))}),1==+spbcSettings.needToWhitelist&&spbcSendAJAXRequest({action:"spbc_private_list_add"},{callback:null})}); //# sourceMappingURL=spbc-admin.min.js.map diff --git a/js/spbc-admin.min.js.map b/js/spbc-admin.min.js.map index 10ff22fbb..81876b071 100644 --- a/js/spbc-admin.min.js.map +++ b/js/spbc-admin.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-admin.min.js","sources":["spbc-admin.js"],"sourcesContent":["/**\n * Get Google Qr Code\n *\n * @return {object}\n */\nfunction spbcGetGoogleQrCode() {\n let data = {};\n let res = {};\n data.security = spbcSettings.ajax_nonce;\n data.action = 'spbc_get_google_qr_code';\n\n jQuery.ajax({\n type: 'POST',\n async: false,\n url: spbcSettings.ajaxurl,\n data: data,\n success: function(result) {\n res = result;\n },\n });\n return res;\n}\n\n/**\n * Check Google Code\n */\nfunction spbcCheckGoogleCode() {\n let data = {};\n data.security = spbcSettings.ajax_nonce;\n data.action = 'spbc_check_google_code';\n data.code = jQuery('#spbct-google-qr-code input').val();\n\n jQuery.ajax({\n type: 'POST',\n async: false,\n url: spbcSettings.ajaxurl,\n data: data,\n success: function(result) {\n if (result.success) {\n jQuery('#spbct-google-qr-code').dialog( 'close' );\n document.location.reload();\n } else {\n alert(result.data);\n }\n },\n });\n}\n\n/**\n * Disable Google 2fa\n *\n * @param {string} element\n */\nfunction spbcDisableG2fa( element ) {\n let data = {};\n data.security = spbcSettings.ajax_nonce;\n data.action = 'spbc_disable_google_2fa';\n data.user_id = jQuery(element).data('user-id');\n\n jQuery.ajax({\n type: 'POST',\n async: false,\n url: spbcSettings.ajaxurl,\n data: data,\n success: function(result) {\n if (result.success) {\n document.location.reload();\n } else {\n alert(result.data);\n }\n },\n });\n}\n\n/**\n * Check Vulnerability\n *\n * @param {array} list\n * @param {string} type\n */\nfunction spbcCheckVulnerability(list, type = 'install') {\n let data = {};\n data.security = spbcSettings.ajax_nonce;\n data.action = type === 'install' ? 'spbc_check_vulnerability_install' : 'spbc_check_vulnerability_list';\n data.list = list;\n\n jQuery.ajax({\n type: 'POST',\n async: false,\n url: spbcSettings.ajaxurl,\n data: data,\n success: function(result) {\n if (result.success) {\n if (type === 'install') {\n spbcCheckVulnerabilityInstallRender(result.list, result.msg);\n }\n if (type === 'list') {\n spbcCheckVulnerabilityListRender(result.list, result.msg);\n }\n } else {\n console.log(result);\n }\n },\n });\n}\n\n/**\n * Check Vulnerability List Render\n *\n * @param {object} list\n * @param {string} msg\n */\nfunction spbcCheckVulnerabilityListRender(list, msg) {\n let card;\n let badge;\n\n list.forEach((el) => {\n badge = document.createElement('div');\n badge.classList.add('notice', 'notice-error', 'error-message');\n badge.innerHTML = '

' + msg + '

';\n card = document.querySelector('.themes .theme[data-slug=' + el + ']');\n if (card) {\n card.appendChild(badge);\n }\n });\n}\n\n/**\n * Check Vulnerability Install Render\n *\n * @param {object} list\n * @param {string} msg\n */\nfunction spbcCheckVulnerabilityInstallRender(list, msg) {\n let card;\n\n let badge = document.createElement('div');\n badge.classList.add('notice');\n badge.innerHTML = '

' + msg + '

';\n\n list.forEach((el) => {\n card = document.querySelector('.theme-id-container .theme-actions a[data-slug=' + el + ']');\n if (card) {\n card.parentNode.parentNode.parentNode.appendChild(badge);\n }\n });\n}\n\njQuery(document).ready(function() {\n if (window.location.href.indexOf('themes.php') > -1 && spbcSettings.vulnerabilityShowList) {\n let slugsState = [];\n let slugs = [];\n let slugsNodes;\n let version;\n\n setInterval(function() {\n slugsNodes = document.querySelectorAll('.themes .theme[data-slug]');\n\n if (slugsNodes.length > 0) {\n slugs = [];\n slugsNodes.forEach(function(el) {\n version = el.querySelector('img').src ?\n el.querySelector('img').src.match(/ver=([\\d\\.]+)/)[1] :\n null;\n slugs.push(el.dataset.slug, version);\n });\n }\n\n if (JSON.stringify(slugs) != JSON.stringify(slugsState)) {\n slugsState = slugs;\n spbcCheckVulnerability(slugs, 'list');\n }\n }, 500);\n }\n\n if (window.location.href.indexOf('theme-install.php') > -1 && spbcSettings.vulnerabilityShowInstall) {\n let slugsState = [];\n let slugs = [];\n let slugsNodes;\n\n setInterval(function() {\n slugsNodes = document.querySelectorAll('.theme-id-container .theme-actions a[data-slug]');\n\n if (slugsNodes.length > 0) {\n slugs = [];\n slugsNodes.forEach(function(el) {\n slugs.push(el.dataset.slug);\n });\n }\n\n if (JSON.stringify(slugs) != JSON.stringify(slugsState)) {\n slugsState = slugs;\n spbcCheckVulnerability(slugs);\n }\n }, 500);\n }\n\n // Auto update banner close handler\n jQuery('.spbc_update_notice').on('click', 'button', function() {\n spbcSetCookie('spbc_update_banner_closed', 1, 86400 * 30);\n });\n\n // Enable G2FA from user profile page\n jQuery(document).on('click', '#spbc-g2fa-enable', function(e) {\n e.preventDefault();\n let spbcGoogleQrCode = spbcGetGoogleQrCode();\n\n if ( spbcGoogleQrCode.success ) {\n let qrCodeDiv = jQuery('#spbct-google-qr-code-img');\n qrCodeDiv.html(spbcGoogleQrCode.data.img + '

' + spbcGoogleQrCode.data.code + '

');\n jQuery('#spbct-google-qr-code input').val('');\n jQuery('#spbct-google-qr-code').dialog({\n modal: true,\n title: 'Google authenticator activation',\n buttons: {\n Cancel: function() {\n jQuery( this ).dialog( 'close' );\n },\n Ok: function() {\n spbcCheckGoogleCode();\n },\n },\n draggable: false,\n resizable: false,\n });\n } else {\n alert(spbcGetGoogleQrCode.data);\n }\n });\n\n // Disable G2FA from user profile page\n jQuery(document).on('click', '#spbc-g2fa-disable', function(e) {\n e.preventDefault();\n if ( confirm( 'Are you sure?' ) ) {\n spbcDisableG2fa( this );\n }\n });\n\n let refreshUserOnlineCounter = function( result, data, params ) {\n setTimeout(function() {\n if ( result !== null ) {\n jQuery('.spbc-admin_bar--user_counter').html(result.count);\n if ( result.count <= 3 ) {\n jQuery('#wp-admin-bar-spbc_admin_bar__online_admins').show();\n jQuery('.spbc-admin_bar--online_admins').html(result.users.join(', '));\n } else {\n jQuery('#wp-admin-bar-spbc_admin_bar__online_admins').hide();\n }\n }\n spbcSendAJAXRequest( data, params );\n }, 15000 );\n };\n\n if ( +spbcSettings.admin_bar__admins_online_counter === 1 ) {\n refreshUserOnlineCounter(null, {action: 'spbc_get_authorized_admins'}, {callback: refreshUserOnlineCounter});\n }\n\n // Dismiss admin banner\n jQuery('body').on('click', '.spbct-notice-dismiss-link', function(e) {\n jQuery(e.target).siblings('.notice-dismiss').click();\n });\n jQuery('body').on('click', '.spbc-notice .notice-dismiss', function(e) {\n const bannerId = jQuery(e.target).parent('.notice').attr('id');\n if ( bannerId ) {\n let elem = '

'+\n spbcSettings.spbctNoticeDismissSuccess+\n '

';\n spbcSendAJAXRequest({'action': 'spbc_dismiss_banner', 'banner_id': bannerId}, {});\n jQuery(e.target)\n .parent('.notice')\n .after(elem);\n setTimeout(function() {\n jQuery('#spbct-notice-dismiss-success').fadeOut();\n }, 2000);\n }\n });\n\n if (+spbcSettings.needToWhitelist === 1) {\n spbcSendAJAXRequest( {'action': 'spbc_private_list_add'}, {'callback': null} );\n }\n});\n\n/**\n * Summary Show CDN Checker Table\n */\nfunction spbcSummaryShowCDNCheckerTable() {/* eslint-disable-line no-unused-vars */\n event.preventDefault();\n let table = document.getElementById('spbc_stats_cdn_checker_table');\n if (typeof (table) !== 'undefined') {\n if (table.style.display === 'block') {\n table.style.display = 'none';\n } else {\n table.style.display = 'block';\n }\n }\n}\n"],"names":["spbcGetGoogleQrCode","let","data","res","security","spbcSettings","ajax_nonce","action","jQuery","ajax","type","async","url","ajaxurl","success","result","spbcCheckGoogleCode","code","val","dialog","document","location","reload","alert","spbcDisableG2fa","element","user_id","spbcCheckVulnerability","list","spbcCheckVulnerabilityInstallRender","msg","spbcCheckVulnerabilityListRender","console","log","card","badge","forEach","createElement","classList","add","innerHTML","querySelector","el","appendChild","parentNode","spbcSummaryShowCDNCheckerTable","event","preventDefault","table","getElementById","style","display","ready","window","href","indexOf","vulnerabilityShowList","slugsState","slugs","slugsNodes","version","setInterval","querySelectorAll","length","src","match","push","dataset","slug","JSON","stringify","vulnerabilityShowInstall","on","spbcSetCookie","e","spbcGoogleQrCode","html","img","modal","title","buttons","Cancel","this","Ok","draggable","resizable","confirm","refreshUserOnlineCounter","params","setTimeout","count","show","users","join","hide","spbcSendAJAXRequest","admin_bar__admins_online_counter","callback","target","siblings","click","elem","bannerId","parent","attr","spbctNoticeDismissSuccess","banner_id","after","fadeOut","needToWhitelist"],"mappings":"AAKA,SAASA,sBACLC,IAAIC,EAAO,GACXD,IAAIE,EAAM,GAaV,OAZAD,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,0BAEdC,OAAOC,KAAK,CACRC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKP,aAAaQ,QAClBX,KAAMA,EACNY,QAAS,SAASC,GACdZ,EAAMY,CACV,CACJ,CAAC,EACMZ,CACX,CAKA,SAASa,sBACLf,IAAIC,EAAO,GACXA,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,yBACdL,EAAKe,KAAOT,OAAO,6BAA6B,EAAEU,IAAI,EAEtDV,OAAOC,KAAK,CACRC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKP,aAAaQ,QAClBX,KAAMA,EACNY,QAAS,SAASC,GACVA,EAAOD,SACPN,OAAO,uBAAuB,EAAEW,OAAQ,OAAQ,EAChDC,SAASC,SAASC,OAAO,GAEzBC,MAAMR,EAAOb,IAAI,CAEzB,CACJ,CAAC,CACL,CAOA,SAASsB,gBAAiBC,GACtBxB,IAAIC,EAAO,GACXA,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,0BACdL,EAAKwB,QAAUlB,OAAOiB,CAAO,EAAEvB,KAAK,SAAS,EAE7CM,OAAOC,KAAK,CACRC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKP,aAAaQ,QAClBX,KAAMA,EACNY,QAAS,SAASC,GACVA,EAAOD,QACPM,SAASC,SAASC,OAAO,EAEzBC,MAAMR,EAAOb,IAAI,CAEzB,CACJ,CAAC,CACL,CAQA,SAASyB,uBAAuBC,EAAMlB,EAAO,WACzCT,IAAIC,EAAO,GACXA,E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oB,CAACxF,OAAU,sBAAuBmG,UAAaJ,CAAQ,EAAG,EAAE,EAChF9F,OAAOkE,EAAEwB,MAAM,EACVK,OAAO,SAAS,EAChBI,MAAMN,CAAI,EACfZ,WAAW,WACPjF,OAAO,+BAA+B,EAAEoG,QAAQ,CACpD,EAAG,GAAI,EAEf,CAAC,EAEqC,GAAlC,CAACvG,aAAawG,iBACdd,oBAAqB,CAACxF,OAAU,uBAAuB,EAAG,CAAC0F,SAAY,IAAI,CAAE,CAErF,CAAC"} \ No newline at end of file +{"version":3,"file":"spbc-admin.min.js","sources":["spbc-admin.js"],"sourcesContent":["/**\n * Get Google Qr Code\n *\n * @return {object}\n */\nfunction spbcGetGoogleQrCode() {\n let data = {};\n let res = {};\n data.security = spbcSettings.ajax_nonce;\n data.action = 'spbc_get_google_qr_code';\n\n jQuery.ajax({\n type: 'POST',\n async: false,\n url: spbcSettings.ajaxurl,\n data: data,\n success: function(result) {\n res = result;\n },\n });\n return res;\n}\n\n/**\n * Check Google Code\n */\nfunction spbcCheckGoogleCode() {\n let data = {};\n data.security = spbcSettings.ajax_nonce;\n data.action = 'spbc_check_google_code';\n data.code = jQuery('#spbct-google-qr-code input').val();\n\n jQuery.ajax({\n type: 'POST',\n async: false,\n url: spbcSettings.ajaxurl,\n data: data,\n success: function(result) {\n if (result.success) {\n jQuery('#spbct-google-qr-code').dialog( 'close' );\n document.location.reload();\n } else {\n alert(result.data);\n }\n },\n });\n}\n\n/**\n * Disable Google 2fa\n *\n * @param {string} element\n */\nfunction spbcDisableG2fa( element ) {\n let data = {};\n data.security = spbcSettings.ajax_nonce;\n data.action = 'spbc_disable_google_2fa';\n data.user_id = jQuery(element).data('user-id');\n\n jQuery.ajax({\n type: 'POST',\n async: false,\n url: spbcSettings.ajaxurl,\n data: data,\n success: function(result) {\n if (result.success) {\n document.location.reload();\n } else {\n alert(result.data);\n }\n },\n });\n}\n\n/**\n * Check Vulnerability\n *\n * @param {array} list\n * @param {string} type\n */\nfunction spbcCheckVulnerability(list, type = 'install') {\n let data = {};\n data.security = spbcSettings.ajax_nonce;\n data.action = type === 'install' ? 'spbc_check_vulnerability_install' : 'spbc_check_vulnerability_list';\n data.list = list;\n\n jQuery.ajax({\n type: 'POST',\n async: false,\n url: spbcSettings.ajaxurl,\n data: data,\n success: function(result) {\n if (result.success) {\n if (type === 'install') {\n spbcCheckVulnerabilityInstallRender(result.list, result.msg);\n }\n if (type === 'list') {\n spbcCheckVulnerabilityListRender(result.list);\n }\n } else {\n console.log(result);\n }\n },\n });\n}\n\n/**\n * Check Vulnerability List Render\n *\n * @param {object} list\n * @param {string} msg\n */\nfunction spbcCheckVulnerabilityListRender(list) {\n let card;\n let badge;\n\n list.forEach((el) => {\n badge = document.createElement('div');\n badge.classList.add('notice', 'notice-error', 'error-message');\n badge.innerHTML = el.msg;\n card = document.querySelector('.themes .theme[data-slug=' + el.slug + ']');\n if (card) {\n card.appendChild(badge);\n }\n });\n}\n\n/**\n * Check Vulnerability Install Render\n *\n * @param {object} list\n * @param {string} msg\n */\nfunction spbcCheckVulnerabilityInstallRender(list, msg) {\n let card;\n\n let badge = document.createElement('div');\n badge.classList.add('notice');\n badge.innerHTML = '

' + msg + '

';\n\n list.forEach((el) => {\n card = document.querySelector('.theme-id-container .theme-actions a[data-slug=' + el + ']');\n if (card) {\n card.parentNode.parentNode.parentNode.appendChild(badge);\n }\n });\n}\n\njQuery(document).ready(function() {\n if (window.location.href.indexOf('themes.php') > -1 && spbcSettings.vulnerabilityShowList) {\n let slugsState = [];\n let slugs = [];\n let slugsNodes;\n let version;\n\n setInterval(function() {\n slugsNodes = document.querySelectorAll('.themes .theme[data-slug]');\n\n if (slugsNodes.length > 0) {\n slugs = [];\n slugsNodes.forEach(function(el) {\n version = el.querySelector('img').src ?\n el.querySelector('img').src.match(/ver=([\\d\\.]+)/)[1] :\n null;\n slugs.push({'slug': el.dataset.slug, 'version': version});\n });\n }\n\n if (JSON.stringify(slugs) != JSON.stringify(slugsState)) {\n slugsState = slugs;\n spbcCheckVulnerability(slugs, 'list');\n }\n }, 500);\n }\n\n if (window.location.href.indexOf('theme-install.php') > -1 && spbcSettings.vulnerabilityShowInstall) {\n let slugsState = [];\n let slugs = [];\n let slugsNodes;\n\n setInterval(function() {\n slugsNodes = document.querySelectorAll('.theme-id-container .theme-actions a[data-slug]');\n\n if (slugsNodes.length > 0) {\n slugs = [];\n slugsNodes.forEach(function(el) {\n slugs.push(el.dataset.slug);\n });\n }\n\n if (JSON.stringify(slugs) != JSON.stringify(slugsState)) {\n slugsState = slugs;\n spbcCheckVulnerability(slugs);\n }\n }, 500);\n }\n\n // Auto update banner close handler\n jQuery('.spbc_update_notice').on('click', 'button', function() {\n spbcSetCookie('spbc_update_banner_closed', 1, 86400 * 30);\n });\n\n // Enable G2FA from user profile page\n jQuery(document).on('click', '#spbc-g2fa-enable', function(e) {\n e.preventDefault();\n let spbcGoogleQrCode = spbcGetGoogleQrCode();\n\n if ( spbcGoogleQrCode.success ) {\n let qrCodeDiv = jQuery('#spbct-google-qr-code-img');\n qrCodeDiv.html(spbcGoogleQrCode.data.img + '

' + spbcGoogleQrCode.data.code + '

');\n jQuery('#spbct-google-qr-code input').val('');\n jQuery('#spbct-google-qr-code').dialog({\n modal: true,\n title: 'Google authenticator activation',\n buttons: {\n Cancel: function() {\n jQuery( this ).dialog( 'close' );\n },\n Ok: function() {\n spbcCheckGoogleCode();\n },\n },\n draggable: false,\n resizable: false,\n });\n } else {\n alert(spbcGetGoogleQrCode.data);\n }\n });\n\n // Disable G2FA from user profile page\n jQuery(document).on('click', '#spbc-g2fa-disable', function(e) {\n e.preventDefault();\n if ( confirm( 'Are you sure?' ) ) {\n spbcDisableG2fa( this );\n }\n });\n\n let refreshUserOnlineCounter = function( result, data, params ) {\n setTimeout(function() {\n if ( result !== null ) {\n jQuery('.spbc-admin_bar--user_counter').html(result.count);\n if ( result.count <= 3 ) {\n jQuery('#wp-admin-bar-spbc_admin_bar__online_admins').show();\n jQuery('.spbc-admin_bar--online_admins').html(result.users.join(', '));\n } else {\n jQuery('#wp-admin-bar-spbc_admin_bar__online_admins').hide();\n }\n }\n spbcSendAJAXRequest( data, params );\n }, 15000 );\n };\n\n if ( +spbcSettings.admin_bar__admins_online_counter === 1 ) {\n refreshUserOnlineCounter(null, {action: 'spbc_get_authorized_admins'}, {callback: refreshUserOnlineCounter});\n }\n\n // Dismiss admin banner\n jQuery('body').on('click', '.spbct-notice-dismiss-link', function(e) {\n jQuery(e.target).siblings('.notice-dismiss').click();\n });\n jQuery('body').on('click', '.spbc-notice .notice-dismiss', function(e) {\n const bannerId = jQuery(e.target).parent('.notice').attr('id');\n if ( bannerId ) {\n let elem = '

'+\n spbcSettings.spbctNoticeDismissSuccess+\n '

';\n spbcSendAJAXRequest({'action': 'spbc_dismiss_banner', 'banner_id': bannerId}, {});\n jQuery(e.target)\n .parent('.notice')\n .after(elem);\n setTimeout(function() {\n jQuery('#spbct-notice-dismiss-success').fadeOut();\n }, 2000);\n }\n });\n\n if (+spbcSettings.needToWhitelist === 1) {\n spbcSendAJAXRequest( {'action': 'spbc_private_list_add'}, {'callback': null} );\n }\n});\n\n/**\n * Summary Show CDN Checker Table\n */\nfunction spbcSummaryShowCDNCheckerTable() {/* eslint-disable-line no-unused-vars */\n event.preventDefault();\n let table = document.getElementById('spbc_stats_cdn_checker_table');\n if (typeof (table) !== 'undefined') {\n if (table.style.display === 'block') {\n table.style.display = 'none';\n } else {\n table.style.display = 'block';\n }\n }\n}\n"],"names":["spbcGetGoogleQrCode","let","data","res","security","spbcSettings","ajax_nonce","action","jQuery","ajax","type","async","url","ajaxurl","success","result","spbcCheckGoogleCode","code","val","dialog","document","location","reload","alert","spbcDisableG2fa","element","user_id","spbcCheckVulnerability","list","spbcCheckVulnerabilityInstallRender","msg","spbcCheckVulnerabilityListRender","console","log","card","badge","forEach","createElement","classList","add","innerHTML","el","querySelector","slug","appendChild","parentNode","spbcSummaryShowCDNCheckerTable","event","preventDefault","table","getElementById","style","display","ready","window","href","indexOf","vulnerabilityShowList","slugsState","slugs","slugsNodes","version","setInterval","querySelectorAll","length","src","match","push","dataset","JSON","stringify","vulnerabilityShowInstall","on","spbcSetCookie","e","spbcGoogleQrCode","html","img","modal","title","buttons","Cancel","this","Ok","draggable","resizable","confirm","refreshUserOnlineCounter","params","setTimeout","count","show","users","join","hide","spbcSendAJAXRequest","admin_bar__admins_online_counter","callback","target","siblings","click","elem","bannerId","parent","attr","spbctNoticeDismissSuccess","banner_id","after","fadeOut","needToWhitelist"],"mappings":"AAKA,SAASA,sBACLC,IAAIC,EAAO,GACXD,IAAIE,EAAM,GAaV,OAZAD,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,0BAEdC,OAAOC,KAAK,CACRC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKP,aAAaQ,QAClBX,KAAMA,EACNY,QAAS,SAASC,GACdZ,EAAMY,CACV,CACJ,CAAC,EACMZ,CACX,CAKA,SAASa,sBACLf,IAAIC,EAAO,GACXA,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,yBACdL,EAAKe,KAAOT,OAAO,6BAA6B,EAAEU,IAAI,EAEtDV,OAAOC,KAAK,CACRC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKP,aAAaQ,QAClBX,KAAMA,EACNY,QAAS,SAASC,GACVA,EAAOD,SACPN,OAAO,uBAAuB,EAAEW,OAAQ,OAAQ,EAChDC,SAASC,SAASC,OAAO,GAEzBC,MAAMR,EAAOb,IAAI,CAEzB,CACJ,CAAC,CACL,CAOA,SAASsB,gBAAiBC,GACtBxB,IAAIC,EAAO,GACXA,EAAKE,SAAWC,aAAaC,WAC7BJ,EAAKK,OAAS,0BACdL,EAAKwB,QAAUlB,OAAOiB,CAAO,EAAEvB,KAAK,SAAS,EAE7CM,OAAOC,KAAK,CACRC,KAAM,OACNC,MAAO,CAAA,EACPC,IAAKP,aAAaQ,QAClBX,KAAMA,EACNY,QAAS,SAASC,GACVA,EAAOD,QACP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C,SAASE,GAChE,IAEQ2B,EAFFC,EAAW9F,OAAOkE,EAAEwB,MAAM,EAAEK,OAAO,SAAS,EAAEC,KAAK,IAAI,EACxDF,IACGD,EAAO,0FACPhG,aAAaoG,0BACb,aACJV,oBAAoB,CAACxF,OAAU,sBAAuBmG,UAAaJ,CAAQ,EAAG,EAAE,EAChF9F,OAAOkE,EAAEwB,MAAM,EACVK,OAAO,SAAS,EAChBI,MAAMN,CAAI,EACfZ,WAAW,WACPjF,OAAO,+BAA+B,EAAEoG,QAAQ,CACpD,EAAG,GAAI,EAEf,CAAC,EAEqC,GAAlC,CAACvG,aAAawG,iBACdd,oBAAqB,CAACxF,OAAU,uBAAuB,EAAG,CAAC0F,SAAY,IAAI,CAAE,CAErF,CAAC"} \ No newline at end of file diff --git a/js/spbc-table.min.js b/js/spbc-table.min.js index c1b967bfc..b5c245027 100644 --- a/js/spbc-table.min.js +++ b/js/spbc-table.min.js @@ -1,2 +1,2 @@ -let spbcBulkAction=null;function spbcReloadAccordion(){spbcSendAJAXRequest({action:"spbc_scanner_tab__reload_accordion"},{notJson:!0,callback:function(e,t,n,a){jQuery(a).accordion("destroy"),jQuery(a).html(e),jQuery(a).accordion({header:"h3",heightStyle:"content",collapsible:!0,active:!1}),spbcTblBulkActionsListen(),spbcTblRowActionsListen(),spbcTblPaginationListen(),spbcTblSortListen(),spbcStartShowHide()}},jQuery("#spbc_scan_accordion"))}function spbcTblBulkActionsListen(){jQuery(".tbl-bulk_actions-all--apply").off("click").on("click",function(){if(spbcScanner.active)alert(spbcTableLocalize.scannerIsActive);else{var e=jQuery(this);let n=e.siblings("select").children()[e.siblings("select").first()[0].selectedIndex].value;if(-1!==["approve","disapprove","send","check_analysis_status","approve_page","disapprove_page","cure","delete_from_analysis_log"].indexOf(n)){if(confirm(spbcTable.warning_bulk)){var t={action:"spbc_tbl-action--bulk",add_action:n,status:e.parents(".tbl-root").attr("type")};if("cure"===n){var a=e.closest("#spbc_tbl__scanner_cure_log").find(".cb-select");let n=[];a.each(function(e,t){t=jQuery(t).val();n.push(t)}),t.selectedIds=n}if("delete_from_analysis_log"===n){a=e.closest("#spbc_tbl__scanner_analysis_log").find(".cb-select");let n=[];a.each(function(e,t){t=jQuery(t).val();n.push(t)}),t.file_ids=n}a={button:this,spinner:e.children(".tbl-preloader--small"),callback:function(e){var t;spbcReloadAccordion(),"check_analysis_status"===n&&void 0!==e&&(t="

Analysis status updated. Total: "+e.counters.total+", updated: "+e.counters.updated+", skipped: "+e.counters.skipped+", failed: "+e.counters.failed+", queued: "+e.counters.queued+"

",spbcModal.open().put(t)),"send"===n&&void 0!==e&&(t="

Files have been sent: "+e.files_sent_counter+"

",spbcModal.open().put(t))},errorOutput:function(e,t){t&&(e=e+"
Additional information:
"+t),spbcModal.open().putError(e)},timeout:6e4};spbcSendAJAXRequest(t,a)}}else alert("This action is not supported for all files yet =(")}}),jQuery(".tbl-bulk_actions--apply").off("click").on("click",function(e){if(spbcBulkAction||confirm(spbcTable.warning_bulk)){var a=spbcBulkAction||jQuery(this);let n=(spbcBulkAction=a).siblings("select").children()[a.siblings("select").first()[0].selectedIndex].value;if("cure"===n)spbcScannerCureSelected(jQuery(this));else if("delete_from_analysis_log"===n)spbcScannerAnalysisLogDeleteFromLog(jQuery(this));else if("allow"===n||"ban"===n){let t="ban"===n?"deny":n;var s=a.parents(".tbl-root").find(".cb-select:checked"),s=(s&&(a.children(".tbl-preloader--small").show(),s.each(function(){var e=jQuery(this).parents("tr").find(".tbl-row_action--"+n).data("ip");spbcSecLogsFilterIp(e,t,!0),jQuery(this).prop("checked",!1)})),a.children(".tbl-preloader--small").hide(),"allow"===n?"Allowed":"Banned"),s="

Success. Selected IPs have been "+s+". Changes will be applied within 10 minutes.

";spbcModal.open().put(s),void setTimeout(spbcReloadAccordion,1900)}else"-1"!==n&&a.parents(".tbl-root").find(".cb-select").is(":checked")?(a.children(".tbl-preloader--small").show(),a.parents(".tbl-root").find(".cb-select:checked").first().parents("tr").find(".tbl-row_action--"+n)[0]?(a.parents(".tbl-root").find(".cb-select:checked").first().parents("tr").find(".tbl-row_action--"+n).click(),a.parents(".tbl-root").find(".cb-select:checked").first().prop("checked",!1)):(a.parents(".tbl-root").find(".cb-select:checked").first().prop("checked",!1),a.click())):(a.children(".tbl-preloader--small").hide(),spbcBulkAction=null,"check_analysis_status"!==n&&"disapprove"!==n||spbcModal.open().put("

All available files are updated.

"),"send"===n&&spbcModal.open().put("

All available files are sent.

"),setTimeout(spbcReloadAccordion,1900))}})}function spbcScannerCureSelected(t){var e=t.closest("#spbc_tbl__scanner_cure_log").find(".cb-select:checked");let n=[];0===e.length&&alert("Please, select elements."),e.each(function(e,t){t=jQuery(t).val();n.push(t)});e={action:"spbc_cure_selected",security:spbcSettings.ajax_nonce,selectedIds:n};jQuery.ajax({type:"POST",url:spbcSettings.ajaxurl,data:e,beforeSend:function(){t.closest("#spbc_tbl__scanner_cure_log").find(".tbl-button---white_blue .tbl-preloader--in_button").show()},success:function(e){t.closest("#spbc_tbl__scanner_cure_log").find(".tbl-button---white_blue .tbl-preloader--in_button").hide(),e.success?(spbcModal.open().put(e.data),document.addEventListener("spbcModalClosed",function(e){document.location.reload()})):spbcModal.open().putError(e.data)}})}function spbcTblRowActionsListen(){jQuery(".tbl-row_action--ajax").off("click").on("click",function(){if(console.log("spbcTblRowActionsListen click"),spbcScanner.active)alert(spbcTableLocalize.scannerIsActive);else{let t=jQuery(this),n={action:"spbc_tbl-action--row",add_action:t.attr("row-action"),id:t.parents(".row-actions").attr("uid"),cols:t.parents(".row-actions").attr("cols_amount"),page_url:t.parent().attr("uid"),page_id:t.parent().attr("page_id")},a={callback:spbcTblRowActionsCallback,errorOutput:function(e){spbcModal.open().putError(e)},spinner:t.parent().siblings(".tbl-preloader--tiny")};var e,s;spbcBulkAction||(e=t.parent().parent()[0].firstChild.innerHTML,s=spbcTable["warning_"+t.attr("row-action")]||spbcTable.warning_default,"copy_file_info"===n.add_action||"check_analysis_status"===n.add_action?spbcSendAJAXRequest(n,a,t.parents("tr")):spbcModal.open().confirm(s,e,e=>{e&&spbcSendAJAXRequest(n,a,t.parents("tr"))})),spbcBulkAction&&spbcSendAJAXRequest(n,a,t.parents("tr"))}})}function spbcTblRowActionsCallback(t,n,e,a){if(t.color&&a.css({background:t.background,color:t.color}),t.html&&(a.parent().parent().parent().prepend(t.html),setTimeout(function(){a.fadeOut(300)},1500),spbcBulkAction||setTimeout(spbcReloadAccordion,1900)),"copy_file_info"===n.add_action&&(!0===t.success&&t.data.file_info?window.prompt("Copy the file info below and send it to support@cleantalk.org: ",t.data.file_info):(s=void 0!==t.data.error?t.data.error:"Unknown copy_file_info error",spbcModal.open().putError(s))),t.temp_html){let e=a.html();if(a.html(t.temp_html),void 0!==t.updated_template){var s=t.updated_template_type,t=t.updated_template,c=jQuery(t).find(".wp-list-table tbody tr").length,i=jQuery('[aria-controls="spbc_scan_accordion_tab_'+s+'"]');if(0n&&jQuery(t).css("outline","1px solid green")}),i.click()}else"analysis_log"===s&&(l='",s='