| @@ -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 = '5.41'; | |
| 12 | + public $brand_option = 'bv_whitelabel_infos'; | |
| 13 | + public $wp_lp_whitelabel_option = 'wprLpWhitelabelConf'; | |
| 14 | + public $version = '6.36'; | |
| 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 = '4'; | |
| 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); |
| @@ -56,28 +58,63 @@ | ||
| 56 | 58 | |
| 57 | 59 | return false; |
| 58 | 60 | } |
| 59 | 61 | |
| 62 | + public function getConnectionKey() { | |
| 63 | + require_once dirname( __FILE__ ) . '/recover.php'; | |
| 64 | + $bvsiteinfo = new WPRWPSiteInfo(); | |
| 65 | + $encoded_url = base64_encode($bvsiteinfo->siteurl()); | |
| 66 | + $secret = WPRRecover::defaultSecret($this->settings); | |
| 67 | + | |
| 68 | + return base64_encode("v2:".$secret.":".$encoded_url.":".$this->plugname); | |
| 69 | + } | |
| 70 | + | |
| 71 | + public function getDefaultSecret() { | |
| 72 | + require_once dirname( __FILE__ ) . '/recover.php'; | |
| 73 | + $bvsiteinfo = new WPRWPSiteInfo(); | |
| 74 | + return WPRRecover::defaultSecret($this->settings); | |
| 75 | + } | |
| 76 | + | |
| 77 | + public function getLatestElementorDBVersion($file) { | |
| 78 | + $managerClass = $file === "elementor/elementor.php" ? '\Elementor\Core\Upgrade\Manager' : '\ElementorPro\Core\Upgrade\Manager'; | |
| 79 | + | |
| 80 | + if (!class_exists($managerClass)) { | |
| 81 | + return false; | |
| 82 | + } | |
| 83 | + | |
| 84 | + $manager = new $managerClass(); | |
| 85 | + return $manager->get_new_version(); | |
| 86 | + } | |
| 87 | + | |
| 60 | 88 | public static function getRequestID() { |
| 61 | 89 | if (!defined("BV_REQUEST_ID")) { |
| 62 | - define("BV_REQUEST_ID", uniqid(mt_rand())); | |
| 90 | + define("BV_REQUEST_ID", uniqid(mt_rand())); // phpcs:ignore WordPress.WP.AlternativeFunctions.rand_mt_rand | |
| 63 | 91 | } |
| 64 | 92 | return BV_REQUEST_ID; |
| 65 | 93 | } |
| 66 | 94 | |
| 67 | - public function canSetCWBranding() { | |
| 68 | - if (WPRWPSiteInfo::isCWServer()) { | |
| 95 | + public function canWhiteLabel($slug = NULL) { | |
| 96 | + // phpcs:disable WordPress.Security.NonceVerification.Recommended | |
| 97 | + if (array_key_exists("bv_override_global_whitelabel", $_REQUEST)) { | |
| 98 | + return false; | |
| 99 | + } | |
| 100 | + if (array_key_exists("bv_override_plugin_whitelabel", $_REQUEST) && isset($slug) && | |
| 101 | + $_REQUEST["bv_override_plugin_whitelabel"] === $slug) { | |
| 102 | + return false; | |
| 103 | + } | |
| 104 | + // phpcs:enable WordPress.Security.NonceVerification.Recommended | |
| 105 | + return true; | |
| 106 | + } | |
| 69 | 107 | |
| 70 | - $bot_protect_accounts = WPRAccount::accountsByType($this->settings, 'botprotect'); | |
| 71 | - if (sizeof($bot_protect_accounts) >= 1) | |
| 72 | - return true; | |
| 73 | - | |
| 74 | - $bot_protect_accounts = WPRAccount::accountsByPattern($this->settings, 'email', '/@cw_user\.com$/'); | |
| 75 | - if (sizeof($bot_protect_accounts) >= 1) | |
| 76 | - return true; | |
| 108 | + public function getPluginWhitelabelInfo($slug = null) { | |
| 109 | + if ($slug === null) { | |
| 110 | + $slug = $this->slug; | |
| 77 | 111 | } |
| 78 | - | |
| 79 | - return false; | |
| 112 | + $whitelabel_infos = $this->getPluginsWhitelabelInfos(); | |
| 113 | + if (!array_key_exists($slug, $whitelabel_infos) || !is_array($whitelabel_infos[$slug])) { | |
| 114 | + return array(); | |
| 115 | + } | |
| 116 | + return $whitelabel_infos[$slug]; | |
| 80 | 117 | } |
| 81 | 118 | |
| 82 | 119 | public function getBrandInfo() { |
| 83 | 120 | return $this->settings->getOption($this->brand_option); |
| @@ -82,19 +119,40 @@ | ||
| 82 | 119 | public function getBrandInfo() { |
| 83 | 120 | return $this->settings->getOption($this->brand_option); |
| 84 | 121 | } |
| 85 | 122 | |
| 123 | + public function getPluginsWhitelabelInfos() { | |
| 124 | + $whitelabel_infos = $this->settings->getOption($this->brand_option); | |
| 125 | + return is_array($whitelabel_infos) ? $whitelabel_infos : array(); | |
| 126 | + } | |
| 127 | + | |
| 128 | + public function getLPWhitelabelInfo() { | |
| 129 | + $infos = $this->settings->getOption($this->wp_lp_whitelabel_option); | |
| 130 | + return is_array($infos) ? $infos : array(); | |
| 131 | + } | |
| 132 | + | |
| 133 | + public function getPluginsWhitelabelInfoByTitle() { | |
| 134 | + $whitelabel_infos = $this->getPluginsWhitelabelInfos(); | |
| 135 | + $whitelabel_infos_by_title = array(); | |
| 136 | + foreach ($whitelabel_infos as $slug => $whitelabel_info) { | |
| 137 | + if (is_array($whitelabel_info) && array_key_exists('default_title', $whitelabel_info) && isset($whitelabel_info['default_title'])) { | |
| 138 | + $whitelabel_info['slug'] = $slug; | |
| 139 | + $whitelabel_infos_by_title[$whitelabel_info['default_title']] = $whitelabel_info; | |
| 140 | + } | |
| 141 | + } | |
| 142 | + return $whitelabel_infos_by_title; | |
| 143 | + } | |
| 144 | + | |
| 86 | 145 | public function getBrandName() { |
| 87 | - $brand = $this->getBrandInfo(); | |
| 146 | + $brand = $this->getPluginWhitelabelInfo(); | |
| 88 | 147 | if (is_array($brand) && array_key_exists('menuname', $brand)) { |
| 89 | 148 | return $brand['menuname']; |
| 90 | 149 | } |
| 91 | - | |
| 92 | 150 | return $this->brandname; |
| 93 | 151 | } |
| 94 | 152 | |
| 95 | 153 | public function getBrandIcon() { |
| 96 | - $brand = $this->getBrandInfo(); | |
| 154 | + $brand = $this->getPluginWhitelabelInfo(); | |
| 97 | 155 | if (is_array($brand) && array_key_exists('brand_icon', $brand)) { |
| 98 | 156 | return $brand['brand_icon']; |
| 99 | 157 | } |
| 100 | 158 | return $this->brand_icon; |
| @@ -108,9 +166,9 @@ | ||
| 108 | 166 | public function appUrl() { |
| 109 | 167 | if (defined('BV_APP_URL')) { |
| 110 | 168 | return BV_APP_URL; |
| 111 | 169 | } else { |
| 112 | - $brand = $this->getBrandInfo(); | |
| 170 | + $brand = $this->getPluginWhitelabelInfo(); | |
| 113 | 171 | if (is_array($brand) && array_key_exists('appurl', $brand)) { |
| 114 | 172 | return $brand['appurl']; |
| 115 | 173 | } |
| 116 | 174 | return $this->appurl; |