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
rename-login-page.php
178 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class CloudSecureWP_Admin_Rename_Login_Page extends CloudSecureWP_Admin_Common { |
| 8 | private $rename_login_page; |
| 9 | private $page_url; |
| 10 | |
| 11 | function __construct( array $info, CloudSecureWP_Rename_Login_Page $rename_login_page ) { |
| 12 | parent::__construct( $info ); |
| 13 | $this->rename_login_page = $rename_login_page; |
| 14 | $this->page_url = admin_url( 'admin.php?page=cloudsecurewp_rename_login_page' ); |
| 15 | $this->prepare_view_data(); |
| 16 | $this->render(); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * 画面表示用のデータを準備 |
| 21 | */ |
| 22 | public function prepare_view_data(): void { |
| 23 | $this->datas = $this->rename_login_page->get_settings(); |
| 24 | |
| 25 | $is_renamed = sanitize_text_field( $_GET['renamed'] ?? '' ); |
| 26 | if ( 't' === $is_renamed ) { |
| 27 | $this->messages[] = 'ログインURL変更機能が有効になりました。'; |
| 28 | $this->important_messages[] = '<a href="' . esc_url( site_url() . '/' . $this->datas['rename_login_page_name'] ) . '" target="__blank">新しいログインページURL</a>をブックマークしてください'; |
| 29 | |
| 30 | } elseif ( 'f' === $is_renamed ) { |
| 31 | $this->messages[] = 'ログインURL変更機能が無効になりました。'; |
| 32 | } |
| 33 | |
| 34 | if ( ! empty( $_POST ) && check_admin_referer( $this->rename_login_page->get_feature_key() . '_csrf' ) ) { |
| 35 | |
| 36 | foreach ( $this->datas as $key => $val ) { |
| 37 | |
| 38 | switch ( $key ) { |
| 39 | case 'rename_login_page': |
| 40 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 41 | if ( ! $this->is_selected( $tmp, self::TF_VALIES ) ) { |
| 42 | $this->errors[] = '有効・無効の値が不正です'; |
| 43 | } |
| 44 | |
| 45 | if ( ! $this->check_environment() ) { |
| 46 | $tmp = 'f'; |
| 47 | } |
| 48 | |
| 49 | $this->datas[ $key ] = $tmp; |
| 50 | break; |
| 51 | |
| 52 | case 'rename_login_page_name': |
| 53 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 54 | if ( ! $tmp || ! preg_match( '/^[a-z0-9_\-]{4,12}$/', $tmp ) ) { |
| 55 | $this->errors[] = 'ログインページ名の値が不正です<br />( 半角英小文字、半角数字、ハイフン、アンダースコアが使用可能で4文字以上12文字以下で� |
| 56 | �力してください )'; |
| 57 | } elseif ( $this->rename_login_page->is_duplicat_file( $tmp ) ) { |
| 58 | $this->errors[] = 'ログインページ名の値が不正です<br />( 既に存在する名称です )'; |
| 59 | } |
| 60 | $this->datas[ $key ] = $tmp; |
| 61 | break; |
| 62 | |
| 63 | case 'rename_login_page_disable_redirect': |
| 64 | $tmp = sanitize_text_field( $_POST[ $key ] ?? 'f' ); |
| 65 | if ( ! $this->is_selected( $tmp, self::TF_VALIES ) ) { |
| 66 | $this->errors[] = 'リダイレクト設定の値が不正です'; |
| 67 | } |
| 68 | $this->datas[ $key ] = $tmp; |
| 69 | break; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | if ( empty( $this->errors ) ) { |
| 74 | |
| 75 | $old_data = $this->rename_login_page->get_settings(); |
| 76 | $this->rename_login_page->save_settings( $this->datas ); |
| 77 | $logout_url = $this->page_url . '&renamed='; |
| 78 | |
| 79 | if ( 't' === $this->datas['rename_login_page'] ) { |
| 80 | if ( $this->rename_login_page->update_htaccess() ) { |
| 81 | $this->messages[] = 'ログインURL変更機能が有効になりました。'; |
| 82 | |
| 83 | if ( $old_data['rename_login_page'] !== $this->datas['rename_login_page'] || $old_data['rename_login_page_name'] !== $this->datas['rename_login_page_name'] ) { |
| 84 | $this->rename_login_page->notification( $this->datas['rename_login_page_name'] ); |
| 85 | $logout_url .= 't'; |
| 86 | wp_redirect( $logout_url ); |
| 87 | exit; |
| 88 | } |
| 89 | } else { |
| 90 | $this->errors[] = self::MESSAGES['error_htaccess_update']; |
| 91 | $this->errors[] = 'ログインURL変更機能が無効になりました。'; |
| 92 | |
| 93 | $this->datas['rename_login_page'] = 'f'; |
| 94 | $this->datas['rename_login_page_name'] = $old_data['rename_login_page_name']; |
| 95 | $this->rename_login_page->save_settings( $this->datas ); |
| 96 | } |
| 97 | } elseif ( $this->rename_login_page->remove_htaccess() ) { |
| 98 | $logout_url .= 'f'; |
| 99 | wp_redirect( $logout_url ); |
| 100 | exit; |
| 101 | |
| 102 | } else { |
| 103 | $this->errors[] = self::MESSAGES['error_htaccess_update']; |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | $this->datas = $this->get_checked( $this->datas, array( 'rename_login_page', 'rename_login_page_disable_redirect' ) ); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * デスクリプション |
| 113 | */ |
| 114 | protected function admin_description(): void { |
| 115 | ?> |
| 116 | <nav> |
| 117 | <ul class="breadcrumb"> |
| 118 | <li class="breadcrumb__list"><a href="?page=cloudsecurewp">ダッシュボード</a></li> |
| 119 | <li class="breadcrumb__list">ログインURL変更</li> |
| 120 | </ul> |
| 121 | </nav> |
| 122 | <div class="title-block mb-12"> |
| 123 | <p class="title-block-small-text">この機能のマニュアルは<a class="title-block-link" target="_blank" href="https://wpplugin.cloudsecure.ne.jp/cloudsecure_wp_security/rename_login_page.php">こちら</a></p> |
| 124 | <h1 class="title-block-title">ログインURL変更</h1> |
| 125 | </div> |
| 126 | <div class="title-bottom-text"> |
| 127 | ログインURL(wp-login.php)を変更します。<br /> |
| 128 | 半角英小文字、半角数字、ハイフン、アンダースコアのいずれかを使用し、4文字以上12文字以下でお好みの名前(文字列)に設定できます。<br /> |
| 129 | <strong>※この機能を使用するには「mod_rewrite」がサーバーにロードされている� |
| 130 | 要があります。</strong> |
| 131 | </div> |
| 132 | <?php |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * ページコンテンツ |
| 137 | */ |
| 138 | protected function page(): void { |
| 139 | ?> |
| 140 | <form method="post" action="<?php echo esc_url( $this->page_url ); ?>"> |
| 141 | <div class="enabled-or-disabled"> |
| 142 | <input class="enabled-or-disabled__btn" id="enabled" type="radio" name="rename_login_page" value="t" <?php echo esc_html( $this->datas['rename_login_page_t'] ?? '' ); ?> /><label for="enabled">有効</label> |
| 143 | <input class="enabled-or-disabled__btn" id="disabled" type="radio" name="rename_login_page" value="f" <?php echo esc_html( $this->datas['rename_login_page_f'] ?? '' ); ?> /><label for="disabled">無効</label> |
| 144 | </div> |
| 145 | <div class="box"> |
| 146 | <div class="box-bottom"> |
| 147 | <div class="box-row flex-start"> |
| 148 | <div class="box-row-title not-label pt-12"> |
| 149 | 変更後のログインURL |
| 150 | </div> |
| 151 | <div class="box-row-content"> |
| 152 | <div class="flex"> |
| 153 | <span class="before-input"><?php echo esc_url( site_url() ); ?>/</span><input type="text" class="rename-login-page-name-input" name="rename_login_page_name" id="rename_login_page_name" value="<?php echo esc_attr( sanitize_text_field( $this->datas['rename_login_page_name'] ) ); ?>" minlength="4" maxlength="12" /> |
| 154 | </div> |
| 155 | <p class="pale-text">半角英小文字、半角数字、ハイフン、アンダースコアのいずれかを使用し、4文字以上12文字以下で� |
| 156 | �力してください。</p> |
| 157 | </div> |
| 158 | </div> |
| 159 | <div class="box-row flex-start"> |
| 160 | <div class="box-row-title not-label"> |
| 161 | リダイレクト設定 |
| 162 | </div> |
| 163 | <div class="box-row-content "> |
| 164 | <input id="redirect-checkbox" class="checkbox" type="checkbox" name="rename_login_page_disable_redirect" value="t" <?php echo esc_html( $this->datas['rename_login_page_disable_redirect_t'] ?? '' ); ?> /><label for="redirect-checkbox">管理� |
| 165 | ページからログインページにリダイレクトしない</label> |
| 166 | </div> |
| 167 | </div> |
| 168 | </div> |
| 169 | </div> |
| 170 | <div id="submit-btn-area"> |
| 171 | <?php $this->nonce_wp( $this->rename_login_page->get_feature_key() ); ?> |
| 172 | <?php $this->submit_button_wp(); ?> |
| 173 | </div> |
| 174 | </form> |
| 175 | <?php |
| 176 | } |
| 177 | } |
| 178 |