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 month ago
disable-xmlrpc.php
1 year ago
login-log-table.php
3 months ago
login-log.php
1 year ago
login-notification.php
1 month ago
rename-login-page.php
1 month ago
restrict-admin-page.php
1 month ago
server-error-notification.php
2 months ago
server-error-table.php
1 year ago
two-factor-authentication-registration.php
1 month 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
login-notification.php
153 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class CloudSecureWP_Admin_Login_Notification extends CloudSecureWP_Admin_Common { |
| 8 | private $login_notification; |
| 9 | |
| 10 | function __construct( array $info, CloudSecureWP_Login_Notification $login_notification ) { |
| 11 | parent::__construct( $info ); |
| 12 | $this->login_notification = $login_notification; |
| 13 | $this->prepare_view_data(); |
| 14 | $this->render(); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * 画面表示用のデータを準備 |
| 19 | */ |
| 20 | public function prepare_view_data(): void { |
| 21 | $this->datas = $this->login_notification->get_settings(); |
| 22 | |
| 23 | if ( ! empty( $_POST ) && check_admin_referer( $this->login_notification->get_feature_key() . '_csrf' ) ) { |
| 24 | |
| 25 | foreach ( $this->datas as $key => $val ) { |
| 26 | |
| 27 | switch ( $key ) { |
| 28 | case 'login_notification': |
| 29 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 30 | if ( ! $this->is_selected( $tmp, self::TF_VALIES ) ) { |
| 31 | $this->errors[] = '有効・無効の値が不正です'; |
| 32 | } |
| 33 | |
| 34 | if ( ! $this->check_environment() ) { |
| 35 | $tmp = 'f'; |
| 36 | } |
| 37 | |
| 38 | $this->datas[ $key ] = $tmp; |
| 39 | break; |
| 40 | |
| 41 | case 'login_notification_subject': |
| 42 | $tmp = sanitize_text_field( wp_unslash( $_POST[ $key ] ?? '' ) ); |
| 43 | if ( ! $tmp ) { |
| 44 | $this->errors[] = '件名を� |
| 45 | �力してください'; |
| 46 | } |
| 47 | $this->datas[ $key ] = $tmp; |
| 48 | break; |
| 49 | |
| 50 | case 'login_notification_body': |
| 51 | $tmp = sanitize_textarea_field( wp_unslash( $_POST[ $key ] ?? '' ) ); |
| 52 | if ( ! $tmp ) { |
| 53 | $this->errors[] = '本文を� |
| 54 | �力してください'; |
| 55 | } |
| 56 | $this->datas[ $key ] = $tmp; |
| 57 | break; |
| 58 | |
| 59 | case 'login_notification_admin_only': |
| 60 | $tmp = sanitize_text_field( $_POST[ $key ] ?? 'f' ); |
| 61 | if ( ! $this->is_selected( $tmp, self::TF_VALIES ) ) { |
| 62 | $this->errors[] = '管理� |
| 63 | のみ通知の値が不正です'; |
| 64 | } |
| 65 | $this->datas[ $key ] = $tmp; |
| 66 | break; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | if ( empty( $this->errors ) ) { |
| 71 | if ( 't' === $this->datas['login_notification'] ) { |
| 72 | $this->messages[] = 'ログイン通知機能が有効になりました。'; |
| 73 | } else { |
| 74 | $this->messages[] = 'ログイン通知機能が無効になりました。'; |
| 75 | } |
| 76 | |
| 77 | $this->login_notification->save_settings( $this->datas ); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | $this->datas = $this->get_checked( $this->datas, array( 'login_notification', 'login_notification_admin_only' ) ); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * デスクリプション |
| 86 | */ |
| 87 | protected function admin_description(): void { |
| 88 | ?> |
| 89 | <nav> |
| 90 | <ul class="breadcrumb"> |
| 91 | <li class="breadcrumb__list"><a href="?page=cloudsecurewp">ダッシュボード</a></li> |
| 92 | <li class="breadcrumb__list">ログイン通知</li> |
| 93 | </ul> |
| 94 | </nav> |
| 95 | <div class="title-block mb-12"> |
| 96 | <p class="title-block-small-text">この機能のマニュアルは<a class="title-block-link" target="_blank" href="https://wpplugin.cloudsecure.ne.jp/cloudsecure_wp_security/login_notification.php">こちら</a></p> |
| 97 | <h1 class="title-block-title">ログイン通知</h1> |
| 98 | </div> |
| 99 | <div class="title-bottom-text"> |
| 100 | ログインがあったとき、ユーザーにメールで通知します。 |
| 101 | </div> |
| 102 | <?php |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * ページコンテンツ |
| 107 | */ |
| 108 | protected function page(): void { |
| 109 | ?> |
| 110 | <form method="post"> |
| 111 | <div class="enabled-or-disabled"> |
| 112 | <input class="enabled-or-disabled__btn" id="enabled" type="radio" name="login_notification" value="t" <?php echo esc_html( $this->datas['login_notification_t'] ?? '' ); ?> /><label for="enabled">有効</label> |
| 113 | <input class="enabled-or-disabled__btn" id="disabled" type="radio" name="login_notification" value="f" <?php echo esc_html( $this->datas['login_notification_f'] ?? '' ); ?> /><label for="disabled">無効</label> |
| 114 | </div> |
| 115 | <div class="box"> |
| 116 | <div class="box-bottom"> |
| 117 | <div class="box-row flex-start"> |
| 118 | <div class="box-row-title not-label pt-12"> |
| 119 | サブジェクト |
| 120 | </div> |
| 121 | <div class="box-row-content"> |
| 122 | <input style="width:100%;" type="text" name="login_notification_subject" value="<?php echo esc_attr( sanitize_text_field( $this->datas['login_notification_subject'] ) ); ?>" /> |
| 123 | </div> |
| 124 | </div> |
| 125 | <div class="box-row flex-start"> |
| 126 | <div class="box-row-title not-label pt-12"> |
| 127 | メール本文 |
| 128 | </div> |
| 129 | <div class="box-row-content"> |
| 130 | <textarea class="login-notification-textarea" style="width:100%; height:148px;" name="login_notification_body"><?php echo esc_textarea( $this->datas['login_notification_body'] ); ?></textarea> |
| 131 | </div> |
| 132 | </div> |
| 133 | <div class="box-row flex-start"> |
| 134 | <div class="box-row-title not-label"> |
| 135 | 受信� |
| 136 | |
| 137 | </div> |
| 138 | <div class="box-row-content "> |
| 139 | <input id="receiver-checkbox" class="checkbox" type="checkbox" name="login_notification_admin_only" value="t" <?php echo esc_html( $this->datas['login_notification_admin_only_t'] ?? '' ); ?> /><label for="receiver-checkbox">管理� |
| 140 | のみ通知</label> |
| 141 | </div> |
| 142 | </div> |
| 143 | </div> |
| 144 | </div> |
| 145 | <div id="submit-btn-area"> |
| 146 | <?php $this->nonce_wp( $this->login_notification->get_feature_key() ); ?> |
| 147 | <?php $this->submit_button_wp(); ?> |
| 148 | </div> |
| 149 | </form> |
| 150 | <?php |
| 151 | } |
| 152 | } |
| 153 |