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/protect.php +33 -32 5.38trunk View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit;
3 3
4 -if (!class_exists('MCProtect')) :
4 +if (!class_exists('WPRProtect_V672')) :
5 5 require_once dirname( __FILE__ ) . '/logger.php';
6 6 require_once dirname( __FILE__ ) . '/ipstore.php';
7 7 require_once dirname( __FILE__ ) . '/request.php';
8 8 require_once dirname( __FILE__ ) . '/wp_user.php';
@@ -10,9 +10,9 @@
10 10 require_once dirname( __FILE__ ) . '/fw.php';
11 11 require_once dirname( __FILE__ ) . '/lp.php';
12 12 require_once dirname( __FILE__ ) . '/../helper.php';
13 13
14 -class MCProtect {
14 +class WPRProtect_V672 {
15 15 public static $settings;
16 16 public static $db;
17 17 public static $info;
18 18
@@ -21,15 +21,19 @@
21 21
22 22 const CONF_VERSION = '2';
23 23
24 24 public static function init($mode) {
25 - if ($mode == MCProtect::MODE_PREPEND) {
25 + if (defined('WP_CLI') && WP_CLI) {
26 + return false;
27 + }
28 +
29 + if ($mode == WPRProtect_V672::MODE_PREPEND) {
26 30 $config_file = MCDATAPATH . MCCONFKEY . '-' . 'mc.conf';
27 - $config = MCProtectUtils::parseFile($config_file);
31 + $config = WPRProtectUtils_V672::parseFile($config_file);
28 32
29 33 if (empty($config['time']) || !($config['time'] > time() - (48*3600)) ||
30 34 !isset($config['mc_conf_version']) ||
31 - (MCProtect::CONF_VERSION !== $config['mc_conf_version'])) {
35 + (WPRProtect_V672::CONF_VERSION !== $config['mc_conf_version'])) {
32 36 return false;
33 37
34 38 }
35 39
@@ -34,22 +38,18 @@
34 38 }
35 39
36 40 $brand_name = array_key_exists('brandname', $config) ? $config['brandname'] : 'Protect';
37 41 $request_ip_header = array_key_exists('ipheader', $config) ? $config['ipheader'] : null;
38 - $request = new MCProtectRequest($request_ip_header);
42 + $req_config = array_key_exists('reqconfig', $config) ? $config['reqconfig'] : array();
43 + $request = new WPRProtectRequest_V672($request_ip_header, $req_config);
39 44 $fw_config = array_key_exists('fw', $config) ? $config['fw'] : array();
40 45
41 - MCProtectFW::getInstance($mode, $request, $fw_config, $brand_name)->init();
46 + WPRProtectFW_V672::getInstance($mode, $request, $fw_config, $brand_name)->init();
42 47 } else {
43 - //For backward compatibility.
44 - self::$settings = new WPRWPSettings();
45 - self::$db = new WPRWPDb();
46 - self::$info = new WPRInfo(self::$settings);
47 -
48 48 $plug_config = self::$settings->getOption(self::$info->services_option_name);
49 49 $config = array_key_exists('protect', $plug_config) ? $plug_config['protect'] : array();
50 50 if (!is_array($config) || !array_key_exists('mc_conf_version', $config) ||
51 - (MCProtect::CONF_VERSION !== $config['mc_conf_version'])) {
51 + (WPRProtect_V672::CONF_VERSION !== $config['mc_conf_version'])) {
52 52
53 53 return false;
54 54 }
55 55
@@ -54,14 +54,15 @@
54 54 }
55 55
56 56 $brand_name = self::$info->getBrandName();
57 57 $request_ip_header = array_key_exists('ipheader', $config) ? $config['ipheader'] : null;
58 - $request = new MCProtectRequest($request_ip_header);
58 + $req_config = array_key_exists('reqconfig', $config) ? $config['reqconfig'] : array();
59 + $request = new WPRProtectRequest_V672($request_ip_header, $req_config);
59 60 $fw_config = array_key_exists('fw', $config) ? $config['fw'] : array();
60 61 $lp_config = array_key_exists('lp', $config) ? $config['lp'] : array();
61 62
62 - MCProtectFW::getInstance($mode, $request, $fw_config, $brand_name)->init();
63 - MCProtectLP::getInstance($request, $lp_config, $brand_name)->init();
63 + WPRProtectFW_V672::getInstance($mode, $request, $fw_config, $brand_name)->init();
64 + WPRProtectLP_V672::getInstance($request, $lp_config, $brand_name)->init();
64 65 }
65 66 }
66 67
67 68 public static function uninstall() {
@@ -66,15 +67,15 @@
66 67
67 68 public static function uninstall() {
68 69 self::$settings->deleteOption('bvptconf');
69 70 self::$settings->deleteOption('bvptplug');
70 - MCProtectIpstore::uninstall();
71 - MCProtectFW::uninstall();
72 - MCProtectLP::uninstall();
71 + WPRProtectIpstore_V672::uninstall();
72 + WPRProtectFW_V672::uninstall();
73 + WPRProtectLP_V672::uninstall();
73 74
74 - MCProtect::removeWPPrepend();
75 - MCProtect::removePHPPrepend();
76 - MCProtect::removeMCData();
75 + WPRProtect_V672::removeWPPrepend();
76 + WPRProtect_V672::removePHPPrepend();
77 + WPRProtect_V672::removeMCData();
77 78
78 79 return true;
79 80 }
80 81
@@ -79,10 +80,10 @@
79 80 }
80 81
81 82 private static function removeWPPrepend() {
82 83 $wp_conf_paths = array(
83 - dirname(ABSPATH) . "/wp-config.php",
84 - dirname(ABSPATH) . "/../wp-config.php"
84 + rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/wp-config.php",
85 + rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/../wp-config.php"
85 86 );
86 87
87 88 if (file_exists($wp_conf_paths[0])) {
88 89 $fname = $wp_conf_paths[0];
@@ -91,34 +92,34 @@
91 92 } else {
92 93 return;
93 94 }
94 95
95 - $pattern = "@include '" . dirname(ABSPATH) . "/malcare-waf.php" . "';";
96 + $pattern = "@include '" . rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/malcare-waf.php" . "';";
96 97
97 - MCProtectUtils::fileRemovePattern($fname, $pattern);
98 + WPRProtectUtils_V672::fileRemovePattern($fname, $pattern);
98 99 }
99 100
100 101 private static function removePHPPrepend() {
101 - MCProtect::removeHtaccessPrepend();
102 - MCProtect::removeUseriniPrepend();
102 + WPRProtect_V672::removeHtaccessPrepend();
103 + WPRProtect_V672::removeUseriniPrepend();
103 104 }
104 105
105 106 private static function removeHtaccessPrepend() {
106 107 $pattern = "/# MalCare WAF(.|\n)*# END MalCare WAF/i";
107 108
108 - MCProtectUtils::fileRemovePattern(dirname(ABSPATH) . "/.htaccess", $pattern, true);
109 + WPRProtectUtils_V672::fileRemovePattern(rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/.htaccess", $pattern, true);
109 110 }
110 111
111 112 private static function removeUseriniPrepend() {
112 113 $pattern = "/; MalCare WAF(.|\n)*; END MalCare WAF/i";
113 114
114 - MCProtectUtils::fileRemovePattern(dirname(ABSPATH) . "/.user.ini", $pattern, true);
115 + WPRProtectUtils_V672::fileRemovePattern(rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/.user.ini", $pattern, true);
115 116 }
116 117
117 118 private static function removeMCData() {
118 - $content_dir = defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : dirname(ABSPATH) . "/wp-content";
119 + $content_dir = defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : rtrim(ABSPATH, DIRECTORY_SEPARATOR) . "/wp-content";
119 120 $mc_data_dir = $content_dir . "/mc_data";
120 121
121 - MCProtectUtils::rrmdir($mc_data_dir);
122 + WPRProtectUtils_V672::rrmdir($mc_data_dir);
122 123 }
123 124 }
124 125 endif;