Migrate Guru: Migrate & Clone WordPress Free - Version 3.2

Version Description

Download this release

Release Info

Developer ritesh.soni36
Plugin Icon 128x128 Migrate Guru: Migrate & Clone WordPress Free
Version 3.2
Comparing to
See all releases

Code changes from version 3.1 to 3.2

account.php CHANGED
@@ -7,6 +7,8 @@ if (!class_exists('MGAccount')) :
7
  public $public;
8
  public $secret;
9
  public $sig_match;
 
 
10
 
11
  public function __construct($settings, $public, $secret) {
12
  $this->settings = $settings;
@@ -14,19 +16,21 @@ if (!class_exists('MGAccount')) :
14
  $this->secret = $secret;
15
  }
16
 
17
- public static function find($settings, $public = false) {
18
- if (!$public) {
19
- $public = self::defaultPublic($settings);
 
20
  }
21
- $bvkeys = self::allKeys($settings);
22
- if ($public && array_key_exists($public, $bvkeys) && isset($bvkeys[$public])) {
23
- $secret = $bvkeys[$public];
24
- } else {
25
- $secret = self::defaultSecret($settings);
26
  }
27
  return new self($settings, $public, $secret);
28
  }
29
 
 
 
 
 
30
  public static function randString($length) {
31
  $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
32
 
@@ -38,24 +42,53 @@ if (!class_exists('MGAccount')) :
38
  return $str;
39
  }
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  public static function allAccounts($settings) {
42
- return $settings->getOption('bvAccounts');
 
 
 
 
43
  }
44
 
45
- public static function hasAccount($settings) {
46
  $accounts = self::allAccounts($settings);
47
- return (is_array($accounts) && sizeof($accounts) >= 1);
 
 
 
 
 
 
 
48
  }
49
 
50
  public static function isConfigured($settings) {
51
- return self::defaultPublic($settings);
 
52
  }
53
 
54
- public function setup() {
55
- $bvinfo = new MGInfo($this->settings);
56
- $this->settings->updateOption('bvSecretKey', self::randString(32));
57
- $this->settings->updateOption($bvinfo->plug_redirect, 'yes');
58
- $this->settings->updateOption('bvActivateTime', time());
59
  }
60
 
61
  public function authenticatedUrl($method) {
@@ -76,50 +109,13 @@ if (!class_exists('MGAccount')) :
76
  return $args;
77
  }
78
 
79
- public static function defaultPublic($settings) {
80
- return $settings->getOption('bvPublic');
81
- }
82
-
83
- public static function defaultSecret($settings) {
84
- return $settings->getOption('bvSecretKey');
85
- }
86
-
87
- public static function allKeys($settings) {
88
- $keys = $settings->getOption('bvkeys');
89
- if (!is_array($keys)) {
90
- $keys = array();
91
- }
92
- $public = self::defaultPublic($settings);
93
- $secret = self::defaultSecret($settings);
94
- if ($public)
95
- $keys[$public] = $secret;
96
- $keys['default'] = $secret;
97
- return $keys;
98
- }
99
-
100
- public function addKeys($public, $secret) {
101
- $bvkeys = $this->settings->getOption('bvkeys');
102
- if (!$bvkeys || (!is_array($bvkeys))) {
103
- $bvkeys = array();
104
- }
105
- $bvkeys[$public] = $secret;
106
- $this->settings->updateOption('bvkeys', $bvkeys);
107
- }
108
-
109
- public function updateKeys($publickey, $secretkey) {
110
- $this->settings->updateOption('bvPublic', $publickey);
111
- $this->settings->updateOption('bvSecretKey', $secretkey);
112
- $this->addKeys($publickey, $secretkey);
113
- }
114
-
115
- public function rmKeys($publickey) {
116
- $bvkeys = $this->settings->getOption('bvkeys');
117
- if ($bvkeys && is_array($bvkeys)) {
118
- unset($bvkeys[$publickey]);
119
- $this->settings->updateOption('bvkeys', $bvkeys);
120
- return true;
121
  }
122
- return false;
 
123
  }
124
 
125
  public function respInfo() {
@@ -129,47 +125,50 @@ if (!class_exists('MGAccount')) :
129
  );
130
  }
131
 
132
- public function authenticate($request) {
133
  $method = $request->method;
134
  $time = $request->time;
135
  $version = $request->version;
136
- $sig = $request->sig;
137
- if ($time < intval($this->settings->getOption('bvLastRecvTime')) - 300) {
138
- return false;
139
- }
140
  if ($request->is_sha1) {
141
- $sig_match = sha1($method.$this->secret.$time.$version);
142
  } else {
143
- $sig_match = md5($method.$this->secret.$time.$version);
144
  }
145
- $this->sig_match = $sig_match;
146
- if ($sig_match !== $sig) {
 
 
 
 
 
 
 
 
147
  return $sig_match;
148
  }
149
  $this->settings->updateOption('bvLastRecvTime', $time);
150
  return 1;
151
  }
152
 
153
- public function add($info) {
154
  $accounts = self::allAccounts($this->settings);
155
- if(!is_array($accounts)) {
156
- $accounts = array();
157
- }
158
  $pubkey = $info['pubkey'];
 
 
 
159
  $accounts[$pubkey]['lastbackuptime'] = time();
 
160
  $accounts[$pubkey]['url'] = $info['url'];
161
  $accounts[$pubkey]['email'] = $info['email'];
162
- $this->update($accounts);
163
  }
164
 
165
- public function remove($pubkey) {
166
- $bvkeys = $this->settings->getOption('bvkeys');
167
- $accounts = self::allAccounts($this->settings);
168
- $this->rmkeys($pubkey);
169
- $this->setup();
170
- if ($accounts && is_array($accounts)) {
171
  unset($accounts[$pubkey]);
172
- $this->update($accounts);
173
  return true;
174
  }
175
  return false;
@@ -179,9 +178,5 @@ if (!class_exists('MGAccount')) :
179
  $accounts = self::allAccounts($this->settings);
180
  return array_key_exists($pubkey, $accounts);
181
  }
182
-
183
- public function update($accounts) {
184
- $this->settings->updateOption('bvAccounts', $accounts);
185
- }
186
  }
187
- endif;
7
  public $public;
8
  public $secret;
9
  public $sig_match;
10
+ public static $api_public_key = 'bvApiPublic';
11
+ public static $accounts_list = 'bvAccountsList';
12
 
13
  public function __construct($settings, $public, $secret) {
14
  $this->settings = $settings;
16
  $this->secret = $secret;
17
  }
18
 
19
+ public static function find($settings, $public) {
20
+ $accounts = self::allAccounts($settings);
21
+ if (array_key_exists($public, $accounts) && isset($accounts[$public]['secret'])) {
22
+ $secret = $accounts[$public]['secret'];
23
  }
24
+ if (empty($secret) || (strlen($secret) < 32)) {
25
+ return null;
 
 
 
26
  }
27
  return new self($settings, $public, $secret);
28
  }
29
 
30
+ public static function update($settings, $allAccounts) {
31
+ $settings->updateOption(self::$accounts_list, $allAccounts);
32
+ }
33
+
34
  public static function randString($length) {
35
  $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
36
 
42
  return $str;
43
  }
44
 
45
+ public static function apiPublicAccount($settings) {
46
+ $pubkey = $settings->getOption(self::$api_public_key);
47
+ return self::find($settings, $pubkey);
48
+ }
49
+
50
+ public static function updateApiPublicKey($settings, $pubkey) {
51
+ $settings->updateOption(self::$api_public_key, $pubkey);
52
+ }
53
+
54
+ public static function getApiPublicKey($settings) {
55
+ return $settings->getOption(self::$api_public_key);
56
+ }
57
+
58
+ public static function getPlugName($settings) {
59
+ $bvinfo = new MGInfo($settings);
60
+ return $bvinfo->plugname;
61
+ }
62
+
63
  public static function allAccounts($settings) {
64
+ $accounts = $settings->getOption(self::$accounts_list);
65
+ if (!is_array($accounts)) {
66
+ $accounts = array();
67
+ }
68
+ return $accounts;
69
  }
70
 
71
+ public static function accountsByPlugname($settings) {
72
  $accounts = self::allAccounts($settings);
73
+ $accountsByPlugname = array();
74
+ $plugname = self::getPlugName($settings);
75
+ foreach ($accounts as $pubkey => $value) {
76
+ if (array_key_exists($plugname, $value) && $value[$plugname] == 1) {
77
+ $accountsByPlugname[$pubkey] = $value;
78
+ }
79
+ }
80
+ return $accountsByPlugname;
81
  }
82
 
83
  public static function isConfigured($settings) {
84
+ $accounts = self::accountsByPlugname($settings);
85
+ return (sizeof($accounts) >= 1);
86
  }
87
 
88
+ public static function setup($settings) {
89
+ $bvinfo = new MGInfo($settings);
90
+ $settings->updateOption($bvinfo->plug_redirect, 'yes');
91
+ $settings->updateOption('bvActivateTime', time());
 
92
  }
93
 
94
  public function authenticatedUrl($method) {
109
  return $args;
110
  }
111
 
112
+ public static function addAccount($settings, $public, $secret) {
113
+ $accounts = self::allAccounts($settings);
114
+ if (!isset($public, $accounts)) {
115
+ $accounts[$public] = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
+ $accounts[$public]['secret'] = $secret;
118
+ self::update($settings, $accounts);
119
  }
120
 
121
  public function respInfo() {
125
  );
126
  }
127
 
128
+ public static function getSigMatch($request, $secret) {
129
  $method = $request->method;
130
  $time = $request->time;
131
  $version = $request->version;
 
 
 
 
132
  if ($request->is_sha1) {
133
+ $sig_match = sha1($method.$secret.$time.$version);
134
  } else {
135
+ $sig_match = md5($method.$secret.$time.$version);
136
  }
137
+ return $sig_match;
138
+ }
139
+
140
+ public function authenticate($request) {
141
+ $time = $request->time;
142
+ if ($time < intval($this->settings->getOption('bvLastRecvTime')) - 300) {
143
+ return false;
144
+ }
145
+ $this->sig_match = self::getSigMatch($request, $this->secret);
146
+ if ($this->sig_match !== $request->sig) {
147
  return $sig_match;
148
  }
149
  $this->settings->updateOption('bvLastRecvTime', $time);
150
  return 1;
151
  }
152
 
153
+ public function updateInfo($info) {
154
  $accounts = self::allAccounts($this->settings);
155
+ $plugname = self::getPlugName($this->settings);
 
 
156
  $pubkey = $info['pubkey'];
157
+ if (!array_key_exists($pubkey, $accounts)) {
158
+ $accounts[$pubkey] = array();
159
+ }
160
  $accounts[$pubkey]['lastbackuptime'] = time();
161
+ $accounts[$pubkey][$plugname] = true;
162
  $accounts[$pubkey]['url'] = $info['url'];
163
  $accounts[$pubkey]['email'] = $info['email'];
164
+ self::update($this->settings, $accounts);
165
  }
166
 
167
+ public static function remove($settings, $pubkey) {
168
+ $accounts = self::allAccounts($settings);
169
+ if (array_key_exists($pubkey, $accounts)) {
 
 
 
170
  unset($accounts[$pubkey]);
171
+ self::update($settings, $accounts);
172
  return true;
173
  }
174
  return false;
178
  $accounts = self::allAccounts($this->settings);
179
  return array_key_exists($pubkey, $accounts);
180
  }
 
 
 
 
181
  }
182
+ endif;
callback/handler.php CHANGED
@@ -35,7 +35,8 @@ if (!class_exists('BVCallbackHandler')) :
35
  "request_info" => $this->request->respInfo(),
36
  "site_info" => $this->siteinfo->respInfo(),
37
  "account_info" => $this->account->respInfo(),
38
- "bvinfo" => $bvinfo->respInfo()
 
39
  );
40
  $this->response->terminate($resp);
41
  }
@@ -110,4 +111,4 @@ if (!class_exists('BVCallbackHandler')) :
110
  return 1;
111
  }
112
  }
113
- endif;
35
  "request_info" => $this->request->respInfo(),
36
  "site_info" => $this->siteinfo->respInfo(),
37
  "account_info" => $this->account->respInfo(),
38
+ "bvinfo" => $bvinfo->respInfo(),
39
+ "api_pubkey" => substr(MGAccount::getApiPublicKey($this->settings), 0, 8)
40
  );
41
  $this->response->terminate($resp);
42
  }
111
  return 1;
112
  }
113
  }
114
+ endif;
callback/wings/account.php CHANGED
@@ -14,27 +14,38 @@ class BVAccountCallback extends BVCallbackBase {
14
  function process($request) {
15
  $params = $request->params;
16
  $account = $this->account;
 
17
  switch ($request->method) {
18
- case "addkeys":
19
- $resp = array("status" => $account->addKeys($params['public'], $params['secret']));
 
20
  break;
21
- case "updatekeys":
22
- $resp = array("status" => $account->updateKeys($params['public'], $params['secret']));
23
- break;
24
- case "rmkeys":
25
- $resp = array("status" => $account->rmKeys($params['public']));
26
  break;
27
  case "updt":
28
  $info = array();
29
  $info['email'] = $params['email'];
30
  $info['url'] = $params['url'];
31
  $info['pubkey'] = $params['pubkey'];
32
- $account->add($info);
33
  $resp = array("status" => $account->doesAccountExists($params['pubkey']));
34
  break;
35
- case "disc":
36
- $account->remove($params['pubkey']);
37
- $resp = array("status" => !$account->doesAccountExists($params['pubkey']));
 
 
 
 
 
 
 
 
 
 
 
 
38
  case "fetch":
39
  $resp = array("status" => MGAccount::allAccounts($this->settings));
40
  break;
14
  function process($request) {
15
  $params = $request->params;
16
  $account = $this->account;
17
+ $settings = $this->settings;
18
  switch ($request->method) {
19
+ case "addacc":
20
+ MGAccount::addAccount($this->settings, $params['public'], $params['secret']);
21
+ $resp = array("status" => $account->doesAccountExists($params['public']));
22
  break;
23
+ case "rmacc":
24
+ $resp = array("status" => $account->remove($params['public']));
 
 
 
25
  break;
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);
32
  $resp = array("status" => $account->doesAccountExists($params['pubkey']));
33
  break;
34
+ case "updtapikey":
35
+ $resp = array("status" => MGAccount::updateApiPublicKey($this->settings, $params['pubkey']));
36
+ break;
37
+ case "rmdefsec":
38
+ $resp = array("status" => $settings->deleteOption('bvDefaultSecret'));
39
+ break;
40
+ case "rmbvkeys":
41
+ $resp = array("status" => $settings->deleteOption('bvKeys'));
42
+ break;
43
+ case "rmdefpub":
44
+ $resp = array("status" => $settings->deleteOption('bvDefaultPublic'));
45
+ break;
46
+ case "rmoldbvacc":
47
+ $resp = array("status" => $settings->deleteOption('bvAccounts'));
48
+ break;
49
  case "fetch":
50
  $resp = array("status" => MGAccount::allAccounts($this->settings));
51
  break;
callback/wings/info.php CHANGED
@@ -315,4 +315,4 @@ class BVInfoCallback extends BVCallbackBase {
315
  return $resp;
316
  }
317
  }
318
- endif;
315
  return $resp;
316
  }
317
  }
318
+ endif;
info.php CHANGED
@@ -9,7 +9,7 @@ if (!class_exists('MGInfo')) :
9
  public $badgeinfo = 'bvmgbadge';
10
  public $ip_header_option = 'bvmgipheader';
11
  public $brand_option = 'bvmgbrand';
12
- public $version = '3.1';
13
  public $webpage = 'https://www.migrateguru.com';
14
  public $appurl = 'https://mg.blogvault.net';
15
  public $slug = 'migrate-guru/migrateguru.php';
@@ -78,7 +78,6 @@ if (!class_exists('MGInfo')) :
78
  public function respInfo() {
79
  return array(
80
  "bvversion" => $this->version,
81
- "asymauth" => "true",
82
  "sha1" => "true"
83
  );
84
  }
9
  public $badgeinfo = 'bvmgbadge';
10
  public $ip_header_option = 'bvmgipheader';
11
  public $brand_option = 'bvmgbrand';
12
+ public $version = '3.2';
13
  public $webpage = 'https://www.migrateguru.com';
14
  public $appurl = 'https://mg.blogvault.net';
15
  public $slug = 'migrate-guru/migrateguru.php';
78
  public function respInfo() {
79
  return array(
80
  "bvversion" => $this->version,
 
81
  "sha1" => "true"
82
  );
83
  }
migrateguru.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://www.migrateguru.com
5
  Description: Migrating your site(s) to any WordPress Hosting platform has never been so easy.
6
  Author: Migrate Guru
7
  Author URI: http://www.migrateguru.com
8
- Version: 3.1
9
  Network: True
10
  */
11
 
@@ -52,6 +52,7 @@ register_deactivation_hook(__FILE__, array($wp_action, 'deactivate'));
52
 
53
  add_action('wp_footer', array($wp_action, 'footerHandler'), 100);
54
 
 
55
  if (is_admin()) {
56
  require_once dirname( __FILE__ ) . '/wp_admin.php';
57
  $wpadmin = new MGWPAdmin($bvsettings, $bvsiteinfo);
@@ -77,8 +78,16 @@ if ((array_key_exists('bvplugname', $_REQUEST)) && ($_REQUEST['bvplugname'] == "
77
  require_once dirname( __FILE__ ) . '/callback/base.php';
78
  require_once dirname( __FILE__ ) . '/callback/response.php';
79
  require_once dirname( __FILE__ ) . '/callback/request.php';
80
-
81
- $account = MGAccount::find($bvsettings, $_REQUEST['pubkey']);
 
 
 
 
 
 
 
 
82
  $request = new BVCallbackRequest($account, $_REQUEST);
83
  $response = new BVCallbackResponse($request->bvb64cksize);
84
 
@@ -109,7 +118,9 @@ if ((array_key_exists('bvplugname', $_REQUEST)) && ($_REQUEST['bvplugname'] == "
109
  "account_info" => $account ? $account->respInfo() : array("error" => "ACCOUNT_NOT_FOUND"),
110
  "request_info" => $request->respInfo(),
111
  "bvinfo" => $bvinfo->respInfo(),
112
- "statusmsg" => "FAILED_AUTH"
 
 
113
  );
114
  $response->terminate($resp);
115
  }
5
  Description: Migrating your site(s) to any WordPress Hosting platform has never been so easy.
6
  Author: Migrate Guru
7
  Author URI: http://www.migrateguru.com
8
+ Version: 3.2
9
  Network: True
10
  */
11
 
52
 
53
  add_action('wp_footer', array($wp_action, 'footerHandler'), 100);
54
 
55
+ ##WPCLIMODULE##
56
  if (is_admin()) {
57
  require_once dirname( __FILE__ ) . '/wp_admin.php';
58
  $wpadmin = new MGWPAdmin($bvsettings, $bvsiteinfo);
78
  require_once dirname( __FILE__ ) . '/callback/base.php';
79
  require_once dirname( __FILE__ ) . '/callback/response.php';
80
  require_once dirname( __FILE__ ) . '/callback/request.php';
81
+ require_once dirname( __FILE__ ) . '/recover.php';
82
+
83
+ $pubkey = $_REQUEST['pubkey'];
84
+
85
+ if (array_key_exists('rcvracc', $_REQUEST)) {
86
+ $account = MGRecover::find($bvsettings, $pubkey);
87
+ } else {
88
+ $account = MGAccount::find($bvsettings, $pubkey);
89
+ }
90
+
91
  $request = new BVCallbackRequest($account, $_REQUEST);
92
  $response = new BVCallbackResponse($request->bvb64cksize);
93
 
118
  "account_info" => $account ? $account->respInfo() : array("error" => "ACCOUNT_NOT_FOUND"),
119
  "request_info" => $request->respInfo(),
120
  "bvinfo" => $bvinfo->respInfo(),
121
+ "statusmsg" => "FAILED_AUTH",
122
+ "api_pubkey" => substr(MGAccount::getApiPublicKey($bvsettings), 0, 8),
123
+ "def_sigmatch" => substr(MGAccount::getSigMatch($request, MGRecover::getDefaultSecret($bvsettings)), 0, 8)
124
  );
125
  $response->terminate($resp);
126
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://www.migrateguru.com/
5
  Donate link: https://www.migrateguru.com/
6
  Requires at least: 4.0
7
  Tested up to: 5.2.1
8
- Stable tag: 3.1
9
  License: GPLv2 or later
10
  License URI: [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html)
11
 
5
  Donate link: https://www.migrateguru.com/
6
  Requires at least: 4.0
7
  Tested up to: 5.2.1
8
+ Stable tag: 3.2
9
  License: GPLv2 or later
10
  License URI: [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html)
11
 
recover.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) exit;
3
+ if (!class_exists('MGRecover')) :
4
+ class MGRecover {
5
+ public static $default_secret_key = 'bvSecretKey';
6
+
7
+ public static function defaultSecret($settings) {
8
+ $secret = self::getDefaultSecret($settings);
9
+ if (empty($secret)) {
10
+ $secret = MGAccount::randString(32);
11
+ self::updateDefaultSecret($settings, $secret);
12
+ }
13
+ return $secret;
14
+ }
15
+
16
+ public static function deleteDefaultSecret($settings) {
17
+ $settings->deleteOption(self::$default_secret_key);
18
+ }
19
+
20
+ public static function getDefaultSecret($settings) {
21
+ return $settings->getOption(self::$default_secret_key);
22
+ }
23
+
24
+ public static function updateDefaultSecret($settings, $secret) {
25
+ $settings->updateOption(self::$default_secret_key, $secret);
26
+ }
27
+
28
+ public static function validate($pubkey) {
29
+ if ($pubkey && strlen($pubkey) >= 32) {
30
+ return true;
31
+ } else {
32
+ return false;
33
+ }
34
+ }
35
+
36
+ public static function find($settings, $pubkey) {
37
+ if (!self::validate($pubkey)) {
38
+ return null;
39
+ }
40
+ $secret = self::getDefaultSecret($settings);
41
+ if (!empty($secret) && (strlen($secret) >= 32)) {
42
+ $account = new MGAccount($settings, $pubkey, $secret);
43
+ }
44
+ return $account;
45
+ }
46
+ }
47
+ endif;
wp_actions.php CHANGED
@@ -16,7 +16,6 @@ if (!class_exists('MGWPAction')) :
16
  }
17
 
18
  public function activate() {
19
- $account = MGAccount::find($this->settings);
20
  if (!isset($_REQUEST['blogvaultkey'])) {
21
  ##BVKEYSLOCATE##
22
  }
@@ -26,7 +25,7 @@ if (!class_exists('MGWPAction')) :
26
  $this->siteinfo->basic($info);
27
  $this->bvapi->pingbv('/bvapi/activate', $info);
28
  } else {
29
- $account->setup();
30
  }
31
  }
32
 
16
  }
17
 
18
  public function activate() {
 
19
  if (!isset($_REQUEST['blogvaultkey'])) {
20
  ##BVKEYSLOCATE##
21
  }
25
  $this->siteinfo->basic($info);
26
  $this->bvapi->pingbv('/bvapi/activate', $info);
27
  } else {
28
+ MGAccount::setup($this->settings);
29
  }
30
  }
31
 
wp_admin.php CHANGED
@@ -5,14 +5,12 @@ if (!class_exists('MGWPAdmin')) :
5
  class MGWPAdmin {
6
  public $settings;
7
  public $siteinfo;
8
- public $account;
9
  public $bvinfo;
10
 
11
  function __construct($settings, $siteinfo) {
12
  $this->settings = $settings;
13
  $this->siteinfo = $siteinfo;
14
  $this->bvinfo = new MGInfo($this->settings);
15
- $this->account = MGAccount::find($this->settings);
16
  }
17
 
18
  public function mainUrl($_params = '') {
@@ -34,7 +32,7 @@ class MGWPAdmin {
34
  (array_key_exists('page', $_REQUEST) &&
35
  $_REQUEST['page'] == $this->bvinfo->plugname)) {
36
  $keys = str_split($_REQUEST['blogvaultkey'], 32);
37
- $this->account->updateKeys($keys[0], $keys[1]);
38
  if (array_key_exists('redirect', $_REQUEST)) {
39
  $location = $_REQUEST['redirect'];
40
  wp_redirect($this->bvinfo->appUrl().'/migration/'.$location);
@@ -122,8 +120,10 @@ class MGWPAdmin {
122
  }
123
 
124
  public function siteInfoTags() {
 
125
  $bvnonce = wp_create_nonce("bvnonce");
126
- $secret = $this->account->secret;
 
127
  $tags = "<input type='hidden' name='url' value='".$this->siteinfo->wpurl()."'/>\n".
128
  "<input type='hidden' name='homeurl' value='".$this->siteinfo->homeurl()."'/>\n".
129
  "<input type='hidden' name='siteurl' value='".$this->siteinfo->siteurl()."'/>\n".
@@ -134,6 +134,7 @@ class MGWPAdmin {
134
  "<input type='hidden' name='serverip' value='".$_SERVER["SERVER_ADDR"]."'/>\n".
135
  "<input type='hidden' name='abspath' value='".ABSPATH."'/>\n".
136
  "<input type='hidden' name='secret' value='".$secret."'/>\n".
 
137
  "<input type='hidden' name='bvnonce' value='".$bvnonce."'/>\n";
138
  return $tags;
139
  }
5
  class MGWPAdmin {
6
  public $settings;
7
  public $siteinfo;
 
8
  public $bvinfo;
9
 
10
  function __construct($settings, $siteinfo) {
11
  $this->settings = $settings;
12
  $this->siteinfo = $siteinfo;
13
  $this->bvinfo = new MGInfo($this->settings);
 
14
  }
15
 
16
  public function mainUrl($_params = '') {
32
  (array_key_exists('page', $_REQUEST) &&
33
  $_REQUEST['page'] == $this->bvinfo->plugname)) {
34
  $keys = str_split($_REQUEST['blogvaultkey'], 32);
35
+ MGAccount::addAccount($this->settings, $keys[0], $keys[1]);
36
  if (array_key_exists('redirect', $_REQUEST)) {
37
  $location = $_REQUEST['redirect'];
38
  wp_redirect($this->bvinfo->appUrl().'/migration/'.$location);
120
  }
121
 
122
  public function siteInfoTags() {
123
+ require_once dirname( __FILE__ ) . '/recover.php';
124
  $bvnonce = wp_create_nonce("bvnonce");
125
+ $secret = MGRecover::defaultSecret($this->settings);
126
+ $public = MGAccount::getApiPublicKey($this->settings);
127
  $tags = "<input type='hidden' name='url' value='".$this->siteinfo->wpurl()."'/>\n".
128
  "<input type='hidden' name='homeurl' value='".$this->siteinfo->homeurl()."'/>\n".
129
  "<input type='hidden' name='siteurl' value='".$this->siteinfo->siteurl()."'/>\n".
134
  "<input type='hidden' name='serverip' value='".$_SERVER["SERVER_ADDR"]."'/>\n".
135
  "<input type='hidden' name='abspath' value='".ABSPATH."'/>\n".
136
  "<input type='hidden' name='secret' value='".$secret."'/>\n".
137
+ "<input type='hidden' name='public' value='".$public."'/>\n".
138
  "<input type='hidden' name='bvnonce' value='".$bvnonce."'/>\n";
139
  return $tags;
140
  }
wp_api.php CHANGED
@@ -3,14 +3,26 @@
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('MGWPAPI')) :
5
  class MGWPAPI {
6
- public $account;
7
 
8
  public function __construct($settings) {
9
- $this->account = MGAccount::find($settings);
10
  }
11
 
12
- public function pingbv($method, $body) {
13
- $url = $this->account->authenticatedUrl($method);
 
 
 
 
 
 
 
 
 
 
 
 
14
  $this->http_request($url, $body);
15
  }
16
 
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('MGWPAPI')) :
5
  class MGWPAPI {
6
+ public $settings;
7
 
8
  public function __construct($settings) {
9
+ $this->settings = $settings;
10
  }
11
 
12
+ public function pingbv($method, $body, $public = false) {
13
+ if ($public) {
14
+ $this->create_request_params($method, $public);
15
+ } else {
16
+ $accounts = MGAccount::allAccounts($this->settings);
17
+ foreach ($accounts as $pubkey => $value ) {
18
+ $this->create_request_params($method, $pubkey);
19
+ }
20
+ }
21
+ }
22
+
23
+ public function create_request_params($method, $pubkey) {
24
+ $account = MGAccount::find($this->settings, $pubkey);
25
+ $url = $account->authenticatedUrl($method);
26
  $this->http_request($url, $body);
27
  }
28
 
wp_site_info.php CHANGED
@@ -38,7 +38,7 @@ class MGWPSiteInfo {
38
  return true;
39
  return is_main_site();
40
  }
41
-
42
  public function respInfo() {
43
  $info = array();
44
  $this->basic($info);
38
  return true;
39
  return is_main_site();
40
  }
41
+
42
  public function respInfo() {
43
  $info = array();
44
  $this->basic($info);