Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordfenc.../views/waf
File: options-group-basic-firewall.php
<?php
[0] Fix | Delete
if (!defined('WORDFENCE_VERSION')) { exit; }
[1] Fix | Delete
/**
[2] Fix | Delete
* Presents the Basic Firewall Options group.
[3] Fix | Delete
*
[4] Fix | Delete
* Expects $firewall, $waf, and $stateKey.
[5] Fix | Delete
*
[6] Fix | Delete
* @var wfFirewall $firewall
[7] Fix | Delete
* @var wfWAF $waf
[8] Fix | Delete
* @var string $stateKey The key under which the collapse state is stored.
[9] Fix | Delete
* @var bool $collapseable If defined, specifies whether or not this grouping can be collapsed. Defaults to true.
[10] Fix | Delete
*/
[11] Fix | Delete
[12] Fix | Delete
$config = $waf->getStorageEngine();
[13] Fix | Delete
[14] Fix | Delete
if (!isset($collapseable)) {
[15] Fix | Delete
$collapseable = true;
[16] Fix | Delete
}
[17] Fix | Delete
?>
[18] Fix | Delete
<div class="wf-row">
[19] Fix | Delete
<div class="wf-col-xs-12">
[20] Fix | Delete
<div class="wf-block<?php if (!$collapseable) { echo ' wf-always-active'; } else { echo (wfPersistenceController::shared()->isActive($stateKey) ? ' wf-active' : ''); } ?>" data-persistence-key="<?php echo esc_attr($stateKey); ?>">
[21] Fix | Delete
<div class="wf-block-header">
[22] Fix | Delete
<div class="wf-block-header-content">
[23] Fix | Delete
<div class="wf-block-title">
[24] Fix | Delete
<strong><?php esc_html_e('Basic Firewall Options', 'wordfence'); ?></strong>
[25] Fix | Delete
</div>
[26] Fix | Delete
<?php if ($collapseable): ?><div class="wf-block-header-action"><div class="wf-block-header-action-disclosure" role="checkbox" aria-checked="<?php echo (wfPersistenceController::shared()->isActive($stateKey) ? 'true' : 'false'); ?>" tabindex="0"></div></div><?php endif; ?>
[27] Fix | Delete
</div>
[28] Fix | Delete
</div>
[29] Fix | Delete
<div class="wf-block-content">
[30] Fix | Delete
<ul class="wf-block-list wf-block-list-horizontal">
[31] Fix | Delete
<li id="wf-option-wafStatus" class="wf-flex-vertical wf-flex-align-left wf-flex-full-width">
[32] Fix | Delete
<h3><?php esc_html_e('Web Application Firewall Status', 'wordfence'); ?></h3>
[33] Fix | Delete
<?php if ($firewall->isSubDirectoryInstallation()): ?>
[34] Fix | Delete
<p class="wf-no-top"><?php echo wp_kses(sprintf(/* translators: WordPress admin URL. */ __('You are currently running the Wordfence Web Application Firewall from another WordPress installation. Please <a href="%s">click here</a> to configure the Firewall to run correctly on this site.', 'wordfence'), esc_attr(network_admin_url('admin.php?page=WordfenceWAF&subpage=waf_options#configureAutoPrepend'))), array('a'=>array('href'=>array()))); ?></p>
[35] Fix | Delete
<?php else: ?>
[36] Fix | Delete
<p class="wf-no-top">
[37] Fix | Delete
<?php $wafStatus = $firewall->firewallMode(); ?>
[38] Fix | Delete
<span id="wafStatus-enabled-description" class="wafStatus-description"<?php if ($wafStatus != wfFirewall::FIREWALL_MODE_ENABLED) { echo ' style="display: none;"'; } ?>><strong><?php esc_html_e('Enabled and Protecting:', 'wordfence'); ?></strong> <?php esc_html_e('In this mode, the Wordfence Web Application Firewall is actively blocking requests matching known attack patterns and is actively protecting your site from attackers.', 'wordfence'); ?></span>
[39] Fix | Delete
<span id="wafStatus-learning-mode-description" class="wafStatus-description"<?php if ($wafStatus != wfFirewall::FIREWALL_MODE_LEARNING) { echo ' style="display: none;"'; } ?>><strong><?php esc_html_e('Learning Mode:', 'wordfence'); ?></strong> <?php echo wp_kses(sprintf(/* translators: Support URL. */ __('When you first install the Wordfence Web Application Firewall, it will be in learning mode. This allows Wordfence to learn about your site so that we can understand how to protect it and how to allow normal visitors through the firewall. We recommend you let Wordfence learn for a week before you enable the firewall. <a href="%s" target="_blank" rel="noopener noreferrer">Learn More<span class="screen-reader-text"> (opens in new tab)</span></a>', 'wordfence'), wfSupportController::supportURL(wfSupportController::ITEM_FIREWALL_WAF_LEARNING_MODE)), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array()), 'span'=>array('class'=>array()))); ?></span>
[40] Fix | Delete
<span id="wafStatus-disabled-description" class="wafStatus-description"<?php if ($wafStatus != wfFirewall::FIREWALL_MODE_DISABLED) { echo ' style="display: none;"'; } ?>><strong><?php esc_html_e('Disabled:', 'wordfence'); ?></strong> <?php esc_html_e('In this mode, the Wordfence Web Application Firewall is functionally turned off and does not run any of its rules or analyze the request in any way.', 'wordfence'); ?></span>
[41] Fix | Delete
</p>
[42] Fix | Delete
<p class="wf-no-top wf-add-bottom">
[43] Fix | Delete
<select id="input-wafStatus" data-original-value="<?php echo esc_attr($wafStatus); ?>" name="wafStatus" class="wf-form-control"<?php echo !WFWAF_ENABLED ? ' disabled' : '' ?>>
[44] Fix | Delete
<option<?php echo $wafStatus == wfFirewall::FIREWALL_MODE_ENABLED ? ' selected' : '' ?> class="wafStatus-enabled" value="enabled"><?php esc_html_e('Enabled and Protecting', 'wordfence'); ?></option>
[45] Fix | Delete
<option<?php echo $wafStatus == wfFirewall::FIREWALL_MODE_LEARNING ? ' selected' : '' ?> class="wafStatus-learning-mode" value="learning-mode"><?php esc_html_e('Learning Mode', 'wordfence'); ?></option>
[46] Fix | Delete
<option<?php echo $wafStatus == wfFirewall::FIREWALL_MODE_DISABLED ? ' selected' : '' ?> class="wafStatus-disabled" value="disabled"><?php esc_html_e('Disabled', 'wordfence'); ?></option>
[47] Fix | Delete
</select>
[48] Fix | Delete
<script type="application/javascript">
[49] Fix | Delete
(function($) {
[50] Fix | Delete
$(function() {
[51] Fix | Delete
$('#input-wafStatus').wfselect2({
[52] Fix | Delete
minimumResultsForSearch: -1,
[53] Fix | Delete
width: '200px'
[54] Fix | Delete
}).on('change', function() {
[55] Fix | Delete
var select = $(this);
[56] Fix | Delete
var value = select.val();
[57] Fix | Delete
var container = $($(this).data('wfselect2').$container);
[58] Fix | Delete
container.removeClass('wafStatus-enabled wafStatus-learning-mode wafStatus-disabled')
[59] Fix | Delete
.addClass('wafStatus-' + value);
[60] Fix | Delete
[61] Fix | Delete
$('.wafStatus-description').hide();
[62] Fix | Delete
$('#wafStatus-' + value + '-description').show();
[63] Fix | Delete
if (value == 'learning-mode') {
[64] Fix | Delete
$('#waf-learning-mode-grace-period').show();
[65] Fix | Delete
}
[66] Fix | Delete
else {
[67] Fix | Delete
$('#waf-learning-mode-grace-period').hide();
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
var originalValue = select.data('originalValue');
[71] Fix | Delete
if (originalValue == value) {
[72] Fix | Delete
delete WFAD.pendingChanges['wafStatus'];
[73] Fix | Delete
}
[74] Fix | Delete
else {
[75] Fix | Delete
WFAD.pendingChanges['wafStatus'] = value;
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
WFAD.updatePendingChanges();
[79] Fix | Delete
}).val(<?php echo json_encode($wafStatus) ?>).triggerHandler('change');
[80] Fix | Delete
[81] Fix | Delete
$('#waf-learning-mode-grace-period .wf-datetime').datetimepicker({
[82] Fix | Delete
dateFormat: 'yy-mm-dd',
[83] Fix | Delete
timezone: <?php try { echo (int) wfUtils::timeZoneMinutes($config->getConfig('learningModeGracePeriod') ? (int) $config->getConfig('learningModeGracePeriod') : false); } catch (Exception $e) { echo 0; }; ?>,
[84] Fix | Delete
showTime: false,
[85] Fix | Delete
showTimepicker: false,
[86] Fix | Delete
showMonthAfterYear: true
[87] Fix | Delete
}).each(function() {
[88] Fix | Delete
var el = $(this);
[89] Fix | Delete
if (el.attr('data-value')) {
[90] Fix | Delete
el.datetimepicker('setDate', new Date(el.attr('data-value') * 1000));
[91] Fix | Delete
}
[92] Fix | Delete
}).on('change', function() {
[93] Fix | Delete
var value = Math.floor($(this).datetimepicker('getDate').getTime() / 1000);
[94] Fix | Delete
var originalValue = $('#input-learningModeGracePeriod').data('originalValue');
[95] Fix | Delete
if (originalValue == value) {
[96] Fix | Delete
delete WFAD.pendingChanges['learningModeGracePeriod'];
[97] Fix | Delete
}
[98] Fix | Delete
else {
[99] Fix | Delete
WFAD.pendingChanges['learningModeGracePeriod'] = $(this).val();
[100] Fix | Delete
}
[101] Fix | Delete
WFAD.updatePendingChanges();
[102] Fix | Delete
});
[103] Fix | Delete
[104] Fix | Delete
$('#waf-learning-mode-grace-period .wf-option-checkbox').on('click', function(e) {
[105] Fix | Delete
e.preventDefault();
[106] Fix | Delete
e.stopPropagation();
[107] Fix | Delete
[108] Fix | Delete
var originalValue = $(this).data('originalValue');
[109] Fix | Delete
var value = originalValue;
[110] Fix | Delete
var isActive = $(this).hasClass('wf-checked');
[111] Fix | Delete
if (isActive) {
[112] Fix | Delete
$(this).removeClass('wf-checked');
[113] Fix | Delete
$('#waf-learning-mode-grace-period .wf-datetime').attr('disabled', true);
[114] Fix | Delete
value = 0;
[115] Fix | Delete
}
[116] Fix | Delete
else {
[117] Fix | Delete
$(this).addClass('wf-checked');
[118] Fix | Delete
$('#waf-learning-mode-grace-period .wf-datetime').attr('disabled', false);
[119] Fix | Delete
value = 1;
[120] Fix | Delete
[121] Fix | Delete
if (!$('#input-learningModeGracePeriod').val()) {
[122] Fix | Delete
var date = new Date();
[123] Fix | Delete
date.setDate(date.getDate() + 7);
[124] Fix | Delete
$('#input-learningModeGracePeriod').datetimepicker('setDate', date);
[125] Fix | Delete
}
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
if (originalValue == value) {
[129] Fix | Delete
delete WFAD.pendingChanges['learningModeGracePeriodEnabled'];
[130] Fix | Delete
}
[131] Fix | Delete
else {
[132] Fix | Delete
WFAD.pendingChanges['learningModeGracePeriodEnabled'] = value;
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
WFAD.updatePendingChanges();
[136] Fix | Delete
});
[137] Fix | Delete
[138] Fix | Delete
$(window).on('wfOptionsReset', function() {
[139] Fix | Delete
$('#input-wafStatus').val($('#input-wafStatus').data('originalValue')).trigger('change');
[140] Fix | Delete
$('#waf-learning-mode-grace-period .wf-option-checkbox').each(function() {
[141] Fix | Delete
var originalValue = $(this).data('originalValue');
[142] Fix | Delete
$(this).toggleClass('wf-checked', !!originalValue);
[143] Fix | Delete
$('#waf-learning-mode-grace-period .wf-datetime').attr('disabled', !originalValue);
[144] Fix | Delete
});
[145] Fix | Delete
$('.wf-datetime').each(function() {
[146] Fix | Delete
var el = $(this);
[147] Fix | Delete
if (el.attr('data-value')) {
[148] Fix | Delete
el.datetimepicker('setDate', new Date(el.attr('data-value') * 1000));
[149] Fix | Delete
}
[150] Fix | Delete
else {
[151] Fix | Delete
el.val('');
[152] Fix | Delete
}
[153] Fix | Delete
})
[154] Fix | Delete
});
[155] Fix | Delete
});
[156] Fix | Delete
})(jQuery);
[157] Fix | Delete
</script>
[158] Fix | Delete
</p>
[159] Fix | Delete
<div id="waf-learning-mode-grace-period" class="wf-add-bottom" style="display: none;"><div class="waf-learning-mode wf-option-checkbox<?php try { echo $config->getConfig('learningModeGracePeriodEnabled') ? ' wf-checked' : ''; } catch (Exception $e) { /* Do nothing */ } ?>" data-original-value="<?php try { echo $config->getConfig('learningModeGracePeriodEnabled') ? 1 : 0; } catch (Exception $e) { echo 0; } ?>"><i class="wf-ion-ios-checkmark-empty" aria-hidden="true"></i></div><span> <?php esc_html_e('Automatically enable on', 'wordfence'); ?> </span><input type="text" name="learningModeGracePeriod" id="input-learningModeGracePeriod" class="wf-datetime wf-form-control" placeholder="Enabled until..." data-value="<?php try { echo esc_attr($config->getConfig('learningModeGracePeriod') ? (int) $config->getConfig('learningModeGracePeriod') : ''); } catch (Exception $e) { /* Do nothing */ } ?>" data-original-value="<?php try { echo esc_attr($config->getConfig('learningModeGracePeriod') ? (int) $config->getConfig('learningModeGracePeriod') : ''); } catch (Exception $e) { /* Do nothing */ } ?>"<?php try { echo $config->getConfig('learningModeGracePeriodEnabled') ? '' : ' disabled'; } catch (Exception $e) { echo ' disabled'; } ?>></div>
[160] Fix | Delete
<?php endif; ?>
[161] Fix | Delete
</li>
[162] Fix | Delete
<li id="wf-option-protectionMode" class="wf-flex-vertical wf-flex-align-left">
[163] Fix | Delete
<h3><?php esc_html_e('Protection Level', 'wordfence'); ?></h3>
[164] Fix | Delete
<?php if ($firewall->protectionMode() == wfFirewall::PROTECTION_MODE_EXTENDED && !$firewall->isSubDirectoryInstallation()): ?>
[165] Fix | Delete
<p class="wf-no-top"><strong><?php esc_html_e('Extended Protection:', 'wordfence'); ?></strong> <?php esc_html_e('All PHP requests will be processed by the firewall prior to running.', 'wordfence'); ?></p>
[166] Fix | Delete
<p><?php echo wp_kses(sprintf(/* translators: Support URL. */ __('If you\'re moving to a new host or a new installation location, you may need to temporarily disable extended protection to avoid any file not found errors. Use this action to remove the configuration changes that enable extended protection mode or you can <a href="%s" target="_blank" rel="noopener noreferrer">remove them manually<span class="screen-reader-text"> (opens in new tab)</span></a>.', 'wordfence'), wfSupportController::esc_supportURL(wfSupportController::ITEM_FIREWALL_WAF_REMOVE_MANUALLY)), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array()), 'span'=>array('class'=>array()))); ?></p>
[167] Fix | Delete
<p class="wf-no-top"><a class="wf-btn wf-btn-default" href="#" id="wf-waf-uninstall" role="button"><?php esc_html_e('Remove Extended Protection', 'wordfence'); ?></a></p>
[168] Fix | Delete
<?php elseif ($firewall->isSubDirectoryInstallation()): ?>
[169] Fix | Delete
<p class="wf-no-top"><strong><?php esc_html_e('Existing WAF Installation Detected:', 'wordfence'); ?></strong> <?php esc_html_e('You are currently running the Wordfence Web Application Firewall from another WordPress installation. Please configure the firewall to run correctly on this site.', 'wordfence'); ?></p>
[170] Fix | Delete
<p><a class="wf-btn wf-btn-primary" href="#" id="wf-waf-install" role="button"><?php esc_html_e('Optimize the Wordfence Firewall', 'wordfence'); ?></a></p>
[171] Fix | Delete
<?php else: ?>
[172] Fix | Delete
<p class="wf-no-top"><strong><?php esc_html_e('Basic WordPress Protection:', 'wordfence'); ?></strong> <?php esc_html_e('The plugin will load as a regular plugin after WordPress has been loaded, and while it can block many malicious requests, some vulnerable plugins or WordPress itself may run vulnerable code before all plugins are loaded.', 'wordfence'); ?></p>
[173] Fix | Delete
<p><a class="wf-btn wf-btn-primary" href="#" id="wf-waf-install" role="button"><?php esc_html_e('Optimize the Wordfence Firewall', 'wordfence'); ?></a></p>
[174] Fix | Delete
<?php endif; ?>
[175] Fix | Delete
<script type="application/javascript">
[176] Fix | Delete
[177] Fix | Delete
(function($) {
[178] Fix | Delete
$(function() {
[179] Fix | Delete
var validateContinue = function() {
[180] Fix | Delete
var backupsAvailable = $('.wf-waf-backups:visible').data('backups');
[181] Fix | Delete
var backupsDownloaded = $('#wf-waf-server-config').data('backups');
[182] Fix | Delete
[183] Fix | Delete
var matchCount = 0;
[184] Fix | Delete
backupsAvailable = backupsAvailable.sort();
[185] Fix | Delete
backupsDownloaded = backupsDownloaded.sort();
[186] Fix | Delete
for (var i = 0; i < backupsAvailable.length; i++) {
[187] Fix | Delete
for (var n = 0; n < backupsDownloaded.length; n++) {
[188] Fix | Delete
if (backupsAvailable[i] == backupsDownloaded[n]) {
[189] Fix | Delete
matchCount++;
[190] Fix | Delete
}
[191] Fix | Delete
}
[192] Fix | Delete
}
[193] Fix | Delete
[194] Fix | Delete
$('#wf-waf-install-continue, #wf-waf-uninstall-continue').toggleClass('wf-disabled', matchCount != backupsAvailable.length);
[195] Fix | Delete
};
[196] Fix | Delete
[197] Fix | Delete
var installUninstallResponseHandler = function(action, res) {
[198] Fix | Delete
var modal = $('.wf-modal-title').closest('.wf-modal');
[199] Fix | Delete
if (res.needsCredentials) {
[200] Fix | Delete
var replacement = $(res.html);
[201] Fix | Delete
modal.replaceWith(replacement);
[202] Fix | Delete
modal = replacement;
[203] Fix | Delete
[204] Fix | Delete
var form = replacement.find('#request-filesystem-credentials-form').closest('form');
[205] Fix | Delete
form.find('input[type="submit"]').attr('type', 'hidden');
[206] Fix | Delete
form.on('submit', function(e) {
[207] Fix | Delete
e.preventDefault();
[208] Fix | Delete
e.stopPropagation();
[209] Fix | Delete
[210] Fix | Delete
WFAD.ajax(action, form.serialize(), function(res) {
[211] Fix | Delete
installUninstallResponseHandler(action, res);
[212] Fix | Delete
});
[213] Fix | Delete
});
[214] Fix | Delete
modal.find('#wf-waf-modal-continue').on('click', function(e) {
[215] Fix | Delete
e.preventDefault();
[216] Fix | Delete
e.stopPropagation();
[217] Fix | Delete
[218] Fix | Delete
form.trigger('submit');
[219] Fix | Delete
});
[220] Fix | Delete
$.wfcolorbox.resize();
[221] Fix | Delete
}
[222] Fix | Delete
else if (res.credentialsFailed || res.installationFailed || res.uninstallationFailed) {
[223] Fix | Delete
var replacement = $(res.html);
[224] Fix | Delete
modal.replaceWith(replacement);
[225] Fix | Delete
modal = replacement;
[226] Fix | Delete
modal.find('#wf-waf-modal-continue').on('click', function(e) {
[227] Fix | Delete
e.preventDefault();
[228] Fix | Delete
e.stopPropagation();
[229] Fix | Delete
[230] Fix | Delete
WFAD.colorboxClose();
[231] Fix | Delete
});
[232] Fix | Delete
$.wfcolorbox.resize();
[233] Fix | Delete
[234] Fix | Delete
var payload = {serverConfiguration: res.serverConfiguration, iniModified: 1};
[235] Fix | Delete
if (res.credentials) {
[236] Fix | Delete
payload['credentials'] = res.credentials;
[237] Fix | Delete
payload['credentialsSignature'] = res.credentialsSignature;
[238] Fix | Delete
}
[239] Fix | Delete
[240] Fix | Delete
$('.wf-waf-uninstall-try-again').on('click', function(e) {
[241] Fix | Delete
e.preventDefault();
[242] Fix | Delete
e.stopPropagation();
[243] Fix | Delete
[244] Fix | Delete
$(this).text('Retrying');
[245] Fix | Delete
payload['retryAttempted'] = 1;
[246] Fix | Delete
[247] Fix | Delete
WFAD.ajax(action, payload, function(res) {
[248] Fix | Delete
installUninstallResponseHandler(action, res);
[249] Fix | Delete
});
[250] Fix | Delete
});
[251] Fix | Delete
}
[252] Fix | Delete
else if (res.uninstallationWaiting) {
[253] Fix | Delete
var replacement = $(res.html);
[254] Fix | Delete
modal.replaceWith(replacement);
[255] Fix | Delete
modal = replacement;
[256] Fix | Delete
modal.find('#wf-waf-modal-continue').on('click', function(e) {
[257] Fix | Delete
e.preventDefault();
[258] Fix | Delete
e.stopPropagation();
[259] Fix | Delete
[260] Fix | Delete
WFAD.colorboxClose();
[261] Fix | Delete
}).addClass('wf-disabled');
[262] Fix | Delete
[263] Fix | Delete
var timeout = res.timeout; //In seconds
[264] Fix | Delete
setTimeout(function() {
[265] Fix | Delete
modal.find('#wf-waf-modal-continue').removeClass('wf-disabled');
[266] Fix | Delete
var payload = {serverConfiguration: res.serverConfiguration, iniModified: 1};
[267] Fix | Delete
if (res.credentials) {
[268] Fix | Delete
payload['credentials'] = res.credentials;
[269] Fix | Delete
payload['credentialsSignature'] = res.credentialsSignature;
[270] Fix | Delete
}
[271] Fix | Delete
WFAD.ajax(action, payload, function(res) {
[272] Fix | Delete
installUninstallResponseHandler(action, res);
[273] Fix | Delete
});
[274] Fix | Delete
}, (timeout + 10) * 1000);
[275] Fix | Delete
$.wfcolorbox.resize();
[276] Fix | Delete
}
[277] Fix | Delete
else if (res.ok) {
[278] Fix | Delete
var replacement = $(res.html);
[279] Fix | Delete
modal.replaceWith(replacement);
[280] Fix | Delete
modal = replacement;
[281] Fix | Delete
modal.find('#wf-waf-modal-continue').on('click', function(e) {
[282] Fix | Delete
e.preventDefault();
[283] Fix | Delete
e.stopPropagation();
[284] Fix | Delete
[285] Fix | Delete
<?php if (array_key_exists('wf_deactivate', $_GET)): ?>
[286] Fix | Delete
window.location.href = <?php echo json_encode(wfUtils::wpAdminURL('plugins.php?wf_deactivate=true')); ?>;
[287] Fix | Delete
<?php else: ?>
[288] Fix | Delete
window.location.reload(true);
[289] Fix | Delete
<?php endif ?>
[290] Fix | Delete
});
[291] Fix | Delete
$.wfcolorbox.resize();
[292] Fix | Delete
}
[293] Fix | Delete
else {
[294] Fix | Delete
WFAD.colorboxModal((WFAD.isSmallScreen ? '300px' : '400px'), <?php echo json_encode(__('Error During Setup', 'wordfence')) ?> , res.errorMsg);
[295] Fix | Delete
}
[296] Fix | Delete
};
[297] Fix | Delete
[298] Fix | Delete
var installUninstallHandler = function(html) {
[299] Fix | Delete
WFAD.colorboxHTML('800px', html, {overlayClose: false, closeButton: false, className: 'wf-modal', onComplete: function() {
[300] Fix | Delete
$('#wf-waf-server-config').data('backups', []);
[301] Fix | Delete
$('.wf-waf-backup-download').on('click', function(e) {
[302] Fix | Delete
var backupIndex = parseInt($(this).data('backupIndex'));
[303] Fix | Delete
var backupsAvailable = $(this).closest('.wf-waf-backups').data('backups');
[304] Fix | Delete
var backupsDownloaded = $('#wf-waf-server-config').data('backups');
[305] Fix | Delete
var found = false;
[306] Fix | Delete
for (var i = 0; i < backupsDownloaded.length; i++) {
[307] Fix | Delete
if (backupsDownloaded[i] == backupsAvailable[backupIndex]) {
[308] Fix | Delete
found = true;
[309] Fix | Delete
break;
[310] Fix | Delete
}
[311] Fix | Delete
}
[312] Fix | Delete
[313] Fix | Delete
if (!found) {
[314] Fix | Delete
backupsDownloaded.push(backupsAvailable[backupIndex]);
[315] Fix | Delete
$('#wf-waf-server-config').data('backups', backupsDownloaded);
[316] Fix | Delete
validateContinue();
[317] Fix | Delete
}
[318] Fix | Delete
});
[319] Fix | Delete
[320] Fix | Delete
$('#wf-waf-server-config').wfselect2({
[321] Fix | Delete
minimumResultsForSearch: -1,
[322] Fix | Delete
width: WFAD.isSmallScreen ? '300px' : '500px'
[323] Fix | Delete
});
[324] Fix | Delete
[325] Fix | Delete
$('#wf-waf-include-prepend > li').each(function(index, element) {
[326] Fix | Delete
$(element).on('click', function(e) {
[327] Fix | Delete
e.preventDefault();
[328] Fix | Delete
e.stopPropagation();
[329] Fix | Delete
[330] Fix | Delete
var control = $(this).closest('.wf-switch');
[331] Fix | Delete
var value = $(this).data('optionValue');
[332] Fix | Delete
[333] Fix | Delete
control.find('li').each(function() {
[334] Fix | Delete
$(this).toggleClass('wf-active', value == $(this).data('optionValue'));
[335] Fix | Delete
});
[336] Fix | Delete
});
[337] Fix | Delete
});
[338] Fix | Delete
[339] Fix | Delete
var nginxNotice = $('.wf-nginx-waf-config');
[340] Fix | Delete
var manualNotice = $('.wf-manual-waf-config');
[341] Fix | Delete
$('#wf-waf-server-config').on('change', function() {
[342] Fix | Delete
var el = $(this);
[343] Fix | Delete
if (manualNotice.length) {
[344] Fix | Delete
if (el.val() == 'manual') {
[345] Fix | Delete
manualNotice.fadeIn(400, function () {
[346] Fix | Delete
$.wfcolorbox.resize();
[347] Fix | Delete
});
[348] Fix | Delete
}
[349] Fix | Delete
else {
[350] Fix | Delete
manualNotice.fadeOut(400, function () {
[351] Fix | Delete
$.wfcolorbox.resize();
[352] Fix | Delete
});
[353] Fix | Delete
}
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
var identifier = '.wf-waf-backups-' + el.val().replace(/[^a-z0-9\-]/i, '');
[357] Fix | Delete
$('.wf-waf-backups').hide();
[358] Fix | Delete
$(identifier).show();
[359] Fix | Delete
if ($(identifier).find('.wf-waf-backup-file-list').children().length > 0) {
[360] Fix | Delete
$('.wf-waf-download-instructions').show();
[361] Fix | Delete
}
[362] Fix | Delete
else {
[363] Fix | Delete
$('.wf-waf-download-instructions').hide();
[364] Fix | Delete
}
[365] Fix | Delete
[366] Fix | Delete
if (nginxNotice.length) { //Install only
[367] Fix | Delete
if (el.val() == 'nginx') {
[368] Fix | Delete
nginxNotice.fadeIn(400, function () {
[369] Fix | Delete
$.wfcolorbox.resize();
[370] Fix | Delete
});
[371] Fix | Delete
}
[372] Fix | Delete
else {
[373] Fix | Delete
nginxNotice.fadeOut(400, function () {
[374] Fix | Delete
$.wfcolorbox.resize();
[375] Fix | Delete
});
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
validateContinue();
[379] Fix | Delete
return;
[380] Fix | Delete
}
[381] Fix | Delete
[382] Fix | Delete
$.wfcolorbox.resize();
[383] Fix | Delete
validateContinue();
[384] Fix | Delete
}).triggerHandler('change');
[385] Fix | Delete
[386] Fix | Delete
$('#wf-waf-install-continue').on('click', function(e) {
[387] Fix | Delete
e.preventDefault();
[388] Fix | Delete
e.stopPropagation();
[389] Fix | Delete
[390] Fix | Delete
var serverConfiguration = $('#wf-waf-server-config').val();
[391] Fix | Delete
var currentAutoPrepend = $('#wf-waf-include-prepend .wf-active').data('optionValue');
[392] Fix | Delete
[393] Fix | Delete
WFAD.ajax('wordfence_installAutoPrepend', {serverConfiguration: serverConfiguration, currentAutoPrepend: currentAutoPrepend}, function(res) {
[394] Fix | Delete
installUninstallResponseHandler('wordfence_installAutoPrepend', res);
[395] Fix | Delete
});
[396] Fix | Delete
});
[397] Fix | Delete
[398] Fix | Delete
$('#wf-waf-uninstall-continue').on('click', function(e) {
[399] Fix | Delete
e.preventDefault();
[400] Fix | Delete
e.stopPropagation();
[401] Fix | Delete
[402] Fix | Delete
if ($('.wf-manual-waf-config').is(':visible')) {
[403] Fix | Delete
WFAD.colorboxClose();
[404] Fix | Delete
return;
[405] Fix | Delete
}
[406] Fix | Delete
[407] Fix | Delete
var serverConfiguration = $('#wf-waf-server-config').val();
[408] Fix | Delete
[409] Fix | Delete
WFAD.ajax('wordfence_uninstallAutoPrepend', {serverConfiguration: serverConfiguration}, function(res) {
[410] Fix | Delete
installUninstallResponseHandler('wordfence_uninstallAutoPrepend', res);
[411] Fix | Delete
});
[412] Fix | Delete
});
[413] Fix | Delete
}});
[414] Fix | Delete
};
[415] Fix | Delete
[416] Fix | Delete
$('#wf-waf-install').on('click', function(e) {
[417] Fix | Delete
e.preventDefault();
[418] Fix | Delete
e.stopPropagation();
[419] Fix | Delete
[420] Fix | Delete
var installer = $('#wafTmpl_install').tmpl();
[421] Fix | Delete
var installerHTML = $("<div />").append(installer).html();
[422] Fix | Delete
installUninstallHandler(installerHTML);
[423] Fix | Delete
});
[424] Fix | Delete
[425] Fix | Delete
$('#wf-waf-uninstall').on('click', function(e) {
[426] Fix | Delete
e.preventDefault();
[427] Fix | Delete
e.stopPropagation();
[428] Fix | Delete
[429] Fix | Delete
var uninstaller = $('#wafTmpl_uninstall').tmpl();
[430] Fix | Delete
var uninstallerHTML = $("<div />").append(uninstaller).html();
[431] Fix | Delete
installUninstallHandler(uninstallerHTML);
[432] Fix | Delete
});
[433] Fix | Delete
[434] Fix | Delete
if (window.location.hash) {
[435] Fix | Delete
var hashes = WFAD.parseHashes();
[436] Fix | Delete
for (var i = 0; i < hashes.length; i++) {
[437] Fix | Delete
if (hashes[i] == 'configureAutoPrepend') {
[438] Fix | Delete
$('#wf-waf-install').trigger('click');
[439] Fix | Delete
history.replaceState('', document.title, window.location.pathname + window.location.search);
[440] Fix | Delete
}
[441] Fix | Delete
else if (hashes[i] == 'removeAutoPrepend') {
[442] Fix | Delete
$('#wf-waf-uninstall').trigger('click');
[443] Fix | Delete
history.replaceState('', document.title, window.location.pathname + window.location.search);
[444] Fix | Delete
}
[445] Fix | Delete
}
[446] Fix | Delete
}
[447] Fix | Delete
[448] Fix | Delete
$(window).on('hashchange', function () {
[449] Fix | Delete
var hashes = WFAD.parseHashes();
[450] Fix | Delete
for (var i = 0; i < hashes.length; i++) {
[451] Fix | Delete
if (hashes[i] == 'configureAutoPrepend') {
[452] Fix | Delete
$('#wf-waf-install').trigger('click');
[453] Fix | Delete
history.replaceState('', document.title, window.location.pathname + window.location.search);
[454] Fix | Delete
}
[455] Fix | Delete
else if (hashes[i] == 'removeAutoPrepend') {
[456] Fix | Delete
$('#wf-waf-uninstall').trigger('click');
[457] Fix | Delete
history.replaceState('', document.title, window.location.pathname + window.location.search);
[458] Fix | Delete
}
[459] Fix | Delete
}
[460] Fix | Delete
});
[461] Fix | Delete
});
[462] Fix | Delete
})(jQuery);
[463] Fix | Delete
</script>
[464] Fix | Delete
</li>
[465] Fix | Delete
<li id="wf-option-disableWAFBlacklistBlocking" class="wf-flex-vertical wf-flex-align-left">
[466] Fix | Delete
<h3><?php esc_html_e('Real-Time IP Blocklist', 'wordfence'); ?></h3>
[467] Fix | Delete
<?php if ($firewall->ruleMode() == wfFirewall::RULE_MODE_COMMUNITY): ?>
[468] Fix | Delete
<p class="wf-no-top"><strong><?php esc_html_e('Premium Feature:', 'wordfence'); ?></strong> <?php esc_html_e('This feature blocks all traffic from IPs with a high volume of recent malicious activity using Wordfence\'s real-time blocklist.', 'wordfence'); ?></p>
[469] Fix | Delete
<p><a class="wf-btn wf-btn-primary wf-btn-callout-subtle" href="https://www.wordfence.com/gnl1blacklistUpgrade/wordfence-signup/#premium-order-form" target="_blank" rel="noopener noreferrer"><?php esc_html_e('Upgrade to Premium', 'wordfence'); ?></a>&nbsp;&nbsp;<a class="wf-btn wf-btn-callout-subtle wf-btn-default" href="https://www.wordfence.com/gnl1blacklistLearn/wordfence-signup/" target="_blank" rel="noopener noreferrer"><?php esc_html_e('Learn More', 'wordfence'); ?><span class="screen-reader-text"> (<?php esc_html_e('opens in new tab', 'wordfence') ?>)</span></a></p>
[470] Fix | Delete
<?php elseif ($firewall->isSubDirectoryInstallation()): ?>
[471] Fix | Delete
<p class="wf-no-top"><?php echo wp_kses(sprintf(__('You are currently running the Wordfence Web Application Firewall from another WordPress installation. Please <a href="%s">click here</a> to configure the Firewall to run correctly on this site.', 'wordfence'), esc_attr(network_admin_url('admin.php?page=WordfenceWAF&subpage=waf_options#configureAutoPrepend'))), array('a'=>array('href'=>array()))); ?></p>
[472] Fix | Delete
<?php else: ?>
[473] Fix | Delete
<p class="wf-no-top"><?php esc_html_e('This feature blocks all traffic from IPs with a high volume of recent malicious activity using Wordfence\'s real-time blocklist.', 'wordfence'); ?></p>
[474] Fix | Delete
<div class="wf-option wf-option-switch wf-padding-add-bottom" data-option-name="disableWAFBlacklistBlocking" data-original-value="<?php try { echo $config->getConfig('disableWAFBlacklistBlocking') ? '1': '0'; } catch (Exception $e) { echo 0; } ?>">
[475] Fix | Delete
<ul class="wf-switch" role="radiogroup">
[476] Fix | Delete
<?php
[477] Fix | Delete
$states = array(
[478] Fix | Delete
array('value' => '1', 'label' => __('Disabled', 'wordfence')),
[479] Fix | Delete
array('value' => '0', 'label' => __('Enabled', 'wordfence')),
[480] Fix | Delete
);
[481] Fix | Delete
[482] Fix | Delete
foreach ($states as $s):
[483] Fix | Delete
$disableBlacklist = false;
[484] Fix | Delete
try {
[485] Fix | Delete
$disableBlacklist = !!$config->getConfig('disableWAFBlacklistBlocking');
[486] Fix | Delete
}
[487] Fix | Delete
catch (Exception $e) { }
[488] Fix | Delete
?>
[489] Fix | Delete
<li<?php if ($s['value'] == ($disableBlacklist ? '1': '0')) { echo ' class="wf-active"'; } ?> data-option-value="<?php echo esc_attr($s['value']); ?>" role="radio" aria-checked="<?php echo (($s['value'] == ($disableBlacklist ? '1': '0')) ? 'true' : 'false'); ?>" tabindex="0"><?php echo esc_html($s['label']); ?></li>
[490] Fix | Delete
<?php endforeach; ?>
[491] Fix | Delete
</ul>
[492] Fix | Delete
</div>
[493] Fix | Delete
<?php endif; ?>
[494] Fix | Delete
</li>
[495] Fix | Delete
</ul>
[496] Fix | Delete
</div>
[497] Fix | Delete
</div>
[498] Fix | Delete
</div>
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function