(function($) { if (!window['wordfenceAdmin']) { //To compile for checking: java -jar /usr/local/bin/closure.jar --js=admin.js --js_output_file=test.js window['wordfenceAdmin'] = { isSmallScreen: false, loading16: '
', loadingCount: 0, dbCheckTables: [], dbCheckCount_ok: 0, dbCheckCount_skipped: 0, dbCheckCount_errors: 0, issues: [], ignoreData: false, iconErrorMsgs: [], scanIDLoaded: 0, colorboxQueue: [], mode: '', visibleIssuesPanel: 'new', preFirstScanMsgsLoaded: false, newestActivityTime: 0, //must be 0 to force loading of all initially elementGeneratorIter: 1, reloadConfigPage: false, nonce: false, tickerUpdatePending: false, activityLogUpdatePending: false, lastALogCtime: 0, lastIssueUpdateTime: 0, activityQueue: [], totalActAdded: 0, maxActivityLogItems: 1000, scanReqAnimation: false, debugOn: false, blockedCountriesPending: [], ownCountry: "", schedStartHour: false, currentPointer: false, countryMap: false, countryCodesToSave: "", performanceScale: 3, performanceMinWidth: 20, _windowHasFocus: true, serverTimestampOffset: 0, serverMicrotime: 0, wfLiveTraffic: null, loadingBlockedIPs: false, scanRunning: false, basePageName: '', pendingChanges: {}, scanStalled: false, siteCleaningIssueTypes: ['file', 'checkGSB', 'checkSpamIP', 'commentBadURL', 'knownfile', 'optionBadURL', 'postBadTitle', 'postBadURL', 'spamvertizeCheck', 'suspiciousAdminUsers'], //Screen sizes SCREEN_XS: 'xs', SCREEN_SM: 'sm', SCREEN_MD: 'md', SCREEN_LG: 'lg', init: function() { this.isSmallScreen = window.matchMedia("only screen and (max-width: 500px)").matches; this.nonce = WordfenceAdminVars.firstNonce; this.debugOn = WordfenceAdminVars.debugOn == '1' ? true : false; this.scanRunning = WordfenceAdminVars.scanRunning == '1' ? true : false; this.basePageName = document.title; var startTicker = false; var self = this; $(window).on('blur', function() { self._windowHasFocus = false; }).on('focus', function() { self._windowHasFocus = true; }).focus(); $('.do-show').click(function() { var $this = $(this); $this.hide(); $($this.data('selector')).show(); return false; }); $('.downloadLogFile').each(function() { $(this).attr('href', WordfenceAdminVars.ajaxURL + '?action=wordfence_downloadLogFile&nonce=' + WFAD.nonce + '&logfile=' + encodeURIComponent($(this).data('logfile'))); }); $('#doSendEmail').click(function() { var ticket = $('#_ticketnumber').val(); if (ticket === null || typeof ticket === "undefined" || ticket.length == 0) { self.colorboxModal((self.isSmallScreen ? '300px' : '400px'), "Error", "Please include your support ticket number or forum username."); return; } WFAD.ajax('wordfence_sendDiagnostic', {email: $('#_email').val(), ticket: ticket}, function(res) { if (res.result) { self.colorboxModal((self.isSmallScreen ? '300px' : '400px'), "Email Diagnostic Report", "Diagnostic report has been sent successfully."); } else { self.colorboxModal((self.isSmallScreen ? '300px' : '400px'), "Error", "There was an error while sending the email."); } }); }); $('#sendByEmail').click(function() { $('#sendByEmailForm').removeClass('hidden'); $(this).hide(); }); $('#expandAllDiagnostics').click(function() { $('#wf-diagnostics').find('.wf-block').each(function() { var el = $(this); if (!el.hasClass('wf-active')) { el.find('.wf-block-header').trigger('click'); } }) }); $(window).bind("scroll", function() { $(this).scrollTop() > 200 ? $(".wf-scrollTop").fadeIn() : $(".wf-scrollTop").fadeOut() }); $(".wf-scrollTop").click(function(e) { return e.stopPropagation(), $("body,html").animate({ scrollTop: 0 }, 800), !1; }); var tabs = jQuery('.wf-page-tabs').find('.wf-tab a'); if (tabs.length > 0) { tabs.click(function() { jQuery('.wf-page-tabs').find('.wf-tab').removeClass('wf-active'); jQuery('.wf-tab-content').removeClass('wf-active'); var tab = jQuery(this).closest('.wf-tab'); tab.addClass('wf-active'); var content = jQuery('#' + tab.data('target')); content.addClass('wf-active'); document.title = tab.data('pageTitle') + " \u2039 " + self.basePageName; self.sectionInit(); $(window).trigger('wfTabChange', [tab.data('target')]); }); if (window.location.hash) { var hashes = WFAD.parseHashes(); var hash = hashes[hashes.length - 1]; for (var i = 0; i < tabs.length; i++) { if (hash == jQuery(tabs[i]).closest('.wf-tab').data('target')) { jQuery(tabs[i]).trigger('click'); } } } else { jQuery(tabs[0]).trigger('click'); } jQuery(window).on('hashchange', function () { var hashes = WFAD.parseHashes(); var hash = hashes[hashes.length - 1]; for (var i = 0; i < tabs.length; i++) { if (hash == jQuery(tabs[i]).closest('.wf-tab').data('target')) { jQuery(tabs[i]).trigger('click'); } } }); } else { this.sectionInit(); } if (this.mode) { jQuery(document).bind('cbox_closed', function() { self.colorboxIsOpen = false; self.colorboxServiceQueue(); }); } if ($('.wf-options-controls-spacer').length) { //The WP code doesn't move update nags and we need to $('.update-nag, #update-nag').insertAfter($('.wf-options-controls-spacer')); } $('.wf-block-header-action-disclosure').each(function() { $(this).on('keydown', function(e) { if (e.keyCode == 32) { e.preventDefault(); e.stopPropagation(); $(this).closest('.wf-block-header').trigger('click'); } }); $(this).closest('.wf-block-header').css('cursor', 'pointer'); $(this).closest('.wf-block-header').on('click', function(e) { // Let links in the header work. if (e.target && e.target.nodeName === 'A' && e.target.href) { return; } e.preventDefault(); e.stopPropagation(); if ($(this).closest('.wf-block').hasClass('wf-disabled')) { return; } var isActive = $(this).closest('.wf-block').hasClass('wf-active'); if (isActive) { //$(this).closest('.wf-block').removeClass('wf-active'); $(this).closest('.wf-block').find('.wf-block-content').slideUp({ always: function() { $(this).closest('.wf-block').removeClass('wf-active'); $(this).attr('aria-checked', 'false'); } }); } else { //$(this).closest('.wf-block').addClass('wf-active'); $(this).closest('.wf-block').find('.wf-block-content').slideDown({ always: function() { $(this).closest('.wf-block').addClass('wf-active'); $(this).attr('aria-checked', 'true'); } }); } WFAD.ajax('wordfence_saveDisclosureState', {name: $(this).closest('.wf-block').data('persistenceKey'), state: !isActive}, function() {}, function() {}, true); }); }); //On/Off Option $('.wf-option.wf-option-toggled .wf-option-checkbox').each(function() { $(this).on('keydown', function(e) { if (e.keyCode == 32) { e.preventDefault(); e.stopPropagation(); $(this).trigger('click'); } }); $(this).on('click', function(e) { e.preventDefault(); e.stopPropagation(); var optionElement = $(this).closest('.wf-option'); if (optionElement.hasClass('wf-option-premium') || optionElement.hasClass('wf-disabled')) { return; } var option = optionElement.data('option'); var value = false; var isActive = $(this).hasClass('wf-checked'); if (isActive) { $(this).removeClass('wf-checked').attr('aria-checked', 'false'); value = optionElement.data('disabledValue'); } else { $(this).addClass('wf-checked').attr('aria-checked', 'true'); value = optionElement.data('enabledValue'); } var originalValue = optionElement.data('originalValue'); if (originalValue == value) { delete WFAD.pendingChanges[option]; } else { WFAD.pendingChanges[option] = value; } $(optionElement).trigger('change', [false]); WFAD.updatePendingChanges(); }); $(this).parent().find('.wf-option-title').on('click', function(e) { var links = $(this).find('a'); var buffer = 10; for (var i = 0; i < links.length; i++) { var t = $(links[i]).offset().top; var l = $(links[i]).offset().left; var b = t + $(links[i]).height(); var r = l + $(links[i]).width(); if (e.pageX > l - buffer && e.pageX < r + buffer && e.pageY > t - buffer && e.pageY < b + buffer) { return; } } $(this).parent().find('.wf-option-checkbox').trigger('click'); }).css('cursor', 'pointer'); }); //On/Off Boolean Switch Option $('.wf-option.wf-option-toggled-boolean-switch .wf-boolean-switch').each(function() { $(this).on('keydown', function(e) { if (e.keyCode == 32) { e.preventDefault(); e.stopPropagation(); $(this).trigger('click'); } }); $(this).on('click', function(e) { e.preventDefault(); e.stopPropagation(); $(this).find('.wf-boolean-switch-handle').trigger('click'); }); $(this).find('.wf-boolean-switch-handle').on('click', function(e) { e.preventDefault(); e.stopPropagation(); var optionElement = $(this).closest('.wf-option'); if (optionElement.hasClass('wf-option-premium') || optionElement.hasClass('wf-disabled')) { return; } var switchElement = $(this).closest('.wf-boolean-switch'); var option = optionElement.data('option'); var value = false; var isActive = switchElement.hasClass('wf-active'); if (isActive) { switchElement.removeClass('wf-active').attr('aria-checked', 'false'); value = optionElement.data('disabledValue'); } else { switchElement.addClass('wf-active').attr('aria-checked', 'true'); value = optionElement.data('enabledValue'); } var originalValue = optionElement.data('originalValue'); if (originalValue == value) { delete WFAD.pendingChanges[option]; } else { WFAD.pendingChanges[option] = value; } $(optionElement).trigger('change', [false]); WFAD.updatePendingChanges(); }); $(this).parent().find('.wf-option-title').on('click', function(e) { var links = $(this).find('a'); var buffer = 10; for (var i = 0; i < links.length; i++) { var t = $(links[i]).offset().top; var l = $(links[i]).offset().left; var b = t + $(links[i]).height(); var r = l + $(links[i]).width(); if (e.pageX > l - buffer && e.pageX < r + buffer && e.pageY > t - buffer && e.pageY < b + buffer) { return; } } $(this).parent().find('.wf-boolean-switch-handle').trigger('click'); }).css('cursor', 'pointer'); }); //On/Off Segmented Option $('.wf-option.wf-option-toggled-segmented [type=radio]').each(function() { $(this).on('click', function(e) { var optionElement = $(this).closest('.wf-option'); if (optionElement.hasClass('wf-option-premium') || optionElement.hasClass('wf-disabled')) { return; } var option = optionElement.data('option'); var value = this.value; var originalValue = optionElement.data('originalValue'); if (originalValue == value) { delete WFAD.pendingChanges[option]; } else { WFAD.pendingChanges[option] = value; } $(optionElement).trigger('change', [false]); WFAD.updatePendingChanges(); }); }); //On/Off Multiple Option $('.wf-option.wf-option-toggled-multiple .wf-option-checkbox').each(function() { $(this).on('keydown', function(e) { if (e.keyCode == 32) { e.preventDefault(); e.stopPropagation(); $(this).trigger('click'); } }); $(this).on('click', function(e) { e.preventDefault(); e.stopPropagation(); var optionElement = $(this).closest('.wf-option'); if (optionElement.hasClass('wf-option-premium') || optionElement.hasClass('wf-disabled')) { return; } var checkboxElement = $(this).closest('ul'); var option = checkboxElement.data('option'); var value = false; var isActive = $(this).hasClass('wf-checked'); if (isActive) { $(this).removeClass('wf-checked').attr('aria-checked', 'false'); value = checkboxElement.data('disabledValue'); } else { $(this).addClass('wf-checked').attr('aria-checked', 'true'); value = checkboxElement.data('enabledValue'); } var originalValue = checkboxElement.data('originalValue'); if (originalValue == value) { delete WFAD.pendingChanges[option]; } else { WFAD.pendingChanges[option] = value; } $(optionElement).trigger('change', [false]); WFAD.updatePendingChanges(); }); }); //On/Off Option with menu and Option with menu $('.wf-option.wf-option-toggled-select .wf-option-checkbox').each(function() { $(this).on('keydown', function(e) { if (e.keyCode == 32) { e.preventDefault(); e.stopPropagation(); $(this).trigger('click'); } }); $(this).on('click', function(e) { e.preventDefault(); e.stopPropagation(); var optionElement = $(this).closest('.wf-option'); if (optionElement.hasClass('wf-option-premium') || optionElement.hasClass('wf-disabled')) { return; } var selectElement = optionElement.find('.wf-option-select select'); var option = optionElement.data('toggleOption'); var value = false; var isActive = $(this).hasClass('wf-checked'); if (isActive) { $(this).removeClass('wf-checked').attr('aria-checked', 'false'); selectElement.attr('disabled', true); value = optionElement.data('disabledToggleValue'); } else { $(this).addClass('wf-checked').attr('aria-checked', 'true'); selectElement.attr('disabled', false); value = optionElement.data('enabledToggleValue'); } var originalValue = optionElement.data('originalToggleValue'); if (originalValue == value) { delete WFAD.pendingChanges[option]; } else { WFAD.pendingChanges[option] = value; } $(optionElement).trigger('change', [false]); WFAD.updatePendingChanges(); }); $(this).parent().find('.wf-option-title').on('click', function(e) { var links = $(this).find('a'); var buffer = 10; for (var i = 0; i < links.length; i++) { var t = $(links[i]).offset().top; var l = $(links[i]).offset().left; var b = t + $(links[i]).height(); var r = l + $(links[i]).width(); if (e.pageX > l - buffer && e.pageX < r + buffer && e.pageY > t - buffer && e.pageY < b + buffer) { return; } } $(this).closest('.wf-option').find('.wf-option-checkbox').trigger('click'); }).css('cursor', 'pointer'); }); $('.wf-option.wf-option-toggled-select > .wf-option-content > ul > li.wf-option-select select, .wf-option.wf-option-select > .wf-option-content > ul > li.wf-option-select select, .wf-option.wf-option-select > li.wf-option-select select').each(function() { if (!$.fn.wfselect2) { return; } var width = WFAD.isSmallScreen ? '200px' : 'resolve'; if ($(this).data('preferredWidth')) { width = $(this).data('preferredWidth'); } $(this).wfselect2({ minimumResultsForSearch: -1, width: width }).on('change', function () { var optionElement = $(this).closest('.wf-option'); var option = optionElement.data('selectOption'); var value = $(this).val(); var originalValue = optionElement.data('originalSelectValue'); if (originalValue == value) { delete WFAD.pendingChanges[option]; } else { WFAD.pendingChanges[option] = value; } $(optionElement).trigger('change', [false]); WFAD.updatePendingChanges(); }); }).triggerHandler('change'); //Text field option $('.wf-option.wf-option-text > .wf-option-content > ul > li.wf-option-text input').on('change paste keyup', function() { var e = this; setTimeout(function() { var optionElement = $(e).closest('.wf-option'); var option = optionElement.data('textOption'); if (typeof option !== 'undefined') { var value = $(e).val(); var originalValue = optionElement.data('originalTextValue'); if (originalValue == value) { delete WFAD.pendingChanges[option]; } else { WFAD.pendingChanges[option] = value; } $(optionElement).trigger('change', [false]); WFAD.updatePendingChanges(); } }, 4); }); //Text area option $('.wf-option.wf-option-textarea > .wf-option-content > ul > li.wf-option-textarea textarea').on('change paste keyup', function() { var e = this; setTimeout(function() { var optionElement = $(e).closest('.wf-option'); var option = optionElement.data('textOption'); var value = $(e).val(); var originalValue = optionElement.data('originalTextValue'); if (originalValue == value) { delete WFAD.pendingChanges[option]; } else { WFAD.pendingChanges[option] = value; } $(optionElement).trigger('change', [false]); WFAD.updatePendingChanges(); }, 4); }); //Value entry token option if ($.fn.wfselect2) { $('.wf-option.wf-option-token select').wfselect2({ tags: true, tokenSeparators: [','], width: 'element', minimumResultsForSearch: -1, selectOnClose: true, matcher: function(params, data) { return null; } }).on('wfselect2:unselect', function(e){ jQuery(e.params.data.element).remove(); }).on('wfselect2:opening wfselect2:close', function(e){ $('body').toggleClass('wf-select2-suppress-dropdown', e.type == 'wfselect2:opening'); }).on('change', function () { var optionElement = $(this).closest('.wf-option'); var option = optionElement.data('tokenOption'); var value = $(this).val(); if (!(value instanceof Array)) { value = []; } var selected = $(this).find('option:selected'); var tagsElement = optionElement.find('.wf-option-token-tags'); var list = $('