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
wpremote / info.php

info.php in The WP Remote WordPress Plugin trunk, at info.php

242 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit;
4 if (!class_exists('WPRInfo')) :
5 class WPRInfo {
6 public $settings;
7 public $config;
8 public $plugname = 'wpremote';
9 public $brandname = 'WP Remote';
10 public $badgeinfo = 'wprbadge';
11 public $ip_header_option = 'wpripheader';
12 public $brand_option = 'bv_whitelabel_infos';
13 public $wp_lp_whitelabel_option = 'wprLpWhitelabelConf';
14 public $version = '6.72';
15 public $webpage = 'https://wpremote.com';
16 public $appurl = 'https://app.wpremote.com';
17 public $slug = 'wpremote/plugin.php';
18 public $plug_redirect = 'wprredirect';
19 public $logo = '../img/wprlogo.png';
20 public $brand_icon = '/img/icon.png';
21 public $services_option_name = 'wprconfig';
22 public $author = 'WP Remote';
23 public $title = 'WP Remote';
24
25 const DB_VERSION = '5';
26 const AL_CONF_VERSION = '1.1';
27
28 public function __construct($settings) {
29 $this->settings = $settings;
30 $this->config = $this->settings->getOption($this->services_option_name);
31 }
32
33 public function getCurrentDBVersion() {
34 $bvconfig = $this->config;
35 if ($bvconfig && array_key_exists('db_version', $bvconfig)) {
36 return $bvconfig['db_version'];
37 }
38 return false;
39 }
40
41 public function hasValidDBVersion() {
42 return WPRInfo::DB_VERSION === $this->getCurrentDBVersion();
43 }
44
45 public function getLatestWooCommerceDBVersion() {
46 if (defined('WC_ABSPATH') && file_exists(WC_ABSPATH . 'includes/class-wc-install.php')) {
47 include_once WC_ABSPATH . 'includes/class-wc-install.php';
48
49 if (class_exists('WC_Install')) {
50 $update_versions = array_keys(WC_Install::get_db_update_callbacks());
51
52 if (!empty($update_versions)) {
53 asort($update_versions);
54 return end($update_versions);
55 }
56 }
57 }
58
59 return false;
60 }
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 $tag = WPRRecover::connectionTag($this->settings);
68
69 #No tag means this site has no salt material in wp-config.php, and there
70 #is no connection key that would be safe to hand out.
71 if (empty($secret) || empty($tag)) {
72 return null;
73 }
74
75 return base64_encode("v3:".$secret.":".$encoded_url.":".$this->plugname.":".$tag);
76 }
77
78 public function getLatestElementorDBVersion($file) {
79 $managerClass = $file === "elementor/elementor.php" ? '\Elementor\Core\Upgrade\Manager' : '\ElementorPro\Core\Upgrade\Manager';
80
81 if (!class_exists($managerClass)) {
82 return false;
83 }
84
85 $manager = new $managerClass();
86 return $manager->get_new_version();
87 }
88
89 public static function getRequestID() {
90 if (!defined("WPR_REQUEST_ID")) {
91 define("WPR_REQUEST_ID", uniqid(mt_rand())); // phpcs:ignore WordPress.WP.AlternativeFunctions.rand_mt_rand
92 }
93 return WPR_REQUEST_ID;
94 }
95
96 public function canWhiteLabel($slug = NULL) {
97 // phpcs:disable WordPress.Security.NonceVerification.Recommended
98 if (array_key_exists("bv_override_global_whitelabel", $_REQUEST)) {
99 return false;
100 }
101 if (array_key_exists("bv_override_plugin_whitelabel", $_REQUEST) && isset($slug) &&
102 $_REQUEST["bv_override_plugin_whitelabel"] === $slug) {
103 return false;
104 }
105 // phpcs:enable WordPress.Security.NonceVerification.Recommended
106 return true;
107 }
108
109 public function getPluginWhitelabelInfo($slug = null) {
110 if ($slug === null) {
111 $slug = $this->slug;
112 }
113 $whitelabel_infos = $this->getPluginsWhitelabelInfos();
114 if (!array_key_exists($slug, $whitelabel_infos) || !is_array($whitelabel_infos[$slug])) {
115 return array();
116 }
117 return $whitelabel_infos[$slug];
118 }
119
120 public function getBrandInfo() {
121 return $this->settings->getOption($this->brand_option);
122 }
123
124 public function getPluginsWhitelabelInfos() {
125 $whitelabel_infos = $this->settings->getOption($this->brand_option);
126 return is_array($whitelabel_infos) ? $whitelabel_infos : array();
127 }
128
129 public function getLPWhitelabelInfo() {
130 $infos = $this->settings->getOption($this->wp_lp_whitelabel_option);
131 return is_array($infos) ? $infos : array();
132 }
133
134 public function getPluginsWhitelabelInfoByTitle() {
135 $whitelabel_infos = $this->getPluginsWhitelabelInfos();
136 $whitelabel_infos_by_title = array();
137 foreach ($whitelabel_infos as $slug => $whitelabel_info) {
138 if (is_array($whitelabel_info) && array_key_exists('default_title', $whitelabel_info) && isset($whitelabel_info['default_title'])) {
139 $whitelabel_info['slug'] = $slug;
140 $whitelabel_infos_by_title[$whitelabel_info['default_title']] = $whitelabel_info;
141 }
142 }
143 return $whitelabel_infos_by_title;
144 }
145
146 public function getBrandName() {
147 $brand = $this->getPluginWhitelabelInfo();
148 if (is_array($brand) && array_key_exists('menuname', $brand)) {
149 return $brand['menuname'];
150 }
151 return $this->brandname;
152 }
153
154 public function getBrandIcon() {
155 $brand = $this->getPluginWhitelabelInfo();
156 if (is_array($brand) && array_key_exists('brand_icon', $brand)) {
157 return $brand['brand_icon'];
158 }
159 return $this->brand_icon;
160 }
161
162 public function getWatchTime() {
163 $time = $this->settings->getOption('bvwatchtime');
164 return ($time ? $time : 0);
165 }
166
167 public function appUrl() {
168 if (defined('BV_APP_URL')) {
169 return BV_APP_URL;
170 } else {
171 $brand = $this->getPluginWhitelabelInfo();
172 if (is_array($brand) && array_key_exists('appurl', $brand)) {
173 return $brand['appurl'];
174 }
175 return $this->appurl;
176 }
177 }
178
179 public function isActivePlugin() {
180 $expiry_time = time() - (3 * 24 * 3600);
181 return ($this->getWatchTime() > $expiry_time);
182 }
183
184 public function isValidEnvironment(){
185 $bvsiteinfo = new WPRWPSiteInfo();
186 $bvconfig = $this->config;
187
188 if (is_multisite()) {
189 return true;
190 } elseif ($bvconfig && array_key_exists("siteurl_scheme", $bvconfig)) {
191 $siteurl = $bvsiteinfo->siteurl('', $bvconfig["siteurl_scheme"]);
192 if (array_key_exists("abspath", $bvconfig) &&
193 array_key_exists("siteurl", $bvconfig) && !empty($siteurl)) {
194 return ($bvconfig["abspath"] == ABSPATH && $bvconfig["siteurl"] == $siteurl);
195 }
196 }
197 return true;
198 }
199
200 public function isProtectModuleEnabled() {
201 return $this->isServiceActive("protect") && $this->isValidEnvironment();
202 }
203
204 public function isDynSyncModuleEnabled() {
205 if ($this->isServiceActive("dynsync")) {
206 $dynconfig = $this->config['dynsync'];
207 if (array_key_exists('dynplug', $dynconfig) && ($dynconfig['dynplug'] === $this->plugname)) {
208 return true;
209 }
210 }
211 return false;
212 }
213
214 public function isServiceActive($service) {
215 $bvconfig = $this->config;
216 if ($bvconfig && array_key_exists('services', $bvconfig)) {
217 return in_array($service, $bvconfig['services']) && $this->isActivePlugin();
218 }
219 return false;
220 }
221
222 public function isActivateRedirectSet() {
223 return ($this->settings->getOption($this->plug_redirect) === 'yes') ? true : false;
224 }
225
226 public function isMalcare() {
227 return $this->getBrandName() === 'MalCare';
228 }
229
230 public function isBlogvault() {
231 return $this->getBrandName() === 'BlogVault';
232 }
233
234 public function info() {
235 return array(
236 "bvversion" => $this->version,
237 "sha1" => "true",
238 "plugname" => $this->plugname
239 );
240 }
241 }
242 endif;