| 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 = 'wprbrand'; |
| 13 |
public $version = '5.24'; |
| 14 |
public $webpage = 'https://wpremote.com'; |
| 15 |
public $appurl = 'https://app.wpremote.com'; |
| 16 |
public $slug = 'wpremote/plugin.php'; |
| 17 |
public $plug_redirect = 'wprredirect'; |
| 18 |
public $logo = '../img/wprlogo.png'; |
| 19 |
public $brand_icon = '/img/icon.png'; |
| 20 |
public $services_option_name = 'wprconfig'; |
| 21 |
public $author = 'WP Remote'; |
| 22 |
public $title = 'WP Remote'; |
| 23 |
|
| 24 |
const DB_VERSION = '4'; |
| 25 |
|
| 26 |
public function __construct($settings) { |
| 27 |
$this->settings = $settings; |
| 28 |
$this->config = $this->settings->getOption($this->services_option_name); |
| 29 |
} |
| 30 |
|
| 31 |
public function getCurrentDBVersion() { |
| 32 |
$bvconfig = $this->config; |
| 33 |
if ($bvconfig && array_key_exists('db_version', $bvconfig)) { |
| 34 |
return $bvconfig['db_version']; |
| 35 |
} |
| 36 |
return false; |
| 37 |
} |
| 38 |
|
| 39 |
public function hasValidDBVersion() { |
| 40 |
return WPRInfo::DB_VERSION === $this->getCurrentDBVersion(); |
| 41 |
} |
| 42 |
|
| 43 |
public static function getRequestID() { |
| 44 |
if (!defined("BV_REQUEST_ID")) { |
| 45 |
define("BV_REQUEST_ID", uniqid(mt_rand())); |
| 46 |
} |
| 47 |
return BV_REQUEST_ID; |
| 48 |
} |
| 49 |
|
| 50 |
public function canSetCWBranding() { |
| 51 |
if (WPRWPSiteInfo::isCWServer()) { |
| 52 |
|
| 53 |
$bot_protect_accounts = WPRAccount::accountsByType($this->settings, 'botprotect'); |
| 54 |
if (sizeof($bot_protect_accounts) >= 1) |
| 55 |
return true; |
| 56 |
|
| 57 |
$bot_protect_accounts = WPRAccount::accountsByPattern($this->settings, 'email', '/@cw_user\.com$/'); |
| 58 |
if (sizeof($bot_protect_accounts) >= 1) |
| 59 |
return true; |
| 60 |
} |
| 61 |
|
| 62 |
return false; |
| 63 |
} |
| 64 |
|
| 65 |
public function getBrandInfo() { |
| 66 |
return $this->settings->getOption($this->brand_option); |
| 67 |
} |
| 68 |
|
| 69 |
public function getBrandName() { |
| 70 |
$brand = $this->getBrandInfo(); |
| 71 |
if (is_array($brand) && array_key_exists('menuname', $brand)) { |
| 72 |
return $brand['menuname']; |
| 73 |
} |
| 74 |
|
| 75 |
return $this->brandname; |
| 76 |
} |
| 77 |
|
| 78 |
public function getBrandIcon() { |
| 79 |
$brand = $this->getBrandInfo(); |
| 80 |
if (is_array($brand) && array_key_exists('brand_icon', $brand)) { |
| 81 |
return $brand['brand_icon']; |
| 82 |
} |
| 83 |
return $this->brand_icon; |
| 84 |
} |
| 85 |
|
| 86 |
public function getWatchTime() { |
| 87 |
$time = $this->settings->getOption('bvwatchtime'); |
| 88 |
return ($time ? $time : 0); |
| 89 |
} |
| 90 |
|
| 91 |
public function appUrl() { |
| 92 |
if (defined('BV_APP_URL')) { |
| 93 |
return BV_APP_URL; |
| 94 |
} else { |
| 95 |
$brand = $this->getBrandInfo(); |
| 96 |
if (is_array($brand) && array_key_exists('appurl', $brand)) { |
| 97 |
return $brand['appurl']; |
| 98 |
} |
| 99 |
return $this->appurl; |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
public function isActivePlugin() { |
| 104 |
$expiry_time = time() - (3 * 24 * 3600); |
| 105 |
return ($this->getWatchTime() > $expiry_time); |
| 106 |
} |
| 107 |
|
| 108 |
public function isValidEnvironment(){ |
| 109 |
$bvsiteinfo = new WPRWPSiteInfo(); |
| 110 |
$bvconfig = $this->config; |
| 111 |
|
| 112 |
if (is_multisite()) { |
| 113 |
return true; |
| 114 |
} elseif ($bvconfig && array_key_exists("siteurl_scheme", $bvconfig)) { |
| 115 |
$siteurl = $bvsiteinfo->siteurl('', $bvconfig["siteurl_scheme"]); |
| 116 |
if (array_key_exists("abspath", $bvconfig) && |
| 117 |
array_key_exists("siteurl", $bvconfig) && !empty($siteurl)) { |
| 118 |
return ($bvconfig["abspath"] == ABSPATH && $bvconfig["siteurl"] == $siteurl); |
| 119 |
} |
| 120 |
} |
| 121 |
return true; |
| 122 |
} |
| 123 |
|
| 124 |
public function isProtectModuleEnabled() { |
| 125 |
return $this->isServiceActive("protect") && $this->isValidEnvironment(); |
| 126 |
} |
| 127 |
|
| 128 |
public function isDynSyncModuleEnabled() { |
| 129 |
if ($this->isServiceActive("dynsync")) { |
| 130 |
$dynconfig = $this->config['dynsync']; |
| 131 |
if (array_key_exists('dynplug', $dynconfig) && ($dynconfig['dynplug'] === $this->plugname)) { |
| 132 |
return true; |
| 133 |
} |
| 134 |
} |
| 135 |
return false; |
| 136 |
} |
| 137 |
|
| 138 |
public function isServiceActive($service) { |
| 139 |
$bvconfig = $this->config; |
| 140 |
if ($bvconfig && array_key_exists('services', $bvconfig)) { |
| 141 |
return in_array($service, $bvconfig['services']) && $this->isActivePlugin(); |
| 142 |
} |
| 143 |
return false; |
| 144 |
} |
| 145 |
|
| 146 |
public function isActivateRedirectSet() { |
| 147 |
return ($this->settings->getOption($this->plug_redirect) === 'yes') ? true : false; |
| 148 |
} |
| 149 |
|
| 150 |
public function isMalcare() { |
| 151 |
return $this->getBrandName() === 'MalCare'; |
| 152 |
} |
| 153 |
|
| 154 |
public function isBlogvault() { |
| 155 |
return $this->getBrandName() === 'BlogVault'; |
| 156 |
} |
| 157 |
|
| 158 |
public function info() { |
| 159 |
return array( |
| 160 |
"bvversion" => $this->version, |
| 161 |
"sha1" => "true", |
| 162 |
"plugname" => $this->plugname |
| 163 |
); |
| 164 |
} |
| 165 |
} |
| 166 |
endif; |