PluginProbe ʕ •ᴥ•ʔ
CloudSecure WP Security / 1.3.5
CloudSecure WP Security v1.3.5
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 / disable-restapi.php
cloudsecure-wp-security / modules / admin Last commit date
captcha.php 1 year ago common.php 1 year ago dashboard.php 1 year ago disable-access-system-file.php 1 year 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 1 year ago login-log.php 1 year ago login-notification.php 1 year ago rename-login-page.php 1 year ago restrict-admin-page.php 1 year ago server-error-notification.php 1 year ago server-error-table.php 1 year ago two-factor-authentication-registration.php 2 years ago two-factor-authentication.php 1 year ago unify-messages.php 1 year ago update-notice.php 1 year ago waf-table.php 1 year ago waf.php 1 year ago
disable-restapi.php
142 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 class CloudSecureWP_Admin_Disable_RESTAPI extends CloudSecureWP_Admin_Common {
8 private $disable_restapi;
9 private $active_plugin_list = '';
10 private $allowed_html;
11
12 function __construct( array $info, CloudSecureWP_Disable_RESTAPI $disable_restapi ) {
13 parent::__construct( $info );
14 $this->disable_restapi = $disable_restapi;
15 $this->prepare_view_data();
16 $this->render();
17 }
18
19 /**
20 * 画面表示用のデータを準備
21 */
22 public function prepare_view_data(): void {
23 $this->datas = $this->disable_restapi->get_settings();
24
25 if ( ! empty( $_POST ) && check_admin_referer( $this->disable_restapi->get_feature_key() . '_csrf' ) ) {
26
27 foreach ( $this->datas as $key => $val ) {
28
29 switch ( $key ) {
30 case 'disable_rest_api':
31 $tmp = sanitize_text_field( $_POST[ $key ] ?? '' );
32 if ( ! $this->is_selected( $tmp, self::TF_VALIES ) ) {
33 $this->errors[] = '有効・無効の値が不正です';
34 }
35
36 if ( ! $this->check_environment() ) {
37 $tmp = 'f';
38 }
39
40 $this->datas[ $key ] = $tmp;
41 break;
42
43 case 'disable_rest_api_exclude':
44 $tmp = stripslashes( sanitize_textarea_field( $_POST[ $key ] ?? '' ) );
45 $this->datas[ $key ] = $this->disable_restapi->text2array( $tmp );
46 break;
47 }
48 }
49
50 if ( empty( $this->errors ) ) {
51 if ( 't' === $this->datas['disable_rest_api'] ) {
52 $this->messages[] = 'REST API無効化機能が有効になりました。';
53 } else {
54 $this->messages[] = 'REST API無効化機能が無効になりました。';
55 }
56
57 $this->disable_restapi->save_settings( $this->datas );
58 }
59 }
60
61 if ( is_array( $this->datas['disable_rest_api_exclude'] ) ) {
62 $this->datas['disable_rest_api_exclude'] = $this->array2text( $this->datas['disable_rest_api_exclude'] );
63 }
64
65 $this->datas = $this->get_checked( $this->datas, array( 'disable_rest_api' ) );
66 $active_plugins = $this->disable_restapi->get_active_plugin_names();
67
68 foreach ( $active_plugins as $active_plugin ) {
69 $this->active_plugin_list .= '<li><span>' . $active_plugin . '</span>&nbsp;<a class="btn-exclude">[追加]</a></li>' . "\n";
70 }
71
72 $this->allowed_html = array(
73 'li' => array(),
74 'span' => array(),
75 'a' => array(
76 'class' => array(),
77 ),
78 );
79 }
80
81 /**
82 * デスクリプション
83 */
84 protected function admin_description(): void {
85 ?>
86 <nav>
87 <ul class="breadcrumb">
88 <li class="breadcrumb__list"><a href="?page=cloudsecurewp">ダッシュボード</a></li>
89 <li class="breadcrumb__list">REST API無効化</li>
90 </ul>
91 </nav>
92 <div class="title-block mb-12">
93 <p class="title-block-small-text">この機能のマニュアルは<a class="title-block-link" target="_blank" href="https://wpplugin.cloudsecure.ne.jp/cloudsecure_wp_security/disable_restapi.php">こちら</a></p>
94 <h1 class="title-block-title">REST API無効化</h1>
95 </div>
96 <div class="title-bottom-text">
97 REST APIの悪用を防ぐため、機能自体を無効化します。<br />
98 デフォルトでは「oEmbed」「Contact Form 7」「Akismet」を除外プラグインにしています。<br />
99 <strong>※上記プラグインが正常に機能しない可能性があるため。</strong>
100 </div>
101 <?php
102 }
103
104 /**
105 * ページコンテンツ
106 */
107 protected function page(): void {
108 ?>
109 <form method="post">
110 <div class="enabled-or-disabled">
111 <input class="enabled-or-disabled__btn" id="enabled" type="radio" name="disable_rest_api" value="t" <?php echo esc_html( $this->datas['disable_rest_api_t'] ?? '' ); ?> /><label for="enabled">有効</label>
112 <input class="enabled-or-disabled__btn" id="disabled" type="radio" name="disable_rest_api" value="f" <?php echo esc_html( $this->datas['disable_rest_api_f'] ?? '' ); ?> /><label for="disabled">無効</label>
113 </div>
114 <div class="box">
115 <div class="box-top">除外プラグイン</div>
116 <div class="box-bottom pt-0">
117 <div class="remove-plugin-area">
118 <div class="remove-plugin-area-text order-1">除外するプラグインを直接�
119 �力できます。※プラグインごとに改行してください。</div>
120 <div class="remove-plugin-area-text order-3">以下の有効なプラグインの「+」ボタンをクリックすると、除外するプラグインに追加できます。</div>
121 <div class="remove-plugin-area-textarea-wrapper">
122 <textarea class="remove-plugin-area-textarea" id="disable_rest_api_exclude" name="disable_rest_api_exclude"><?php echo esc_textarea( $this->datas['disable_rest_api_exclude'] ); ?></textarea>
123 </div>
124 <div class="remove-plugin-area-like-textarea-wrapper">
125 <div class="remove-plugin-area-like-textarea">
126 <ul id="active-plugins">
127 <?php echo wp_kses( $this->active_plugin_list, $this->allowed_html ); ?>
128 </ul>
129 </div>
130 </div>
131 </div>
132 </div>
133 </div>
134 <div id="submit-btn-area">
135 <?php $this->nonce_wp( $this->disable_restapi->get_feature_key() ); ?>
136 <?php $this->submit_button_wp(); ?>
137 </div>
138 </form>
139 <?php
140 }
141 }
142