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
restrict-admin-page.php
143 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class CloudSecureWP_Admin_Restrict_Admin_Page extends CloudSecureWP_Admin_Common { |
| 8 | private $restrict_admin_page; |
| 9 | |
| 10 | function __construct( array $info, CloudSecureWP_Restrict_Admin_Page $restrict_admin_page ) { |
| 11 | parent::__construct( $info ); |
| 12 | $this->restrict_admin_page = $restrict_admin_page; |
| 13 | $this->prepare_view_data(); |
| 14 | $this->render(); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * 画面表示用のデータを準備 |
| 19 | */ |
| 20 | public function prepare_view_data(): void { |
| 21 | $this->datas = $this->restrict_admin_page->get_settings(); |
| 22 | |
| 23 | if ( ! empty( $_POST ) && check_admin_referer( $this->restrict_admin_page->get_feature_key() . '_csrf' ) ) { |
| 24 | |
| 25 | foreach ( $this->datas as $key => $val ) { |
| 26 | |
| 27 | switch ( $key ) { |
| 28 | case 'restrict_admin_page': |
| 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 'restrict_admin_page_paths': |
| 42 | $tmp = stripslashes( sanitize_textarea_field( $_POST[ $key ] ?? '' ) ); |
| 43 | $this->datas[ $key ] = $this->restrict_admin_page->text2array( $tmp ); |
| 44 | break; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | if ( empty( $this->errors ) ) { |
| 49 | |
| 50 | $old_data = $this->restrict_admin_page->get_settings(); |
| 51 | $this->restrict_admin_page->save_settings( $this->datas ); |
| 52 | |
| 53 | if ( 't' === $this->datas['restrict_admin_page'] ) { |
| 54 | if ( $this->restrict_admin_page->update() ) { |
| 55 | $this->messages[] = '管理画面アクセス制限機能が有効になりました。'; |
| 56 | } else { |
| 57 | $this->errors[] = self::MESSAGES['error_htaccess_update']; |
| 58 | $this->errors[] = '管理画面アクセス制限機能が無効になりました。'; |
| 59 | |
| 60 | $this->datas['restrict_admin_page'] = 'f'; |
| 61 | $this->datas['restrict_admin_page_paths'] = $old_data['restrict_admin_page_paths']; |
| 62 | $this->restrict_admin_page->save_settings( $this->datas ); |
| 63 | } |
| 64 | } elseif ( $this->restrict_admin_page->remove_htaccess() ) { |
| 65 | $this->messages[] = '管理画面アクセス制限機能が無効になりました。'; |
| 66 | } else { |
| 67 | $this->errors[] = self::MESSAGES['error_htaccess_update']; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | if ( is_array( $this->datas['restrict_admin_page_paths'] ) ) { |
| 73 | $this->datas['restrict_admin_page_paths'] = $this->array2text( $this->datas['restrict_admin_page_paths'] ); |
| 74 | } |
| 75 | |
| 76 | $this->datas = $this->get_checked( $this->datas, array( 'restrict_admin_page' ) ); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | /** |
| 81 | * デスクリプション |
| 82 | */ |
| 83 | protected function admin_description(): void { |
| 84 | ?> |
| 85 | <nav> |
| 86 | <ul class="breadcrumb"> |
| 87 | <li class="breadcrumb__list"><a href="?page=cloudsecurewp">ダッシュボード</a></li> |
| 88 | <li class="breadcrumb__list">管理画面アクセス制限</li> |
| 89 | </ul> |
| 90 | </nav> |
| 91 | <div class="title-block mb-12"> |
| 92 | <p class="title-block-small-text">この機能のマニュアルは<a class="title-block-link" target="_blank" href="https://wpplugin.cloudsecure.ne.jp/cloudsecure_wp_security/restrict_admin_page.php">こちら</a></p> |
| 93 | <h1 class="title-block-title">管理画面アクセス制限</h1> |
| 94 | </div> |
| 95 | <div class="title-bottom-text"> |
| 96 | 管理画面にログインしていない接続� |
| 97 | �IPアドレスから管理ページ(/wp-admin/以降)にアクセスすると、404エラー(Not Found)を返します。<br /> |
| 98 | 24時間以上管理画面にログインしていない接続� |
| 99 | �IPアドレスが対象です。<br /> |
| 100 | <strong>※この機能を使用するには「mod_rewrite」がサーバーにロードされている� |
| 101 | 要があります。</strong> |
| 102 | </div> |
| 103 | <?php |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * ページコンテンツ |
| 108 | */ |
| 109 | protected function page(): void { |
| 110 | ?> |
| 111 | <form method="post"> |
| 112 | <div class="enabled-or-disabled"> |
| 113 | <input class="enabled-or-disabled__btn" id="enabled" type="radio" name="restrict_admin_page" value="t" <?php echo esc_html( $this->datas['restrict_admin_page_t'] ?? '' ); ?> /><label for="enabled">有効</label> |
| 114 | <input class="enabled-or-disabled__btn" id="disabled" type="radio" name="restrict_admin_page" value="f" <?php echo esc_html( $this->datas['restrict_admin_page_f'] ?? '' ); ?> /><label for="disabled">無効</label> |
| 115 | </div> |
| 116 | <div class="box"> |
| 117 | <div class="box-bottom"> |
| 118 | <div class="box-row flex-start"> |
| 119 | <div class="box-row-title not-label pt-12"> |
| 120 | 除外パス |
| 121 | </div> |
| 122 | <div class="box-row-content"> |
| 123 | <textarea class="restrict-textarea" name="restrict_admin_page_paths"><?php echo esc_textarea( $this->datas['restrict_admin_page_paths'] ); ?></textarea> |
| 124 | <div class="pale-text"> |
| 125 | この機能を除外したいページがあれば、/wp-admin/以降のパスを� |
| 126 | �力してください。<br /> |
| 127 | 複数のページを登録したい場合、改行して登録してください。 |
| 128 | </div> |
| 129 | </div> |
| 130 | </div> |
| 131 | </div> |
| 132 | </div> |
| 133 | <div style="margin-bottom:10px;"> |
| 134 | </div> |
| 135 | <div id="submit-btn-area"> |
| 136 | <?php $this->nonce_wp( $this->restrict_admin_page->get_feature_key() ); ?> |
| 137 | <?php $this->submit_button_wp(); ?> |
| 138 | </div> |
| 139 | </form> |
| 140 | <?php |
| 141 | } |
| 142 | } |
| 143 |