Duplicator – WordPress Migration Plugin - Version 1.4.7.2

Version Description

Download this release

Release Info

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

Code changes from version 1.4.7.1 to 1.4.7.2

classes/class.io.php CHANGED
@@ -21,7 +21,7 @@ class DUP_IO
21
  {
22
  if (file_exists($file)) {
23
  if (@unlink($file) === false) {
24
- DUP_Log::Info("Could not delete file: {$file}");
25
  return false;
26
  }
27
  }
@@ -89,4 +89,33 @@ class DUP_IO
89
 
90
  return copy($source_file, $dest_filepath);
91
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
21
  {
22
  if (file_exists($file)) {
23
  if (@unlink($file) === false) {
24
+ DUP_Log::Info("Duplicator could not delete file: '{$file}'");
25
  return false;
26
  }
27
  }
89
 
90
  return copy($source_file, $dest_filepath);
91
  }
92
+
93
+ /**
94
+ * Prepends data to an existing file
95
+ *
96
+ * @param string $file The full file path to the file
97
+ * @param string $content The content to prepend to the file
98
+ *
99
+ * @return TRUE on success or if file does not exist. FALSE on failure
100
+ */
101
+ public static function fwritePrepend($file, $prepend)
102
+ {
103
+ if (!file_exists($file) || !is_writable($file)) {
104
+ return false;
105
+ }
106
+
107
+ $handle = fopen($file, "r+");
108
+ $len = strlen($prepend);
109
+ $final_len = filesize($file) + $len;
110
+ $cache_old = fread($handle, $len);
111
+ rewind($handle);
112
+ $i = 1;
113
+ while (ftell($handle) < $final_len) {
114
+ fwrite($handle, $prepend);
115
+ $prepend = $cache_old;
116
+ $cache_old = fread($handle, $len);
117
+ fseek($handle, $i * $len);
118
+ $i++;
119
+ }
120
+ }
121
  }
classes/class.plugin.upgrade.php CHANGED
@@ -2,69 +2,69 @@
2
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
 
4
  /**
5
-
6
- * Upgrade logic of plugin resides here
7
-
8
  */
9
  class DUP_LITE_Plugin_Upgrade
10
  {
11
 
12
  const DUP_VERSION_OPT_KEY = 'duplicator_version_plugin';
13
 
 
 
 
 
 
14
  public static function onActivationAction()
15
  {
 
16
  if (($oldDupVersion = get_option(self::DUP_VERSION_OPT_KEY, false)) === false) {
17
  self::newInstallation();
18
  } else {
19
  self::updateInstallation($oldDupVersion);
20
  }
21
 
22
- //Setup All Directories
 
23
  DUP_Util::initSnapshotDirectory();
24
  }
25
 
 
 
 
 
 
26
  protected static function newInstallation()
27
  {
28
- self::updateDatabase();
29
-
30
  //WordPress Options Hooks
31
  update_option(self::DUP_VERSION_OPT_KEY, DUPLICATOR_VERSION);
32
  }
33
 
 
 
 
 
 
 
 
34
  protected static function updateInstallation($oldVersion)
35
  {
36
- self::updateDatabase();
37
-
38
  //PRE 1.3.35
39
  //Do not update to new wp-content storage till after
40
  if (version_compare($oldVersion, '1.3.35', '<')) {
41
  DUP_Settings::Set('storage_position', DUP_Settings::STORAGE_POSITION_LECAGY);
42
  DUP_Settings::Save();
43
  }
44
-
45
- //Run and secure updates
46
- self::secureLocalStorageDirectory($oldVersion);
47
 
48
  //WordPress Options Hooks
49
  update_option(self::DUP_VERSION_OPT_KEY, DUPLICATOR_VERSION);
50
  }
51
 
52
- protected static function secureLocalStorageDirectory($oldVersion) {
53
-
54
- //PRE 1.4.7
55
- //Remove the core dup-install file that might exist in local storage directory
56
- if (version_compare($oldVersion, '1.4.7', '<=')) {
57
- $ssdir = DUP_Settings::getSsdirPath();
58
- $dupInstallFile = "{$ssdir}/dup-installer/main.installer.php";
59
- if (file_exists($dupInstallFile) ) {
60
- @unlink("{$dupInstallFile}");
61
- }
62
- }
63
-
64
- //Always apply the htaccess to backup dir
65
- DUP_Util::setupBackupDirHtaccess();
66
- }
67
-
68
  protected static function updateDatabase()
69
  {
70
  global $wpdb;
2
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
 
4
  /**
5
+ * Upgrade/Install logic of plugin resides here
6
+ *
 
7
  */
8
  class DUP_LITE_Plugin_Upgrade
9
  {
10
 
11
  const DUP_VERSION_OPT_KEY = 'duplicator_version_plugin';
12
 
13
+ /**
14
+ * Called as part of WordPress register_activation_hook
15
+ *
16
+ * @return void
17
+ */
18
  public static function onActivationAction()
19
  {
20
+ //NEW VS UPDATE
21
  if (($oldDupVersion = get_option(self::DUP_VERSION_OPT_KEY, false)) === false) {
22
  self::newInstallation();
23
  } else {
24
  self::updateInstallation($oldDupVersion);
25
  }
26
 
27
+ //Initilize Backup Directories
28
+ self::updateDatabase();
29
  DUP_Util::initSnapshotDirectory();
30
  }
31
 
32
+ /**
33
+ * Runs only on new installs
34
+ *
35
+ * @return void
36
+ */
37
  protected static function newInstallation()
38
  {
 
 
39
  //WordPress Options Hooks
40
  update_option(self::DUP_VERSION_OPT_KEY, DUPLICATOR_VERSION);
41
  }
42
 
43
+ /**
44
+ * Run only on update installs
45
+ *
46
+ * @param string $oldVersion The last/previous installed version
47
+ *
48
+ * @return void
49
+ */
50
  protected static function updateInstallation($oldVersion)
51
  {
 
 
52
  //PRE 1.3.35
53
  //Do not update to new wp-content storage till after
54
  if (version_compare($oldVersion, '1.3.35', '<')) {
55
  DUP_Settings::Set('storage_position', DUP_Settings::STORAGE_POSITION_LECAGY);
56
  DUP_Settings::Save();
57
  }
 
 
 
58
 
59
  //WordPress Options Hooks
60
  update_option(self::DUP_VERSION_OPT_KEY, DUPLICATOR_VERSION);
61
  }
62
 
63
+ /**
64
+ * Runs for both new and update installs and creates the database tables
65
+ *
66
+ * @return void
67
+ */
 
 
 
 
 
 
 
 
 
 
 
68
  protected static function updateDatabase()
69
  {
70
  global $wpdb;
classes/package/class.pack.installer.php CHANGED
@@ -10,8 +10,8 @@ require_once(DUPLICATOR_PLUGIN_PATH.'/classes/class.password.php');
10
 
11
  class DUP_Installer
12
  {
13
-
14
- const DEFAULT_INSTALLER_FILE_NAME_WITHOUT_HASH = 'installer.php';
15
 
16
  //PUBLIC
17
  public $File;
@@ -84,7 +84,10 @@ class DUP_Installer
84
  {
85
  $success = true;
86
  $archive_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->Archive->File}";
87
- $installer_filepath = apply_filters('duplicator_installer_file_path', DUP_Settings::getSsdirTmpPath()."/{$this->Package->NameHash}_installer.php");
 
 
 
88
  $template_filepath = DUPLICATOR_PLUGIN_PATH.'/installer/installer.tpl';
89
  $mini_expander_filepath = DUPLICATOR_PLUGIN_PATH.'/lib/dup_archive/classes/class.duparchive.mini.expander.php';
90
 
@@ -149,7 +152,7 @@ class DUP_Installer
149
 
150
  //READ-ONLY: GENERAL
151
  // $ac->installer_base_name = $global->installer_base_name;
152
- $ac->installer_base_name = 'installer.php';
153
  $ac->installer_backup_name = $this->Package->NameHash.'_installer-backup.php';
154
  $ac->package_name = "{$this->Package->NameHash}_archive.{$extension}";
155
  $ac->package_hash = $this->Package->getPackageHash();
@@ -199,7 +202,10 @@ class DUP_Installer
199
  private function add_extra_files($package)
200
  {
201
  $success = false;
202
- $installer_filepath = apply_filters('duplicator_installer_file_path', DUP_Settings::getSsdirTmpPath()."/{$this->Package->NameHash}_installer.php");
 
 
 
203
  $scan_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->NameHash}_scan.json";
204
  $sql_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->Database->File}";
205
  $archive_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->Archive->File}";
10
 
11
  class DUP_Installer
12
  {
13
+ const INSTALLER_SERVER_EXTENSION = '.php.bak';
14
+ const DEFAULT_INSTALLER_FILE_NAME_WITHOUT_HASH = 'installer';
15
 
16
  //PUBLIC
17
  public $File;
84
  {
85
  $success = true;
86
  $archive_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->Archive->File}";
87
+ $installer_filepath = apply_filters(
88
+ 'duplicator_installer_file_path',
89
+ DUP_Settings::getSsdirTmpPath()."/{$this->Package->NameHash}_installer" . self::INSTALLER_SERVER_EXTENSION
90
+ );
91
  $template_filepath = DUPLICATOR_PLUGIN_PATH.'/installer/installer.tpl';
92
  $mini_expander_filepath = DUPLICATOR_PLUGIN_PATH.'/lib/dup_archive/classes/class.duparchive.mini.expander.php';
93
 
152
 
153
  //READ-ONLY: GENERAL
154
  // $ac->installer_base_name = $global->installer_base_name;
155
+ $ac->installer_base_name = 'installer' . self::INSTALLER_SERVER_EXTENSION;
156
  $ac->installer_backup_name = $this->Package->NameHash.'_installer-backup.php';
157
  $ac->package_name = "{$this->Package->NameHash}_archive.{$extension}";
158
  $ac->package_hash = $this->Package->getPackageHash();
202
  private function add_extra_files($package)
203
  {
204
  $success = false;
205
+ $installer_filepath = apply_filters(
206
+ 'duplicator_installer_file_path',
207
+ DUP_Settings::getSsdirTmpPath()."/{$this->Package->NameHash}_installer" . self::INSTALLER_SERVER_EXTENSION
208
+ );
209
  $scan_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->NameHash}_scan.json";
210
  $sql_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->Database->File}";
211
  $archive_filepath = DUP_Settings::getSsdirTmpPath()."/{$this->Package->Archive->File}";
classes/package/class.pack.php CHANGED
@@ -388,12 +388,15 @@ class DUP_Package
388
  {
389
  switch (DUP_Settings::Get('installer_name_mode')) {
390
  case DUP_Settings::INSTALLER_NAME_MODE_SIMPLE:
391
- return DUP_Installer::DEFAULT_INSTALLER_FILE_NAME_WITHOUT_HASH;
392
-
393
  case DUP_Settings::INSTALLER_NAME_MODE_WITH_HASH:
394
  default:
395
- return basename($this->getLocalPackageFile(DUP_PackageFileType::Installer));
 
396
  }
 
 
397
  }
398
 
399
  /**
@@ -420,7 +423,10 @@ class DUP_Package
420
 
421
  $this->Archive->Format = strtoupper($extension);
422
  $this->Archive->File = "{$this->NameHash}_archive.{$extension}";
423
- $this->Installer->File = apply_filters('duplicator_installer_file_path', "{$this->NameHash}_installer.php");
 
 
 
424
  $this->Database->File = "{$this->NameHash}_database.sql";
425
  $this->WPUser = isset($current_user->user_login) ? $current_user->user_login : 'unknown';
426
 
@@ -494,14 +500,14 @@ class DUP_Package
494
  //Perms
495
  @chmod($tmpPath."/{$archiveFile}", 0644);
496
  @chmod($tmpPath."/{$nameHash}_database.sql", 0644);
497
- @chmod($tmpPath."/{$nameHash}_installer.php", 0644);
498
  @chmod($tmpPath."/{$nameHash}_scan.json", 0644);
499
  @chmod($tmpPath."/{$wpConfigFile}", 0644);
500
  @chmod($tmpPath."/{$nameHash}.log", 0644);
501
 
502
  @chmod($ssdPath."/{$archiveFile}", 0644);
503
  @chmod($ssdPath."/{$nameHash}_database.sql", 0644);
504
- @chmod($ssdPath."/{$nameHash}_installer.php", 0644);
505
  @chmod($ssdPath."/{$nameHash}_scan.json", 0644);
506
  // In older version, The plugin was storing [HASH]_wp-config.txt in main storage area. The below line code is for backward compatibility
507
  @chmod($ssdPath."/{$wpConfigFile}", 0644);
@@ -509,14 +515,14 @@ class DUP_Package
509
  //Remove
510
  @unlink($tmpPath."/{$archiveFile}");
511
  @unlink($tmpPath."/{$nameHash}_database.sql");
512
- @unlink($tmpPath."/{$nameHash}_installer.php");
513
  @unlink($tmpPath."/{$nameHash}_scan.json");
514
  @unlink($tmpPath."/{$wpConfigFile}");
515
  @unlink($tmpPath."/{$nameHash}.log");
516
 
517
  @unlink($ssdPath."/{$archiveFile}");
518
  @unlink($ssdPath."/{$nameHash}_database.sql");
519
- @unlink($ssdPath."/{$nameHash}_installer.php");
520
  @unlink($ssdPath."/{$nameHash}_scan.json");
521
  // In older version, The plugin was storing [HASH]_wp-config.txt in main storage area. The below line code is for backward compatibility
522
  @unlink($ssdPath."/{$wpConfigFile}");
@@ -1052,7 +1058,7 @@ class DUP_Package
1052
 
1053
  public function getInstallerFilename()
1054
  {
1055
- return "{$this->NameHash}_installer.php";
1056
  }
1057
 
1058
  public function getDatabaseFilename()
388
  {
389
  switch (DUP_Settings::Get('installer_name_mode')) {
390
  case DUP_Settings::INSTALLER_NAME_MODE_SIMPLE:
391
+ $name = DUP_Installer::DEFAULT_INSTALLER_FILE_NAME_WITHOUT_HASH . DUP_Installer::INSTALLER_SERVER_EXTENSION;
392
+ break;
393
  case DUP_Settings::INSTALLER_NAME_MODE_WITH_HASH:
394
  default:
395
+ $name = basename($this->getLocalPackageFile(DUP_PackageFileType::Installer));
396
+ break;
397
  }
398
+ $info = pathinfo($name);
399
+ return $info['filename'];
400
  }
401
 
402
  /**
423
 
424
  $this->Archive->Format = strtoupper($extension);
425
  $this->Archive->File = "{$this->NameHash}_archive.{$extension}";
426
+ $this->Installer->File = apply_filters(
427
+ 'duplicator_installer_file_path',
428
+ "{$this->NameHash}_installer" . DUP_Installer::INSTALLER_SERVER_EXTENSION
429
+ );
430
  $this->Database->File = "{$this->NameHash}_database.sql";
431
  $this->WPUser = isset($current_user->user_login) ? $current_user->user_login : 'unknown';
432
 
500
  //Perms
501
  @chmod($tmpPath."/{$archiveFile}", 0644);
502
  @chmod($tmpPath."/{$nameHash}_database.sql", 0644);
503
+ @chmod($tmpPath."/{$nameHash}_installer" . DUP_Installer::INSTALLER_SERVER_EXTENSION, 0644);
504
  @chmod($tmpPath."/{$nameHash}_scan.json", 0644);
505
  @chmod($tmpPath."/{$wpConfigFile}", 0644);
506
  @chmod($tmpPath."/{$nameHash}.log", 0644);
507
 
508
  @chmod($ssdPath."/{$archiveFile}", 0644);
509
  @chmod($ssdPath."/{$nameHash}_database.sql", 0644);
510
+ @chmod($ssdPath."/{$nameHash}_installer" . DUP_Installer::INSTALLER_SERVER_EXTENSION, 0644);
511
  @chmod($ssdPath."/{$nameHash}_scan.json", 0644);
512
  // In older version, The plugin was storing [HASH]_wp-config.txt in main storage area. The below line code is for backward compatibility
513
  @chmod($ssdPath."/{$wpConfigFile}", 0644);
515
  //Remove
516
  @unlink($tmpPath."/{$archiveFile}");
517
  @unlink($tmpPath."/{$nameHash}_database.sql");
518
+ @unlink($tmpPath."/{$nameHash}_installer" . DUP_Installer::INSTALLER_SERVER_EXTENSION);
519
  @unlink($tmpPath."/{$nameHash}_scan.json");
520
  @unlink($tmpPath."/{$wpConfigFile}");
521
  @unlink($tmpPath."/{$nameHash}.log");
522
 
523
  @unlink($ssdPath."/{$archiveFile}");
524
  @unlink($ssdPath."/{$nameHash}_database.sql");
525
+ @unlink($ssdPath."/{$nameHash}_installer" . DUP_Installer::INSTALLER_SERVER_EXTENSION);
526
  @unlink($ssdPath."/{$nameHash}_scan.json");
527
  // In older version, The plugin was storing [HASH]_wp-config.txt in main storage area. The below line code is for backward compatibility
528
  @unlink($ssdPath."/{$wpConfigFile}");
1058
 
1059
  public function getInstallerFilename()
1060
  {
1061
+ return "{$this->NameHash}_installer" . DUP_Installer::INSTALLER_SERVER_EXTENSION;
1062
  }
1063
 
1064
  public function getDatabaseFilename()
classes/utilities/class.u.patch.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
+
4
+ /**
5
+ * Class used to apply various patches to installer file
6
+ *
7
+ * Standard: PSR-2
8
+ * @link http://www.php-fig.org/psr/psr-2
9
+ *
10
+ * @package Duplicator
11
+ * @subpackage classes
12
+ * @copyright (c) 2022, Snapcreek LLC
13
+ *
14
+ */
15
+ class DUP_Patch
16
+ {
17
+ /**
18
+ * The current backup directory path for Duplicator Lite
19
+ * Possible options are 'wp-snapshots' and 'backups-dup-lite'
20
+ */
21
+ public $DupLiteBackupDir;
22
+
23
+ /**
24
+ * Class construct for init
25
+ */
26
+ public function __construct() {
27
+ $this->DupLiteBackupDir = DUP_Settings::getSsdirPath();
28
+ }
29
+
30
+ /**
31
+ * Apply patch code to all installer files
32
+ */
33
+ public function ApplyInstallerPatch_0001()
34
+ {
35
+ $backupDir = $this->DupLiteBackupDir;
36
+
37
+ foreach (glob("{$backupDir}/*_installer" . DUP_Installer::INSTALLER_SERVER_EXTENSION) as $file) {
38
+ if (strstr($file, '_installer' . DUP_Installer::INSTALLER_SERVER_EXTENSION)) {
39
+ $content = "<?php \n";
40
+ $content .= " /** PATCH_MARKER_START:V.0001 **/ \n";
41
+ $content .= " //TODO ADD PHP CODE HERE";
42
+ $content .= " /** PATCH_MARKER_END **/ \n";
43
+ $content .= "?>\n";
44
+ DUP_IO::fwritePrepend($file, $content);
45
+ }
46
+ }
47
+ }
48
+ }
classes/utilities/class.u.php CHANGED
@@ -1,8 +1,10 @@
1
  <?php
2
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
 
 
 
4
  /**
5
- * Recursivly scans a directory and finds all sym-links and unreadable files
6
  *
7
  * Standard: PSR-2
8
  * @link http://www.php-fig.org/psr/psr-2
@@ -11,10 +13,13 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
11
  * @subpackage classes/utilities
12
  * @copyright (c) 2017, Snapcreek LLC
13
  *
14
- * @todo Refactor out IO methods into class.io.php file
15
  */
16
  class DUP_Util
17
  {
 
 
 
 
18
 
19
  /**
20
  * Is PHP 5.2.9 or better running
@@ -48,10 +53,10 @@ class DUP_Util
48
  */
49
  public static function init()
50
  {
51
- self::$on_php_529_plus = version_compare(PHP_VERSION, '5.2.9') >= 0;
52
- self::$on_php_53_plus = version_compare(PHP_VERSION, '5.3.0') >= 0;
53
- self::$on_php_54_plus = version_compare(PHP_VERSION, '5.4.0') >= 0;
54
- self::$PHP7_plus = version_compare(PHP_VERSION, '7.0.0', '>=');
55
  }
56
 
57
  public static function getArchitectureString()
@@ -474,9 +479,6 @@ class DUP_Util
474
  {
475
  return base64_encode($string);
476
  }
477
- const SECURE_ISSUE_DIE = 'die';
478
- const SECURE_ISSUE_THROW = 'throw';
479
- const SECURE_ISSUE_RETURN = 'return';
480
 
481
  /**
482
  * Does the current user have the capability
@@ -560,22 +562,23 @@ class DUP_Util
560
  */
561
  public static function initSnapshotDirectory()
562
  {
563
- $error = false;
564
-
565
  $path_wproot = duplicator_get_abs_path();
566
- $path_ssdir = DUP_Settings::getSsdirPath();
567
  $path_plugin = DUP_Util::safePath(DUPLICATOR_PLUGIN_PATH);
568
 
569
- if (!file_exists($path_ssdir)) {
 
 
 
570
  $old_root_perm = @fileperms($path_wproot);
571
 
572
- //--------------------------------
573
  //CHMOD DIRECTORY ACCESS
574
  //wordpress root directory
575
  DupLiteSnapLibIOU::chmod($path_wproot, 'u+rwx');
576
 
577
  //snapshot directory
578
- if (DupLiteSnapLibIOU::dirWriteCheckOrMkdir($path_ssdir, 'u+rwx,go+rx') == false) {
579
  $error = true;
580
  }
581
 
@@ -587,43 +590,16 @@ class DUP_Util
587
  }
588
  }
589
 
590
- DupLiteSnapLibIOU::chmod($path_ssdir, 'u+rwx,go+rx');
591
-
592
  DupLiteSnapLibIOU::dirWriteCheckOrMkdir(DUP_Settings::getSsdirTmpPath(), 'u+rwx');
593
 
594
- //plugins dir/files
595
- DupLiteSnapLibIOU::dirWriteCheckOrMkdir($path_plugin.'files', 'u+rwx');
596
-
597
  //--------------------------------
598
- //FILE CREATION
599
- //SSDIR: Create Index File
600
- $fileName = $path_ssdir.'/index.php';
601
- if (!file_exists($fileName)) {
602
- $ssfile = @fopen($fileName, 'w');
603
- @fwrite($ssfile,
604
- '<?php error_reporting(0); if (stristr(php_sapi_name(), "fcgi")) { $url = "http://" . $_SERVER["HTTP_HOST"]; header("Location: {$url}/404.html");} else { header("HTTP/1.1 404 Not Found", true, 404);} exit(); ?>');
605
- @fclose($ssfile);
606
- }
607
-
608
- //SSDIR: Create .htaccess file
609
- $storage_htaccess_off = DUP_Settings::Get('storage_htaccess_off');
610
- $fileName = $path_ssdir.'/.htaccess';
611
- if ($storage_htaccess_off) {
612
- @unlink($fileName);
613
- } else if (!file_exists($fileName)) {
614
- self::setupBackupDirHtaccess();
615
- }
616
-
617
- //SSDIR: Create Robots.txt file
618
- $fileName = $path_ssdir.'/robots.txt';
619
- if (!file_exists($fileName)) {
620
- $robotfile = @fopen($fileName, 'w');
621
- @fwrite($robotfile,
622
- "User-agent: * \n"
623
- ."Disallow: /".DUP_Settings::SSDIR_NAME_LEGACY."/\n"
624
- ."Disallow: /".DUP_Settings::SSDIR_NAME_NEW."/");
625
- @fclose($robotfile);
626
- }
627
 
628
  return true;
629
  }
@@ -633,21 +609,106 @@ class DUP_Util
633
  *
634
  * @return null
635
  */
636
- public static function setupBackupDirHtaccess()
637
  {
638
  try {
639
- $backupDirPath = DUP_Settings::getSsdirPath();
640
- $fileName = "{$backupDirPath}/.htaccess";
641
- $htfile = @fopen($fileName, 'w');
642
- $htoutput = "Options -Indexes \n";
643
- $htoutput .= "<Files *.php>\n deny from all\n</Files>";
644
- @fwrite($htfile, $htoutput);
645
- @fclose($htfile);
 
 
 
 
 
 
 
646
  } catch (Exception $ex) {
647
  DUP_Log::Info("Duplicator Error: Unable to properly configure .htaccess for servers storage directory {$fileName}" . $ex);
648
  }
649
  }
650
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
651
  /**
652
  * Attempts to get the file zip path on a users system
653
  *
1
  <?php
2
  defined('ABSPATH') || defined('DUPXABSPATH') || exit;
3
 
4
+ require_once(DUPLICATOR_PLUGIN_PATH . '/classes/class.io.php');
5
+
6
  /**
7
+ * Utility class used for helper type functions
8
  *
9
  * Standard: PSR-2
10
  * @link http://www.php-fig.org/psr/psr-2
13
  * @subpackage classes/utilities
14
  * @copyright (c) 2017, Snapcreek LLC
15
  *
 
16
  */
17
  class DUP_Util
18
  {
19
+
20
+ const SECURE_ISSUE_DIE = 'die';
21
+ const SECURE_ISSUE_THROW = 'throw';
22
+ const SECURE_ISSUE_RETURN = 'return';
23
 
24
  /**
25
  * Is PHP 5.2.9 or better running
53
  */
54
  public static function init()
55
  {
56
+ self::$on_php_529_plus = version_compare(PHP_VERSION, '5.2.9') >= 0;
57
+ self::$on_php_53_plus = version_compare(PHP_VERSION, '5.3.0') >= 0;
58
+ self::$on_php_54_plus = version_compare(PHP_VERSION, '5.4.0') >= 0;
59
+ self::$PHP7_plus = version_compare(PHP_VERSION, '7.0.0', '>=');
60
  }
61
 
62
  public static function getArchitectureString()
479
  {
480
  return base64_encode($string);
481
  }
 
 
 
482
 
483
  /**
484
  * Does the current user have the capability
562
  */
563
  public static function initSnapshotDirectory()
564
  {
565
+ $error = false;
 
566
  $path_wproot = duplicator_get_abs_path();
567
+ $backupsDir = DUP_Settings::getSsdirPath();
568
  $path_plugin = DUP_Util::safePath(DUPLICATOR_PLUGIN_PATH);
569
 
570
+ //--------------------------------
571
+ //DIRCTORY CREATION
572
+ //Seupt the main directory and tmp build dir
573
+ if (!file_exists($backupsDir)) {
574
  $old_root_perm = @fileperms($path_wproot);
575
 
 
576
  //CHMOD DIRECTORY ACCESS
577
  //wordpress root directory
578
  DupLiteSnapLibIOU::chmod($path_wproot, 'u+rwx');
579
 
580
  //snapshot directory
581
+ if (DupLiteSnapLibIOU::dirWriteCheckOrMkdir($backupsDir, 'u+rwx,go+rx') == false) {
582
  $error = true;
583
  }
584
 
590
  }
591
  }
592
 
593
+ DupLiteSnapLibIOU::chmod($backupsDir, 'u+rwx,go+rx');
 
594
  DupLiteSnapLibIOU::dirWriteCheckOrMkdir(DUP_Settings::getSsdirTmpPath(), 'u+rwx');
595
 
 
 
 
596
  //--------------------------------
597
+ //FILE CREATION & HARDEN PROCESS
598
+ //index.php, .htaccess, robots.txt
599
+ self::setupBackupDirIndexFile($backupsDir);
600
+ self::setupBackupDirRobotsFile($backupsDir);
601
+ self::setupBackupDirHtaccess($backupsDir);
602
+ self::performHardenProcesses($backupsDir);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
603
 
604
  return true;
605
  }
609
  *
610
  * @return null
611
  */
612
+ public static function setupBackupDirHtaccess($backupsDir)
613
  {
614
  try {
615
+ $storageHtaccessOff = DUP_Settings::Get('storage_htaccess_off');
616
+ $fileName = "{$backupsDir}/.htaccess";
617
+
618
+ if ($storageHtaccessOff) {
619
+ @unlink($fileName);
620
+ } else if (!file_exists($fileName) || @filesize($fileName) == 0) {
621
+ $htfile = @fopen($fileName, 'w');
622
+ $htoutput = "Options -Indexes \n";
623
+ $htoutput .= "<Files *.php>\n deny from all\n</Files>";
624
+ if ($htfile !== false) {
625
+ @fwrite($htfile, $htoutput);
626
+ @fclose($htfile);
627
+ }
628
+ }
629
  } catch (Exception $ex) {
630
  DUP_Log::Info("Duplicator Error: Unable to properly configure .htaccess for servers storage directory {$fileName}" . $ex);
631
  }
632
  }
633
 
634
+ /**
635
+ * Attempts to create an index.php file in the backups directory
636
+ *
637
+ * @return null
638
+ */
639
+ public static function setupBackupDirIndexFile($backupsDir)
640
+ {
641
+ try {
642
+ $fileName = "{$backupsDir}/index.php";
643
+ if (!file_exists($fileName)) {
644
+ $ssfile = @fopen($fileName, 'w');
645
+ if ($ssfile !== false) {
646
+ @fwrite($ssfile,
647
+ '<?php error_reporting(0); if (stristr(php_sapi_name(), "fcgi")) { $url = "http://" . $_SERVER["HTTP_HOST"]; '
648
+ . 'header("Location: {$url}/404.html");} else { header("HTTP/1.1 404 Not Found", true, 404);} exit(); ?>');
649
+ @fclose($ssfile);
650
+ }
651
+ }
652
+ } catch (Exception $ex) {
653
+ DUP_Log::Info("Duplicator Error: Unable to properly configure index.php for servers storage directory {$fileName}" . $ex);
654
+ }
655
+ }
656
+
657
+ /**
658
+ * Attempts to create a robots.txt file in the backups directory
659
+ * to prevent search engines
660
+ *
661
+ * @return null
662
+ */
663
+ public static function setupBackupDirRobotsFile($backupsDir)
664
+ {
665
+ try {
666
+ $fileName = "{$backupsDir}/robots.txt";
667
+ if (!file_exists($fileName)) {
668
+ $robotfile = @fopen($fileName, 'w');
669
+ if ($robotfile !== false) {
670
+ @fwrite($robotfile,
671
+ "User-agent: * \n"
672
+ ."Disallow: /".DUP_Settings::SSDIR_NAME_LEGACY."/\n"
673
+ ."Disallow: /".DUP_Settings::SSDIR_NAME_NEW."/");
674
+ @fclose($robotfile);
675
+ }
676
+ }
677
+ } catch (Exception $ex) {
678
+ DUP_Log::Info("Duplicator Error: Unable to properly configure tobots.txt for servers storage directory {$fileName}" . $ex);
679
+ }
680
+ }
681
+
682
+ /**
683
+ * Run various secure processes to harden the backups dir
684
+ *
685
+ * @return null
686
+ */
687
+ public static function performHardenProcesses($backupsDir)
688
+ {
689
+ //Edge Case: Remove any dup-installer/main.installer.php
690
+ $dupInstallFile = "{$backupsDir}/dup-installer/main.installer.php";
691
+ if (file_exists($dupInstallFile) ) {
692
+ DupLiteSnapLibIOU::chmod($dupInstallFile, "a+w");
693
+ DUP_IO::deleteFile("{$dupInstallFile}");
694
+ }
695
+
696
+ //Rename installer php files to .bak
697
+ DupLiteSnapLibIOU::regexGlobCallback(
698
+ $backupsDir,
699
+ function ($path) {
700
+ $parts = pathinfo($path);
701
+ $newPath = $parts['dirname'] . '/' . $parts['filename'] . DUP_Installer::INSTALLER_SERVER_EXTENSION;
702
+ DupLiteSnapLibIOU::rename($path, $newPath);
703
+ },
704
+ array(
705
+ 'regexFile' => '/^.+_installer.*\.php$/',
706
+ 'regexFolder' => false,
707
+ 'recursive' => true,
708
+ )
709
+ );
710
+ }
711
+
712
  /**
713
  * Attempts to get the file zip path on a users system
714
  *
ctrls/class.web.services.php CHANGED
@@ -122,12 +122,18 @@ class DUP_Web_Services
122
  throw new Exception(__("Invalid request."));
123
  }
124
 
125
- $fileName = $package->getInstDownloadName();
126
- $filepath = DUP_Settings::getSsdirPath().'/'.$package->Installer->File;
 
 
 
 
 
 
127
 
128
  // Process download
129
  if (!file_exists($filepath)) {
130
- throw new Exception(__("Invalid request."));
131
  }
132
 
133
  // Clean output buffer
122
  throw new Exception(__("Invalid request."));
123
  }
124
 
125
+ $fileName = $package->getInstDownloadName();
126
+ $realFileName = $package->Installer->File;
127
+ $backupDir = DUP_Settings::getSsdirPath();
128
+
129
+ if(DUP_STR::endsWith($realFileName, '.php')) {
130
+ $realFileName = basename($realFileName, '.php').DUP_Installer::INSTALLER_SERVER_EXTENSION;
131
+ }
132
+ $filepath = "{$backupDir}/{$realFileName}";
133
 
134
  // Process download
135
  if (!file_exists($filepath)) {
136
+ throw new Exception(__("INVALID REQUEST: File not found, please check the backup folder for file."));
137
  }
138
 
139
  // Clean output buffer
define.php CHANGED
@@ -5,8 +5,8 @@ defined('ABSPATH') || defined('DUPXABSPATH') || exit;
5
 
6
  if (function_exists('plugin_dir_url'))
7
  {
8
- define('DUPLICATOR_VERSION', '1.4.7.1');
9
- define('DUPLICATOR_VERSION_BUILD', '2022-08-02_15:00');
10
  define('DUPLICATOR_PLUGIN_URL', plugin_dir_url(__FILE__));
11
  define('DUPLICATOR_SITE_URL', get_site_url());
12
 
5
 
6
  if (function_exists('plugin_dir_url'))
7
  {
8
+ define('DUPLICATOR_VERSION', '1.4.7.2');
9
+ define('DUPLICATOR_VERSION_BUILD', '2022-08-15_11:00');
10
  define('DUPLICATOR_PLUGIN_URL', plugin_dir_url(__FILE__));
11
  define('DUPLICATOR_SITE_URL', get_site_url());
12
 
duplicator.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Duplicator
4
  Plugin URI: https://snapcreek.com/duplicator/duplicator-free/
5
  Description: Migrate and backup a copy of your WordPress files and database. Duplicate and move a site from one location to another quickly.
6
- Version: 1.4.7.1
7
  Requires at least: 4.0
8
  Tested up to: 6.0
9
  Requires PHP: 5.3.8
3
  Plugin Name: Duplicator
4
  Plugin URI: https://snapcreek.com/duplicator/duplicator-free/
5
  Description: Migrate and backup a copy of your WordPress files and database. Duplicate and move a site from one location to another quickly.
6
+ Version: 1.4.7.2
7
  Requires at least: 4.0
8
  Tested up to: 6.0
9
  Requires PHP: 5.3.8
lib/snaplib/class.snaplib.u.io.php CHANGED
@@ -367,7 +367,7 @@ if (!class_exists('DupLiteSnapLibIOU', false)) {
367
  /**
368
  *
369
  * @param resource $handle
370
- * @param srtring $string
371
  * @return int
372
  * @throws Exception
373
  */
367
  /**
368
  *
369
  * @param resource $handle
370
+ * @param string $string
371
  * @return int
372
  * @throws Exception
373
  */
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: migration, backup, duplicate, move, migrate, restore, transfer, clone, aut
4
  Requires at least: 4.0
5
  Tested up to: 6.0
6
  Requires PHP: 5.3.8
7
- Stable tag: 1.4.7.1
8
  License: GPLv2
9
 
10
  WordPress migration and backups are much easier with Duplicator! Clone, backup, move and transfer an entire site from one location to another.
4
  Requires at least: 4.0
5
  Tested up to: 6.0
6
  Requires PHP: 5.3.8
7
+ Stable tag: 1.4.7.2
8
  License: GPLv2
9
 
10
  WordPress migration and backups are much easier with Duplicator! Clone, backup, move and transfer an entire site from one location to another.
uninstall.php CHANGED
@@ -21,6 +21,7 @@ require_once 'lib/snaplib/snaplib.all.php';
21
  require_once 'classes/class.settings.php';
22
  require_once 'classes/utilities/class.u.php';
23
  require_once 'classes/class.plugin.upgrade.php';
 
24
 
25
  global $wpdb;
26
  DUP_Settings::init();
@@ -48,8 +49,8 @@ if (DUP_Settings::Get('uninstall_files')) {
48
  if (strstr($file, '_database.sql'))
49
  @unlink("{$file}");
50
  }
51
- foreach (glob("{$ssdir}/*_installer.php") as $file) {
52
- if (strstr($file, '_installer.php'))
53
  @unlink("{$file}");
54
  }
55
  foreach (glob("{$ssdir}/*_archive.zip*") as $file) {
21
  require_once 'classes/class.settings.php';
22
  require_once 'classes/utilities/class.u.php';
23
  require_once 'classes/class.plugin.upgrade.php';
24
+ require_once 'classes/package/class.pack.installer.php';
25
 
26
  global $wpdb;
27
  DUP_Settings::init();
49
  if (strstr($file, '_database.sql'))
50
  @unlink("{$file}");
51
  }
52
+ foreach (glob("{$ssdir}/*_installer" . DUP_Installer::INSTALLER_SERVER_EXTENSION) as $file) {
53
+ if (strstr($file, '_installer' . DUP_Installer::INSTALLER_SERVER_EXTENSION))
54
  @unlink("{$file}");
55
  }
56
  foreach (glob("{$ssdir}/*_archive.zip*") as $file) {
views/packages/details/detail.php CHANGED
@@ -169,14 +169,18 @@ GENERAL -->
169
  </tr>
170
  <tr>
171
  <td><?php esc_html_e('Installer', 'duplicator') ?>: </td>
172
- <td><a href="#" onclick="Duplicator.Pack.DownloadInstaller(<?php echo $installerDownloadInfoJson; ?>);return false;" ><?php echo esc_html($package->Installer->File) ?></a></td>
 
 
 
 
173
  </tr>
174
  <tr>
175
  <td><?php esc_html_e("Build Log", 'duplicator') ?>: </td>
176
  <td><a href="<?php echo $logDownloadInfo["url"] ?>" target="file_results"><?php echo $logDownloadInfo["filename"]; ?></a></td>
177
  </tr>
178
  <tr>
179
- <td class="sub-notes">
180
  <i class="fas fa-download"></i> <?php _e("Click links to download", 'duplicator-pro') ?>
181
  </td>
182
  </tr>
169
  </tr>
170
  <tr>
171
  <td><?php esc_html_e('Installer', 'duplicator') ?>: </td>
172
+ <td>
173
+ <a href="#" onclick="Duplicator.Pack.DownloadInstaller(<?php echo $installerDownloadInfoJson; ?>);return false;" >
174
+ <?php echo esc_html(rtrim($package->Installer->File, '.bak')) ?>
175
+ </a>
176
+ </td>
177
  </tr>
178
  <tr>
179
  <td><?php esc_html_e("Build Log", 'duplicator') ?>: </td>
180
  <td><a href="<?php echo $logDownloadInfo["url"] ?>" target="file_results"><?php echo $logDownloadInfo["filename"]; ?></a></td>
181
  </tr>
182
  <tr>
183
+ <td class="sub-notes" colspan="2">
184
  <i class="fas fa-download"></i> <?php _e("Click links to download", 'duplicator-pro') ?>
185
  </td>
186
  </tr>
views/packages/main/s3.build.php CHANGED
@@ -189,9 +189,10 @@ TOOL BAR:STEPS -->
189
  </sup>
190
  </div>
191
  <div style="margin-top:20px; font-size:11px">
192
- <span id="dup-click-to-copy-installer-name"
193
- class="link-style no-decoration"
194
- data-dup-copy-text="<?php echo esc_attr(DUP_Installer::DEFAULT_INSTALLER_FILE_NAME_WITHOUT_HASH); ?>">
 
195
  <?php esc_html_e("[Copy Installer Name to Clipboard]", 'duplicator'); ?>
196
  <i class="far fa-copy"></i>
197
  </span><br/>
189
  </sup>
190
  </div>
191
  <div style="margin-top:20px; font-size:11px">
192
+ <span
193
+ id="dup-click-to-copy-installer-name"
194
+ class="link-style no-decoration"
195
+ data-dup-copy-text="<?php echo DUP_Installer::DEFAULT_INSTALLER_FILE_NAME_WITHOUT_HASH . DUP_Installer::INSTALLER_SERVER_EXTENSION; ?>">
196
  <?php esc_html_e("[Copy Installer Name to Clipboard]", 'duplicator'); ?>
197
  <i class="far fa-copy"></i>
198
  </span><br/>
views/settings/packages.php CHANGED
@@ -286,16 +286,19 @@ $installerNameMode = DUP_Settings::Get('installer_name_mode');
286
  <td id="installer-name-mode-option" >
287
  <b><?php esc_html_e("Default 'Save as' name:", 'duplicator'); ?></b> <br/>
288
  <label>
289
- <i class='fas fa-lock lock-info'></i><input type="radio" name="installer_name_mode"
290
- value="<?php echo DUP_Settings::INSTALLER_NAME_MODE_WITH_HASH; ?>"
291
- <?php checked($installerNameMode === DUP_Settings::INSTALLER_NAME_MODE_WITH_HASH); ?> />
 
292
  [name]_[hash]_[date]_installer.php <i>(<?php esc_html_e("recommended", 'duplicator'); ?>)</i>
293
  </label><br>
294
  <label>
295
- <i class='fas fa-lock-open lock-info'></i><input type="radio" name="installer_name_mode"
296
- value="<?php echo DUP_Settings::INSTALLER_NAME_MODE_SIMPLE; ?>"
297
- <?php checked($installerNameMode === DUP_Settings::INSTALLER_NAME_MODE_SIMPLE); ?> />
298
- <?php echo DUP_Installer::DEFAULT_INSTALLER_FILE_NAME_WITHOUT_HASH; ?>
 
 
299
  </label>
300
  <p class="description">
301
  <?php esc_html_e("To understand the importance and usage of the installer name, please", 'duplicator') ?>
286
  <td id="installer-name-mode-option" >
287
  <b><?php esc_html_e("Default 'Save as' name:", 'duplicator'); ?></b> <br/>
288
  <label>
289
+ <i class='fas fa-lock lock-info'></i>
290
+ <input type="radio" name="installer_name_mode"
291
+ value="<?php echo DUP_Settings::INSTALLER_NAME_MODE_WITH_HASH; ?>"
292
+ <?php checked($installerNameMode === DUP_Settings::INSTALLER_NAME_MODE_WITH_HASH); ?> />
293
  [name]_[hash]_[date]_installer.php <i>(<?php esc_html_e("recommended", 'duplicator'); ?>)</i>
294
  </label><br>
295
  <label>
296
+ <i class='fas fa-lock-open lock-info'></i>
297
+ <input type="radio" name="installer_name_mode"
298
+ value="<?php echo DUP_Settings::INSTALLER_NAME_MODE_SIMPLE; ?>"
299
+ <?php checked($installerNameMode === DUP_Settings::INSTALLER_NAME_MODE_SIMPLE); ?>
300
+ >
301
+ <?php echo DUP_Installer::DEFAULT_INSTALLER_FILE_NAME_WITHOUT_HASH . DUP_Installer::INSTALLER_SERVER_EXTENSION; ?>
302
  </label>
303
  <p class="description">
304
  <?php esc_html_e("To understand the importance and usage of the installer name, please", 'duplicator') ?>