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