rebase from live enviornment

This commit is contained in:
Rachit Bhargava
2024-01-09 22:14:20 -05:00
parent ff0b49a046
commit 3a22fcaa4a
15968 changed files with 2344674 additions and 45234 deletions

View File

@@ -0,0 +1,505 @@
<?php
if (!defined('WORDFENCE_VERSION')) { exit; }
/**
* Presents the list of blocks.
*
*/
?>
<div class="wf-row">
<div class="wf-col-xs-12">
<div class="wf-flex-horizontal wf-flex-full-width wf-add-bottom-small">
<h3 class="wf-no-top wf-no-bottom"><?php echo wp_kses(sprintf(/* translators: Site URL */ __('Current blocks<span class="wf-hidden-xs"> for %s</span>', 'wordfence'), preg_replace('/^https?:\/\//i', '', wfUtils::wpSiteURL())), array('span'=>array('class'=>array()))); ?></h3>
<div class="wf-right">
<div class="wf-inline-block">
<ul class="wf-option wf-option-toggled-boolean-switch wf-option-no-spacing" data-option="displayAutomaticBlocks" data-enabled-value="1" data-disabled-value="0" data-original-value="<?php echo wfConfig::get('displayAutomaticBlocks') ? 1 : 0; ?>">
<li class="wf-boolean-switch<?php echo wfConfig::get('displayAutomaticBlocks') ? ' wf-active' : ''; ?>"><a href="#" class="wf-boolean-switch-handle"></a></li>
<li class="wf-option-title wf-padding-add-left wf-no-right wf-padding-no-right">
<?php echo wp_kses(__('Show<span class="wf-hidden-xs"> Wordfence</span> Automatic<span class="wf-hidden-xs"> Blocks</span>', 'wordfence'), array('span'=>array('class'=>array()))); ?>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="wf-row">
<div class="wf-col-xs-12">
<div class="wf-row">
<div class="wf-col-xs-12">
<div class="wf-block wf-block-no-header wf-active">
<div class="wf-block-content wf-padding-add-top-large wf-padding-add-bottom-large">
<ul class="wf-flex-horizontal wf-flex-vertical-xs wf-flex-full-width wf-flex-grow-all wf-no-top">
<li class="wf-padding-add-bottom-xs">
<ul class="wf-flex-horizontal wf-flex-full-width wf-flex-grow-first wf-no-top">
<li><input type="text" placeholder="<?php esc_attr_e('Filter by Type, Detail, or Reason', 'wordfence'); ?>" id="wf-blocks-filter-field" class="wf-input-text"></li>
<li class="wf-padding-add-left-medium"><a href="#" id="wf-blocks-apply-filter" class="wf-btn wf-btn-callout wf-btn-default" role="button"><?php esc_html_e('Filter', 'wordfence'); ?></a>&nbsp;&nbsp;<a href="<?php echo wfSupportController::esc_supportURL(wfSupportController::ITEM_FIREWALL_BLOCKING_FILTER); ?>" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (<?php esc_html_e('opens in new tab', 'wordfence') ?>)</span></a></li>
</ul>
</li>
<li class="wf-right wf-flex-vertical-xs">
<a href="#" id="blocks-bulk-unblock" class="wf-btn wf-btn-callout wf-btn-default" role="button"><?php esc_html_e('Unblock', 'wordfence'); ?></a>&nbsp;&nbsp;<a href="#" id="blocks-bulk-make-permanent" class="wf-btn wf-btn-callout wf-btn-default"><?php esc_html_e('Make Permanent', 'wordfence'); ?></a>&nbsp;&nbsp;<a href="<?php echo wfUtils::siteURLRelative(); ?>?_wfsf=blockedIPs&amp;nonce=<?php echo wp_create_nonce('wp-ajax'); ?>" id="blocks-export-ips" class="wf-btn wf-btn-callout wf-btn-default"><?php echo wp_kses(/* translators: word order may be altered as long as HTML remains around "All IPs" */ __('Export<span class="wf-hidden-xs"> All IPs</span>', 'wordfence'), array('span'=>array('class'=>array()))); ?></a>
</li>
</ul>
<div class="wf-block wf-block-no-padding wf-block-no-header wf-active wf-no-bottom wf-overflow-y-auto-xs">
<div class="wf-block-content">
<div id="wf-blocks-wrapper"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div> <!-- end block list -->
<script type="text/x-jquery-template" id="wf-blocks-tmpl">
<div class="wf-blocks-table-container">
<table class="wf-striped-table wf-blocks-table">
<thead>
</thead>
<tbody>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</script>
<script type="text/x-jquery-template" id="wf-blocks-columns-tmpl">
<tr class="wf-blocks-columns">
<th style="width: 2%;text-align: center"><div class="wf-blocks-bulk-select wf-option-checkbox"><i class="wf-ion-ios-checkmark-empty" aria-hidden="true"></i></div></th>
<th data-column="type" class="wf-sortable wf-unsorted"><?php esc_html_e('Block Type', 'wordfence'); ?> <i class="wf-sorted-ascending wf-ion-android-arrow-dropup" aria-hidden="true"></i><i class="wf-sorted-descending wf-ion-android-arrow-dropdown" aria-hidden="true"></i></th>
<th data-column="detail" class="wf-sortable wf-unsorted"><?php esc_html_e('Detail', 'wordfence'); ?> <i class="wf-sorted-ascending wf-ion-android-arrow-dropup" aria-hidden="true"></i><i class="wf-sorted-descending wf-ion-android-arrow-dropdown" aria-hidden="true"></i></th>
<th data-column="ruleAdded" class="wf-sortable wf-unsorted"><?php esc_html_e('Rule Added', 'wordfence'); ?> <i class="wf-sorted-ascending wf-ion-android-arrow-dropup" aria-hidden="true"></i><i class="wf-sorted-descending wf-ion-android-arrow-dropdown" aria-hidden="true"></i></th>
<th data-column="reason" class="wf-sortable wf-unsorted"><?php esc_html_e('Reason', 'wordfence'); ?> <i class="wf-sorted-ascending wf-ion-android-arrow-dropup" aria-hidden="true"></i><i class="wf-sorted-descending wf-ion-android-arrow-dropdown" aria-hidden="true"></i></th>
<th data-column="expiration" class="wf-sortable wf-unsorted"><?php esc_html_e('Expiration', 'wordfence'); ?> <i class="wf-sorted-ascending wf-ion-android-arrow-dropup" aria-hidden="true"></i><i class="wf-sorted-descending wf-ion-android-arrow-dropdown" aria-hidden="true"></i></th>
<th data-column="blockCount" class="wf-sortable wf-unsorted"><?php esc_html_e('Block Count', 'wordfence'); ?> <i class="wf-sorted-ascending wf-ion-android-arrow-dropup" aria-hidden="true"></i><i class="wf-sorted-descending wf-ion-android-arrow-dropdown" aria-hidden="true"></i></th>
<th data-column="lastAttempt" class="wf-sortable wf-unsorted"><?php esc_html_e('Last Attempt', 'wordfence'); ?> <i class="wf-sorted-ascending wf-ion-android-arrow-dropup" aria-hidden="true"></i><i class="wf-sorted-descending wf-ion-android-arrow-dropdown" aria-hidden="true"></i></th>
</tr>
</script>
<script type="text/x-jquery-template" id="wf-no-blocks-tmpl">
<tr id="wf-no-blocks">
<td colspan="8"><?php esc_html_e('No blocks are currently active.', 'wordfence'); ?></td>
</tr>
</script>
<script type="text/x-jquery-template" id="wf-no-filtered-blocks-tmpl">
<tr id="wf-no-blocks">
<td colspan="8"><?php esc_html_e('No blocks match the current filter.', 'wordfence'); ?></td>
</tr>
</script>
<script type="text/x-jquery-template" id="wf-blocks-loading-tmpl">
<tr id="wf-blocks-loading">
<td colspan="8" class="wf-center wf-padding-add-top wf-padding-add-bottom">
<?php
echo wfView::create('common/indeterminate-progress', array(
'size' => 50,
))->render();
?>
</td>
</tr>
</script>
<script type="text/x-jquery-template" id="wf-block-row-tmpl">
<tr class="wf-block-record" data-id="${id}" data-expiration="${expiration}">
<td style="text-align: center;"><div class="wf-blocks-table-bulk-checkbox wf-option-checkbox"><i class="wf-ion-ios-checkmark-empty" aria-hidden="true"></i></div></td>
<td data-column="type" data-sort="${typeSort}">${typeDisplay}</td>
<td data-column="detail" data-sort="${detailSort}">${detailDisplay}{{if (editable)}}&nbsp;<a href="#" class="wf-block-edit" data-edit-type="${editType}" data-edit-values="${editValues}" role="button"><i class="wf-ion-edit" aria-hidden="true"></i></a>{{/if}}</td>
<td data-column="ruleAdded" data-sort="${ruleAddedSort}">${ruleAddedDisplay}</td>
<td data-column="reason" data-sort="${reasonSort}">${reasonDisplay}</td>
<td data-column="expiration" data-sort="${expirationSort}">${expirationDisplay}</td>
<td data-column="blockCount" data-sort="${blockCountSort}">${blockCountDisplay}</td>
<td data-column="lastAttempt" data-sort="${lastAttemptSort}">${lastAttemptDisplay}</td>
</tr>
</script>
<script type="application/javascript">
(function($) {
WFAD.blockHeaderCheckboxAction = function(checkbox) { //Top-level checkboxes
$('.wf-blocks-bulk-select.wf-option-checkbox').toggleClass('wf-checked');
var checked = $(checkbox).hasClass('wf-checked');
$('.wf-blocks-table-bulk-checkbox.wf-option-checkbox').toggleClass('wf-checked', checked);
$(window).trigger('wordfenceUpdateBlockButtons');
};
$(window).on('wordfenceRefreshBlockList', function(e, payload, append) {
if (!payload.hasOwnProperty('loading')) {
payload['loading'] = false;
}
//Create table if needed
var table = $(".wf-blocks-table-container");
if (table.length == 0) {
var wrapperTemplate = $('#wf-blocks-tmpl').tmpl();
$('#wf-blocks-wrapper').append(wrapperTemplate);
table = $(".wf-blocks-table-container");
}
if (!append) {
table.find('.wf-block-record').remove();
}
//Create header if needed
if (table.find('thead > .wf-blocks-columns').length == 0) {
table.find('thead').append($('#wf-blocks-columns-tmpl').tmpl());
table.find('thead .wf-blocks-bulk-select.wf-option-checkbox').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
WFAD.blockHeaderCheckboxAction($(this));
});
table.find('thead > .wf-blocks-columns > .wf-sortable').on('click', function(e, initialState) {
e.preventDefault();
e.stopPropagation();
var column = $(this).data('column');
if ($(this).hasClass('wf-sorted-ascending')) {
table.find('.wf-blocks-columns > .wf-sortable.wf-sorted-ascending').each(function() {
$(this).removeClass('wf-sorted-ascending');
$(this).addClass('wf-sorted-descending');
});
if (!initialState) {
WFAD.sortColumn = column;
WFAD.sortDirection = 'descending';
$(window).trigger('wordfenceLoadBlocks', [true]);
}
}
else if ($(this).hasClass('wf-sorted-descending')) {
table.find('.wf-blocks-columns > .wf-sortable.wf-sorted-descending').each(function() {
$(this).removeClass('wf-sorted-descending');
$(this).addClass('wf-sorted-ascending');
});
if (!initialState) {
WFAD.sortColumn = column;
WFAD.sortDirection = 'ascending';
$(window).trigger('wordfenceLoadBlocks', [true]);
}
}
else {
table.find('.wf-blocks-columns > .wf-sortable').removeClass('wf-sorted-descending').removeClass('wf-sorted-ascending').addClass('wf-unsorted');
var column = $(this).data('column');
$(this).removeClass('wf-unsorted').addClass('wf-sorted-ascending');
table.find('tfoot > .wf-blocks-columns > .wf-sortable[data-column="' + column + '"]').removeClass('wf-unsorted').addClass('wf-sorted-ascending');
if (!initialState) {
WFAD.sortColumn = column;
WFAD.sortDirection = 'ascending';
$(window).trigger('wordfenceLoadBlocks', [true]);
}
}
});
}
//Create or remove footer if needed
var loadedBlockCount = $('.wf-block-record').length + payload['blocks'].length;
if (loadedBlockCount > 5 && table.find('tfoot > .wf-blocks-columns').length == 0) {
table.find('tfoot').append($('#wf-blocks-columns-tmpl').tmpl());
table.find('tfoot .wf-blocks-bulk-select.wf-option-checkbox').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
WFAD.blockHeaderCheckboxAction($(this));
});
table.find('tfoot > .wf-blocks-columns > .wf-sortable').on('click', function(e, initialState) {
e.preventDefault();
e.stopPropagation();
var column = $(this).data('column');
if ($(this).hasClass('wf-sorted-ascending')) {
table.find('.wf-blocks-columns > .wf-sortable.wf-sorted-ascending').each(function() {
$(this).removeClass('wf-sorted-ascending');
$(this).addClass('wf-sorted-descending');
});
if (!initialState) {
WFAD.sortColumn = column;
WFAD.sortDirection = 'descending';
$(window).trigger('wordfenceLoadBlocks', [true]);
}
}
else if ($(this).hasClass('wf-sorted-descending')) {
table.find('.wf-blocks-columns > .wf-sortable.wf-sorted-descending').each(function() {
$(this).removeClass('wf-sorted-descending');
$(this).addClass('wf-sorted-ascending');
});
if (!initialState) {
WFAD.sortColumn = column;
WFAD.sortDirection = 'ascending';
$(window).trigger('wordfenceLoadBlocks', [true]);
}
}
else {
table.find('.wf-blocks-columns > .wf-sortable').removeClass('wf-sorted-descending').removeClass('wf-sorted-ascending').addClass('wf-unsorted');
$(this).removeClass('wf-unsorted').addClass('wf-sorted-ascending');
table.find('thead > .wf-blocks-columns > .wf-sortable[data-column="' + column + '"]').removeClass('wf-unsorted').addClass('wf-sorted-ascending');
if (!initialState) {
WFAD.sortColumn = column;
WFAD.sortDirection = 'ascending';
$(window).trigger('wordfenceLoadBlocks', [true]);
}
}
});
}
else if (loadedBlockCount > 5) {
//Do nothing
}
else {
table.find('tfoot > .wf-blocks-columns').remove();
}
//Add row(s)
$('#wf-blocks-loading').remove();
if (!append && payload['blocks'].length == 0) {
if (!payload['loading'] && $('#wf-no-blocks').length == 0) {
if (!!WFAD.blocksFilter) {
table.find('tbody').append($('#wf-no-filtered-blocks-tmpl').tmpl());
}
else {
table.find('tbody').append($('#wf-no-blocks-tmpl').tmpl());
}
}
}
else {
$('#wf-no-blocks').remove();
for (var i = 0; i < payload['blocks'].length; i++) {
var row = $('#wf-block-row-tmpl').tmpl(payload['blocks'][i]);
row.find('.wf-blocks-table-bulk-checkbox.wf-option-checkbox').on('click', function() { //Individual checkboxes
e.preventDefault();
e.stopPropagation();
$(this).toggleClass('wf-checked');
$(window).trigger('wordfenceUpdateBulkSelect');
$(window).trigger('wordfenceUpdateBlockButtons');
});
row.find('.wf-block-edit').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var editType = $(this).data('editType');
$('#wf-block-type > li > a[data-value="' + editType + '"]').trigger('click');
if ($('#wf-block-parameters-title').offset().top < $(window).scrollTop()) {
$("body,html").animate({
scrollTop: $('#wf-block-parameters-title').offset().top
}, 800);
}
});
var reasonDisplayChunks = payload['blocks'][i]['reasonDisplay'].split(/\s+/);
for (var n = 0; n < reasonDisplayChunks.length; n++) {
if (reasonDisplayChunks[n].length >= 50) {
row.find('[data-column="reason"]').addClass('wf-split-word');
break;
}
}
var existing = table.find('tbody tr[data-id="' + payload['blocks'][i]['id'] + '"]');
if (existing.length > 0) {
existing.replaceWith(row);
}
else {
table.find('tbody').append(row);
}
}
}
try {
$('#wf-blocks-wrapper').data('hasCountryBlock', JSON.parse(payload.hasCountryBlock));
}
catch (e) {
$('#wf-blocks-wrapper').data('hasCountryBlock', '');
}
if (table.find('.wf-blocks-columns > .wf-sortable.wf-sorted-ascending, .wf-blocks-columns > .wf-sortable.wf-sorted-descending').length == 0) {
table.find('thead > .wf-blocks-columns > .wf-sortable[data-column="ruleAdded"]').addClass('wf-sorted-ascending').trigger('click', [true]);
}
$(window).trigger('wordfenceUpdateBlockButtons');
});
$(window).on('wordfenceUpdateBlockButtons', function() {
var totalCount = $('.wf-blocks-table-bulk-checkbox.wf-option-checkbox').length;
var checked = $('.wf-blocks-table-bulk-checkbox.wf-option-checkbox.wf-checked');
var allowUnblock = false;
var allowMakeForever = false;
for (var i = 0; i < checked.length; i++) {
var tr = $(checked[i]).closest('tr');
if (tr.is(':visible')) {
allowUnblock = true;
if (tr.data('expiration') > 0) {
allowMakeForever = true;
}
}
}
$('#blocks-bulk-unblock').toggleClass('wf-disabled', !allowUnblock);
$('#blocks-bulk-make-permanent').toggleClass('wf-disabled', !allowMakeForever);
$('#blocks-export-ips').toggleClass('wf-disabled', (totalCount == 0));
});
$(window).on('wordfenceUpdateBulkSelect', function() {
var totalCount = $('.wf-blocks-table-bulk-checkbox.wf-option-checkbox:visible').length;
var checkedCount = $('.wf-blocks-table-bulk-checkbox.wf-option-checkbox.wf-checked:visible').length;
$('.wf-blocks-bulk-select.wf-option-checkbox:visible').toggleClass('wf-checked', (totalCount > 0 && checkedCount == totalCount));
});
$(window).on('wordfenceLoadBlocks', function(e, reload) {
var offset = reload ? 0 : $('.wf-block-record').length;
WFAD.loadingBlocks = true;
WFAD.ajax('wordfence_getBlocks', {offset: offset, sortColumn: WFAD.sortColumn, sortDirection: WFAD.sortDirection, blocksFilter: WFAD.blocksFilter}, function(res) {
$(window).trigger('wordfenceRefreshBlockList', [res, !reload]);
WFAD.loadingBlocks = false;
});
});
$(function() {
WFAD.sortColumn = 'ruleAdded';
WFAD.sortDirection = 'descending';
$(window).trigger('wordfenceRefreshBlockList', [{blocks: [], loading: true}, false]);
$(window).trigger('wordfenceLoadBlocks', [true]);
var issuesWrapper = $('#wf-blocks-wrapper');
var hasScrolled = false;
$(window).on('scroll', function() {
var win = $(this);
var currentScrollBottom = win.scrollTop() + window.innerHeight;
var scrollThreshold = issuesWrapper.outerHeight() + issuesWrapper.offset().top;
if (hasScrolled && !WFAD.loadingBlocks && currentScrollBottom >= scrollThreshold) {
hasScrolled = false;
$(window).trigger('wordfenceLoadBlocks', [false]);
}
else if (currentScrollBottom < scrollThreshold) {
hasScrolled = true;
}
});
$('#wf-blocks-filter-field').on('keypress', function(e) {
if (e.which == 13) {
$('#wf-blocks-apply-filter').trigger('click');
return false;
}
}).on('change paste keyup', function() {
setTimeout(function() {
var currentValue = $('#wf-blocks-filter-field').val() || '';
if (!WFAD.blocksFilter) {
$('#wf-blocks-apply-filter').text('<?php esc_html_e('Filter', 'wordfence'); ?>').data('filterMode', '');
}
else if (currentValue == '' || currentValue == WFAD.blocksFilter) {
$('#wf-blocks-apply-filter').text('<?php esc_html_e('Clear Filter', 'wordfence'); ?>').data('filterMode', 'filtered');
}
else {
$('#wf-blocks-apply-filter').text('<?php esc_html_e('Change Filter', 'wordfence'); ?>').data('filterMode', 'pendingChange');
}
}, 4);
});
$('#wf-blocks-apply-filter').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var mode = $('#wf-blocks-apply-filter').data('filterMode') || '';
if (mode != 'filtered') {
WFAD.blocksFilter = $('#wf-blocks-filter-field').val() || '';
}
else {
WFAD.blocksFilter = '';
$('#wf-blocks-filter-field').val('')
}
$('#wf-blocks-filter-field').trigger('keyup');
$(window).trigger('wordfenceLoadBlocks', [true]);
});
$('#blocks-bulk-unblock').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var totalCount = $('.wf-blocks-table-bulk-checkbox.wf-option-checkbox:visible').length;
var checked = $('.wf-blocks-table-bulk-checkbox.wf-option-checkbox.wf-checked:visible');
var checkedCount = checked.length;
var removingCountryBlock = false;
var blockIDs = [];
var rows = [];
for (var i = 0; i < checked.length; i++) {
var tr = $(checked[i]).closest('tr');
rows.push(tr);
blockIDs.push(tr.data('id'));
if (tr.find('td[data-column="type"]').data('sort') == <?php echo (int) wfBlock::TYPE_COUNTRY; ?>) {
removingCountryBlock = true;
}
}
var prompt = $('#wfTmpl_unblockPrompt').tmpl({count: checkedCount});
var promptHTML = $("<div />").append(prompt).html();
WFAD.colorboxHTML('400px', promptHTML, {overlayClose: false, closeButton: false, className: 'wf-modal', onComplete: function() {
$('#wf-blocking-prompt-cancel').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
WFAD.colorboxClose();
});
$('#wf-blocking-prompt-unblock').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
WFAD.loadingBlocks = true;
WFAD.ajax('wordfence_deleteBlocks', {blocks: JSON.stringify(blockIDs), sortColumn: WFAD.sortColumn, sortDirection: WFAD.sortDirection, blocksFilter: WFAD.blocksFilter}, function(res) {
WFAD.loadingBlocks = false;
if (totalCount == checkedCount) {
$(window).trigger('wordfenceRefreshBlockList', [res, false]); //Everything deleted, just reload it
}
else {
for (var i = 0; i < rows.length; i++) {
$(rows[i]).remove();
}
if (removingCountryBlock) {
$('#wf-blocks-wrapper').data('hasCountryBlock', '');
}
$(window).trigger('wordfenceUpdateBulkSelect');
$(window).trigger('wordfenceUpdateBlockButtons');
}
WFAD.colorboxClose();
});
});
}});
});
$('#blocks-bulk-make-permanent').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var checked = $('.wf-blocks-table-bulk-checkbox.wf-option-checkbox.wf-checked:visible');
var updateIDs = [];
for (var i = 0; i < checked.length; i++) {
var tr = $(checked[i]).closest('tr');
if (tr.is(':visible')) {
updateIDs.push(tr.data('id'));
}
}
WFAD.loadingBlocks = true;
WFAD.ajax('wordfence_makePermanentBlocks', {updates: JSON.stringify(updateIDs), sortColumn: WFAD.sortColumn, sortDirection: WFAD.sortDirection, blocksFilter: WFAD.blocksFilter}, function(res) {
WFAD.loadingBlocks = false;
$(window).trigger('wordfenceRefreshBlockList', [res, false]);
});
});
$('.wf-option.wf-option-toggled-boolean-switch[data-option="displayAutomaticBlocks"]').on('change', function() {
delete WFAD.pendingChanges['displayAutomaticBlocks'];
var isOn = $(this).find('.wf-boolean-switch').hasClass('wf-active');
WFAD.setOption($(this).data('option'), (isOn ? $(this).data('enabledValue') : $(this).data('disabledValue')), function() {
$(window).trigger('wordfenceLoadBlocks', [true]);
});
});
});
})(jQuery);
</script>
<script type="text/x-jquery-template" id="wfTmpl_unblockPrompt">
<?php
echo wfView::create('common/modal-prompt', array(
'title' => __('Unblocking', 'wordfence'),
'message' => '{{if count == 1}}' . __('Are you sure you want to stop blocking the selected IP, range, or country?', 'wordfence') . ' {{else}}' . __('Are you sure you want to stop blocking the ${count} selected IPs, ranges, and countries?', 'wordfence') . '{{/if}}',
'primaryButton' => array('id' => 'wf-blocking-prompt-cancel', 'label' => __('Cancel', 'wordfence'), 'link' => '#'),
'secondaryButtons' => array(array('id' => 'wf-blocking-prompt-unblock', 'label' => __('Unblock', 'wordfence'), 'link' => '#')),
))->render();
?>
</script>

View File

@@ -0,0 +1,533 @@
<?php
if (!defined('WORDFENCE_VERSION')) { exit; }
$wfBlockRange = filter_input(INPUT_GET, 'wfBlockRange', FILTER_DEFAULT, FILTER_REQUIRE_SCALAR);
?>
<ul class="wf-block-list wf-block-list-vertical">
<li class="wf-flex-vertical wf-padding-add-top wf-padding-add-bottom">
<table id="wf-create-block" class="wf-option">
<tr>
<th class="wf-right wf-padding-add-right"><?php echo wp_kses(__('<span class="wf-hidden-xs">Block </span>Type', 'wordfence'), array('span'=>array('class'=>array()))); ?></th>
<td class="wf-block-type">
<ul id="wf-block-type" class="wf-nav wf-nav-pills wf-nav-pills-bordered wf-nav-pills-connected">
<li><a href="#" data-value="ip-address" data-new-button="<?php echo esc_attr(wp_kses(/* translators: word order may be altered as long as HTML remains around "this IP Address" */ __('Block<span class="wf-hidden-xs"> this IP Address</span>', 'wordfence'), array('span' => array('class' => array())))); ?>" role="button"><?php echo wp_kses(/* translators: word order may be altered as long as HTML remains around "Address" */ __('IP<span class="wf-hidden-xs"> Address</span>', 'wordfence'), array( 'span' => array( 'class' => array() ))); ?></a></li>
<li><a href="#" data-value="country" data-new-button="<?php echo esc_attr(wp_kses(/* translators: word order may be altered as long as HTML remains around "the Selected Countries" */ __('Block<span class="wf-hidden-xs"> the Selected Countries</span>', 'wordfence'), array('span' => array('class' => array())))); ?>" data-edit-button="<?php echo esc_attr(wp_kses(/* translators: word order may be reversed as long as HTML remains around "Block" */ __('Update<span class="wf-hidden-xs"> Block</span>', 'wordfence'), array('span' => array('class' => array())))); ?>" role="button"><?php esc_html_e('Country', 'wordfence'); ?></a></li>
<li<?php echo $wfBlockRange ? ' class="wf-active"' : '' ?>><a href="#" data-value="custom-pattern" data-new-button="<?php echo esc_attr(wp_kses(/* translators: word order may be altered as long as HTML remains around "Visitors Matching this Pattern" */ __('Block<span class="wf-hidden-xs"> Visitors Matching this Pattern</span>', 'wordfence'), array('span' => array('class' => array())))); ?>" role="button"><?php echo wp_kses(/* translators: word order may be reversed as long as HTML remains around "Custom" */ __('<span class="wf-hidden-xs">Custom </span>Pattern', 'wordfence'), array('span'=>array('class'=>array()))); ?></a></li>
</ul>
<script type="application/javascript">
(function($) {
WFAD.updateCreateBlockPattern = function() {
var active = $('#wf-block-type > li.wf-active a').data('value');
var duration = Date.parse('t + ' + $('#wf-block-duration').val());
if (duration === null || !$('#wf-block-duration').val() || $('#wf-block-duration').val() == 'forever') {
duration = 0;
}
else {
duration = (Date.now().getTime() - duration.getTime()) / 1000;
}
var allowCreation = duration >= 0 && !!$('#wf-block-reason').val();
if (active == 'ip-address') {
allowCreation = allowCreation && $('#wf-block-ip').val() && WFAD.isValidIP($('#wf-block-ip').val());
}
else if (active == 'country') {
var countries = $('#wf-block-country-countries').val() || [];
allowCreation = allowCreation && ($('#wf-block-country-login .wf-option-checkbox').hasClass('wf-checked') || $('#wf-block-country-site .wf-option-checkbox').hasClass('wf-checked')) && countries.length > 0;
}
else if (active == 'custom-pattern') {
allowCreation = allowCreation && (($('#wf-block-ip-range').val() && WFAD.parseIPRange($('#wf-block-ip-range').val())) || $('#wf-block-hostname').val() || $('#wf-block-user-agent').val() || $('#wf-block-referrer').val());
}
$('#wf-block-add-save').toggleClass('wf-disabled', !allowCreation);
};
$(function() {
$('#wf-block-type a').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$('#wf-block-type > li').removeClass('wf-active');
$(this).closest('li').addClass('wf-active');
$('#wf-block-duration, #wf-block-reason, #wf-block-ip, #wf-block-ip-range, #wf-block-hostname, #wf-block-user-agent, #wf-block-referrer').val('');
var title = $('#wf-block-parameters-title').data('newTitle');
var saveButton = $('#wf-block-type > li.wf-active a').data('newButton');
var active = $('#wf-block-type > li.wf-active a').data('value');
if (active == 'ip-address') {
$('.wf-block-add-country, .wf-block-add-pattern').hide();
$('.wf-block-add-ip').show();
}
else if (active == 'country') {
$('.wf-block-add-ip, .wf-block-add-pattern').hide();
$('.wf-block-add-country').show();
$('#wf-block-reason').val('<?php esc_attr_e('Country Blocking', 'wordfence'); ?>');
if (!!$('#wf-blocks-wrapper').data('hasCountryBlock')) {
title = $('#wf-block-parameters-title').data('editTitle');
saveButton = $('#wf-block-type > li.wf-active a').data('editButton');
var editValues = $('#wf-blocks-wrapper').data('hasCountryBlock');
$('.wf-block-edit').first().closest('tr').addClass('wf-editing');
$('#wf-block-reason').val(editValues.reason);
$('#wf-block-country-login .wf-option-checkbox').toggleClass('wf-checked', !!editValues.blockLogin);
$('#wf-block-country-site .wf-option-checkbox').toggleClass('wf-checked', !!editValues.blockSite);
$('#wf-block-country-countries').val(editValues.countries).trigger('change');
}
else {
$('#wf-block-country-login .wf-option-checkbox').toggleClass('wf-checked', true);
$('#wf-block-country-site .wf-option-checkbox').toggleClass('wf-checked', true);
$('#wf-block-country-countries').val([]).trigger('change');
}
}
else if (active == 'custom-pattern') {
$('.wf-block-add-ip, .wf-block-add-country').hide();
$('.wf-block-add-pattern').show();
}
$('#wf-block-parameters-title').text(title);
$('#wf-block-add-save').html(saveButton);
$('.wf-block-add-common').show();
});
$('#wf-block-type .wf-active a').triggerHandler('click');
<?php if ($wfBlockRange): ?>
$('#wf-block-ip-range').val('<?php echo esc_attr($wfBlockRange); ?>');
<?php endif; ?>
$('#wf-block-reason, #wf-block-ip, #wf-block-ip-range, #wf-block-hostname, #wf-block-user-agent, #wf-block-referrer').on('change paste keyup', function() {
setTimeout(function() {
WFAD.updateCreateBlockPattern();
}, 4);
});
});
})(jQuery);
</script>
</td>
</tr>
<tr class="" style="display: none;">
<th class="wf-right wf-padding-add-right"><?php esc_html_e('Block Duration', 'wordfence'); ?></th>
<td class="wf-option-text">
<input id="wf-block-duration" type="text" placeholder="<?php esc_attr_e('Enter a duration (default is forever)', 'wordfence'); ?>">
<script type="application/javascript">
<?php
$locale = get_locale();
$locale = preg_replace('/_/', '-', $locale);
$localizedDateJS = wfDateLocalization::localizationForLanguage($locale);
if ($localizedDateJS === false) {
$localizedDateJS = wfDateLocalization::localizationForLanguage('en-US');
}
echo $localizedDateJS;
?>
</script>
<?php if (false): ?><script type="application/javascript" src="<?php echo esc_attr(wfUtils::getBaseURL() . 'js/date.js'); ?>"></script><?php endif; ?>
</td>
</tr>
<?php if (wfConfig::get('isPaid')): ?>
<tr class="wf-block-add-country" style="display: none;">
<th class="wf-right wf-padding-add-right wf-padding-add-top-small"><?php echo wp_kses(__('<span class="wf-hidden-xs">What to </span>Block', 'wordfence'), array('span'=>array('class'=>array()))); ?></th>
<td class="wf-padding-add-top-small wf-form-field">
<div class="wf-option-checkboxes">
<ul id="wf-block-country-login">
<li class="wf-option-checkbox wf-checked"><i class="wf-ion-ios-checkmark-empty" aria-hidden="true"></i></li>
<li class="wf-option-title"><?php esc_html_e('Login Form', 'wordfence'); ?></li>
</ul>
<ul id="wf-block-country-site">
<li class="wf-option-checkbox wf-checked"><i class="wf-ion-ios-checkmark-empty" aria-hidden="true"></i></li>
<li class="wf-option-title"><?php echo wp_kses(__('<span class="wf-hidden-xs">Block access to the rest of the site</span><span class="wf-visible-xs">Rest of site</span>', 'wordfence'), array('span'=>array('class'=>array()))); ?></li>
</ul>
</div>
</td>
</tr>
<tr class="wf-block-add-country" style="display: none;">
<th class="wf-right wf-padding-add-right wf-padding-add-top-small"></th>
<td class="wf-padding-add-top-small wf-form-field">
<em><?php echo wp_kses(sprintf(/* translators: Support URL */ __('If you use Google Ads, blocking countries from accessing the entire site is not recommended. <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_BLOCKING_FULL_SITE)), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array()), 'span'=>array('class'=>array()))); ?></em>
</td>
</tr>
<tr class="wf-block-add-country" style="display: none;">
<th class="wf-right wf-padding-add-right wf-padding-add-top-small"><?php echo wp_kses(/* translators: word order may be altered as long as HTML remains around "to Block" */ __('Countries<span class="wf-hidden-xs"> to Block</span>', 'wordfence'), array('span'=>array('class'=>array()))); ?><br><a href="#" id="wf-block-country-countries-popup" role="button"><?php echo wp_kses(/* translators: word order may be reversed as long as HTML remains around "from List" */ __('Pick<span class="wf-hidden-xs"> from List</span>', 'wordfence'), array('span'=>array('class'=>array()))); ?></a></th>
<td class="wf-option-text wf-padding-add-top-small">
<select id="wf-block-country-countries" multiple>
<?php
require(WORDFENCE_PATH . 'lib/wfBulkCountries.php'); /** @var array $wfBulkCountries */
asort($wfBulkCountries);
foreach ($wfBulkCountries as $code => $name):
?>
<option value="<?php echo esc_attr($code); ?>"><?php echo esc_html($name); ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr class="wf-block-add-country" style="display: none;">
<th class="wf-right wf-padding-add-right wf-padding-add-top-small"></th>
<td class="wf-option-text wf-padding-add-top-small">
<div id="wf-block-country-countries-tags"></div>
</td>
</tr>
<?php else: ?>
<tr class="wf-block-add-country" style="display: none;">
<td colspan="2">
<ul class="wf-flex-vertical">
<li><h3><?php esc_html_e('Put Geographic Protection In Place With Country Blocking', 'wordfence'); ?></h3></li>
<li><p class="wf-no-top"><?php esc_html_e('Wordfence country blocking is designed to stop an attack, prevent content theft, or end malicious activity that originates from a geographic region in less than 1/300,000th of a second. Blocking countries who are regularly creating failed logins, a large number of page not found errors, and are clearly engaged in malicious activity is an effective way to protect your site during an attack.', 'wordfence'); ?></p></li>
<li><?php echo wfView::create('blocking/country-block-map')->render(); ?></li>
<li><a class="wf-btn wf-btn-primary wf-btn-callout-subtle" href="https://www.wordfence.com/gnl1countryBlockUpgrade/wordfence-signup/" target="_blank" rel="noopener noreferrer"><?php esc_html_e('Upgrade to Premium', 'wordfence'); ?><span class="screen-reader-text"> (<?php esc_html_e('opens in new tab', 'wordfence') ?>)</span></a></li>
</ul>
</td>
</tr>
<?php endif; ?>
<tr class="wf-block-add-ip" style="display: none;">
<th class="wf-right wf-padding-add-right wf-padding-add-top-small"><?php echo wp_kses(__('IP<span class="wf-hidden-xs"> Address to Block</span>', 'wordfence'), array('span'=>array('class'=>array()))); ?></th>
<td class="wf-option-text wf-padding-add-top-small"><input id="wf-block-ip" type="text" placeholder="<?php esc_attr_e('Enter an IP address', 'wordfence'); ?>"></td>
</tr>
<tr class="wf-block-add-pattern" style="display: none;">
<th class="wf-right wf-padding-add-right wf-padding-add-top-small"><?php echo wp_kses(__('IP<span class="wf-hidden-xs"> Address</span> Range', 'wordfence'), array('span'=>array('class'=>array()))); ?></th>
<td class="wf-option-text wf-padding-add-top-small"><input id="wf-block-ip-range" type="text" placeholder="<?php esc_attr_e('e.g., 192.168.200.200 - 192.168.200.220 or 192.168.200.0/24', 'wordfence'); ?>"></td>
</tr>
<tr class="wf-block-add-pattern" style="display: none;">
<th class="wf-right wf-padding-add-right wf-padding-add-top-small"><?php esc_html_e('Hostname', 'wordfence'); ?></th>
<td class="wf-option-text wf-padding-add-top-small"><input id="wf-block-hostname" type="text" placeholder="<?php esc_attr_e('e.g., *.amazonaws.com or *.linode.com', 'wordfence'); ?>"></td>
</tr>
<tr class="wf-block-add-pattern" style="display: none;">
<th class="wf-right wf-padding-add-right wf-padding-add-top-small"><?php echo wp_kses(__('<span class="wf-hidden-xs">Browser </span>User Agent', 'wordfence'), array('span'=>array('class'=>array()))); ?></th>
<td class="wf-option-text wf-padding-add-top-small"><input id="wf-block-user-agent" type="text" placeholder="<?php esc_attr_e('e.g., *badRobot*, *MSIE*, or *browserSuffix', 'wordfence'); ?>"></td>
</tr>
<tr class="wf-block-add-pattern" style="display: none;">
<th class="wf-right wf-padding-add-right wf-padding-add-top-small"><?php esc_html_e('Referrer', 'wordfence'); ?></th>
<td class="wf-option-text wf-padding-add-top-small"><input id="wf-block-referrer" type="text" placeholder="<?php esc_attr_e('e.g., *badwebsite.example.com*', 'wordfence'); ?>"></td>
</tr>
<tr class="wf-block-add-ip wf-block-add-pattern" style="display: none;">
<th class="wf-right wf-padding-add-right wf-padding-add-top-small"><?php echo wp_kses(__('<span class="wf-hidden-xs">Block </span>Reason', 'wordfence'), array('span'=>array('class'=>array()))); ?><span class="wf-red-dark">*</span></th>
<td class="wf-option-text wf-padding-add-top-small"><input id="wf-block-reason" type="text" placeholder="<?php esc_attr_e('Enter a reason', 'wordfence'); ?>" maxlength="50"></td>
</tr>
</table>
</li>
<li class="<?php echo (wfConfig::get('isPaid') ? 'wf-block-add-common' : 'wf-block-add-ip wf-block-add-pattern'); ?>" style="display: none;">
<div class="wf-right wf-padding-add-top wf-padding-add-bottom">
<a id="wf-block-add-cancel" class="wf-btn wf-btn-default wf-btn-callout-subtle" href="#" role="button"><?php esc_html_e('Cancel', 'wordfence'); ?></a>&nbsp;&nbsp;<a id="wf-block-add-save" class="wf-btn wf-btn-primary wf-btn-callout-subtle wf-disabled" href="#"><?php echo wp_kses(/* translators: word order may be altered as long as HTML remains around "Visitors Matching this" */ __('Block<span class="wf-hidden-xs"> Visitors Matching this</span> Pattern', 'wordfence'), array('span'=>array('class'=>array()))); ?></a>
<script type="application/javascript">
(function($) {
$(function() {
$('.wf-option-checkboxes .wf-option-checkbox').each(function() {
$(this).on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).toggleClass('wf-checked');
WFAD.updateCreateBlockPattern();
});
});
$('#wf-block-country-countries').wfselect2({
tags: true,
tokenSeparators: [',', ' '],
placeholder: "Hit enter to add",
width: 'element',
minimumResultsForSearch: 1,
minimumInputLength: 2,
selectOnClose: false,
createTag: function (params) {
return null; //No custom tags
},
sorter: function(results) {
var term = $('#wf-block-country-countries').data('wfselect2').$container.find('.wfselect2-search__field').val();
if (term) {
var escapedTerm = term.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
var termRegex = new RegExp('^' + escapedTerm, 'i');
return results.sort(function(a, b) {
var aPrefix = termRegex.test(a.text);
var bPrefix = termRegex.test(b.text);
if (aPrefix && !bPrefix) { return -1; }
if (!aPrefix && bPrefix) { return 1; }
return a.text.localeCompare(b.text);
});
}
return results;
}
}).on('change', function () {
var selected = $(this).find('option:selected');
var container = $('#wf-block-country-countries-tags');
var list = $('<ul>');
selected.each(function(index, value) {
var li = $('<li class="wf-tag-selected' + (index > 4 && !container.data('expanded') ? ' wf-hidden' : '') + '"><a class="wf-destroy-tag-selected">×</a>' + $(value).text() + '</li>');
li.children('a.wf-destroy-tag-selected')
.off('click.wfselect2-copy')
.on('click.wfselect2-copy', function(e) {
var opt = $(this).data('wfselect2-opt');
opt.prop('selected', false);
opt.parents('select').trigger('change');
}).data('wfselect2-opt', $(value));
list.append(li);
});
if (selected.length > 5) {
if (!container.data('expanded')) {
list.append($('<li class="wf-tags-show-hide-more"><a href="#" role="button">and ' + (selected.length - 5) + ' more...' + '</a></li>'));
}
else {
list.append($('<li class="wf-tags-show-hide-more"><a href="#" role="button">Hide' + '</a></li>'));
}
}
container.html('').append(list);
$('.wf-tags-show-hide-more').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var expanded = !!container.data('expanded');
$('.wf-tag-selected').slice(5).toggleClass('wf-hidden', expanded);
container.data('expanded', !expanded);
$(this).find('a').text(expanded ? 'and ' + (selected.length - 5) + ' more...' : 'Hide');
});
WFAD.updateCreateBlockPattern();
}).triggerHandler('change');
if ($('#wf-block-country-countries').length > 0) {
$('#wf-block-country-countries').data('wfselect2').$container.addClass('wf-select2-placeholder-fix wf-select2-hide-tags');
}
$('#wf-block-country-countries-popup').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var content = $('#wfTmpl_countrySelector').tmpl();
$(content).find('#wf-country-selector-confirm').text($('#wf-block-add-save').text());
var modal = $(content);
var countries = {};
var currentSelection = $('#wf-block-country-countries').val() || [];
for (var i = 0; i < currentSelection.length; i++) {
countries[currentSelection[i]] = 1;
modal.find('li[data-country="' + currentSelection[i] + '"]').addClass('wf-active');
}
modal.data('countries', countries);
$.wfDrawer({
width: WFAD.isSmallScreen ? '320px' : '800px',
content: content,
onComplete: function() {
var updateCount = function() {
var count = $('.wf-blocked-countries li.wf-active').length;
$('#wf-country-selector-count').text(count + (count == 1 ? ' Country Selected' : ' Countries Selected'));
};
updateCount();
$('.wf-blocked-countries a').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).closest('li').trigger('click');
});
$('.wf-blocked-countries li').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var modal = $('#wf-country-selector');
var countries = modal.data('countries');
var country = $(this).data('country');
$(this).toggleClass('wf-active');
if ($(this).hasClass('wf-active')) {
countries[country] = 1;
}
else {
delete countries[country];
}
modal.data('countries', countries);
updateCount();
});
$('#wf-country-selector-block-all').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var modal = $('#wf-country-selector');
var countries = {};
modal.find('li[data-country]').addClass('wf-active').each(function() {
countries[$(this).data('country')] = 1;
});
modal.data('countries', countries);
updateCount();
});
$('#wf-country-selector-unblock-all').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var modal = $('#wf-country-selector');
modal.data('countries', {});
modal.find('li[data-country]').removeClass('wf-active');
updateCount();
});
$('.wf-country-selector-section-options li a').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).closest('li').trigger('click');
});
$('.wf-country-selector-section-options li').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var letter = $(this).find('a').data('letter');
var scrollTarget = $('.wf-blocked-countries[data-letter="' + letter + '"]');
$('.wf-country-selector-inner-wrapper').animate({
scrollTop: $('.wf-country-selector-inner-wrapper').scrollTop() + scrollTarget.offset().top - $('.wf-country-selector-inner-wrapper').offset().top
}, 500);
});
$('#wf-country-selector-cancel').on('click', function(e) { //Commits but doesn't save
e.preventDefault();
e.stopPropagation();
var modal = $('#wf-country-selector');
var countries = Object.keys(modal.data('countries')) || [];
$('#wf-block-country-countries').val(countries).trigger('change');
$.wfDrawer.close()
});
$('#wf-country-selector-confirm').on('click', function(e) { //Commits and saves
e.preventDefault();
e.stopPropagation();
var modal = $('#wf-country-selector');
var countries = Object.keys(modal.data('countries')) || [];
$('#wf-block-country-countries').val(countries).trigger('change');
$('#wf-block-add-save').trigger('click');
$.wfDrawer.close()
});
}});
});
$('#wf-block-add-cancel').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$('.wf-blocks-table > tbody > tr').removeClass('wf-editing');
$('#wf-block-parameters-title').text($('#wf-block-parameters-title').data('newTitle'));
$('#wf-block-type > li').removeClass('wf-active');
$('.wf-block-add-common, .wf-block-add-ip, .wf-block-add-country, .wf-block-add-pattern').hide();
$('#wf-block-duration, #wf-block-reason, #wf-block-ip, #wf-block-ip-range, #wf-block-hostname, #wf-block-user-agent, #wf-block-referrer').val('');
});
$('#wf-block-add-save').on('click', function(e) {
var selectedCountries = $('#wf-block-country-countries').val() || [];
var blockSite = $('#wf-block-country-site .wf-option-checkbox').hasClass('wf-checked') ? 1 : 0;
var button = $(this);
var includesUs = false;
for (var index in selectedCountries) {
if (selectedCountries[index] === 'US') {
includesUs = true;
break;
}
}
if (includesUs && blockSite && !button.data('acknowledged')) {
var modal = $("#wfTmpl_blockUnitedStatesPrompt").tmpl();
var modalHtml = $("<div>").append(modal).html();
WFAD.colorboxHTML(
WFAD.isSmallScreen ? '300px' : '400px',
modalHtml,
{
onComplete: function() {
$('#wf-us-blocking-prompt-cancel').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
WFAD.colorboxClose();
});
$('#wf-us-blocking-prompt-continue').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
button.data('acknowledged', true);
WFAD.colorboxClose();
button.trigger('click');
});
},
className: 'wf-modal',
closeButton: false,
overlayClose: false
}
);
return;
}
button.data('acknowledged', false);
e.preventDefault();
e.stopPropagation();
var active = $('#wf-block-type > li.wf-active a').data('value');
var payload = {type: active};
payload['duration'] = Date.parse('t + ' + $('#wf-block-duration').val());
if (payload['duration'] === null || !$('#wf-block-duration').val() || $('#wf-block-duration').val() == 'forever') {
payload['duration'] = 0;
}
else {
payload['duration'] = (Date.now().getTime() - payload['duration'].getTime()) / 1000;
}
payload['reason'] = $('#wf-block-reason').val();
if (active == 'ip-address') {
payload['ip'] = $('#wf-block-ip').val();
}
else if (active == 'country') {
payload['blockLogin'] = $('#wf-block-country-login .wf-option-checkbox').hasClass('wf-checked') ? 1 : 0;
payload['blockSite'] = blockSite;
payload['countries'] = selectedCountries;
}
else if (active == 'custom-pattern') {
payload['ipRange'] = $('#wf-block-ip-range').val();
payload['hostname'] = $('#wf-block-hostname').val();
payload['userAgent'] = $('#wf-block-user-agent').val();
payload['referrer'] = $('#wf-block-referrer').val();
}
WFAD.loadingBlocks = true;
WFAD.ajax('wordfence_createBlock', {payload: JSON.stringify(payload), sortColumn: WFAD.sortColumn, sortDirection: WFAD.sortDirection, blocksFilter: WFAD.blocksFilter}, function(res) {
WFAD.loadingBlocks = false;
if (res.success) {
$(window).trigger('wordfenceRefreshBlockList', [res, false]);
$('.wf-blocks-table > tbody > tr').removeClass('wf-editing');
$('#wf-block-parameters-title').text($('#wf-block-parameters-title').data('newTitle'));
$('#wf-block-type > li').removeClass('wf-active');
$('.wf-block-add-common, .wf-block-add-ip, .wf-block-add-country, .wf-block-add-pattern').hide();
$('#wf-block-duration, #wf-block-reason, #wf-block-ip, #wf-block-ip-range, #wf-block-hostname, #wf-block-user-agent, #wf-block-referrer').val('');
}
else {
WFAD.colorboxModalHTML((WFAD.isSmallScreen ? '300px' : '400px'), <?php echo json_encode(esc_html__('Error Saving Block', 'wordfence')) ?>, res.error);
}
});
});
});
})(jQuery);
</script>
</div></li>
</ul>
<?php
echo wfView::create('blocking/country-modal')->render();
?>
<script type="text/x-jquery-template" id="wfTmpl_blockUnitedStatesPrompt">
<?php
echo wfView::create('common/modal-prompt', array(
'title' => __('U.S. Blocked', 'wordfence'),
'messageHTML' => esc_html__('For most sites, we recommend allowing access from the United States, where Google and other benign crawlers are located. Some well-known crawlers also have locations in Europe, so be careful when blocking other countries, especially if you have not seen significant attacks from them.', 'wordfence') . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_FIREWALL_BLOCKING_FULL_SITE). '" target="_blank" rel="noopener noreferrer">' . esc_html__('Learn More', 'wordfence') . '</a>',
'primaryButton' => array('id' => 'wf-us-blocking-prompt-cancel', 'label' => __('Cancel', 'wordfence'), 'link' => '#'),
'secondaryButtons' => array(array('id' => 'wf-us-blocking-prompt-continue', 'label' => __('Continue', 'wordfence'), 'link' => '#')),
))->render();
?>
</script>

View File

@@ -0,0 +1,31 @@
<?php
if (!defined('WORDFENCE_VERSION')) { exit; }
/**
* Presents the blocking status.
*
*/
?>
<ul class="wf-block-list wf-block-list-horizontal wf-blocking-status<?php echo (wfConfig::get('isPaid') ? ' wf-blocking-status-premium' : ''); ?>">
<li>
<?php
echo wfView::create('common/block-navigation-option', array(
'id' => 'blocking-all-options',
'img' => 'options.svg',
'title' => __('Blocking Options', 'wordfence'),
'subtitle' => __('Manage global blocking options.', 'wordfence'),
'link' => network_admin_url('admin.php?page=WordfenceWAF&subpage=blocking_options'),
))->render();
?>
</li>
<?php if (!wfConfig::get('isPaid')): ?>
<li class="wf-flex-horizontal wf-flex-full-width">
<div class="wf-flex-vertical wf-flex-align-left">
<h4 class="wf-no-bottom"><?php esc_html_e('Upgrade to Premium', 'wordfence') ?></h4>
<p class="wf-add-top-smaller"><?php esc_html_e('Enable country blocking by upgrading to Premium.', 'wordfence') ?></p>
</div>
<div class="wf-flex-horizontal wf-flex-full-width">
<p class="wf-right"><a class="wf-btn wf-btn-primary wf-btn-callout-subtle" href="https://www.wordfence.com/gnl1blockingUpgrade/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/gnl1blockingLearn/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>
</div>
</li>
<?php endif; ?>
</ul>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,79 @@
<?php
if (!defined('WORDFENCE_VERSION')) { exit; }
/**
* Presents the country selection modal.
*/
require(WORDFENCE_PATH . 'lib/wfBulkCountries.php'); /** @var array $wfBulkCountries */
asort($wfBulkCountries);
$letters = '';
foreach ($wfBulkCountries as $name) {
$l = strtoupper(substr($name, 0, 1));
$test = strtoupper(substr($letters, -1));
if ($l != $test) {
$letters .= $l;
}
}
$letters = str_split($letters);
?>
<script type="text/x-jquery-template" id="wfTmpl_countrySelector">
<div class="wf-modal" id="wf-country-selector">
<div class="wf-modal-header">
<div class="wf-modal-header-content">
<div class="wf-modal-title">
<?php esc_html_e('Select Countries to Block from List', 'wordfence'); ?>
</div>
</div>
<div class="wf-modal-header-action">
<a href="#" class="wf-btn wf-btn-default wf-btn-callout-subtle wf-countries-shortcut" id="wf-country-selector-block-all" data-shortcut="select" role="button"><?php esc_html_e('Block All', 'wordfence'); ?></a>&nbsp;&nbsp;<a href="#" class="wf-btn wf-btn-default wf-btn-callout-subtle wf-countries-shortcut" id="wf-country-selector-unblock-all" data-shortcut="deselect"><?php esc_html_e('Unblock All', 'wordfence'); ?></a>
</div>
</div>
<div class="wf-modal-content">
<ul class="wf-country-selector-controls">
<li>
<ul class="wf-country-selector-section-options">
<?php
foreach ($letters as $l) {
echo '<li><a href="#" data-letter="' . esc_attr($l) . '" role="button">' . esc_html($l) . '</a></li>';
}
?>
</ul>
</li>
</ul>
<div class="wf-country-selector-outer-wrapper">
<div class="wf-country-selector-inner-wrapper">
<div class="wf-country-selector-options">
<?php
$current = '';
foreach ($wfBulkCountries as $code => $name) {
$test = strtoupper(substr($name, 0, 1));
if ($test != $current) {
if ($current != '') {
echo '</ul>';
}
$current = $test;
?>
<ul class="wf-blocked-countries" data-letter="<?php echo esc_attr($current); ?>">
<?php
}
?>
<li id="wf-country-option-<?php echo esc_attr(strtolower($code)); ?>" data-country="<?php echo esc_attr($code); ?>"><a href="#" role="button"><?php echo esc_html($name); ?></a></li>
<?php
}
if ($current != '') {
echo '</ul>';
}
?>
</div>
</div>
</div>
</div>
<div class="wf-modal-footer">
<ul class="wf-flex-horizontal wf-flex-full-width">
<li id="wf-country-selector-count"></li>
<li class="wf-right"><a href="#" class="wf-btn wf-btn-default wf-btn-callout-subtle" id="wf-country-selector-cancel" role="button"><?php esc_html_e('Back', 'wordfence'); ?></a>&nbsp;&nbsp;<a href="#" class="wf-btn wf-btn-primary wf-btn-callout-subtle" id="wf-country-selector-confirm"><?php esc_html_e('Save', 'wordfence'); ?></a></li>
</ul>
</div>
</div>
</script>

View File

@@ -0,0 +1,51 @@
<?php
if (!defined('WORDFENCE_VERSION')) { exit; }
?>
<ul id="wf-option-cbl-bypassViewURL" class="wf-option wf-option-bypass-cookie">
<li class="wf-option-spacer"></li>
<li class="wf-option-content">
<ul>
<li class="wf-option-title"><?php esc_html_e('Bypass Cookie', 'wordfence'); ?> <a href="<?php echo wfSupportController::esc_supportURL(wfSupportController::ITEM_FIREWALL_BLOCKING_BYPASS_COOKIE); ?>" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (<?php esc_html_e('opens in new tab', 'wordfence') ?>)</span></a></li>
<li class="wf-option-fields">
<table class="wf-full-width">
<tr>
<td class="wf-right wf-padding-add-right"><?php esc_html_e('If user who is allowed to access the site views the relative URL', 'wordfence'); ?></td>
<td class="wf-option-text"><input id="wf-bypass-view-url" type="text" value="<?php echo esc_attr(wfConfig::get('cbl_bypassViewURL')); ?>" placeholder="<?php esc_attr_e('/set-country-bypass/', 'wordfence'); ?>" data-option="cbl_bypassViewURL" data-original-value="<?php echo esc_attr(wfConfig::get('cbl_bypassViewURL')); ?>"></td>
</tr>
<tr>
<td colspan="2" class="wf-right wf-padding-add-top-small"><?php esc_html_e('then set a cookie that will bypass country blocking in future in case that user hits the site from a blocked country.', 'wordfence'); ?></td>
</tr>
</table>
<script type="application/javascript">
(function($) {
$(function() {
$('#wf-bypass-view-url').on('change paste keyup', function() {
setTimeout(function() {
var option = $('#wf-bypass-view-url').data('option');
var value = $('#wf-bypass-view-url').val();
var originalValue = $('#wf-bypass-view-url').data('originalValue');
if (originalValue == value) {
delete WFAD.pendingChanges[option];
}
else {
WFAD.pendingChanges[option] = value;
}
WFAD.updatePendingChanges();
}, 4);
});
$(window).on('wfOptionsReset', function() {
$('#wf-bypass-view-url').each(function() {
var originalValue = $(this).data('originalValue');
$(this).val(originalValue);
});
});
});
})(jQuery);
</script>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,58 @@
<?php
if (!defined('WORDFENCE_VERSION')) { exit; }
?>
<ul class="wf-option wf-option-bypass-redirect">
<li class="wf-option-spacer"></li>
<li class="wf-option-content">
<ul>
<li class="wf-option-title"><?php esc_html_e('Bypass Redirect', 'wordfence'); ?> <a href="<?php echo wfSupportController::esc_supportURL(wfSupportController::ITEM_FIREWALL_BLOCKING_BYPASS_REDIRECT); ?>" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (<?php esc_html_e('opens in new tab', 'wordfence') ?>)</span></a></li>
<li class="wf-option-fields">
<table class="wf-full-width">
<tr>
<td class="wf-right wf-padding-add-right"><?php esc_html_e('If user hits the relative URL', 'wordfence'); ?></td>
<td id="wf-option-cbl-bypassRedirURL" class="wf-option-text"><input id="wf-bypass-redir-url" type="text" value="<?php echo esc_attr(wfConfig::get('cbl_bypassRedirURL'), array()); ?>" placeholder="<?php esc_attr_e('/bypassurl/', 'wordfence'); ?>" data-option="cbl_bypassRedirURL" data-original-value="<?php echo esc_attr(wfConfig::get('cbl_bypassRedirURL')); ?>"></td>
</tr>
<tr>
<td class="wf-right wf-padding-add-right wf-padding-add-top-small"><?php esc_html_e('then redirect that user to', 'wordfence'); ?></td>
<td id="wf-option-cbl-bypassRedirDest" class="wf-option-text wf-padding-add-top-small"><input id="wf-bypass-redir-dest" type="text" value="<?php echo esc_attr(wfConfig::get('cbl_bypassRedirDest')); ?>" placeholder="<?php esc_attr_e('/page-name/', 'wordfence'); ?>" data-option="cbl_bypassRedirDest" data-original-value="<?php echo esc_attr(wfConfig::get('cbl_bypassRedirDest')); ?>"></td>
</tr>
<tr>
<td></td>
<td class="wf-padding-add-top-small"><?php esc_html_e('and set a cookie that will bypass all country blocking.', 'wordfence'); ?></td>
</tr>
</table>
<script type="application/javascript">
(function($) {
$(function() {
$('#wf-bypass-redir-url, #wf-bypass-redir-dest').on('change paste keyup', function() {
var e = this;
setTimeout(function() {
var option = $(e).data('option');
var value = $(e).val();
var originalValue = $(e).data('originalValue');
if (originalValue == value) {
delete WFAD.pendingChanges[option];
}
else {
WFAD.pendingChanges[option] = value;
}
WFAD.updatePendingChanges();
}, 4);
});
$(window).on('wfOptionsReset', function() {
$('#wf-bypass-redir-url, #wf-bypass-redir-dest').each(function() {
var originalValue = $(this).data('originalValue');
$(this).val(originalValue);
});
});
});
})(jQuery);
</script>
</li>
</ul>
</li>
</ul>

View File

@@ -0,0 +1,91 @@
<?php
if (!defined('WORDFENCE_VERSION')) { exit; }
/**
* Presents the Advanced Country Blocking Options group.
*
* Expects $stateKey.
*
* @var string $stateKey The key under which the collapse state is stored.
* @var bool $collapseable If defined, specifies whether or not this grouping can be collapsed. Defaults to true.
*/
if (!isset($collapseable)) {
$collapseable = true;
}
?>
<div class="wf-row">
<div class="wf-col-xs-12">
<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); ?>">
<div class="wf-block-header">
<div class="wf-block-header-content">
<div class="wf-block-title">
<strong><?php esc_html_e('Advanced Country Blocking Options', 'wordfence'); ?></strong>
</div>
<?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; ?>
</div>
</div>
<div class="wf-block-content">
<?php if (wfConfig::get('isPaid')): ?>
<ul class="wf-block-list">
<li>
<?php
echo wfView::create('options/option-select', array(
'selectOptionName' => 'cbl_action',
'selectOptions' => array(
array('value' => 'block', 'label' => 'Show the standard Wordfence blocked message'),
array('value' => 'redir', 'label' => 'Redirect to the URL below'),
),
'selectValue' => wfConfig::get('cbl_action'),
'title' => __('What to do when we block someone', 'wordfence'),
'helpLink' => wfSupportController::supportURL(wfSupportController::ITEM_FIREWALL_BLOCKING_OPTION_WHAT_TO_DO),
))->render();
?>
</li>
<li>
<?php
echo wfView::create('options/option-text', array(
'textOptionName' => 'cbl_redirURL',
'textValue' => wfConfig::get('cbl_redirURL'),
'title' => __('URL to redirect blocked users to', 'wordfence'),
'placeholder' => __('Enter a full URL (e.g., http://example.com/blocked/)', 'wordfence'),
'helpLink' => wfSupportController::supportURL(wfSupportController::ITEM_FIREWALL_BLOCKING_OPTION_REDIRECT),
))->render();
?>
</li>
<li>
<?php
echo wfView::create('options/option-toggled', array(
'optionName' => 'cbl_loggedInBlocked',
'enabledValue' => 1,
'disabledValue' => 0,
'value' => wfConfig::get('cbl_loggedInBlocked') ? 1 : 0,
'title' => __('Block countries even if they are logged in', 'wordfence'),
'helpLink' => wfSupportController::supportURL(wfSupportController::ITEM_FIREWALL_BLOCKING_OPTION_BLOCK_LOGGED_IN),
))->render();
?>
</li>
<li>
<?php
echo wfView::create('blocking/option-bypass-redirect', array(
))->render();
?>
</li>
<li>
<?php
echo wfView::create('blocking/option-bypass-cookie', array(
))->render();
?>
</li>
</ul>
<?php else: ?>
<ul class="wf-flex-vertical wf-padding-add-right-large wf-padding-add-bottom-large">
<li><h3><?php esc_html_e('Put Geographic Protection In Place With Country Blocking', 'wordfence'); ?></h3></li>
<li><p class="wf-no-top"><?php esc_html_e('Wordfence country blocking is designed to stop an attack, prevent content theft, or end malicious activity that originates from a geographic region in less than 1/300,000th of a second. Blocking countries who are regularly creating failed logins, a large number of page not found errors, and are clearly engaged in malicious activity is an effective way to protect your site during an attack.', 'wordfence'); ?></p></li>
<li><?php echo wfView::create('blocking/country-block-map')->render(); ?></li>
<li><a class="wf-btn wf-btn-primary wf-btn-callout-subtle" href="https://www.wordfence.com/gnl1countryBlockUpgrade/wordfence-signup/" target="_blank" rel="noopener noreferrer"><?php esc_html_e('Upgrade to Premium', 'wordfence'); ?><span class="screen-reader-text"> (<?php esc_html_e('opens in new tab', 'wordfence') ?>)</span></a></li>
</ul>
<?php endif; ?>
</div>
</div>
</div>
</div> <!-- end country blocking -->