Changeset 2378681
- Timestamp:
- 09/10/2020 12:15:35 PM (6 years ago)
- Location:
- malcare-security/trunk
- Files:
-
- 10 edited
-
account.php (modified) (3 diffs)
-
callback/wings/account.php (modified) (2 diffs)
-
callback/wings/db.php (modified) (1 diff)
-
callback/wings/fs.php (modified) (4 diffs)
-
callback/wings/misc.php (modified) (1 diff)
-
info.php (modified) (3 diffs)
-
malcare.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
wp_admin.php (modified) (6 diffs)
-
wp_cli.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
malcare-security/trunk/account.php
r2297475 r2378681 85 85 } 86 86 87 public static function accountsByType($settings, $account_type) { 88 $accounts = self::allAccounts($settings); 89 $accounts_by_type = array(); 90 foreach ($accounts as $pubkey => $value) { 91 if (array_key_exists('account_type', $value) && $value['account_type'] === $account_type) { 92 $accounts_by_type[$pubkey] = $value; 93 } 94 } 95 return $accounts_by_type; 96 } 97 98 public static function accountsByGid($settings, $account_gid) { 99 $accounts = self::allAccounts($settings); 100 $accounts_by_gid = array(); 101 foreach ($accounts as $pubkey => $value) { 102 if (array_key_exists('account_gid', $value) && $value['account_gid'] === $account_gid) { 103 $accounts_by_gid[$pubkey] = $value; 104 } 105 } 106 return $accounts_by_gid; 107 } 108 109 public static function accountsByPattern($settings, $search_key, $search_pattern) { 110 $accounts = self::allAccounts($settings); 111 $accounts_by_pattern = array(); 112 foreach ($accounts as $pubkey => $value) { 113 if (array_key_exists($search_key, $value) && preg_match($search_pattern, $value[$search_key]) == 1) { 114 $accounts_by_pattern[$pubkey] = $value; 115 } 116 } 117 return $accounts_by_pattern; 118 } 119 87 120 public static function isConfigured($settings) { 88 121 $accounts = self::accountsByPlugname($settings); … … 156 189 return 1; 157 190 } 158 191 159 192 public function updateInfo($info) { 160 193 $accounts = self::allAccounts($this->settings); 161 $plugname = self::getPlugName($this->settings); 194 $plugname = $info["plugname"]; 195 $account_type = $info["account_type"]; 162 196 $pubkey = $info['pubkey']; 163 197 if (!array_key_exists($pubkey, $accounts)) { 164 198 $accounts[$pubkey] = array(); 165 199 } 200 if (array_key_exists('secret', $info)) { 201 $accounts[$pubkey]['secret'] = $info['secret']; 202 } 203 $accounts[$pubkey]['account_gid'] = $info['account_gid']; 166 204 $accounts[$pubkey]['lastbackuptime'] = time(); 167 205 $accounts[$pubkey][$plugname] = true; 206 $accounts[$pubkey]['account_type'] = $account_type; 168 207 $accounts[$pubkey]['url'] = $info['url']; 169 208 $accounts[$pubkey]['email'] = $info['email']; … … 181 220 } 182 221 222 public static function removeByAccountType($settings, $account_type) { 223 $accounts = MCAccount::accountsByType($settings, $account_type); 224 if (sizeof($accounts) >= 1) { 225 foreach ($accounts as $pubkey => $value) { 226 MCAccount::remove($settings, $pubkey); 227 } 228 return true; 229 } 230 return false; 231 } 232 233 public static function removeByAccountGid($settings, $account_gid) { 234 $accounts = MCAccount::accountsByGid($settings, $account_gid); 235 if (sizeof($accounts) >= 1) { 236 foreach ($accounts as $pubkey => $value) { 237 MCAccount::remove($settings, $pubkey); 238 } 239 return true; 240 } 241 return false; 242 } 243 183 244 public static function exists($settings, $pubkey) { 184 245 $accounts = self::allAccounts($settings); -
malcare-security/trunk/callback/wings/account.php
r2207998 r2378681 25 25 break; 26 26 case "updt": 27 $info = array(); 28 $info['email'] = $params['email']; 29 $info['url'] = $params['url']; 30 $info['pubkey'] = $params['pubkey']; 31 $account->updateInfo($info); 27 $account->updateInfo($params); 32 28 $resp = array("status" => MCAccount::exists($this->settings, $params['pubkey'])); 33 29 break; … … 36 32 $resp = array("status" => $this->settings->getOption(MCAccount::$api_public_key)); 37 33 break; 38 case "rm defsec":39 $resp = array("status" => $settings->deleteOption('bv DefaultSecret'));34 case "rmbvscrt": 35 $resp = array("status" => $settings->deleteOption('bvSecretKey')); 40 36 break; 41 37 case "rmbvkeys": -
malcare-security/trunk/callback/wings/db.php
r2323804 r2378681 70 70 $stream_init_info = BVStream::startStream($this->account, $request); 71 71 72 if( MCWPSiteInfo::isCWServer() && !$this->bvinfo->isManualSignup()) {72 if($this->bvinfo->canSetCWBranding()) { 73 73 $bv_table = $params['table']; 74 74 if (!empty($bv_table)) { -
malcare-security/trunk/callback/wings/fs.php
r2350813 r2378681 13 13 public function __construct($callback_handler) { 14 14 $this->account = $callback_handler->account; 15 $this->bvinfo = $callback_handler->bvinfo; 15 16 } 16 17 … … 27 28 $fdata["link"] = @readlink($absfile); 28 29 } 29 if ($md5 === true ) {30 if ($md5 === true && !is_dir($absfile)) { 30 31 $fdata["md5"] = $this->calculateMd5($absfile, array(), 0, 0, 0); 31 32 } … … 197 198 continue; 198 199 } 199 if ($md5 === true ) {200 if ($md5 === true && !is_dir($absfile)) { 200 201 $fdata["md5"] = $this->calculateMd5($absfile, $fdata, $offset, $limit, $bsize); 201 202 } … … 246 247 $params = $request->params; 247 248 $stream_init_info = BVStream::startStream($this->account, $request); 248 249 249 250 if($this->bvinfo->canSetCWBranding()) { 251 if(array_key_exists('initdir', $params)) { 252 return $stream_init_info; 253 } 254 255 if (array_key_exists('files', $params)) { 256 $files = $params['files']; 257 258 foreach($files as $file) { 259 if (!in_array($file, BVFSCallback::$cwAllowedFiles)) { 260 return $stream_init_info; 261 } 262 } 263 } 264 } 265 250 266 251 267 if (array_key_exists('stream', $stream_init_info)) { -
malcare-security/trunk/callback/wings/misc.php
r2323804 r2378681 95 95 $resp = array("dlttrsnt" => $settings->deleteTransient($params['key'])); 96 96 break; 97 case "set manulsignup":98 $resp = array("s etmanulsignup" => $settings->updateOption("bvmanualsignup", true));97 case "setbvss": 98 $resp = array("status" => $settings->updateOption('bv_site_settings', $params['bv_site_settings'])); 99 99 break; 100 100 default: -
malcare-security/trunk/info.php
r2350813 r2378681 10 10 public $ip_header_option = 'mcipheader'; 11 11 public $brand_option = 'mcbrand'; 12 public $version = '4. 35';12 public $version = '4.4'; 13 13 public $webpage = 'https://www.malcare.com'; 14 14 public $appurl = 'https://app.malcare.com'; … … 22 22 } 23 23 24 public function isManualSignup() { 25 $scanOption = $this->settings->getOption('bvmanualsignup'); 26 return (isset($scanOption) && $scanOption == 1); 24 public function canSetCWBranding() { 25 if (MCWPSiteInfo::isCWServer()) { 26 27 $bot_protect_accounts = MCAccount::accountsByType($this->settings, 'botprotect'); 28 if (sizeof($bot_protect_accounts) >= 1) 29 return true; 30 31 $bot_protect_accounts = MCAccount::accountsByPattern($this->settings, 'email', '/@cw_user\.com$/'); 32 if (sizeof($bot_protect_accounts) >= 1) 33 return true; 34 } 35 36 return false; 27 37 } 28 38 … … 37 47 } 38 48 $bvinfo = new MCInfo($this->settings); 39 if ( MCWPSiteInfo::isCWServer() && !$bvinfo->isManualSignup()) {49 if ($bvinfo->canSetCWBranding()) { 40 50 return "Cloudways"; 41 51 } -
malcare-security/trunk/malcare.php
r2350813 r2378681 6 6 Author: MalCare Security 7 7 Author URI: https://www.malcare.com 8 Version: 4. 358 Version: 4.4 9 9 Network: True 10 10 */ … … 75 75 add_action('admin_notices', array($wpadmin, 'activateWarning')); 76 76 add_action('admin_enqueue_scripts', array($wpadmin, 'mcsecAdminMenu')); 77 add_action('plugin_action_links', array($wpadmin, 'disableDeactivation'), 10, 2); 77 78 } 78 79 … … 143 144 144 145 ##DYNSYNCMODULE## 146 ##WPAUTOUPDATEBLOCKMODULE## 145 147 } -
malcare-security/trunk/readme.txt
r2350813 r2378681 7 7 Tested up to: 5.5 8 8 Requires PHP: 5.4.0 9 Stable tag: 4. 359 Stable tag: 4.4 10 10 License: GPLv2 or later 11 11 License URI: [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html) … … 391 391 392 392 == CHANGELOG == 393 = 4.35 = 394 * Improved scanfiles and filelist api 393 = 4.4 = 394 * Disabling deactivate for botprotection accounts 395 * Disconnect functionality through wpcli with params account_gid and account_type 396 * Removed manual signup logic 395 397 396 398 = 4.33 = -
malcare-security/trunk/wp_admin.php
r2336505 r2378681 30 30 remove_all_actions('all_admin_notices'); 31 31 } 32 } 33 34 public function disableDeactivation($actions, $plugin_file) { 35 if ($this->bvinfo->canSetCWBranding()) { 36 if ( $this->bvinfo->slug === $plugin_file ) { 37 unset( $actions['deactivate'] ); 38 } 39 } 40 return $actions; 32 41 } 33 42 … … 68 77 if ($this->bvinfo->isActivateRedirectSet()) { 69 78 $this->settings->updateOption($this->bvinfo->plug_redirect, 'no'); 70 $this->settings->updateOption('bvmanualsignup', true);71 79 wp_redirect($this->mainUrl()); 72 80 } … … 106 114 array($this, 'showAccountDetailsPage')); 107 115 108 if (! MCWPSiteInfo::isCWServer() || $this->bvinfo->isManualSignup()) {116 if (!$this->bvinfo->canSetCWBranding()) { 109 117 $bname = $this->bvinfo->getBrandName(); 110 118 $icon = $this->bvinfo->getBrandIcon(); … … 138 146 #XNOTE: Fix this 139 147 if ( $file == plugin_basename( dirname(__FILE__).'/malcare.php' ) ) { 140 if (! MCWPSiteInfo::isCWServer() || $this->bvinfo->isManualSignup()) {148 if (!$this->bvinfo->canSetCWBranding()) { 141 149 $settings_link = '<a href="'.$this->mainUrl().'">'.__( 'Settings' ).'</a>'; 142 150 array_unshift($links, $settings_link); … … 189 197 190 198 public function showAddAccountPage() { 191 $this->settings->updateOption('bvmanualsignup', true);192 199 $this->enqueueBootstrapCSS(); 193 200 require_once dirname( __FILE__ ) . "/admin/registration.php"; … … 228 235 } 229 236 230 if ( MCWPSiteInfo::isCWServer() && !$this->bvinfo->isManualSignup()) {237 if ($this->bvinfo->canSetCWBranding()) { 231 238 $brand = $this->cwBrandInfo(); 232 239 if (array_key_exists('name', $brand)) { -
malcare-security/trunk/wp_cli.php
r2336505 r2378681 30 30 'Authorization' => "BVAPI-HMAC {$params['account_public']}:{$params['sig']}:{$params['timestamp']}" 31 31 ); 32 $this->request($url, $request_params, $headers); 32 33 $resp = $this->request($url, $request_params, $headers); 34 35 $this->updateAccountInfo($resp); 36 37 $this->handle_response($resp); 33 38 } 34 39 … … 56 61 WP_CLI::error('Account not found'); 57 62 } 58 $this->request($account->authenticatedUrl('/bvapi/disable_fw')); 63 $resp = $this->request($account->authenticatedUrl('/bvapi/disable_fw')); 64 $this->handle_response($resp); 59 65 } 60 66 … … 64 70 WP_CLI::error('Account not found.'); 65 71 } 66 $this->request($account->authenticatedUrl('/bvapi/enable_fw')); 72 $resp = $this->request($account->authenticatedUrl('/bvapi/enable_fw')); 73 $this->handle_response($resp); 67 74 } 68 75 69 76 public function disconnect($args, $params) { 77 $status = false; 70 78 if (isset($params['public_key'])) { 71 if (strlen($params['public_key']) >= 32) { 72 $status = MCAccount::remove($this->settings, $params['public_key']); 73 if ($status) { 74 WP_CLI::success('Account Keys removed successfully.'); 75 } else { 76 WP_CLI::error('No Account with provided public key exists.'); 77 } 78 } else { 79 WP_CLI::error('Invalid Public Key.'); 80 } 79 $status = MCAccount::remove($this->settings, $params['public_key']); 80 } else if(isset($params['account_type'])) { 81 $status = MCAccount::removeByAccountType($this->settings, $params['account_type']); 82 } else if(isset($params['account_gid'])) { 83 $status = MCAccount::removeByAccountGid($this->settings, $params['account_gid']); 81 84 } else { 82 WP_CLI::error('Please Provide Public Key.'); 85 WP_CLI::error('Input Params are incorrect. Please validate the params.'); 86 } 87 88 if ($status) { 89 WP_CLI::success('Account removed successfully.'); 90 } else { 91 WP_CLI::error('No Account exists.'); 83 92 } 84 93 } … … 86 95 private function request($url, $request_params = array(), $headers = array()) { 87 96 $resp = $this->bvapi->http_request($url, $request_params, $headers); 88 $this->handle_response($resp); 97 return $resp; 98 } 99 100 private function updateAccountInfo($resp) { 101 if(isset($resp["response"]) && isset($resp["response"]["code"]) && ($resp["response"]["code"] == 200)) { 102 if (isset($resp["body"])) { 103 $body = json_decode($resp["body"], true); 104 if (isset($body["account_info"])) { 105 $info = $body["account_info"]; 106 MCAccount::addAccount($this->settings, $info['pubkey'], $info['secret']); 107 $account = MCAccount::find($this->settings, $info['pubkey']); 108 $account->updateInfo($info); 109 } 110 } 111 } 89 112 } 90 113
Note: See TracChangeset
for help on using the changeset viewer.