| @@ -8,10 +8,11 @@ | ||
| 8 | 8 | public $plugname = 'wpremote'; |
| 9 | 9 | public $brandname = 'WP Remote'; |
| 10 | 10 | public $badgeinfo = 'wprbadge'; |
| 11 | 11 | public $ip_header_option = 'wpripheader'; |
| 12 | - public $brand_option = 'wprbrand'; | |
| 13 | - public $version = '4.87'; | |
| 12 | + public $brand_option = 'bv_whitelabel_infos'; | |
| 13 | + public $wp_lp_whitelabel_option = 'wprLpWhitelabelConf'; | |
| 14 | + public $version = '6.76'; | |
| 14 | 15 | public $webpage = 'https://wpremote.com'; |
| 15 | 16 | public $appurl = 'https://app.wpremote.com'; |
| 16 | 17 | public $slug = 'wpremote/plugin.php'; |
| 17 | 18 | public $plug_redirect = 'wprredirect'; |
| @@ -20,9 +21,10 @@ | ||
| 20 | 21 | public $services_option_name = 'wprconfig'; |
| 21 | 22 | public $author = 'WP Remote'; |
| 22 | 23 | public $title = 'WP Remote'; |
| 23 | 24 | |
| 24 | - const DB_VERSION = '3'; | |
| 25 | + const DB_VERSION = '5'; | |
| 26 | + const AL_CONF_VERSION = '1.1'; | |
| 25 | 27 | |
| 26 | 28 | public function __construct($settings) { |
| 27 | 29 | $this->settings = $settings; |
| 28 | 30 | $this->config = $this->settings->getOption($this->services_option_name); |
| @@ -35,49 +37,131 @@ | ||
| 35 | 37 | } |
| 36 | 38 | return false; |
| 37 | 39 | } |
| 38 | 40 | |
| 41 | + # The server leases capture for a few days at a time; a stale configuration | |
| 42 | + # registers nothing. | |
| 43 | + public function isActivityLogActive() { | |
| 44 | + $config = isset($this->config['activity_log']) ? $this->config['activity_log'] : null; | |
| 45 | + return $this->hasValidDBVersion() && is_array($config) && !empty($config['hooks']) && | |
| 46 | + isset($config['enabled_until']) && is_numeric($config['enabled_until']) && $config['enabled_until'] > time(); | |
| 47 | + } | |
| 48 | + | |
| 39 | 49 | public function hasValidDBVersion() { |
| 40 | 50 | return WPRInfo::DB_VERSION === $this->getCurrentDBVersion(); |
| 41 | 51 | } |
| 42 | 52 | |
| 43 | - public static function getRequestID() { | |
| 44 | - if (!defined("BV_REQUEST_ID")) { | |
| 45 | - define("BV_REQUEST_ID", uniqid(mt_rand())); | |
| 53 | + public function getLatestWooCommerceDBVersion() { | |
| 54 | + if (defined('WC_ABSPATH') && file_exists(WC_ABSPATH . 'includes/class-wc-install.php')) { | |
| 55 | + include_once WC_ABSPATH . 'includes/class-wc-install.php'; | |
| 56 | + | |
| 57 | + if (class_exists('WC_Install')) { | |
| 58 | + $update_versions = array_keys(WC_Install::get_db_update_callbacks()); | |
| 59 | + | |
| 60 | + if (!empty($update_versions)) { | |
| 61 | + asort($update_versions); | |
| 62 | + return end($update_versions); | |
| 63 | + } | |
| 64 | + } | |
| 46 | 65 | } |
| 47 | - return BV_REQUEST_ID; | |
| 66 | + | |
| 67 | + return false; | |
| 48 | 68 | } |
| 49 | 69 | |
| 50 | - public function canSetCWBranding() { | |
| 51 | - if (WPRWPSiteInfo::isCWServer()) { | |
| 70 | + public function getConnectionKey() { | |
| 71 | + require_once dirname( __FILE__ ) . '/recover.php'; | |
| 72 | + $bvsiteinfo = new WPRWPSiteInfo(); | |
| 73 | + $encoded_url = base64_encode($bvsiteinfo->siteurl()); | |
| 74 | + $secret = WPRRecover::defaultSecret($this->settings); | |
| 75 | + $tag = WPRRecover::connectionTag($this->settings); | |
| 52 | 76 | |
| 53 | - $bot_protect_accounts = WPRAccount::accountsByType($this->settings, 'botprotect'); | |
| 54 | - if (sizeof($bot_protect_accounts) >= 1) | |
| 55 | - return true; | |
| 77 | + #No tag means this site has no salt material in wp-config.php, and there | |
| 78 | + #is no connection key that would be safe to hand out. | |
| 79 | + if (empty($secret) || empty($tag)) { | |
| 80 | + return null; | |
| 81 | + } | |
| 56 | 82 | |
| 57 | - $bot_protect_accounts = WPRAccount::accountsByPattern($this->settings, 'email', '/@cw_user\.com$/'); | |
| 58 | - if (sizeof($bot_protect_accounts) >= 1) | |
| 59 | - return true; | |
| 83 | + return base64_encode("v3:".$secret.":".$encoded_url.":".$this->plugname.":".$tag); | |
| 84 | + } | |
| 85 | + | |
| 86 | + public function getLatestElementorDBVersion($file) { | |
| 87 | + $managerClass = $file === "elementor/elementor.php" ? '\Elementor\Core\Upgrade\Manager' : '\ElementorPro\Core\Upgrade\Manager'; | |
| 88 | + | |
| 89 | + if (!class_exists($managerClass)) { | |
| 90 | + return false; | |
| 60 | 91 | } |
| 61 | 92 | |
| 62 | - return false; | |
| 93 | + $manager = new $managerClass(); | |
| 94 | + return $manager->get_new_version(); | |
| 63 | 95 | } |
| 64 | 96 | |
| 97 | + public static function getRequestID() { | |
| 98 | + if (!defined("WPR_REQUEST_ID")) { | |
| 99 | + define("WPR_REQUEST_ID", uniqid(mt_rand())); // phpcs:ignore WordPress.WP.AlternativeFunctions.rand_mt_rand | |
| 100 | + } | |
| 101 | + return WPR_REQUEST_ID; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public function canWhiteLabel($slug = NULL) { | |
| 105 | + // phpcs:disable WordPress.Security.NonceVerification.Recommended | |
| 106 | + if (array_key_exists("bv_override_global_whitelabel", $_REQUEST)) { | |
| 107 | + return false; | |
| 108 | + } | |
| 109 | + if (array_key_exists("bv_override_plugin_whitelabel", $_REQUEST) && isset($slug) && | |
| 110 | + $_REQUEST["bv_override_plugin_whitelabel"] === $slug) { | |
| 111 | + return false; | |
| 112 | + } | |
| 113 | + // phpcs:enable WordPress.Security.NonceVerification.Recommended | |
| 114 | + return true; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public function getPluginWhitelabelInfo($slug = null) { | |
| 118 | + if ($slug === null) { | |
| 119 | + $slug = $this->slug; | |
| 120 | + } | |
| 121 | + $whitelabel_infos = $this->getPluginsWhitelabelInfos(); | |
| 122 | + if (!array_key_exists($slug, $whitelabel_infos) || !is_array($whitelabel_infos[$slug])) { | |
| 123 | + return array(); | |
| 124 | + } | |
| 125 | + return $whitelabel_infos[$slug]; | |
| 126 | + } | |
| 127 | + | |
| 65 | 128 | public function getBrandInfo() { |
| 66 | 129 | return $this->settings->getOption($this->brand_option); |
| 67 | 130 | } |
| 68 | 131 | |
| 132 | + public function getPluginsWhitelabelInfos() { | |
| 133 | + $whitelabel_infos = $this->settings->getOption($this->brand_option); | |
| 134 | + return is_array($whitelabel_infos) ? $whitelabel_infos : array(); | |
| 135 | + } | |
| 136 | + | |
| 137 | + public function getLPWhitelabelInfo() { | |
| 138 | + $infos = $this->settings->getOption($this->wp_lp_whitelabel_option); | |
| 139 | + return is_array($infos) ? $infos : array(); | |
| 140 | + } | |
| 141 | + | |
| 142 | + public function getPluginsWhitelabelInfoByTitle() { | |
| 143 | + $whitelabel_infos = $this->getPluginsWhitelabelInfos(); | |
| 144 | + $whitelabel_infos_by_title = array(); | |
| 145 | + foreach ($whitelabel_infos as $slug => $whitelabel_info) { | |
| 146 | + if (is_array($whitelabel_info) && array_key_exists('default_title', $whitelabel_info) && isset($whitelabel_info['default_title'])) { | |
| 147 | + $whitelabel_info['slug'] = $slug; | |
| 148 | + $whitelabel_infos_by_title[$whitelabel_info['default_title']] = $whitelabel_info; | |
| 149 | + } | |
| 150 | + } | |
| 151 | + return $whitelabel_infos_by_title; | |
| 152 | + } | |
| 153 | + | |
| 69 | 154 | public function getBrandName() { |
| 70 | - $brand = $this->getBrandInfo(); | |
| 155 | + $brand = $this->getPluginWhitelabelInfo(); | |
| 71 | 156 | if (is_array($brand) && array_key_exists('menuname', $brand)) { |
| 72 | 157 | return $brand['menuname']; |
| 73 | 158 | } |
| 74 | - | |
| 75 | 159 | return $this->brandname; |
| 76 | 160 | } |
| 77 | 161 | |
| 78 | 162 | public function getBrandIcon() { |
| 79 | - $brand = $this->getBrandInfo(); | |
| 163 | + $brand = $this->getPluginWhitelabelInfo(); | |
| 80 | 164 | if (is_array($brand) && array_key_exists('brand_icon', $brand)) { |
| 81 | 165 | return $brand['brand_icon']; |
| 82 | 166 | } |
| 83 | 167 | return $this->brand_icon; |
| @@ -91,9 +175,9 @@ | ||
| 91 | 175 | public function appUrl() { |
| 92 | 176 | if (defined('BV_APP_URL')) { |
| 93 | 177 | return BV_APP_URL; |
| 94 | 178 | } else { |
| 95 | - $brand = $this->getBrandInfo(); | |
| 179 | + $brand = $this->getPluginWhitelabelInfo(); | |
| 96 | 180 | if (is_array($brand) && array_key_exists('appurl', $brand)) { |
| 97 | 181 | return $brand['appurl']; |
| 98 | 182 | } |
| 99 | 183 | return $this->appurl; |
| @@ -162,5 +246,5 @@ | ||
| 162 | 246 | "plugname" => $this->plugname |
| 163 | 247 | ); |
| 164 | 248 | } |
| 165 | 249 | } |
| 166 | -endif; | |
| 250 | +endif; | |