| @@ -1,10 +1,31 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if (!defined('ABSPATH')) die('Access denied.'); |
| 4 | 4 | |
| 5 | -global $current_user, $simba_two_factor_authentication; | |
| 5 | +global $current_user, $simba_two_factor_authentication, $wpdb; | |
| 6 | 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 | +} | |
| 7 | 28 | ?> |
| 8 | 29 | <style> |
| 9 | 30 | #icon-tfa-plugin { |
| 10 | 31 | background: transparent url('<?php print plugin_dir_url(__FILE__); ?>img/tfa_admin_icon_32x32.png' ) no-repeat; |
| @@ -15,35 +36,33 @@ | ||
| 15 | 36 | } |
| 16 | 37 | </style> |
| 17 | 38 | <div class="wrap"> |
| 18 | 39 | |
| 19 | - <h2><?php echo __('Two Factor Authentication', 'two-factor-authentication').' '.__('Settings', 'two-factor-authentication'); ?></h2> | |
| 40 | + <?php screen_icon('tfa-plugin'); ?> | |
| 41 | + <h2><?php echo __('Two Factor Authentication', SIMBA_TFA_TEXT_DOMAIN).' '.__('Settings', SIMBA_TFA_TEXT_DOMAIN); ?></h2> | |
| 20 | 42 | |
| 21 | 43 | <?php |
| 22 | 44 | |
| 23 | - if (!empty($tfa_settings_saved)) { | |
| 24 | - echo '<div class="updated notice is-dismissible">'."<p><strong>".__('Settings saved.', 'two-factor-authentication')."</strong></p></div>"; | |
| 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>"; | |
| 25 | 47 | } |
| 26 | 48 | |
| 27 | - $simba_two_factor_authentication->include_template('settings-intro-notices.php'); | |
| 49 | + $simba_two_factor_authentication->settings_intro_notices(); | |
| 28 | 50 | |
| 29 | 51 | ?> |
| 30 | 52 | |
| 53 | + <!-- New Radios to enable/disable tfa --> | |
| 31 | 54 | <form method="post" action="<?php print esc_url(add_query_arg('settings-updated', 'true', $_SERVER['REQUEST_URI'])); ?>"> |
| 32 | - | |
| 33 | - <?php wp_nonce_field('tfa_activate', '_tfa_activate_nonce', false, true); ?> | |
| 34 | - | |
| 35 | - <h2><?php _e('Activate two factor authentication', 'two-factor-authentication'); ?></h2> | |
| 55 | + <h2><?php _e('Activate two factor authentication', SIMBA_TFA_TEXT_DOMAIN); ?></h2> | |
| 36 | 56 | <p> |
| 37 | 57 | <?php |
| 38 | - $utc_date = gmdate('Y-m-d H:i:s'); | |
| 39 | - $date_now = get_date_from_gmt($utc_date, 'Y-m-d H:i:s'); | |
| 40 | - echo sprintf(__('N.B. Getting your TFA app/device to generate the correct code depends upon a) you first setting it up by entering or scanning the code below into it, and b) upon your web-server and your TFA app/device agreeing upon the UTC time (within a minute or so). The current UTC time according to the server when this page loaded: %s, and in the time-zone you have configured in your WordPress settings: %s', 'two-factor-authentication'), htmlspecialchars($utc_date), htmlspecialchars($date_now)); | |
| 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)); | |
| 41 | 60 | ?> |
| 42 | 61 | </p> |
| 43 | 62 | <p> |
| 44 | 63 | <?php |
| 45 | - $simba_two_factor_authentication->paint_enable_tfa_radios($current_user->ID); | |
| 64 | + $simba_two_factor_authentication->tfaListEnableRadios($current_user->ID); | |
| 46 | 65 | ?></p> |
| 47 | 66 | <?php submit_button(); ?> |
| 48 | 67 | </form> |
| 49 | 68 | <?php |
| @@ -51,9 +70,7 @@ | ||
| 51 | 70 | $simba_two_factor_authentication->current_codes_box(); |
| 52 | 71 | |
| 53 | 72 | $simba_two_factor_authentication->advanced_settings_box(); |
| 54 | 73 | |
| 55 | - do_action('simba_tfa_user_settings_after_advanced_settings'); | |
| 56 | - | |
| 57 | 74 | ?> |
| 58 | 75 | |
| 59 | -</div> | |
| 76 | +</div> | |