Merged in feature/from-pantheon (pull request #16)

code from pantheon

* code from pantheon
This commit is contained in:
Tony Volpe
2024-01-10 17:03:02 +00:00
parent 054b4fffc9
commit 4eb982d7a8
16492 changed files with 3475854 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
<?php if (!defined('WORDFENCE_VERSION')) { exit; } ?>
<?php //$data is defined here as an array of login attempts: array('IP' => binary ip, 'countryCode' => string, 'blockCount' => int, 'unixday' => int, 'totalIPs' => int, 'totalBlockCount' => int, 'countryName' => string) ?>
<table class="wf-table wf-table-hover">
<thead>
<tr>
<th colspan="2"><?php esc_html_e('Country', 'wordfence') ?></th>
<th><?php esc_html_e('Block Count', 'wordfence') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($data as $l): ?>
<tr>
<td><?php echo esc_html($l['countryName']); ?></td>
<td><span class="wf-flag <?php echo esc_attr('wf-flag-' . strtolower($l['countryCode'])); ?>" title="<?php echo esc_attr($l['countryName']); ?>"></span></td>
<td><?php echo esc_html(number_format_i18n($l['totalBlockCount'])); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

View File

@@ -0,0 +1,21 @@
<?php if (!defined('WORDFENCE_VERSION')) { exit; } ?>
<?php //$data is defined here as an array of login attempts: array('IP' => binary ip, 'countryCode' => string, 'blockCount' => int, 'unixday' => int, 'countryName' => string) ?>
<table class="wf-table wf-table-hover">
<thead>
<tr>
<th><?php esc_html_e('IP', 'wordfence') ?></th>
<th colspan="2"><?php esc_html_e('Country', 'wordfence') ?></th>
<th><?php esc_html_e('Block Count', 'wordfence') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($data as $l): ?>
<tr>
<td><?php echo esc_html(wfUtils::inet_ntop($l['IP'])); ?></td>
<td><?php echo esc_html($l['countryName']); ?></td>
<td><span class="wf-flag <?php echo esc_attr('wf-flag-' . strtolower($l['countryCode'])); ?>" title="<?php echo esc_attr($l['countryName']); ?>"></span></td>
<td><?php echo esc_html(number_format_i18n($l['blockCount'])); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

View File

@@ -0,0 +1,27 @@
<?php if (!defined('WORDFENCE_VERSION')) { exit; } ?>
<?php //$data is defined here as an array of login attempts: array('t' => timestamp, 'name' => username, 'ip' => IP address) ?>
<table class="wf-table wf-table-hover">
<thead>
<tr>
<th><?php esc_html_e('Username', 'wordfence') ?></th>
<th><?php esc_html_e('IP', 'wordfence') ?></th>
<th><?php esc_html_e('Date', 'wordfence') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($data as $l): ?>
<tr>
<td><?php echo esc_html($l['name']); ?></td>
<td><?php echo esc_html($l['ip']); ?></td>
<td><?php
if (time() - $l['t'] < 86400) {
echo esc_html(wfUtils::makeTimeAgo(time() - $l['t']) . ' ago');
}
else {
echo esc_html(wfUtils::formatLocalTime(get_option('date_format') . ' ' . get_option('time_format'), (int) $l['t']));
}
?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

View File

@@ -0,0 +1,64 @@
<?php if (!defined('WORDFENCE_VERSION')) { exit; } ?>
<?php //$d is defined here as a wfDashboard instance ?>
<div class="wf-row">
<div class="wf-col-xs-12">
<div class="wf-dashboard-item active">
<div class="wf-dashboard-item-inner">
<div class="wf-dashboard-item-content">
<div class="wf-dashboard-item-title">
<strong><?php esc_html_e('Top Countries by Number of Attacks - Last 7 Days', 'wordfence') ?></strong>
</div>
<div class="wf-dashboard-item-action"><div class="wf-dashboard-item-action-disclosure"></div></div>
</div>
</div>
<div class="wf-dashboard-item-extra">
<?php if ($firewall->learningModeStatus() !== false): ?>
<div class="wf-widget-learning-mode"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100.11 100.44"><path d="M96.14,30.67a50.7,50.7,0,0,0-10.66-16A50,50,0,0,0,69.51,4,49.57,49.57,0,0,0,30.6,4a50,50,0,0,0-16,10.69A50.69,50.69,0,0,0,4,30.67,50,50,0,0,0,4,69.74a50.62,50.62,0,0,0,10.66,16,50,50,0,0,0,16,10.69,49.54,49.54,0,0,0,38.91,0,50,50,0,0,0,16-10.69,50.56,50.56,0,0,0,10.66-16,50,50,0,0,0,0-39.07Zm-75.74,39a35.77,35.77,0,0,1-1-37.35,35.21,35.21,0,0,1,12.91-13A34.65,34.65,0,0,1,50.06,14.6a34.22,34.22,0,0,1,19.55,5.93ZM82.71,64a35.4,35.4,0,0,1-7.56,11.37A36,36,0,0,1,63.84,83a34.32,34.32,0,0,1-13.79,2.84A34.85,34.85,0,0,1,30.7,80L79.84,31a34.57,34.57,0,0,1,5.67,19.23A35.17,35.17,0,0,1,82.71,64Zm0,0"/></svg><span><?php esc_html_e('No Data Available During Learning Mode', 'wordfence'); ?></span></div>
<?php else: ?>
<ul class="wf-dashboard-item-list">
<li>
<div>
<?php if (isset($d->countriesNetwork) && count($d->countriesNetwork) > 0): ?>
<div class="wf-dashboard-toggle-btns">
<ul class="wf-pagination wf-pagination-sm">
<li class="wf-active"><a href="#" class="wf-dashboard-countries" data-grouping="local" role="button">Local Site</a></li>
<li><a href="#" class="wf-dashboard-countries" data-grouping="network" role="button"><?php esc_html_e('Wordfence Network', 'wordfence') ?></a></li>
</ul>
</div>
<?php endif; ?>
<div class="wf-countries wf-countries-local">
<?php if (!isset($d->countriesLocal) || count($d->countriesLocal) == 0): ?>
<div class="wf-dashboard-item-list-text"><p><em><?php esc_html_e('No blocks have been recorded.', 'wordfence') ?></em></p></div>
<?php else: ?>
<?php $data = array_slice($d->countriesLocal, 0, min(10, count($d->countriesLocal)), true); include(dirname(__FILE__) . '/widget_content_countries.php'); ?>
<?php endif; ?>
</div>
<div class="wf-countries wf-countries-network wf-hidden">
<?php if (!isset($d->countriesNetwork) || count($d->countriesNetwork) == 0): ?>
<div class="wf-dashboard-item-list-text"><p><em><?php esc_html_e('No blocks have been recorded.', 'wordfence') ?></em></p></div>
<?php else: ?>
<?php $data = array_slice($d->countriesNetwork, 0, min(10, count($d->countriesNetwork)), true); include(dirname(__FILE__) . '/widget_content_countries.php'); ?>
<?php endif; ?>
</div>
<script type="application/javascript">
(function($) {
$('.wf-dashboard-countries').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).closest('ul').find('li').removeClass('wf-active');
$(this).closest('li').addClass('wf-active');
$('.wf-countries').addClass('wf-hidden');
$('.wf-countries-' + $(this).data('grouping')).removeClass('wf-hidden');
});
})(jQuery);
</script>
</div>
</li>
</ul>
<?php endif; ?>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,131 @@
<?php if (!defined('WORDFENCE_VERSION')) { exit; } ?>
<?php
//$d is defined here as a wfDashboard instance
$initial = false;
if (!isset($limit)) { $limit = 10; $initial = true; }
?>
<div class="wf-row">
<div class="wf-col-xs-12">
<div class="wf-dashboard-item active">
<div class="wf-dashboard-item-inner">
<div class="wf-dashboard-item-content">
<div class="wf-dashboard-item-title">
<strong><?php esc_html_e('Top IPs Blocked', 'wordfence') ?></strong>
</div>
<div class="wf-dashboard-item-action"><div class="wf-dashboard-item-action-disclosure"></div></div>
</div>
</div>
<div class="wf-dashboard-item-extra">
<?php if ($firewall->learningModeStatus() !== false): ?>
<div class="wf-widget-learning-mode"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100.11 100.44"><path d="M96.14,30.67a50.7,50.7,0,0,0-10.66-16A50,50,0,0,0,69.51,4,49.57,49.57,0,0,0,30.6,4a50,50,0,0,0-16,10.69A50.69,50.69,0,0,0,4,30.67,50,50,0,0,0,4,69.74a50.62,50.62,0,0,0,10.66,16,50,50,0,0,0,16,10.69,49.54,49.54,0,0,0,38.91,0,50,50,0,0,0,16-10.69,50.56,50.56,0,0,0,10.66-16,50,50,0,0,0,0-39.07Zm-75.74,39a35.77,35.77,0,0,1-1-37.35,35.21,35.21,0,0,1,12.91-13A34.65,34.65,0,0,1,50.06,14.6a34.22,34.22,0,0,1,19.55,5.93ZM82.71,64a35.4,35.4,0,0,1-7.56,11.37A36,36,0,0,1,63.84,83a34.32,34.32,0,0,1-13.79,2.84A34.85,34.85,0,0,1,30.7,80L79.84,31a34.57,34.57,0,0,1,5.67,19.23A35.17,35.17,0,0,1,82.71,64Zm0,0"/></svg><span><?php esc_html_e('No Data Available During Learning Mode', 'wordfence'); ?></span></div>
<?php else: ?>
<ul class="wf-dashboard-item-list">
<li>
<div>
<div class="wf-dashboard-toggle-btns">
<ul class="wf-pagination wf-pagination-sm">
<li class="wf-active"><a href="#" class="wf-dashboard-ips" data-grouping="24h" role="button"><?php esc_html_e('24 Hours', 'wordfence') ?></a></li>
<li><a href="#" class="wf-dashboard-ips" data-grouping="7d" role="button"><?php esc_html_e('7 Days', 'wordfence') ?></a></li>
<li><a href="#" class="wf-dashboard-ips" data-grouping="30d" role="button"><?php esc_html_e('30 Days', 'wordfence') ?></a></li>
</ul>
</div>
<div class="wf-ips wf-ips-24h">
<?php if (count($d->ips24h) == 0): ?>
<div class="wf-dashboard-item-list-text"><p><em><?php esc_html_e('No blocks have been recorded.', 'wordfence') ?></em></p></div>
<?php else: ?>
<?php $data = array_slice($d->ips24h, 0, min($limit, count($d->ips24h)), true); include(dirname(__FILE__) . '/widget_content_ips.php'); ?>
<?php if (count($d->ips24h) > $limit && $initial): ?>
<div class="wf-dashboard-item-list-text"><div class="wf-dashboard-show-more" data-grouping="ips" data-period="24h"><a href="#" role="button"><?php esc_html_e('Show more', 'wordfence') ?></a></div></div>
<?php endif; ?>
<?php endif; ?>
</div>
<div class="wf-ips wf-ips-7d wf-hidden">
<?php if (count($d->ips7d) == 0): ?>
<div class="wf-dashboard-item-list-text"><p><em><?php esc_html_e('No blocks have been recorded.', 'wordfence') ?></em></p></div>
<?php else: ?>
<?php $data = array_slice($d->ips7d, 0, min($limit, count($d->ips7d)), true); include(dirname(__FILE__) . '/widget_content_ips.php'); ?>
<?php if (count($d->ips7d) > $limit && $initial): ?>
<div class="wf-dashboard-item-list-text"><div class="wf-dashboard-show-more" data-grouping="ips" data-period="7d"><a href="#" role="button"><?php esc_html_e('Show more', 'wordfence') ?></a></div></div>
<?php endif; ?>
<?php endif; ?>
</div>
<div class="wf-ips wf-ips-30d wf-hidden">
<?php if (count($d->ips30d) == 0): ?>
<div class="wf-dashboard-item-list-text"><p><em><?php esc_html_e('No blocks have been recorded.', 'wordfence') ?></em></p></div>
<?php else: ?>
<?php $data = array_slice($d->ips30d, 0, min($limit, count($d->ips30d)), true); include(dirname(__FILE__) . '/widget_content_ips.php'); ?>
<?php if (count($d->ips30d) > $limit && $initial): ?>
<div class="wf-dashboard-item-list-text"><div class="wf-dashboard-show-more" data-grouping="ips" data-period="30d"><a href="#" role="button"><?php esc_html_e('Show more', 'wordfence') ?></a></div></div>
<?php endif; ?>
<?php endif; ?>
</div>
<script type="application/javascript">
(function($) {
$('.wf-dashboard-ips').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).closest('ul').find('li').removeClass('wf-active');
$(this).closest('li').addClass('wf-active');
$('.wf-ips').addClass('wf-hidden');
$('.wf-ips-' + $(this).data('grouping')).removeClass('wf-hidden');
});
$('.wf-ips .wf-dashboard-show-more a').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var grouping = $(this).parent().data('grouping');
var period = $(this).parent().data('period');
$(this).closest('.wf-dashboard-item-list-text').fadeOut();
var self = this;
WFAD.ajax('wordfence_dashboardShowMore', {
grouping: grouping,
period: period
}, function(res) {
if (res.ok) {
var table = $('#ips-data-template').tmpl(res);
$(self).closest('.wf-ips').css('overflow-y', 'auto');
$(self).closest('.wf-ips').find('table').replaceWith(table);
}
else {
WFAD.colorboxModal('300px', <?php echo json_encode(__('An error occurred', 'wordfence')) ?>, <?php echo json_encode(__('We encountered an error trying load more data.', 'wordfence')) ?>);
$(this).closest('.wf-dashboard-item-list-text').fadeIn();
}
});
});
})(jQuery);
</script>
</div>
</li>
</ul>
<?php endif; ?>
</div>
</div>
</div>
</div>
<script type="text/x-jquery-template" id="ips-data-template">
<table class="wf-table wf-table-hover">
<thead>
<tr>
<th><?php esc_html_e('IP', 'wordfence') ?></th>
<th colspan="2"><?php esc_html_e('Country', 'wordfence') ?></th>
<th><?php esc_html_e('Block Count', 'wordfence') ?></th>
</tr>
</thead>
<tbody>
{{each(idx, d) data}}
<tr>
<td>${d.IP}</td>
<td>${d.countryName}</td>
<td><span class="wf-flag ${d.countryFlag}" title="${d.countryName}"></td>
<td>${d.blockCount}</td>
</tr>
{{/each}}
</tbody>
</table>
</script>

View File

@@ -0,0 +1,78 @@
<?php if (!defined('WORDFENCE_VERSION')) { exit; } ?>
<div class="wf-row">
<div class="wf-col-xs-12">
<div class="wf-dashboard-item active">
<div class="wf-dashboard-item-inner">
<div class="wf-dashboard-item-content">
<div class="wf-dashboard-item-title">
<strong><?php esc_html_e('Firewall Summary:', 'wordfence'); ?> </strong><?php echo esc_html(sprintf(
/* translators: The site's domain name. */
__('Attacks Blocked for %s', 'wordfence'), preg_replace('/^[^:]+:\/\//', '', network_site_url()))); ?>
</div>
<div class="wf-dashboard-item-action"><div class="wf-dashboard-item-action-disclosure"></div></div>
</div>
</div>
<div class="wf-dashboard-item-extra">
<?php if ($firewall->learningModeStatus() !== false): ?>
<div class="wf-widget-learning-mode"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100.11 100.44"><path d="M96.14,30.67a50.7,50.7,0,0,0-10.66-16A50,50,0,0,0,69.51,4,49.57,49.57,0,0,0,30.6,4a50,50,0,0,0-16,10.69A50.69,50.69,0,0,0,4,30.67,50,50,0,0,0,4,69.74a50.62,50.62,0,0,0,10.66,16,50,50,0,0,0,16,10.69,49.54,49.54,0,0,0,38.91,0,50,50,0,0,0,16-10.69,50.56,50.56,0,0,0,10.66-16,50,50,0,0,0,0-39.07Zm-75.74,39a35.77,35.77,0,0,1-1-37.35,35.21,35.21,0,0,1,12.91-13A34.65,34.65,0,0,1,50.06,14.6a34.22,34.22,0,0,1,19.55,5.93ZM82.71,64a35.4,35.4,0,0,1-7.56,11.37A36,36,0,0,1,63.84,83a34.32,34.32,0,0,1-13.79,2.84A34.85,34.85,0,0,1,30.7,80L79.84,31a34.57,34.57,0,0,1,5.67,19.23A35.17,35.17,0,0,1,82.71,64Zm0,0"/></svg><span><?php esc_html_e('No Data Available During Learning Mode', 'wordfence'); ?></span></div>
<?php else: ?>
<ul class="wf-dashboard-item-list">
<li class="wf-flex-vertical wf-flex-full-width">
<?php
$hasSome = false;
foreach ($d->localBlocks as $row) {
if ($row['24h'] > 0 || $row['7d'] > 0 || $row['30d'] > 0) {
$hasSome = true;
break;
}
}
if (!$hasSome):
?>
<div class="wf-dashboard-item-list-text"><p><em><?php esc_html_e('No blocks have been recorded.', 'wordfence'); ?></em></p></div>
<?php else: ?>
<table class="wf-blocks-summary">
<thead>
<tr>
<th><?php echo wp_kses(__('<span class="wf-hidden-xs">Block </span>Type', 'wordfence'), array('span'=>array('class'=>array()))); ?></th>
<?php
$totals = array('24h' => 0, '7d' => 0, '30d' => 0);
foreach ($d->localBlocks as $row): ?>
<th width="25%"<?php if ($row['type'] == wfActivityReport::BLOCK_TYPE_BLACKLIST && !wfConfig::get('isPaid')) { echo ' class="wf-premium"'; } ?>><?php echo esc_html($row['title']); ?></th>
<?php $totals['24h'] += $row['24h']; $totals['7d'] += $row['7d']; $totals['30d'] += $row['30d']; ?>
<?php endforeach; ?>
<th width="25%"><?php esc_html_e('Total', 'wordfence'); ?></th>
</tr>
</thead>
<tbody>
<?php
$keys = array('24h' => __('Today', 'wordfence'), '7d' => __('Week', 'wordfence'), '30d' => __('Month', 'wordfence'));
foreach ($keys as $k => $title): ?>
<tr>
<th><?php echo esc_html($title); ?></th>
<?php foreach ($d->localBlocks as $row): ?>
<td<?php if ($row['type'] == wfActivityReport::BLOCK_TYPE_BLACKLIST && !wfConfig::get('isPaid')) { echo ' class="wf-premium"'; } ?>><?php echo ($row['type'] == wfActivityReport::BLOCK_TYPE_BLACKLIST && !wfConfig::get('isPaid')) ? '&mdash;' : esc_html(number_format_i18n($row[$k])); ?></td>
<?php endforeach; ?>
<td><?php echo esc_html(number_format_i18n($totals[$k])); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<th></th>
<?php foreach ($d->localBlocks as $row): ?>
<td<?php if ($row['type'] == wfActivityReport::BLOCK_TYPE_BLACKLIST && !wfConfig::get('isPaid')) { echo ' class="wf-premium"'; } ?>><?php if ($row['type'] == wfActivityReport::BLOCK_TYPE_BLACKLIST && !wfConfig::get('isPaid')) { esc_html_e('Premium', 'wordfence'); } ?></td>
<?php endforeach; ?>
<td></td>
</tr>
</tfoot>
</table>
<p class="wf-right wf-no-top"><a href="<?php echo wfSupportController::esc_supportURL(wfSupportController::ITEM_WIDGET_LOCAL_ATTACKS); ?>" target="_blank" rel="noopener noreferrer"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i> <?php esc_html_e('How are these categorized?', 'wordfence'); ?><span class="screen-reader-text"> (<?php esc_html_e('opens in new tab', 'wordfence') ?>)</span></a></p>
<?php endif; ?>
</li>
</ul>
<?php endif; ?>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,110 @@
<?php if (!defined('WORDFENCE_VERSION')) { exit; } ?>
<?php //$d is defined here as a wfDashboard instance ?>
<div class="wf-row">
<div class="wf-col-xs-12">
<div class="wf-dashboard-item active">
<div class="wf-dashboard-item-inner">
<div class="wf-dashboard-item-content">
<div class="wf-dashboard-item-title">
<strong><?php esc_html_e('Login Attempts', 'wordfence') ?></strong>
</div>
<div class="wf-dashboard-item-action"><div class="wf-dashboard-item-action-disclosure"></div></div>
</div>
</div>
<div class="wf-dashboard-item-extra">
<ul class="wf-dashboard-item-list">
<li>
<div>
<div class="wf-dashboard-toggle-btns">
<ul class="wf-pagination wf-pagination-sm">
<li class="wf-active"><a href="#" class="wf-dashboard-login-attempts" data-grouping="success" role="button"><?php esc_html_e('Successful', 'wordfence') ?></a></li>
<li><a href="#" class="wf-dashboard-login-attempts" data-grouping="fail" role="button"><?php esc_html_e('Failed', 'wordfence') ?></a></li>
</ul>
</div>
<div class="wf-recent-logins wf-recent-logins-success">
<?php if (count($d->loginsSuccess) == 0): ?>
<div class="wf-dashboard-item-list-text"><p><em><?php esc_html_e('No successful logins have been recorded.', 'wordfence') ?></em></p></div>
<?php else: ?>
<?php $data = array_slice($d->loginsSuccess, 0, min(10, count($d->loginsSuccess)), true); include(dirname(__FILE__) . '/widget_content_logins.php'); ?>
<?php if (count($d->loginsSuccess) > 10): ?>
<div class="wf-dashboard-item-list-text"><div class="wf-dashboard-show-more" data-grouping="logins" data-period="success"><a href="#" role="button"><?php esc_html_e('Show more', 'wordfence') ?></a></div></div>
<?php endif; ?>
<?php endif; ?>
</div>
<div class="wf-recent-logins wf-recent-logins-fail wf-hidden">
<?php if (count($d->loginsFail) == 0): ?>
<div class="wf-dashboard-item-list-text"><p><em><?php esc_html_e('No failed logins have been recorded.', 'wordfence') ?></em></p></div>
<?php else: ?>
<?php $data = array_slice($d->loginsFail, 0, min(10, count($d->loginsFail)), true); include(dirname(__FILE__) . '/widget_content_logins.php'); ?>
<?php if (count($d->loginsFail) > 10): ?>
<div class="wf-dashboard-item-list-text"><div class="wf-dashboard-show-more" data-grouping="logins" data-period="fail"><a href="#" role="button"><?php esc_html_e('Show more', 'wordfence') ?></a></div></div>
<?php endif; ?>
<?php endif; ?>
</div>
<script type="application/javascript">
(function($) {
$('.wf-dashboard-login-attempts').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).closest('ul').find('li').removeClass('wf-active');
$(this).closest('li').addClass('wf-active');
$('.wf-recent-logins').addClass('wf-hidden');
$('.wf-recent-logins-' + $(this).data('grouping')).removeClass('wf-hidden');
});
$('.wf-recent-logins .wf-dashboard-show-more a').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var grouping = $(this).parent().data('grouping');
var period = $(this).parent().data('period');
$(this).closest('.wf-dashboard-item-list-text').fadeOut();
var self = this;
WFAD.ajax('wordfence_dashboardShowMore', {
grouping: grouping,
period: period
}, function(res) {
if (res.ok) {
var table = $('#logins-data-template').tmpl(res);
$(self).closest('.wf-recent-logins').css('overflow-y', 'auto');
$(self).closest('.wf-recent-logins').find('table').replaceWith(table);
}
else {
WFAD.colorboxModal('300px', <?php echo json_encode(__('An error occurred', 'wordfence')) ?>, <?php echo json_encode(__('We encountered an error trying load more data.', 'wordfence')) ?>);
$(this).closest('.wf-dashboard-item-list-text').fadeIn();
}
});
});
})(jQuery);
</script>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
<script type="text/x-jquery-template" id="logins-data-template">
<table class="wf-table wf-table-hover">
<thead>
<tr>
<th><?php esc_html_e('Username', 'wordfence') ?></th>
<th><?php esc_html_e('IP', 'wordfence') ?></th>
<th><?php esc_html_e('Date', 'wordfence') ?></th>
</tr>
</thead>
<tbody>
{{each(idx, d) data}}
<tr>
<td>${d.name}</td>
<td>${d.ip}</td>
<td>${d.t}</td>
</tr>
{{/each}}
</tbody>
</table>
</script>

View File

@@ -0,0 +1,212 @@
<?php if (!defined('WORDFENCE_VERSION')) { exit; } ?>
<div class="wf-row">
<div class="wf-col-xs-12">
<div class="wf-dashboard-item active">
<div class="wf-dashboard-item-inner">
<div class="wf-dashboard-item-content">
<div class="wf-dashboard-item-title">
<strong><?php esc_html_e('Total Attacks Blocked:', 'wordfence'); ?> </strong><?php esc_html_e('Wordfence Network', 'wordfence'); ?>
</div>
<div class="wf-dashboard-item-action"><div class="wf-dashboard-item-action-disclosure"></div></div>
</div>
</div>
<div class="wf-dashboard-item-extra">
<ul class="wf-dashboard-item-list">
<li>
<?php if ($d->networkBlock24h === null): ?>
<div class="wf-dashboard-item-list-text"><p><em><?php esc_html_e('Blocked attack counts not available yet.', 'wordfence'); ?></em></p></div>
<?php else: ?>
<div class="wf-dashboard-graph-wrapper">
<div class="wf-dashboard-toggle-btns">
<ul class="wf-pagination wf-pagination-sm">
<li class="wf-active"><a href="#" class="wf-dashboard-graph-attacks" data-grouping="24h" role="button"><?php esc_html_e('24 Hours', 'wordfence'); ?></a></li>
<li><a href="#" class="wf-dashboard-graph-attacks" data-grouping="30d" role="button"><?php esc_html_e('30 Days', 'wordfence'); ?></a></li>
</ul>
</div>
<div class="wf-dashboard-network-blocks"><canvas id="wf-dashboard-network-blocks-24h"></canvas></div>
<div class="wf-dashboard-network-blocks wf-hidden"><canvas id="wf-dashboard-network-blocks-7d"></canvas></div>
<div class="wf-dashboard-network-blocks wf-hidden"><canvas id="wf-dashboard-network-blocks-30d"></canvas></div>
</div>
<script type="application/javascript">
<?php
$totalAttacksString = json_encode(__("Total Attacks", 'wordfence'));
$styling = <<<STYLING
label: $totalAttacksString,
fill: false,
lineTension: 0.1,
backgroundColor: "rgba(75,192,192,0.4)",
borderColor: "#16bc9b",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "rgba(75,192,192,1)",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "rgba(75,192,192,1)",
pointHoverBorderColor: "rgba(220,220,220,1)",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
spanGaps: false,
STYLING;
?>
(function($) {
$(document).ready(function() {
new Chart($('#wf-dashboard-network-blocks-24h'), {
type: 'line',
data: {
<?php
$blocks = $d->networkBlock24h;
$labels = array();
$values = array();
foreach ($blocks as $b) {
$values[] = $b['c'];
$labels[] = "'" . wfUtils::formatLocalTime('g a', $b['t']) . "'";
}
?>
labels: [<?php echo implode(',', $labels); ?>],
datasets: [
{
<?php echo $styling; ?>
data: [<?php echo implode(',', $values) ?>]
}
]
},
options: {
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value, index, values) {
return value.toLocaleString();
}
}
}
},
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || 'Other';
var label = parseInt(tooltipItem.yLabel).toLocaleString();
return datasetLabel + ': ' + label;
}
}
}
}
});
new Chart($('#wf-dashboard-network-blocks-7d'), {
type: 'line',
data: {
<?php
$blocks = $d->networkBlock7d;
$labels = array();
$values = array();
foreach ($blocks as $b) {
$values[] = $b['c'];
$labels[] = "'" . wfUtils::formatLocalTime('M j', $b['t']) . "'";
}
?>
labels: [<?php echo implode(',', $labels); ?>],
datasets: [
{
<?php echo $styling; ?>
data: [<?php echo implode(',', $values) ?>]
}
]
},
options: {
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value, index, values) {
return value.toLocaleString();
}
}
}
},
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || 'Other';
var label = parseInt(tooltipItem.yLabel).toLocaleString();
return datasetLabel + ': ' + label;
}
}
}
}
});
new Chart($('#wf-dashboard-network-blocks-30d'), {
type: 'line',
data: {
<?php
$blocks = $d->networkBlock30d;
$labels = array();
$values = array();
foreach ($blocks as $b) {
$values[] = $b['c'];
$labels[] = "'" . wfUtils::formatLocalTime('M j', $b['t']) . "'";
}
?>
labels: [<?php echo implode(',', $labels); ?>],
datasets: [
{
<?php echo $styling; ?>
data: [<?php echo implode(',', $values) ?>]
}
]
},
options: {
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value, index, values) {
return value.toLocaleString();
}
}
}
},
tooltips: {
callbacks: {
label: function(tooltipItem, data) {
var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || 'Other';
var label = parseInt(tooltipItem.yLabel).toLocaleString();
return datasetLabel + ': ' + label;
}
}
}
}
});
});
$('.wf-dashboard-graph-attacks').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).closest('ul').find('li').removeClass('wf-active');
$(this).closest('li').addClass('wf-active');
$('.wf-dashboard-network-blocks').addClass('wf-hidden');
$('#wf-dashboard-network-blocks-' + $(this).data('grouping')).closest('.wf-dashboard-network-blocks').removeClass('wf-hidden');
});
})(jQuery);
</script>
<?php endif; ?>
</li>
</ul>
<p class="wf-dashboard-last-updated"><?php echo esc_html(sprintf(
/* translators: Time since. Example: 1 minute, 2 seconds */
__('Last Updated: %s ago', 'wordfence'), wfUtils::makeTimeAgo(time() - $d->lastGenerated))); ?></p>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,138 @@
<?php if (!defined('WORDFENCE_VERSION')) { exit; } ?>
<div class="wf-flex-row wf-flex-row-full-height wf-flex-row-vertical-xs">
<div class="wf-flex-col-xs-100 <?php if (wfCentral::isSupported() && wfConfig::get('showWfCentralUI', false)): ?>wf-flex-col-lg-50 wf-col-lg-half-padding-right wf-dashboard-item-flex-wrapper<?php endif ?>">
<div class="wf-dashboard-item active">
<div class="wf-dashboard-item-inner">
<div class="wf-dashboard-item-content">
<div class="wf-dashboard-item-title">
<strong><?php esc_html_e('Notifications', 'wordfence') ?></strong><span class="wf-dashboard-badge wf-notification-count-container wf-notification-count-value<?php echo (count($d->notifications) == 0 ? ' wf-hidden' : ''); ?>"><?php echo number_format_i18n(count($d->notifications)); ?></span>
</div>
<div class="wf-dashboard-item-action"><div class="wf-dashboard-item-action-disclosure"></div></div>
</div>
</div>
<div class="wf-dashboard-item-extra">
<ul class="wf-dashboard-item-list wf-dashboard-item-list-striped">
<?php foreach ($d->notifications as $n): ?>
<li class="wf-notification<?php if ($n->priority % 10 == 1) { echo ' wf-notification-critical'; } else if ($n->priority % 10 == 2) { echo ' wf-notification-warning'; } ?>" data-notification="<?php echo esc_html($n->id); ?>">
<div class="wf-dashboard-item-list-title"><?php echo $n->html; ?></div>
<?php foreach ($n->links as $l): ?>
<div class="wf-dashboard-item-list-action"><a href="<?php echo esc_html($l['link']); ?>"<?php if (preg_match('/^https?:\/\//i', $l['link'])) { echo ' target="_blank" rel="noopener noreferrer"'; } ?>><?php echo esc_html($l['label']); ?><span class="screen-reader-text"> (<?php esc_html_e('opens in new tab', 'wordfence') ?>)</span></a></div>
<?php endforeach; ?>
<div class="wf-dashboard-item-list-dismiss"><a href="#" class="wf-dismiss-notification" role="button"><i class="wf-fa wf-fa-times-circle" aria-hidden="true"></i></a></div>
</li>
<?php endforeach; ?>
<?php if (count($d->notifications) == 0): ?>
<li class="wf-notifications-empty"><?php esc_html_e('No notifications received', 'wordfence') ?></li>
<?php endif; ?>
</ul>
</div>
</div>
</div>
<?php if (wfCentral::isSupported() && wfConfig::get('showWfCentralUI', false)): ?>
<div class="wf-flex-col-xs-100 wf-flex-col-lg-50 wf-col-lg-half-padding-left wf-dashboard-item-flex-wrapper wf-central-connected">
<div class="wf-dashboard-item active wf-flex-row-1">
<div class="wf-central-dashboard">
<img class="wf-central-dashboard-logo" src="<?php echo wfUtils::getBaseURL() ?>images/wf-central-logo.svg" alt="Wordfence Central">
<div class="wf-central-dashboard-copy">
<p id="wf-central-status"><strong><?php esc_html_e('Wordfence Central Status', 'wordfence') ?></strong></p>
<p><?php
if ($d->wordfenceCentralConnected) {
echo esc_html(sprintf(
/* translators: 1. Email address. 2. Localized date. */
__('Connected by %1$s on %2$s', 'wordfence'), $d->wordfenceCentralConnectEmail, date_i18n(get_option('date_format'), $d->wordfenceCentralConnectTime)));
} elseif ($d->wordfenceCentralDisconnected) {
echo esc_html(sprintf(
/* translators: 1. Email address. 2. Localized date. */
__('Disconnected by %1$s on %2$s', 'wordfence'), $d->wordfenceCentralDisconnectEmail, date_i18n(get_option('date_format'), $d->wordfenceCentralDisconnectTime)));
} elseif (wfCentral::isPartialConnection()) {
_e('It looks like you\'ve tried to connect this site to Wordfence Central, but the installation did not finish.', 'wordfence');
} else {
_e('Wordfence Central allows you to manage Wordfence on multiple sites from one location. It makes security monitoring and configuring Wordfence easier.', 'wordfence');
}
?></p>
<div class="wf-flex-row">
<?php if (wfCentral::isPartialConnection()): ?>
<p>
<a href="<?php echo WORDFENCE_CENTRAL_URL_SEC ?>/sites/connection-issues?complete-setup=<?php echo esc_attr(wfConfig::get('wordfenceCentralSiteID')) ?>"
class="wf-central-resume wf-btn wf-btn-sm wf-btn-primary"
><?php esc_html_e('Resume Installation', 'wordfence') ?></a>
<a href="#" class="wf-central-disconnect wf-btn wf-btn-sm wf-btn-default" role="button"><strong><?php esc_html_e('Disconnect This Site', 'wordfence') ?></strong></a>
</p>
<?php else: ?>
<p class="wf-flex-row-1">
<?php if ($d->wordfenceCentralConnected): ?>
<a href="#" class="wf-central-disconnect" role="button"><strong><?php esc_html_e('Disconnect This Site', 'wordfence') ?></strong></a>
<?php else: ?>
<a href="<?php echo WORDFENCE_CENTRAL_URL_SEC ?>?newsite=<?php echo esc_attr(home_url()) ?>"><strong><?php $d->wordfenceCentralDisconnected ? esc_html_e('Reconnect This Site', 'wordfence') : esc_html_e('Connect This Site', 'wordfence') ?></strong></a>
<?php endif; ?>
</p>
<p class="wf-flex-row-1 wf-right wf-nowrap"><a href="<?php echo esc_url(WORDFENCE_CENTRAL_URL_SEC) ?>" target="_blank" rel="noopener noreferrer"><strong><?php esc_html_e('Visit Wordfence Central', 'wordfence') ?></strong><span class="screen-reader-text"> (<?php esc_html_e('opens in new tab', 'wordfence') ?>)</span></a></p>
<?php endif ?>
</div>
</div>
</div>
</div>
</div>
<?php endif ?>
</div>
<script type="application/javascript">
(function($) {
$('.wf-dismiss-notification').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var n = $(this).closest('.wf-notification');
var id = n.data('notification');
n.fadeOut(400, function() {
n.remove();
var count = $('.wf-dismiss-notification').length;
WFDash.updateNotificationCount(count);
});
WFAD.ajax('wordfence_dismissNotification', {
id: id
}, function(res) {
//Do nothing
});
});
$('.wf-central-disconnect').on('click', function(e) {
e.preventDefault();
var prompt = $('#wfTmpl_wfCentralDisconnectPrompt').tmpl();
var promptHTML = $("<div />").append(prompt).html();
WFAD.colorboxHTML('400px', promptHTML, {
overlayClose: false, closeButton: false, className: 'wf-modal', onComplete: function() {
$('#wf-central-prompt-cancel').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
WFAD.colorboxClose();
});
$('#wf-central-prompt-disconnect').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
WFAD.ajax('wordfence_wfcentral_disconnect', {}, function(response) {
window.location.reload(true);
});
});
}
});
return false;
});
})(jQuery);
</script>
<script type="text/x-jquery-template" id="wfTmpl_wfCentralDisconnectPrompt">
<?php
echo wfView::create('common/modal-prompt', array(
'title' => __('Confirm Disconnect', 'wordfence'),
'message' => __('Are you sure you want to disconnect your site from Wordfence Central?', 'wordfence'),
'primaryButton' => array('id' => 'wf-central-prompt-cancel', 'label' => __('Cancel', 'wordfence'), 'link' => '#'),
'secondaryButtons' => array(array('id' => 'wf-central-prompt-disconnect', 'label' => __('Disconnect', 'wordfence'), 'link' => '#')),
))->render();
?>
</script>