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
captcha.php
164 lines
| 1 | <?php |
| 2 | |
| 3 | class CloudSecureWP_Admin_CAPTCHA extends CloudSecureWP_Admin_Common { |
| 4 | private $captcha; |
| 5 | private $constant_settings; |
| 6 | |
| 7 | function __construct( array $info, CloudSecureWP_CAPTCHA $captcha ) { |
| 8 | parent::__construct( $info ); |
| 9 | $this->captcha = $captcha; |
| 10 | $this->constant_settings = $this->captcha->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->captcha->get_settings(); |
| 20 | |
| 21 | if ( ! empty( $_POST ) && check_admin_referer( $this->captcha->get_feature_key() . '_csrf' ) ) { |
| 22 | |
| 23 | foreach ( $this->datas as $key => $val ) { |
| 24 | |
| 25 | switch ( $key ) { |
| 26 | case 'captcha': |
| 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 | if ( '$tmp' === $tmp ) { |
| 37 | $environment_error = $this->captcha->check_modules(); |
| 38 | |
| 39 | if ( '' !== $environment_error ) { |
| 40 | $this->errors[] = $environment_error; |
| 41 | $tmp = 'f'; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | $this->datas[ $key ] = $tmp; |
| 46 | break; |
| 47 | |
| 48 | case 'captcha_login': |
| 49 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 50 | if ( ! $this->is_selected( $tmp, $this->constant_settings['captcha_login'] ) ) { |
| 51 | $this->errors[] = 'ログインフォームの値が不正です'; |
| 52 | } |
| 53 | $this->datas[ $key ] = $tmp; |
| 54 | break; |
| 55 | |
| 56 | case 'captcha_comment': |
| 57 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 58 | if ( ! $this->is_selected( $tmp, $this->constant_settings['captcha_comment'] ) ) { |
| 59 | $this->errors[] = 'コメントフォームの値が不正です'; |
| 60 | } |
| 61 | $this->datas[ $key ] = $tmp; |
| 62 | break; |
| 63 | |
| 64 | case 'captcha_lost_password': |
| 65 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 66 | if ( ! $this->is_selected( $tmp, $this->constant_settings['captcha_lost_password'] ) ) { |
| 67 | $this->errors[] = 'パスワードリセットフォームフォームの値が不正です'; |
| 68 | } |
| 69 | $this->datas[ $key ] = $tmp; |
| 70 | break; |
| 71 | |
| 72 | case 'captcha_register': |
| 73 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 74 | if ( ! $this->is_selected( $tmp, $this->constant_settings['captcha_register'] ) ) { |
| 75 | $this->errors[] = 'ユーザー登録フォームフォームの値が不正です'; |
| 76 | } |
| 77 | $this->datas[ $key ] = $tmp; |
| 78 | break; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | if ( empty( $this->errors ) ) { |
| 83 | if ( 't' === $this->datas['captcha'] ) { |
| 84 | $this->messages[] = '画像認証追加機能が有効になりました。'; |
| 85 | } else { |
| 86 | $this->messages[] = '画像認証追加機能が無効になりました。'; |
| 87 | } |
| 88 | |
| 89 | $this->captcha->save_settings( $this->datas ); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | $this->datas = $this->get_checked( $this->datas, array( 'captcha', 'captcha_login', 'captcha_comment', 'captcha_lost_password', 'captcha_register' ) ); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * デスクリプション |
| 98 | */ |
| 99 | protected function admin_description(): void { |
| 100 | ?> |
| 101 | <div class="title-block mb-12"> |
| 102 | <h1 class="title-block-title">画像認証追加</h1> |
| 103 | <p class="title-block-small-text">この機能のマニュアルは<a class="title-block-link" target="_blank" href="https://wpplugin.cloudsecure.ne.jp/cloudsecure_wp_security/captcha.php">こちら</a></p> |
| 104 | </div> |
| 105 | <div class="title-bottom-text"> |
| 106 | 画像データ上にランダムに表示される文字の� |
| 107 | �力を求め、一致しなければ次の画面に進めないようにする機能です。 |
| 108 | </div> |
| 109 | <?php |
| 110 | } |
| 111 | |
| 112 | |
| 113 | |
| 114 | /** |
| 115 | * ページコンテンツ |
| 116 | */ |
| 117 | protected function page(): void { |
| 118 | ?> |
| 119 | <form method="post"> |
| 120 | <div class="enabled-or-disabled"> |
| 121 | <input class="enabled-or-disabled__btn" id="enabled" type="radio" name="captcha" value="t" <?php echo esc_html( $this->datas['captcha_t'] ?? '' ); ?> /><label for="enabled">有効</label> |
| 122 | <input class="enabled-or-disabled__btn" id="disabled" type="radio" name="captcha" value="f" <?php echo esc_html( $this->datas['captcha_f'] ?? '' ); ?> /><label for="disabled">無効</label> |
| 123 | </div> |
| 124 | <div class="box"> |
| 125 | <div class="box-bottom"> |
| 126 | <div class="box-row flex-start"> |
| 127 | <div class="box-row-title not-label">ログインフォーム</div> |
| 128 | <div class="box-row-content radio-btns"> |
| 129 | <input type="radio" class="circle-radio" id="captcha_login-off" name="captcha_login" value="<?php echo esc_attr( $this->constant_settings['captcha_login'][0] ); ?>" <?php echo esc_html( $this->datas[ 'captcha_login_' . $this->constant_settings['captcha_login'][0] ] ?? '' ); ?> /><label for="captcha_login-off"><?php echo esc_html( $this->constant_settings['captcha_login'][0] ); ?> 無効</label><br /> |
| 130 | <input type="radio" class="circle-radio" id="captcha_login-on" name="captcha_login" value="<?php echo esc_attr( $this->constant_settings['captcha_login'][1] ); ?>" <?php echo esc_html( $this->datas[ 'captcha_login_' . $this->constant_settings['captcha_login'][1] ] ?? '' ); ?> /><label for="captcha_login-on"><?php echo esc_html( $this->constant_settings['captcha_login'][1] ); ?> 有効</label> |
| 131 | </div> |
| 132 | </div> |
| 133 | <div class="box-row flex-start"> |
| 134 | <div class="box-row-title not-label">コメントフォーム</div> |
| 135 | <div class="box-row-content radio-btns"> |
| 136 | <input type="radio" id="captcha_comment-off" class="circle-radio" name="captcha_comment" value="<?php echo esc_attr( $this->constant_settings['captcha_comment'][0] ); ?>" <?php echo esc_html( $this->datas[ 'captcha_comment_' . $this->constant_settings['captcha_comment'][0] ] ?? '' ); ?> /><label for="captcha_comment-off"><?php echo esc_html( $this->constant_settings['captcha_comment'][0] ); ?> 無効</label><br /> |
| 137 | <input type="radio" id="captcha_comment-on" class="circle-radio" name="captcha_comment" value="<?php echo esc_attr( $this->constant_settings['captcha_comment'][1] ); ?>" <?php echo esc_html( $this->datas[ 'captcha_comment_' . $this->constant_settings['captcha_comment'][1] ] ?? '' ); ?> /><label for="captcha_comment-on"><?php echo esc_html( $this->constant_settings['captcha_comment'][1] ); ?> 有効</label><br /> |
| 138 | </div> |
| 139 | </div> |
| 140 | <div class="box-row flex-start"> |
| 141 | <div class="box-row-title not-label">パスワードリセットフォーム</div> |
| 142 | <div class="box-row-content radio-btns"> |
| 143 | <input type="radio" id="captcha_lost_password-off" class="circle-radio" name="captcha_lost_password" value="<?php echo esc_attr( $this->constant_settings['captcha_lost_password'][0] ); ?>" <?php echo esc_html( $this->datas[ 'captcha_lost_password_' . $this->constant_settings['captcha_lost_password'][0] ] ?? '' ); ?> /><label for="captcha_lost_password-off"><?php echo esc_html( $this->constant_settings['captcha_lost_password'][0] ); ?> 無効</label><br /> |
| 144 | <input type="radio" id="captcha_lost_password-on" class="circle-radio" name="captcha_lost_password" value="<?php echo esc_attr( $this->constant_settings['captcha_lost_password'][1] ); ?>" <?php echo esc_html( $this->datas[ 'captcha_lost_password_' . $this->constant_settings['captcha_lost_password'][1] ] ?? '' ); ?> /><label for="captcha_lost_password-on"><?php echo esc_html( $this->constant_settings['captcha_lost_password'][1] ); ?> 有効</label> |
| 145 | </div> |
| 146 | </div> |
| 147 | <div class="box-row flex-start"> |
| 148 | <div class="box-row-title not-label">ユーザー登録フォーム</div> |
| 149 | <div class="box-row-content radio-btns"> |
| 150 | <input type="radio" id="captcha_register-off" class="circle-radio" name="captcha_register" value="<?php echo esc_attr( $this->constant_settings['captcha_register'][0] ); ?>" <?php echo esc_html( $this->datas[ 'captcha_register_' . $this->constant_settings['captcha_register'][0] ] ?? '' ); ?> /><label for="captcha_register-off"><?php echo esc_html( $this->constant_settings['captcha_register'][0] ); ?> 無効</label><br /> |
| 151 | <input type="radio" id="captcha_register-on" class="circle-radio" name="captcha_register" value="<?php echo esc_attr( $this->constant_settings['captcha_register'][1] ); ?>" <?php echo esc_html( $this->datas[ 'captcha_register_' . $this->constant_settings['captcha_register'][1] ] ?? '' ); ?> /><label for="captcha_register-on"><?php echo esc_html( $this->constant_settings['captcha_register'][1] ); ?> 有効</label><br /> |
| 152 | </div> |
| 153 | </div> |
| 154 | </div> |
| 155 | </div> |
| 156 | <div id="submit-btn-area"> |
| 157 | <?php $this->nonce_wp( $this->captcha->get_feature_key() ); ?> |
| 158 | <?php $this->submit_button_wp(); ?> |
| 159 | </div> |
| 160 | </form> |
| 161 | <?php |
| 162 | } |
| 163 | } |
| 164 |