WP Engine Automated Migration - Version 4.31

Version Description

  • Fetching Mysql Version
  • Robust data fetch APIs
  • Core plugin changes
  • Sanitizing incoming params
Download this release

Release Info

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

Code changes from version 3.9 to 4.31

account.php CHANGED
@@ -42,6 +42,10 @@ if (!class_exists('WPEAccount')) :
42
  return $str;
43
  }
44
 
 
 
 
 
45
  public static function apiPublicAccount($settings) {
46
  $pubkey = $settings->getOption(self::$api_public_key);
47
  return self::find($settings, $pubkey);
@@ -98,6 +102,7 @@ if (!class_exists('WPEAccount')) :
98
  }
99
 
100
  public function newAuthParams($version) {
 
101
  $args = array();
102
  $time = time();
103
  $sig = sha1($this->public.$this->secret.$time.$version);
@@ -106,6 +111,7 @@ if (!class_exists('WPEAccount')) :
106
  $args['bvPublic'] = $this->public;
107
  $args['bvVersion'] = $version;
108
  $args['sha1'] = '1';
 
109
  return $args;
110
  }
111
 
@@ -179,4 +185,4 @@ if (!class_exists('WPEAccount')) :
179
  return array_key_exists($pubkey, $accounts);
180
  }
181
  }
182
- endif;
42
  return $str;
43
  }
44
 
45
+ public static function sanitizeKey($key) {
46
+ return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key);
47
+ }
48
+
49
  public static function apiPublicAccount($settings) {
50
  $pubkey = $settings->getOption(self::$api_public_key);
51
  return self::find($settings, $pubkey);
102
  }
103
 
104
  public function newAuthParams($version) {
105
+ $bvinfo = new WPEInfo($this->settings);
106
  $args = array();
107
  $time = time();
108
  $sig = sha1($this->public.$this->secret.$time.$version);
111
  $args['bvPublic'] = $this->public;
112
  $args['bvVersion'] = $version;
113
  $args['sha1'] = '1';
114
+ $args['plugname'] = $bvinfo->plugname;
115
  return $args;
116
  }
117
 
185
  return array_key_exists($pubkey, $accounts);
186
  }
187
  }
188
+ endif;
callback/handler.php CHANGED
@@ -84,6 +84,10 @@ if (!class_exists('BVCallbackHandler')) :
84
  require_once dirname( __FILE__ ) . '/wings/account.php';
85
  $module = new BVAccountCallback($this);
86
  break;
 
 
 
 
87
  default:
88
  require_once dirname( __FILE__ ) . '/wings/misc.php';
89
  $module = new BVMiscCallback($this);
@@ -104,4 +108,4 @@ if (!class_exists('BVCallbackHandler')) :
104
  return 1;
105
  }
106
  }
107
- endif;
84
  require_once dirname( __FILE__ ) . '/wings/account.php';
85
  $module = new BVAccountCallback($this);
86
  break;
87
+ case 'fswrt':
88
+ require_once dirname( __FILE__ ) . '/wings/fs_write.php';
89
+ $module = new BVFSWriteCallback();
90
+ break;
91
  default:
92
  require_once dirname( __FILE__ ) . '/wings/misc.php';
93
  $module = new BVMiscCallback($this);
108
  return 1;
109
  }
110
  }
111
+ endif;
callback/request.php CHANGED
@@ -89,7 +89,7 @@ if (!class_exists('BVCallbackRequest')) :
89
  if (array_key_exists('bvprms', $in_params) && isset($in_params['bvprms']) &&
90
  array_key_exists('bvprmsmac', $in_params) && isset($in_params['bvprmsmac'])) {
91
  $digest_algo = 'SHA1';
92
- $sent_mac = $in_params['bvprmsmac'];
93
 
94
  if (array_key_exists('bvprmshshalgo', $in_params) && isset($in_params['bvprmshshalgo'])) {
95
  $digest_algo = $in_params['bvprmshshalgo'];
@@ -176,4 +176,4 @@ if (!class_exists('BVCallbackRequest')) :
176
  return $data;
177
  }
178
  }
179
- endif;
89
  if (array_key_exists('bvprms', $in_params) && isset($in_params['bvprms']) &&
90
  array_key_exists('bvprmsmac', $in_params) && isset($in_params['bvprmsmac'])) {
91
  $digest_algo = 'SHA1';
92
+ $sent_mac = WPEAccount::sanitizeKey($in_params['bvprmsmac']);
93
 
94
  if (array_key_exists('bvprmshshalgo', $in_params) && isset($in_params['bvprmshshalgo'])) {
95
  $digest_algo = $in_params['bvprmshshalgo'];
176
  return $data;
177
  }
178
  }
179
+ endif;
callback/wings/fs.php CHANGED
@@ -12,8 +12,6 @@ class BVFSCallback extends BVCallbackBase {
12
 
13
  public function __construct($callback_handler) {
14
  $this->account = $callback_handler->account;
15
- $this->siteinfo = $callback_handler->siteinfo;
16
- $this->bvinfo = $callback_handler->bvinfo;
17
  }
18
 
19
  function fileStat($relfile) {
@@ -236,33 +234,6 @@ class BVFSCallback extends BVCallbackBase {
236
  return $result;
237
  }
238
 
239
- function mkdir($path, $permissions) {
240
- $result = array();
241
- $path = ABSPATH.$path;
242
-
243
- if (!file_exists($path)) {
244
- if (!mkdir($path)) {
245
- $result['status'] = 'Error';
246
- $result['message'] = 'UNABLE_TO_CREATE_DIR';
247
- }
248
- } else {
249
- $result['already_exists'] = true;
250
- }
251
-
252
- if (file_exists($path)) {
253
- $result['exists'] = true;
254
-
255
- if (chmod($path, $permissions)) {
256
- $result['status'] = 'Done';
257
- } else {
258
- $result['status'] = 'Error';
259
- $result['message'] = "UNABLE_TO_SET_PERMISSIONS";
260
- }
261
- }
262
-
263
- return $result;
264
- }
265
-
266
  function process($request) {
267
  $params = $request->params;
268
  $stream_init_info = BVStream::startStream($this->account, $request);
@@ -346,10 +317,6 @@ class BVFSCallback extends BVCallbackBase {
346
  $withContent = array_key_exists('withcontent', $params) ? $params['withcontent'] : true;
347
  $resp = array("files_content" => $this->getFilesContent($files, $withContent));
348
  break;
349
- case "mkdr":
350
- $permissions = array_key_exists('permissions', $params) ? $params['permissions'] : 0777;
351
- $resp = array('mkdir' => $this->mkdir($params['path'], $permissions));
352
- break;
353
  default:
354
  $resp = false;
355
  }
12
 
13
  public function __construct($callback_handler) {
14
  $this->account = $callback_handler->account;
 
 
15
  }
16
 
17
  function fileStat($relfile) {
234
  return $result;
235
  }
236
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  function process($request) {
238
  $params = $request->params;
239
  $stream_init_info = BVStream::startStream($this->account, $request);
317
  $withContent = array_key_exists('withcontent', $params) ? $params['withcontent'] : true;
318
  $resp = array("files_content" => $this->getFilesContent($files, $withContent));
319
  break;
 
 
 
 
320
  default:
321
  $resp = false;
322
  }
callback/wings/info.php CHANGED
@@ -135,7 +135,9 @@ class BVInfoCallback extends BVCallbackBase {
135
  'charset' => get_bloginfo('charset'),
136
  'wpversion' => $wp_version,
137
  'dbversion' => $wp_db_version,
 
138
  'abspath' => ABSPATH,
 
139
  'uploadpath' => $upload_dir['basedir'],
140
  'uploaddir' => wp_upload_dir(),
141
  'contentdir' => defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : null,
@@ -237,6 +239,15 @@ class BVInfoCallback extends BVCallbackBase {
237
  return array('actinfo' => $resp);
238
  }
239
 
 
 
 
 
 
 
 
 
 
240
  public function process($request) {
241
  $db = $this->db;
242
  $params = $request->params;
@@ -290,6 +301,19 @@ class BVInfoCallback extends BVCallbackBase {
290
  $transient = $this->objectToArray($transient);
291
  $resp = array("transient" => $transient);
292
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  default:
294
  $resp = false;
295
  }
135
  'charset' => get_bloginfo('charset'),
136
  'wpversion' => $wp_version,
137
  'dbversion' => $wp_db_version,
138
+ 'mysql_version' => $db->getMysqlVersion(),
139
  'abspath' => ABSPATH,
140
+ 'bvpluginpath' => defined('WPEBASEPATH') ? WPEBASEPATH : null,
141
  'uploadpath' => $upload_dir['basedir'],
142
  'uploaddir' => wp_upload_dir(),
143
  'contentdir' => defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : null,
239
  return array('actinfo' => $resp);
240
  }
241
 
242
+ public function getHostInfo() {
243
+ $host_info = $_SERVER;
244
+ $host_info['PHP_SERVER_NAME'] = php_uname('\n');
245
+ if (array_key_exists('IS_PRESSABLE', get_defined_constants())) {
246
+ $host_info['IS_PRESSABLE'] = true;
247
+ }
248
+ return array('host_info' => $host_info);
249
+ }
250
+
251
  public function process($request) {
252
  $db = $this->db;
253
  $params = $request->params;
301
  $transient = $this->objectToArray($transient);
302
  $resp = array("transient" => $transient);
303
  break;
304
+ case "gthost":
305
+ $resp = $this->getHostInfo();
306
+ break;
307
+ case "gtplinfo":
308
+ $args = array(
309
+ 'slug' => wp_unslash($params['slug'])
310
+ );
311
+ $action = $params['action'];
312
+ $args = (object) $args;
313
+ $args = apply_filters('plugins_api_args', $args, $action);
314
+ $data = apply_filters('plugins_api', false, $action, $args);
315
+ $resp = array("plugins_info" => $data);
316
+ break;
317
  default:
318
  $resp = false;
319
  }
callback/wings/misc.php CHANGED
@@ -16,6 +16,32 @@ class BVMiscCallback extends BVCallbackBase {
16
  $this->bvinfo = new WPEInfo($callback_handler->settings);
17
  }
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  public function process($request) {
20
  $bvinfo = $this->bvinfo;
21
  $settings = $this->settings;
@@ -53,10 +79,10 @@ class BVMiscCallback extends BVCallbackBase {
53
  $resp = array("unsetdynplug" => $settings->getOption('bvdynplug'));
54
  break;
55
  case "wpupplgs":
56
- $resp = array("wpupdateplugins" => wp_update_plugins());
57
  break;
58
  case "wpupthms":
59
- $resp = array("wpupdatethemes" => wp_update_themes());
60
  break;
61
  case "wpupcre":
62
  $resp = array("wpupdatecore" => wp_version_check());
@@ -68,10 +94,13 @@ class BVMiscCallback extends BVCallbackBase {
68
  case "dlttrsnt":
69
  $resp = array("dlttrsnt" => $settings->deleteTransient($params['key']));
70
  break;
 
 
 
71
  default:
72
  $resp = false;
73
  }
74
  return $resp;
75
  }
76
  }
77
- endif;
16
  $this->bvinfo = new WPEInfo($callback_handler->settings);
17
  }
18
 
19
+ public function refreshPluginUpdates() {
20
+ global $wp_current_filter;
21
+ $wp_current_filter[] = 'load-update-core.php';
22
+
23
+ wp_update_plugins();
24
+
25
+ array_pop($wp_current_filter);
26
+
27
+ wp_update_plugins();
28
+
29
+ return array("wpupdateplugins" => true);
30
+ }
31
+
32
+ public function refreshThemeUpdates() {
33
+ global $wp_current_filter;
34
+ $wp_current_filter[] = 'load-update-core.php';
35
+
36
+ wp_update_themes();
37
+
38
+ array_pop($wp_current_filter);
39
+
40
+ wp_update_themes();
41
+
42
+ return array("wpupdatethemes" => true);
43
+ }
44
+
45
  public function process($request) {
46
  $bvinfo = $this->bvinfo;
47
  $settings = $this->settings;
79
  $resp = array("unsetdynplug" => $settings->getOption('bvdynplug'));
80
  break;
81
  case "wpupplgs":
82
+ $resp = $this->refreshPluginUpdates();
83
  break;
84
  case "wpupthms":
85
+ $resp = $this->refreshThemeUpdates();
86
  break;
87
  case "wpupcre":
88
  $resp = array("wpupdatecore" => wp_version_check());
94
  case "dlttrsnt":
95
  $resp = array("dlttrsnt" => $settings->deleteTransient($params['key']));
96
  break;
97
+ case "setmanulsignup":
98
+ $resp = array("setmanulsignup" => $settings->updateOption("bvmanualsignup", true));
99
+ break;
100
  default:
101
  $resp = false;
102
  }
103
  return $resp;
104
  }
105
  }
106
+ endif;
info.php CHANGED
@@ -9,7 +9,7 @@ if (!class_exists('WPEInfo')) :
9
  public $badgeinfo = 'wpebadge';
10
  public $ip_header_option = 'wpeipheader';
11
  public $brand_option = 'wpebrand';
12
- public $version = '3.9';
13
  public $webpage = 'https://wpengine.com';
14
  public $appurl = 'https://wpengine.blogvault.net';
15
  public $slug = 'wp-site-migrate/wpengine.php';
@@ -21,8 +21,8 @@ if (!class_exists('WPEInfo')) :
21
  $this->settings = $settings;
22
  }
23
 
24
- public function canOverrideCW() {
25
- $scanOption = $this->settings->getOption('bvoverridecw');
26
  return (isset($scanOption) && $scanOption == 1);
27
  }
28
 
9
  public $badgeinfo = 'wpebadge';
10
  public $ip_header_option = 'wpeipheader';
11
  public $brand_option = 'wpebrand';
12
+ public $version = '4.31';
13
  public $webpage = 'https://wpengine.com';
14
  public $appurl = 'https://wpengine.blogvault.net';
15
  public $slug = 'wp-site-migrate/wpengine.php';
21
  $this->settings = $settings;
22
  }
23
 
24
+ public function isManualSignup() {
25
+ $scanOption = $this->settings->getOption('bvmanualsignup');
26
  return (isset($scanOption) && $scanOption == 1);
27
  }
28
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: wpe, wpengine, migration
4
  Requires at least: 4.0
5
  Tested up to: 5.4
6
  Requires PHP: 5.4.0
7
- Stable tag: 3.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -79,6 +79,12 @@ That's easy! [Signup here](http://wpengine.com/plans/).
79
  2. BlogVault dashboard showing live updates.
80
 
81
  == Changelog ==
 
 
 
 
 
 
82
  = 3.9 =
83
  * .htaccess Warning Added in Main Page
84
 
4
  Requires at least: 4.0
5
  Tested up to: 5.4
6
  Requires PHP: 5.4.0
7
+ Stable tag: 4.31
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
79
  2. BlogVault dashboard showing live updates.
80
 
81
  == Changelog ==
82
+ = 4.31 =
83
+ * Fetching Mysql Version
84
+ * Robust data fetch APIs
85
+ * Core plugin changes
86
+ * Sanitizing incoming params
87
+
88
  = 3.9 =
89
  * .htaccess Warning Added in Main Page
90
 
wp_admin.php CHANGED
@@ -9,7 +9,7 @@ class WPEWPAdmin {
9
  public $bvinfo;
10
  public $bvapi;
11
 
12
- function __construct($settings, $siteinfo, $bvapi) {
13
  $this->settings = $settings;
14
  $this->siteinfo = $siteinfo;
15
  $this->bvapi = $bvapi;
9
  public $bvinfo;
10
  public $bvapi;
11
 
12
+ function __construct($settings, $siteinfo, $bvapi = null) {
13
  $this->settings = $settings;
14
  $this->siteinfo = $siteinfo;
15
  $this->bvapi = $bvapi;
wp_api.php CHANGED
@@ -8,22 +8,24 @@ if (!class_exists('WPEWPAPI')) :
8
  public function __construct($settings) {
9
  $this->settings = $settings;
10
  }
11
-
12
  public function pingbv($method, $body, $public = false) {
13
  if ($public) {
14
- $this->create_request_params($method, $body, $public);
15
  } else {
16
- $accounts = WPEAccount::allAccounts($this->settings);
17
- foreach ($accounts as $pubkey => $value ) {
18
- $this->create_request_params($method, $body, $pubkey);
19
  }
20
  }
21
  }
22
 
23
- public function create_request_params($method, $body, $pubkey) {
24
  $account = WPEAccount::find($this->settings, $pubkey);
25
- $url = $account->authenticatedUrl($method);
26
- $this->http_request($url, $body);
 
 
27
  }
28
 
29
  public function http_request($url, $body, $headers = array()) {
8
  public function __construct($settings) {
9
  $this->settings = $settings;
10
  }
11
+
12
  public function pingbv($method, $body, $public = false) {
13
  if ($public) {
14
+ $this->do_request($method, $body, $public);
15
  } else {
16
+ $api_public_key = $this->settings->getOption('bvApiPublic');
17
+ if (!empty($api_public_key) && (strlen($api_public_key) >= 32)) {
18
+ $this->do_request($method, $body, $api_public_key);
19
  }
20
  }
21
  }
22
 
23
+ public function do_request($method, $body, $pubkey) {
24
  $account = WPEAccount::find($this->settings, $pubkey);
25
+ if (isset($account)) {
26
+ $url = $account->authenticatedUrl($method);
27
+ $this->http_request($url, $body);
28
+ }
29
  }
30
 
31
  public function http_request($url, $body, $headers = array()) {
wp_db.php CHANGED
@@ -182,5 +182,10 @@ class WPEWPDb {
182
 
183
  return $result;
184
  }
 
 
 
 
 
185
  }
186
- endif;
182
 
183
  return $result;
184
  }
185
+
186
+ public function getMysqlVersion() {
187
+ global $wpdb;
188
+ return $wpdb->db_version();
189
+ }
190
  }
191
+ 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: 3.9
9
  Network: True
10
  */
11
 
@@ -56,7 +56,7 @@ add_action('wp_footer', array($wp_action, 'footerHandler'), 100);
56
  ##WPCLIMODULE##
57
  if (is_admin()) {
58
  require_once dirname( __FILE__ ) . '/wp_admin.php';
59
- $wpadmin = new WPEWPAdmin($bvsettings, $bvsiteinfo, $bvapi);
60
  add_action('admin_init', array($wpadmin, 'initHandler'));
61
  add_filter('all_plugins', array($wpadmin, 'initBranding'));
62
  add_filter('plugin_row_meta', array($wpadmin, 'hidePluginDetails'), 10, 2);
@@ -82,7 +82,7 @@ if ((array_key_exists('bvplugname', $_REQUEST)) && ($_REQUEST['bvplugname'] == "
82
  require_once dirname( __FILE__ ) . '/callback/request.php';
83
  require_once dirname( __FILE__ ) . '/recover.php';
84
 
85
- $pubkey = $_REQUEST['pubkey'];
86
 
87
  if (array_key_exists('rcvracc', $_REQUEST)) {
88
  $account = WPERecover::find($bvsettings, $pubkey);
5
  Description: The easiest way to migrate your site to WP Engine
6
  Author: WPEngine
7
  Author URI: https://wpengine.com
8
+ Version: 4.31
9
  Network: True
10
  */
11
 
56
  ##WPCLIMODULE##
57
  if (is_admin()) {
58
  require_once dirname( __FILE__ ) . '/wp_admin.php';
59
+ $wpadmin = new WPEWPAdmin($bvsettings, $bvsiteinfo);
60
  add_action('admin_init', array($wpadmin, 'initHandler'));
61
  add_filter('all_plugins', array($wpadmin, 'initBranding'));
62
  add_filter('plugin_row_meta', array($wpadmin, 'hidePluginDetails'), 10, 2);
82
  require_once dirname( __FILE__ ) . '/callback/request.php';
83
  require_once dirname( __FILE__ ) . '/recover.php';
84
 
85
+ $pubkey = WPEAccount::sanitizeKey($_REQUEST['pubkey']);
86
 
87
  if (array_key_exists('rcvracc', $_REQUEST)) {
88
  $account = WPERecover::find($bvsettings, $pubkey);