captcha.php
2 years ago
common.php
2 years ago
dashboard.php
2 years ago
disable-author-query.php
2 years ago
disable-login.php
2 years ago
disable-restapi.php
2 years ago
disable-xmlrpc.php
2 years ago
login-log-table.php
2 years ago
login-log.php
2 years ago
login-notification.php
2 years ago
rename-login-page.php
2 years ago
restrict-admin-page.php
2 years ago
server-error-notification.php
2 years ago
server-error-table.php
2 years ago
two-factor-authentication-registration.php
2 years ago
two-factor-authentication.php
2 years ago
unify-messages.php
2 years ago
update-notice.php
2 years ago
disable-login.php
143 lines
| 1 | <?php |
| 2 | |
| 3 | class CloudSecureWP_Admin_Disable_Login extends CloudSecureWP_Admin_Common { |
| 4 | private $disable_login; |
| 5 | private $constant_settings; |
| 6 | |
| 7 | function __construct( array $info, CloudSecureWP_Disable_Login $disable_login ) { |
| 8 | parent::__construct( $info ); |
| 9 | $this->disable_login = $disable_login; |
| 10 | $this->constant_settings = $this->disable_login->get_constant_settings(); |
| 11 | $this->prepare_view_data(); |
| 12 | $this->render(); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * 画面表示用のデータを準備 |
| 17 | */ |
| 18 | public function prepare_view_data(): void { |
| 19 | $this->datas = $this->disable_login->get_settings(); |
| 20 | |
| 21 | if ( ! empty( $_POST ) && check_admin_referer( $this->disable_login->get_feature_key() . '_csrf' ) ) { |
| 22 | |
| 23 | foreach ( $this->datas as $key => $val ) { |
| 24 | |
| 25 | switch ( $key ) { |
| 26 | case 'disable_login': |
| 27 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 28 | if ( ! $this->is_selected( $tmp, self::TF_VALIES ) ) { |
| 29 | $this->errors[] = '有効・無効の値が不正です'; |
| 30 | } |
| 31 | |
| 32 | if ( ! $this->check_environment() ) { |
| 33 | $tmp = 'f'; |
| 34 | } |
| 35 | |
| 36 | $this->datas[ $key ] = $tmp; |
| 37 | break; |
| 38 | |
| 39 | case 'disable_login_interval': |
| 40 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 41 | if ( ! $this->is_selected( $tmp, $this->constant_settings['disable_login_interval'] ) ) { |
| 42 | $this->errors[] = '間隔の値が不正です'; |
| 43 | } |
| 44 | $this->datas[ $key ] = $tmp; |
| 45 | break; |
| 46 | |
| 47 | case 'disable_login_limit': |
| 48 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 49 | if ( ! $this->is_selected( $tmp, $this->constant_settings['disable_login_limit'] ) ) { |
| 50 | $this->errors[] = 'ログイン失敗回数の値が不正です'; |
| 51 | } |
| 52 | $this->datas[ $key ] = $tmp; |
| 53 | break; |
| 54 | |
| 55 | case 'disable_login_duration': |
| 56 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 57 | if ( ! $this->is_selected( $tmp, $this->constant_settings['disable_login_duration'] ) ) { |
| 58 | $this->errors[] = 'ログイン無効時間の値が不正です'; |
| 59 | } |
| 60 | $this->datas[ $key ] = $tmp; |
| 61 | break; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | if ( empty( $this->errors ) ) { |
| 66 | if ( 't' === $this->datas['disable_login'] ) { |
| 67 | $this->messages[] = 'ログイン無効化機能が有効になりました。'; |
| 68 | } else { |
| 69 | $this->messages[] = 'ログイン無効化機能が無効になりました。'; |
| 70 | } |
| 71 | |
| 72 | $this->disable_login->save_settings( $this->datas ); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | $this->datas = $this->get_checked( $this->datas, array( 'disable_login', 'disable_login_interval', 'disable_login_limit', 'disable_login_duration' ) ); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * デスクリプション |
| 81 | */ |
| 82 | protected function admin_description(): void { |
| 83 | ?> |
| 84 | <div class="title-block mb-12"> |
| 85 | <p class="title-block-small-text">この機能のマニュアルは<a class="title-block-link" target="_blank" href="https://wpplugin.cloudsecure.ne.jp/cloudsecure_wp_security/disable_login.php">こちら</a></p> |
| 86 | <h1 class="title-block-title">ログイン無効化</h1> |
| 87 | </div> |
| 88 | <div class="title-bottom-text"> |
| 89 | 指定した期間� |
| 90 | にログイン失敗回数が指定した回数に達した場合、指定した時間ログインを無効化(ブロック)します。 |
| 91 | </div> |
| 92 | <?php |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * ページコンテンツ |
| 97 | */ |
| 98 | protected function page(): void { |
| 99 | ?> |
| 100 | <form method="post"> |
| 101 | <div class="enabled-or-disabled"> |
| 102 | <input class="enabled-or-disabled__btn" id="enabled" type="radio" name="disable_login" value="t" <?php echo esc_html( $this->datas['disable_login_t'] ?? '' ); ?> /><label for="enabled">有効</label> |
| 103 | <input class="enabled-or-disabled__btn" id="disabled" type="radio" name="disable_login" value="f" <?php echo esc_html( $this->datas['disable_login_f'] ?? '' ); ?> /><label for="disabled">無効</label> |
| 104 | </div> |
| 105 | <div class="box"> |
| 106 | <div class="box-bottom"> |
| 107 | <div class="box-row flex-start"> |
| 108 | <div class="box-row-title not-label">間隔</div> |
| 109 | <div class="box-row-content radio-btns"> |
| 110 | <input type="radio" class="circle-radio" id="interval-s" name="disable_login_interval" value="<?php echo esc_attr( $this->constant_settings['disable_login_interval'][0] ); ?>" <?php echo esc_html( $this->datas[ 'disable_login_interval_' . $this->constant_settings['disable_login_interval'][0] ] ?? '' ); ?> /><label for="interval-s"><?php echo esc_html( $this->constant_settings['disable_login_interval'][0] ); ?> 秒</label><br /> |
| 111 | <input type="radio" class="circle-radio" id="interval-m" name="disable_login_interval" value="<?php echo esc_attr( $this->constant_settings['disable_login_interval'][1] ); ?>" <?php echo esc_html( $this->datas[ 'disable_login_interval_' . $this->constant_settings['disable_login_interval'][1] ] ?? '' ); ?> /><label for="interval-m"><?php echo esc_html( $this->constant_settings['disable_login_interval'][1] ); ?> 秒</label><br /> |
| 112 | <input type="radio" class="circle-radio" id="interval-l" name="disable_login_interval" value="<?php echo esc_attr( $this->constant_settings['disable_login_interval'][2] ); ?>" <?php echo esc_html( $this->datas[ 'disable_login_interval_' . $this->constant_settings['disable_login_interval'][2] ] ?? '' ); ?> /><label for="interval-l"><?php echo esc_html( $this->constant_settings['disable_login_interval'][2] ); ?> 秒</label> |
| 113 | </div> |
| 114 | </div> |
| 115 | <div class="box-row flex-start"> |
| 116 | <div class="box-row-title not-label">ログイン失敗回数</div> |
| 117 | <div class="box-row-content radio-btns"> |
| 118 | <input type="radio" id="failure-s" class="circle-radio" name="disable_login_limit" value="<?php echo esc_attr( $this->constant_settings['disable_login_limit'][0] ); ?>" <?php echo esc_html( $this->datas[ 'disable_login_limit_' . $this->constant_settings['disable_login_limit'][0] ] ?? '' ); ?> /><label for="failure-s"><?php echo esc_html( $this->constant_settings['disable_login_limit'][0] ); ?> 回</label><br /> |
| 119 | <input type="radio" id="failure-m" class="circle-radio" name="disable_login_limit" value="<?php echo esc_attr( $this->constant_settings['disable_login_limit'][1] ); ?>" <?php echo esc_html( $this->datas[ 'disable_login_limit_' . $this->constant_settings['disable_login_limit'][1] ] ?? '' ); ?> /><label for="failure-m"><?php echo esc_html( $this->constant_settings['disable_login_limit'][1] ); ?> 回</label><br /> |
| 120 | <input type="radio" id="failure-l" class="circle-radio" name="disable_login_limit" value="<?php echo esc_attr( $this->constant_settings['disable_login_limit'][2] ); ?>" <?php echo esc_html( $this->datas[ 'disable_login_limit_' . $this->constant_settings['disable_login_limit'][2] ] ?? '' ); ?> /><label for="failure-l"><?php echo esc_html( $this->constant_settings['disable_login_limit'][2] ); ?> 回</label> |
| 121 | </div> |
| 122 | </div> |
| 123 | <div class="box-row flex-start"> |
| 124 | <div class="box-row-title not-label">ログイン無効時間</div> |
| 125 | <div class="box-row-content radio-btns"> |
| 126 | <input type="radio" id="invalid-ss" class="circle-radio" name="disable_login_duration" value="<?php echo esc_attr( $this->constant_settings['disable_login_duration'][0] ); ?>" <?php echo esc_html( $this->datas[ 'disable_login_duration_' . $this->constant_settings['disable_login_duration'][0] ] ?? '' ); ?> /><label for="invalid-ss"><?php echo esc_html( $this->constant_settings['disable_login_duration'][0] ); ?> 秒</label><br /> |
| 127 | <input type="radio" id="invalid-s" class="circle-radio" name="disable_login_duration" value="<?php echo esc_attr( $this->constant_settings['disable_login_duration'][1] ); ?>" <?php echo esc_html( $this->datas[ 'disable_login_duration_' . $this->constant_settings['disable_login_duration'][1] ] ?? '' ); ?> /><label for="invalid-s"><?php echo esc_html( $this->constant_settings['disable_login_duration'][1] ); ?> 秒</label><br /> |
| 128 | <input type="radio" id="invalid-m" class="circle-radio" name="disable_login_duration" value="<?php echo esc_attr( $this->constant_settings['disable_login_duration'][2] ); ?>" <?php echo esc_html( $this->datas[ 'disable_login_duration_' . $this->constant_settings['disable_login_duration'][2] ] ?? '' ); ?> /><label for="invalid-m"><?php echo esc_html( $this->constant_settings['disable_login_duration'][2] ); ?> 秒</label><br /> |
| 129 | <input type="radio" id="invalid-l" class="circle-radio" name="disable_login_duration" value="<?php echo esc_attr( $this->constant_settings['disable_login_duration'][3] ); ?>" <?php echo esc_html( $this->datas[ 'disable_login_duration_' . $this->constant_settings['disable_login_duration'][3] ] ?? '' ); ?> /><label for="invalid-l"><?php echo esc_html( $this->constant_settings['disable_login_duration'][3] ); ?> 秒</label><br /> |
| 130 | <input type="radio" id="invalid-ll" class="circle-radio" name="disable_login_duration" value="<?php echo esc_attr( $this->constant_settings['disable_login_duration'][4] ); ?>" <?php echo esc_html( $this->datas[ 'disable_login_duration_' . $this->constant_settings['disable_login_duration'][4] ] ?? '' ); ?> /><label for="invalid-ll"><?php echo esc_html( $this->constant_settings['disable_login_duration'][4] ); ?> 秒</label> |
| 131 | </div> |
| 132 | </div> |
| 133 | </div> |
| 134 | </div> |
| 135 | <div id="submit-btn-area"> |
| 136 | <?php $this->nonce_wp( $this->disable_login->get_feature_key() ); ?> |
| 137 | <?php $this->submit_button_wp(); ?> |
| 138 | </div> |
| 139 | </form> |
| 140 | <?php |
| 141 | } |
| 142 | } |
| 143 |