| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) die('Access denied.'); |
| 4 |
|
| 5 |
global $current_user, $simba_two_factor_authentication, $wpdb; |
| 6 |
|
| 7 |
// if (is_multisite() && (!is_super_admin() || !is_object($wpdb) || !isset($wpdb->blogid) || 1 != $wpdb->blogid)) { |
| 8 |
// die("How did you get here?"); |
| 9 |
// return; |
| 10 |
// } |
| 11 |
|
| 12 |
if(!empty($_POST['tfa_enable_tfa']) && !empty($_GET['settings-updated'])) { |
| 13 |
$tfa->changeEnableTFA($current_user->ID, $_POST['tfa_enable_tfa']); |
| 14 |
$tfa_settings_saved = true; |
| 15 |
} elseif (!empty($_POST['tfa_algorithm_type']) && !empty($_GET['settings-updated'])) { |
| 16 |
$old_algorithm = $tfa->getUserAlgorithm($current_user->ID); |
| 17 |
|
| 18 |
if($old_algorithm != $_POST['tfa_algorithm_type']) { |
| 19 |
$tfa->changeUserAlgorithmTo($current_user->ID, $_POST['tfa_algorithm_type']); |
| 20 |
} |
| 21 |
|
| 22 |
$tfa_settings_saved = true; |
| 23 |
} |
| 24 |
|
| 25 |
if(isset($_GET['warning_button_clicked']) && $_GET['warning_button_clicked'] == 1) { |
| 26 |
delete_user_meta($current_user->ID, 'tfa_hotp_off_sync'); |
| 27 |
} |
| 28 |
?> |
| 29 |
<style> |
| 30 |
#icon-tfa-plugin { |
| 31 |
background: transparent url('<?php print plugin_dir_url(__FILE__); ?>img/tfa_admin_icon_32x32.png' ) no-repeat; |
| 32 |
} |
| 33 |
.inside > h3, .normal { |
| 34 |
cursor: default; |
| 35 |
margin-top: 20px; |
| 36 |
} |
| 37 |
</style> |
| 38 |
<div class="wrap"> |
| 39 |
|
| 40 |
<?php screen_icon('tfa-plugin'); ?> |
| 41 |
<h2><?php echo __('Two Factor Authentication', SIMBA_TFA_TEXT_DOMAIN).' '.__('Settings', SIMBA_TFA_TEXT_DOMAIN); ?></h2> |
| 42 |
|
| 43 |
<?php |
| 44 |
|
| 45 |
if (isset($tfa_settings_saved)) { |
| 46 |
echo '<div class="updated notice is-dismissible">'."<p><strong>".__('Settings saved.', SIMBA_TFA_TEXT_DOMAIN)."</strong></p></div>"; |
| 47 |
} |
| 48 |
|
| 49 |
$simba_two_factor_authentication->settings_intro_notices(); |
| 50 |
|
| 51 |
?> |
| 52 |
|
| 53 |
<!-- New Radios to enable/disable tfa --> |
| 54 |
<form method="post" action="<?php print esc_url(add_query_arg('settings-updated', 'true', $_SERVER['REQUEST_URI'])); ?>"> |
| 55 |
<h2><?php _e('Activate two factor authentication', SIMBA_TFA_TEXT_DOMAIN); ?></h2> |
| 56 |
<p> |
| 57 |
<?php |
| 58 |
$date_now = get_date_from_gmt(gmdate('Y-m-d H:i:s'), 'Y-m-d H:i:s'); |
| 59 |
echo sprintf(__('N.B. Generating two-factor codes depends upon your web-server and your TFA app/device agreeing upon the time. The current UTC time according to the server when this page loaded: %s', SIMBA_TFA_TEXT_DOMAIN), htmlspecialchars($date_now)); |
| 60 |
?> |
| 61 |
</p> |
| 62 |
<p> |
| 63 |
<?php |
| 64 |
$simba_two_factor_authentication->tfaListEnableRadios($current_user->ID); |
| 65 |
?></p> |
| 66 |
<?php submit_button(); ?> |
| 67 |
</form> |
| 68 |
<?php |
| 69 |
|
| 70 |
$simba_two_factor_authentication->current_codes_box(); |
| 71 |
|
| 72 |
$simba_two_factor_authentication->advanced_settings_box(); |
| 73 |
|
| 74 |
?> |
| 75 |
|
| 76 |
</div> |