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 year 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
disable-xmlrpc.php
141 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class CloudSecureWP_Admin_Disable_XMLRPC extends CloudSecureWP_Admin_Common { |
| 8 | private $disable_xmlrpc; |
| 9 | private $constant_settings; |
| 10 | |
| 11 | function __construct( array $info, CloudSecureWP_Disable_XMLRPC $disable_xmlrpc ) { |
| 12 | parent::__construct( $info ); |
| 13 | $this->disable_xmlrpc = $disable_xmlrpc; |
| 14 | $this->constant_settings = $this->disable_xmlrpc->get_constant_settings(); |
| 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_xmlrpc->get_settings(); |
| 24 | |
| 25 | if ( ! empty( $_POST ) && check_admin_referer( $this->disable_xmlrpc->get_feature_key() . '_csrf' ) ) { |
| 26 | |
| 27 | foreach ( $this->datas as $key => $val ) { |
| 28 | |
| 29 | switch ( $key ) { |
| 30 | case 'disable_xmlrpc': |
| 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_xmlrpc_type': |
| 44 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 45 | if ( ! $this->is_selected( $tmp, $this->constant_settings['disable_xmlrpc_type'] ) ) { |
| 46 | $this->errors[] = '無効化種別の値が不正です'; |
| 47 | } |
| 48 | $this->datas[ $key ] = $tmp; |
| 49 | break; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | if ( empty( $this->errors ) ) { |
| 54 | |
| 55 | $this->disable_xmlrpc->save_settings( $this->datas ); |
| 56 | |
| 57 | if ( 't' === $this->datas['disable_xmlrpc'] ) { |
| 58 | if ( $this->datas['disable_xmlrpc_type'] === $this->constant_settings['disable_xmlrpc_type'][0] ) { |
| 59 | if ( $this->disable_xmlrpc->remove_htaccess() ) { |
| 60 | $this->messages[] = 'ピンバック無効化機能が有効になりました。'; |
| 61 | } else { |
| 62 | $this->errors[] = self::MESSAGES['error_htaccess_update']; |
| 63 | $this->errors[] = 'XML-RPC無効化機能が無効になりました。'; |
| 64 | |
| 65 | $this->datas['disable_xmlrpc'] = 'f'; |
| 66 | $this->disable_xmlrpc->save_settings( $this->datas ); |
| 67 | } |
| 68 | } elseif ( $this->datas['disable_xmlrpc_type'] === $this->constant_settings['disable_xmlrpc_type'][1] ) { |
| 69 | |
| 70 | if ( $this->disable_xmlrpc->update_htaccess() ) { |
| 71 | $this->messages[] = 'XML-RPC無効化機能が有効になりました。'; |
| 72 | } else { |
| 73 | $this->errors[] = self::MESSAGES['error_htaccess_update']; |
| 74 | $this->errors[] = 'XML-RPC無効化機能が無効になりました。'; |
| 75 | |
| 76 | $this->datas['disable_xmlrpc'] = 'f'; |
| 77 | $this->disable_xmlrpc->save_settings( $this->datas ); |
| 78 | } |
| 79 | } |
| 80 | } elseif ( $this->disable_xmlrpc->remove_htaccess() ) { |
| 81 | $this->messages[] = 'XML-RPC無効化機能が無効になりました。'; |
| 82 | } else { |
| 83 | $this->errors[] = self::MESSAGES['error_htaccess_update']; |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | $this->datas = $this->get_checked( $this->datas, array( 'disable_xmlrpc', 'disable_xmlrpc_type' ) ); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * デスクリプション |
| 93 | */ |
| 94 | protected function admin_description(): void { |
| 95 | ?> |
| 96 | <nav> |
| 97 | <ul class="breadcrumb"> |
| 98 | <li class="breadcrumb__list"><a href="?page=cloudsecurewp">ダッシュボード</a></li> |
| 99 | <li class="breadcrumb__list">XML-RPC無効化</li> |
| 100 | </ul> |
| 101 | </nav> |
| 102 | <div class="title-block mb-12"> |
| 103 | <p class="title-block-small-text">この機能のマニュアルは<a class="title-block-link" target="_blank" href="https://wpplugin.cloudsecure.ne.jp/cloudsecure_wp_security/disable_xmlrpc.php">こちら</a></p> |
| 104 | <h1 class="title-block-title">XML-RPC無効化</h1> |
| 105 | </div> |
| 106 | <div class="title-bottom-text"> |
| 107 | XML-RPC機能、またはピンバック機能を無効にし、XML-RPC経由での不正ログインを防ぎます。 |
| 108 | </div> |
| 109 | <?php |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * ページコンテンツ |
| 114 | */ |
| 115 | protected function page(): void { |
| 116 | ?> |
| 117 | <form method="post"> |
| 118 | <div class="enabled-or-disabled"> |
| 119 | <input class="enabled-or-disabled__btn" id="enabled" type="radio" name="disable_xmlrpc" value="t" <?php echo esc_html( $this->datas['disable_xmlrpc_t'] ?? '' ); ?> /><label for="enabled">有効</label> |
| 120 | <input class="enabled-or-disabled__btn" id="disabled" type="radio" name="disable_xmlrpc" value="f" <?php echo esc_html( $this->datas['disable_xmlrpc_f'] ?? '' ); ?> /><label for="disabled">無効</label> |
| 121 | </div> |
| 122 | <div class="box"> |
| 123 | <div class="box-bottom"> |
| 124 | <div class="box-row flex-start"> |
| 125 | <div class="box-row-title not-label">無効化種別</div> |
| 126 | <div class="box-row-content radio-btns"> |
| 127 | <input type="radio" class="circle-radio" id="pin-pack" name="disable_xmlrpc_type" value="<?php echo esc_attr( $this->constant_settings['disable_xmlrpc_type'][0] ); ?>" <?php echo esc_html( $this->datas[ 'disable_xmlrpc_type_' . $this->constant_settings['disable_xmlrpc_type'][0] ] ?? '' ); ?> /><label for="pin-pack">ピンバック無効</label><br /> |
| 128 | <input type="radio" class="circle-radio" id="xmlrpc" name="disable_xmlrpc_type" value="<?php echo esc_attr( $this->constant_settings['disable_xmlrpc_type'][1] ); ?>" <?php echo esc_html( $this->datas[ 'disable_xmlrpc_type_' . $this->constant_settings['disable_xmlrpc_type'][1] ] ?? '' ); ?> /><label for="xmlrpc">XML-RPC無効</label> |
| 129 | </div> |
| 130 | </div> |
| 131 | </div> |
| 132 | </div> |
| 133 | <div id="submit-btn-area"> |
| 134 | <?php $this->nonce_wp( $this->disable_xmlrpc->get_feature_key() ); ?> |
| 135 | <?php $this->submit_button_wp(); ?> |
| 136 | </div> |
| 137 | </form> |
| 138 | <?php |
| 139 | } |
| 140 | } |
| 141 |