PluginProbe ʕ •ᴥ•ʔ
CloudSecure WP Security / 1.4.5
CloudSecure WP Security v1.4.5
1.4.10 1.4.9 trunk 0.9.0 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.19 1.3.2 1.3.20 1.3.21 1.3.22 1.3.23 1.3.24 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8
cloudsecure-wp-security / modules / admin / two-factor-authentication.php
cloudsecure-wp-security / modules / admin Last commit date
captcha.php 1 year ago common.php 1 year ago dashboard.php 1 year ago disable-access-system-file.php 7 months ago disable-author-query.php 1 year ago disable-login.php 1 year ago disable-restapi.php 1 year ago disable-xmlrpc.php 1 year ago login-log-table.php 1 year ago login-log.php 1 year ago login-notification.php 1 year ago rename-login-page.php 1 year ago restrict-admin-page.php 1 year ago server-error-notification.php 1 year ago server-error-table.php 1 year ago two-factor-authentication-registration.php 4 months ago two-factor-authentication.php 4 months ago unify-messages.php 1 year ago update-notice.php 1 year ago waf-table.php 1 year ago waf.php 7 months ago
two-factor-authentication.php
134 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 class CloudSecureWP_Admin_Two_Factor_Authentication extends CloudSecureWP_Admin_Common {
8 private $two_factor_authentication;
9
10 function __construct( array $info, CloudSecureWP_Two_Factor_Authentication $two_factor_authentication ) {
11 parent::__construct( $info );
12 $this->two_factor_authentication = $two_factor_authentication;
13 $this->prepare_view_data();
14 $this->render();
15 }
16
17 /**
18 * 画面表示用のデータを準備
19 */
20 public function prepare_view_data(): void {
21 $this->datas = $this->two_factor_authentication->get_settings();
22
23 if ( ! empty( $_POST ) && check_admin_referer( $this->two_factor_authentication->get_feature_key() . '_csrf' ) ) {
24
25 foreach ( $this->datas as $key => $val ) {
26
27 if ( 'two_factor_authentication' === $key ) {
28 $tmp = sanitize_text_field( $_POST[ $key ] ?? '' );
29 if ( ! $this->is_selected( $tmp, self::TF_VALIES ) ) {
30 $this->errors[] = '有効・無効の値が不正です';
31 }
32
33 if ( ! $this->check_environment() ) {
34 $tmp = 'f';
35 }
36
37 $this->datas[ $key ] = $tmp;
38 }
39 }
40
41 if ( empty( $this->errors ) ) {
42
43 $roles = array_map( 'sanitize_text_field', $_POST['roles'] ?? array() );
44 update_option( 'cloudsecurewp_two_factor_authentication_roles', $roles );
45
46 if ( 't' === $this->datas['two_factor_authentication'] ) {
47 $this->messages[] = '2段階認証機能が有効になりました。';
48 } else {
49 $this->messages[] = '2段階認証機能が無効になりました。';
50 }
51
52 $this->two_factor_authentication->save_settings( $this->datas );
53 }
54 }
55
56 $this->datas = $this->get_checked( $this->datas, array( 'two_factor_authentication' ) );
57 }
58
59 /**
60 * ディスクリプション
61 */
62 protected function admin_description(): void {
63 ?>
64 <nav>
65 <ul class="breadcrumb">
66 <li class="breadcrumb__list"><a href="?page=cloudsecurewp">ダッシュボード</a></li>
67 <li class="breadcrumb__list">2段階認証</li>
68 </ul>
69 </nav>
70 <div class="title-block mb-12">
71 <p class="title-block-small-text">この機能のマニュアルは<a class="title-block-link" target="_blank" href="https://wpplugin.cloudsecure.ne.jp/cloudsecure_wp_security/two_factor_authentication.php">こちら</a></p>
72 <h1 class="title-block-title">2段階認証</h1>
73 </div>
74 <div class="title-bottom-text">
75 ユーザー名とパスワードの�
76 �力に加え、別のコードで追加認証を行います。<br />
77 2段階認証機能を利用するには、各ユーザーが自身で認証方法の設定を行う�
78 要があります。<br />
79 <?php if ( 't' === $this->datas['two_factor_authentication'] ) : ?>
80 <b>※認証方法が未設定の場合は、<a href="<?php echo esc_url( admin_url( 'admin.php?page=cloudsecurewp_two_factor_authentication_registration' ) ); ?>">認証方法の設定</a>を行ってください。</b><br />
81 <?php endif; ?>
82 </div>
83 <?php
84 }
85
86 /**
87 * ページコンテンツ
88 */
89 protected function page(): void {
90 $all_roles = array_keys( wp_roles()->roles );
91 $roles = get_option( 'cloudsecurewp_two_factor_authentication_roles', $all_roles );
92 $lastkey = '';
93
94 if ( ! empty( $all_roles ) ) {
95 end( $all_roles );
96 $lastkey = key( $all_roles );
97 reset( $all_roles );
98 }
99
100 ?>
101 <form method="post">
102 <div class="enabled-or-disabled">
103 <input class="enabled-or-disabled__btn" id="enabled" type="radio" name="two_factor_authentication"
104 value="t" <?php echo esc_html( $this->datas['two_factor_authentication_t'] ?? '' ); ?> /><label for="enabled">有効</label>
105 <input class="enabled-or-disabled__btn" id="disabled" type="radio" name="two_factor_authentication"
106 value="f" <?php echo esc_html( $this->datas['two_factor_authentication_f'] ?? '' ); ?> /><label for="disabled">無効</label>
107 </div>
108 <div class="box">
109 <div class="box-bottom">
110 <div class="box-row flex-start">
111 <div class="box-row-title not-label">2段階認証が有効な権限グループ</div>
112 <div class="box-row-content">
113 <?php foreach ( $all_roles as $key => $role ) : ?>
114 <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $role ); ?>" name="roles[]"
115 value="<?php echo esc_attr( $role ); ?>"<?php checked( in_array( $role, $roles ) ); ?> />
116 <label for="<?php echo esc_attr( $role ); ?>"><?php echo esc_html_x( ucfirst( $role ), 'User role' ); ?></label>
117 <br/>
118 <?php endforeach; ?>
119 <p class="description">
120 ユーザーごとの設定状況(未設定/設定済)は <a href="<?php echo esc_url( admin_url( 'users.php' ) ); ?>">ユーザー一覧</a> 画面で確認してください。
121 </p>
122 </div>
123 </div>
124 </div>
125 </div>
126 <div id="submit-btn-area">
127 <?php $this->nonce_wp( $this->two_factor_authentication->get_feature_key() ); ?>
128 <?php $this->submit_button_wp(); ?>
129 </div>
130 </form>
131 <?php
132 }
133 }
134