Duplicator – WordPress Migration Plugin - Version 1.2.4

Version Description

Download this release

Release Info

Developer cory@lamle.org
Plugin Icon 128x128 Duplicator – WordPress Migration Plugin
Version 1.2.4
Comparing to
See all releases

Code changes from version 1.2.2 to 1.2.4

classes/package/class.pack.php CHANGED
@@ -413,12 +413,17 @@ class DUP_Package
413
 
414
  /**
415
  * Makes the hashkey for the package files
 
416
  *
417
  * @return string Returns a unique hashkey
418
  */
419
  public function makeHash()
420
  {
421
- return uniqid().mt_rand(1000, 9999).date("ymdHis");
 
 
 
 
422
  }
423
 
424
  /**
413
 
414
  /**
415
  * Makes the hashkey for the package files
416
+ * Rare cases will need to fall back to GUID
417
  *
418
  * @return string Returns a unique hashkey
419
  */
420
  public function makeHash()
421
  {
422
+ if (function_exists('random_bytes')) {
423
+ return bin2hex(random_bytes(8)).mt_rand(1000, 9999).date("ymdHis");
424
+ } else {
425
+ return DUP_Util::GUIDv4();
426
+ }
427
  }
428
 
429
  /**
classes/utilities/class.u.php CHANGED
@@ -475,6 +475,65 @@ class DUP_Util
475
 
476
  return $filepath;
477
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478
  }
479
  DUP_Util::init();
480
  ?>
475
 
476
  return $filepath;
477
  }
478
+
479
+
480
+ /**
481
+ * Returns a GUIDv4 string
482
+ *
483
+ * Uses the best cryptographically secure method
484
+ * for all supported pltforms with fallback to an older,
485
+ * less secure version.
486
+ *
487
+ * @param bool $trim Trim '}{' curly
488
+ * @param bool $nodash Remove the dashes from the GUID
489
+ * @param bool $grail Add a 'G' to the end for status
490
+ *
491
+ * @return string
492
+ */
493
+ public static function GUIDv4($trim = true, $nodash = true, $gtrail = true)
494
+ {
495
+ // Windows
496
+ if (function_exists('com_create_guid') === true) {
497
+ if ($trim === true) {
498
+ $guidv4 = trim(com_create_guid(), '{}');
499
+ } else {
500
+ $guidv4 = com_create_guid();
501
+ }
502
+
503
+ //Linux
504
+ } elseif (function_exists('openssl_random_pseudo_bytes') === true) {
505
+ $data = openssl_random_pseudo_bytes(16);
506
+ $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
507
+ $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
508
+ $guidv4 = vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
509
+
510
+ // Fallback (PHP 4.2+)
511
+ } else {
512
+
513
+ mt_srand((double) microtime() * 10000);
514
+ $charid = strtolower(md5(uniqid(rand(), true)));
515
+ $hyphen = chr(45); // "-"
516
+ $lbrace = $trim ? "" : chr(123); // "{"
517
+ $rbrace = $trim ? "" : chr(125); // "}"
518
+ $guidv4 = $lbrace.
519
+ substr($charid, 0, 8).$hyphen.
520
+ substr($charid, 8, 4).$hyphen.
521
+ substr($charid, 12, 4).$hyphen.
522
+ substr($charid, 16, 4).$hyphen.
523
+ substr($charid, 20, 12).
524
+ $rbrace;
525
+ }
526
+
527
+ if ($nodash) {
528
+ $guidv4 = str_replace('-', '', $guidv4);
529
+ }
530
+
531
+ if ($gtrail) {
532
+ $guidv4 = $guidv4.'G';
533
+ }
534
+
535
+ return $guidv4;
536
+ }
537
  }
538
  DUP_Util::init();
539
  ?>
define.php CHANGED
@@ -2,7 +2,7 @@
2
  //Prevent directly browsing to the file
3
  if (function_exists('plugin_dir_url'))
4
  {
5
- define('DUPLICATOR_VERSION', '1.2.2');
6
  define('DUPLICATOR_HOMEPAGE', 'http://lifeinthegrid.com/labs/duplicator');
7
  define('DUPLICATOR_PLUGIN_URL', plugin_dir_url(__FILE__));
8
  define('DUPLICATOR_SITE_URL', get_site_url());
2
  //Prevent directly browsing to the file
3
  if (function_exists('plugin_dir_url'))
4
  {
5
+ define('DUPLICATOR_VERSION', '1.2.4');
6
  define('DUPLICATOR_HOMEPAGE', 'http://lifeinthegrid.com/labs/duplicator');
7
  define('DUPLICATOR_PLUGIN_URL', plugin_dir_url(__FILE__));
8
  define('DUPLICATOR_SITE_URL', get_site_url());
duplicator.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Duplicator
4
  Plugin URI: http://www.lifeinthegrid.com/duplicator/
5
  Description: Create and transfer a copy of your WordPress files and database. Duplicate and move a site from one location to another quickly.
6
- Version: 1.2.2
7
  Author: Snap Creek
8
  Author URI: http://www.snapcreek.com/duplicator/
9
  Text Domain: duplicator
3
  Plugin Name: Duplicator
4
  Plugin URI: http://www.lifeinthegrid.com/duplicator/
5
  Description: Create and transfer a copy of your WordPress files and database. Duplicate and move a site from one location to another quickly.
6
+ Version: 1.2.4
7
  Author: Snap Creek
8
  Author URI: http://www.snapcreek.com/duplicator/
9
  Text Domain: duplicator
installer/build/classes/class.engine.php CHANGED
@@ -22,7 +22,7 @@ class DUPX_UpdateEngine
22
  public static function logErrors($report)
23
  {
24
  if (!empty($report['errsql'])) {
25
- DUPX_Log::info("====================================");
26
  DUPX_Log::info("DATA-REPLACE ERRORS (MySQL)");
27
  foreach ($report['errsql'] as $error) {
28
  DUPX_Log::info($error);
@@ -30,7 +30,7 @@ class DUPX_UpdateEngine
30
  DUPX_Log::info("");
31
  }
32
  if (!empty($report['errser'])) {
33
- DUPX_Log::info("====================================");
34
  DUPX_Log::info("DATA-REPLACE ERRORS (Serialization):");
35
  foreach ($report['errser'] as $error) {
36
  DUPX_Log::info($error);
@@ -38,7 +38,7 @@ class DUPX_UpdateEngine
38
  DUPX_Log::info("");
39
  }
40
  if (!empty($report['errkey'])) {
41
- DUPX_Log::info("====================================");
42
  DUPX_Log::info("DATA-REPLACE ERRORS (Key):");
43
  DUPX_Log::info('Use SQL: SELECT @row := @row + 1 as row, t.* FROM some_table t, (SELECT @row := 0) r');
44
  foreach ($report['errkey'] as $error) {
22
  public static function logErrors($report)
23
  {
24
  if (!empty($report['errsql'])) {
25
+ DUPX_Log::info("--------------------------------------");
26
  DUPX_Log::info("DATA-REPLACE ERRORS (MySQL)");
27
  foreach ($report['errsql'] as $error) {
28
  DUPX_Log::info($error);
30
  DUPX_Log::info("");
31
  }
32
  if (!empty($report['errser'])) {
33
+ DUPX_Log::info("--------------------------------------");
34
  DUPX_Log::info("DATA-REPLACE ERRORS (Serialization):");
35
  foreach ($report['errser'] as $error) {
36
  DUPX_Log::info($error);
38
  DUPX_Log::info("");
39
  }
40
  if (!empty($report['errkey'])) {
41
+ DUPX_Log::info("--------------------------------------");
42
  DUPX_Log::info("DATA-REPLACE ERRORS (Key):");
43
  DUPX_Log::info('Use SQL: SELECT @row := @row + 1 as row, t.* FROM some_table t, (SELECT @row := 0) r');
44
  foreach ($report['errkey'] as $error) {
installer/build/ctrls/ctrl.step3.php CHANGED
@@ -129,17 +129,30 @@ if ($_POST['postguid']) {
129
  DUPX_Log::info("Reverted '{$update_guid}' post guid columns back to '{$_POST['url_old']}'");
130
  }
131
 
132
- /* FINAL UPDATES: Must happen after the global replace to prevent double pathing
133
  http://xyz.com/abc01 will become http://xyz.com/abc0101 with trailing data */
134
  mysqli_query($dbh, "UPDATE `{$GLOBALS['FW_TABLEPREFIX']}options` SET option_value = '{$_POST['url_new']}' WHERE option_name = 'home' ");
135
  mysqli_query($dbh, "UPDATE `{$GLOBALS['FW_TABLEPREFIX']}options` SET option_value = '{$_POST['siteurl']}' WHERE option_name = 'siteurl' ");
136
 
 
 
 
 
 
 
 
 
 
 
137
 
138
- //====================================================================================================
139
- //FINAL CLEANUP
140
- //====================================================================================================
 
 
141
  DUPX_Log::info("\n====================================");
142
- DUPX_Log::info('START FINAL CLEANUP: ');
 
143
 
144
  /** CREATE NEW USER LOGIC */
145
  if (strlen($_POST['wp_username']) >= 4 && strlen($_POST['wp_password']) >= 6) {
@@ -205,19 +218,15 @@ if ($mu_updates) {
205
  }
206
 
207
 
208
- /** ==============================
209
- * UPDATE WP-CONFIG FILE */
210
- DUPX_WPConfig::updateStandard();
211
- $config_file = DUPX_WPConfig::updateExtended();
212
- DUPX_Log::info("\nUPDATED WP-CONFIG: {$root_path}/wp-config.php' (if present)");
213
-
214
  //Create snapshots directory in order to
215
  //compensate for permissions on some servers
216
  if (!file_exists(DUPLICATOR_SSDIR_NAME)) {
217
  mkdir(DUPLICATOR_SSDIR_NAME, 0755);
 
218
  }
219
  $fp = fopen(DUPLICATOR_SSDIR_NAME . '/index.php', 'w');
220
  fclose($fp);
 
221
 
222
 
223
 
@@ -260,8 +269,7 @@ $JSON['step3']['warn_all'] = empty($JSON['step3']['warnlist']) ? 0 : count($JSON
260
 
261
  mysqli_close($dbh);
262
 
263
- //CONFIG Setup
264
- DUPX_ServerConfig::setup();
265
 
266
  $ajax2_end = DUPX_U::getMicrotime();
267
  $ajax2_sum = DUPX_U::elapsedTime($ajax2_end, $ajax2_start);
129
  DUPX_Log::info("Reverted '{$update_guid}' post guid columns back to '{$_POST['url_old']}'");
130
  }
131
 
132
+ /** FINAL UPDATES: Must happen after the global replace to prevent double pathing
133
  http://xyz.com/abc01 will become http://xyz.com/abc0101 with trailing data */
134
  mysqli_query($dbh, "UPDATE `{$GLOBALS['FW_TABLEPREFIX']}options` SET option_value = '{$_POST['url_new']}' WHERE option_name = 'home' ");
135
  mysqli_query($dbh, "UPDATE `{$GLOBALS['FW_TABLEPREFIX']}options` SET option_value = '{$_POST['siteurl']}' WHERE option_name = 'siteurl' ");
136
 
137
+ //===============================================
138
+ //CONFIGURATION FILE UPDATES
139
+ //===============================================
140
+ DUPX_Log::info("\n====================================");
141
+ DUPX_Log::info('CONFIGURATION FILE UPDATES:');
142
+ DUPX_Log::info("====================================\n");
143
+ DUPX_WPConfig::updateStandard();
144
+ $config_file = DUPX_WPConfig::updateExtended();
145
+ DUPX_Log::info("UPDATED WP-CONFIG: {$root_path}/wp-config.php' (if present)");
146
+ DUPX_ServerConfig::setup();
147
 
148
+
149
+
150
+ //===============================================
151
+ //GENERAL UPDATES & CLEANUP
152
+ //===============================================
153
  DUPX_Log::info("\n====================================");
154
+ DUPX_Log::info('GENERAL UPDATES & CLEANUP:');
155
+ DUPX_Log::info("====================================\n");
156
 
157
  /** CREATE NEW USER LOGIC */
158
  if (strlen($_POST['wp_username']) >= 4 && strlen($_POST['wp_password']) >= 6) {
218
  }
219
 
220
 
 
 
 
 
 
 
221
  //Create snapshots directory in order to
222
  //compensate for permissions on some servers
223
  if (!file_exists(DUPLICATOR_SSDIR_NAME)) {
224
  mkdir(DUPLICATOR_SSDIR_NAME, 0755);
225
+ DUPX_Log::info("- Created directory ". DUPLICATOR_SSDIR_NAME);
226
  }
227
  $fp = fopen(DUPLICATOR_SSDIR_NAME . '/index.php', 'w');
228
  fclose($fp);
229
+ DUPX_Log::info("- Created file ". DUPLICATOR_SSDIR_NAME . '/index.php');
230
 
231
 
232
 
269
 
270
  mysqli_close($dbh);
271
 
272
+
 
273
 
274
  $ajax2_end = DUPX_U::getMicrotime();
275
  $ajax2_sum = DUPX_U::elapsedTime($ajax2_end, $ajax2_start);
installer/build/main.installer.php CHANGED
@@ -171,17 +171,28 @@ if ($_POST['action_step'] == 1 && ! isset($_GET['help'])) {
171
  @@CLASS.ENGINE.PHP@@
172
  @@CLASS.CONF.WP.PHP@@
173
  @@CLASS.CONF.SRV.PHP@@
174
- <?php if (isset($_POST['action_ajax'])) :?>
175
- <?php switch ($_POST['action_ajax']): ?>
176
- <?php case "1": ?>@@CTRL.STEP1.PHP@@<?php break;?>
177
- <?php case "2": ?>@@CTRL.STEP2.PHP@@<?php break;?>
178
- <?php case "3": ?>@@CTRL.STEP3.PHP@@<?php break;?>
179
- <?php endswitch ?>
180
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  @fclose($GLOBALS["LOG_FILE_HANDLE"]);
182
  die("");
 
 
183
  ?>
184
- <?php endif; ?>
185
 
186
 
187
  <!DOCTYPE html>
171
  @@CLASS.ENGINE.PHP@@
172
  @@CLASS.CONF.WP.PHP@@
173
  @@CLASS.CONF.SRV.PHP@@
 
 
 
 
 
 
174
  <?php
175
+ if (isset($_POST['action_ajax'])) :
176
+
177
+ //Alternative control switch structer will not work in this case
178
+ //see: http://php.net/manual/en/control-structures.alternative-syntax.php
179
+ //Some clients will create double spaces such as the FTP client which
180
+ //will break example found online
181
+ switch ($_POST['action_ajax']) :
182
+
183
+ case "1": ?>@@CTRL.STEP1.PHP@@<?php break;
184
+
185
+ case "2": ?>@@CTRL.STEP2.PHP@@<?php break;
186
+
187
+ case "3": ?>@@CTRL.STEP3.PHP@@<?php break;
188
+
189
+ endswitch;
190
+
191
  @fclose($GLOBALS["LOG_FILE_HANDLE"]);
192
  die("");
193
+
194
+ endif;
195
  ?>
 
196
 
197
 
198
  <!DOCTYPE html>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: www.lifeinthegrid.com/partner
4
  Tags: backup, restore, move, migrate, localhost, synchronize, duplicate, clone, automate, niche site
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
- Stable tag: 1.2.2
8
  License: GPLv2
9
 
10
  Duplicate, clone, backup, move and transfer an entire site from one location to another.
4
  Tags: backup, restore, move, migrate, localhost, synchronize, duplicate, clone, automate, niche site
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
+ Stable tag: 1.2.4
8
  License: GPLv2
9
 
10
  Duplicate, clone, backup, move and transfer an entire site from one location to another.
views/packages/main/packages.php CHANGED
@@ -38,7 +38,7 @@
38
 
39
  <form id="form-duplicator" method="post">
40
 
41
- <?php if($statusCount >= 2) : ?>
42
  <div style="font-size:14px; position: absolute; top:15px; right:25px">
43
  <a href="admin.php?page=duplicator-about" style="color:#448B6C"><i><i class="fa fa-handshake-o"></i> <?php _e("Help Promote Duplicator", 'duplicator') ?></i> </a>
44
  </div>
38
 
39
  <form id="form-duplicator" method="post">
40
 
41
+ <?php if($statusCount >= 1) : ?>
42
  <div style="font-size:14px; position: absolute; top:15px; right:25px">
43
  <a href="admin.php?page=duplicator-about" style="color:#448B6C"><i><i class="fa fa-handshake-o"></i> <?php _e("Help Promote Duplicator", 'duplicator') ?></i> </a>
44
  </div>