WP Engine Automated Migration - Version 2.1

Version Description

  • Restructuring classes
Download this release

Release Info

Developer ritesh.soni36
Plugin Icon 128x128 WP Engine Automated Migration
Version 2.1
Comparing to
See all releases

Code changes from version 1.88 to 2.1

account.php ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('WPEAccount')) :
5
+ class WPEAccount {
6
+ public $settings;
7
+ public $public;
8
+ public $secret;
9
+ public $sig_match;
10
+
11
+ public function __construct($settings, $public, $secret) {
12
+ $this->settings = $settings;
13
+ $this->public = $public;
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
+
33
+ $str = "";
34
+ $size = strlen($chars);
35
+ for( $i = 0; $i < $length; $i++ ) {
36
+ $str .= $chars[rand(0, $size - 1)];
37
+ }
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 WPEInfo($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) {
62
+ $bvinfo = new WPEInfo($this->settings);
63
+ $qstr = http_build_query($this->newAuthParams($bvinfo->version));
64
+ return $bvinfo->appUrl().$method."?".$qstr;
65
+ }
66
+
67
+ public function newAuthParams($version) {
68
+ $args = array();
69
+ $time = time();
70
+ $sig = sha1($this->public.$this->secret.$time.$version);
71
+ $args['sig'] = $sig;
72
+ $args['bvTime'] = $time;
73
+ $args['bvPublic'] = $this->public;
74
+ $args['bvVersion'] = $version;
75
+ $args['sha1'] = '1';
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() {
126
+ return array(
127
+ "public" => substr($this->public, 0, 6),
128
+ "sigmatch" => substr($this->sig_match, 0, 6)
129
+ );
130
+ }
131
+
132
+ public function authenticate() {
133
+ $method = $_REQUEST['bvMethod'];
134
+ $time = intval($_REQUEST['bvTime']);
135
+ $version = $_REQUEST['bvVersion'];
136
+ $sig = $_REQUEST['sig'];
137
+ if ($time < intval($this->settings->getOption('bvLastRecvTime')) - 300) {
138
+ return false;
139
+ }
140
+ if (array_key_exists('sha1', $_REQUEST)) {
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;
176
+ }
177
+
178
+ public function doesAccountExists($pubkey) {
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;
admin/main_page.php CHANGED
@@ -14,7 +14,7 @@
14
  <div class="row">
15
 
16
  <div class="seven columns">
17
- <form id="wpe_migrate_form" dummy=">" action="<?php echo $this->bvmain->appUrl(); ?>/home/migrate" onsubmit="document.getElementById('migratesubmit').disabled = true;" method="post" name="signup">
18
  <h1>Migrate My Site to WP Engine</h1>
19
  <p>The WP Engine Automated Migration plugin allows you to easily migrate your entire WordPress site from
20
  your previous hosting service to WP Engine for free.</p>
14
  <div class="row">
15
 
16
  <div class="seven columns">
17
+ <form id="wpe_migrate_form" dummy=">" action="<?php echo $this->bvinfo->appUrl(); ?>/home/migrate" onsubmit="document.getElementById('migratesubmit').disabled = true;" method="post" name="signup">
18
  <h1>Migrate My Site to WP Engine</h1>
19
  <p>The WP Engine Automated Migration plugin allows you to easily migrate your entire WordPress site from
20
  your previous hosting service to WP Engine for free.</p>
callback.php DELETED
@@ -1,251 +0,0 @@
1
- <?php
2
-
3
- if (!defined('ABSPATH')) exit;
4
- if (!class_exists('BVCallback')) :
5
-
6
- require_once dirname( __FILE__ ) . '/callback/response.php';
7
-
8
- class BVCallback {
9
- public $bvmain;
10
- function __construct($bvmain) {
11
- $this->bvmain = $bvmain;
12
- }
13
-
14
- public function serversig($full = false) {
15
- $sig = sha1($_SERVER['SERVER_ADDR'].ABSPATH);
16
- if ($full)
17
- return $sig;
18
- else
19
- return substr($sig, 0, 6);
20
- }
21
-
22
- public function terminate($with_basic, $bvdebug = false) {
23
- global $bvresp;
24
- $public = $this->bvmain->auth->defaultPublic();
25
- $bvresp->addStatus("signature", "Blogvault API");
26
- $bvresp->addStatus("asymauth", "true");
27
- $bvresp->addStatus("sha1", "true");
28
- $bvresp->addStatus("dbsig", $this->bvmain->lib->dbsig(false));
29
- $bvresp->addStatus("serversig", $this->serversig(false));
30
- $bvresp->addStatus("public", substr($public, 0, 6));
31
- if (array_key_exists('adajx', $_REQUEST)) {
32
- $bvresp->addStatus("adajx", true);
33
- }
34
- if ($with_basic) {
35
- $binfo = array();
36
- $this->bvmain->info->basic($binfo);
37
- $bvresp->addStatus("basic", $binfo);
38
- $bvresp->addStatus("bvversion", $this->bvmain->version);
39
- }
40
-
41
- if ($bvdebug) {
42
- $bvresp->addStatus("inreq", $_REQUEST);
43
- }
44
-
45
- $bvresp->finish();
46
- exit;
47
- }
48
-
49
- public function processParams() {
50
- if (array_key_exists('concat', $_REQUEST)) {
51
- foreach ($_REQUEST['concat'] as $key) {
52
- $concated = '';
53
- $count = intval($_REQUEST[$key]);
54
- for ($i = 1; $i <= $count; $i++) {
55
- $concated .= $_REQUEST[$key."_bv_".$i];
56
- }
57
- $_REQUEST[$key] = $concated;
58
- }
59
- }
60
- if (array_key_exists('b64', $_REQUEST)) {
61
- foreach ($_REQUEST['b64'] as $key) {
62
- if (is_array($_REQUEST[$key])) {
63
- $_REQUEST[$key] = array_map('base64_decode', $_REQUEST[$key]);
64
- } else {
65
- $_REQUEST[$key] = base64_decode($_REQUEST[$key]);
66
- }
67
- }
68
- }
69
- if (array_key_exists('unser', $_REQUEST)) {
70
- foreach ($_REQUEST['unser'] as $key) {
71
- $_REQUEST[$key] = json_decode($_REQUEST[$key], TRUE);
72
- }
73
- }
74
- if (array_key_exists('b642', $_REQUEST)) {
75
- foreach ($_REQUEST['b642'] as $key) {
76
- if (is_array($_REQUEST[$key])) {
77
- $_REQUEST[$key] = array_map('base64_decode', $_REQUEST[$key]);
78
- } else {
79
- $_REQUEST[$key] = base64_decode($_REQUEST[$key]);
80
- }
81
- }
82
- }
83
- if (array_key_exists('dic', $_REQUEST)) {
84
- foreach ($_REQUEST['dic'] as $key => $mkey) {
85
- $_REQUEST[$mkey] = $_REQUEST[$key];
86
- unset($_REQUEST[$key]);
87
- }
88
- }
89
- if (array_key_exists('clacts', $_REQUEST)) {
90
- foreach ($_REQUEST['clacts'] as $action) {
91
- remove_all_actions($action);
92
- }
93
- }
94
- if (array_key_exists('clallacts', $_REQUEST)) {
95
- global $wp_filter;
96
- foreach ( $wp_filter as $filter => $val ){
97
- remove_all_actions($filter);
98
- }
99
- }
100
- if (array_key_exists('memset', $_REQUEST)) {
101
- $val = intval(urldecode($_REQUEST['memset']));
102
- @ini_set('memory_limit', $val.'M');
103
- }
104
- }
105
-
106
- public function recover() {
107
- $recover = new BVRecover(base64_decode($_REQUEST['sig']), $_REQUEST['orig'],
108
- $_REQUEST['keyname'], $_REQUEST["keysize"]);
109
- if ($recover->validate() && ($recover->process() === 1)) {
110
- $recover->processKeyExchange();
111
- return 1;
112
- }
113
- return false;
114
- }
115
-
116
- public function preauth() {
117
- global $bvresp;
118
- if (array_key_exists('obend', $_REQUEST) && function_exists('ob_end_clean'))
119
- @ob_end_clean();
120
- if (array_key_exists('op_reset', $_REQUEST) && function_exists('output_reset_rewrite_vars'))
121
- @output_reset_rewrite_vars();
122
- if (array_key_exists('binhead', $_REQUEST)) {
123
- header("Content-type: application/binary");
124
- header('Content-Transfer-Encoding: binary');
125
- }
126
- if (array_key_exists('bvrcvr', $_REQUEST)) {
127
- require_once dirname( __FILE__ ) . '/callback/recover.php';
128
- if ($this->recover() !== 1) {
129
- $bvresp->addStatus("statusmsg", 'failed authentication');
130
- }
131
- $this->terminate(false, array_key_exists('bvdbg', $_REQUEST));
132
- return false;
133
- }
134
- return 1;
135
- }
136
-
137
- public function authenticate() {
138
- global $bvresp;
139
- $auth = $this->bvmain->auth;
140
- $method = $_REQUEST['bvMethod'];
141
- $time = intval($_REQUEST['bvTime']);
142
- $version = $_REQUEST['bvVersion'];
143
- $sig = $_REQUEST['sig'];
144
- $public = $auth->publicParam();
145
-
146
- $bvresp->addStatus("requestedsig", $sig);
147
- $bvresp->addStatus("requestedtime", $time);
148
- $bvresp->addStatus("requestedversion", $version);
149
-
150
- $sig_match = $auth->validate($public, $method, $time, $version, $sig);
151
- if ($sig_match === 1) {
152
- return 1;
153
- } else {
154
- $bvresp->addStatus("sigmatch", substr($sig_match, 0, 6));
155
- $bvresp->addStatus("statusmsg", 'failed authentication');
156
- return false;
157
- }
158
- }
159
-
160
- public function route($wing, $method) {
161
- global $bvresp;
162
- $bvresp->addStatus("callback", $method);
163
- switch ($wing) {
164
- case 'manage':
165
- require_once dirname( __FILE__ ) . '/callback/wings/manage.php';
166
- $module = new BVManageCallback();
167
- break;
168
- case 'fs':
169
- require_once dirname( __FILE__ ) . '/callback/wings/fs.php';
170
- $module = new BVFSCallback();
171
- break;
172
- case 'db':
173
- require_once dirname( __FILE__ ) . '/callback/wings/db.php';
174
- $module = new BVDBCallback();
175
- break;
176
- case 'info':
177
- require_once dirname( __FILE__ ) . '/callback/wings/info.php';
178
- $module = new BVInfoCallback();
179
- break;
180
- case 'dynsync':
181
- require_once dirname( __FILE__ ) . '/callback/wings/dynsync.php';
182
- $module = new BVDynSyncCallback();
183
- break;
184
- case 'ipstr':
185
- require_once dirname( __FILE__ ) . '/callback/wings/ipstore.php';
186
- $module = new BVIPStoreCallback();
187
- break;
188
- case 'auth':
189
- require_once dirname( __FILE__ ) . '/callback/wings/auth.php';
190
- $module = new BVAuthCallback();
191
- break;
192
- case 'fw':
193
- require_once dirname( __FILE__ ) . '/callback/wings/fw.php';
194
- $module = new BVFirewallCallback();
195
- break;
196
- case 'lp':
197
- require_once dirname( __FILE__ ) . '/callback/wings/lp.php';
198
- $module = new BVLoginProtectCallback();
199
- break;
200
- case 'monit':
201
- require_once dirname( __FILE__ ) . '/callback/wings/monit.php';
202
- $module = new BVMonitCallback();
203
- break;
204
- case 'brand':
205
- require_once dirname( __FILE__ ) . '/callback/wings/brand.php';
206
- $module = new BVBrandCallback();
207
- break;
208
- case 'pt':
209
- require_once dirname( __FILE__ ) . '/callback/wings/protect.php';
210
- $module = new BVProtectCallback();
211
- break;
212
- case 'act':
213
- require_once dirname( __FILE__ ) . '/callback/wings/account.php';
214
- $module = new BVAccountCallback();
215
- break;
216
- default:
217
- require_once dirname( __FILE__ ) . '/callback/wings/misc.php';
218
- $module = new BVMiscCallback();
219
- break;
220
- }
221
- $rval = $module->process($method);
222
- if ($rval === false) {
223
- $bvresp->addStatus("statusmsg", "Bad Command");
224
- $bvresp->addStatus("status", false);
225
- }
226
- return 1;
227
- }
228
-
229
- public function bvAdmExecuteWithoutUser() {
230
- global $bvresp;
231
- $bvresp->addStatus("bvadmwithoutuser", true);
232
- $this->execute();
233
- }
234
-
235
- public function bvAdmExecuteWithUser() {
236
- global $bvresp;
237
- $bvresp->addStatus("bvadmwithuser", true);
238
- $this->execute();
239
- }
240
-
241
- public function execute() {
242
- global $bvresp;
243
- $this->processParams();
244
- if ($bvresp->startStream()) {
245
- $this->route($_REQUEST['wing'], $_REQUEST['bvMethod']);
246
- $bvresp->endStream();
247
- }
248
- $this->terminate(true, array_key_exists('bvdbg', $_REQUEST));
249
- }
250
- }
251
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
callback/base.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVCallbackBase')) :
5
+
6
+ class BVCallbackBase {
7
+ public function objectToArray($obj) {
8
+ return json_decode(json_encode($obj), true);
9
+ }
10
+
11
+ public function base64Encode($data, $chunk_size) {
12
+ if ($chunk_size) {
13
+ $out = "";
14
+ $len = strlen($data);
15
+ for ($i = 0; $i < $len; $i += $chunk_size) {
16
+ $out .= base64_encode(substr($data, $i, $chunk_size));
17
+ }
18
+ } else {
19
+ $out = base64_encode($data);
20
+ }
21
+ return $out;
22
+ }
23
+ }
24
+ endif;
callback/handler.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVCallbackHandler')) :
5
+
6
+ class BVCallbackHandler {
7
+ public $db;
8
+ public $settings;
9
+ public $siteinfo;
10
+ public $request;
11
+ public $account;
12
+ public $response;
13
+
14
+ public function __construct($db, $settings, $siteinfo, $request, $account) {
15
+ $this->db = $db;
16
+ $this->settings = $settings;
17
+ $this->siteinfo = $siteinfo;
18
+ $this->request = $request;
19
+ $this->account = $account;
20
+ $this->response = new BVCallbackResponse();
21
+ }
22
+
23
+ public function bvAdmExecuteWithoutUser() {
24
+ $this->execute(array("bvadmwithoutuser" => true));
25
+ }
26
+
27
+ public function bvAdmExecuteWithUser() {
28
+ $this->execute(array("bvadmwithuser" => true));
29
+ }
30
+
31
+ public function execute($resp = array()) {
32
+ $this->routeRequest();
33
+ $bvinfo = new WPEInfo($this->settings);
34
+ $resp = array(
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, $this->request->params);
41
+ }
42
+
43
+ public function routeRequest() {
44
+ switch ($this->request->wing) {
45
+ case 'manage':
46
+ require_once dirname( __FILE__ ) . '/wings/manage.php';
47
+ $module = new BVManageCallback($this);
48
+ break;
49
+ case 'fs':
50
+ require_once dirname( __FILE__ ) . '/wings/fs.php';
51
+ $module = new BVFSCallback($this);
52
+ break;
53
+ case 'db':
54
+ require_once dirname( __FILE__ ) . '/wings/db.php';
55
+ $module = new BVDBCallback($this);
56
+ break;
57
+ case 'info':
58
+ require_once dirname( __FILE__ ) . '/wings/info.php';
59
+ $module = new BVInfoCallback($this);
60
+ break;
61
+ case 'dynsync':
62
+ require_once dirname( __FILE__ ) . '/wings/dynsync.php';
63
+ $module = new BVDynSyncCallback($this);
64
+ break;
65
+ case 'ipstr':
66
+ require_once dirname( __FILE__ ) . '/wings/ipstore.php';
67
+ $module = new BVIPStoreCallback($this);
68
+ break;
69
+ case 'fw':
70
+ require_once dirname( __FILE__ ) . '/wings/fw.php';
71
+ $module = new BVFirewallCallback($this);
72
+ break;
73
+ case 'lp':
74
+ require_once dirname( __FILE__ ) . '/wings/lp.php';
75
+ $module = new BVLoginProtectCallback($this);
76
+ break;
77
+ case 'monit':
78
+ require_once dirname( __FILE__ ) . '/wings/monit.php';
79
+ $module = new BVMonitCallback($this);
80
+ break;
81
+ case 'brand':
82
+ require_once dirname( __FILE__ ) . '/wings/brand.php';
83
+ $module = new BVBrandCallback($this);
84
+ break;
85
+ case 'pt':
86
+ require_once dirname( __FILE__ ) . '/wings/protect.php';
87
+ $module = new BVProtectCallback($this);
88
+ break;
89
+ case 'act':
90
+ require_once dirname( __FILE__ ) . '/wings/account.php';
91
+ $module = new BVAccountCallback($this);
92
+ break;
93
+ default:
94
+ require_once dirname( __FILE__ ) . '/wings/misc.php';
95
+ $module = new BVMiscCallback($this);
96
+ break;
97
+ }
98
+ $resp = $module->process($this->request);
99
+ if ($resp === false) {
100
+ $resp = array(
101
+ "statusmsg" => "Bad Command",
102
+ "status" => false);
103
+ }
104
+ $resp = array(
105
+ $this->request->wing => array(
106
+ $this->request->method => $resp
107
+ )
108
+ );
109
+ $this->response->addStatus("callbackresponse", $resp);
110
+ return 1;
111
+ }
112
+ }
113
+ endif;
callback/request.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVCallbackRequest')) :
5
+ class BVCallbackRequest {
6
+ public $params;
7
+ public $method;
8
+ public $wing;
9
+ public $is_afterload;
10
+ public $is_admin_ajax;
11
+ public $is_debug;
12
+ public $is_recovery;
13
+
14
+ public function __construct($params) {
15
+ $this->params = $params;
16
+ $this->wing = $this->params['wing'];
17
+ $this->method = $this->params['bvMethod'];
18
+ $this->is_afterload = array_key_exists('afterload', $this->params);
19
+ $this->is_admin_ajax = array_key_exists('adajx', $this->params);
20
+ $this->is_debug = array_key_exists('bvdbg', $this->params);
21
+ $this->is_recovery = array_key_exists('bvrcvr', $this->params);
22
+ }
23
+
24
+ public function isAPICall() {
25
+ return array_key_exists('apicall', $this->params);
26
+ }
27
+
28
+ public function respInfo() {
29
+ $info = array(
30
+ "requestedsig" => $this->params['sig'],
31
+ "requestedtime" => intval($this->params['bvTime']),
32
+ "requestedversion" => $this->params['bvVersion']
33
+ );
34
+ if ($this->is_debug) {
35
+ $info["inreq"] = $this->params;
36
+ }
37
+ if ($this->is_admin_ajax) {
38
+ $info["adajx"] = true;
39
+ }
40
+ if ($this->is_afterload) {
41
+ $info["afterload"] = true;
42
+ }
43
+ return $info;
44
+ }
45
+
46
+ public function processParams() {
47
+ $params = $this->params;
48
+ if (array_key_exists('obend', $params) && function_exists('ob_end_clean'))
49
+ @ob_end_clean();
50
+ if (array_key_exists('op_reset', $params) && function_exists('output_reset_rewrite_vars'))
51
+ @output_reset_rewrite_vars();
52
+ if (array_key_exists('binhead', $params)) {
53
+ header("Content-type: application/binary");
54
+ header('Content-Transfer-Encoding: binary');
55
+ }
56
+ if (array_key_exists('concat', $params)) {
57
+ foreach ($params['concat'] as $key) {
58
+ $concated = '';
59
+ $count = intval($params[$key]);
60
+ for ($i = 1; $i <= $count; $i++) {
61
+ $concated .= $params[$key."_bv_".$i];
62
+ }
63
+ $params[$key] = $concated;
64
+ }
65
+ }
66
+ if (array_key_exists('b64', $params)) {
67
+ foreach ($params['b64'] as $key) {
68
+ if (is_array($params[$key])) {
69
+ $params[$key] = array_map('base64_decode', $params[$key]);
70
+ } else {
71
+ $params[$key] = base64_decode($params[$key]);
72
+ }
73
+ }
74
+ }
75
+ if (array_key_exists('unser', $params)) {
76
+ foreach ($params['unser'] as $key) {
77
+ $params[$key] = json_decode($params[$key], TRUE);
78
+ }
79
+ }
80
+ if (array_key_exists('b642', $params)) {
81
+ foreach ($params['b642'] as $key) {
82
+ if (is_array($params[$key])) {
83
+ $params[$key] = array_map('base64_decode', $params[$key]);
84
+ } else {
85
+ $params[$key] = base64_decode($params[$key]);
86
+ }
87
+ }
88
+ }
89
+ if (array_key_exists('dic', $params)) {
90
+ foreach ($params['dic'] as $key => $mkey) {
91
+ $params[$mkey] = $params[$key];
92
+ unset($params[$key]);
93
+ }
94
+ }
95
+ if (array_key_exists('clacts', $params)) {
96
+ foreach ($params['clacts'] as $action) {
97
+ remove_all_actions($action);
98
+ }
99
+ }
100
+ if (array_key_exists('clallacts', $params)) {
101
+ global $wp_filter;
102
+ foreach ( $wp_filter as $filter => $val ){
103
+ remove_all_actions($filter);
104
+ }
105
+ }
106
+ if (array_key_exists('memset', $params)) {
107
+ $val = intval(urldecode($params['memset']));
108
+ @ini_set('memory_limit', $val.'M');
109
+ }
110
+ return $params;
111
+ }
112
+ }
113
+ endif;
callback/response.php CHANGED
@@ -1,107 +1,37 @@
1
  <?php
2
 
3
  if (!defined('ABSPATH')) exit;
4
- if (!class_exists('BVResponse')) :
5
-
6
- require_once dirname( __FILE__ ) . '/streams.php';
7
 
8
- class BVResponse {
9
- public $status;
10
- public $stream;
11
 
12
- function __construct() {
13
- $this->status = array("blogvault" => "response");
14
- }
15
-
16
- public function addStatus($key, $value) {
17
- $this->status[$key] = $value;
18
- }
19
-
20
- public function addArrayToStatus($key, $value) {
21
- if (!isset($this->status[$key])) {
22
- $this->status[$key] = array();
23
- }
24
- $this->status[$key][] = $value;
25
- }
26
-
27
- public function base64Encode($data, $chunk_size) {
28
- if ($chunk_size) {
29
- $out = "";
30
- $len = strlen($data);
31
- for ($i = 0; $i < $len; $i += $chunk_size) {
32
- $out .= base64_encode(substr($data, $i, $chunk_size));
33
- }
34
- } else {
35
- $out = base64_encode($data);
36
  }
37
- return $out;
38
- }
39
 
40
- public function finish() {
41
- $response = "bvbvbvbvbv".serialize($this->status)."bvbvbvbvbv";
42
- if (array_key_exists('bvb64resp', $_REQUEST)) {
43
- $chunk_size = array_key_exists('bvb64cksize', $_REQUEST) ? intval($_REQUEST['bvb64cksize']) : false;
44
- $response = "bvb64bvb64".$this->base64Encode($response, $chunk_size)."bvb64bvb64";
45
  }
46
- die($response);
47
- }
48
 
49
- public function writeStream($_string) {
50
- if (strlen($_string) > 0) {
51
- $chunk = "";
52
- if (isset($_REQUEST['bvb64stream'])) {
53
- $chunk_size = array_key_exists('bvb64cksize', $_REQUEST) ? intval($_REQUEST['bvb64cksize']) : false;
54
- $_string = $this->base64Encode($_string, $chunk_size);
55
- $chunk .= "BVB64" . ":";
56
  }
57
- $chunk .= (strlen($_string) . ":" . $_string);
58
- if (isset($_REQUEST['checksum'])) {
59
- if ($_REQUEST['checksum'] == 'crc32') {
60
- $chunk = "CRC32" . ":" . crc32($_string) . ":" . $chunk;
61
- } else if ($_REQUEST['checksum'] == 'md5') {
62
- $chunk = "MD5" . ":" . md5($_string) . ":" . $chunk;
63
- }
64
- }
65
- $this->stream->writeChunk($chunk);
66
  }
67
- }
68
 
69
- public function startStream() {
70
- global $bvcb;
71
- $this->stream = new BVRespStream();
72
- if (array_key_exists('apicall',$_REQUEST)) {
73
- $this->stream = new BVHttpStream($_REQUEST['apihost'], intval($_REQUEST['apiport']), array_key_exists('apissl', $_REQUEST));
74
- if (!$this->stream->connect()) {
75
- $this->addStatus("httperror", "Cannot Open Connection to Host");
76
- $this->addStatus("streamerrno", $this->stream->errno);
77
- $this->addStatus("streamerrstr", $this->stream->errstr);
78
- return false;
79
  }
80
- if (array_key_exists('acbmthd', $_REQUEST)) {
81
- $url = $bvcb->bvmain->authenticatedUrl('/bvapi/'.$_REQUEST['acbmthd'], $_REQUEST['bvapicheck'], false);
82
- if (array_key_exists('acbqry', $_REQUEST)) {
83
- $url .= "&".$_REQUEST['acbqry'];
84
- }
85
- $this->stream->multipartChunkedPost($url);
86
- } else {
87
- $this->addStatus("httperror", "ApiCall method not present");
88
- return false;
89
- }
90
- }
91
- return true;
92
- }
93
 
94
- public function endStream() {
95
- $this->stream->endStream();
96
- if (array_key_exists('apicall', $_REQUEST)) {
97
- $resp = $this->stream->getResponse();
98
- if (array_key_exists('httperror', $resp)) {
99
- $this->addStatus("httperror", $resp['httperror']);
100
- } else {
101
- $this->addStatus("respstatus", $resp['status']);
102
- $this->addStatus("respstatus_string", $resp['status_string']);
103
- }
104
  }
105
  }
106
- }
107
  endif;
1
  <?php
2
 
3
  if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVCallbackResponse')) :
 
 
5
 
6
+ class BVCallbackResponse extends BVCallbackBase {
7
+ public $status;
 
8
 
9
+ public function __construct() {
10
+ $this->status = array("blogvault" => "response");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
 
 
12
 
13
+ public function addStatus($key, $value) {
14
+ $this->status[$key] = $value;
 
 
 
15
  }
 
 
16
 
17
+ public function addArrayToStatus($key, $value) {
18
+ if (!isset($this->status[$key])) {
19
+ $this->status[$key] = array();
 
 
 
 
20
  }
21
+ $this->status[$key][] = $value;
 
 
 
 
 
 
 
 
22
  }
 
23
 
24
+ public function terminate($resp = array(), $req_params) {
25
+ $resp = array_merge($this->status, $resp);
26
+ $resp["signature"] = "Blogvault API";
27
+ $response = "bvbvbvbvbv".serialize($resp)."bvbvbvbvbv";
28
+ if (array_key_exists('bvb64resp', $req_params)) {
29
+ $chunk_size = array_key_exists('bvb64cksize', $req_params) ? intval($req_params['bvb64cksize']) : false;
30
+ $response = "bvb64bvb64".$this->base64Encode($response, $chunk_size)."bvb64bvb64";
 
 
 
31
  }
32
+ die($response);
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
+ exit;
 
 
 
 
 
 
 
 
 
35
  }
36
  }
 
37
  endif;
callback/streams.php CHANGED
@@ -2,18 +2,85 @@
2
 
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('BVRespStream')) :
5
-
6
- class BVRespStream {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  public function writeChunk($_string) {
8
  echo "ckckckckck".$_string."ckckckckck";
9
  }
10
 
11
  public function endStream() {
12
  echo "rerererere";
 
 
13
  }
14
  }
15
 
16
- class BVHttpStream {
17
  var $user_agent = 'BVHttpStream';
18
  var $host;
19
  var $port;
@@ -24,13 +91,11 @@ class BVHttpStream {
24
  var $boundary;
25
  var $apissl;
26
 
27
- /**
28
- * PHP5 constructor.
29
- */
30
- function __construct($_host, $_port, $_apissl) {
31
- $this->host = $_host;
32
- $this->port = $_port;
33
- $this->apissl = $_apissl;
34
  }
35
 
36
  public function connect() {
@@ -95,8 +160,8 @@ class BVHttpStream {
95
 
96
  public function multipartChunkedPost($url) {
97
  $mph = array(
98
- "Content-Disposition" => "form-data; name=bvinfile; filename=data",
99
- "Content-Type" => "application/octet-stream"
100
  );
101
  $rnd = rand(100000, 999999);
102
  $this->boundary = "----".$rnd;
@@ -122,6 +187,16 @@ class BVHttpStream {
122
  $epilogue = "\r\n\r\n--".$this->boundary."--\r\n";
123
  $this->sendChunk($epilogue);
124
  $this->closeChunk();
 
 
 
 
 
 
 
 
 
 
125
  }
126
 
127
  public function getResponse() {
2
 
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('BVRespStream')) :
5
+
6
+ class BVStream extends BVCallbackBase {
7
+ public $bvb64stream;
8
+ public $bvb64cksize;
9
+ public $checksum;
10
+
11
+ function __construct($params) {
12
+ $this->bvb64stream = isset($params['bvb64stream']);
13
+ $this->bvb64cksize = array_key_exists('bvb64cksize', $params) ? intval($params['bvb64cksize']) : false;
14
+ $this->checksum = array_key_exists('checksum', $params) ? $params['checksum'] : false;
15
+ }
16
+
17
+ public function writeChunk($chunk) {
18
+ }
19
+
20
+ public static function startStream($account, $request) {
21
+ $result = array();
22
+ $params = $request->params;
23
+ $stream = new BVRespStream($params);
24
+ if ($request->isAPICall()) {
25
+ $stream = new BVHttpStream($params);
26
+ if (!$stream->connect()) {
27
+ $apicallstatus = array(
28
+ "httperror" => "Cannot Open Connection to Host",
29
+ "streamerrno" => $stream->errno,
30
+ "streamerrstr" => $stream->errstr
31
+ );
32
+ return array("apicallstatus" => $apicallstatus);
33
+ }
34
+ if (array_key_exists('acbmthd', $params)) {
35
+ $qstr = http_build_query(array('bvapicheck' => $params['bvapicheck']));
36
+ $url = '/bvapi/'.$params['acbmthd']."?".$qstr;
37
+ if (array_key_exists('acbqry', $params)) {
38
+ $url .= "&".$params['acbqry'];
39
+ }
40
+ $stream->multipartChunkedPost($url);
41
+ } else {
42
+ return array("apicallstatus" => array("httperror" => "ApiCall method not present"));
43
+ }
44
+ }
45
+ return array('stream' => $stream);
46
+ }
47
+
48
+ public function writeStream($_string) {
49
+ if (strlen($_string) > 0) {
50
+ $chunk = "";
51
+ if ($this->bvb64stream) {
52
+ $chunk_size = $this->bvb64cksize;
53
+ $_string = $this->base64Encode($_string, $chunk_size);
54
+ $chunk .= "BVB64" . ":";
55
+ }
56
+ $chunk .= (strlen($_string) . ":" . $_string);
57
+ if ($this->checksum == 'crc32') {
58
+ $chunk = "CRC32" . ":" . crc32($_string) . ":" . $chunk;
59
+ } else if ($this->checksum == 'md5') {
60
+ $chunk = "MD5" . ":" . md5($_string) . ":" . $chunk;
61
+ }
62
+ $this->writeChunk($chunk);
63
+ }
64
+ }
65
+ }
66
+
67
+ class BVRespStream extends BVStream {
68
+ function __construct($params) {
69
+ parent::__construct($params);
70
+ }
71
+
72
  public function writeChunk($_string) {
73
  echo "ckckckckck".$_string."ckckckckck";
74
  }
75
 
76
  public function endStream() {
77
  echo "rerererere";
78
+
79
+ return array();
80
  }
81
  }
82
 
83
+ class BVHttpStream extends BVStream {
84
  var $user_agent = 'BVHttpStream';
85
  var $host;
86
  var $port;
91
  var $boundary;
92
  var $apissl;
93
 
94
+ function __construct($params) {
95
+ parent::__construct($params);
96
+ $this->host = $params['apihost'];
97
+ $this->port = intval($params['apiport']);
98
+ $this->apissl = array_key_exists('apissl', $params);
 
 
99
  }
100
 
101
  public function connect() {
160
 
161
  public function multipartChunkedPost($url) {
162
  $mph = array(
163
+ "Content-Disposition" => "form-data; name=bvinfile; filename=data",
164
+ "Content-Type" => "application/octet-stream"
165
  );
166
  $rnd = rand(100000, 999999);
167
  $this->boundary = "----".$rnd;
187
  $epilogue = "\r\n\r\n--".$this->boundary."--\r\n";
188
  $this->sendChunk($epilogue);
189
  $this->closeChunk();
190
+
191
+ $result = array();
192
+ $resp = $this->getResponse();
193
+ if (array_key_exists('httperror', $resp)) {
194
+ $result["httperror"] = $resp['httperror'];
195
+ } else {
196
+ $result["respstatus"] = $resp['status'];
197
+ $result["respstatus_string"] = $resp['status_string'];
198
+ }
199
+ return array("apicallstatus" => $result);
200
  }
201
 
202
  public function getResponse() {
callback/wings/account.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVAccountCallback')) :
5
+ class BVAccountCallback extends BVCallbackBase {
6
+ public $account;
7
+ public $settings;
8
+
9
+ public function __construct($callback_handler) {
10
+ $this->account = $callback_handler->account;
11
+ $this->settings = $callback_handler->settings;
12
+ }
13
+
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" => WPEAccount::allAccounts($this->settings));
40
+ break;
41
+ default:
42
+ $resp = false;
43
+ }
44
+ return $resp;
45
+ }
46
+ }
47
+ endif;
callback/wings/auth.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
-
3
- if (!defined('ABSPATH')) exit;
4
- if (!class_exists('BVAuthCallback')) :
5
- class BVAuthCallback {
6
-
7
- function process($method) {
8
- global $bvresp, $bvcb;
9
- $auth = $bvcb->bvmain->auth;
10
- switch ($method) {
11
- case "addkeys":
12
- $bvresp->addStatus("status", $auth->addKeys($_REQUEST['public'], $_REQUEST['secret']));
13
- break;
14
- case "updatekeys":
15
- $bvresp->addStatus("status", $auth->updateKeys($_REQUEST['public'], $_REQUEST['secret']));
16
- break;
17
- case "rmkeys":
18
- $bvresp->addStatus("status", $auth->rmKeys($_REQUEST['public']));
19
- break;
20
- default:
21
- return false;
22
- }
23
- return true;
24
- }
25
- }
26
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
callback/wings/brand.php CHANGED
@@ -3,46 +3,52 @@
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('BVBrandCallback')) :
5
 
6
- class BVBrandCallback {
7
- public function process($method) {
8
- global $bvresp, $bvcb;
9
- $info = $bvcb->bvmain->info;
10
- $option_name = $bvcb->bvmain->brand_option;
11
- switch($method) {
 
 
 
 
 
 
12
  case 'setbrand':
13
  $brandinfo = array();
14
- if (array_key_exists('hide', $_REQUEST)) {
15
- $brandinfo['hide'] = $_REQUEST['hide'];
16
  } else {
17
- $brandinfo['name'] = $_REQUEST['name'];
18
- $brandinfo['title'] = $_REQUEST['title'];
19
- $brandinfo['description'] = $_REQUEST['description'];
20
- $brandinfo['pluginuri'] = $_REQUEST['pluginuri'];
21
- $brandinfo['author'] = $_REQUEST['author'];
22
- $brandinfo['authorname'] = $_REQUEST['authorname'];
23
- $brandinfo['authoruri'] = $_REQUEST['authoruri'];
24
- $brandinfo['menuname'] = $_REQUEST['menuname'];
25
- $brandinfo['logo'] = $_REQUEST['logo'];
26
- $brandinfo['webpage'] = $_REQUEST['webpage'];
27
- $brandinfo['appurl'] = $_REQUEST['appurl'];
28
- if (array_key_exists('hide_plugin_details', $_REQUEST)) {
29
- $brandinfo['hide_plugin_details'] = $_REQUEST['hide_plugin_details'];
30
  }
31
- if (array_key_exists('hide_from_menu', $_REQUEST)) {
32
- $brandinfo['hide_from_menu'] = $_REQUEST['hide_from_menu'];
33
  }
34
  }
35
- $info->updateOption($option_name, $brandinfo);
36
- $bvresp->addStatus("setbrand", $info->getOption($option_name));
37
  break;
38
  case 'rmbrand':
39
- $info->deleteOption($option_name);
40
- $bvresp->addStatus("rmbrand", !$info->getOption($option_name));
41
  break;
42
  default:
43
- return false;
44
  }
45
- return true;
46
  }
47
  }
48
  endif;
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('BVBrandCallback')) :
5
 
6
+ class BVBrandCallback extends BVCallbackBase {
7
+ public $settings;
8
+
9
+ public function __construct($callback_handler) {
10
+ $this->settings = $callback_handler->settings;
11
+ }
12
+
13
+ public function process($request) {
14
+ $bvinfo = new WPEInfo($this->settings);
15
+ $option_name = $bvinfo->brand_option;
16
+ $params = $request->params;
17
+ switch($request->method) {
18
  case 'setbrand':
19
  $brandinfo = array();
20
+ if (array_key_exists('hide', $params)) {
21
+ $brandinfo['hide'] = $params['hide'];
22
  } else {
23
+ $brandinfo['name'] = $params['name'];
24
+ $brandinfo['title'] = $params['title'];
25
+ $brandinfo['description'] = $params['description'];
26
+ $brandinfo['pluginuri'] = $params['pluginuri'];
27
+ $brandinfo['author'] = $params['author'];
28
+ $brandinfo['authorname'] = $params['authorname'];
29
+ $brandinfo['authoruri'] = $params['authoruri'];
30
+ $brandinfo['menuname'] = $params['menuname'];
31
+ $brandinfo['logo'] = $params['logo'];
32
+ $brandinfo['webpage'] = $params['webpage'];
33
+ $brandinfo['appurl'] = $params['appurl'];
34
+ if (array_key_exists('hide_plugin_details', $params)) {
35
+ $brandinfo['hide_plugin_details'] = $params['hide_plugin_details'];
36
  }
37
+ if (array_key_exists('hide_from_menu', $params)) {
38
+ $brandinfo['hide_from_menu'] = $params['hide_from_menu'];
39
  }
40
  }
41
+ $this->settings->updateOption($option_name, $brandinfo);
42
+ $resp = array("setbrand" => $this->settings->getOption($option_name));
43
  break;
44
  case 'rmbrand':
45
+ $this->settings->deleteOption($option_name);
46
+ $resp = array("rmbrand" => !$this->settings->getOption($option_name));
47
  break;
48
  default:
49
+ $resp = false;
50
  }
51
+ return $resp;
52
  }
53
  }
54
  endif;
callback/wings/db.php CHANGED
@@ -2,7 +2,17 @@
2
 
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('BVDBCallback')) :
5
- class BVDBCallback {
 
 
 
 
 
 
 
 
 
 
6
 
7
  public function getLastID($pkeys, $end_row) {
8
  $last_ids = array();
@@ -13,11 +23,10 @@ class BVDBCallback {
13
  }
14
 
15
  public function getTableData($table, $tname, $rcount, $offset, $limit, $bsize, $filter, $pkeys, $include_rows = false) {
16
- global $bvcb, $bvresp;
17
  $tinfo = array();
18
 
19
- $rows_count = $bvcb->bvmain->db->rowsCount($table);
20
- $bvresp->addStatus('count', $rows_count);
21
  if ($limit == 0) {
22
  $limit = $rows_count;
23
  }
@@ -25,7 +34,7 @@ class BVDBCallback {
25
  while (($limit > 0) && ($srows > 0)) {
26
  if ($bsize > $limit)
27
  $bsize = $limit;
28
- $rows = $bvcb->bvmain->db->getTableContent($table, '*', $filter, $bsize, $offset);
29
  $srows = sizeof($rows);
30
  $data = array();
31
  $data["offset"] = $offset;
@@ -36,110 +45,127 @@ class BVDBCallback {
36
  $end_row = end($rows);
37
  $last_ids = $this->getLastID($pkeys, $end_row);
38
  $data['last_ids'] = $last_ids;
39
- $bvresp->addStatus('last_ids', $last_ids);
40
  }
41
  if ($include_rows) {
42
  $data["rows"] = $rows;
43
  $str = serialize($data);
44
- $bvresp->writeStream($str);
45
  }
46
  $offset += $srows;
47
  $limit -= $srows;
48
  }
49
- $bvresp->addStatus('size', $offset);
50
- $bvresp->addStatus('tinfo', $tinfo);
 
51
  }
52
 
53
- public function process($method) {
54
- global $bvresp, $bvcb;
55
- $db = $bvcb->bvmain->db;
56
- switch ($method) {
57
- case "gettbls":
58
- $bvresp->addStatus("tables", $db->showTables());
59
- break;
60
- case "tblstatus":
61
- $bvresp->addStatus("statuses", $db->showTableStatus());
62
- break;
63
- case "tablekeys":
64
- $table = urldecode($_REQUEST['table']);
65
- $bvresp->addStatus("table_keys", $db->tableKeys($table));
66
- break;
67
- case "describetable":
68
- $table = urldecode($_REQUEST['table']);
69
- $bvresp->addStatus("table_description", $db->describeTable($table));
70
- break;
71
- case "checktable":
72
- $table = urldecode($_REQUEST['table']);
73
- $type = urldecode($_REQUEST['type']);
74
- $bvresp->addStatus("status", $db->checkTable($table, $type));
75
- break;
76
- case "repairtable":
77
- $table = urldecode($_REQUEST['table']);
78
- $bvresp->addStatus("status", $db->repairTable($table));
79
- break;
80
- case "gettcrt":
81
- $table = urldecode($_REQUEST['table']);
82
- $bvresp->addStatus("create", $db->showTableCreate($table));
83
- break;
84
- case "getrowscount":
85
- $table = urldecode($_REQUEST['table']);
86
- $bvresp->addStatus("count", $db->rowsCount($table));
87
- break;
88
- case "gettablecontent":
89
- $table = urldecode($_REQUEST['table']);
90
- $fields = urldecode($_REQUEST['fields']);
91
- $filter = (array_key_exists('filter', $_REQUEST)) ? urldecode($_REQUEST['filter']) : "";
92
- $limit = intval(urldecode($_REQUEST['limit']));
93
- $offset = intval(urldecode($_REQUEST['offset']));
94
- $pkeys = (array_key_exists('pkeys', $_REQUEST)) ? $_REQUEST['pkeys'] : array();
95
- $bvresp->addStatus('timestamp', time());
96
- $bvresp->addStatus('tablename', $table);
97
- $rows = $db->getTableContent($table, $fields, $filter, $limit, $offset);
98
- $srows = sizeof($rows);
99
- if (!empty($pkeys) && $srows > 0) {
100
- $end_row = end($rows);
101
- $bvresp->addStatus('last_ids', $this->getLastID($pkeys, $end_row));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  }
103
- $bvresp->addStatus("rows", $rows);
104
- break;
105
- case "tableinfo":
106
- $table = urldecode($_REQUEST['table']);
107
- $offset = intval(urldecode($_REQUEST['offset']));
108
- $limit = intval(urldecode($_REQUEST['limit']));
109
- $bsize = intval(urldecode($_REQUEST['bsize']));
110
- $filter = (array_key_exists('filter', $_REQUEST)) ? urldecode($_REQUEST['filter']) : "";
111
- $rcount = intval(urldecode($_REQUEST['rcount']));
112
- $tname = urldecode($_REQUEST['tname']);
113
- $pkeys = (array_key_exists('pkeys', $_REQUEST)) ? $_REQUEST['pkeys'] : array();
114
- $this->getTableData($table, $tname, $rcount, $offset, $limit, $bsize, $filter, $pkeys, false);
115
- break;
116
- case "uploadrows":
117
- $table = urldecode($_REQUEST['table']);
118
- $offset = intval(urldecode($_REQUEST['offset']));
119
- $limit = intval(urldecode($_REQUEST['limit']));
120
- $bsize = intval(urldecode($_REQUEST['bsize']));
121
- $filter = (array_key_exists('filter', $_REQUEST)) ? urldecode($_REQUEST['filter']) : "";
122
- $rcount = intval(urldecode($_REQUEST['rcount']));
123
- $tname = urldecode($_REQUEST['tname']);
124
- $pkeys = (array_key_exists('pkeys', $_REQUEST)) ? $_REQUEST['pkeys'] : array();
125
- $this->getTableData($table, $tname, $rcount, $offset, $limit, $bsize, $filter, $pkeys, true);
126
- break;
127
- case "tblexists":
128
- $bvresp->addStatus("tblexists", $db->isTablePresent($_REQUEST['tablename']));
129
- break;
130
- case "crttbl":
131
- $bvresp->addStatus("crttbl", $db->createTable($_REQUEST['query'], $_REQUEST['tablename']));
132
- break;
133
- case "drptbl":
134
- $bvresp->addStatus("drptbl", $db->dropBVTable($_REQUEST['name']));
135
- break;
136
- case "trttbl":
137
- $bvresp->addStatus("trttbl", $db->truncateBVTable($_REQUEST['name']));
138
- break;
139
- default:
140
- return false;
141
  }
142
- return true;
143
  }
144
  }
145
  endif;
2
 
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('BVDBCallback')) :
5
+ require_once dirname( __FILE__ ) . '/../streams.php';
6
+
7
+ class BVDBCallback extends BVCallbackBase {
8
+ public $db;
9
+ public $stream;
10
+ public $account;
11
+
12
+ public function __construct($callback_handler) {
13
+ $this->db = $callback_handler->db;
14
+ $this->account = $callback_handler->account;
15
+ }
16
 
17
  public function getLastID($pkeys, $end_row) {
18
  $last_ids = array();
23
  }
24
 
25
  public function getTableData($table, $tname, $rcount, $offset, $limit, $bsize, $filter, $pkeys, $include_rows = false) {
 
26
  $tinfo = array();
27
 
28
+ $rows_count = $this->db->rowsCount($table);
29
+ $result = array('count' => $rows_count);
30
  if ($limit == 0) {
31
  $limit = $rows_count;
32
  }
34
  while (($limit > 0) && ($srows > 0)) {
35
  if ($bsize > $limit)
36
  $bsize = $limit;
37
+ $rows = $this->db->getTableContent($table, '*', $filter, $bsize, $offset);
38
  $srows = sizeof($rows);
39
  $data = array();
40
  $data["offset"] = $offset;
45
  $end_row = end($rows);
46
  $last_ids = $this->getLastID($pkeys, $end_row);
47
  $data['last_ids'] = $last_ids;
48
+ $result['last_ids'] = $last_ids;
49
  }
50
  if ($include_rows) {
51
  $data["rows"] = $rows;
52
  $str = serialize($data);
53
+ $this->stream->writeStream($str);
54
  }
55
  $offset += $srows;
56
  $limit -= $srows;
57
  }
58
+ $result['size'] = $offset;
59
+ $result['tinfo'] = $tinfo;
60
+ return $result;
61
  }
62
 
63
+ public function process($request) {
64
+ $db = $this->db;
65
+ $params = $request->params;
66
+ $stream_init_info = BVStream::startStream($this->account, $request);
67
+ if (array_key_exists('stream', $stream_init_info)) {
68
+ $this->stream = $stream_init_info['stream'];
69
+ switch ($request->method) {
70
+ case "gettbls":
71
+ $resp = array("tables" => $db->showTables());
72
+ break;
73
+ case "tblstatus":
74
+ $resp = array("statuses" => $db->showTableStatus());
75
+ break;
76
+ case "tablekeys":
77
+ $table = urldecode($params['table']);
78
+ $resp = array("table_keys" => $db->tableKeys($table));
79
+ break;
80
+ case "describetable":
81
+ $table = urldecode($params['table']);
82
+ $resp = array("table_description" => $db->describeTable($table));
83
+ break;
84
+ case "checktable":
85
+ $table = urldecode($params['table']);
86
+ $type = urldecode($params['type']);
87
+ $resp = array("status" => $db->checkTable($table, $type));
88
+ break;
89
+ case "repairtable":
90
+ $table = urldecode($params['table']);
91
+ $resp = array("status" => $db->repairTable($table));
92
+ break;
93
+ case "gettcrt":
94
+ $table = urldecode($params['table']);
95
+ $resp = array("create" => $db->showTableCreate($table));
96
+ break;
97
+ case "getrowscount":
98
+ $table = urldecode($params['table']);
99
+ $resp = array("count" => $db->rowsCount($table));
100
+ break;
101
+ case "gettablecontent":
102
+ $result = array();
103
+ $table = urldecode($params['table']);
104
+ $fields = urldecode($params['fields']);
105
+ $filter = (array_key_exists('filter', $params)) ? urldecode($params['filter']) : "";
106
+ $limit = intval(urldecode($params['limit']));
107
+ $offset = intval(urldecode($params['offset']));
108
+ $pkeys = (array_key_exists('pkeys', $params)) ? $params['pkeys'] : array();
109
+ $result['timestamp'] = time();
110
+ $result['tablename'] = $table;
111
+ $rows = $db->getTableContent($table, $fields, $filter, $limit, $offset);
112
+ $srows = sizeof($rows);
113
+ if (!empty($pkeys) && $srows > 0) {
114
+ $end_row = end($rows);
115
+ $result['last_ids'] = $this->getLastID($pkeys, $end_row);
116
+ }
117
+ $result["rows"] = $rows;
118
+ $resp = $result;
119
+ break;
120
+ case "tableinfo":
121
+ $table = urldecode($params['table']);
122
+ $offset = intval(urldecode($params['offset']));
123
+ $limit = intval(urldecode($params['limit']));
124
+ $bsize = intval(urldecode($params['bsize']));
125
+ $filter = (array_key_exists('filter', $params)) ? urldecode($params['filter']) : "";
126
+ $rcount = intval(urldecode($params['rcount']));
127
+ $tname = urldecode($params['tname']);
128
+ $pkeys = (array_key_exists('pkeys', $params)) ? $params['pkeys'] : array();
129
+ $resp = $this->getTableData($table, $tname, $rcount, $offset, $limit, $bsize, $filter, $pkeys, false);
130
+ break;
131
+ case "uploadrows":
132
+ $table = urldecode($params['table']);
133
+ $offset = intval(urldecode($params['offset']));
134
+ $limit = intval(urldecode($params['limit']));
135
+ $bsize = intval(urldecode($params['bsize']));
136
+ $filter = (array_key_exists('filter', $params)) ? urldecode($params['filter']) : "";
137
+ $rcount = intval(urldecode($params['rcount']));
138
+ $tname = urldecode($params['tname']);
139
+ $pkeys = (array_key_exists('pkeys', $params)) ? $params['pkeys'] : array();
140
+ $resp = $this->getTableData($table, $tname, $rcount, $offset, $limit, $bsize, $filter, $pkeys, true);
141
+ break;
142
+ case "tblexists":
143
+ $resp = array("tblexists" => $db->isTablePresent($params['tablename']));
144
+ break;
145
+ case "crttbl":
146
+ $usedbdelta = array_key_exists('usedbdelta', $params);
147
+ $resp = array("crttbl" => $db->createTable($params['query'], $params['tablename'], $usedbdelta));
148
+ break;
149
+ case "drptbl":
150
+ $resp = array("drptbl" => $db->dropBVTable($params['name']));
151
+ break;
152
+ case "trttbl":
153
+ $resp = array("trttbl" => $db->truncateBVTable($params['name']));
154
+ break;
155
+ case "altrtbl":
156
+ $resp = array("altrtbl" => $db->alterBVTable($params['query'], $params['query']));
157
+ break;
158
+ default:
159
+ $resp = false;
160
+ }
161
+ $end_stream_info = $this->stream->endStream();
162
+ if (!empty($end_stream_info) && is_array($resp)) {
163
+ $resp = array_merge($resp, $end_stream_info);
164
  }
165
+ } else {
166
+ $resp = $stream_init_info;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  }
168
+ return $resp;
169
  }
170
  }
171
  endif;
callback/wings/fs.php CHANGED
@@ -2,7 +2,16 @@
2
 
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('BVFSCallback')) :
5
- class BVFSCallback {
 
 
 
 
 
 
 
 
 
6
  function fileStat($relfile) {
7
  $absfile = ABSPATH.$relfile;
8
  $fdata = array();
@@ -22,7 +31,6 @@ class BVFSCallback {
22
  }
23
 
24
  function scanFilesUsingGlob($initdir = "./", $offset = 0, $limit = 0, $bsize = 512, $recurse = true, $regex = '{.??,}*') {
25
- global $bvresp;
26
  $i = 0;
27
  $dirs = array();
28
  $dirs[] = $initdir;
@@ -51,7 +59,7 @@ class BVFSCallback {
51
  $bfc++;
52
  if ($bfc == $bsize) {
53
  $str = serialize($bfa);
54
- $bvresp->writeStream($str);
55
  $bfc = 0;
56
  $bfa = array();
57
  }
@@ -63,12 +71,12 @@ class BVFSCallback {
63
  }
64
  if ($bfc != 0) {
65
  $str = serialize($bfa);
66
- $bvresp->writeStream($str);
67
  }
 
68
  }
69
 
70
  function scanFiles($initdir = "./", $offset = 0, $limit = 0, $bsize = 512, $recurse = true) {
71
- global $bvresp;
72
  $i = 0;
73
  $dirs = array();
74
  $dirs[] = $initdir;
@@ -97,7 +105,7 @@ class BVFSCallback {
97
  $bfc++;
98
  if ($bfc == $bsize) {
99
  $str = serialize($bfa);
100
- $bvresp->writeStream($str);
101
  $bfc = 0;
102
  $bfa = array();
103
  }
@@ -110,8 +118,9 @@ class BVFSCallback {
110
  }
111
  if ($bfc != 0) {
112
  $str = serialize($bfa);
113
- $bvresp->writeStream($str);
114
  }
 
115
  }
116
 
117
  function calculateMd5($absfile, $fdata, $offset, $limit, $bsize) {
@@ -141,27 +150,27 @@ class BVFSCallback {
141
  }
142
 
143
  function getFilesStats($files, $offset = 0, $limit = 0, $bsize = 102400, $md5 = false) {
144
- global $bvresp;
145
  foreach ($files as $file) {
146
  $fdata = $this->fileStat($file);
147
  $absfile = ABSPATH.$file;
148
  if (!is_readable($absfile)) {
149
- $bvresp->addArrayToStatus("missingfiles", $file);
150
  continue;
151
  }
152
  if ($md5 === true) {
153
  $fdata["md5"] = $this->calculateMd5($absfile, $fdata, $offset, $limit, $bsize);
154
  }
155
- $bvresp->addArrayToStatus("stats", $fdata);
156
  }
 
157
  }
158
 
159
  function uploadFiles($files, $offset = 0, $limit = 0, $bsize = 102400) {
160
- global $bvresp;
161
-
162
  foreach ($files as $file) {
163
  if (!is_readable(ABSPATH.$file)) {
164
- $bvresp->addArrayToStatus("missingfiles", $file);
165
  continue;
166
  }
167
  $handle = fopen(ABSPATH.$file, "rb");
@@ -175,7 +184,7 @@ class BVFSCallback {
175
  $_limit = $fdata["size"] - $offset;
176
  $fdata["limit"] = $_limit;
177
  $sfdata = serialize($fdata);
178
- $bvresp->writeStream($sfdata);
179
  fseek($handle, $offset, SEEK_SET);
180
  $dlen = 1;
181
  while (($_limit > 0) && ($dlen > 0)) {
@@ -183,76 +192,89 @@ class BVFSCallback {
183
  $_bsize = $_limit;
184
  $d = fread($handle, $_bsize);
185
  $dlen = strlen($d);
186
- $bvresp->writeStream($d);
187
  $_limit -= $dlen;
188
  }
189
  fclose($handle);
190
  } else {
191
- $bvresp->addArrayToStatus("unreadablefiles", $file);
192
  }
193
  }
 
 
194
  }
195
 
196
- function process($method) {
197
- switch ($method) {
198
- case "scanfilesglob":
199
- $initdir = urldecode($_REQUEST['initdir']);
200
- $offset = intval(urldecode($_REQUEST['offset']));
201
- $limit = intval(urldecode($_REQUEST['limit']));
202
- $bsize = intval(urldecode($_REQUEST['bsize']));
203
- $regex = urldecode($_REQUEST['regex']);
204
- $recurse = true;
205
- if (array_key_exists('recurse', $_REQUEST) && $_REQUEST["recurse"] == "false") {
206
- $recurse = false;
207
- }
208
- $this->scanFilesUsingGlob($initdir, $offset, $limit, $bsize, $recurse, $regex);
209
- break;
210
- case "scanfiles":
211
- $initdir = urldecode($_REQUEST['initdir']);
212
- $offset = intval(urldecode($_REQUEST['offset']));
213
- $limit = intval(urldecode($_REQUEST['limit']));
214
- $bsize = intval(urldecode($_REQUEST['bsize']));
215
- $recurse = true;
216
- if (array_key_exists('recurse', $_REQUEST) && $_REQUEST["recurse"] == "false") {
217
- $recurse = false;
218
- }
219
- $this->scanFiles($initdir, $offset, $limit, $bsize, $recurse);
220
- break;
221
- case "getfilesstats":
222
- $files = $_REQUEST['files'];
223
- $offset = intval(urldecode($_REQUEST['offset']));
224
- $limit = intval(urldecode($_REQUEST['limit']));
225
- $bsize = intval(urldecode($_REQUEST['bsize']));
226
- $md5 = false;
227
- if (array_key_exists('md5', $_REQUEST)) {
228
- $md5 = true;
229
- }
230
- $this->getFilesStats($files, $offset, $limit, $bsize, $md5);
231
- break;
232
- case "sendmanyfiles":
233
- $files = $_REQUEST['files'];
234
- $offset = intval(urldecode($_REQUEST['offset']));
235
- $limit = intval(urldecode($_REQUEST['limit']));
236
- $bsize = intval(urldecode($_REQUEST['bsize']));
237
- $this->uploadFiles($files, $offset, $limit, $bsize);
238
- break;
239
- case "filelist":
240
- $initdir = $_REQUEST['initdir'];
241
- $glob_option = GLOB_MARK;
242
- if(array_key_exists('onlydir', $_REQUEST)) {
243
- $glob_option = GLOB_ONLYDIR;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  }
245
- $regex = "*";
246
- if(array_key_exists('regex', $_REQUEST)){
247
- $regex = $_REQUEST['regex'];
248
  }
249
- $directoryList = glob($initdir.$regex, $glob_option);
250
- $this->getFilesStats($directoryList);
251
- break;
252
- default:
253
- return false;
254
  }
255
- return true;
256
  }
257
  }
258
  endif;
2
 
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('BVFSCallback')) :
5
+ require_once dirname( __FILE__ ) . '/../streams.php';
6
+
7
+ class BVFSCallback extends BVCallbackBase {
8
+ public $stream;
9
+ public $account;
10
+
11
+ public function __construct($callback_handler) {
12
+ $this->account = $callback_handler->account;
13
+ }
14
+
15
  function fileStat($relfile) {
16
  $absfile = ABSPATH.$relfile;
17
  $fdata = array();
31
  }
32
 
33
  function scanFilesUsingGlob($initdir = "./", $offset = 0, $limit = 0, $bsize = 512, $recurse = true, $regex = '{.??,}*') {
 
34
  $i = 0;
35
  $dirs = array();
36
  $dirs[] = $initdir;
59
  $bfc++;
60
  if ($bfc == $bsize) {
61
  $str = serialize($bfa);
62
+ $this->stream->writeStream($str);
63
  $bfc = 0;
64
  $bfa = array();
65
  }
71
  }
72
  if ($bfc != 0) {
73
  $str = serialize($bfa);
74
+ $this->stream->writeStream($str);
75
  }
76
+ return array("status" => "done");
77
  }
78
 
79
  function scanFiles($initdir = "./", $offset = 0, $limit = 0, $bsize = 512, $recurse = true) {
 
80
  $i = 0;
81
  $dirs = array();
82
  $dirs[] = $initdir;
105
  $bfc++;
106
  if ($bfc == $bsize) {
107
  $str = serialize($bfa);
108
+ $this->stream->writeStream($str);
109
  $bfc = 0;
110
  $bfa = array();
111
  }
118
  }
119
  if ($bfc != 0) {
120
  $str = serialize($bfa);
121
+ $this->stream->writeStream($str);
122
  }
123
+ return array("status" => "done");
124
  }
125
 
126
  function calculateMd5($absfile, $fdata, $offset, $limit, $bsize) {
150
  }
151
 
152
  function getFilesStats($files, $offset = 0, $limit = 0, $bsize = 102400, $md5 = false) {
153
+ $result = array();
154
  foreach ($files as $file) {
155
  $fdata = $this->fileStat($file);
156
  $absfile = ABSPATH.$file;
157
  if (!is_readable($absfile)) {
158
+ $result["missingfiles"][] = $file;
159
  continue;
160
  }
161
  if ($md5 === true) {
162
  $fdata["md5"] = $this->calculateMd5($absfile, $fdata, $offset, $limit, $bsize);
163
  }
164
+ $result["stats"][] = $fdata;
165
  }
166
+ return $result;
167
  }
168
 
169
  function uploadFiles($files, $offset = 0, $limit = 0, $bsize = 102400) {
170
+ $result = array();
 
171
  foreach ($files as $file) {
172
  if (!is_readable(ABSPATH.$file)) {
173
+ $result["missingfiles"][] = $file;
174
  continue;
175
  }
176
  $handle = fopen(ABSPATH.$file, "rb");
184
  $_limit = $fdata["size"] - $offset;
185
  $fdata["limit"] = $_limit;
186
  $sfdata = serialize($fdata);
187
+ $this->stream->writeStream($sfdata);
188
  fseek($handle, $offset, SEEK_SET);
189
  $dlen = 1;
190
  while (($_limit > 0) && ($dlen > 0)) {
192
  $_bsize = $_limit;
193
  $d = fread($handle, $_bsize);
194
  $dlen = strlen($d);
195
+ $this->stream->writeStream($d);
196
  $_limit -= $dlen;
197
  }
198
  fclose($handle);
199
  } else {
200
+ $result["unreadablefiles"][] = $file;
201
  }
202
  }
203
+ $result["status"] = "done";
204
+ return $result;
205
  }
206
 
207
+ function process($request) {
208
+ $params = $request->params;
209
+ $stream_init_info = BVStream::startStream($this->account, $request);
210
+ if (array_key_exists('stream', $stream_init_info)) {
211
+ $this->stream = $stream_init_info['stream'];
212
+ switch ($request->method) {
213
+ case "scanfilesglob":
214
+ $initdir = urldecode($params['initdir']);
215
+ $offset = intval(urldecode($params['offset']));
216
+ $limit = intval(urldecode($params['limit']));
217
+ $bsize = intval(urldecode($params['bsize']));
218
+ $regex = urldecode($params['regex']);
219
+ $recurse = true;
220
+ if (array_key_exists('recurse', $params) && $params["recurse"] == "false") {
221
+ $recurse = false;
222
+ }
223
+ $resp = $this->scanFilesUsingGlob($initdir, $offset, $limit, $bsize, $recurse, $regex);
224
+ break;
225
+ case "scanfiles":
226
+ $initdir = urldecode($params['initdir']);
227
+ $offset = intval(urldecode($params['offset']));
228
+ $limit = intval(urldecode($params['limit']));
229
+ $bsize = intval(urldecode($params['bsize']));
230
+ $recurse = true;
231
+ if (array_key_exists('recurse', $params) && $params["recurse"] == "false") {
232
+ $recurse = false;
233
+ }
234
+ $resp = $this->scanFiles($initdir, $offset, $limit, $bsize, $recurse);
235
+ break;
236
+ case "getfilesstats":
237
+ $files = $params['files'];
238
+ $offset = intval(urldecode($params['offset']));
239
+ $limit = intval(urldecode($params['limit']));
240
+ $bsize = intval(urldecode($params['bsize']));
241
+ $md5 = false;
242
+ if (array_key_exists('md5', $params)) {
243
+ $md5 = true;
244
+ }
245
+ $resp = $this->getFilesStats($files, $offset, $limit, $bsize, $md5);
246
+ break;
247
+ case "sendmanyfiles":
248
+ $files = $params['files'];
249
+ $offset = intval(urldecode($params['offset']));
250
+ $limit = intval(urldecode($params['limit']));
251
+ $bsize = intval(urldecode($params['bsize']));
252
+ $resp = $this->uploadFiles($files, $offset, $limit, $bsize);
253
+ break;
254
+ case "filelist":
255
+ $initdir = $params['initdir'];
256
+ $glob_option = GLOB_MARK;
257
+ if(array_key_exists('onlydir', $params)) {
258
+ $glob_option = GLOB_ONLYDIR;
259
+ }
260
+ $regex = "*";
261
+ if(array_key_exists('regex', $params)){
262
+ $regex = $params['regex'];
263
+ }
264
+ $directoryList = glob($initdir.$regex, $glob_option);
265
+ $resp = $this->getFilesStats($directoryList);
266
+ break;
267
+ default:
268
+ $resp = false;
269
  }
270
+ $end_stream_info = $this->stream->endStream();
271
+ if (!empty($end_stream_info) && is_array($resp)) {
272
+ $resp = array_merge($resp, $end_stream_info);
273
  }
274
+ } else {
275
+ $resp = $stream_init_info;
 
 
 
276
  }
277
+ return $resp;
278
  }
279
  }
280
  endif;
callback/wings/info.php CHANGED
@@ -2,36 +2,51 @@
2
 
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('BVInfoCallback')) :
5
- class BVInfoCallback {
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  public function getPosts($post_type, $count = 5) {
7
- global $bvresp;
8
  $output = array();
9
  $args = array('numberposts' => $count, 'post_type' => $post_type);
10
  $posts = get_posts($args);
11
  $keys = array('post_title', 'guid', 'ID', 'post_date');
 
12
  foreach ($posts as $post) {
13
  $pdata = array();
14
  $post_array = get_object_vars($post);
15
  foreach ($keys as $key) {
16
  $pdata[$key] = $post_array[$key];
17
  }
18
- $bvresp->addArrayToStatus("posts", $pdata);
19
  }
 
20
  }
21
 
22
  public function getStats() {
23
- global $bvresp;
24
- $bvresp->addStatus("posts", get_object_vars(wp_count_posts()));
25
- $bvresp->addStatus("pages", get_object_vars(wp_count_posts("page")));
26
- $bvresp->addStatus("comments", get_object_vars(wp_count_comments()));
 
27
  }
28
 
29
  public function getPlugins() {
30
- global $bvresp;
31
  if (!function_exists('get_plugins')) {
32
  require_once (ABSPATH."wp-admin/includes/plugin.php");
33
  }
34
  $plugins = get_plugins();
 
35
  foreach ($plugins as $plugin_file => $plugin_data) {
36
  $pdata = array(
37
  'file' => $plugin_file,
@@ -40,8 +55,9 @@ class BVInfoCallback {
40
  'active' => is_plugin_active($plugin_file),
41
  'network' => $plugin_data['Network']
42
  );
43
- $bvresp->addArrayToStatus("plugins", $pdata);
44
  }
 
45
  }
46
 
47
  public function themeToArray($theme) {
@@ -66,19 +82,19 @@ class BVInfoCallback {
66
  }
67
 
68
  public function getThemes() {
69
- global $bvresp;
70
  $themes = function_exists('wp_get_themes') ? wp_get_themes() : get_themes();
71
  foreach($themes as $theme) {
72
  $pdata = $this->themeToArray($theme);
73
- $bvresp->addArrayToStatus("themes", $pdata);
74
  }
75
  $theme = function_exists('wp_get_theme') ? wp_get_theme() : get_current_theme();
76
  $pdata = $this->themeToArray($theme);
77
- $bvresp->addStatus("currenttheme", $pdata);
 
78
  }
79
 
80
  public function getSystemInfo() {
81
- global $bvresp;
82
  $sys_info = array(
83
  'serverip' => $_SERVER['SERVER_ADDR'],
84
  'host' => $_SERVER['HTTP_HOST'],
@@ -98,22 +114,22 @@ class BVInfoCallback {
98
  $sys_info['webuid'] = posix_getuid();
99
  $sys_info['webgid'] = posix_getgid();
100
  }
101
- $bvresp->addStatus("sys", $sys_info);
102
  }
103
 
104
  public function getWpInfo() {
105
  global $wp_version, $wp_db_version, $wp_local_package;
106
- global $bvresp, $bvcb;
 
107
  $upload_dir = wp_upload_dir();
108
- $info = $bvcb->bvmain->info;
109
 
110
  $wp_info = array(
111
- 'dbprefix' => $bvcb->bvmain->db->dbprefix(),
112
- 'wpmu' => $info->isMultisite(),
113
- 'mainsite' => $info->isMainSite(),
114
  'name' => get_bloginfo('name'),
115
- 'siteurl' => $info->siteurl(),
116
- 'homeurl' => $info->homeurl(),
117
  'charset' => get_bloginfo('charset'),
118
  'wpversion' => $wp_version,
119
  'dbversion' => $wp_db_version,
@@ -128,17 +144,16 @@ class BVInfoCallback {
128
  'disallow_file_mods' => defined('DISALLOW_FILE_MODS'),
129
  'locale' => get_locale(),
130
  'wp_local_string' => $wp_local_package,
131
- 'charset_collate' => $bvcb->bvmain->db->getCharsetCollate()
132
  );
133
- $bvresp->addStatus("wp", $wp_info);
134
  }
135
 
136
  public function getUsers($args = array(), $full) {
137
- global $bvresp, $bvcb;
138
  $results = array();
139
  $users = get_users($args);
140
  if ('true' == $full) {
141
- $results = $bvcb->bvmain->lib->objectToArray($users);
142
  } else {
143
  foreach( (array) $users as $user) {
144
  $result = array();
@@ -154,7 +169,7 @@ class BVInfoCallback {
154
  $results[] = $result;
155
  }
156
  }
157
- $bvresp->addStatus("users", $results);
158
  }
159
 
160
  public function availableFunctions(&$info) {
@@ -181,27 +196,25 @@ class BVInfoCallback {
181
  return $info;
182
  }
183
 
184
- public function servicesInfo(&$info) {
185
- global $bvcb;
186
- $bvinfo = $bvcb->bvmain->info;
187
- $info['dynsync'] = $bvinfo->getOption('bvDynSyncActive');
188
- $info['woodyn'] = $bvinfo->getOption('bvWooDynSync');
189
- $info['dynplug'] = $bvinfo->getOption('bvdynplug');
190
- $info['ptplug'] = $bvinfo->getOption('bvptplug');
191
- $info['fw'] = $this->getFWConfig();
192
- $info['lp'] = $this->getLPConfig();
193
- $info['brand'] = $bvinfo->getOption($bvcb->bvmain->brand_option);
194
- $info['badgeinfo'] = $bvinfo->getOption($bvcb->bvmain->badgeinfo);
195
  }
196
 
197
  public function getLPConfig() {
198
- global $bvcb;
199
  $config = array();
200
- $bvinfo = $bvcb->bvmain->info;
201
- $mode = $bvinfo->getOption('bvlpmode');
202
- $cplimit = $bvinfo->getOption('bvlpcaptchalimit');
203
- $tplimit = $bvinfo->getOption('bvlptempblocklimit');
204
- $bllimit = $bvinfo->getOption('bvlpblockAllLimit');
205
  $config['mode'] = intval($mode ? $mode : 1);
206
  $config['captcha_limit'] = intval($cplimit ? $cplimit : 3);
207
  $config['temp_block_limit'] = intval($tplimit? $tplimit : 6);
@@ -210,83 +223,86 @@ class BVInfoCallback {
210
  }
211
 
212
  public function getFWConfig() {
213
- global $bvcb;
214
  $config = array();
215
- $bvinfo = $bvcb->bvmain->info;
216
- $mode = $bvinfo->getOption('bvfwmode');
217
- $drules = $bvinfo->getOption('bvfwdisabledrules');
218
- $rmode = $bvinfo->getOption('bvfwrulesmode');
 
 
219
  $config['mode'] = intval($mode ? $mode : 1);
220
  $config['disabled_rules'] = $drules ? $drules : array();
 
221
  $config['rules_mode'] = intval($rmode ? $rmode : 1);
 
222
  return $config;
223
  }
224
 
225
  public function dbconf(&$info) {
226
- global $bvcb;
227
  if (defined('DB_CHARSET'))
228
  $info['dbcharset'] = DB_CHARSET;
229
- $info['dbprefix'] = $bvcb->bvmain->db->dbprefix();
230
- $info['charset_collate'] = $bvcb->bvmain->db->getCharsetCollate();
231
  return $info;
232
  }
233
 
234
  public function activate() {
235
- global $bvcb, $bvresp;
236
  $resp = array();
237
- $bvcb->bvmain->info->basic($resp);
238
  $this->servicesInfo($resp);
239
  $this->dbconf($resp);
240
  $this->availableFunctions($resp);
241
- $bvresp->addStatus('actinfo', $resp);
242
  }
243
 
244
- public function process($method) {
245
- global $bvresp, $bvcb;
246
- switch ($method) {
 
247
  case "activateinfo":
248
- $this->activate();
249
  break;
250
  case "gtpsts":
251
  $count = 5;
252
- if (array_key_exists('count', $_REQUEST))
253
- $count = $_REQUEST['count'];
254
- $this->getPosts($_REQUEST['post_type'], $count);
255
  break;
256
  case "gtsts":
257
- $this->getStats();
258
  break;
259
  case "gtplgs":
260
- $this->getPlugins();
261
  break;
262
  case "gtthms":
263
- $this->getThemes();
264
  break;
265
  case "gtsym":
266
- $this->getSystemInfo();
267
  break;
268
  case "gtwp":
269
- $this->getWpInfo();
270
  break;
271
  case "getoption":
272
- $bvresp->addStatus("option", $bvresp->getOption($_REQUEST['name']));
273
  break;
274
  case "gtusrs":
275
  $full = false;
276
- if (array_key_exists('full', $_REQUEST))
277
  $full = true;
278
- $this->getUsers($_REQUEST['args'], $full);
279
  break;
280
  case "gttrnsnt":
281
- $transient = $bvcb->bvmain->info->getTransient($_REQUEST['name']);
282
- if ($transient && array_key_exists('asarray', $_REQUEST))
283
- $transient = $bvcb->bvmain->lib->objectToArray($transient);
284
- $bvresp->addStatus("transient", $transient);
285
  break;
286
  default:
287
- return false;
288
  }
289
- return true;
290
  }
291
  }
292
  endif;
2
 
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('BVInfoCallback')) :
5
+
6
+ class BVInfoCallback extends BVCallbackBase {
7
+ public $db;
8
+ public $settings;
9
+ public $siteinfo;
10
+ public $bvinfo;
11
+
12
+ public function __construct($callback_handler) {
13
+ $this->db = $callback_handler->db;
14
+ $this->siteinfo = $callback_handler->siteinfo;
15
+ $this->settings = $callback_handler->settings;
16
+ $this->bvinfo = new WPEInfo($this->settings);
17
+ }
18
+
19
  public function getPosts($post_type, $count = 5) {
 
20
  $output = array();
21
  $args = array('numberposts' => $count, 'post_type' => $post_type);
22
  $posts = get_posts($args);
23
  $keys = array('post_title', 'guid', 'ID', 'post_date');
24
+ $result = array();
25
  foreach ($posts as $post) {
26
  $pdata = array();
27
  $post_array = get_object_vars($post);
28
  foreach ($keys as $key) {
29
  $pdata[$key] = $post_array[$key];
30
  }
31
+ $result["posts"][] = $pdata;
32
  }
33
+ return $result;
34
  }
35
 
36
  public function getStats() {
37
+ return array(
38
+ "posts" => get_object_vars(wp_count_posts()),
39
+ "pages" => get_object_vars(wp_count_posts("page")),
40
+ "comments" => get_object_vars(wp_count_comments())
41
+ );
42
  }
43
 
44
  public function getPlugins() {
 
45
  if (!function_exists('get_plugins')) {
46
  require_once (ABSPATH."wp-admin/includes/plugin.php");
47
  }
48
  $plugins = get_plugins();
49
+ $result = array();
50
  foreach ($plugins as $plugin_file => $plugin_data) {
51
  $pdata = array(
52
  'file' => $plugin_file,
55
  'active' => is_plugin_active($plugin_file),
56
  'network' => $plugin_data['Network']
57
  );
58
+ $result["plugins"][] = $pdata;
59
  }
60
+ return $result;
61
  }
62
 
63
  public function themeToArray($theme) {
82
  }
83
 
84
  public function getThemes() {
85
+ $result = array();
86
  $themes = function_exists('wp_get_themes') ? wp_get_themes() : get_themes();
87
  foreach($themes as $theme) {
88
  $pdata = $this->themeToArray($theme);
89
+ $result["themes"][] = $pdata;
90
  }
91
  $theme = function_exists('wp_get_theme') ? wp_get_theme() : get_current_theme();
92
  $pdata = $this->themeToArray($theme);
93
+ $result["currenttheme"] = $pdata;
94
+ return $result;
95
  }
96
 
97
  public function getSystemInfo() {
 
98
  $sys_info = array(
99
  'serverip' => $_SERVER['SERVER_ADDR'],
100
  'host' => $_SERVER['HTTP_HOST'],
114
  $sys_info['webuid'] = posix_getuid();
115
  $sys_info['webgid'] = posix_getgid();
116
  }
117
+ return array("sys" => $sys_info);
118
  }
119
 
120
  public function getWpInfo() {
121
  global $wp_version, $wp_db_version, $wp_local_package;
122
+ $siteinfo = $this->siteinfo;
123
+ $db = $this->db;
124
  $upload_dir = wp_upload_dir();
 
125
 
126
  $wp_info = array(
127
+ 'dbprefix' => $db->dbprefix(),
128
+ 'wpmu' => $siteinfo->isMultisite(),
129
+ 'mainsite' => $siteinfo->isMainSite(),
130
  'name' => get_bloginfo('name'),
131
+ 'siteurl' => $siteinfo->siteurl(),
132
+ 'homeurl' => $siteinfo->homeurl(),
133
  'charset' => get_bloginfo('charset'),
134
  'wpversion' => $wp_version,
135
  'dbversion' => $wp_db_version,
144
  'disallow_file_mods' => defined('DISALLOW_FILE_MODS'),
145
  'locale' => get_locale(),
146
  'wp_local_string' => $wp_local_package,
147
+ 'charset_collate' => $db->getCharsetCollate()
148
  );
149
+ return array("wp" => $wp_info);
150
  }
151
 
152
  public function getUsers($args = array(), $full) {
 
153
  $results = array();
154
  $users = get_users($args);
155
  if ('true' == $full) {
156
+ $results = $this->objectToArray($users);
157
  } else {
158
  foreach( (array) $users as $user) {
159
  $result = array();
169
  $results[] = $result;
170
  }
171
  }
172
+ return array("users" => $results);
173
  }
174
 
175
  public function availableFunctions(&$info) {
196
  return $info;
197
  }
198
 
199
+ public function servicesInfo(&$data) {
200
+ $settings = $this->settings;
201
+ $data['dynsync'] = $settings->getOption('bvDynSyncActive');
202
+ $data['woodyn'] = $settings->getOption('bvWooDynSync');
203
+ $data['dynplug'] = $settings->getOption('bvdynplug');
204
+ $data['ptplug'] = $settings->getOption('bvptplug');
205
+ $data['fw'] = $this->getFWConfig();
206
+ $data['lp'] = $this->getLPConfig();
207
+ $data['brand'] = $settings->getOption($this->bvinfo->brand_option);
208
+ $data['badgeinfo'] = $settings->getOption($this->bvinfo->badgeinfo);
 
209
  }
210
 
211
  public function getLPConfig() {
 
212
  $config = array();
213
+ $settings = $this->settings;
214
+ $mode = $settings->getOption('bvlpmode');
215
+ $cplimit = $settings->getOption('bvlpcaptchalimit');
216
+ $tplimit = $settings->getOption('bvlptempblocklimit');
217
+ $bllimit = $settings->getOption('bvlpblockAllLimit');
218
  $config['mode'] = intval($mode ? $mode : 1);
219
  $config['captcha_limit'] = intval($cplimit ? $cplimit : 3);
220
  $config['temp_block_limit'] = intval($tplimit? $tplimit : 6);
223
  }
224
 
225
  public function getFWConfig() {
 
226
  $config = array();
227
+ $settings = $this->settings;
228
+ $mode = $settings->getOption('bvfwmode');
229
+ $drules = $settings->getOption('bvfwdisabledrules');
230
+ $arules = $settings->getOption('bvfwauditrules');
231
+ $rmode = $settings->getOption('bvfwrulesmode');
232
+ $reqprofilingmode = $settings->getOption('bvfwreqprofilingmode');
233
  $config['mode'] = intval($mode ? $mode : 1);
234
  $config['disabled_rules'] = $drules ? $drules : array();
235
+ $config['audit_rules'] = $arules ? $arules : array();
236
  $config['rules_mode'] = intval($rmode ? $rmode : 1);
237
+ $config['req_profiling_mode'] = intval($reqprofilingmode ? $reqprofilingmode : 1);
238
  return $config;
239
  }
240
 
241
  public function dbconf(&$info) {
242
+ $db = $this->db;
243
  if (defined('DB_CHARSET'))
244
  $info['dbcharset'] = DB_CHARSET;
245
+ $info['dbprefix'] = $db->dbprefix();
246
+ $info['charset_collate'] = $db->getCharsetCollate();
247
  return $info;
248
  }
249
 
250
  public function activate() {
 
251
  $resp = array();
252
+ $this->siteinfo->basic($resp);
253
  $this->servicesInfo($resp);
254
  $this->dbconf($resp);
255
  $this->availableFunctions($resp);
256
+ return array('actinfo' => $resp);
257
  }
258
 
259
+ public function process($request) {
260
+ $db = $this->db;
261
+ $params = $request->params;
262
+ switch ($request->method) {
263
  case "activateinfo":
264
+ $resp = $this->activate();
265
  break;
266
  case "gtpsts":
267
  $count = 5;
268
+ if (array_key_exists('count', $params))
269
+ $count = $params['count'];
270
+ $resp = $this->getPosts($params['post_type'], $count);
271
  break;
272
  case "gtsts":
273
+ $resp = $this->getStats();
274
  break;
275
  case "gtplgs":
276
+ $resp = $this->getPlugins();
277
  break;
278
  case "gtthms":
279
+ $resp = $this->getThemes();
280
  break;
281
  case "gtsym":
282
+ $resp = $this->getSystemInfo();
283
  break;
284
  case "gtwp":
285
+ $resp = $this->getWpInfo();
286
  break;
287
  case "getoption":
288
+ $resp = array("option" => $this->settings->getOption($params['name']));
289
  break;
290
  case "gtusrs":
291
  $full = false;
292
+ if (array_key_exists('full', $params))
293
  $full = true;
294
+ $resp = $this->getUsers($params['args'], $full);
295
  break;
296
  case "gttrnsnt":
297
+ $transient = $this->settings->getTransient($params['name']);
298
+ if ($transient && array_key_exists('asarray', $params))
299
+ $transient = $this->objectToArray($transient);
300
+ $resp = array("transient" => $transient);
301
  break;
302
  default:
303
+ $resp = false;
304
  }
305
+ return $resp;
306
  }
307
  }
308
  endif;
callback/wings/misc.php CHANGED
@@ -3,69 +3,87 @@
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('BVMiscCallback')) :
5
 
6
- class BVMiscCallback {
 
 
 
 
7
 
8
- function process($method) {
9
- global $bvcb, $bvresp;
10
- $info = $bvcb->bvmain->info;
11
- switch ($method) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  case "enablebadge":
13
- $option = $bvcb->bvmain->badgeinfo;
14
  $badgeinfo = array();
15
- $badgeinfo['badgeurl'] = $_REQUEST['badgeurl'];
16
- $badgeinfo['badgeimg'] = $_REQUEST['badgeimg'];
17
- $badgeinfo['badgealt'] = $_REQUEST['badgealt'];
18
- $info->updateOption($option, $badgeinfo);
19
- $bvresp->addStatus("status", $info->getOption($option));
20
  break;
21
  case "disablebadge":
22
- $option = $bvcb->bvmain->badgeinfo;
23
- $info->deleteOption($option);
24
- $bvresp->addStatus("status", !$info->getOption($option));
25
  break;
26
  case "getoption":
27
- $bvresp->addStatus('getoption', $info->getOption($_REQUEST['opkey']));
28
  break;
29
  case "setdynplug":
30
- $info->updateOption('bvdynplug', $_REQUEST['dynplug']);
31
- $bvresp->addStatus("setdynplug", $info->getOption('bvdynplug'));
32
  break;
33
  case "unsetdynplug":
34
- $info->deleteOption('bvdynplug');
35
- $bvresp->addStatus("unsetdynplug", $info->getOption('bvdynplug'));
36
  break;
37
  case "setptplug":
38
- $info->updateOption('bvptplug', $_REQUEST['ptplug']);
39
- $bvresp->addStatus("setptplug", $info->getOption('bvptplug'));
40
  break;
41
  case "unsetptplug":
42
- $info->deleteOption('bvptlug');
43
- $bvresp->addStatus("unsetptplug", $info->getOption('bvptlug'));
44
  break;
45
  case "wpupplgs":
46
- $bvresp->addStatus("wpupdateplugins", wp_update_plugins());
47
  break;
48
  case "wpupthms":
49
- $bvresp->addStatus("wpupdatethemes", wp_update_themes());
50
  break;
51
  case "wpupcre":
52
- $bvresp->addStatus("wpupdatecore", wp_version_check());
53
  break;
54
  case "rmmonitime":
55
- $bvcb->bvmain->unSetMonitTime();
56
- $bvresp->addStatus("rmmonitime", !$bvcb->bvmain->getMonitTime());
57
  break;
58
  case "phpinfo":
59
  phpinfo();
60
  die();
61
  break;
62
  case "dlttrsnt":
63
- $bvresp->addStatus("dlttrsnt", $bvcb->bvmain->info->deleteTransient($_REQUEST['key']));
64
  break;
65
  default:
66
- return false;
67
  }
68
- return true;
69
  }
70
  }
71
  endif;
3
  if (!defined('ABSPATH')) exit;
4
  if (!class_exists('BVMiscCallback')) :
5
 
6
+ class BVMiscCallback extends BVCallbackBase {
7
+ public $settings;
8
+ public $bvinfo;
9
+ public $siteinfo;
10
+ public $account;
11
 
12
+ public function __construct($callback_handler) {
13
+ $this->settings = $callback_handler->settings;
14
+ $this->siteinfo = $callback_handler->siteinfo;
15
+ $this->account = $callback_handler->account;
16
+ $this->bvinfo = new WPEInfo($callback_handler->settings);
17
+ }
18
+
19
+ public function process($request) {
20
+ $bvinfo = $this->bvinfo;
21
+ $settings = $this->settings;
22
+ $params = $request->params;
23
+ switch ($request->method) {
24
+ case "dummyping":
25
+ $resp = array();
26
+ $resp = array_merge($resp, $this->siteinfo->respInfo());
27
+ $resp = array_merge($resp, $this->account->respInfo());
28
+ $resp = array_merge($resp, $this->bvinfo->respInfo());
29
+ break;
30
  case "enablebadge":
31
+ $option = $bvinfo->badgeinfo;
32
  $badgeinfo = array();
33
+ $badgeinfo['badgeurl'] = $params['badgeurl'];
34
+ $badgeinfo['badgeimg'] = $params['badgeimg'];
35
+ $badgeinfo['badgealt'] = $params['badgealt'];
36
+ $settings->updateOption($option, $badgeinfo);
37
+ $resp = array("status" => $settings->getOption($option));
38
  break;
39
  case "disablebadge":
40
+ $option = $bvinfo->badgeinfo;
41
+ $settings->deleteOption($option);
42
+ $resp = array("status" => !$settings->getOption($option));
43
  break;
44
  case "getoption":
45
+ $resp = array('getoption' => $settings->getOption($params['opkey']));
46
  break;
47
  case "setdynplug":
48
+ $settings->updateOption('bvdynplug', $params['dynplug']);
49
+ $resp = array("setdynplug" => $settings->getOption('bvdynplug'));
50
  break;
51
  case "unsetdynplug":
52
+ $settings->deleteOption('bvdynplug');
53
+ $resp = array("unsetdynplug" => $settings->getOption('bvdynplug'));
54
  break;
55
  case "setptplug":
56
+ $settings->updateOption('bvptplug', $params['ptplug']);
57
+ $resp = array("setptplug" => $settings->getOption('bvptplug'));
58
  break;
59
  case "unsetptplug":
60
+ $settings->deleteOption('bvptlug');
61
+ $resp = array("unsetptplug" => $settings->getOption('bvptlug'));
62
  break;
63
  case "wpupplgs":
64
+ $resp = array("wpupdateplugins" => wp_update_plugins());
65
  break;
66
  case "wpupthms":
67
+ $resp = array("wpupdatethemes" => wp_update_themes());
68
  break;
69
  case "wpupcre":
70
+ $resp = array("wpupdatecore" => wp_version_check());
71
  break;
72
  case "rmmonitime":
73
+ $this->settings->deleteOption('bvmonittime');
74
+ $resp = array("rmmonitime" => !$bvinfo->getMonitTime());
75
  break;
76
  case "phpinfo":
77
  phpinfo();
78
  die();
79
  break;
80
  case "dlttrsnt":
81
+ $resp = array("dlttrsnt" => $settings->deleteTransient($params['key']));
82
  break;
83
  default:
84
+ $resp = false;
85
  }
86
+ return $resp;
87
  }
88
  }
89
  endif;
info.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('WPEInfo')) :
5
+ class WPEInfo {
6
+ public $settings;
7
+ public $plugname = 'wpengine';
8
+ public $brandname = 'WPEngine Migration';
9
+ public $badgeinfo = 'wpebadge';
10
+ public $ip_header_option = 'wpeipheader';
11
+ public $brand_option = 'wpebrand';
12
+ public $version = '2.1';
13
+ public $webpage = 'https://wpengine.com';
14
+ public $appurl = 'https://wpengine.blogvault.net';
15
+ public $slug = 'wp-site-migrate/wpengine.php';
16
+ public $plug_redirect = 'wperedirect';
17
+ public $logo = '../assets/img/wpengine-logo.png';
18
+
19
+ public function __construct($settings) {
20
+ $this->settings = $settings;
21
+ }
22
+
23
+ public function getBrandInfo() {
24
+ return $this->settings->getOption($this->brand_option);
25
+ }
26
+
27
+ public function getBrandName() {
28
+ $brand = $this->getBrandInfo();
29
+ if ($brand && array_key_exists('menuname', $brand)) {
30
+ return $brand['menuname'];
31
+ }
32
+ return $this->brandname;
33
+ }
34
+
35
+ public function getMonitTime() {
36
+ $time = $this->settings->getOption('bvmonittime');
37
+ return ($time ? $time : 0);
38
+ }
39
+
40
+ public function appUrl() {
41
+ if (defined('BV_APP_URL')) {
42
+ return BV_APP_URL;
43
+ } else {
44
+ $brand = $this->getBrandInfo();
45
+ if ($brand && array_key_exists('appurl', $brand)) {
46
+ return $brand['appurl'];
47
+ }
48
+ return $this->appurl;
49
+ }
50
+ }
51
+
52
+ public function isActivePlugin() {
53
+ $expiry_time = time() - (3 * 24 * 3600);
54
+ return ($this->getMonitTime() > $expiry_time);
55
+ }
56
+
57
+ public function isProtectModuleEnabled() {
58
+ return ($this->settings->getOption('bvptplug') === $this->plugname) &&
59
+ $this->isActivePlugin();
60
+ }
61
+
62
+ public function isDynSyncModuleEnabled() {
63
+ return ($this->settings->getOption('bvdynplug') === $this->plugname) &&
64
+ $this->isActivePlugin();
65
+ }
66
+ public function isActivateRedirectSet() {
67
+ return ($this->settings->getOption($this->plug_redirect) === 'yes') ? true : false;
68
+ }
69
+
70
+ public function isMalcare() {
71
+ return $this->getBrandName() === 'MalCare - Pro';
72
+ }
73
+
74
+ public function isBlogvault() {
75
+ return $this->getBrandName() === 'BlogVault';
76
+ }
77
+
78
+ public function respInfo() {
79
+ return array(
80
+ "bvversion" => $this->version,
81
+ "asymauth" => "true",
82
+ "sha1" => "true"
83
+ );
84
+ }
85
+ }
86
+ endif;
main.php DELETED
@@ -1,167 +0,0 @@
1
- <?php
2
- if (!defined('ABSPATH')) exit;
3
- if (!class_exists('WPEngine')) :
4
-
5
- require_once dirname( __FILE__ ) . '/main/lib.php';
6
- require_once dirname( __FILE__ ) . '/main/site_info.php';
7
- require_once dirname( __FILE__ ) . '/main/auth.php';
8
- require_once dirname( __FILE__ ) . '/main/db.php';
9
-
10
- class WPEngine {
11
- public $version = '1.88';
12
- public $plugname = 'wpengine';
13
- public $brandname = 'WPEngine Migration';
14
- public $webpage = 'https://wpengine.com';
15
- public $appurl = 'https://wpengine.blogvault.net';
16
- public $slug = 'wp-site-migrate/wpengine.php';
17
- public $plug_redirect = 'wperedirect';
18
- public $badgeinfo = 'wpebadge';
19
- public $logo = '../assets/img/wpengine-logo.png';
20
-
21
- public $ip_header_option = 'wpeipheader';
22
- public $brand_option = 'wpebrand';
23
-
24
- public $lib;
25
- public $info;
26
- public $auth;
27
- public $db;
28
- function __construct() {
29
- $this->lib = new WPELib();
30
- $this->info = new WPESiteInfo($this->lib);
31
- $this->auth = new WPEAuth($this->info);
32
- $this->db = new WPEDb();
33
- }
34
-
35
- public function appUrl() {
36
- if (defined('BV_APP_URL')) {
37
- return BV_APP_URL;
38
- } else {
39
- $brand = $this->getBrandInfo();
40
- if ($brand && array_key_exists('appurl', $brand)) {
41
- return $brand['appurl'];
42
- }
43
- return $this->appurl;
44
- }
45
- }
46
-
47
- public function getIPHeader() {
48
- return $this->info->getOption($this->ip_header_option);
49
- }
50
-
51
- public function getBrandName() {
52
- $brand = $this->getBrandInfo();
53
- if ($brand && array_key_exists('menuname', $brand)) {
54
- return $brand['menuname'];
55
- }
56
- return $this->brandname;
57
- }
58
-
59
- public function isMalcare() {
60
- return $this->getBrandName() === 'MalCare - Pro';
61
- }
62
-
63
- public function isBlogvault() {
64
- return $this->getBrandName() === 'BlogVault';
65
- }
66
-
67
- public function getBrandInfo() {
68
- return $this->info->getOption($this->brand_option);
69
- }
70
-
71
- public function authenticatedUrl($method, $apicheck = null, $full = true) {
72
- $_params = $this->auth->newAuthParams($this->version);
73
- if ($apicheck) {
74
- $_params['bvapicheck'] = $apicheck;
75
- }
76
- $qstr = http_build_query($_params);
77
- if (!$full)
78
- return $method."?".$qstr;
79
- return $this->appUrl().$method."?".$qstr;
80
- }
81
-
82
- public function isConfigured() {
83
- return $this->auth->defaultPublic();
84
- }
85
-
86
- public function getMonitTime() {
87
- $time = $this->info->getOption('bvmonittime');
88
- return ($time ? $time : 0);
89
- }
90
-
91
- public function unSetMonitTime() {
92
- return $this->info->deleteOption('bvmonittime');
93
- }
94
-
95
- public function setMonitTime() {
96
- return $this->info->updateOption('bvmonittime', time());
97
- }
98
-
99
- public function isActivePlugin() {
100
- $expiry_time = time() - (3 * 24 * 3600);
101
- return ($this->getMonitTime() > $expiry_time);
102
- }
103
-
104
- public function isProtectModuleEnabled() {
105
- return ($this->info->getOption('bvptplug') === $this->plugname) &&
106
- $this->isActivePlugin();
107
- }
108
-
109
- public function isDynSyncModuleEnabled() {
110
- return ($this->info->getOption('bvdynplug') === $this->plugname) &&
111
- $this->isActivePlugin();
112
- }
113
-
114
- public function pingbv($method) {
115
- $body = array();
116
- $this->info->basic($body);
117
- $body['plug'] = $this->plugname;
118
- $url = $this->authenticatedUrl($method);
119
- $this->lib->http_request($url, $body);
120
- }
121
-
122
- public function setup($rand_secret) {
123
- $this->info->updateOption('bvSecretKey', $rand_secret);
124
- $this->info->updateOption($this->plug_redirect, 'yes');
125
- $this->info->updateOption('bvActivateTime', time());
126
- }
127
-
128
- public function isActivateRedirectSet() {
129
- if ($this->info->getOption($this->plug_redirect) === 'yes') {
130
- $this->info->updateOption($this->plug_redirect, 'no');
131
- return true;
132
- }
133
- return false;
134
- }
135
-
136
- public function activate() {
137
- if (!isset($_REQUEST['blogvaultkey'])) {
138
- ##BVKEYSLOCATE##
139
- }
140
- if ($this->isConfigured()) {
141
- /* This informs the server about the activation */
142
- $this->pingbv('/bvapi/activate');
143
- } else {
144
- $this->setup($this->lib->randString(32));
145
- }
146
- }
147
-
148
- public function footerHandler() {
149
- $bvfooter = $this->info->getOption($this->badgeinfo);
150
- if ($bvfooter) {
151
- echo '<div style="max-width:150px;min-height:70px;margin:0 auto;text-align:center;position:relative;">
152
- <a href='.$bvfooter['badgeurl'].' target="_blank" ><img src="'.plugins_url($bvfooter['badgeimg'], __FILE__).'" alt="'.$bvfooter['badgealt'].'" /></a></div>';
153
- }
154
- }
155
-
156
- public function deactivate() {
157
- $this->pingbv('/bvapi/deactivate');
158
- }
159
-
160
- public static function uninstall() {
161
- ##CLEARLPCONFIG##
162
- ##CLEARFWCONFIG##
163
- ##CLEARIPSTORE##
164
- ##CLEARDYNSYNCCONFIG##
165
- }
166
- }
167
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
main/auth.php DELETED
@@ -1,106 +0,0 @@
1
- <?php
2
-
3
- if (!defined('ABSPATH')) exit;
4
- if (!class_exists('WPEAuth')) :
5
-
6
- class WPEAuth {
7
- public $info;
8
- function __construct($info) {
9
- $this->info = $info;
10
- }
11
-
12
- public function defaultPublic() {
13
- return $this->info->getOption('bvPublic');
14
- }
15
-
16
- public function defaultSecret() {
17
- return $this->info->getOption('bvSecretKey');
18
- }
19
-
20
- public function allKeys() {
21
- $keys = $this->info->getOption('bvkeys');
22
- if (!is_array($keys)) {
23
- $keys = array();
24
- }
25
- $public = $this->defaultPublic();
26
- $secret = $this->defaultSecret();
27
- if ($public)
28
- $keys[$public] = $secret;
29
- $keys['default'] = $secret;
30
- return $keys;
31
- }
32
-
33
- public function publicParam() {
34
- if (array_key_exists('pubkey', $_REQUEST)) {
35
- return $_REQUEST['pubkey'];
36
- } else {
37
- return $this->defaultPublic();
38
- }
39
- }
40
-
41
- public function secretForPublic($public = false) {
42
- $bvkeys = $this->allKeys();
43
- if ($public && array_key_exists($public, $bvkeys) && isset($bvkeys[$public]))
44
- return $bvkeys[$public];
45
- else
46
- return $this->defaultSecret();
47
- }
48
-
49
- public function addKeys($public, $secret) {
50
- $bvkeys = $this->info->getOption('bvkeys');
51
- if ($bvkeys && is_array($bvkeys))
52
- $bvkeys[$public] = $secret;
53
- else
54
- $bvkeys = array($public => $secret);
55
- $this->info->updateOption('bvkeys', $bvkeys);
56
- }
57
-
58
- public function updateKeys($publickey, $secretkey) {
59
- $this->info->updateOption('bvPublic', $publickey);
60
- $this->info->updateOption('bvSecretKey', $secretkey);
61
- $this->addKeys($publickey, $secretkey);
62
- }
63
-
64
- public function rmKeys($publickey) {
65
- $bvkeys = $this->info->getOption('bvkeys');
66
- if ($bvkeys && is_array($bvkeys)) {
67
- unset($bvkeys[$publickey]);
68
- $this->info->updateOption('bvkeys', $bvkeys);
69
- return true;
70
- }
71
- return false;
72
- }
73
-
74
- public function validate($public, $method, $time, $version, $sig) {
75
- $secret = $this->secretForPublic($public);
76
- if ($time < intval($this->info->getOption('bvLastRecvTime')) - 300) {
77
- return false;
78
- }
79
- if (array_key_exists('sha1', $_REQUEST)) {
80
- $sig_match = sha1($method.$secret.$time.$version);
81
- } else {
82
- $sig_match = md5($method.$secret.$time.$version);
83
- }
84
- if ($sig_match !== $sig) {
85
- return $sig_match;
86
- }
87
- $this->info->updateOption('bvLastRecvTime', $time);
88
- return 1;
89
- }
90
-
91
- public function newAuthParams($version) {
92
- $args = array();
93
- $time = time();
94
- $public = $this->publicParam();
95
- $secret = $this->secretForPublic($public);
96
-
97
- $sig = sha1($public.$secret.$time.$version);
98
- $args['sig'] = $sig;
99
- $args['bvTime'] = $time;
100
- $args['bvPublic'] = $public;
101
- $args['bvVersion'] = $version;
102
- $args['sha1'] = '1';
103
- return $args;
104
- }
105
- }
106
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
main/lib.php DELETED
@@ -1,44 +0,0 @@
1
- <?php
2
-
3
- if (!defined('ABSPATH')) exit;
4
- if (!class_exists('WPELib')) :
5
-
6
- class WPELib {
7
- public function objectToArray($obj) {
8
- return json_decode(json_encode($obj), true);
9
- }
10
-
11
- public function dbsig($full = false) {
12
- if (defined('DB_USER') && defined('DB_NAME') &&
13
- defined('DB_PASSWORD') && defined('DB_HOST')) {
14
- $sig = sha1(DB_USER.DB_NAME.DB_PASSWORD.DB_HOST);
15
- } else {
16
- $sig = "bvnone".$this->randString(34);
17
- }
18
- if ($full)
19
- return $sig;
20
- else
21
- return substr($sig, 0, 6);
22
- }
23
-
24
- public function randString($length) {
25
- $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
26
-
27
- $str = "";
28
- $size = strlen($chars);
29
- for( $i = 0; $i < $length; $i++ ) {
30
- $str .= $chars[rand(0, $size - 1)];
31
- }
32
- return $str;
33
- }
34
-
35
- public function http_request($url, $body) {
36
- $_body = array(
37
- 'method' => 'POST',
38
- 'timeout' => 15,
39
- 'body' => $body);
40
-
41
- return wp_remote_post($url, $_body);
42
- }
43
- }
44
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
main/site_info.php DELETED
@@ -1,99 +0,0 @@
1
- <?php
2
-
3
- if (!defined('ABSPATH')) exit;
4
- if (!class_exists('WPESiteInfo')) :
5
-
6
- class WPESiteInfo {
7
- public function getOption($key) {
8
- $res = false;
9
- if (function_exists('get_site_option')) {
10
- $res = get_site_option($key, false);
11
- }
12
- if ($res === false) {
13
- $res = get_option($key, false);
14
- }
15
- return $res;
16
- }
17
-
18
- public function deleteOption($key) {
19
- if (function_exists('delete_site_option')) {
20
- return delete_site_option($key);
21
- } else {
22
- return delete_option($key);
23
- }
24
- }
25
-
26
- public function updateOption($key, $value) {
27
- if (function_exists('update_site_option')) {
28
- return update_site_option($key, $value);
29
- } else {
30
- return update_option($key, $value);
31
- }
32
- }
33
-
34
- public function setTransient($name, $value, $time) {
35
- if (function_exists('set_site_transient')) {
36
- return set_site_transient($name, $value, $time);
37
- }
38
- return false;
39
- }
40
-
41
- public function deleteTransient($name) {
42
- if (function_exists('delete_site_transient')) {
43
- return delete_site_transient($name);
44
- }
45
- return false;
46
- }
47
-
48
- public function getTransient($name) {
49
- if (function_exists('get_site_transient')) {
50
- return get_site_transient($name);
51
- }
52
- return false;
53
- }
54
-
55
- public function wpurl() {
56
- if (function_exists('network_site_url'))
57
- return network_site_url();
58
- else
59
- return get_bloginfo('wpurl');
60
- }
61
-
62
- public function siteurl() {
63
- if (function_exists('site_url')) {
64
- return site_url();
65
- } else {
66
- return get_bloginfo('wpurl');
67
- }
68
- }
69
-
70
- public function homeurl() {
71
- if (function_exists('home_url')) {
72
- return home_url();
73
- } else {
74
- return get_bloginfo('url');
75
- }
76
- }
77
-
78
- public function isMultisite() {
79
- if (function_exists('is_multisite'))
80
- return is_multisite();
81
- return false;
82
- }
83
-
84
- public function isMainSite() {
85
- if (!function_exists('is_main_site' ) || !$this->isMultisite())
86
- return true;
87
- return is_main_site();
88
- }
89
-
90
- public function basic(&$info) {
91
- $info['wpurl'] = $this->wpurl();
92
- $info['siteurl'] = $this->siteurl();
93
- $info['homeurl'] = $this->homeurl();
94
- $info['serverip'] = $_SERVER['SERVER_ADDR'];
95
- $info['abspath'] = ABSPATH;
96
- return $info;
97
- }
98
- }
99
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wpengine, blogvault, akshatc, taylor4484
3
  Tags: wpe, wpengine, migration
4
  Requires at least: 4.0
5
  Tested up to: 5.2.1
6
- Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -78,6 +78,9 @@ That's easy! [Signup here](http://wpengine.com/plans/).
78
  2. BlogVault dashboard showing live updates.
79
 
80
  == Changelog ==
 
 
 
81
  = 1.88 =
82
  * Callback improvements
83
 
3
  Tags: wpe, wpengine, migration
4
  Requires at least: 4.0
5
  Tested up to: 5.2.1
6
+ Stable tag: 2.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
78
  2. BlogVault dashboard showing live updates.
79
 
80
  == Changelog ==
81
+ = 2.1 =
82
+ * Restructuring classes
83
+
84
  = 1.88 =
85
  * Callback improvements
86
 
wp_actions.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('WPEWPAction')) :
5
+ class WPEWPAction {
6
+ public $settings;
7
+ public $siteinfo;
8
+ public $bvinfo;
9
+ public $bvapi;
10
+
11
+ public function __construct($settings, $siteinfo, $bvapi) {
12
+ $this->settings = $settings;
13
+ $this->siteinfo = $siteinfo;
14
+ $this->bvapi = $bvapi;
15
+ $this->bvinfo = new WPEInfo($settings);
16
+ }
17
+
18
+ public function activate() {
19
+ $account = WPEAccount::find($this->settings);
20
+ if (!isset($_REQUEST['blogvaultkey'])) {
21
+ ##BVKEYSLOCATE##
22
+ }
23
+ if (WPEAccount::isConfigured($this->settings)) {
24
+ /* This informs the server about the activation */
25
+ $info = array();
26
+ $this->siteinfo->basic($info);
27
+ $this->bvapi->pingbv('/bvapi/activate', $info);
28
+ } else {
29
+ $account->setup();
30
+ }
31
+ }
32
+
33
+ public function deactivate() {
34
+ $info = array();
35
+ $this->siteinfo->basic($info);
36
+ $this->bvapi->pingbv('/bvapi/deactivate', $info);
37
+ }
38
+
39
+ public static function uninstall() {
40
+ ##CLEARLPCONFIG##
41
+ ##CLEARFWCONFIG##
42
+ ##CLEARIPSTORE##
43
+ ##CLEARDYNSYNCCONFIG##
44
+ }
45
+
46
+ public function footerHandler() {
47
+ $bvfooter = $this->settings->getOption($this->bvinfo->badgeinfo);
48
+ if ($bvfooter) {
49
+ echo '<div style="max-width:150px;min-height:70px;margin:0 auto;text-align:center;position:relative;">
50
+ <a href='.$bvfooter['badgeurl'].' target="_blank" ><img src="'.plugins_url($bvfooter['badgeimg'], __FILE__).'" alt="'.$bvfooter['badgealt'].'" /></a></div>';
51
+ }
52
+ }
53
+ }
54
+ endif;
admin.php → wp_admin.php RENAMED
@@ -1,18 +1,25 @@
1
  <?php
2
 
3
  if (!defined('ABSPATH')) exit;
4
- if (!class_exists('WPEAdmin')) :
5
- class WPEAdmin {
6
- public $bvmain;
7
- function __construct($bvmain) {
8
- $this->bvmain = $bvmain;
 
 
 
 
 
 
 
9
  }
10
 
11
  public function mainUrl($_params = '') {
12
  if (function_exists('network_admin_url')) {
13
- return network_admin_url('admin.php?page='.$this->bvmain->plugname.$_params);
14
  } else {
15
- return admin_url('admin.php?page='.$this->bvmain->plugname.$_params);
16
  }
17
  }
18
 
@@ -25,32 +32,33 @@ class WPEAdmin {
25
  array_key_exists('blogvaultkey', $_REQUEST) &&
26
  (strlen($_REQUEST['blogvaultkey']) == 64) &&
27
  (array_key_exists('page', $_REQUEST) &&
28
- $_REQUEST['page'] == $this->bvmain->plugname)) {
29
  $keys = str_split($_REQUEST['blogvaultkey'], 32);
30
- $this->bvmain->auth->updateKeys($keys[0], $keys[1]);
31
  if (array_key_exists('redirect', $_REQUEST)) {
32
  $location = $_REQUEST['redirect'];
33
- wp_redirect($this->bvmain->appUrl().'/migration/'.$location);
34
  exit();
35
  }
36
  }
37
- if ($this->bvmain->isActivateRedirectSet()) {
 
38
  wp_redirect($this->mainUrl());
39
  }
40
  }
41
 
42
  public function menu() {
43
- $brand = $this->bvmain->getBrandInfo();
44
  if (!$brand || (!array_key_exists('hide', $brand) && !array_key_exists('hide_from_menu', $brand))) {
45
- $bname = $this->bvmain->getBrandName();
46
- add_menu_page($bname, $bname, 'manage_options', $this->bvmain->plugname,
47
  array($this, 'adminPage'), plugins_url('assets/img/favicon.ico', __FILE__ ));
48
  }
49
  }
50
 
51
  public function hidePluginDetails($plugin_metas, $slug) {
52
- $brand = $this->bvmain->getBrandInfo();
53
- $bvslug = $this->bvmain->slug;
54
 
55
  if ($slug === $bvslug && $brand && array_key_exists('hide_plugin_details', $brand)){
56
  foreach ($plugin_metas as $pluginKey => $pluginValue) {
@@ -95,31 +103,31 @@ class WPEAdmin {
95
  }
96
 
97
  public function getPluginLogo() {
98
- $brand = $this->bvmain->getBrandInfo();
99
  if ($brand && array_key_exists('logo', $brand)) {
100
  return $brand['logo'];
101
  }
102
- return $this->bvmain->logo;
103
  }
104
 
105
  public function getWebPage() {
106
- $brand = $this->bvmain->getBrandInfo();
107
  if ($brand && array_key_exists('webpage', $brand)) {
108
  return $brand['webpage'];
109
  }
110
- return $this->bvmain->webpage;
111
  }
112
 
113
  public function siteInfoTags() {
114
  $bvnonce = wp_create_nonce("bvnonce");
115
- $secret = $this->bvmain->auth->defaultSecret();
116
- $tags = "<input type='hidden' name='url' value='".$this->bvmain->info->wpurl()."'/>\n".
117
- "<input type='hidden' name='homeurl' value='".$this->bvmain->info->homeurl()."'/>\n".
118
- "<input type='hidden' name='siteurl' value='".$this->bvmain->info->siteurl()."'/>\n".
119
- "<input type='hidden' name='dbsig' value='".$this->bvmain->lib->dbsig(false)."'/>\n".
120
- "<input type='hidden' name='plug' value='".$this->bvmain->plugname."'/>\n".
121
  "<input type='hidden' name='adminurl' value='".$this->mainUrl()."'/>\n".
122
- "<input type='hidden' name='bvversion' value='".$this->bvmain->version."'/>\n".
123
  "<input type='hidden' name='serverip' value='".$_SERVER["SERVER_ADDR"]."'/>\n".
124
  "<input type='hidden' name='abspath' value='".ABSPATH."'/>\n".
125
  "<input type='hidden' name='secret' value='".$secret."'/>\n".
@@ -129,7 +137,7 @@ class WPEAdmin {
129
 
130
  public function activateWarning() {
131
  global $hook_suffix;
132
- if (!$this->bvmain->isConfigured() && $hook_suffix == 'index.php' ) {
133
  ?>
134
  <div id="message" class="updated" style="padding: 8px; font-size: 16px; background-color: #dff0d8">
135
  <a class="button-primary" href="<?php echo $this->mainUrl(); ?>">Activate Migrate Guru</a>
@@ -144,8 +152,8 @@ class WPEAdmin {
144
  }
145
 
146
  public function initBranding($plugins) {
147
- $slug = $this->bvmain->slug;
148
- $brand = $this->bvmain->getBrandInfo();
149
  if ($brand) {
150
  if (array_key_exists('hide', $brand)) {
151
  unset($plugins[$slug]);
1
  <?php
2
 
3
  if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('WPEWPAdmin')) :
5
+ class WPEWPAdmin {
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 WPEInfo($this->settings);
15
+ $this->account = WPEAccount::find($this->settings);
16
  }
17
 
18
  public function mainUrl($_params = '') {
19
  if (function_exists('network_admin_url')) {
20
+ return network_admin_url('admin.php?page='.$this->bvinfo->plugname.$_params);
21
  } else {
22
+ return admin_url('admin.php?page='.$this->bvinfo->plugname.$_params);
23
  }
24
  }
25
 
32
  array_key_exists('blogvaultkey', $_REQUEST) &&
33
  (strlen($_REQUEST['blogvaultkey']) == 64) &&
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);
41
  exit();
42
  }
43
  }
44
+ if ($this->bvinfo->isActivateRedirectSet()) {
45
+ $this->settings->updateOption($this->bvinfo->plug_redirect, 'no');
46
  wp_redirect($this->mainUrl());
47
  }
48
  }
49
 
50
  public function menu() {
51
+ $brand = $this->bvinfo->getBrandInfo();
52
  if (!$brand || (!array_key_exists('hide', $brand) && !array_key_exists('hide_from_menu', $brand))) {
53
+ $bname = $this->bvinfo->getBrandName();
54
+ add_menu_page($bname, $bname, 'manage_options', $this->bvinfo->plugname,
55
  array($this, 'adminPage'), plugins_url('assets/img/favicon.ico', __FILE__ ));
56
  }
57
  }
58
 
59
  public function hidePluginDetails($plugin_metas, $slug) {
60
+ $brand = $this->bvinfo->getBrandInfo();
61
+ $bvslug = $this->bvinfo->slug;
62
 
63
  if ($slug === $bvslug && $brand && array_key_exists('hide_plugin_details', $brand)){
64
  foreach ($plugin_metas as $pluginKey => $pluginValue) {
103
  }
104
 
105
  public function getPluginLogo() {
106
+ $brand = $this->bvinfo->getBrandInfo();
107
  if ($brand && array_key_exists('logo', $brand)) {
108
  return $brand['logo'];
109
  }
110
+ return $this->bvinfo->logo;
111
  }
112
 
113
  public function getWebPage() {
114
+ $brand = $this->bvinfo->getBrandInfo();
115
  if ($brand && array_key_exists('webpage', $brand)) {
116
  return $brand['webpage'];
117
  }
118
+ return $this->bvinfo->webpage;
119
  }
120
 
121
  public function siteInfoTags() {
122
  $bvnonce = wp_create_nonce("bvnonce");
123
+ $secret = $this->account->secret;
124
+ $tags = "<input type='hidden' name='url' value='".$this->siteinfo->wpurl()."'/>\n".
125
+ "<input type='hidden' name='homeurl' value='".$this->siteinfo->homeurl()."'/>\n".
126
+ "<input type='hidden' name='siteurl' value='".$this->siteinfo->siteurl()."'/>\n".
127
+ "<input type='hidden' name='dbsig' value='".$this->siteinfo->dbsig(false)."'/>\n".
128
+ "<input type='hidden' name='plug' value='".$this->bvinfo->plugname."'/>\n".
129
  "<input type='hidden' name='adminurl' value='".$this->mainUrl()."'/>\n".
130
+ "<input type='hidden' name='bvversion' value='".$this->bvinfo->version."'/>\n".
131
  "<input type='hidden' name='serverip' value='".$_SERVER["SERVER_ADDR"]."'/>\n".
132
  "<input type='hidden' name='abspath' value='".ABSPATH."'/>\n".
133
  "<input type='hidden' name='secret' value='".$secret."'/>\n".
137
 
138
  public function activateWarning() {
139
  global $hook_suffix;
140
+ if (!WPEAccount::isConfigured($this->settings) && $hook_suffix == 'index.php' ) {
141
  ?>
142
  <div id="message" class="updated" style="padding: 8px; font-size: 16px; background-color: #dff0d8">
143
  <a class="button-primary" href="<?php echo $this->mainUrl(); ?>">Activate Migrate Guru</a>
152
  }
153
 
154
  public function initBranding($plugins) {
155
+ $slug = $this->bvinfo->slug;
156
+ $brand = $this->bvinfo->getBrandInfo();
157
  if ($brand) {
158
  if (array_key_exists('hide', $brand)) {
159
  unset($plugins[$slug]);
wp_api.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('WPEWPAPI')) :
5
+ class WPEWPAPI {
6
+ public $account;
7
+
8
+ public function __construct($settings) {
9
+ $this->account = WPEAccount::find($settings);
10
+ }
11
+
12
+ public function pingbv($method, $body) {
13
+ $url = $this->account->authenticatedUrl($method);
14
+ $this->http_request($url, $body);
15
+ }
16
+
17
+ public function http_request($url, $body) {
18
+ $_body = array(
19
+ 'method' => 'POST',
20
+ 'timeout' => 15,
21
+ 'body' => $body);
22
+
23
+ return wp_remote_post($url, $_body);
24
+ }
25
+ }
26
+ endif;
main/db.php → wp_db.php RENAMED
@@ -1,87 +1,87 @@
1
  <?php
2
 
3
  if (!defined('ABSPATH')) exit;
4
- if (!class_exists('WPEDb')) :
5
 
6
- class WPEDb {
7
- function dbprefix() {
8
  global $wpdb;
9
  $prefix = $wpdb->base_prefix ? $wpdb->base_prefix : $wpdb->prefix;
10
  return $prefix;
11
  }
12
 
13
- function prepare($query, $args) {
14
  global $wpdb;
15
  return $wpdb->prepare($query, $args);
16
  }
17
 
18
- function getSiteId() {
19
  global $wpdb;
20
  return $wpdb->siteid;
21
  }
22
 
23
- function getResult($query, $obj = ARRAY_A) {
24
  global $wpdb;
25
  return $wpdb->get_results($query, $obj);
26
  }
27
 
28
- function query($query) {
29
  global $wpdb;
30
  return $wpdb->query($query);
31
  }
32
 
33
- function getVar($query, $col = 0, $row = 0) {
34
  global $wpdb;
35
  return $wpdb->get_var($query, $col, $row);
36
  }
37
 
38
- function getCol($query, $col = 0) {
39
  global $wpdb;
40
  return $wpdb->get_col($query, $col);
41
  }
42
 
43
- function tableName($table) {
44
  return $table[0];
45
  }
46
 
47
- function showTables() {
48
  $tables = $this->getResult("SHOW TABLES", ARRAY_N);
49
  return array_map(array($this, 'tableName'), $tables);
50
  }
51
 
52
- function showTableStatus() {
53
  return $this->getResult("SHOW TABLE STATUS");
54
  }
55
 
56
- function tableKeys($table) {
57
  return $this->getResult("SHOW KEYS FROM $table;");
58
  }
59
 
60
- function describeTable($table) {
61
  return $this->getResult("DESCRIBE $table;");
62
  }
63
 
64
- function checkTable($table, $type) {
65
  return $this->getResult("CHECK TABLE $table $type;");
66
  }
67
 
68
- function repairTable($table) {
69
  return $this->getResult("REPAIR TABLE $table;");
70
  }
71
 
72
- function showTableCreate($table) {
73
  return $this->getVar("SHOW CREATE TABLE $table;", 1);
74
  }
75
 
76
- function rowsCount($table) {
77
  $count = $this->getVar("SELECT COUNT(*) FROM $table;");
78
  return intval($count);
79
  }
80
 
81
- function createTable($query, $name) {
82
  $table = $this->getBVTable($name);
83
  if (!$this->isTablePresent($table)) {
84
- if (array_key_exists('usedbdelta', $_REQUEST)) {
85
  if (!function_exists('dbDelta'))
86
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
87
  dbDelta($query);
@@ -92,7 +92,16 @@ class WPEDb {
92
  return $this->isTablePresent($table);
93
  }
94
 
95
- function getTableContent($table, $fields = '*', $filter = '', $limit = 0, $offset = 0) {
 
 
 
 
 
 
 
 
 
96
  $query = "SELECT $fields from $table $filter";
97
  if ($limit > 0)
98
  $query .= " LIMIT $limit";
@@ -102,27 +111,24 @@ class WPEDb {
102
  return $rows;
103
  }
104
 
105
- function isTablePresent($table) {
106
  return ($this->getVar("SHOW TABLES LIKE '$table'") === $table);
107
  }
108
 
109
- function getCharsetCollate() {
110
  global $wpdb;
111
- if (method_exists($wpdb, 'get_charset_collate')) {
112
- return $wpdb->get_charset_collate();
113
- }
114
- return '';
115
  }
116
 
117
- function getWPTable($name) {
118
  return ($this->dbprefix() . $name);
119
  }
120
 
121
- function getBVTable($name) {
122
  return ($this->getWPTable("bv_" . $name));
123
  }
124
 
125
- function truncateBVTable($name) {
126
  $table = $this->getBVTable($name);
127
  if ($this->isTablePresent($table)) {
128
  return $this->query("TRUNCATE TABLE $table;");
@@ -131,7 +137,7 @@ class WPEDb {
131
  }
132
  }
133
 
134
- function deleteBVTableContent($name, $filter = "") {
135
  $table = $this->getBVTable($name);
136
  if ($this->isTablePresent($table)) {
137
  return $this->query("DELETE FROM $table $filter;");
@@ -140,7 +146,7 @@ class WPEDb {
140
  }
141
  }
142
 
143
- function dropBVTable($name) {
144
  $table = $this->getBVTable($name);
145
  if ($this->isTablePresent($table)) {
146
  $this->query("DROP TABLE IF EXISTS $table;");
@@ -148,7 +154,7 @@ class WPEDb {
148
  return !$this->isTablePresent($table);
149
  }
150
 
151
- function deleteRowsFromtable($name, $count = 1) {
152
  $table = $this->getBVTable($name);
153
  if ($this->isTablePresent($table)) {
154
  return $this->getResult("DELETE FROM $table LIMIT $count;");
@@ -157,7 +163,7 @@ class WPEDb {
157
  }
158
  }
159
 
160
- function replaceIntoBVTable($name, $value) {
161
  global $wpdb;
162
  $table = $this->getBVTable($name);
163
  return $wpdb->replace($table, $value);
1
  <?php
2
 
3
  if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('WPEWPDb')) :
5
 
6
+ class WPEWPDb {
7
+ public function dbprefix() {
8
  global $wpdb;
9
  $prefix = $wpdb->base_prefix ? $wpdb->base_prefix : $wpdb->prefix;
10
  return $prefix;
11
  }
12
 
13
+ public function prepare($query, $args) {
14
  global $wpdb;
15
  return $wpdb->prepare($query, $args);
16
  }
17
 
18
+ public function getSiteId() {
19
  global $wpdb;
20
  return $wpdb->siteid;
21
  }
22
 
23
+ public function getResult($query, $obj = ARRAY_A) {
24
  global $wpdb;
25
  return $wpdb->get_results($query, $obj);
26
  }
27
 
28
+ public function query($query) {
29
  global $wpdb;
30
  return $wpdb->query($query);
31
  }
32
 
33
+ public function getVar($query, $col = 0, $row = 0) {
34
  global $wpdb;
35
  return $wpdb->get_var($query, $col, $row);
36
  }
37
 
38
+ public function getCol($query, $col = 0) {
39
  global $wpdb;
40
  return $wpdb->get_col($query, $col);
41
  }
42
 
43
+ public function tableName($table) {
44
  return $table[0];
45
  }
46
 
47
+ public function showTables() {
48
  $tables = $this->getResult("SHOW TABLES", ARRAY_N);
49
  return array_map(array($this, 'tableName'), $tables);
50
  }
51
 
52
+ public function showTableStatus() {
53
  return $this->getResult("SHOW TABLE STATUS");
54
  }
55
 
56
+ public function tableKeys($table) {
57
  return $this->getResult("SHOW KEYS FROM $table;");
58
  }
59
 
60
+ public function describeTable($table) {
61
  return $this->getResult("DESCRIBE $table;");
62
  }
63
 
64
+ public function checkTable($table, $type) {
65
  return $this->getResult("CHECK TABLE $table $type;");
66
  }
67
 
68
+ public function repairTable($table) {
69
  return $this->getResult("REPAIR TABLE $table;");
70
  }
71
 
72
+ public function showTableCreate($table) {
73
  return $this->getVar("SHOW CREATE TABLE $table;", 1);
74
  }
75
 
76
+ public function rowsCount($table) {
77
  $count = $this->getVar("SELECT COUNT(*) FROM $table;");
78
  return intval($count);
79
  }
80
 
81
+ public function createTable($query, $name, $usedbdelta = false) {
82
  $table = $this->getBVTable($name);
83
  if (!$this->isTablePresent($table)) {
84
+ if ($usedbdelta) {
85
  if (!function_exists('dbDelta'))
86
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
87
  dbDelta($query);
92
  return $this->isTablePresent($table);
93
  }
94
 
95
+ public function alterBVTable($query, $name) {
96
+ $resp = false;
97
+ $table = $this->getBVTable($name);
98
+ if ($this->isTablePresent($table)) {
99
+ $resp = $this->query($query);
100
+ }
101
+ return $resp;
102
+ }
103
+
104
+ public function getTableContent($table, $fields = '*', $filter = '', $limit = 0, $offset = 0) {
105
  $query = "SELECT $fields from $table $filter";
106
  if ($limit > 0)
107
  $query .= " LIMIT $limit";
111
  return $rows;
112
  }
113
 
114
+ public function isTablePresent($table) {
115
  return ($this->getVar("SHOW TABLES LIKE '$table'") === $table);
116
  }
117
 
118
+ public function getCharsetCollate() {
119
  global $wpdb;
120
+ return $wpdb->get_charset_collate();
 
 
 
121
  }
122
 
123
+ public function getWPTable($name) {
124
  return ($this->dbprefix() . $name);
125
  }
126
 
127
+ public function getBVTable($name) {
128
  return ($this->getWPTable("bv_" . $name));
129
  }
130
 
131
+ public function truncateBVTable($name) {
132
  $table = $this->getBVTable($name);
133
  if ($this->isTablePresent($table)) {
134
  return $this->query("TRUNCATE TABLE $table;");
137
  }
138
  }
139
 
140
+ public function deleteBVTableContent($name, $filter = "") {
141
  $table = $this->getBVTable($name);
142
  if ($this->isTablePresent($table)) {
143
  return $this->query("DELETE FROM $table $filter;");
146
  }
147
  }
148
 
149
+ public function dropBVTable($name) {
150
  $table = $this->getBVTable($name);
151
  if ($this->isTablePresent($table)) {
152
  $this->query("DROP TABLE IF EXISTS $table;");
154
  return !$this->isTablePresent($table);
155
  }
156
 
157
+ public function deleteRowsFromtable($name, $count = 1) {
158
  $table = $this->getBVTable($name);
159
  if ($this->isTablePresent($table)) {
160
  return $this->getResult("DELETE FROM $table LIMIT $count;");
163
  }
164
  }
165
 
166
+ public function replaceIntoBVTable($name, $value) {
167
  global $wpdb;
168
  $table = $this->getBVTable($name);
169
  return $wpdb->replace($table, $value);
wp_settings.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('WPEWPSettings')) :
5
+ class WPEWPSettings {
6
+ public function getOption($key) {
7
+ $res = false;
8
+ if (function_exists('get_site_option')) {
9
+ $res = get_site_option($key, false);
10
+ }
11
+ if ($res === false) {
12
+ $res = get_option($key, false);
13
+ }
14
+ return $res;
15
+ }
16
+
17
+ public function deleteOption($key) {
18
+ if (function_exists('delete_site_option')) {
19
+ return delete_site_option($key);
20
+ } else {
21
+ return delete_option($key);
22
+ }
23
+ }
24
+
25
+ public function updateOption($key, $value) {
26
+ if (function_exists('update_site_option')) {
27
+ return update_site_option($key, $value);
28
+ } else {
29
+ return update_option($key, $value);
30
+ }
31
+ }
32
+
33
+ public function setTransient($name, $value, $time) {
34
+ if (function_exists('set_site_transient')) {
35
+ return set_site_transient($name, $value, $time);
36
+ }
37
+ return false;
38
+ }
39
+
40
+ public function deleteTransient($name) {
41
+ if (function_exists('delete_site_transient')) {
42
+ return delete_site_transient($name);
43
+ }
44
+ return false;
45
+ }
46
+
47
+ public function getTransient($name) {
48
+ if (function_exists('get_site_transient')) {
49
+ return get_site_transient($name);
50
+ }
51
+ return false;
52
+ }
53
+ }
54
+ endif;
wp_site_info.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('WPEWPSiteInfo')) :
5
+
6
+ class WPEWPSiteInfo {
7
+ public function wpurl() {
8
+ if (function_exists('network_site_url'))
9
+ return network_site_url();
10
+ else
11
+ return get_bloginfo('wpurl');
12
+ }
13
+
14
+ public function siteurl() {
15
+ if (function_exists('site_url')) {
16
+ return site_url();
17
+ } else {
18
+ return get_bloginfo('wpurl');
19
+ }
20
+ }
21
+
22
+ public function homeurl() {
23
+ if (function_exists('home_url')) {
24
+ return home_url();
25
+ } else {
26
+ return get_bloginfo('url');
27
+ }
28
+ }
29
+
30
+ public function isMultisite() {
31
+ if (function_exists('is_multisite'))
32
+ return is_multisite();
33
+ return false;
34
+ }
35
+
36
+ public function isMainSite() {
37
+ if (!function_exists('is_main_site' ) || !$this->isMultisite())
38
+ return true;
39
+ return is_main_site();
40
+ }
41
+
42
+ public function respInfo() {
43
+ $info = array();
44
+ $this->basic($info);
45
+ $info['dbsig'] = $this->dbsig(false);
46
+ $info["serversig"] = $this->serversig(false);
47
+ return $info;
48
+ }
49
+
50
+ public function basic(&$info) {
51
+ $info['wpurl'] = $this->wpurl();
52
+ $info['siteurl'] = $this->siteurl();
53
+ $info['homeurl'] = $this->homeurl();
54
+ $info['serverip'] = $_SERVER['SERVER_ADDR'];
55
+ $info['abspath'] = ABSPATH;
56
+ }
57
+
58
+ public function serversig($full = false) {
59
+ $sig = sha1($_SERVER['SERVER_ADDR'].ABSPATH);
60
+ if ($full)
61
+ return $sig;
62
+ else
63
+ return substr($sig, 0, 6);
64
+ }
65
+
66
+ public function dbsig($full = false) {
67
+ if (defined('DB_USER') && defined('DB_NAME') &&
68
+ defined('DB_PASSWORD') && defined('DB_HOST')) {
69
+ $sig = sha1(DB_USER.DB_NAME.DB_PASSWORD.DB_HOST);
70
+ } else {
71
+ $sig = "bvnone".WPEAccount::randString(34);
72
+ }
73
+ if ($full)
74
+ return $sig;
75
+ else
76
+ return substr($sig, 0, 6);
77
+ }
78
+ }
79
+ endif;
wpengine.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://wpengine.com
5
  Description: The easiest way to migrate your site to WP Engine
6
  Author: WPEngine
7
  Author URI: https://wpengine.com
8
- Version: 1.88
9
  Network: True
10
  */
11
 
@@ -28,55 +28,83 @@ Network: True
28
  /* Global response array */
29
 
30
  if (!defined('ABSPATH')) exit;
31
- global $bvcb, $bvresp;
 
 
 
 
 
 
32
 
33
- require_once dirname( __FILE__ ) . '/main.php';
34
- $bvmain = new WPEngine();
35
 
36
- register_uninstall_hook(__FILE__, array('WPEngine', 'uninstall'));
37
- register_activation_hook(__FILE__, array($bvmain, 'activate'));
38
- register_deactivation_hook(__FILE__, array($bvmain, 'deactivate'));
39
 
40
- add_action('wp_footer', array($bvmain, 'footerHandler'), 100);
 
 
 
 
 
 
 
 
 
41
 
42
  if (is_admin()) {
43
- require_once dirname( __FILE__ ) . '/admin.php';
44
- $bvadmin = new WPEAdmin($bvmain);
45
- add_action('admin_init', array($bvadmin, 'initHandler'));
46
- add_filter('all_plugins', array($bvadmin, 'initBranding'));
47
- add_filter('plugin_row_meta', array($bvadmin, 'hidePluginDetails'), 10, 2);
48
- if ($bvmain->info->isMultisite()) {
49
- add_action('network_admin_menu', array($bvadmin, 'menu'));
50
  } else {
51
- add_action('admin_menu', array($bvadmin, 'menu'));
52
  }
53
- add_filter('plugin_action_links', array($bvadmin, 'settingsLink'), 10, 2);
54
  ##ACTIVATEWARNING##
55
- add_action('admin_enqueue_scripts', array($bvadmin, 'wpesecAdminMenu'));
56
  }
57
 
 
58
  if ((array_key_exists('bvreqmerge', $_POST)) || (array_key_exists('bvreqmerge', $_GET))) {
59
- $_REQUEST = array_merge($_GET, $_POST);
60
  }
61
 
62
- if ((array_key_exists('bvplugname', $_REQUEST)) &&
63
- stristr($_REQUEST['bvplugname'], $bvmain->plugname)) {
64
- require_once dirname( __FILE__ ) . '/callback.php';
65
- $bvcb = new BVCallback($bvmain);
66
- $bvresp = new BVResponse();
67
- if ($bvcb->preauth() === 1) {
68
- if ($bvcb->authenticate() === 1) {
69
- if (array_key_exists('afterload', $_REQUEST)) {
70
- add_action('wp_loaded', array($bvcb, 'execute'));
71
- } else if (array_key_exists('adajx', $_REQUEST)) {
72
- add_action('wp_ajax_bvadm', array($bvcb, 'bvAdmExecuteWithUser'));
73
- add_action('wp_ajax_nopriv_bvadm', array($bvcb, 'bvAdmExecuteWithoutUser'));
74
- } else {
75
- $bvcb->execute();
76
- }
 
 
 
 
 
77
  } else {
78
- $bvcb->terminate(false, array_key_exists('bvdbg', $_REQUEST));
79
  }
 
 
 
 
 
 
 
 
 
80
  }
81
  } else {
82
  ##PROTECTMODULE##
5
  Description: The easiest way to migrate your site to WP Engine
6
  Author: WPEngine
7
  Author URI: https://wpengine.com
8
+ Version: 2.1
9
  Network: True
10
  */
11
 
28
  /* Global response array */
29
 
30
  if (!defined('ABSPATH')) exit;
31
+ require_once dirname( __FILE__ ) . '/wp_settings.php';
32
+ require_once dirname( __FILE__ ) . '/wp_site_info.php';
33
+ require_once dirname( __FILE__ ) . '/wp_db.php';
34
+ require_once dirname( __FILE__ ) . '/wp_api.php';
35
+ require_once dirname( __FILE__ ) . '/wp_actions.php';
36
+ require_once dirname( __FILE__ ) . '/info.php';
37
+ require_once dirname( __FILE__ ) . '/account.php';
38
 
 
 
39
 
40
+ $bvsettings = new WPEWPSettings();
41
+ $bvsiteinfo = new WPEWPSiteInfo();
42
+ $bvdb = new WPEWPDb();
43
 
44
+
45
+ $bvapi = new WPEWPAPI($bvsettings);
46
+ $bvinfo = new WPEInfo($bvsettings);
47
+ $wp_action = new WPEWPAction($bvsettings, $bvsiteinfo, $bvapi);
48
+
49
+ register_uninstall_hook(__FILE__, array('WPEWPAction', 'uninstall'));
50
+ register_activation_hook(__FILE__, array($wp_action, 'activate'));
51
+ 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 WPEWPAdmin($bvsettings, $bvsiteinfo);
58
+ add_action('admin_init', array($wpadmin, 'initHandler'));
59
+ add_filter('all_plugins', array($wpadmin, 'initBranding'));
60
+ add_filter('plugin_row_meta', array($wpadmin, 'hidePluginDetails'), 10, 2);
61
+ if ($bvsiteinfo->isMultisite()) {
62
+ add_action('network_admin_menu', array($wpadmin, 'menu'));
63
  } else {
64
+ add_action('admin_menu', array($wpadmin, 'menu'));
65
  }
66
+ add_filter('plugin_action_links', array($wpadmin, 'settingsLink'), 10, 2);
67
  ##ACTIVATEWARNING##
68
+ add_action('admin_enqueue_scripts', array($wpadmin, 'wpesecAdminMenu'));
69
  }
70
 
71
+
72
  if ((array_key_exists('bvreqmerge', $_POST)) || (array_key_exists('bvreqmerge', $_GET))) {
73
+ $_REQUEST = array_merge($_GET, $_POST);
74
  }
75
 
76
+ if ((array_key_exists('bvplugname', $_REQUEST)) && ($_REQUEST['bvplugname'] == "wpengine")) {
77
+ require_once dirname( __FILE__ ) . '/callback/base.php';
78
+ require_once dirname( __FILE__ ) . '/callback/request.php';
79
+ require_once dirname( __FILE__ ) . '/callback/response.php';
80
+
81
+ $request = new BVCallbackRequest($_REQUEST);
82
+ $account = WPEAccount::find($bvsettings, $_REQUEST['pubkey']);
83
+
84
+
85
+ ##RECOVERYMODULE##
86
+
87
+ if ($account && (1 === $account->authenticate())) {
88
+ require_once dirname( __FILE__ ) . '/callback/handler.php';
89
+ $request->params = $request->processParams();
90
+ $callback_handler = new BVCallbackHandler($bvdb, $bvsettings, $bvsiteinfo, $request, $account);
91
+ if ($request->is_afterload) {
92
+ add_action('wp_loaded', array($callback_handler, 'execute'));
93
+ } else if ($request->is_admin_ajax) {
94
+ add_action('wp_ajax_bvadm', array($callback_handler, 'bvAdmExecuteWithUser'));
95
+ add_action('wp_ajax_nopriv_bvadm', array($callback_handler, 'bvAdmExecuteWithoutUser'));
96
  } else {
97
+ $callback_handler->execute();
98
  }
99
+ } else {
100
+ $resp = array(
101
+ "account_info" => $account ? $account->respInfo() : array("error" => "ACCOUNT_NOT_FOUND"),
102
+ "request_info" => $request->respInfo(),
103
+ "bvinfo" => $bvinfo->respInfo(),
104
+ "statusmsg" => "FAILED_AUTH"
105
+ );
106
+ $response = new BVCallbackResponse();
107
+ $response->terminate($resp, $request->params);
108
  }
109
  } else {
110
  ##PROTECTMODULE##