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