PluginProbe ʕ •ᴥ•ʔ
CloudSecure WP Security / 1.3.10
CloudSecure WP Security v1.3.10
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 1 year ago disable-xmlrpc.php 1 year ago htaccess.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 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
579 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 add_action( 'admin_notices', array( $this->rename_login_page, 'admin_notices' ), 10, 0 );
173 $this->rename_login_page->deactivate();
174 }
175 } else {
176 if ( $this->htaccess->setting_tag_exists( $this->rename_login_page->get_feature_key() ) ) {
177 $this->rename_login_page->deactivate();
178 }
179 }
180
181 if ( $this->unify_messages->is_enabled() ) {
182 add_filter( 'login_errors', array( $this->unify_messages, 'login_errors' ), 10, 1 );
183 }
184
185 if ( $this->restrict_admin_page->is_enabled() ) {
186 if ( $this->htaccess->setting_tag_exists( $this->restrict_admin_page->get_feature_key() ) ) {
187 add_action( 'wp_login', array( $this->restrict_admin_page, 'update' ), 1, 2 );
188
189 } else {
190 add_action( 'admin_notices', array( $this->restrict_admin_page, 'admin_notices' ), 10, 0 );
191 $this->restrict_admin_page->deactivate();
192 }
193 } else {
194 if ( $this->htaccess->setting_tag_exists( $this->restrict_admin_page->get_feature_key() ) ) {
195 $this->restrict_admin_page->deactivate();
196 }
197 }
198
199 if ( $this->disable_xmlrpc->is_enabled() ) {
200 if ( $this->disable_xmlrpc->is_pingback_disabled() ) {
201 if ( $this->htaccess->setting_tag_exists( $this->disable_xmlrpc->get_feature_key() ) ) {
202 add_action( 'admin_notices', array( $this->disable_xmlrpc, 'admin_notices' ), 10, 0 );
203 $this->disable_xmlrpc->deactivate();
204 } else {
205 add_filter( 'xmlrpc_methods', array( $this->disable_xmlrpc, 'xmlrpc_methods' ) );
206 }
207 }
208
209 if ( $this->disable_xmlrpc->is_xmlrpc_disabled() ) {
210 if ( ! $this->htaccess->setting_tag_exists( $this->disable_xmlrpc->get_feature_key() ) ) {
211 add_action( 'admin_notices', array( $this->disable_xmlrpc, 'admin_notices' ), 10, 0 );
212 $this->disable_xmlrpc->deactivate();
213 }
214 }
215 } else {
216 if ( $this->htaccess->setting_tag_exists( $this->disable_xmlrpc->get_feature_key() ) ) {
217 $this->disable_xmlrpc->deactivate();
218 }
219 }
220
221 if ( $this->disable_author_query->is_enabled() ) {
222 add_action( 'init', array( $this->disable_author_query, 'init' ) );
223 }
224
225 if ( $this->disable_restapi->is_enabled() ) {
226 add_filter( 'rest_pre_dispatch', array( $this->disable_restapi, 'rest_pre_dispatch' ), 10, 3 );
227 }
228
229 if ( $this->update_notice->is_enabled() ) {
230 $this->update_notice->set_cron();
231 add_action( $this->update_notice->get_cron_key(), array( $this->update_notice, 'update_notice' ) );
232 }
233
234 if ( $this->captcha->is_enabled() && 'xmlrpc.php' !== basename( sanitize_text_field( $_SERVER['SCRIPT_NAME'] ) ) && ! is_admin() ) {
235 add_filter( 'shake_error_codes', array( $this->captcha, 'shake_error_codes' ) );
236
237 if ( $this->captcha->is_login_form_enabled() ) {
238 add_filter( 'login_form', array( $this->captcha, 'login_form' ) );
239 add_action( 'wp_authenticate_user', array( $this->captcha, 'wp_authenticate_user' ), 10, 2 );
240 }
241
242 if ( $this->captcha->is_comment_form_enabled() ) {
243 add_action( 'comment_form_logged_in_after', array( $this->captcha, 'comment_form_default_fields' ), 1 );
244 add_action( 'comment_form_after_fields', array( $this->captcha, 'comment_form_default_fields' ) );
245 add_filter( 'preprocess_comment', array( $this->captcha, 'preprocess_comment' ) );
246 }
247
248 if ( $this->captcha->is_lost_password_form_enabled() ) {
249 add_filter( 'lostpassword_form', array( $this->captcha, 'lostpassword_form' ) );
250 add_filter( 'allow_password_reset', array( $this->captcha, 'allow_password_reset' ), 10, 2 );
251 }
252
253 if ( $this->captcha->is_register_form_enabled() ) {
254 add_action( 'register_form', array( $this->captcha, 'register_form' ) );
255 add_action( 'register_post', array( $this->captcha, 'register_post' ), 10, 3 );
256 }
257 }
258
259 if ( $this->two_factor_authentication->is_enabled() && 'xmlrpc.php' !== basename( $_SERVER['SCRIPT_NAME'] ) && ! is_admin() ) {
260 add_action( 'wp_login', array( $this->two_factor_authentication, 'wp_login' ), 0, 2 );
261 add_action( 'wp_login', array( $this->two_factor_authentication, 'redirect_if_not_two_factor_authentication_registered' ), 10, 2 );
262 }
263 }
264
265 if ( is_admin() ) {
266 if ( 'cloudsecurewp_rename_login_page' === sanitize_text_field( $_GET['page'] ?? '' ) ) {
267 ob_start();
268 }
269
270 $this->update();
271
272 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
273 }
274 }
275
276 /**
277 * プラグイン有効化
278 */
279 public function activate(): void {
280 $this->config->rm();
281 $this->config->set( 'version', $this->info['version'] );
282 $this->config->save();
283
284 $this->login_notification->activate();
285 $this->disable_login->activate();
286 $this->rename_login_page->activate();
287 $this->unify_messages->activate();
288 $this->restrict_admin_page->activate();
289 $this->disable_xmlrpc->activate();
290 $this->disable_author_query->activate();
291 $this->disable_restapi->activate();
292 $this->update_notice->activate();
293 $this->captcha->activate();
294 $this->login_log->activate();
295 $this->two_factor_authentication->activate();
296 $this->server_error_notification->activate();
297 $this->waf->activate();
298 $this->disable_access_system_file->activate();
299 }
300
301 /**
302 * プラグイン無効化
303 */
304 public function deactivate(): void {
305 $this->config->load_option();
306 $this->login_notification->deactivate();
307 $this->disable_login->deactivate();
308 $this->rename_login_page->deactivate();
309 $this->unify_messages->deactivate();
310 $this->restrict_admin_page->deactivate();
311 $this->disable_xmlrpc->deactivate();
312 $this->disable_author_query->deactivate();
313 $this->disable_restapi->deactivate();
314 $this->update_notice->deactivate();
315 $this->captcha->deactivate();
316 $this->two_factor_authentication->deactivate();
317 $this->server_error_notification->deactivate();
318 $this->waf->deactivate();
319 $this->disable_access_system_file->deactivate();
320 }
321
322 /**
323 * admin menuを追加
324 */
325 public function admin_menu(): void {
326 require_once __DIR__ . '/admin/common.php';
327
328 wp_enqueue_style( 'cloudsecurewp', $this->info['plugin_url'] . 'assets/css/style.css', array(), $this->info['version'] );
329
330 $slug = 'cloudsecurewp';
331 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' );
332 add_submenu_page( $slug, 'ダッシュボード', 'ダッシュボード', 'manage_options', $slug, array( $this, 'dashboard' ) );
333 add_submenu_page( $slug, 'ログイン無効化', 'ログイン無効化', 'manage_options', $slug . '_disable_login', array( $this, 'm_disable_login' ) );
334 add_submenu_page( $slug, 'ログインURL変更', 'ログインURL変更', 'manage_options', $slug . '_rename_login_page', array( $this, 'm_rename_login_page' ) );
335 add_submenu_page( $slug, 'ログインエラーメッセージ統一', 'ログインエラーメッセージ統一', 'manage_options', $slug . '_unify_messages', array( $this, 'm_unify_messages' ) );
336 add_submenu_page( $slug, '2段階認証', '2段階認証', 'manage_options', $slug . '_two_factor_authentication', array( $this, 'm_two_factor_authentication' ) );
337 add_submenu_page( $slug, '画像認証追加', '画像認証追加', 'manage_options', $slug . '_captcha', array( $this, 'm_captcha' ) );
338 add_submenu_page( $slug, '管理画面アクセス制限', '管理画面アクセス制限', 'manage_options', $slug . '_restrict_admin_page', array( $this, 'm_restrict_admin_page' ) );
339 add_submenu_page( $slug, '設定ファイルアクセス防止', '設定ファイルアクセス防止', 'manage_options', $slug . '_disable_access_system_file', array( $this, 'm_disable_access_system_file' ) );
340 add_submenu_page( $slug, 'ユーザー名漏えい防止', 'ユーザー名漏えい防止', 'manage_options', $slug . '_disable_author_query', array( $this, 'm_disable_author_query' ) );
341 add_submenu_page( $slug, 'XML-RPC無効化', 'XML-RPC無効化', 'manage_options', $slug . '_disable_xmlrpc', array( $this, 'm_disable_xmlrpc' ) );
342 add_submenu_page( $slug, 'REST API無効化', 'REST API無効化', 'manage_options', $slug . '_disable_restapi', array( $this, 'm_disable_restapi' ) );
343 add_submenu_page( $slug, 'シンプルWAF', 'シンプルWAF', 'manage_options', $slug . '_waf', array( $this, 'm_waf' ) );
344 add_submenu_page( $slug, 'ログイン通知', 'ログイン通知', 'manage_options', $slug . '_login_notification', array( $this, 'm_login_notification' ) );
345 add_submenu_page( $slug, 'アップデート通知', 'アップデート通知', 'manage_options', $slug . '_update_notification', array( $this, 'm_update_notice' ) );
346 add_submenu_page( $slug, 'サーバーエラー通知', 'サーバーエラー通知', 'manage_options', $slug . '_server_error_notification', array( $this, 'm_server_error_notification' ) );
347 add_submenu_page( $slug, 'ログイン履歴', 'ログイン履歴', 'manage_options', $slug . '_login_log', array( $this, 'm_login_log' ) );
348
349 if ( $this->two_factor_authentication->is_enabled_on_screen() ) {
350 add_menu_page( 'デバイス登録', '2段階認証', 'read', $slug . '_two_factor_authentication_registration', array( $this, 'm_two_factor_authentication_registration' ), 'dashicons-lock', 72 );
351 }
352 }
353
354 /**
355 * ダッシュボードページ
356 *
357 * @return void
358 */
359 public function dashboard(): void {
360 require_once 'admin/dashboard.php';
361
362 $datas = array(
363 $this->login_notification->get_feature_key() => $this->config->get( $this->login_notification->get_feature_key() ),
364 $this->disable_login->get_feature_key() => $this->config->get( $this->disable_login->get_feature_key() ),
365 $this->rename_login_page->get_feature_key() => $this->config->get( $this->rename_login_page->get_feature_key() ),
366 $this->unify_messages->get_feature_key() => $this->config->get( $this->unify_messages->get_feature_key() ),
367 $this->restrict_admin_page->get_feature_key() => $this->config->get( $this->restrict_admin_page->get_feature_key() ),
368 $this->disable_xmlrpc->get_feature_key() => $this->config->get( $this->disable_xmlrpc->get_feature_key() ),
369 $this->disable_author_query->get_feature_key() => $this->config->get( $this->disable_author_query->get_feature_key() ),
370 $this->disable_restapi->get_feature_key() => $this->config->get( $this->disable_restapi->get_feature_key() ),
371 $this->update_notice->get_feature_key() => $this->config->get( $this->update_notice->get_feature_key() ),
372 $this->server_error_notification->get_feature_key() => $this->config->get( $this->server_error_notification->get_feature_key() ),
373 $this->captcha->get_feature_key() => $this->config->get( $this->captcha->get_feature_key() ),
374 $this->two_factor_authentication->get_feature_key() => $this->config->get( $this->two_factor_authentication->get_feature_key() ),
375 $this->waf->get_feature_key() => $this->config->get( $this->waf->get_feature_key() ),
376 $this->disable_access_system_file->get_feature_key() => $this->config->get( $this->disable_access_system_file->get_feature_key() ),
377 );
378
379 new CloudSecureWP_Admin_Dashboard( $this->info, $datas );
380 }
381
382 /**
383 * ログイン通知ページ
384 *
385 * @return void
386 */
387 public function m_login_notification(): void {
388 require_once 'admin/login-notification.php';
389 new CloudSecureWP_Admin_Login_Notification( $this->info, $this->login_notification );
390 }
391
392 /**
393 * ログイン無効化ページ
394 *
395 * @return void
396 */
397 public function m_disable_login(): void {
398 require_once 'admin/disable-login.php';
399 new CloudSecureWP_Admin_Disable_Login( $this->info, $this->disable_login );
400 }
401
402 /**
403 * ログインURL変更
404 *
405 * @return void
406 */
407 public function m_rename_login_page(): void {
408 require_once 'admin/rename-login-page.php';
409 new CloudSecureWP_Admin_Rename_Login_Page( $this->info, $this->rename_login_page );
410 }
411
412 /**
413 * エラーメッセージ単一化機能
414 *
415 * @return void
416 */
417 public function m_unify_messages(): void {
418 require_once 'admin/unify-messages.php';
419 new CloudSecureWP_Admin_Unify_Messages( $this->info, $this->unify_messages );
420 }
421
422 /**
423 * 管理画面アクセス制限
424 *
425 * @return void
426 */
427 public function m_restrict_admin_page(): void {
428 require_once 'admin/restrict-admin-page.php';
429 new CloudSecureWP_Admin_Restrict_Admin_Page( $this->info, $this->restrict_admin_page );
430 }
431
432 /**
433 * XMLRPC無効化
434 *
435 * @return void
436 */
437 public function m_disable_xmlrpc(): void {
438 require_once 'admin/disable-xmlrpc.php';
439 new CloudSecureWP_Admin_Disable_XMLRPC( $this->info, $this->disable_xmlrpc );
440 }
441
442 /**
443 * ユーザー名漏えい防止
444 *
445 * @return void
446 */
447 public function m_disable_author_query(): void {
448 require_once 'admin/disable-author-query.php';
449 new CloudSecureWP_Admin_Disable_Author_Query( $this->info, $this->disable_author_query );
450 }
451
452 /**
453 * REST API無効化
454 *
455 * @return void
456 */
457 public function m_disable_restapi(): void {
458 require_once 'admin/disable-restapi.php';
459 new CloudSecureWP_Admin_Disable_RESTAPI( $this->info, $this->disable_restapi );
460 }
461
462 /**
463 * アップデート通知
464 *
465 * @return void
466 */
467 public function m_update_notice(): void {
468 require_once 'admin/update-notice.php';
469 new CloudSecureWP_Admin_Update_Notice( $this->info, $this->update_notice );
470 }
471
472 /**
473 * 画像認証追加
474 *
475 * @return void
476 */
477 public function m_captcha(): void {
478 require_once 'admin/captcha.php';
479 new CloudSecureWP_Admin_CAPTCHA( $this->info, $this->captcha );
480 }
481
482 /**
483 * ログイン履歴
484 *
485 * @return void
486 */
487 public function m_login_log(): void {
488 require_once 'admin/login-log.php';
489 require_once 'admin/login-log-table.php';
490 new CloudSecureWP_Admin_Login_Log( $this->info, $this->login_log );
491 }
492
493 /**
494 * 2段階認証
495 *
496 * @return void
497 */
498 public function m_two_factor_authentication(): void {
499 require_once 'admin/two-factor-authentication.php';
500 new CloudSecureWP_Admin_Two_Factor_Authentication( $this->info, $this->two_factor_authentication );
501 }
502
503 /**
504 * 2段階認証のデバイス登録
505 *
506 * @return void
507 */
508 public function m_two_factor_authentication_registration(): void {
509 require_once 'admin/two-factor-authentication-registration.php';
510 new CloudSecureWP_Admin_Two_Factor_Authentication_Registration( $this->info, $this->two_factor_authentication );
511 }
512
513 /**
514 * サーバーエラー通知
515 *
516 * @return void
517 */
518 public function m_server_error_notification(): void {
519 require_once 'admin/server-error-notification.php';
520 require_once 'admin/server-error-table.php';
521 new CloudSecureWP_Admin_Server_Error_Notification( $this->info, $this->server_error_notification );
522 }
523
524 /**
525 * シンプルWAF
526 *
527 * @return void
528 */
529 public function m_waf(): void {
530 require_once 'admin/waf.php';
531 require_once 'admin/waf-table.php';
532 new CloudSecureWP_Admin_Waf( $this->info, $this->waf );
533 }
534
535 /**
536 * 設定ファイルアクセス防止
537 *
538 * @return void
539 */
540 public function m_disable_access_system_file(): void {
541 require_once 'admin/disable-access-system-file.php';
542 new CloudSecureWP_Admin_Disable_Access_System_File( $this->info, $this->disable_access_system_file );
543 }
544
545 /**
546 * プラグイン更新時の処理
547 */
548 private function update(): void {
549 $old_version = $this->config->get( 'version' );
550 $now_version = $this->info['version'];
551
552 if ( empty( $old_version ) ) {
553 $old_version = '1.0.0';
554 }
555
556 if ( 0 <= version_compare( $old_version, $now_version ) ) {
557 return;
558 }
559
560 if ( version_compare( $old_version, '1.1.0' ) < 0 ) {
561 $this->two_factor_authentication->activate();
562 $this->server_error_notification->activate();
563 }
564
565 if ( version_compare( $old_version, '1.3.0' ) < 0 ) {
566 $this->waf->activate();
567 $this->disable_access_system_file->activate();
568 }
569
570 if ( version_compare( $old_version, '1.3.7' ) < 0 ) {
571 $this->waf->activate();
572 $this->server_error_notification->activate();
573 }
574
575 $this->config->set( 'version', $now_version );
576 $this->config->save();
577 }
578 }
579