PluginProbe ʕ •ᴥ•ʔ
CloudSecure WP Security / 1.4.9
CloudSecure WP Security v1.4.9
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 2 months 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 3 months ago login-log.php 1 year ago login-notification.php 1 year ago rename-login-page.php 1 month ago restrict-admin-page.php 1 year ago server-error-notification.php 2 months ago server-error-table.php 1 year ago two-factor-authentication-registration.php 2 months ago two-factor-authentication.php 2 months ago unify-messages.php 1 year ago update-notice.php 2 months ago waf-table.php 1 year ago waf.php 2 months ago
two-factor-authentication.php
151 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 if ( 'two_factor_authentication_xmlrpc_login' === $key ) {
41 $this->datas[ $key ] = isset( $_POST['two_factor_authentication_xmlrpc_login_deny'] ) ? '1' : '0';
42 }
43 }
44
45 if ( empty( $this->errors ) ) {
46
47 $roles = array_map( 'sanitize_text_field', $_POST['roles'] ?? array() );
48 update_option( 'cloudsecurewp_two_factor_authentication_roles', $roles );
49
50 if ( 't' === $this->datas['two_factor_authentication'] ) {
51 $this->messages[] = '2段階認証機能が有効になりました。';
52 } else {
53 $this->messages[] = '2段階認証機能が無効になりました。';
54 }
55
56 $this->two_factor_authentication->save_settings( $this->datas );
57 }
58 }
59
60 $this->datas = $this->get_checked( $this->datas, array( 'two_factor_authentication' ) );
61 }
62
63 /**
64 * ディスクリプション
65 */
66 protected function admin_description(): void {
67 ?>
68 <nav>
69 <ul class="breadcrumb">
70 <li class="breadcrumb__list"><a href="?page=cloudsecurewp">ダッシュボード</a></li>
71 <li class="breadcrumb__list">2段階認証</li>
72 </ul>
73 </nav>
74 <div class="title-block mb-12">
75 <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>
76 <h1 class="title-block-title">2段階認証</h1>
77 </div>
78 <div class="title-bottom-text">
79 ユーザー名とパスワードの�
80 �力に加え、別のコードで追加認証を行います。<br />
81 2段階認証機能を利用するには、各ユーザーが自身で認証方法の設定を行う�
82 要があります。<br />
83 <?php if ( 't' === $this->datas['two_factor_authentication'] ) : ?>
84 <b>※認証方法が未設定の場合は、<a href="<?php echo esc_url( admin_url( 'admin.php?page=cloudsecurewp_two_factor_authentication_registration' ) ); ?>">認証方法の設定</a>を行ってください。</b><br />
85 <?php endif; ?>
86 </div>
87 <?php
88 }
89
90 /**
91 * ページコンテンツ
92 */
93 protected function page(): void {
94 $all_roles = array_keys( wp_roles()->roles );
95 $roles = get_option( 'cloudsecurewp_two_factor_authentication_roles', $all_roles );
96 $lastkey = '';
97
98 if ( ! empty( $all_roles ) ) {
99 end( $all_roles );
100 $lastkey = key( $all_roles );
101 reset( $all_roles );
102 }
103
104 ?>
105 <form method="post">
106 <div class="enabled-or-disabled">
107 <input class="enabled-or-disabled__btn" id="enabled" type="radio" name="two_factor_authentication"
108 value="t" <?php echo esc_html( $this->datas['two_factor_authentication_t'] ?? '' ); ?> /><label for="enabled">有効</label>
109 <input class="enabled-or-disabled__btn" id="disabled" type="radio" name="two_factor_authentication"
110 value="f" <?php echo esc_html( $this->datas['two_factor_authentication_f'] ?? '' ); ?> /><label for="disabled">無効</label>
111 </div>
112 <div class="box">
113 <div class="box-bottom">
114 <div class="box-row flex-start">
115 <div class="box-row-title not-label">2段階認証が有効な権限グループ</div>
116 <div class="box-row-content">
117 <?php foreach ( $all_roles as $key => $role ) : ?>
118 <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $role ); ?>" name="roles[]"
119 value="<?php echo esc_attr( $role ); ?>"<?php checked( in_array( $role, $roles ) ); ?> />
120 <label for="<?php echo esc_attr( $role ); ?>"><?php echo esc_html_x( ucfirst( $role ), 'User role' ); ?></label>
121 <br/>
122 <?php endforeach; ?>
123 <p class="description">
124 ユーザーごとの設定状況(未設定/設定済)は <a href="<?php echo esc_url( admin_url( 'users.php' ) ); ?>">ユーザー一覧</a> 画面で確認してください。
125 </p>
126 </div>
127 </div>
128 <div class="box-row flex-start">
129 <div class="box-row-title not-label">2段階認証の適用範囲</div>
130 <div class="box-row-content">
131 <input type="checkbox" class="checkbox" id="two_factor_authentication_xmlrpc_login_deny"
132 name="two_factor_authentication_xmlrpc_login_deny"
133 value="1"<?php checked( $this->datas['two_factor_authentication_xmlrpc_login'] === '1' ); ?> />
134 <label for="two_factor_authentication_xmlrpc_login_deny">XML-RPC経由のログインを遮断する</label>
135 <br/>
136 <p class="description">
137 チェックを外すとXML-RPC経由のログインが可能になりますが、2段階認証は適用されません。<a class="title-block-link" target="_blank" href="https://wpplugin.cloudsecure.ne.jp/cloudsecure_wp_security/two_factor_authentication.php#two_factor_authentication-scope">詳細はこちら</a>
138 </p>
139 </div>
140 </div>
141 </div>
142 </div>
143 <div id="submit-btn-area">
144 <?php $this->nonce_wp( $this->two_factor_authentication->get_feature_key() ); ?>
145 <?php $this->submit_button_wp(); ?>
146 </div>
147 </form>
148 <?php
149 }
150 }
151