first commit

This commit is contained in:
Rachit Bhargava
2023-07-21 17:12:10 -04:00
parent d0fe47dde4
commit 5d0f0734d8
14003 changed files with 2829464 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
$assets = isset($assets) ? $assets : array();
$scriptData = isset($scriptData) ? $scriptData : array();
$enabled = \WordfenceLS\Controller_Users::shared()->has_2fa_active($user);
$requires2fa = \WordfenceLS\Controller_Users::shared()->requires_2fa($user, $inGracePeriod, $requiredAt);
$lockedOut = $requires2fa && !$enabled;
$containerClasses = 'wfls-flex-row ' . ($stacked ? 'wfls-flex-row-wrapped' : 'wfls-flex-row-wrappable wfls-flex-row-equal-heights');
$columnClasses = 'wfls-flex-row wfls-flex-item-xs-100 ' . ($stacked ? '' : 'wfls-flex-row-equal-heights');
?>
<?php if (!empty($scriptData)): ?>
<script type="text/javascript">
<?php foreach ($scriptData as $key => $data): ?>
var <?php echo $key ?> = <?php echo wp_json_encode($data); ?>;
<?php endforeach ?>
</script>
<?php endif ?>
<?php foreach ($assets as $asset): ?>
<?php $asset->renderInlineIfNotEnqueued(); ?>
<?php endforeach ?>
<div id="wfls-management-embedded"<?php if ($stacked): ?> class="stacked" <?php endif ?>>
<p><?php echo wp_kses(sprintf(__('Two-Factor Authentication, or 2FA, significantly improves login security for your account. Wordfence 2FA works with a number of TOTP-based apps like Google Authenticator, FreeOTP, and Authy. For a full list of tested TOTP-based apps, <a href="%s" target="_blank" rel="noopener noreferrer">click here</a>.', 'wordfence-2fa'), \WordfenceLS\Controller_Support::esc_supportURL(\WordfenceLS\Controller_Support::ITEM_MODULE_LOGIN_SECURITY_2FA)), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array()))); ?></p>
<div id="wfls-deactivation-controls" class="<?php echo $containerClasses ?>"<?php if (!$enabled) { echo ' style="display: none;"'; } ?>>
<!-- begin status content -->
<div class="<?php echo $columnClasses ?>">
<?php
echo \WordfenceLS\Model_View::create('manage/deactivate', array(
'user' => $user,
))->render();
?>
</div>
<!-- end status content -->
<!-- begin regenerate codes -->
<div class="<?php echo $columnClasses ?>">
<?php
echo \WordfenceLS\Model_View::create('manage/regenerate', array(
'user' => $user,
'remaining' => \WordfenceLS\Controller_Users::shared()->recovery_code_count($user),
))->render();
?>
</div>
<!-- end regenerate codes -->
</div>
<div id="wfls-activation-controls" class="<?php echo $containerClasses ?><?php if (!$stacked): ?> wfls-no-bottom-column-margin<?php endif ?>"<?php if ($enabled) { echo ' style="display: none;"'; } ?>>
<?php
$initializationData = new \WordfenceLS\Model_2faInitializationData($user);
?>
<!-- begin qr code -->
<div class="<?php echo $columnClasses ?><?php if (!$stacked): ?> wfls-col-sm-half-padding-right wfls-flex-item-sm-50<?php endif ?>">
<?php
echo \WordfenceLS\Model_View::create('manage/code', array(
'initializationData' => $initializationData
))->render();
?>
</div>
<!-- end qr code -->
<!-- begin activation -->
<div class="<?php echo $columnClasses ?><?php if (!$stacked): ?> wfls-col-sm-half-padding-left wfls-flex-item-sm-50<?php endif ?>">
<?php
echo \WordfenceLS\Model_View::create('manage/activate', array(
'initializationData' => $initializationData
))->render();
?>
</div>
<!-- end activation -->
</div>
<div id="wfls-grace-period-controls" class="<?php echo $containerClasses ?>"<?php if ($enabled || !($lockedOut || $inGracePeriod)) { echo ' style="display: none;"'; } ?>>
<div class="<?php echo $columnClasses ?> wfls-add-top">
<?php
echo \WordfenceLS\Model_View::create('manage/grace-period', array(
'user' => $user,
'lockedOut' => $lockedOut,
'gracePeriod' => $inGracePeriod,
'requiredAt' => $requiredAt
))->render();
?>
</div>
</div>
<?php
/**
* Fires after the main content of the activation page has been output.
*/
do_action('wfls_activation_page_footer');
?>
</div>

View File

@@ -0,0 +1,119 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* @var \WP_User $user The user being edited. Required.
* @var bool $canEditUsers Whether or not the viewer of the page can edit other users. Optional, defaults to false.
*/
if (!isset($canEditUsers)) {
$canEditUsers = false;
}
$ownAccount = false;
$ownUser = wp_get_current_user();
if ($ownUser->ID == $user->ID) {
$ownAccount = true;
}
$enabled = \WordfenceLS\Controller_Users::shared()->has_2fa_active($user);
$requires2fa = \WordfenceLS\Controller_Users::shared()->requires_2fa($user, $inGracePeriod, $requiredAt);
$lockedOut = $requires2fa && !$enabled;
?>
<p><?php echo wp_kses(sprintf(__('Two-Factor Authentication, or 2FA, significantly improves login security for your website. Wordfence 2FA works with a number of TOTP-based apps like Google Authenticator, FreeOTP, and Authy. For a full list of tested TOTP-based apps, <a href="%s" target="_blank" rel="noopener noreferrer">click here</a>.', 'wordfence-2fa'), \WordfenceLS\Controller_Support::esc_supportURL(\WordfenceLS\Controller_Support::ITEM_MODULE_LOGIN_SECURITY_2FA)), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array()))); ?></p>
<?php if ($canEditUsers): ?>
<div id="wfls-editing-display" class="wfls-flex-row wfls-flex-row-xs-wrappable wfls-flex-row-equal-heights">
<div class="wfls-block wfls-always-active wfls-flex-item-full-width wfls-add-bottom">
<div class="wfls-block-header wfls-block-header-border-bottom">
<div class="wfls-block-header-content">
<div class="wfls-block-title">
<strong><?php echo wp_kses(sprintf(__('Editing User:&nbsp;&nbsp;%s <span class="wfls-text-plain">%s</span>', 'wordfence-2fa'), get_avatar($user->ID, 16, '', $user->user_login), \WordfenceLS\Text\Model_HTML::esc_html($user->user_login) . ($ownAccount ? ' ' . __('(you)', 'wordfence-2fa') : '')), array('span'=>array('class'=>array()))); ?></strong>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
<div id="wfls-deactivation-controls" class="wfls-flex-row wfls-flex-row-wrappable wfls-flex-row-equal-heights"<?php if (!$enabled) { echo ' style="display: none;"'; } ?>>
<!-- begin status content -->
<div class="wfls-flex-row wfls-flex-row-equal-heights wfls-flex-item-xs-100">
<?php
echo \WordfenceLS\Model_View::create('manage/deactivate', array(
'user' => $user,
))->render();
?>
</div>
<!-- end status content -->
<!-- begin regenerate codes -->
<div class="wfls-flex-row wfls-flex-row-equal-heights wfls-flex-item-xs-100">
<?php
echo \WordfenceLS\Model_View::create('manage/regenerate', array(
'user' => $user,
'remaining' => \WordfenceLS\Controller_Users::shared()->recovery_code_count($user),
))->render();
?>
</div>
<!-- end regenerate codes -->
</div>
<div id="wfls-activation-controls" class="wfls-flex-row wfls-flex-row-xs-wrappable wfls-flex-row-equal-heights"<?php if ($enabled) { echo ' style="display: none;"'; } ?>>
<?php
$initializationData = new \WordfenceLS\Model_2faInitializationData($user);
?>
<!-- begin qr code -->
<div class="wfls-flex-row wfls-flex-row-equal-heights wfls-col-sm-half-padding-right wfls-flex-item-xs-100 wfls-flex-item-sm-50">
<?php
echo \WordfenceLS\Model_View::create('manage/code', array(
'initializationData' => $initializationData
))->render();
?>
</div>
<!-- end qr code -->
<!-- begin activation -->
<div class="wfls-flex-row wfls-flex-row-equal-heights wfls-col-sm-half-padding-left wfls-flex-item-xs-100 wfls-flex-item-sm-50">
<?php
echo \WordfenceLS\Model_View::create('manage/activate', array(
'initializationData' => $initializationData
))->render();
?>
</div>
<!-- end activation -->
</div>
<div id="wfls-grace-period-controls" class="wfls-flex-row wfls-flex-row-xs-wrappable wfls-flex-row-equal-heights"<?php if ($enabled || !($lockedOut || $inGracePeriod)) { echo ' style="display: none;"'; } ?>>
<div class="wfls-flex-row wfls-flex-row-equal-heights wfls-flex-item-xs-100 wfls-add-top">
<?php
echo \WordfenceLS\Model_View::create('manage/grace-period', array(
'user' => $user,
'lockedOut' => $lockedOut,
'gracePeriod' => $inGracePeriod,
'requiredAt' => $requiredAt
))->render();
?>
</div>
</div>
<?php
/**
* Fires after the main content of the activation page has been output.
*/
do_action('wfls_activation_page_footer');
$time = time();
$correctedTime = \WordfenceLS\Controller_Time::time($time);
$tz = get_option('timezone_string');
if (empty($tz)) {
$offset = get_option('gmt_offset');
$tz = 'UTC' . ($offset >= 0 ? '+' . $offset : $offset);
}
?>
<?php if (\WordfenceLS\Controller_Permissions::shared()->can_manage_settings()): ?>
<p><?php esc_html_e('Server Time:', 'wordfence-2fa'); ?> <?php echo date('Y-m-d H:i:s', $time); ?> UTC (<?php echo \WordfenceLS\Controller_Time::format_local_time('Y-m-d H:i:s', $time) . ' ' . $tz; ?>)<br>
<?php esc_html_e('Browser Time:', 'wordfence-2fa'); ?> <script type="application/javascript">var date = new Date(); document.write(date.toUTCString() + ' (' + date.toString() + ')');</script><br>
<?php
if (\WordfenceLS\Controller_Settings::shared()->is_ntp_enabled()) {
echo esc_html__('Corrected Time (NTP):', 'wordfence-2fa') . ' ' . date('Y-m-d H:i:s', $correctedTime) . ' UTC (' . \WordfenceLS\Controller_Time::format_local_time('Y-m-d H:i:s', $correctedTime) . ' ' . $tz . ')<br>';
}
else if (WORDFENCE_LS_FROM_CORE && $correctedTime != $time) {
echo esc_html__('Corrected Time (WF):', 'wordfence-2fa') . ' ' . date('Y-m-d H:i:s', $correctedTime) . ' UTC (' . \WordfenceLS\Controller_Time::format_local_time('Y-m-d H:i:s', $correctedTime) . ' ' . $tz . ')<br>';
}
?>
<?php esc_html_e('Detected IP:', 'wordfence-2fa'); ?> <?php echo \WordfenceLS\Text\Model_HTML::esc_html(\WordfenceLS\Model_Request::current()->ip()); if (\WordfenceLS\Controller_Whitelist::shared()->is_whitelisted(\WordfenceLS\Model_Request::current()->ip())) { echo ' (' . esc_html__('allowlisted', 'wordfence-2fa') . ')'; } ?></p>
<?php endif; ?>

View File

@@ -0,0 +1,37 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* @var array $sections The content tabs, each element is an array of the syntax array('tab' => Model_Tab instance, 'title' => Title instance, 'content' => HTML content). Required.
*/
?>
<?php do_action('wfls_activation_page_header'); ?>
<div class="wrap wordfence-ls">
<?php
if (\WordfenceLS\Controller_Permissions::shared()->can_manage_settings() && !\WordfenceLS\Controller_Settings::shared()->get_bool(\WordfenceLS\Controller_Settings::OPTION_DISMISSED_FRESH_INSTALL_MODAL) && !WORDFENCE_LS_FROM_CORE) {
echo \WordfenceLS\Model_View::create('onboarding/standalone-header')->render();
}
?>
<div class="wfls-container-fluid">
<?php
$tabs = array_map(function($t) { return $t['tab']; }, $sections);
echo \WordfenceLS\Model_View::create('page/tabbar', array(
'tabs' => $tabs,
))->render();
?>
<div class="wfls-row">
<div class="wfls-col-xs-12">
<?php foreach ($sections as $s): ?>
<div id="<?php echo esc_attr($s['tab']->id); ?>" class="wfls-tab-content" data-title="<?php echo esc_attr($s['tab']->pageTitle); ?>">
<?php
echo \WordfenceLS\Model_View::create('page/section-title', array(
'title' => $s['title'],
))->render();
echo $s['content'];
?>
</div> <!-- end <?php echo \WordfenceLS\Text\Model_HTML::esc_html($s['tab']->id); ?> block -->
<?php endforeach; ?>
</div> <!-- end content block -->
</div> <!-- end row -->
</div> <!-- end container -->
</div>

View File

@@ -0,0 +1,8 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
?>
<div>
<h2><?php esc_html_e('Permission Denied', 'wordfence-2fa') ?></h2>
<p><?php esc_html_e('You do not have permission to manage 2FA settings for your account.', 'wordfence-2fa') ?></p>
</div>

View File

@@ -0,0 +1,55 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
?>
<?php if (is_multisite()): ?>
<p><em>(<?php esc_html_e('This page only shows users and roles on the main site of this network', 'wordfence-2fa') ?>)</em></p>
<?php endif ?>
<div class="wfls-block wfls-always-active wfls-flex-item-full-width wfls-add-bottom">
<?php if ($requiredAt === false): ?>
<div class="wfls-block-content">
<p><?php echo esc_html(sprintf(__('2FA is not required for the %s role', 'wordfence-2fa'), $roleTitle)) ?></p>
</div>
<?php elseif (empty($users)): ?>
<div class="wfls-block-content">
<p>
<?php if ($page == 1): ?>
<?php echo esc_html(sprintf(__('No users found in the %s state for the %s role', 'wordfence-2fa'), $stateTitle, $roleTitle)) ?>
<?php else: ?>
<?php echo esc_html(sprintf(__('Page %d is out of range', 'wordfence-2fa'), $page)) ?>
<?php endif ?>
</p>
</div>
<?php else: ?>
<table class="wfls-table wfls-table-striped wfls-table-header-separators wfls-table-expanded wfls-no-bottom">
<tr>
<th>User</th>
<th>Required Date</th>
</tr>
<?php foreach ($users as $user): ?>
<tr>
<th scope="row"><a href="<?php echo esc_attr(get_edit_user_link($user->user_id)) ?>#wfls-user-settings"><?php echo esc_html($user->user_login) ?></a></td>
<td>
<?php if ($user->required_at): ?>
<?php echo esc_html(\WordfenceLS\Controller_Time::format_local_time('F j, Y g:i A', $user->required_at)) ?>
<?php else: ?>
<?php esc_html_e('N/A', 'wordfence-2fa'); ?>
<?php endif ?>
</td>
</tr>
<?php endforeach ?>
<?php if ($page != 1 || !$lastPage): ?>
<tr>
<td colspan="2" class="wfls-center">
<?php if ($page > 1): ?>
<a href="<?php echo esc_attr(add_query_arg($pageKey, $page-1) . "#$stateKey") ?>"><span class="dashicons dashicons-arrow-left-alt2"></span></a>
<?php endif ?>
<strong class="wfls-page-indicator"><?php esc_html_e('Page ', 'wordfence-2fa') ?><?php echo (int) $page ?></strong>
<?php if (!$lastPage): ?>
<a href="<?php echo esc_attr(add_query_arg($pageKey, $page+1) . "#$stateKey") ?>"><span class="dashicons dashicons-arrow-right-alt2"></span></a>
<?php endif ?>
</td>
</tr>
<?php endif ?>
</table>
<?php endif ?>
</div>

View File

@@ -0,0 +1,16 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* @var \WordfenceLS\Page\Model_Title $title The page title parameters.
* @var bool $showIcon Whether or not to show the header icon. Optional, defaults to false.
*/
?>
<div class="wfls-section-title">
<?php if (isset($showIcon) && $showIcon): ?>
<div class="wfls-header-icon wfls-hidden-xs"></div>
<?php endif; ?>
<h2 class="wfls-center-xs" id="section-title-<?php echo esc_attr($title->id); ?>"><?php echo \WordfenceLS\Text\Model_HTML::esc_html($title->title); ?></h2>
<?php if ($title->helpURL !== null && $title->helpLink !== null): ?>
<span class="wfls-hidden-xs"><a href="<?php echo esc_url($title->helpURL); ?>" target="_blank" rel="noopener noreferrer" class="wfls-help-link"><?php echo \WordfenceLS\Text\Model_HTML::esc_html($title->helpLink); ?> <i class="<?php echo (\WordfenceLS\Controller_WordfenceLS::shared()->should_use_core_font_awesome_styles() ? 'wf-fa wf-fa-external-link' : 'wfls-fa wfls-fa-external-link'); ?>" aria-hidden="true"></i></a></span>
<?php endif; ?>
</div>

View File

@@ -0,0 +1,26 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
?>
<div class="wfls-save-banner wfls-nowrap wfls-padding-add-right-responsive">
<a href="#" id="wfls-cancel-changes" class="wfls-btn wfls-btn-sm wfls-btn-default wfls-disabled"><?php echo wp_kses(__('Cancel<span class="wfls-visible-sm-inline"> Changes</span>', 'wordfence-2fa'), array('span'=>array('class'=>array()))); ?></a>&nbsp;&nbsp;<a href="#" id="wfls-save-changes" class="wfls-btn wfls-btn-sm wfls-btn-primary wfls-disabled"><?php echo wp_kses(__('Save<span class="wfls-visible-sm-inline"> Changes</span>', 'wordfence-2fa'), array('span'=>array('class'=>array()))); ?></a>
</div>
<div id="wfls-settings" class="wfls-flex-row wfls-flex-row-wrappable wfls-flex-row-equal-heights">
<!-- begin status content -->
<div id="wfls-user-stats" class="wfls-flex-row wfls-flex-row-equal-heights wfls-flex-item-xs-100">
<?php
echo \WordfenceLS\Model_View::create('settings/user-stats', array(
'counts' => \WordfenceLS\Controller_Users::shared()->get_detailed_user_counts_if_enabled(),
))->render();
?>
</div>
<!-- end status content -->
<!-- begin options content -->
<div id="wfls-options">
<?php
echo \WordfenceLS\Model_View::create('settings/options', array(
'hasWoocommerce' => $hasWoocommerce
))->render();
?>
</div>
<!-- end options content -->
</div>

View File

@@ -0,0 +1,23 @@
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
/**
* @var array $tabs An array of Tab instances. Required.
*/
?>
<div class="wfls-row wfls-tab-container">
<div class="wfls-col-xs-12">
<div class="wp-header-end"></div>
<ul class="wfls-page-tabs">
<li class="wfls-header-icon"></li>
<?php foreach ($tabs as $t): ?>
<?php
$a = $t->a;
if (!preg_match('/^https?:\/\//i', $a)) {
$a = '#top#' . urlencode($a);
}
?>
<li class="wfls-tab" id="wfls-tab-<?php echo esc_attr($t->id); ?>" data-target="<?php echo esc_attr($t->id); ?>" data-page-title="<?php echo esc_attr($t->pageTitle); ?>"><a href="<?php echo esc_url($a); ?>"><?php echo esc_html($t->tabTitle); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
</div>