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