Backup Migration - Version 1.1.3

Version Description

  • Fixed PHP CLI migration process (in case of different table prefix)
  • Restricted access to global logs
  • Restricted access to backup logs
  • Added censor for backup name in all log files
  • Added censor for sensitive details in global log and others
  • Randomize folder name for each site, it will rename old directory as well
  • Backup hash name will be now extended up to 16 characters including A-z
  • Decreased default database batch size to 250 from 2500 queries
  • Added constant ABSPATH for exclusion rules
  • Tested up to WordPress 5.8
Download this release

Release Info

Developer iclyde
Plugin Icon wp plugin Backup Migration
Version 1.1.3
Comparing to
See all releases

Code changes from version 1.1.2 to 1.1.3

backup-backup.php CHANGED
@@ -7,7 +7,7 @@
7
  * Author URI: https://backupbliss.com/
8
  * Plugin URI: https://backupbliss.com
9
  * Text Domain: backup-backup
10
- * Version: 1.1.2
11
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
 
13
  // Exit on direct access
@@ -21,7 +21,7 @@
21
  define('BMI_DEBUG', false);
22
  }
23
  if (!defined('BMI_VERSION')) {
24
- define('BMI_VERSION', '1.1.2');
25
  }
26
  if (!defined('BMI_ROOT_DIR')) {
27
  define('BMI_ROOT_DIR', __DIR__);
7
  * Author URI: https://backupbliss.com/
8
  * Plugin URI: https://backupbliss.com
9
  * Text Domain: backup-backup
10
+ * Version: 1.1.3
11
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
 
13
  // Exit on direct access
21
  define('BMI_DEBUG', false);
22
  }
23
  if (!defined('BMI_VERSION')) {
24
+ define('BMI_VERSION', '1.1.3');
25
  }
26
  if (!defined('BMI_ROOT_DIR')) {
27
  define('BMI_ROOT_DIR', __DIR__);
includes/ajax.php CHANGED
@@ -387,7 +387,7 @@
387
  public function makeBackupName() {
388
  $name = Dashboard\bmi_get_config('BACKUP:NAME');
389
 
390
- $hash = rand(1000, 9999);
391
  $name = str_replace('%hash', $hash, $name);
392
  $name = str_replace('%Y', date('Y'), $name);
393
  $name = str_replace('%M', date('M'), $name);
@@ -1369,7 +1369,7 @@
1369
 
1370
  public function saveStorageConfig() {
1371
  $dir_path = $this->post['directory']; // STORAGE::LOCAL::PATH
1372
- $accessible = $this->post['access']; // TORAGE::DIRECT::URL
1373
  $curr_path = Dashboard\bmi_get_config('STORAGE::LOCAL::PATH');
1374
 
1375
  $error = 0;
@@ -1401,6 +1401,13 @@
1401
 
1402
  @rmdir($cur_dir);
1403
  @rmdir(dirname($cur_dir));
 
 
 
 
 
 
 
1404
  }
1405
  }
1406
  } else {
@@ -1714,8 +1721,9 @@
1714
  }
1715
  $ignored_paths = $ignored_paths_default;
1716
 
1717
- // Fix slashes for current system
1718
  for ($i = 0; $i < sizeof($ignored_paths); ++$i) {
 
1719
  $ignored_paths[$i] = BMP::fixSlashes($ignored_paths[$i]);
1720
  }
1721
 
@@ -1808,6 +1816,7 @@
1808
 
1809
  if ($is && $acis) {
1810
  foreach ($ac as $key => $value) {
 
1811
  $value = BMP::fixSlashes($value);
1812
  $acres->{$value} = 1;
1813
  }
387
  public function makeBackupName() {
388
  $name = Dashboard\bmi_get_config('BACKUP:NAME');
389
 
390
+ $hash = BMP::randomString(16);
391
  $name = str_replace('%hash', $hash, $name);
392
  $name = str_replace('%Y', date('Y'), $name);
393
  $name = str_replace('%M', date('M'), $name);
1369
 
1370
  public function saveStorageConfig() {
1371
  $dir_path = $this->post['directory']; // STORAGE::LOCAL::PATH
1372
+ $accessible = $this->post['access']; // STORAGE::DIRECT::URL
1373
  $curr_path = Dashboard\bmi_get_config('STORAGE::LOCAL::PATH');
1374
 
1375
  $error = 0;
1401
 
1402
  @rmdir($cur_dir);
1403
  @rmdir(dirname($cur_dir));
1404
+
1405
+ if (is_dir($curr_path) && file_exists($curr_path)) {
1406
+ $left_files = array_diff(scandir($curr_path), ['..', '.']);
1407
+ if (sizeof($left_files) == 0) {
1408
+ @rmdir($curr_path);
1409
+ }
1410
+ }
1411
  }
1412
  }
1413
  } else {
1721
  }
1722
  $ignored_paths = $ignored_paths_default;
1723
 
1724
+ // Fix slashes for current system (directories)
1725
  for ($i = 0; $i < sizeof($ignored_paths); ++$i) {
1726
+ $ignored_paths[$i] = str_replace('***ABSPATH***', untrailingslashit(ABSPATH), $ignored_paths[$i]);
1727
  $ignored_paths[$i] = BMP::fixSlashes($ignored_paths[$i]);
1728
  }
1729
 
1816
 
1817
  if ($is && $acis) {
1818
  foreach ($ac as $key => $value) {
1819
+ $value = str_replace('***ABSPATH***', untrailingslashit(ABSPATH), $value);
1820
  $value = BMP::fixSlashes($value);
1821
  $acres->{$value} = 1;
1822
  }
includes/constants.php CHANGED
@@ -25,7 +25,7 @@
25
  define('BMI_CONFIG_DIR', dirname(BMI_CONFIG_PATH));
26
  }
27
  if (!defined('BMI_DB_MAX_ROWS_PER_QUERY')) {
28
- define('BMI_DB_MAX_ROWS_PER_QUERY', 2500);
29
  }
30
  if (!defined('BMI_REV')) {
31
  define('BMI_REV', 2);
@@ -34,7 +34,6 @@
34
  // Load configuration
35
  require_once BMI_INCLUDES . DIRECTORY_SEPARATOR . 'config.php';
36
 
37
-
38
  // Default constants
39
  if (!defined('BMI_CLI_EXECUTABLE')) {
40
  $php_cli_path = Dashboard\bmi_get_config('OTHER:CLI:PATH');
25
  define('BMI_CONFIG_DIR', dirname(BMI_CONFIG_PATH));
26
  }
27
  if (!defined('BMI_DB_MAX_ROWS_PER_QUERY')) {
28
+ define('BMI_DB_MAX_ROWS_PER_QUERY', 250);
29
  }
30
  if (!defined('BMI_REV')) {
31
  define('BMI_REV', 2);
34
  // Load configuration
35
  require_once BMI_INCLUDES . DIRECTORY_SEPARATOR . 'config.php';
36
 
 
37
  // Default constants
38
  if (!defined('BMI_CLI_EXECUTABLE')) {
39
  $php_cli_path = Dashboard\bmi_get_config('OTHER:CLI:PATH');
includes/dashboard/chapter/store_config.php CHANGED
@@ -48,7 +48,7 @@
48
  <div class="format-entry"><b>%H</b> = <?php _e("24-hour format of an hour with leading zeros", 'backup-backup'); ?></div>
49
  <div class="format-entry"><b>%i</b> = <?php _e("Minutes with leading zeros", 'backup-backup'); ?></div>
50
  <div class="format-entry"><b>%s</b> = <?php _e("Seconds with leading zeros", 'backup-backup'); ?></div>
51
- <div class="format-entry"><b>%hash</b> = <?php _e("4 digit random hash", 'backup-backup'); ?></div>
52
  </div>
53
  <div class="right-align">
54
  <a href="#" class="hoverable nodec secondary" id="hide-format-tip"><?php _e("Hide", 'backup-backup'); ?></a>
48
  <div class="format-entry"><b>%H</b> = <?php _e("24-hour format of an hour with leading zeros", 'backup-backup'); ?></div>
49
  <div class="format-entry"><b>%i</b> = <?php _e("Minutes with leading zeros", 'backup-backup'); ?></div>
50
  <div class="format-entry"><b>%s</b> = <?php _e("Seconds with leading zeros", 'backup-backup'); ?></div>
51
+ <div class="format-entry"><b>%hash</b> = <?php _e("16 character random hash", 'backup-backup'); ?></div>
52
  </div>
53
  <div class="right-align">
54
  <a href="#" class="hoverable nodec secondary" id="hide-format-tip"><?php _e("Hide", 'backup-backup'); ?></a>
includes/dashboard/chapter/what_backed_up.php CHANGED
@@ -242,6 +242,8 @@
242
  <textarea id="dynamic-fpaths-names" class="fullwidth bmi-txtar" name="name" rows="6" cols="80" placeholder="<?php echo $ex0 . '&#10;' . $ex1 . '&#10;' . $ex2 . '&#10;' . $ex3 ?>">
243
  </textarea>
244
 
 
 
245
  </div>
246
  </div>
247
 
@@ -264,6 +266,8 @@
264
  <textarea id="dynamic-dpaths-names" class="fullwidth bmi-txtar" name="name" rows="6" cols="80" placeholder="<?php echo $ex0 . '&#10;' . $ex4 . '&#10;' . $ex5 . '&#10;' . $ex6 ?>">
265
  </textarea>
266
 
 
 
267
  </div>
268
  </div>
269
 
242
  <textarea id="dynamic-fpaths-names" class="fullwidth bmi-txtar" name="name" rows="6" cols="80" placeholder="<?php echo $ex0 . '&#10;' . $ex1 . '&#10;' . $ex2 . '&#10;' . $ex3 ?>">
243
  </textarea>
244
 
245
+ <?php echo str_replace('%s', '<b>***ABSPATH***</b>', __('You can use there constant %s as your root path.', 'backup-backup')); ?>
246
+
247
  </div>
248
  </div>
249
 
266
  <textarea id="dynamic-dpaths-names" class="fullwidth bmi-txtar" name="name" rows="6" cols="80" placeholder="<?php echo $ex0 . '&#10;' . $ex4 . '&#10;' . $ex5 . '&#10;' . $ex6 ?>">
267
  </textarea>
268
 
269
+ <?php echo str_replace('%s', '<b>***ABSPATH***</b>', __('You can use there constant %s as your root path.', 'backup-backup')); ?>
270
+
271
  </div>
272
  </div>
273
 
includes/extracter/extract.php CHANGED
@@ -75,15 +75,15 @@
75
  }
76
  $this->databaseExist = false;
77
  if (isset($options['databaseExist'])) {
78
- $this->databaseExist = (($options['databaseExist'] == 'true' || $options['databaseExist'] === true) ? true : false);
79
  }
80
  $this->firstDB = true;
81
  if (isset($options['firstDB'])) {
82
- $this->firstDB = (($options['firstDB'] == 'true' || $options['firstDB'] === true) ? true : false);
83
  }
84
  $this->firstExtract = true;
85
  if (isset($options['firstExtract'])) {
86
- $this->firstExtract = (($options['firstExtract'] == 'false' || $options['firstExtract'] === false) ? false : true);
87
  }
88
 
89
  $this->db_xi = 0;
@@ -940,10 +940,10 @@
940
 
941
  // Update TasteWP option
942
  update_option('tastewp_auto_activated', true);
 
943
 
944
  if (!$this->isCLI) {
945
 
946
- $this->databaseExist = $database_exist;
947
  BMP::res(['status' => 'restore_ongoing', 'tmp' => $this->tmptime, 'secret' => $secret, 'options' => [
948
  'code' => $this->code,
949
  'start' => $this->start,
75
  }
76
  $this->databaseExist = false;
77
  if (isset($options['databaseExist'])) {
78
+ $this->databaseExist = (($options['databaseExist'] == 'true' || $options['databaseExist'] === '1' || $options['databaseExist'] === 1 || $options['databaseExist'] === true) ? true : false);
79
  }
80
  $this->firstDB = true;
81
  if (isset($options['firstDB'])) {
82
+ $this->firstDB = (($options['firstDB'] == 'true' || $options['firstDB'] === '1' || $options['firstDB'] === 1 || $options['firstDB'] === true) ? true : false);
83
  }
84
  $this->firstExtract = true;
85
  if (isset($options['firstExtract'])) {
86
+ $this->firstExtract = (($options['firstExtract'] == 'false' || $options['firstExtract'] === '1' || $options['firstExtract'] === 1 || $options['firstExtract'] === false) ? false : true);
87
  }
88
 
89
  $this->db_xi = 0;
940
 
941
  // Update TasteWP option
942
  update_option('tastewp_auto_activated', true);
943
+ $this->databaseExist = $database_exist;
944
 
945
  if (!$this->isCLI) {
946
 
 
947
  BMP::res(['status' => 'restore_ongoing', 'tmp' => $this->tmptime, 'secret' => $secret, 'options' => [
948
  'code' => $this->code,
949
  'start' => $this->start,
includes/htaccess/default.json CHANGED
@@ -30,7 +30,7 @@
30
  "OTHER:USE:TIMEOUT:NORMAL": true,
31
  "OTHER:UNINSTALL:CONFIGS": false,
32
  "OTHER:UNINSTALL:BACKUPS": false,
33
- "OTHER:DOWNLOAD:DIRECT": true,
34
  "OTHER:CLI:DISABLE": false,
35
  "OTHER:CLI:PATH": "",
36
  "CRON:ENABLED": false,
30
  "OTHER:USE:TIMEOUT:NORMAL": true,
31
  "OTHER:UNINSTALL:CONFIGS": false,
32
  "OTHER:UNINSTALL:BACKUPS": false,
33
+ "OTHER:DOWNLOAD:DIRECT": false,
34
  "OTHER:CLI:DISABLE": false,
35
  "OTHER:CLI:PATH": "",
36
  "CRON:ENABLED": false,
includes/initializer.php CHANGED
@@ -140,6 +140,64 @@
140
 
141
  }
142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  public function ajax($cli = false) {
144
  if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
145
  if ((isset($_POST['token']) && $_POST['token'] == 'bmi' && isset($_POST['f']) && is_admin()) || $cli) {
@@ -344,6 +402,7 @@
344
  }
345
 
346
  public function admin_init_hook() {
 
347
  if (get_option('_bmi_redirect', false)) {
348
  $this->fixLitespeed();
349
  delete_option('_bmi_redirect');
@@ -521,6 +580,52 @@
521
  file_put_contents($file, $status . '.' . $time);
522
  }
523
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
524
  public function handle_cron_backup() {
525
 
526
  // Abort if disabled
@@ -756,6 +861,10 @@
756
  exit;
757
  }
758
  } elseif ($type == 'BMI_BACKUP_LOGS') {
 
 
 
 
759
  ob_clean();
760
  $backupname = $get_bid;
761
  $file = $this->fixSlashes(BMI_BACKUPS . DIRECTORY_SEPARATOR . $backupname);
@@ -772,7 +881,20 @@
772
  header('Content-Disposition: attachment; filename="' . substr($backupname, 0, -4) . '.log"');
773
  http_response_code(200);
774
  if (ob_get_level()) ob_end_clean();
775
- echo $logs;
 
 
 
 
 
 
 
 
 
 
 
 
 
776
  exit;
777
  } else {
778
  if (ob_get_level()) ob_end_clean();
@@ -781,9 +903,19 @@
781
  exit;
782
  }
783
  }
 
784
  } elseif ($type == 'PROGRESS_LOGS') {
785
  $allowed_progress = ['latest_full.log', 'latest.log', 'latest_progress.log', 'latest_migration_progress.log', 'latest_migration.log', 'complete_logs.log', 'latest_migration_full.log'];
786
  if (isset($get_pid) && in_array($get_pid, $allowed_progress)) {
 
 
 
 
 
 
 
 
 
787
  header('Content-Type: text/plain');
788
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
789
  http_response_code(200);
@@ -791,7 +923,7 @@
791
  if ($get_pid == 'complete_logs.log') {
792
  $file = BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . 'complete_logs.log';
793
  if (ob_get_level()) ob_end_clean();
794
- readfile($file);
795
  exit;
796
  } else if ($get_pid == 'latest_full.log') {
797
  $progress = dirname(BMI_BACKUPS) . DIRECTORY_SEPARATOR . 'backups' . DIRECTORY_SEPARATOR . 'latest_progress.log';
@@ -800,7 +932,7 @@
800
  if (ob_get_level()) ob_end_clean();
801
  readfile($progress);
802
  echo "\n";
803
- readfile($logs);
804
  exit;
805
  } else {
806
  if (file_exists($progress) && !(time() - filemtime($progress)) < (60 * 5)) {
@@ -821,7 +953,7 @@
821
  if (ob_get_level()) ob_end_clean();
822
  readfile($progress);
823
  echo "\n";
824
- readfile($logs);
825
  exit;
826
  } else {
827
  if (file_exists($progress) && !(time() - filemtime($progress)) < (60 * 5)) {
@@ -839,7 +971,9 @@
839
  $file = dirname(BMI_BACKUPS) . DIRECTORY_SEPARATOR . 'backups' . DIRECTORY_SEPARATOR . $get_pid;
840
  if (file_exists($file) && (((time() - filemtime($file)) < (60 * 5)) || current_user_can('administrator'))) {
841
  if (ob_get_level()) ob_end_clean();
842
- readfile($file);
 
 
843
  echo "\n";
844
  if ($get_pid == 'latest.log') $file = dirname(BMI_BACKUPS) . DIRECTORY_SEPARATOR . 'backups' . DIRECTORY_SEPARATOR . 'latest_progress.log';
845
  if ($get_pid == 'latest_migration.log') $file = dirname(BMI_BACKUPS) . DIRECTORY_SEPARATOR . 'backups' . DIRECTORY_SEPARATOR . 'latest_migration_progress.log';
140
 
141
  }
142
 
143
+ public static function randomString($max = 16) {
144
+
145
+ $bank = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
146
+ $bank .= 'abcdefghijklmnopqrstuvwxyz';
147
+ $bank .= '0123456789';
148
+
149
+ $str = str_shuffle($bank);
150
+
151
+ while (is_numeric($str[0])) {
152
+ $str = str_shuffle($bank);
153
+ }
154
+
155
+ $str = substr($str, 0, $max);
156
+
157
+ return $str;
158
+
159
+ }
160
+
161
+ /**
162
+ * hotFixPatches - Function which fixes things for "old" users
163
+ *
164
+ * @return @void
165
+ */
166
+ public function hotfix_patches() {
167
+
168
+ if (!is_admin()) return;
169
+
170
+ $current_patch = get_option('bmi_hotfixes', array());
171
+ if (!in_array('BMI_D20_M07_01', $current_patch)) {
172
+
173
+ $current_directory = Dashboard\bmi_get_config('STORAGE::LOCAL::PATH');
174
+ if (basename($current_directory) == 'backup-migration') {
175
+
176
+ require_once BMI_INCLUDES . '/ajax.php';
177
+ $handler = new BMI_Ajax();
178
+
179
+ $handler->post['directory'] = dirname($current_directory) . DIRECTORY_SEPARATOR . 'backup-migration-' . $this->randomString(10);
180
+ $handler->post['access'] = Dashboard\bmi_get_config('STORAGE::DIRECT::URL');
181
+
182
+ $res = $handler->saveStorageConfig();
183
+ if (isset($res['status']) && $res['status'] == 'success') {
184
+
185
+ $current_patch[] = 'BMI_D20_M07_01';
186
+
187
+ }
188
+
189
+ } else {
190
+
191
+ $current_patch[] = 'BMI_D20_M07_01';
192
+
193
+ }
194
+
195
+ }
196
+
197
+ update_option('bmi_hotfixes', $current_patch);
198
+
199
+ }
200
+
201
  public function ajax($cli = false) {
202
  if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
203
  if ((isset($_POST['token']) && $_POST['token'] == 'bmi' && isset($_POST['f']) && is_admin()) || $cli) {
402
  }
403
 
404
  public function admin_init_hook() {
405
+ $this->hotfix_patches();
406
  if (get_option('_bmi_redirect', false)) {
407
  $this->fixLitespeed();
408
  delete_option('_bmi_redirect');
580
  file_put_contents($file, $status . '.' . $time);
581
  }
582
 
583
+ public function readFileSensitive($file) {
584
+
585
+ $file = new \SplFileObject($file);
586
+ $file->seek($file->getSize());
587
+ $total_lines = $file->key() + 1;
588
+
589
+ $current_directory = Dashboard\bmi_get_config('STORAGE::LOCAL::PATH');
590
+ $backups_path = $this->fixSlashes($current_directory . DIRECTORY_SEPARATOR . 'backups');
591
+ $scanned_directory_all = array_diff(scandir($backups_path), ['..', '.']);
592
+ $scanned_directory = array_values(preg_grep('/((.*).zip)/i', $scanned_directory_all));
593
+
594
+ for ($i = 0; $i < $total_lines; ++$i) {
595
+
596
+ $file->seek($i);
597
+ $line = $this->escapeSensitive($file->current(), $current_directory, $scanned_directory);
598
+
599
+ echo $line;
600
+ unset($line);
601
+
602
+ }
603
+
604
+ }
605
+
606
+ public function escapeSensitive($line, $current_directory, $scanned_directory) {
607
+
608
+ $dir_name = basename($current_directory);
609
+
610
+ $line = preg_replace('/\:\ ((.*)\.zip)/', ': *****.zip', $line);
611
+ $line = preg_replace('/(\"filename\":(.*)\.zip)\"/', '"filename": "*****.zip"', $line);
612
+ $line = preg_replace('/\"http(.*)\"/', '"***site_url***"', $line);
613
+ $line = preg_replace('/\:\ http(.*)\n/', ": ***site_url***\n", $line);
614
+ $line = preg_replace('/\"\d{10}\"/', '"***secret_login***"', $line);
615
+ $line = str_replace(ABSPATH, '***ABSPATH***/', $line);
616
+ $line = str_replace($dir_name, '***backup_path***', $line);
617
+
618
+ for ($i = 0; $i < sizeof($scanned_directory); ++$i) {
619
+
620
+ $backup_name = $scanned_directory[$i];
621
+ $line = str_replace($backup_name, '***some_backup***', $line);
622
+
623
+ }
624
+
625
+ return $line;
626
+
627
+ }
628
+
629
  public function handle_cron_backup() {
630
 
631
  // Abort if disabled
861
  exit;
862
  }
863
  } elseif ($type == 'BMI_BACKUP_LOGS') {
864
+
865
+ // Only Admin can download backup logs
866
+ if (!(current_user_can('administrator') || current_user_can('do_backups'))) return;
867
+
868
  ob_clean();
869
  $backupname = $get_bid;
870
  $file = $this->fixSlashes(BMI_BACKUPS . DIRECTORY_SEPARATOR . $backupname);
881
  header('Content-Disposition: attachment; filename="' . substr($backupname, 0, -4) . '.log"');
882
  http_response_code(200);
883
  if (ob_get_level()) ob_end_clean();
884
+
885
+ $logs = explode('\n', $logs);
886
+ $current_directory = Dashboard\bmi_get_config('STORAGE::LOCAL::PATH');
887
+ $backups_path = $this->fixSlashes($current_directory . DIRECTORY_SEPARATOR . 'backups');
888
+ $scanned_directory_all = array_diff(scandir($backups_path), ['..', '.']);
889
+ $scanned_directory = array_values(preg_grep('/((.*).zip)/i', $scanned_directory_all));
890
+
891
+ for ($i = 0; $i < sizeof($logs); ++$i) {
892
+
893
+ $line = $logs[$i];
894
+ echo $this->escapeSensitive($line, $current_directory, $scanned_directory) . "\n";
895
+
896
+ }
897
+
898
  exit;
899
  } else {
900
  if (ob_get_level()) ob_end_clean();
903
  exit;
904
  }
905
  }
906
+
907
  } elseif ($type == 'PROGRESS_LOGS') {
908
  $allowed_progress = ['latest_full.log', 'latest.log', 'latest_progress.log', 'latest_migration_progress.log', 'latest_migration.log', 'complete_logs.log', 'latest_migration_full.log'];
909
  if (isset($get_pid) && in_array($get_pid, $allowed_progress)) {
910
+
911
+ $restricted_progress = ['complete_logs.log'];
912
+ if (in_array($get_pid, $restricted_progress)) {
913
+
914
+ // Only Admin can download backup logs
915
+ if (!(current_user_can('administrator') || current_user_can('do_backups'))) return;
916
+
917
+ }
918
+
919
  header('Content-Type: text/plain');
920
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
921
  http_response_code(200);
923
  if ($get_pid == 'complete_logs.log') {
924
  $file = BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . 'complete_logs.log';
925
  if (ob_get_level()) ob_end_clean();
926
+ $this->readFileSensitive($file);
927
  exit;
928
  } else if ($get_pid == 'latest_full.log') {
929
  $progress = dirname(BMI_BACKUPS) . DIRECTORY_SEPARATOR . 'backups' . DIRECTORY_SEPARATOR . 'latest_progress.log';
932
  if (ob_get_level()) ob_end_clean();
933
  readfile($progress);
934
  echo "\n";
935
+ $this->readFileSensitive($logs);
936
  exit;
937
  } else {
938
  if (file_exists($progress) && !(time() - filemtime($progress)) < (60 * 5)) {
953
  if (ob_get_level()) ob_end_clean();
954
  readfile($progress);
955
  echo "\n";
956
+ $this->readFileSensitive($logs);
957
  exit;
958
  } else {
959
  if (file_exists($progress) && !(time() - filemtime($progress)) < (60 * 5)) {
971
  $file = dirname(BMI_BACKUPS) . DIRECTORY_SEPARATOR . 'backups' . DIRECTORY_SEPARATOR . $get_pid;
972
  if (file_exists($file) && (((time() - filemtime($file)) < (60 * 5)) || current_user_can('administrator'))) {
973
  if (ob_get_level()) ob_end_clean();
974
+
975
+ $this->readFileSensitive($file);
976
+
977
  echo "\n";
978
  if ($get_pid == 'latest.log') $file = dirname(BMI_BACKUPS) . DIRECTORY_SEPARATOR . 'backups' . DIRECTORY_SEPARATOR . 'latest_progress.log';
979
  if ($get_pid == 'latest_migration.log') $file = dirname(BMI_BACKUPS) . DIRECTORY_SEPARATOR . 'backups' . DIRECTORY_SEPARATOR . 'latest_migration_progress.log';
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: Migrate
3
  Tags: Backup, Migration, Migrate, Backups, Restore, Duplicate
4
  Requires at least: 4.6
5
- Tested up to: 5.7.2
6
- Stable tag: 1.1.2
7
  License: GPLv3
8
  Requires PHP: 5.6
9
 
@@ -118,6 +118,18 @@ Besides having the most intuitive interface and smoothest user experience, Backu
118
 
119
  == Changelog ==
120
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  = 1.1.2 =
122
  * Added new option which allow to specify own PHP CLI path
123
  * Added possibility to disable PHP CLI for both restore and backup process
@@ -258,25 +270,15 @@ Besides having the most intuitive interface and smoothest user experience, Backu
258
 
259
  == Upgrade Notice ==
260
 
261
- = 1.1.2 =
262
- What's new in 1.1.2?
263
- * Added new option which allow to specify own PHP CLI path
264
- * Added possibility to disable PHP CLI for both restore and backup process
265
- * Fixed output data restore process – should not hang up on success
266
- * Fixed output data for backup process should not hang up on success as well
267
- * Added batching for restore process, should extend execution time
268
- * Increased batch size for huge sites up to 40k files per batch
269
- * Increased default max size of batch from 60 MB to 96 MB
270
- * Fixed issues with PHP CLI when the output was not correct
271
- * Added possibility to download live log of restore process (useful when it hang up)
272
- * Restore process now can calculate file amount before extraction
273
- * Added secret keys for restore process – should be much more secure now
274
- * Added batching for database export, plugin should use maximum execution time now
275
- * Removed debug information in console log (should be in 1.1.1)
276
- * Added batching for files extraction during restore process
277
- * Restore process now shows extraction progress – the process is slower because of it but more stable
278
- * Fixed PHP CLI for premium users where the site is too large
279
- * Fixed SuperQuick Migration via PHP CLI – now the process should continue automatically
280
- * Added notice logging into restore process
281
- * Now restore process will continue on notice like uninitialized classname
282
- * Fixed issue when restore process hangs up (5.6 - 7.4 PHP versions) due to uninitialized classname
2
  Contributors: Migrate
3
  Tags: Backup, Migration, Migrate, Backups, Restore, Duplicate
4
  Requires at least: 4.6
5
+ Tested up to: 5.8
6
+ Stable tag: 1.1.3
7
  License: GPLv3
8
  Requires PHP: 5.6
9
 
118
 
119
  == Changelog ==
120
 
121
+ = 1.1.3 =
122
+ * Fixed PHP CLI migration process (in case of different table prefix)
123
+ * Restricted access to global logs
124
+ * Restricted access to backup logs
125
+ * Added censor for backup name in all log files
126
+ * Added censor for sensitive details in global log and others
127
+ * Randomize folder name for each site, it will rename old directory as well
128
+ * Backup hash name will be now extended up to 16 characters including A-z
129
+ * Decreased default database batch size to 250 from 2500 queries
130
+ * Added constant ***ABSPATH*** for exclusion rules
131
+ * Tested up to WordPress 5.8
132
+
133
  = 1.1.2 =
134
  * Added new option which allow to specify own PHP CLI path
135
  * Added possibility to disable PHP CLI for both restore and backup process
270
 
271
  == Upgrade Notice ==
272
 
273
+ = 1.1.3 =
274
+ What's new in 1.1.3?
275
+ * Fixed PHP CLI migration process (in case of different table prefix)
276
+ * Restricted access to global logs
277
+ * Restricted access to backup logs
278
+ * Added censor for backup name in all log files
279
+ * Added censor for sensitive details in global log and others
280
+ * Randomize folder name for each site, it will rename old directory as well
281
+ * Backup hash name will be now extended up to 16 characters including A-z
282
+ * Decreased default database batch size to 250 from 2500 queries
283
+ * Added constant ***ABSPATH*** for exclusion rules
284
+ * Tested up to WordPress 5.8