PluginProbe
The WP Remote WordPress Plugin / trunk
The WP Remote WordPress Plugin vtrunk
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
← All changes | protect/fw.php +111 -111 6.69trunk View file →
@@ -1,13 +1,13 @@
1 1 <?php
2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit;
3 3
4 -if (!class_exists('WPRProtectFW_V669')) :
4 +if (!class_exists('WPRProtectFW_V672')) :
5 5 require_once dirname( __FILE__ ) . '/fw/rule/errors.php';
6 6 require_once dirname( __FILE__ ) . '/fw/rule/engine.php';
7 7 require_once dirname( __FILE__ ) . '/fw/rule.php';
8 8
9 -class WPRProtectFW_V669 {
9 +class WPRProtectFW_V672 {
10 10 private $brand_name;
11 11 private $protect_mode;
12 12 private $request;
13 13 private $ipstore;
@@ -22,13 +22,13 @@
22 22 private $is_ip_checked_for_blacklisted = false;
23 23 private $is_ip_whitelisted = null;
24 24 private $has_valid_bypass_cookie;
25 25
26 - private $mode = WPRProtectFW_V669::MODE_DISABLED;
27 - private $ip_cookie_mode = WPRProtectFW_V669::IP_COOKIE_MODE_DISABLED;
28 - private $admin_cookie_mode = WPRProtectFW_V669::ADMIN_COOKIE_MODE_DISABLED;
29 - private $bypass_level = WPRProtectFW_V669::WP_USER_ROLE_LEVEL_CONTRIBUTOR;
30 - private $wpf_rule_init_mode = WPRProtectFW_V669::WPF_RULE_INIT_MODE_WP;
26 + private $mode = WPRProtectFW_V672::MODE_DISABLED;
27 + private $ip_cookie_mode = WPRProtectFW_V672::IP_COOKIE_MODE_DISABLED;
28 + private $admin_cookie_mode = WPRProtectFW_V672::ADMIN_COOKIE_MODE_DISABLED;
29 + private $bypass_level = WPRProtectFW_V672::WP_USER_ROLE_LEVEL_CONTRIBUTOR;
30 + private $wpf_rule_init_mode = WPRProtectFW_V672::WPF_RULE_INIT_MODE_WP;
31 31 private $custom_roles = array();
32 32 private $cookie_key = "";
33 33 private $cookie_path = "";
34 34 private $cookie_domain = "";
@@ -33,14 +33,14 @@
33 33 private $cookie_path = "";
34 34 private $cookie_domain = "";
35 35 private $cookie_validity = 2592000;
36 36 private $can_set_cache_prevention_cookie = false;
37 - private $rules_mode = WPRProtectFW_V669::RULES_MODE_DISABLED;
37 + private $rules_mode = WPRProtectFW_V672::RULES_MODE_DISABLED;
38 38 private $is_geo_blocking = false;
39 39 private $is_wp_user_cookie_enabled = false;
40 40 private $log_config = array();
41 - private $request_profiling_mode = WPRProtectFW_V669::REQ_PROFILING_MODE_DISABLED;
42 - private $logging_mode = WPRProtectFW_V669::LOGGING_MODE_VISITOR;
41 + private $request_profiling_mode = WPRProtectFW_V672::REQ_PROFILING_MODE_DISABLED;
42 + private $logging_mode = WPRProtectFW_V672::LOGGING_MODE_VISITOR;
43 43 private $skip_log_config = array();
44 44 private $skip_log_cookies = array();
45 45 private $skip_log_headers = array();
46 46 private $skip_log_post_params = array();
@@ -53,9 +53,9 @@
53 53 private $rule_log = array();
54 54 private $matched_rules = array();
55 55 private $break_rule_matching = false;
56 56 private $can_log_raw_body = false;
57 - private $log_slice_size = WPRProtectFW_V669::LOG_SLICE_SIZE;
57 + private $log_slice_size = WPRProtectFW_V672::LOG_SLICE_SIZE;
58 58
59 59 private static $instance = null;
60 60
61 61 const MODE_DISABLED = 1;
@@ -99,18 +99,18 @@
99 99 const LOGGING_MODE_COMPLETE = 2;
100 100 const LOGGING_MODE_DISABLED = 3;
101 101
102 102 const DEFAULT_WP_USER_ROLE_LEVELS = array(
103 - 'administrator' => WPRProtectFW_V669::WP_USER_ROLE_LEVEL_ADMIN,
104 - 'editor' => WPRProtectFW_V669::WP_USER_ROLE_LEVEL_EDITOR,
105 - 'author' => WPRProtectFW_V669::WP_USER_ROLE_LEVEL_AUTHOR,
106 - 'contributor' => WPRProtectFW_V669::WP_USER_ROLE_LEVEL_CONTRIBUTOR,
107 - 'subscriber' => WPRProtectFW_V669::WP_USER_ROLE_LEVEL_SUBSCRIBER
103 + 'administrator' => WPRProtectFW_V672::WP_USER_ROLE_LEVEL_ADMIN,
104 + 'editor' => WPRProtectFW_V672::WP_USER_ROLE_LEVEL_EDITOR,
105 + 'author' => WPRProtectFW_V672::WP_USER_ROLE_LEVEL_AUTHOR,
106 + 'contributor' => WPRProtectFW_V672::WP_USER_ROLE_LEVEL_CONTRIBUTOR,
107 + 'subscriber' => WPRProtectFW_V672::WP_USER_ROLE_LEVEL_SUBSCRIBER
108 108 );
109 109
110 110 const EXTRA_WP_USER_ROLE_LEVELS = array(
111 - 'custom' => WPRProtectFW_V669::WP_USER_ROLE_LEVEL_CUSTOM,
112 - 'unknown' => WPRProtectFW_V669::WP_USER_ROLE_LEVEL_UNKNOWN
111 + 'custom' => WPRProtectFW_V672::WP_USER_ROLE_LEVEL_CUSTOM,
112 + 'unknown' => WPRProtectFW_V672::WP_USER_ROLE_LEVEL_UNKNOWN
113 113 );
114 114
115 115 const TABLE_NAME = "fw_requests";
116 116 const IP_COOKIE_NAME = "mcfw-ip-cookie";
@@ -247,13 +247,13 @@
247 247 }
248 248
249 249 if ($this->isPrependMode()) {
250 250 $log_file = MCDATAPATH . MCCONFKEY . '-mc.log';
251 - $this->ipstore = new WPRProtectIpstore_V669(WPRProtectIpstore_V669::STORAGE_TYPE_FS);
252 - $this->logger = new WPRProtectLogger_V669($log_file, WPRProtectLogger_V669::TYPE_FS);
251 + $this->ipstore = new WPRProtectIpstore_V672(WPRProtectIpstore_V672::STORAGE_TYPE_FS);
252 + $this->logger = new WPRProtectLogger_V672($log_file, WPRProtectLogger_V672::TYPE_FS);
253 253 } else {
254 - $this->ipstore = new WPRProtectIpstore_V669(WPRProtectIpstore_V669::STORAGE_TYPE_DB);
255 - $this->logger = new WPRProtectLogger_V669(WPRProtectFW_V669::TABLE_NAME, WPRProtectLogger_V669::TYPE_DB);
254 + $this->ipstore = new WPRProtectIpstore_V672(WPRProtectIpstore_V672::STORAGE_TYPE_DB);
255 + $this->logger = new WPRProtectLogger_V672(WPRProtectFW_V672::TABLE_NAME, WPRProtectLogger_V672::TYPE_DB);
256 256 }
257 257
258 258 if ($this->is_wp_user_cookie_enabled) {
259 259 $this->loadWPUser();
@@ -264,12 +264,12 @@
264 264
265 265 public static function getInstance($protect_mode, $request, $config, $brand_name) {
266 266 if (!isset(self::$instance)) {
267 267 self::$instance = new self($protect_mode, $request, $config, $brand_name);
268 - } elseif (self::$instance->protect_mode != $protect_mode && $protect_mode == WPRProtect_V669::MODE_WP) {
268 + } elseif (self::$instance->protect_mode != $protect_mode && $protect_mode == WPRProtect_V672::MODE_WP) {
269 269 self::$instance->protect_mode = $protect_mode;
270 270 self::$instance->brand_name = $brand_name;
271 - self::$instance->ipstore = new WPRProtectIpstore_V669(WPRProtectIpstore_V669::STORAGE_TYPE_DB);
271 + self::$instance->ipstore = new WPRProtectIpstore_V672(WPRProtectIpstore_V672::STORAGE_TYPE_DB);
272 272 self::$instance->initRules();
273 273 }
274 274
275 275 return self::$instance;
@@ -275,9 +275,9 @@
275 275 return self::$instance;
276 276 }
277 277
278 278 public static function uninstall() {
279 - WPRProtect_V669::$db->dropBVTable(WPRProtectFW_V669::TABLE_NAME);
279 + WPRProtect_V672::$db->dropBVTable(WPRProtectFW_V672::TABLE_NAME);
280 280 }
281 281
282 282 public function init() {
283 283 if (!$this->isModeDisabled()) {
@@ -295,42 +295,42 @@
295 295 }
296 296 }
297 297
298 298 private function isPrependMode() {
299 - return ($this->protect_mode === WPRProtect_V669::MODE_PREPEND);
299 + return ($this->protect_mode === WPRProtect_V672::MODE_PREPEND);
300 300 }
301 301
302 302 private function isWPMode() {
303 - return ($this->protect_mode === WPRProtect_V669::MODE_WP);
303 + return ($this->protect_mode === WPRProtect_V672::MODE_WP);
304 304 }
305 305
306 306 private function isModeDisabled() {
307 - return ($this->mode === WPRProtectFW_V669::MODE_DISABLED);
307 + return ($this->mode === WPRProtectFW_V672::MODE_DISABLED);
308 308 }
309 309
310 310 private function isModeProtect() {
311 - return ($this->mode === WPRProtectFW_V669::MODE_PROTECT);
311 + return ($this->mode === WPRProtectFW_V672::MODE_PROTECT);
312 312 }
313 313
314 314 private function isAdminCookieEnabled() {
315 - return ($this->admin_cookie_mode === WPRProtectFW_V669::ADMIN_COOKIE_MODE_ENABLED);
315 + return ($this->admin_cookie_mode === WPRProtectFW_V672::ADMIN_COOKIE_MODE_ENABLED);
316 316 }
317 317
318 318 private function isIPCookieEnabled() {
319 - return ($this->ip_cookie_mode === WPRProtectFW_V669::IP_COOKIE_MODE_ENABLED);
319 + return ($this->ip_cookie_mode === WPRProtectFW_V672::IP_COOKIE_MODE_ENABLED);
320 320 }
321 321
322 322 private function isRequestProfilingDisabled() {
323 - return ($this->request_profiling_mode === WPRProtectFW_V669::REQ_PROFILING_MODE_DISABLED);
323 + return ($this->request_profiling_mode === WPRProtectFW_V672::REQ_PROFILING_MODE_DISABLED);
324 324 }
325 325
326 326 private function isRequestProfilingModeDebug() {
327 - return ($this->request_profiling_mode === WPRProtectFW_V669::REQ_PROFILING_MODE_DEBUG);
327 + return ($this->request_profiling_mode === WPRProtectFW_V672::REQ_PROFILING_MODE_DEBUG);
328 328 }
329 329
330 330 private function isRequestHasValidBypassCookie() {
331 331 if (!isset($this->has_valid_bypass_cookie)) {
332 - $cookie = (string) $this->request->getCookies(WPRProtectFW_V669::BYPASS_COOKIE_NAME);
332 + $cookie = (string) $this->request->getCookies(WPRProtectFW_V672::BYPASS_COOKIE_NAME);
333 333 $new_cookie = $this->generateBypassCookie();
334 334 $is_valid = ($this->isAdminCookieEnabled() && $new_cookie && ($cookie === $new_cookie));
335 335 $this->has_valid_bypass_cookie = $is_valid;
336 336 }
@@ -338,17 +338,17 @@
338 338 return $this->has_valid_bypass_cookie;
339 339 }
340 340
341 341 private function isRulesModeProtect() {
342 - return ($this->rules_mode === WPRProtectFW_V669::RULES_MODE_PROTECT);
342 + return ($this->rules_mode === WPRProtectFW_V672::RULES_MODE_PROTECT);
343 343 }
344 344
345 345 public function isLoggingModeComplete() {
346 - return ($this->logging_mode === WPRProtectFW_V669::LOGGING_MODE_COMPLETE);
346 + return ($this->logging_mode === WPRProtectFW_V672::LOGGING_MODE_COMPLETE);
347 347 }
348 348
349 349 public function isLoggingModeVisitor() {
350 - return ($this->logging_mode === WPRProtectFW_V669::LOGGING_MODE_VISITOR);
350 + return ($this->logging_mode === WPRProtectFW_V672::LOGGING_MODE_VISITOR);
351 351 }
352 352
353 353 public function isGeoBlockingEnabled() {
354 354 return ($this->is_geo_blocking === true);
@@ -354,13 +354,13 @@
354 354 return ($this->is_geo_blocking === true);
355 355 }
356 356
357 357 private function isWPFRuleInitModePrepend() {
358 - return ($this->wpf_rule_init_mode === WPRProtectFW_V669::WPF_RULE_INIT_MODE_PREPEND);
358 + return ($this->wpf_rule_init_mode === WPRProtectFW_V672::WPF_RULE_INIT_MODE_PREPEND);
359 359 }
360 360
361 361 private function isWPFRuleInitModeWP() {
362 - return ($this->wpf_rule_init_mode === WPRProtectFW_V669::WPF_RULE_INIT_MODE_WP);
362 + return ($this->wpf_rule_init_mode === WPRProtectFW_V672::WPF_RULE_INIT_MODE_WP);
363 363 }
364 364
365 365 private function canInitWPFRules() {
366 366 if (!$this->isWPFRuleInitModePrepend() && $this->isPrependMode()) {
@@ -387,18 +387,18 @@
387 387 if (function_exists('is_user_logged_in') && is_user_logged_in()) {
388 388 $current_wp_user = $this->getCurrentWPUser();
389 389
390 390 if (!$current_wp_user->isIdentical($this->request->wp_user)) {
391 - $serialized_wp_user = WPRProtectWPUser_V669::_serialize($current_wp_user);
391 + $serialized_wp_user = WPRProtectWPUser_V672::_serialize($current_wp_user);
392 392 $cookie_val = $serialized_wp_user . '_' .
393 - WPRProtectUtils_V669::signMessage($serialized_wp_user, $this->cookie_key);
393 + WPRProtectUtils_V672::signMessage($serialized_wp_user, $this->cookie_key);
394 394 $cookie_val = base64_encode($cookie_val);
395 395
396 - $this->setCookie(WPRProtectWPUser_V669::COOKIE_NAME, $cookie_val);
396 + $this->setCookie(WPRProtectWPUser_V672::COOKIE_NAME, $cookie_val);
397 397 }
398 398 } elseif ($this->request->wp_user->isLoggedIn()) {
399 - $this->request->wp_user = WPRProtectWPUser_V669::defaultUser();
400 - $this->unsetCookie(WPRProtectWPUser_V669::COOKIE_NAME);
399 + $this->request->wp_user = WPRProtectWPUser_V672::defaultUser();
400 + $this->unsetCookie(WPRProtectWPUser_V672::COOKIE_NAME);
401 401 }
402 402 }
403 403
404 404 private function getCurrentWPUser() {
@@ -413,9 +413,9 @@
413 413 $role_level = $this->getCurrentWPUserRoleLevel();
414 414 $capabilities = $this->getCurrentWPUserCapabilities();
415 415 }
416 416
417 - return (new WPRProtectWPUser_V669($id, $role_level, $capabilities, $time));
417 + return (new WPRProtectWPUser_V672($id, $role_level, $capabilities, $time));
418 418 }
419 419
420 420 private function getCurrentWPUserCapabilities() {
421 421 $capabilities = array();
@@ -432,11 +432,11 @@
432 432 return $capabilities;
433 433 }
434 434
435 435 private function loadWPUser() {
436 - $this->request->wp_user = WPRProtectWPUser_V669::defaultUser();
436 + $this->request->wp_user = WPRProtectWPUser_V672::defaultUser();
437 437
438 - $cookie_val = $this->request->getCookies(WPRProtectWPUser_V669::COOKIE_NAME);
438 + $cookie_val = $this->request->getCookies(WPRProtectWPUser_V672::COOKIE_NAME);
439 439 if (!is_string($cookie_val)) {
440 440 return;
441 441 }
442 442
@@ -450,10 +450,10 @@
450 450 return;
451 451 }
452 452 list($serialized_user, $signature) = $cookie_val_array;
453 453
454 - if (WPRProtectUtils_V669::verifyMessage($serialized_user, $signature, $this->cookie_key) === true) {
455 - $wp_user = WPRProtectWPUser_V669::_unserialize($serialized_user);
454 + if (WPRProtectUtils_V672::verifyMessage($serialized_user, $signature, $this->cookie_key) === true) {
455 + $wp_user = WPRProtectWPUser_V672::_unserialize($serialized_user);
456 456
457 457 if (!isset($wp_user) || $wp_user->time !== (int) floor(time() / $this->cookie_validity)) {
458 458 return;
459 459 }
@@ -466,10 +466,10 @@
466 466 $this->request->wp_user->capability_names[] = $capability_names[$capability];
467 467 }
468 468 }
469 469
470 - $role_by_level = array_flip(array_merge(WPRProtectFW_V669::DEFAULT_WP_USER_ROLE_LEVELS,
471 - WPRProtectFW_V669::EXTRA_WP_USER_ROLE_LEVELS));
470 + $role_by_level = array_flip(array_merge(WPRProtectFW_V672::DEFAULT_WP_USER_ROLE_LEVELS,
471 + WPRProtectFW_V672::EXTRA_WP_USER_ROLE_LEVELS));
472 472 $this->request->wp_user->role = $role_by_level[$this->request->wp_user->role_level];
473 473 }
474 474 }
475 475
@@ -491,11 +491,11 @@
491 491 }
492 492
493 493 if ($this->isPrependMode()) {
494 494 $rules_file = MCDATAPATH . MCCONFKEY . '-' . 'mc_rules.json';
495 - $rule_arrays = WPRProtectUtils_V669::parseFile($rules_file);
495 + $rule_arrays = WPRProtectUtils_V672::parseFile($rules_file);
496 496 } else {
497 - $rule_arrays = WPRProtect_V669::$settings->getOption('bvruleset');
497 + $rule_arrays = WPRProtect_V672::$settings->getOption('bvruleset');
498 498 if(!is_array($rule_arrays)) {
499 499 $rule_arrays = array();
500 500 }
501 501 }
@@ -505,9 +505,9 @@
505 505 return;
506 506 }
507 507
508 508 foreach($rule_arrays as $rule_array) {
509 - $rule = WPRProtectFWRule_V669::init($rule_array);
509 + $rule = WPRProtectFWRule_V672::init($rule_array);
510 510
511 511 if ($rule) {
512 512 if (!$this->is_rule_initialized && $rule->isExeOnBoot()) {
513 513 if (!$this->isRequestHasValidBypassCookie()) {
@@ -530,105 +530,105 @@
530 530 }
531 531
532 532 private function initWPFRule($rule) {
533 533 switch ($rule->execute_on) {
534 - case WPRProtectFWRule_V669::EXE_ON_PRE_UPDATE_OPTION:
534 + case WPRProtectFWRule_V672::EXE_ON_PRE_UPDATE_OPTION:
535 535 $this->addWPHook($rule, 'pre_update_option', 'handleRequestOnPreUpdateOption', 3);
536 536 break;
537 - case WPRProtectFWRule_V669::EXE_ON_PRE_DELETE_POST:
537 + case WPRProtectFWRule_V672::EXE_ON_PRE_DELETE_POST:
538 538 $this->addWPHook($rule, 'pre_delete_post', 'handleRequestOnPreDeletePost', 3);
539 539 break;
540 - case WPRProtectFWRule_V669::EXE_ON_WP_INSERT_POST_EMPTY_CONTENT:
540 + case WPRProtectFWRule_V672::EXE_ON_WP_INSERT_POST_EMPTY_CONTENT:
541 541 $this->addWPHook($rule, 'wp_insert_post_empty_content',
542 542 'handleRequestOnWPInsertPostEmptyContent', 2);
543 543 break;
544 - case WPRProtectFWRule_V669::EXE_ON_INSERT_USER_META:
544 + case WPRProtectFWRule_V672::EXE_ON_INSERT_USER_META:
545 545 $this->addWPHook($rule, 'insert_user_meta', 'handleRequestOnInsertUserMeta', 4);
546 546 break;
547 - case WPRProtectFWRule_V669::EXE_ON_DELETE_OPTION:
547 + case WPRProtectFWRule_V672::EXE_ON_DELETE_OPTION:
548 548 $this->addWPHook($rule, 'delete_option', 'handleRequestOnDeleteOption', 1, 'action');
549 549 break;
550 - case WPRProtectFWRule_V669::EXE_ON_DELETE_USER:
550 + case WPRProtectFWRule_V672::EXE_ON_DELETE_USER:
551 551 $this->addWPHook($rule, 'delete_user', 'handleRequestOnDeleteUser', 3, 'action');
552 552 break;
553 - case WPRProtectFWRule_V669::EXE_ON_PASSWORD_RESET:
553 + case WPRProtectFWRule_V672::EXE_ON_PASSWORD_RESET:
554 554 $this->addWPHook($rule, 'password_reset', 'handleRequestOnPasswordReset', 2, 'action');
555 555 break;
556 - case WPRProtectFWRule_V669::EXE_ON_SEND_AUTH_COOKIES:
556 + case WPRProtectFWRule_V672::EXE_ON_SEND_AUTH_COOKIES:
557 557 $this->addWPHook($rule, 'send_auth_cookies', 'handleRequestOnSendAuthCookies', 6);
558 558 break;
559 - case WPRProtectFWRule_V669::EXE_ON_SET_AUTH_COOKIE:
559 + case WPRProtectFWRule_V672::EXE_ON_SET_AUTH_COOKIE:
560 560 $this->addWPHook($rule, 'set_auth_cookie', 'handleRequestOnSetAuthCookie', 6, 'action');
561 561 break;
562 - case WPRProtectFWRule_V669::EXE_ON_INIT:
562 + case WPRProtectFWRule_V672::EXE_ON_INIT:
563 563 $this->addWPHook($rule, 'init', 'handleRequestOnInit', 0, 'action');
564 564 break;
565 - case WPRProtectFWRule_V669::EXE_ON_USER_REGISTER:
565 + case WPRProtectFWRule_V672::EXE_ON_USER_REGISTER:
566 566 $this->addWPHook($rule, 'user_register', 'handleRequestOnUserRegister', 2, 'action');
567 567 break;
568 - case WPRProtectFWRule_V669::EXE_ON_ADD_USER_META:
568 + case WPRProtectFWRule_V672::EXE_ON_ADD_USER_META:
569 569 $this->addWPHook($rule, 'add_user_meta', 'handleRequestOnAddUserMeta', 3, 'action');
570 570 break;
571 - case WPRProtectFWRule_V669::EXE_ON_UPDATE_USER_METADATA:
571 + case WPRProtectFWRule_V672::EXE_ON_UPDATE_USER_METADATA:
572 572 $this->addWPHook($rule, 'update_user_metadata', 'handleRequestOnUpdateUserMetadata', 5);
573 573 break;
574 - case WPRProtectFWRule_V669::EXE_ON_UPDATE_USER_META:
574 + case WPRProtectFWRule_V672::EXE_ON_UPDATE_USER_META:
575 575 $this->addWPHook($rule, 'update_user_meta', 'handleRequestOnUpdateUserMeta', 4, 'action');
576 576 break;
577 - case WPRProtectFWRule_V669::EXE_ON_ADD_OPTION:
577 + case WPRProtectFWRule_V672::EXE_ON_ADD_OPTION:
578 578 $this->addWPHook($rule, 'add_option', 'handleRequestOnAddOption', 2, 'action');
579 579 break;
580 - case WPRProtectFWRule_V669::EXE_ON_WP_PRE_INSERT_USER_DATA:
580 + case WPRProtectFWRule_V672::EXE_ON_WP_PRE_INSERT_USER_DATA:
581 581 $this->addWPHook($rule, 'wp_pre_insert_user_data', 'handleRequestOnWPPreInsertUserData', 4);
582 582 break;
583 - case WPRProtectFWRule_V669::EXE_ON_REST_REQUEST_BEFORE_CALLBACKS:
583 + case WPRProtectFWRule_V672::EXE_ON_REST_REQUEST_BEFORE_CALLBACKS:
584 584 $this->addWPHook($rule, 'rest_request_before_callbacks',
585 585 'handleRequestOnRestRequestBeforeCallbacks', 3);
586 586 break;
587 - case WPRProtectFWRule_V669::EXE_ON_ADMIN_INIT:
587 + case WPRProtectFWRule_V672::EXE_ON_ADMIN_INIT:
588 588 $this->addWPHook($rule, 'admin_init', 'handleRequestOnAdminInit', 0, 'action');
589 589 break;
590 - case WPRProtectFWRule_V669::EXE_ON_WP_HANDLE_UPLOAD_PREFILTER:
590 + case WPRProtectFWRule_V672::EXE_ON_WP_HANDLE_UPLOAD_PREFILTER:
591 591 $this->addWPHook($rule, 'wp_handle_upload_prefilter',
592 592 'handleRequestOnWPHandleUploadPrefilter', 1);
593 593 break;
594 - case WPRProtectFWRule_V669::EXE_ON_TEMPLATE_REDIRECT:
594 + case WPRProtectFWRule_V672::EXE_ON_TEMPLATE_REDIRECT:
595 595 $this->addWPHook($rule, 'template_redirect', 'handleRequestOnTemplateRedirect', 0, 'action');
596 596 break;
597 - case WPRProtectFWRule_V669::EXE_ON_WP_LOADED:
597 + case WPRProtectFWRule_V672::EXE_ON_WP_LOADED:
598 598 $this->addWPHook($rule, 'wp_loaded', 'handleRequestOnWPLoaded', 0, 'action');
599 599 break;
600 - case WPRProtectFWRule_V669::EXE_ON_ADD_POST_METADATA:
600 + case WPRProtectFWRule_V672::EXE_ON_ADD_POST_METADATA:
601 601 $this->addWPHook($rule, 'add_post_metadata', 'handleRequestOnAddPostMetadata', 5);
602 602 break;
603 - case WPRProtectFWRule_V669::EXE_ON_UPDATE_POST_METADATA:
603 + case WPRProtectFWRule_V672::EXE_ON_UPDATE_POST_METADATA:
604 604 $this->addWPHook($rule, 'update_post_metadata', 'handleRequestOnUpdatePostMetadata', 5);
605 605 break;
606 - case WPRProtectFWRule_V669::EXE_ON_DELETE_POST_METADATA:
606 + case WPRProtectFWRule_V672::EXE_ON_DELETE_POST_METADATA:
607 607 $this->addWPHook($rule, 'delete_post_metadata', 'handleRequestOnDeletePostMetadata', 5);
608 608 break;
609 - case WPRProtectFWRule_V669::EXE_ON_ADD_TERM_METADATA:
609 + case WPRProtectFWRule_V672::EXE_ON_ADD_TERM_METADATA:
610 610 $this->addWPHook($rule, 'add_term_metadata', 'handleRequestOnAddTermMetadata', 5);
611 611 break;
612 - case WPRProtectFWRule_V669::EXE_ON_UPDATE_TERM_METADATA:
612 + case WPRProtectFWRule_V672::EXE_ON_UPDATE_TERM_METADATA:
613 613 $this->addWPHook($rule, 'update_term_metadata', 'handleRequestOnUpdateTermMetadata', 5);
614 614 break;
615 - case WPRProtectFWRule_V669::EXE_ON_DELETE_TERM_METADATA:
615 + case WPRProtectFWRule_V672::EXE_ON_DELETE_TERM_METADATA:
616 616 $this->addWPHook($rule, 'delete_term_metadata', 'handleRequestOnDeleteTermMetadata', 5);
617 617 break;
618 - case WPRProtectFWRule_V669::EXE_ON_ADD_COMMENT_METADATA:
618 + case WPRProtectFWRule_V672::EXE_ON_ADD_COMMENT_METADATA:
619 619 $this->addWPHook($rule, 'add_comment_metadata', 'handleRequestOnAddCommentMetadata', 5);
620 620 break;
621 - case WPRProtectFWRule_V669::EXE_ON_UPDATE_COMMENT_METADATA:
621 + case WPRProtectFWRule_V672::EXE_ON_UPDATE_COMMENT_METADATA:
622 622 $this->addWPHook($rule, 'update_comment_metadata', 'handleRequestOnUpdateCommentMetadata', 5);
623 623 break;
624 - case WPRProtectFWRule_V669::EXE_ON_DELETE_COMMENT_METADATA:
624 + case WPRProtectFWRule_V672::EXE_ON_DELETE_COMMENT_METADATA:
625 625 $this->addWPHook($rule, 'delete_comment_metadata', 'handleRequestOnDeleteCommentMetadata', 5);
626 626 break;
627 - case WPRProtectFWRule_V669::EXE_ON_ADD_USER_METADATA:
627 + case WPRProtectFWRule_V672::EXE_ON_ADD_USER_METADATA:
628 628 $this->addWPHook($rule, 'add_user_metadata', 'handleRequestOnAddUserMetadata', 5);
629 629 break;
630 - case WPRProtectFWRule_V669::EXE_ON_DELETE_USER_METADATA:
630 + case WPRProtectFWRule_V672::EXE_ON_DELETE_USER_METADATA:
631 631 $this->addWPHook($rule, 'delete_user_metadata', 'handleRequestOnDeleteUserMetadata', 5);
632 632 break;
633 633 }
634 634 }
@@ -644,9 +644,9 @@
644 644 } else {
645 645 add_filter($hook_name, $callback, -9999999, $accepted_args);
646 646 }
647 647 } else {
648 - WPRProtectUtils_V669::preInitWPHook($hook_name, $callback, -9999999, $accepted_args);
648 + WPRProtectUtils_V672::preInitWPHook($hook_name, $callback, -9999999, $accepted_args);
649 649 }
650 650 }
651 651
652 652 $this->pushWPFRule($function_name, $rule);
@@ -1202,14 +1202,14 @@
1202 1202 }
1203 1203
1204 1204 private function setIPCookie() {
1205 1205 if (!$this->is_ip_cookie_set && $this->isIPCookieEnabled() &&
1206 - !$this->request->getCookies(WPRProtectFW_V669::IP_COOKIE_NAME)) {
1206 + !$this->request->getCookies(WPRProtectFW_V672::IP_COOKIE_NAME)) {
1207 1207
1208 1208 $time = floor(time() / 86400);
1209 1209 $cookie = hash('sha256', $this->request->ip . $time . $this->cookie_key);
1210 1210 if ($cookie) {
1211 - $this->setCookie(WPRProtectFW_V669::IP_COOKIE_NAME, $cookie, time() + 86400);
1211 + $this->setCookie(WPRProtectFW_V672::IP_COOKIE_NAME, $cookie, time() + 86400);
1212 1212 }
1213 1213 }
1214 1214 }
1215 1215
@@ -1215,18 +1215,18 @@
1215 1215
1216 1216 private function getCurrentWPUserRoleLevel() {
1217 1217 if (function_exists('current_user_can')) {
1218 1218 if (function_exists('is_super_admin') && is_super_admin()) {
1219 - return WPRProtectFW_V669::WP_USER_ROLE_LEVEL_ADMIN;
1219 + return WPRProtectFW_V672::WP_USER_ROLE_LEVEL_ADMIN;
1220 1220 }
1221 1221
1222 1222 foreach ($this->custom_roles as $role) {
1223 1223 if (current_user_can($role)) {
1224 - return WPRProtectFW_V669::WP_USER_ROLE_LEVEL_CUSTOM;
1224 + return WPRProtectFW_V672::WP_USER_ROLE_LEVEL_CUSTOM;
1225 1225 }
1226 1226 }
1227 1227
1228 - foreach (WPRProtectFW_V669::DEFAULT_WP_USER_ROLE_LEVELS as $role => $level) {
1228 + foreach (WPRProtectFW_V672::DEFAULT_WP_USER_ROLE_LEVELS as $role => $level) {
1229 1229 if (current_user_can($role)) {
1230 1230 return $level;
1231 1231 }
1232 1232 }
@@ -1332,11 +1332,11 @@
1332 1332
1333 1333 private function getBVCookies() {
1334 1334 $cookies = array();
1335 1335
1336 - if ($this->request->getCookies(WPRProtectFW_V669::IP_COOKIE_NAME) !== NULL) {
1337 - $cookie_val = (string) $this->request->getCookies(WPRProtectFW_V669::IP_COOKIE_NAME);
1338 - $cookies[WPRProtectFW_V669::IP_COOKIE_NAME] = $cookie_val;
1336 + if ($this->request->getCookies(WPRProtectFW_V672::IP_COOKIE_NAME) !== NULL) {
1337 + $cookie_val = (string) $this->request->getCookies(WPRProtectFW_V672::IP_COOKIE_NAME);
1338 + $cookies[WPRProtectFW_V672::IP_COOKIE_NAME] = $cookie_val;
1339 1339 }
1340 1340
1341 1341 return $cookies;
1342 1342 }
@@ -1498,9 +1498,9 @@
1498 1498 }
1499 1499 }
1500 1500
1501 1501 private function getUserBy($attribute, $value) {
1502 - if (isset($value) && function_exists('get_user_by') && WPRProtectUtils_V669::havePluginsLoaded()) {
1502 + if (isset($value) && function_exists('get_user_by') && WPRProtectUtils_V672::havePluginsLoaded()) {
1503 1503 return get_user_by($attribute, $value);
1504 1504 }
1505 1505 }
1506 1506
@@ -1602,9 +1602,9 @@
1602 1602 xlsx|psd|mp3|m4a|ogg|wav|mp4|m4v|mov|wmv|avi|mpg|ogv|3gp|3g2|php|html|phtml|js|css)/ix', $value)) {
1603 1603 $profiled_data[$key]["file"] = true;
1604 1604 }
1605 1605
1606 - if ($this->matchCount(WPRProtectFWRule_V669::SQLIREGEX, $value) > 2) {
1606 + if ($this->matchCount(WPRProtectFWRule_V672::SQLIREGEX, $value) > 2) {
1607 1607 $profiled_data[$key]["sql"] = true;
1608 1608 }
1609 1609
1610 1610 if (WPRHelper::safePregMatch('/(?:\.{2}[\/]+)/', $value)) {
@@ -1691,15 +1691,15 @@
1691 1691 }
1692 1692
1693 1693 private function canRequestBypassFirewall() {
1694 1694 if ($this->isRequestIPWhitelisted() || $this->isRequestHasValidBypassCookie()) {
1695 - $this->request->category = WPRProtectRequest_V669::CATEGORY_WHITELISTED;
1696 - $this->request->status = WPRProtectRequest_V669::STATUS_BYPASSED;
1695 + $this->request->category = WPRProtectRequest_V672::CATEGORY_WHITELISTED;
1696 + $this->request->status = WPRProtectRequest_V672::STATUS_BYPASSED;
1697 1697
1698 1698 return true;
1699 - } elseif (WPRProtectUtils_V669::isPrivateIP($this->request->ip)) {
1700 - $this->request->category = WPRProtectRequest_V669::CATEGORY_PRIVATEIP;
1701 - $this->request->status = WPRProtectRequest_V669::STATUS_BYPASSED;
1699 + } elseif (WPRProtectUtils_V672::isPrivateIP($this->request->ip)) {
1700 + $this->request->category = WPRProtectRequest_V672::CATEGORY_PRIVATEIP;
1701 + $this->request->status = WPRProtectRequest_V672::STATUS_BYPASSED;
1702 1702
1703 1703 return true;
1704 1704 }
1705 1705
@@ -1721,9 +1721,9 @@
1721 1721 }
1722 1722 }
1723 1723
1724 1724 private function handleRequestOnRuleMatch($rules, $engine_vars = array(), $log_data = array()) {
1725 - $normalized_engine_vars = WPRProtectFWRuleEngine_V669::normalizeVariables($engine_vars);
1725 + $normalized_engine_vars = WPRProtectFWRuleEngine_V672::normalizeVariables($engine_vars);
1726 1726
1727 1727 foreach ($rules as $rule) {
1728 1728 if ($this->break_rule_matching) {
1729 1729 break;
@@ -1731,12 +1731,12 @@
1731 1731
1732 1732 $_engine_vars = $normalized_engine_vars;
1733 1733 if (array_key_exists('variables', $rule->opts)) {
1734 1734 $_engine_vars = array_merge($_engine_vars,
1735 - WPRProtectFWRuleEngine_V669::normalizeVariables($rule->opts['variables']));
1735 + WPRProtectFWRuleEngine_V672::normalizeVariables($rule->opts['variables']));
1736 1736 }
1737 1737
1738 - $rule_engine = new WPRProtectFWRuleEngine_V669($this->request, $_engine_vars);
1738 + $rule_engine = new WPRProtectFWRuleEngine_V672($this->request, $_engine_vars);
1739 1739
1740 1740 if ($rule_engine->evaluate($rule) && !$rule_engine->hasError()) {
1741 1741 if (!empty($log_data)) {
1742 1742 $this->updateRuleLog("info", (string) $rule->id, $log_data);
@@ -1747,13 +1747,13 @@
1747 1747 foreach($rule->actions as $action) {
1748 1748 switch ($action["type"]) {
1749 1749 case "ALLOW":
1750 1750 $this->break_rule_matching = true;
1751 - $this->request->category = WPRProtectRequest_V669::CATEGORY_RULE_ALLOWED;
1751 + $this->request->category = WPRProtectRequest_V672::CATEGORY_RULE_ALLOWED;
1752 1752 return;
1753 1753 case "BLOCK":
1754 1754 if ($this->isModeProtect()) {
1755 - $this->terminateRequest(WPRProtectRequest_V669::CATEGORY_RULE_BLOCKED);
1755 + $this->terminateRequest(WPRProtectRequest_V672::CATEGORY_RULE_BLOCKED);
1756 1756 }
1757 1757 return;
1758 1758 case "INSPECT":
1759 1759 $this->inspectRequest();
@@ -1767,15 +1767,15 @@
1767 1767 }
1768 1768
1769 1769 private function terminateRequest($category) {
1770 1770 $this->request->category = $category;
1771 - $this->request->status = WPRProtectRequest_V669::STATUS_BLOCKED;
1771 + $this->request->status = WPRProtectRequest_V672::STATUS_BLOCKED;
1772 1772 $this->request->setRespCode(403);
1773 1773
1774 1774 if ($this->can_set_cache_prevention_cookie &&
1775 - !$this->request->getCookies(WPRProtectFW_V669::PREVENT_CACHE_COOKIE_NAME)) {
1775 + !$this->request->getCookies(WPRProtectFW_V672::PREVENT_CACHE_COOKIE_NAME)) {
1776 1776 $value = "Prevent Caching Response.";
1777 - $this->setCookie(WPRProtectFW_V669::PREVENT_CACHE_COOKIE_NAME, $value, time() + 43200);
1777 + $this->setCookie(WPRProtectFW_V672::PREVENT_CACHE_COOKIE_NAME, $value, time() + 43200);
1778 1778 }
1779 1779
1780 1780 header("Cache-Control: no-cache, no-store, must-revalidate");
1781 1781 header("Pragma: no-cache");
@@ -1801,9 +1801,9 @@
1801 1801 $role_level = $this->getCurrentWPUserRoleLevel();
1802 1802 if ($role_level >= $this->bypass_level) {
1803 1803 $cookie = $this->generateBypassCookie();
1804 1804 if ($cookie) {
1805 - $this->setCookie(WPRProtectFW_V669::BYPASS_COOKIE_NAME, $cookie);
1805 + $this->setCookie(WPRProtectFW_V672::BYPASS_COOKIE_NAME, $cookie);
1806 1806 }
1807 1807 }
1808 1808 }
1809 1809 }