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 / cloudsecure-wp.php
cloudsecure-wp-security / modules Last commit date
admin 1 year ago lib 1 year ago captcha.php 2 years ago cloudsecure-wp.php 1 year ago common.php 1 year ago config.php 2 years ago disable-access-system-file.php 1 year ago disable-author-query.php 2 years ago disable-login.php 1 year ago disable-restapi.php 2 years ago disable-xmlrpc.php 2 years ago htaccess.php 1 year ago login-log.php 1 year ago login-notification.php 1 year ago rename-login-page.php 2 years ago restrict-admin-page.php 1 year ago server-error-notification.php 1 year ago two-factor-authentication.php 1 year ago unify-messages.php 2 years ago update-notice.php 2 years ago waf-engine.php 1 year ago waf.php 1 year ago
cloudsecure-wp.php
570 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 require_once __DIR__ . '/common.php';
8 require_once __DIR__ . '/config.php';
9 require_once __DIR__ . '/htaccess.php';
10 require_once __DIR__ . '/login-notification.php';
11 require_once __DIR__ . '/disable-login.php';
12 require_once __DIR__ . '/rename-login-page.php';
13 require_once __DIR__ . '/unify-messages.php';
14 require_once __DIR__ . '/restrict-admin-page.php';
15 require_once __DIR__ . '/disable-xmlrpc.php';
16 require_once __DIR__ . '/disable-author-query.php';
17 require_once __DIR__ . '/disable-restapi.php';
18 require_once __DIR__ . '/update-notice.php';
19 require_once __DIR__ . '/captcha.php';
20 require_once __DIR__ . '/../really-simple-captcha/really-simple-captcha.php';
21 require_once __DIR__ . '/lib/class-time-based-one-time-password.php';
22 require_once __DIR__ . '/login-log.php';
23 require_once __DIR__ . '/two-factor-authentication.php';
24 require_once __DIR__ . '/server-error-notification.php';
25 require_once __DIR__ . '/waf-engine.php';
26 require_once __DIR__ . '/waf.php';
27 require_once __DIR__ . '/lib/class-waf-rules.php';
28 require_once __DIR__ . '/disable-access-system-file.php';
29 require_once __DIR__ . '/lib/class-disable-access-system-file-rules.php';
30
31 class CloudSecureWP extends CloudSecureWP_Common {
32 private $config;
33 private $htaccess;
34 private $login_notification;
35 private $disable_login;
36 private $rename_login_page;
37 private $unify_messages;
38 private $restrict_admin_page;
39 private $disable_xmlrpc;
40 private $disable_author_query;
41 private $disable_restapi;
42 private $update_notice;
43 private $captcha;
44 private $login_log;
45 private $two_factor_authentication;
46 private $server_error_notification;
47 private $waf;
48 private $disable_access_system_file;
49
50 function __construct( array $info ) {
51 parent::__construct( $info );
52 $this->config = new CloudSecureWP_Config( $info );
53 $this->htaccess = new CloudSecureWP_Htaccess( $info );
54 $this->login_notification = new CloudSecureWP_Login_Notification( $info, $this->config );
55 $this->disable_login = new CloudSecureWP_Disable_Login( $info, $this->config );
56 $this->rename_login_page = new CloudSecureWP_Rename_Login_Page( $info, $this->config, $this->htaccess );
57 $this->unify_messages = new CloudSecureWP_Unify_Messages( $info, $this->config, $this->disable_login );
58 $this->restrict_admin_page = new CloudSecureWP_Restrict_Admin_Page( $info, $this->config, $this->htaccess, $this->disable_login );
59 $this->disable_xmlrpc = new CloudSecureWP_Disable_XMLRPC( $info, $this->config, $this->htaccess );
60 $this->disable_author_query = new CloudSecureWP_Disable_Author_Query( $info, $this->config );
61 $this->disable_restapi = new CloudSecureWP_Disable_RESTAPI( $info, $this->config );
62 $this->update_notice = new CloudSecureWP_Update_Notice( $info, $this->config );
63 $this->captcha = new CloudSecureWP_CAPTCHA( $info, $this->config );
64 $this->login_log = new CloudSecureWP_Login_Log( $info, $this->config, $this->disable_login );
65 $this->two_factor_authentication = new CloudSecureWP_Two_Factor_Authentication( $info, $this->config, $this->disable_login );
66 $this->server_error_notification = new CloudSecureWP_Server_Error_Notification( $info, $this->config );
67 $this->waf = new CloudSecureWP_Waf( $info, $this->config );
68 $this->disable_access_system_file = new CloudSecureWP_Disable_Access_System_File( $info, $this->config );
69 }
70
71 /**
72 * プラグイン実行
73 *
74 * @return void
75 */
76 public function run() {
77 if ( ! $this->check_environment() ) {
78 if ( $this->login_notification->is_enabled() ) {
79 $this->login_notification->deactivate();
80 }
81
82 if ( $this->disable_login->is_enabled() ) {
83 $this->disable_login->deactivate();
84 }
85
86 if ( $this->rename_login_page->is_enabled() ) {
87 $this->rename_login_page->deactivate();
88 }
89
90 if ( $this->unify_messages->is_enabled() ) {
91 $this->unify_messages->deactivate();
92 }
93
94 if ( $this->restrict_admin_page->is_enabled() ) {
95 $this->restrict_admin_page->deactivate();
96 }
97
98 if ( $this->disable_xmlrpc->is_enabled() ) {
99 $this->disable_xmlrpc->deactivate();
100 }
101
102 if ( $this->disable_author_query->is_enabled() ) {
103 $this->disable_author_query->deactivate();
104 }
105
106 if ( $this->disable_restapi->is_enabled() ) {
107 $this->disable_restapi->deactivate();
108 }
109
110 if ( $this->update_notice->is_enabled() ) {
111 $this->update_notice->deactivate();
112 }
113
114 if ( $this->captcha->is_enabled() ) {
115 $this->captcha->deactivate();
116 }
117
118 if ( $this->two_factor_authentication->is_enabled() ) {
119 $this->two_factor_authentication->deactivate();
120 }
121
122 if ( $this->server_error_notification->is_enabled() ) {
123 $this->server_error_notification->deactivate();
124 }
125
126 if ( $this->waf->is_enabled() ) {
127 $this->waf->deactivate();
128 }
129
130 if ( $this->disable_access_system_file->is_enabled() ) {
131 $this->disable_access_system_file->deactivate();
132 }
133 } else {
134 if ( $this->waf->is_enabled() ) {
135 add_action( 'plugins_loaded', array( $this->waf, 'waf' ), 10 );
136 }
137
138 if ( $this->server_error_notification->is_enabled() ) {
139 add_filter( 'wp_php_error_args', array( $this->server_error_notification, 'notification' ), 10, 2 );
140 }
141
142 if ( $this->disable_access_system_file->is_enabled() ) {
143 add_action( 'plugins_loaded', array( $this->disable_access_system_file, 'init' ), 10 );
144 }
145
146 add_action( 'wp_login', array( $this->login_log, 'wp_login' ), 1, 1 );
147 add_action( 'xmlrpc_call', array( $this->login_log, 'xmlrpc_call' ), 10 );
148 add_action( 'wp_login_failed', array( $this->login_log, 'wp_login_failed' ), 20, 1 );
149
150 if ( $this->login_notification->is_enabled() ) {
151 add_action( 'wp_login', array( $this->login_notification, 'notification' ), 10, 2 );
152 }
153
154 if ( $this->disable_login->is_enabled() ) {
155 add_filter( 'shake_error_codes', array( $this->disable_login, 'shake_error_codes' ) );
156 add_filter( 'authenticate', array( $this->disable_login, 'authenticate' ), 99, 3 );
157 add_action( 'wp_login_failed', array( $this->disable_login, 'wp_login_failed' ), 10, 1 );
158 }
159
160 if ( $this->rename_login_page->is_enabled() ) {
161 if ( $this->htaccess->setting_tag_exists( $this->rename_login_page->get_feature_key() ) ) {
162 remove_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
163 add_action( 'plugins_loaded', array( $this->rename_login_page, 'wp_register_404' ), 10 );
164 add_filter( 'login_init', array( $this->rename_login_page, 'login_init' ), 10, 2 );
165 add_filter( 'site_url', array( $this->rename_login_page, 'site_url' ), 10, 4 );
166 add_filter( 'network_site_url', array( $this->rename_login_page, 'network_site_url' ), 10, 3 );
167 add_filter( 'register', array( $this->rename_login_page, 'register' ), 10, 1 );
168 add_filter( 'wp_redirect', array( $this->rename_login_page, 'wp_redirect' ), 10, 2 );
169 add_filter( 'auth_redirect_scheme', array( $this->rename_login_page, 'auth_redirect_scheme' ), 99, 1 );
170
171 } else {
172 $this->rename_login_page->deactivate();
173 }
174 } else {
175 if ( $this->htaccess->setting_tag_exists( $this->rename_login_page->get_feature_key() ) ) {
176 $this->rename_login_page->deactivate();
177 }
178 }
179
180 if ( $this->unify_messages->is_enabled() ) {
181 add_filter( 'login_errors', array( $this->unify_messages, 'login_errors' ), 10, 1 );
182 }
183
184 if ( $this->restrict_admin_page->is_enabled() ) {
185 if ( $this->htaccess->setting_tag_exists( $this->restrict_admin_page->get_feature_key() ) ) {
186 add_action( 'wp_login', array( $this->restrict_admin_page, 'update' ), 1, 2 );
187
188 } else {
189 $this->restrict_admin_page->deactivate();
190 }
191 } else {
192 if ( $this->htaccess->setting_tag_exists( $this->restrict_admin_page->get_feature_key() ) ) {
193 $this->restrict_admin_page->deactivate();
194 }
195 }
196
197 if ( $this->disable_xmlrpc->is_enabled() ) {
198 if ( $this->disable_xmlrpc->is_pingback_disabled() ) {
199 if ( $this->htaccess->setting_tag_exists( $this->disable_xmlrpc->get_feature_key() ) ) {
200 $this->disable_xmlrpc->deactivate();
201 } else {
202 add_filter( 'xmlrpc_methods', array( $this->disable_xmlrpc, 'xmlrpc_methods' ) );
203 }
204 }
205
206 if ( $this->disable_xmlrpc->is_xmlrpc_disabled() ) {
207 if ( ! $this->htaccess->setting_tag_exists( $this->disable_xmlrpc->get_feature_key() ) ) {
208 $this->disable_xmlrpc->deactivate();
209 }
210 }
211 } else {
212 if ( $this->htaccess->setting_tag_exists( $this->disable_xmlrpc->get_feature_key() ) ) {
213 $this->disable_xmlrpc->deactivate();
214 }
215 }
216
217 if ( $this->disable_author_query->is_enabled() ) {
218 add_action( 'init', array( $this->disable_author_query, 'init' ) );
219 }
220
221 if ( $this->disable_restapi->is_enabled() ) {
222 add_filter( 'rest_pre_dispatch', array( $this->disable_restapi, 'rest_pre_dispatch' ), 10, 3 );
223 }
224
225 if ( $this->update_notice->is_enabled() ) {
226 $this->update_notice->set_cron();
227 add_action( $this->update_notice->get_cron_key(), array( $this->update_notice, 'update_notice' ) );
228 }
229
230 if ( $this->captcha->is_enabled() && 'xmlrpc.php' !== basename( sanitize_text_field( $_SERVER['SCRIPT_NAME'] ) ) && ! is_admin() ) {
231 add_filter( 'shake_error_codes', array( $this->captcha, 'shake_error_codes' ) );
232
233 if ( $this->captcha->is_login_form_enabled() ) {
234 add_filter( 'login_form', array( $this->captcha, 'login_form' ) );
235 add_action( 'wp_authenticate_user', array( $this->captcha, 'wp_authenticate_user' ), 10, 2 );
236 }
237
238 if ( $this->captcha->is_comment_form_enabled() ) {
239 add_action( 'comment_form_logged_in_after', array( $this->captcha, 'comment_form_default_fields' ), 1 );
240 add_action( 'comment_form_after_fields', array( $this->captcha, 'comment_form_default_fields' ) );
241 add_filter( 'preprocess_comment', array( $this->captcha, 'preprocess_comment' ) );
242 }
243
244 if ( $this->captcha->is_lost_password_form_enabled() ) {
245 add_filter( 'lostpassword_form', array( $this->captcha, 'lostpassword_form' ) );
246 add_filter( 'allow_password_reset', array( $this->captcha, 'allow_password_reset' ), 10, 2 );
247 }
248
249 if ( $this->captcha->is_register_form_enabled() ) {
250 add_action( 'register_form', array( $this->captcha, 'register_form' ) );
251 add_action( 'register_post', array( $this->captcha, 'register_post' ), 10, 3 );
252 }
253 }
254
255 if ( $this->two_factor_authentication->is_enabled() && 'xmlrpc.php' !== basename( $_SERVER['SCRIPT_NAME'] ) && ! is_admin() ) {
256 add_action( 'wp_login', array( $this->two_factor_authentication, 'wp_login' ), 0, 2 );
257 add_action( 'wp_login', array( $this->two_factor_authentication, 'redirect_if_not_two_factor_authentication_registered' ), 10, 2 );
258 }
259 }
260
261 if ( is_admin() ) {
262 if ( 'cloudsecurewp_rename_login_page' === sanitize_text_field( $_GET['page'] ?? '' ) ) {
263 ob_start();
264 }
265
266 $this->update();
267
268 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
269 }
270 }
271
272 /**
273 * プラグイン有効化
274 */
275 public function activate(): void {
276 $this->config->rm();
277 $this->config->set( 'version', $this->info['version'] );
278 $this->config->save();
279
280 $this->login_notification->activate();
281 $this->disable_login->activate();
282 $this->rename_login_page->activate();
283 $this->unify_messages->activate();
284 $this->restrict_admin_page->activate();
285 $this->disable_xmlrpc->activate();
286 $this->disable_author_query->activate();
287 $this->disable_restapi->activate();
288 $this->update_notice->activate();
289 $this->captcha->activate();
290 $this->login_log->activate();
291 $this->two_factor_authentication->activate();
292 $this->server_error_notification->activate();
293 $this->waf->activate();
294 $this->disable_access_system_file->activate();
295 }
296
297 /**
298 * プラグイン無効化
299 */
300 public function deactivate(): void {
301 $this->config->load_option();
302 $this->login_notification->deactivate();
303 $this->disable_login->deactivate();
304 $this->rename_login_page->deactivate();
305 $this->unify_messages->deactivate();
306 $this->restrict_admin_page->deactivate();
307 $this->disable_xmlrpc->deactivate();
308 $this->disable_author_query->deactivate();
309 $this->disable_restapi->deactivate();
310 $this->update_notice->deactivate();
311 $this->captcha->deactivate();
312 $this->two_factor_authentication->deactivate();
313 $this->server_error_notification->deactivate();
314 $this->waf->deactivate();
315 $this->disable_access_system_file->deactivate();
316 }
317
318 /**
319 * admin menuを追加
320 */
321 public function admin_menu(): void {
322 require_once __DIR__ . '/admin/common.php';
323
324 wp_enqueue_style( 'cloudsecurewp', $this->info['plugin_url'] . 'assets/css/style.css', array(), $this->info['version'] );
325
326 $slug = 'cloudsecurewp';
327 add_menu_page( $this->info['plugin_name'], $this->info['plugin_name'], 'manage_options', $slug, array( $this, 'dashboard' ), $this->info['plugin_url'] . 'assets/images/plugin-icon.png' );
328 add_submenu_page( $slug, 'ダッシュボード', 'ダッシュボード', 'manage_options', $slug, array( $this, 'dashboard' ) );
329 add_submenu_page( $slug, 'ログイン無効化', 'ログイン無効化', 'manage_options', $slug . '_disable_login', array( $this, 'm_disable_login' ) );
330 add_submenu_page( $slug, 'ログインURL変更', 'ログインURL変更', 'manage_options', $slug . '_rename_login_page', array( $this, 'm_rename_login_page' ) );
331 add_submenu_page( $slug, 'ログインエラーメッセージ統一', 'ログインエラーメッセージ統一', 'manage_options', $slug . '_unify_messages', array( $this, 'm_unify_messages' ) );
332 add_submenu_page( $slug, '2段階認証', '2段階認証', 'manage_options', $slug . '_two_factor_authentication', array( $this, 'm_two_factor_authentication' ) );
333 add_submenu_page( $slug, '画像認証追加', '画像認証追加', 'manage_options', $slug . '_captcha', array( $this, 'm_captcha' ) );
334 add_submenu_page( $slug, '管理画面アクセス制限', '管理画面アクセス制限', 'manage_options', $slug . '_restrict_admin_page', array( $this, 'm_restrict_admin_page' ) );
335 add_submenu_page( $slug, '設定ファイルアクセス防止', '設定ファイルアクセス防止', 'manage_options', $slug . '_disable_access_system_file', array( $this, 'm_disable_access_system_file' ) );
336 add_submenu_page( $slug, 'ユーザー名漏えい防止', 'ユーザー名漏えい防止', 'manage_options', $slug . '_disable_author_query', array( $this, 'm_disable_author_query' ) );
337 add_submenu_page( $slug, 'XML-RPC無効化', 'XML-RPC無効化', 'manage_options', $slug . '_disable_xmlrpc', array( $this, 'm_disable_xmlrpc' ) );
338 add_submenu_page( $slug, 'REST API無効化', 'REST API無効化', 'manage_options', $slug . '_disable_restapi', array( $this, 'm_disable_restapi' ) );
339 add_submenu_page( $slug, 'シンプルWAF', 'シンプルWAF', 'manage_options', $slug . '_waf', array( $this, 'm_waf' ) );
340 add_submenu_page( $slug, 'ログイン通知', 'ログイン通知', 'manage_options', $slug . '_login_notification', array( $this, 'm_login_notification' ) );
341 add_submenu_page( $slug, 'アップデート通知', 'アップデート通知', 'manage_options', $slug . '_update_notification', array( $this, 'm_update_notice' ) );
342 add_submenu_page( $slug, 'サーバーエラー通知', 'サーバーエラー通知', 'manage_options', $slug . '_server_error_notification', array( $this, 'm_server_error_notification' ) );
343 add_submenu_page( $slug, 'ログイン履歴', 'ログイン履歴', 'manage_options', $slug . '_login_log', array( $this, 'm_login_log' ) );
344
345 if ( $this->two_factor_authentication->is_enabled_on_screen() ) {
346 add_menu_page( 'デバイス登録', '2段階認証', 'read', $slug . '_two_factor_authentication_registration', array( $this, 'm_two_factor_authentication_registration' ), 'dashicons-lock', 72 );
347 }
348 }
349
350 /**
351 * ダッシュボードページ
352 *
353 * @return void
354 */
355 public function dashboard(): void {
356 require_once 'admin/dashboard.php';
357
358 $datas = array(
359 $this->login_notification->get_feature_key() => $this->config->get( $this->login_notification->get_feature_key() ),
360 $this->disable_login->get_feature_key() => $this->config->get( $this->disable_login->get_feature_key() ),
361 $this->rename_login_page->get_feature_key() => $this->config->get( $this->rename_login_page->get_feature_key() ),
362 $this->unify_messages->get_feature_key() => $this->config->get( $this->unify_messages->get_feature_key() ),
363 $this->restrict_admin_page->get_feature_key() => $this->config->get( $this->restrict_admin_page->get_feature_key() ),
364 $this->disable_xmlrpc->get_feature_key() => $this->config->get( $this->disable_xmlrpc->get_feature_key() ),
365 $this->disable_author_query->get_feature_key() => $this->config->get( $this->disable_author_query->get_feature_key() ),
366 $this->disable_restapi->get_feature_key() => $this->config->get( $this->disable_restapi->get_feature_key() ),
367 $this->update_notice->get_feature_key() => $this->config->get( $this->update_notice->get_feature_key() ),
368 $this->server_error_notification->get_feature_key() => $this->config->get( $this->server_error_notification->get_feature_key() ),
369 $this->captcha->get_feature_key() => $this->config->get( $this->captcha->get_feature_key() ),
370 $this->two_factor_authentication->get_feature_key() => $this->config->get( $this->two_factor_authentication->get_feature_key() ),
371 $this->waf->get_feature_key() => $this->config->get( $this->waf->get_feature_key() ),
372 $this->disable_access_system_file->get_feature_key() => $this->config->get( $this->disable_access_system_file->get_feature_key() ),
373 );
374
375 new CloudSecureWP_Admin_Dashboard( $this->info, $datas );
376 }
377
378 /**
379 * ログイン通知ページ
380 *
381 * @return void
382 */
383 public function m_login_notification(): void {
384 require_once 'admin/login-notification.php';
385 new CloudSecureWP_Admin_Login_Notification( $this->info, $this->login_notification );
386 }
387
388 /**
389 * ログイン無効化ページ
390 *
391 * @return void
392 */
393 public function m_disable_login(): void {
394 require_once 'admin/disable-login.php';
395 new CloudSecureWP_Admin_Disable_Login( $this->info, $this->disable_login );
396 }
397
398 /**
399 * ログインURL変更
400 *
401 * @return void
402 */
403 public function m_rename_login_page(): void {
404 require_once 'admin/rename-login-page.php';
405 new CloudSecureWP_Admin_Rename_Login_Page( $this->info, $this->rename_login_page );
406 }
407
408 /**
409 * エラーメッセージ単一化機能
410 *
411 * @return void
412 */
413 public function m_unify_messages(): void {
414 require_once 'admin/unify-messages.php';
415 new CloudSecureWP_Admin_Unify_Messages( $this->info, $this->unify_messages );
416 }
417
418 /**
419 * 管理画面アクセス制限
420 *
421 * @return void
422 */
423 public function m_restrict_admin_page(): void {
424 require_once 'admin/restrict-admin-page.php';
425 new CloudSecureWP_Admin_Restrict_Admin_Page( $this->info, $this->restrict_admin_page );
426 }
427
428 /**
429 * XMLRPC無効化
430 *
431 * @return void
432 */
433 public function m_disable_xmlrpc(): void {
434 require_once 'admin/disable-xmlrpc.php';
435 new CloudSecureWP_Admin_Disable_XMLRPC( $this->info, $this->disable_xmlrpc );
436 }
437
438 /**
439 * ユーザー名漏えい防止
440 *
441 * @return void
442 */
443 public function m_disable_author_query(): void {
444 require_once 'admin/disable-author-query.php';
445 new CloudSecureWP_Admin_Disable_Author_Query( $this->info, $this->disable_author_query );
446 }
447
448 /**
449 * REST API無効化
450 *
451 * @return void
452 */
453 public function m_disable_restapi(): void {
454 require_once 'admin/disable-restapi.php';
455 new CloudSecureWP_Admin_Disable_RESTAPI( $this->info, $this->disable_restapi );
456 }
457
458 /**
459 * アップデート通知
460 *
461 * @return void
462 */
463 public function m_update_notice(): void {
464 require_once 'admin/update-notice.php';
465 new CloudSecureWP_Admin_Update_Notice( $this->info, $this->update_notice );
466 }
467
468 /**
469 * 画像認証追加
470 *
471 * @return void
472 */
473 public function m_captcha(): void {
474 require_once 'admin/captcha.php';
475 new CloudSecureWP_Admin_CAPTCHA( $this->info, $this->captcha );
476 }
477
478 /**
479 * ログイン履歴
480 *
481 * @return void
482 */
483 public function m_login_log(): void {
484 require_once 'admin/login-log.php';
485 require_once 'admin/login-log-table.php';
486 new CloudSecureWP_Admin_Login_Log( $this->info, $this->login_log );
487 }
488
489 /**
490 * 2段階認証
491 *
492 * @return void
493 */
494 public function m_two_factor_authentication(): void {
495 require_once 'admin/two-factor-authentication.php';
496 new CloudSecureWP_Admin_Two_Factor_Authentication( $this->info, $this->two_factor_authentication );
497 }
498
499 /**
500 * 2段階認証のデバイス登録
501 *
502 * @return void
503 */
504 public function m_two_factor_authentication_registration(): void {
505 require_once 'admin/two-factor-authentication-registration.php';
506 new CloudSecureWP_Admin_Two_Factor_Authentication_Registration( $this->info, $this->two_factor_authentication );
507 }
508
509 /**
510 * サーバーエラー通知
511 *
512 * @return void
513 */
514 public function m_server_error_notification(): void {
515 require_once 'admin/server-error-notification.php';
516 require_once 'admin/server-error-table.php';
517 new CloudSecureWP_Admin_Server_Error_Notification( $this->info, $this->server_error_notification );
518 }
519
520 /**
521 * シンプルWAF
522 *
523 * @return void
524 */
525 public function m_waf(): void {
526 require_once 'admin/waf.php';
527 require_once 'admin/waf-table.php';
528 new CloudSecureWP_Admin_Waf( $this->info, $this->waf );
529 }
530
531 /**
532 * 設定ファイルアクセス防止
533 *
534 * @return void
535 */
536 public function m_disable_access_system_file(): void {
537 require_once 'admin/disable-access-system-file.php';
538 new CloudSecureWP_Admin_Disable_Access_System_File( $this->info, $this->disable_access_system_file );
539 }
540
541 /**
542 * プラグイン更新時の処理
543 */
544 private function update(): void {
545 $old_version = $this->config->get( 'version' );
546 $now_version = $this->info['version'];
547
548 if ( empty( $old_version ) ) {
549 $old_version = '1.0.0';
550 }
551
552 if ( 0 <= version_compare( $old_version, $now_version ) ) {
553 return;
554 }
555
556 if ( version_compare( $old_version, '1.1.0' ) < 0 ) {
557 $this->two_factor_authentication->activate();
558 $this->server_error_notification->activate();
559 }
560
561 if ( version_compare( $old_version, '1.3.0' ) < 0 ) {
562 $this->waf->activate();
563 $this->disable_access_system_file->activate();
564 }
565
566 $this->config->set( 'version', $now_version );
567 $this->config->save();
568 }
569 }
570