XCloner – Backup and Restore - Version 4.4.5

Version Description

  • fix: https://github.com/watchfulli/XCloner-Wordpress/issues/240
  • fix: https://github.com/watchfulli/XCloner-Wordpress/issues/234
  • fix: https://github.com/watchfulli/XCloner-Wordpress/issues/225
Download this release

Release Info

Developer watchful
Plugin Icon 128x128 XCloner – Backup and Restore
Version 4.4.5
Comparing to
See all releases

Code changes from version 4.4.4 to 4.4.5

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags: backup, database backup, cloud backup, WordPress backup, WordPress migrati
5
  Requires at least: 5.1
6
  Requires PHP: 7.3
7
  Tested up to: 6.0
8
- Stable tag: 4.4.4
9
 
10
 
11
  XCloner is a backup plugin that allows you to safely back up and restore your WordPress sites. You can send site backups to SFTP, Dropbox, Amazon, Google Drive, Backblaze and other locations.
@@ -117,6 +117,11 @@ Of course, schedules can be adjusted accordingly to how often you update your si
117
 
118
  == Changelog ==
119
 
 
 
 
 
 
120
  = 4.4.4 =
121
  * fix: missing escapes and sanitizations
122
 
5
  Requires at least: 5.1
6
  Requires PHP: 7.3
7
  Tested up to: 6.0
8
+ Stable tag: 4.4.5
9
 
10
 
11
  XCloner is a backup plugin that allows you to safely back up and restore your WordPress sites. You can send site backups to SFTP, Dropbox, Amazon, Google Drive, Backblaze and other locations.
117
 
118
  == Changelog ==
119
 
120
+ = 4.4.5 =
121
+ * fix: https://github.com/watchfulli/XCloner-Wordpress/issues/240
122
+ * fix: https://github.com/watchfulli/XCloner-Wordpress/issues/234
123
+ * fix: https://github.com/watchfulli/XCloner-Wordpress/issues/225
124
+
125
  = 4.4.4 =
126
  * fix: missing escapes and sanitizations
127
 
admin/class-xcloner-admin.php CHANGED
@@ -241,14 +241,15 @@ class Xcloner_Admin
241
  </div>
242
 
243
  <ul class="nav-tab-wrapper col s12 ">
244
- <li><a href="?page=xcloner_settings_page&tab=general_options"
245
- class="nav-tab col s12 m3 l3 <?php echo $active_tab == 'general_options' ? 'nav-tab-active' : ''; ?>"><?php echo __('General Options', 'xcloner-backup-and-restore') ?></a>
 
 
246
  </li>
247
- <li><a href="?page=xcloner_settings_page&tab=mysql_options"
248
- class="nav-tab col s12 m3 l3 <?php echo $active_tab == 'mysql_options' ? 'nav-tab-active' : ''; ?>"><?php echo __('Mysql Options', 'xcloner-backup-and-restore') ?></a>
249
- </li>
250
- <li><a href="?page=xcloner_settings_page&tab=system_options"
251
- class="nav-tab col s12 m3 l3 <?php echo $active_tab == 'system_options' ? 'nav-tab-active' : ''; ?>"><?php echo __('System Options', 'xcloner-backup-and-restore') ?></a>
252
  </li>
253
  </ul>
254
 
@@ -260,9 +261,6 @@ class Xcloner_Admin
260
  if ($active_tab == 'general_options') {
261
  settings_fields('xcloner_general_settings_group');
262
  do_settings_sections('xcloner_settings_page');
263
- } elseif ($active_tab == 'mysql_options') {
264
- settings_fields('xcloner_mysql_settings_group');
265
- do_settings_sections('xcloner_mysql_settings_page');
266
  } elseif ($active_tab == 'system_options') {
267
  settings_fields('xcloner_system_settings_group');
268
  do_settings_sections('xcloner_system_settings_page');
241
  </div>
242
 
243
  <ul class="nav-tab-wrapper col s12 ">
244
+ <li>
245
+ <a href="?page=xcloner_settings_page&tab=general_options"
246
+ class="nav-tab col s12 m3 l3 <?php echo $active_tab == 'general_options' ? 'nav-tab-active' : ''; ?>"><?php echo __('General Options', 'xcloner-backup-and-restore') ?>
247
+ </a>
248
  </li>
249
+ <li>
250
+ <a href="?page=xcloner_settings_page&tab=system_options"
251
+ class="nav-tab col s12 m3 l3 <?php echo $active_tab == 'system_options' ? 'nav-tab-active' : ''; ?>"><?php echo __('System Options', 'xcloner-backup-and-restore') ?>
252
+ </a>
 
253
  </li>
254
  </ul>
255
 
261
  if ($active_tab == 'general_options') {
262
  settings_fields('xcloner_general_settings_group');
263
  do_settings_sections('xcloner_settings_page');
 
 
 
264
  } elseif ($active_tab == 'system_options') {
265
  settings_fields('xcloner_system_settings_group');
266
  do_settings_sections('xcloner_system_settings_page');
admin/partials/remote_storage/aws.php CHANGED
@@ -124,7 +124,7 @@ if (!defined('WPINC')) {
124
  </div>
125
  </div>
126
 
127
- <? echo common_cleanup_html('aws') ?>
128
 
129
  <div class="row">
130
  <div class="col s6 m4">
124
  </div>
125
  </div>
126
 
127
+ <?php echo common_cleanup_html('aws') ?>
128
 
129
  <div class="row">
130
  <div class="col s6 m4">
admin/partials/xcloner_generate_backups_page.php CHANGED
@@ -15,13 +15,11 @@ $tab = 1;
15
  <li><a href="#backup_options"
16
  class="nav-tab col s12 m3 l2 nav-tab-active"><?php echo esc_html($tab) . ". " . __('Backup Options', 'xcloner-backup-and-restore') ?></a>
17
  </li>
18
- <?php if ($xcloner_settings->get_enable_mysql_backup()): ?>
19
- <li>
20
- <a href="#database_options" class="nav-tab col s12 m3 l2 ">
21
- <?php echo esc_html(++$tab) . ". " . __('Database Options', 'xcloner-backup-and-restore') ?>
22
- </a>
23
- </li>
24
- <?php endif ?>
25
  <li>
26
  <a href="#files_options" class="nav-tab col s12 m3 l2 ">
27
  <?php echo esc_html(++$tab) . ". " . __('Files Options', 'xcloner-backup-and-restore') ?>
@@ -209,33 +207,31 @@ $tab = 1;
209
 
210
  </div>
211
 
212
- <?php if ($xcloner_settings->get_enable_mysql_backup()): ?>
213
- <div id="database_options" class="tab-content">
214
- <div class="row">
215
- <div class="input-field col s12 m10 l10 right-align">
216
- <a class="waves-effect waves-light btn" onclick="next_tab('#files_options');"><i
217
- class="material-icons right">skip_next</i>Next</a>
218
- </div>
219
  </div>
 
220
 
221
- <h2><?php echo __('Select database data to include in the backup', 'xcloner-backup-and-restore') ?>
222
- :
223
- <a class="btn-floating tooltipped btn-small" data-position="right" data-delay="50"
224
- data-tooltip="<?php echo __('Enable the \'Backup only WP tables\' setting if you don\'t want to show all other databases and tables not related to this Wordpress install', 'xcloner-backup-and-restore'); ?>"
225
- data-tooltip-id="">
226
- <i class="material-icons">help_outline</i>
227
- </a>
228
- </h2>
229
 
230
- <!-- database/tables tree -->
231
- <div class="row">
232
- <div class="col s12 l6">
233
- <div id="jstree_database_container"></div>
234
- </div>
235
  </div>
236
-
237
  </div>
238
- <?php endif ?>
 
239
 
240
  <div id="files_options" class="tab-content">
241
  <div class="row">
@@ -299,36 +295,34 @@ $tab = 1;
299
  </div>
300
  <div class="collapsible-body status-body"></div>
301
  </li>
302
- <?php if ($xcloner_settings->get_enable_mysql_backup()): ?>
303
- <li class="database-backup">
304
- <div class="collapsible-header">
305
- <i class="material-icons">storage</i>
306
- <?php echo __('Generating the Mysql Backup...', 'xcloner-backup-and-restore') ?>
307
 
308
- <p class="right">
309
- <?php echo sprintf(__('Found %s tables in %s databases (%s)', 'xcloner-backup-and-restore'), '<span class="table-counter">0</span>', '<span class="database-counter">0</span>', '<span data-processed="0" class="total-records">0</span> records', 'xcloner-backup-and-restore') ?>
310
- </p>
311
 
312
- <div>
313
- <p class="right"><span class="last-logged-table"></span></p>
314
- </div>
315
 
316
- <div class="progress">
317
- <div class="determinate" style="width:0%"></div>
318
- </div>
319
  </div>
320
- <div class="collapsible-body status-body">
321
- <div class="row">
322
- <div class="col l7 s12">
323
- <ul class="logged-tables"></ul>
324
- </div>
325
- <div class="col l5 s12">
326
- <ul class="logged-databases right"></ul>
327
- </div>
328
  </div>
329
  </div>
330
- </li>
331
- <?php endif ?>
332
  <li class="files-backup">
333
  <div class="collapsible-header">
334
  <i class="material-icons">archive</i>
@@ -516,7 +510,8 @@ $tab = 1;
516
 
517
  <div class="row">
518
  <div class="col s12 l7">
519
- <button class="right btn waves-effect waves-light submit_schedule" type="submit" name="action">
 
520
  <?php echo __("Save Schedule", 'xcloner-backup-and-restore') ?>
521
  <i class="material-icons right">send</i>
522
  </button>
@@ -693,7 +688,6 @@ $tab = 1;
693
  }
694
  });
695
 
696
- <?php if ($xcloner_settings->get_enable_mysql_backup()): ?>
697
  jQuery('#jstree_database_container').jstree({
698
  'core': {
699
  'check_callback': true,
@@ -737,7 +731,6 @@ $tab = 1;
737
  "wholerow"
738
  ]
739
  });
740
- <?php endif ?>
741
 
742
  jQuery('#jstree_files_container').jstree({
743
  'core': {
15
  <li><a href="#backup_options"
16
  class="nav-tab col s12 m3 l2 nav-tab-active"><?php echo esc_html($tab) . ". " . __('Backup Options', 'xcloner-backup-and-restore') ?></a>
17
  </li>
18
+ <li>
19
+ <a href="#database_options" class="nav-tab col s12 m3 l2 ">
20
+ <?php echo esc_html(++$tab) . ". " . __('Database Options', 'xcloner-backup-and-restore') ?>
21
+ </a>
22
+ </li>
 
 
23
  <li>
24
  <a href="#files_options" class="nav-tab col s12 m3 l2 ">
25
  <?php echo esc_html(++$tab) . ". " . __('Files Options', 'xcloner-backup-and-restore') ?>
207
 
208
  </div>
209
 
210
+ <div id="database_options" class="tab-content">
211
+ <div class="row">
212
+ <div class="input-field col s12 m10 l10 right-align">
213
+ <a class="waves-effect waves-light btn" onclick="next_tab('#files_options');"><i
214
+ class="material-icons right">skip_next</i>Next</a>
 
 
215
  </div>
216
+ </div>
217
 
218
+ <h2><?php echo __('Select database data to include in the backup', 'xcloner-backup-and-restore') ?>
219
+ :
220
+ <a class="btn-floating tooltipped btn-small" data-position="right" data-delay="50"
221
+ data-tooltip="<?php echo __('Enable the \'Backup only WP tables\' setting if you don\'t want to show all other databases and tables not related to this Wordpress install', 'xcloner-backup-and-restore'); ?>"
222
+ data-tooltip-id="">
223
+ <i class="material-icons">help_outline</i>
224
+ </a>
225
+ </h2>
226
 
227
+ <!-- database/tables tree -->
228
+ <div class="row">
229
+ <div class="col s12 l6">
230
+ <div id="jstree_database_container"></div>
 
231
  </div>
 
232
  </div>
233
+
234
+ </div>
235
 
236
  <div id="files_options" class="tab-content">
237
  <div class="row">
295
  </div>
296
  <div class="collapsible-body status-body"></div>
297
  </li>
298
+ <li class="database-backup">
299
+ <div class="collapsible-header">
300
+ <i class="material-icons">storage</i>
301
+ <?php echo __('Generating the Mysql Backup...', 'xcloner-backup-and-restore') ?>
 
302
 
303
+ <p class="right">
304
+ <?php echo sprintf(__('Found %s tables in %s databases (%s)', 'xcloner-backup-and-restore'), '<span class="table-counter">0</span>', '<span class="database-counter">0</span>', '<span data-processed="0" class="total-records">0</span> records', 'xcloner-backup-and-restore') ?>
305
+ </p>
306
 
307
+ <div>
308
+ <p class="right"><span class="last-logged-table"></span></p>
309
+ </div>
310
 
311
+ <div class="progress">
312
+ <div class="determinate" style="width:0%"></div>
 
313
  </div>
314
+ </div>
315
+ <div class="collapsible-body status-body">
316
+ <div class="row">
317
+ <div class="col l7 s12">
318
+ <ul class="logged-tables"></ul>
319
+ </div>
320
+ <div class="col l5 s12">
321
+ <ul class="logged-databases right"></ul>
322
  </div>
323
  </div>
324
+ </div>
325
+ </li>
326
  <li class="files-backup">
327
  <div class="collapsible-header">
328
  <i class="material-icons">archive</i>
510
 
511
  <div class="row">
512
  <div class="col s12 l7">
513
+ <button class="right btn waves-effect waves-light submit_schedule" type="submit"
514
+ name="action">
515
  <?php echo __("Save Schedule", 'xcloner-backup-and-restore') ?>
516
  <i class="material-icons right">send</i>
517
  </button>
688
  }
689
  });
690
 
 
691
  jQuery('#jstree_database_container').jstree({
692
  'core': {
693
  'check_callback': true,
731
  "wholerow"
732
  ]
733
  });
 
734
 
735
  jQuery('#jstree_files_container').jstree({
736
  'core': {
admin/partials/xcloner_header.php CHANGED
@@ -1,5 +1,5 @@
1
  <a href="https://www.xcloner.com" target="_blank" title="XCloner.com">
2
- <img src="<? echo plugin_dir_url((__DIR__))?>/images/xcloner-logo.svg" class="xcloner-logo"
3
  alt="XCloner backup and restore plugin" />
4
  </a>
5
  <!-- Dropdown Trigger -->
1
  <a href="https://www.xcloner.com" target="_blank" title="XCloner.com">
2
+ <img src="<?php echo plugin_dir_url((__DIR__))?>/images/xcloner-logo.svg" class="xcloner-logo"
3
  alt="XCloner backup and restore plugin" />
4
  </a>
5
  <!-- Dropdown Trigger -->
lib/Xcloner.php CHANGED
@@ -479,7 +479,7 @@ class Xcloner
479
  $schedule['name'] = "pre_auto_update";
480
  $schedule['recurrence'] = "single";
481
  $schedule['excluded_files'] = json_encode($exclude_files);
482
- $schedule['table_params'] = json_encode(array("#" => array($this->get_xcloner_settings()->get_db_database())));
483
 
484
  $schedule['backup_params'] = new stdClass();
485
  $schedule['backup_params']->email_notification = get_option('admin_email');
479
  $schedule['name'] = "pre_auto_update";
480
  $schedule['recurrence'] = "single";
481
  $schedule['excluded_files'] = json_encode($exclude_files);
482
+ $schedule['table_params'] = json_encode(array("#" => array($this->get_xcloner_database()->dbname)));
483
 
484
  $schedule['backup_params'] = new stdClass();
485
  $schedule['backup_params']->email_notification = get_option('admin_email');
lib/Xcloner_Activator.php CHANGED
@@ -74,10 +74,6 @@ class Xcloner_Activator
74
  update_option('xcloner_force_tmp_path_site_root', 1);
75
  }
76
 
77
- if (get_option('xcloner_enable_mysql_backup') === false) {
78
- update_option('xcloner_enable_mysql_backup', 1);
79
- }
80
-
81
  if (get_option('xcloner_system_settings_page') === false) {
82
  update_option('xcloner_system_settings_page', 100);
83
  }
74
  update_option('xcloner_force_tmp_path_site_root', 1);
75
  }
76
 
 
 
 
 
77
  if (get_option('xcloner_system_settings_page') === false) {
78
  update_option('xcloner_system_settings_page', 100);
79
  }
lib/Xcloner_Api.php CHANGED
@@ -240,7 +240,7 @@ class Xcloner_Api
240
 
241
  if ($id === null) {
242
  $this->xcloner_database->insert(
243
- $this->xcloner_settings->get_table_prefix() . 'xcloner_scheduler',
244
  $schedule,
245
  array(
246
  '%s',
@@ -249,7 +249,7 @@ class Xcloner_Api
249
  );
250
  } else {
251
  $this->xcloner_database->update(
252
- $this->xcloner_settings->get_table_prefix() . 'xcloner_scheduler',
253
  $schedule,
254
  array('id' => $id),
255
  array(
@@ -582,13 +582,13 @@ class Xcloner_Api
582
  }
583
 
584
  foreach ($return as $database) {
585
- if ($xcloner_backup_only_wp_tables && $database['name'] != $this->xcloner_settings->get_db_database()) {
586
  continue;
587
  }
588
 
589
  $state = array();
590
 
591
- if ($database['name'] == $this->xcloner_settings->get_db_database()) {
592
  $state['selected'] = true;
593
  if ($database['num_tables'] < 25) {
594
  $state['opened'] = false;
@@ -616,12 +616,12 @@ class Xcloner_Api
616
 
617
  if ($xcloner_backup_only_wp_tables && !stristr(
618
  $table['name'],
619
- $this->xcloner_settings->get_table_prefix()
620
  )) {
621
  continue;
622
  }
623
 
624
- if (isset($database['name']) && $database['name'] == $this->xcloner_settings->get_db_database()) {
625
  $state = array('selected' => true);
626
  }
627
 
240
 
241
  if ($id === null) {
242
  $this->xcloner_database->insert(
243
+ $this->xcloner_database->prefix . 'xcloner_scheduler',
244
  $schedule,
245
  array(
246
  '%s',
249
  );
250
  } else {
251
  $this->xcloner_database->update(
252
+ $this->xcloner_database->prefix . 'xcloner_scheduler',
253
  $schedule,
254
  array('id' => $id),
255
  array(
582
  }
583
 
584
  foreach ($return as $database) {
585
+ if ($xcloner_backup_only_wp_tables && $database['name'] != $this->xcloner_database->dbname) {
586
  continue;
587
  }
588
 
589
  $state = array();
590
 
591
+ if ($database['name'] == $this->xcloner_database->dbname) {
592
  $state['selected'] = true;
593
  if ($database['num_tables'] < 25) {
594
  $state['opened'] = false;
616
 
617
  if ($xcloner_backup_only_wp_tables && !stristr(
618
  $table['name'],
619
+ $this->xcloner_database->prefix
620
  )) {
621
  continue;
622
  }
623
 
624
+ if (isset($database['name']) && $database['name'] == $this->xcloner_database->dbname) {
625
  $state = array('selected' => true);
626
  }
627
 
lib/Xcloner_Database.php CHANGED
@@ -35,22 +35,13 @@ class Xcloner_Database extends wpdb
35
  {
36
  public $debug = 0;
37
  public $recordsPerSession = 10000;
38
- public $dbCompatibility = "";
39
  public $dbDropSyntax = 1;
40
  public $countRecords = 0;
41
 
42
- private $link;
43
- private $db_selected;
44
  private $logger;
45
  private $xcloner_settings;
46
  private $fs;
47
 
48
- private $xcloner_dbhost;
49
- private $xcloner_dbuser;
50
- private $xcloner_dbpassword;
51
- private $xcloner_dbname;
52
- private $xcloner_prefix;
53
-
54
  private $TEMP_DBPROCESS_FILE = ".database";
55
  private $TEMP_DUMP_FILE = "database-backup.sql";
56
 
@@ -68,56 +59,10 @@ class Xcloner_Database extends wpdb
68
  $this->recordsPerSession = 100;
69
  }
70
 
71
- $this->xcloner_dbhost = $this->xcloner_settings->get_db_hostname();
72
- $this->xcloner_dbuser = $this->xcloner_settings->get_db_username();
73
- $this->xcloner_dbpassword = $this->xcloner_settings->get_db_password();
74
- $this->xcloner_dbname = $this->xcloner_settings->get_db_database();
75
- $this->xcloner_prefix= "";
76
-
77
- //fetch the default wordpress mysql credentials
78
- if ( !$this->xcloner_dbuser || !$this->xcloner_dbhost || !$this->xcloner_dbname ) {
79
- global $wpdb;
80
-
81
- $this->xcloner_dbhost = $wpdb->dbhost;
82
- update_option('xcloner_mysql_hostname', $this->xcloner_dbhost);
83
- $this->xcloner_dbuser = $wpdb->dbuser;
84
- update_option('xcloner_mysql_username', $this->xcloner_dbuser);
85
- $this->xcloner_dbpassword = $wpdb->dbpassword;
86
- update_option('xcloner_mysql_password', $this->xcloner_dbpassword);
87
- $this->xcloner_dbname = $wpdb->dbname;
88
- update_option('xcloner_mysql_database', $this->xcloner_dbname);
89
- $this->xcloner_prefix = $wpdb->prefix;
90
- update_option('xcloner_mysql_prefix', $this->xcloner_prefix);
91
-
92
- }
93
-
94
- parent::__construct($this->xcloner_dbuser, $this->xcloner_dbpassword, $this->xcloner_dbname, $this->xcloner_dbhost);
95
-
96
- //$this->use_mysqli = true;
97
- }
98
-
99
- public function getPrefix() {
100
- return $this->xcloner_prefix;
101
- }
102
-
103
- public function getDbHost()
104
- {
105
- return $this->xcloner_dbhost;
106
- }
107
-
108
- public function getDbUser()
109
- {
110
- return $this->xcloner_dbuser;
111
- }
112
-
113
- public function getDbPassword()
114
- {
115
- return $this->xcloner_dbpassword;
116
- }
117
 
118
- public function getDbName()
119
- {
120
- return $this->xcloner_dbname;
121
  }
122
 
123
  /*
@@ -154,11 +99,6 @@ class Xcloner_Database extends wpdb
154
  "database_count"=>0,
155
  );
156
 
157
- if (!$this->xcloner_settings->get_enable_mysql_backup()) {
158
- $return['finished'] = 1;
159
- return $return;
160
- }
161
-
162
  $this->logger->debug(__("Starting database backup process"));
163
 
164
  $this->init($params, $init);
35
  {
36
  public $debug = 0;
37
  public $recordsPerSession = 10000;
 
38
  public $dbDropSyntax = 1;
39
  public $countRecords = 0;
40
 
 
 
41
  private $logger;
42
  private $xcloner_settings;
43
  private $fs;
44
 
 
 
 
 
 
 
45
  private $TEMP_DBPROCESS_FILE = ".database";
46
  private $TEMP_DUMP_FILE = "database-backup.sql";
47
 
59
  $this->recordsPerSession = 100;
60
  }
61
 
62
+ global $wpdb;
63
+ $this->set_prefix($wpdb->prefix);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
+ parent::__construct($wpdb->dbuser, $wpdb->dbpassword, $wpdb->dbname, $wpdb->dbhost);
 
 
66
  }
67
 
68
  /*
99
  "database_count"=>0,
100
  );
101
 
 
 
 
 
 
102
  $this->logger->debug(__("Starting database backup process"));
103
 
104
  $this->init($params, $init);
lib/Xcloner_Restore.php CHANGED
@@ -315,7 +315,7 @@ class Xcloner_Restore
315
 
316
  global $wpdb;
317
 
318
- $wpdb->select($this->xcloner_container->get_xcloner_settings()->get_db_database());
319
 
320
  $wpdb->hide_errors();
321
  if ($result = $wpdb->get_var("SELECT count(*) FROM " . $wpdb->prefix . "usermeta2")) {
315
 
316
  global $wpdb;
317
 
318
+ $wpdb->select($wpdb->dbname);
319
 
320
  $wpdb->hide_errors();
321
  if ($result = $wpdb->get_var("SELECT count(*) FROM " . $wpdb->prefix . "usermeta2")) {
lib/Xcloner_Scheduler.php CHANGED
@@ -23,7 +23,7 @@ class Xcloner_Scheduler
23
 
24
  $this->xcloner_container->get_xcloner_database()->show_errors = false;
25
 
26
- $this->scheduler_table = $this->xcloner_container->get_xcloner_settings()->get_table_prefix() . $this->scheduler_table;
27
  }
28
 
29
  public function get_scheduler_list($return_only_enabled = 0)
23
 
24
  $this->xcloner_container->get_xcloner_database()->show_errors = false;
25
 
26
+ $this->scheduler_table = $this->xcloner_container->get_xcloner_database()->prefix . $this->scheduler_table;
27
  }
28
 
29
  public function get_scheduler_list($return_only_enabled = 0)
lib/Xcloner_Settings.php CHANGED
@@ -257,64 +257,6 @@ class Xcloner_Settings
257
  return "backup_[domain]".(isset($data['port']) ? "_".$data['port'] : "")."-[time]-".($this->get_enable_mysql_backup() ? "sql" : "nosql");
258
  }
259
 
260
- /**
261
- * Get Database Hostname
262
- *
263
- */
264
- public function get_db_hostname()
265
- {
266
- if (!$data = $this->get_xcloner_option('xcloner_mysql_hostname')) {
267
- // $data = $this->xcloner_database->getDbHost();
268
- }
269
-
270
- return $data;
271
- }
272
-
273
- /**
274
- * Get Database Username
275
- *
276
- */
277
- public function get_db_username()
278
- {
279
- if (!$data = $this->get_xcloner_option('xcloner_mysql_username')) {
280
- //$data = $this->xcloner_database->getDbUser();
281
- }
282
-
283
- return $data;
284
- }
285
-
286
- /**
287
- * Get Database Password
288
- *
289
- */
290
- public function get_db_password()
291
- {
292
- if (!$data = $this->get_xcloner_option('xcloner_mysql_password')) {
293
- //$data = $this->xcloner_database->getDbPassword();
294
- }
295
-
296
- return $data;
297
- }
298
-
299
- /**
300
- * Get Database Name
301
- *
302
- */
303
- public function get_db_database()
304
- {
305
- return $this->get_xcloner_option('xcloner_mysql_database');
306
- }
307
-
308
- /**
309
- * Get Database Tables Prefix
310
- *
311
- * @return string
312
- */
313
- public function get_table_prefix()
314
- {
315
- return $this->get_xcloner_option('xcloner_mysql_prefix');
316
- }
317
-
318
  /**
319
  * @param string $option
320
  */
@@ -342,11 +284,6 @@ class Xcloner_Settings
342
 
343
  public function settings_init()
344
  {
345
- //ADDING MISSING OPTIONS
346
- if (!$this->get_xcloner_option('xcloner_mysql_settings_page')) {
347
- update_option('xcloner_mysql_settings_page', '');
348
- }
349
-
350
  if (!$this->get_xcloner_option('xcloner_cron_settings_page')) {
351
  update_option('xcloner_cron_settings_page', '');
352
  }
@@ -368,13 +305,6 @@ class Xcloner_Settings
368
  array($this, 'xcloner_settings_section_cb'),
369
  'xcloner_settings_page'
370
  );
371
- //MYSQL section
372
- add_settings_section(
373
- 'xcloner_mysql_settings_group',
374
- __(' '),
375
- array($this, 'xcloner_settings_section_cb'),
376
- 'xcloner_mysql_settings_page'
377
- );
378
 
379
  //SYSTEM section
380
  add_settings_section(
@@ -526,126 +456,6 @@ class Xcloner_Settings
526
  )
527
  );
528
 
529
- //REGISTERING THE 'MYSQL SECTION' FIELDS
530
- register_setting('xcloner_mysql_settings_group', 'xcloner_enable_mysql_backup', array(
531
- $this->xcloner_sanitization,
532
- "sanitize_input_as_int"
533
- ));
534
- add_settings_field(
535
- 'xcloner_enable_mysql_backup',
536
- __('Enable Mysql Backup', 'xcloner-backup-and-restore'),
537
- array($this, 'do_form_switch_field'),
538
- 'xcloner_mysql_settings_page',
539
- 'xcloner_mysql_settings_group',
540
- array(
541
- 'xcloner_enable_mysql_backup',
542
- __('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.', 'xcloner-backup-and-restore')
543
- )
544
- );
545
-
546
- register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables');
547
- add_settings_field(
548
- 'xcloner_backup_only_wp_tables',
549
- __('Backup only WP tables', 'xcloner-backup-and-restore'),
550
- array($this, 'do_form_switch_field'),
551
- 'xcloner_mysql_settings_page',
552
- 'xcloner_mysql_settings_group',
553
- array(
554
- 'xcloner_backup_only_wp_tables',
555
- sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix', 'xcloner-backup-and-restore'), $this->get_table_prefix())
556
- )
557
- );
558
-
559
- register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array(
560
- $this->xcloner_sanitization,
561
- "sanitize_input_as_raw"
562
- ));
563
- add_settings_field(
564
- 'xcloner_mysql_hostname',
565
- __('Mysql Hostname', 'xcloner-backup-and-restore'),
566
- array($this, 'do_form_text_field'),
567
- 'xcloner_mysql_settings_page',
568
- 'xcloner_mysql_settings_group',
569
- array(
570
- 'xcloner_mysql_hostname',
571
- __('Wordpress mysql hostname', 'xcloner-backup-and-restore'),
572
- $this->get_db_hostname(),
573
- //'disabled'
574
- )
575
- );
576
-
577
- register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array(
578
- $this->xcloner_sanitization,
579
- "sanitize_input_as_raw"
580
- ));
581
- add_settings_field(
582
- 'xcloner_mysql_username',
583
- __('Mysql Username', 'xcloner-backup-and-restore'),
584
- array($this, 'do_form_text_field'),
585
- 'xcloner_mysql_settings_page',
586
- 'xcloner_mysql_settings_group',
587
- array(
588
- 'xcloner_mysql_username',
589
- __('Wordpress mysql username', 'xcloner-backup-and-restore'),
590
- $this->get_db_username(),
591
- //'disabled'
592
- )
593
- );
594
-
595
- register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_password', array(
596
- $this->xcloner_sanitization,
597
- "sanitize_input_as_raw"
598
- ));
599
- add_settings_field(
600
- 'xcloner_mysql_password',
601
- __('Mysql Password', 'xcloner-backup-and-restore'),
602
- array($this, 'do_form_password_field'),
603
- 'xcloner_mysql_settings_page',
604
- 'xcloner_mysql_settings_group',
605
- array(
606
- 'xcloner_mysql_password',
607
- __('Wordpress mysql password', 'xcloner-backup-and-restore'),
608
- $this->get_db_password(),
609
- //'disabled'
610
- )
611
- );
612
-
613
- register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array(
614
- $this->xcloner_sanitization,
615
- "sanitize_input_as_raw"
616
- ));
617
- add_settings_field(
618
- 'xcloner_mysql_database',
619
- __('Mysql Database', 'xcloner-backup-and-restore'),
620
- array($this, 'do_form_text_field'),
621
- 'xcloner_mysql_settings_page',
622
- 'xcloner_mysql_settings_group',
623
- array(
624
- 'xcloner_mysql_database',
625
- __('Wordpress mysql database', 'xcloner-backup-and-restore'),
626
- $this->get_db_database(),
627
- //'disabled'
628
- )
629
- );
630
-
631
- register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_prefix', array(
632
- $this->xcloner_sanitization,
633
- "sanitize_input_as_raw"
634
- ));
635
- add_settings_field(
636
- 'xcloner_mysql_prefix',
637
- __('Mysql Tables Prefix', 'xcloner-backup-and-restore'),
638
- array($this, 'do_form_text_field'),
639
- 'xcloner_mysql_settings_page',
640
- 'xcloner_mysql_settings_group',
641
- array(
642
- 'xcloner_mysql_prefix',
643
- __('Wordpress mysql tables prefix', 'xcloner-backup-and-restore'),
644
- $this->get_table_prefix(),
645
- //'disabled'
646
- )
647
- );
648
-
649
  //REGISTERING THE 'SYSTEM SECTION' FIELDS
650
  register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array(
651
  $this->xcloner_sanitization,
@@ -772,7 +582,7 @@ class Xcloner_Settings
772
  'xcloner_system_settings_group',
773
  array(
774
  'xcloner_force_tmp_path_site_root',
775
- sprintf(__('Enable this option if you want the XCloner Temporary Path to be within your XCloner Storage Location', 'xcloner-backup-and-restore'), $this->get_table_prefix())
776
  )
777
  );
778
 
@@ -785,7 +595,7 @@ class Xcloner_Settings
785
  'xcloner_system_settings_group',
786
  array(
787
  'xcloner_disable_email_notification',
788
- sprintf(__('Enable this option if you want the XCloner to NOT send email notifications on successful backups', 'xcloner-backup-and-restore'), $this->get_table_prefix())
789
  )
790
  );
791
 
@@ -798,7 +608,7 @@ class Xcloner_Settings
798
  'xcloner_system_settings_group',
799
  array(
800
  'xcloner_restore_defaults',
801
- sprintf(__('This option will completelly remove all existing XCloner options and set them back to a default state.', 'xcloner-backup-and-restore'), $this->get_table_prefix())
802
  )
803
  );
804
 
257
  return "backup_[domain]".(isset($data['port']) ? "_".$data['port'] : "")."-[time]-".($this->get_enable_mysql_backup() ? "sql" : "nosql");
258
  }
259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  /**
261
  * @param string $option
262
  */
284
 
285
  public function settings_init()
286
  {
 
 
 
 
 
287
  if (!$this->get_xcloner_option('xcloner_cron_settings_page')) {
288
  update_option('xcloner_cron_settings_page', '');
289
  }
305
  array($this, 'xcloner_settings_section_cb'),
306
  'xcloner_settings_page'
307
  );
 
 
 
 
 
 
 
308
 
309
  //SYSTEM section
310
  add_settings_section(
456
  )
457
  );
458
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459
  //REGISTERING THE 'SYSTEM SECTION' FIELDS
460
  register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array(
461
  $this->xcloner_sanitization,
582
  'xcloner_system_settings_group',
583
  array(
584
  'xcloner_force_tmp_path_site_root',
585
+ __('Enable this option if you want the XCloner Temporary Path to be within your XCloner Storage Location', 'xcloner-backup-and-restore')
586
  )
587
  );
588
 
595
  'xcloner_system_settings_group',
596
  array(
597
  'xcloner_disable_email_notification',
598
+ __('Enable this option if you want the XCloner to NOT send email notifications on successful backups', 'xcloner-backup-and-restore')
599
  )
600
  );
601
 
608
  'xcloner_system_settings_group',
609
  array(
610
  'xcloner_restore_defaults',
611
+ __('This option will completelly remove all existing XCloner options and set them back to a default state.', 'xcloner-backup-and-restore')
612
  )
613
  );
614
 
lib/Xcloner_cli.php ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Watchfulli\XClonerCore;
4
+
5
+ use Exception;
6
+ use splitbrain\PHPArchive\ArchiveIllegalCompressionException;
7
+ use splitbrain\PHPArchive\ArchiveIOException;
8
+
9
+ class Xcloner_cli
10
+ {
11
+ private $argv;
12
+
13
+ public function __construct($argv) {
14
+ $this->argv = $argv;
15
+ }
16
+
17
+ public function shouldRun() {
18
+ if (php_sapi_name() !== 'cli') {
19
+ return false;
20
+ }
21
+
22
+ if (defined('WP_CLI') && WP_CLI === true) {
23
+ return true;
24
+ }
25
+
26
+ if (isset($this->argv) && basename($this->argv[0]) === 'xcloner.php') {
27
+ return true;
28
+ }
29
+
30
+ return false;
31
+ }
32
+
33
+
34
+ /**
35
+ * @throws ArchiveIllegalCompressionException
36
+ * @throws ArchiveIOException
37
+ */
38
+ public function run($argv = array(), $opts = array())
39
+ {
40
+ if (!$this->shouldRun()) {
41
+ return;
42
+ }
43
+
44
+ if (defined('WP_CLI') && WP_CLI === true) {
45
+ $this->do_wp_cli_execution();
46
+ return;
47
+ }
48
+
49
+ $this->do_cli_execution($argv);
50
+ }
51
+
52
+ private function do_wp_cli_execution()
53
+ {
54
+ \WP_CLI::add_command(
55
+ 'xcloner_generate_backup',
56
+ /**
57
+ * XCloner Generate backup based on supplied profile Name or ID
58
+ *
59
+ * [--profile=<profile>]
60
+ * : backup profile name or id
61
+ *
62
+ * [--encrypt=<backup_name>]
63
+ * : encrypt backup archive
64
+ *
65
+ * [--decrypt=<backup_name>]
66
+ * : decrypt backup archive
67
+ *
68
+ * [--key=<encryption_key>]
69
+ * : custom encryption/decryption key
70
+ *
71
+ * [--list=<backup_name>]
72
+ * : list backup archive contents
73
+ *
74
+ * @when before_wp_load
75
+ */
76
+ function ($args, $assoc_args) {
77
+ if (\WP_CLI::get_config('quiet')) {
78
+ $assoc_args['quiet'] = true;
79
+ }
80
+ $this->argv = $args;
81
+ $this->do_cli_execution($assoc_args);
82
+ }
83
+ );
84
+ }
85
+
86
+ /**
87
+ * Execute xcloner in CLI mode
88
+ *
89
+ * @param array $opts
90
+ * @return void
91
+ * @throws ArchiveIOException
92
+ * @throws ArchiveIllegalCompressionException
93
+ * @throws Exception
94
+ */
95
+ private function do_cli_execution($opts = array())
96
+ {
97
+ if (!sizeof($opts)) {
98
+ $opts = getopt('v::p:h::q::e:d:k:l:', array('verbose::', 'profile:', 'help::', 'quiet::', 'encrypt:', 'decrypt:', 'key:', 'list:'));
99
+ }
100
+
101
+ if (!sizeof($opts)) {
102
+ $opts['h'] = true;
103
+ }
104
+
105
+ if (isset($opts['h']) || isset($opts['help'])) {
106
+ echo "-h Display help\n";
107
+ echo "-p <profile name> Specify the backup profile name or ID\n";
108
+ echo "-e <backup name> Encrypt backup file\n";
109
+ echo "-d <backup name> Decrypt backup file\n";
110
+ echo "-k <encryption key> Encryption/Decryption Key\n";
111
+ echo "-l <backup name> List files inside backup\n";
112
+ echo "-v Verbose output\n";
113
+ echo "-q Disable output\n";
114
+ return;
115
+ }
116
+
117
+ if (isset($opts['q']) || isset($opts['quiet'])) {
118
+ define('XCLONER_DISABLE_OUTPUT', true);
119
+ }
120
+
121
+ if (!defined('WP_DEBUG') && !defined('WP_DEBUG_DISPLAY')) {
122
+ define('WP_DEBUG', isset($opts['v']) || isset($opts['verbose']));
123
+ define('WP_DEBUG_DISPLAY', isset($opts['v']) || isset($opts['verbose']));
124
+ }
125
+
126
+ $wp_load_path = XCLONER_PLUGIN_DIR . '/../../../wp-load.php';
127
+ if (!file_exists($wp_load_path)) {
128
+ throw new Exception('Can\'t find WordPress load file (wp-load.php)');
129
+ }
130
+
131
+ require_once($wp_load_path);
132
+
133
+ $profile = [
134
+ 'id' => 0
135
+ ];
136
+
137
+ $profile_name = "";
138
+
139
+ // --profile|p profile name
140
+ if (isset($opts['p']) && $opts['p']) {
141
+ $profile_name = $opts['p'];
142
+ } elseif (isset($opts['profile']) && $opts['profile']) {
143
+ $profile_name = $opts['profile'];
144
+ }
145
+
146
+ $xcloner_backup = new Xcloner();
147
+
148
+ // --list|l list backup archive
149
+ if (isset($opts['l']) || isset($opts['list'])) {
150
+ $backup_file_path = $opts['list'] . $opts['l'];
151
+
152
+ // function to list backup content recursively
153
+ $list_backup_archive_contents = function ($backup_name, $start = 0) use ($xcloner_backup) {
154
+ $xcloner_settings = $xcloner_backup->get_xcloner_settings();
155
+ $xcloner_file_system = $xcloner_backup->get_xcloner_filesystem();
156
+
157
+ if ($xcloner_backup->get_xcloner_encryption()->is_encrypted_file($backup_name)) {
158
+ die(sprintf("%s file is encrypted, please decrypt it first! \n", $backup_name));
159
+ }
160
+
161
+ $tar = $xcloner_backup->get_archive_system();
162
+
163
+ $backup_parts = [$backup_name];
164
+
165
+ if ($xcloner_file_system->is_multipart($backup_name)) {
166
+ $backup_parts = $xcloner_file_system->get_multipart_files($backup_name);
167
+ }
168
+
169
+ foreach ($backup_parts as $backup_name) {
170
+ if (!$start) {
171
+ echo sprintf("Processing %s \n", $backup_name);
172
+ }
173
+ $tar->open($xcloner_settings->get_xcloner_store_path() . DS . $backup_name, $start);
174
+
175
+ $data = $tar->contents($xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request'));
176
+
177
+ foreach ($data['extracted_files'] as $key => $file) {
178
+ echo sprintf("%s (%s) \n", $file->getPath(), size_format($file->getSize()));
179
+ }
180
+
181
+ if (isset($data['start'])) {
182
+ call_user_func(__FUNCTION__, $backup_name, $data['start']);
183
+ }
184
+ }
185
+ };
186
+
187
+ $list_backup_archive_contents($backup_file_path);
188
+
189
+ exit;
190
+ }
191
+
192
+ // --key|k encryption key
193
+ $encryption_key = "";
194
+ if (isset($opts['k']) || isset($opts['key'])) {
195
+ $encryption_key = $opts['key'] . $opts['k'];
196
+ }
197
+
198
+ // --encrypt|e encrypt backup archive
199
+ if (isset($opts['e']) || isset($opts['encrypt'])) {
200
+ $backup_name = $opts['encrypt'] . $opts['e'];
201
+ if (!$xcloner_backup->get_xcloner_encryption()->is_encrypted_file($backup_name)) {
202
+ $xcloner_backup->get_xcloner_encryption()->encrypt_file($backup_name, "", $encryption_key, 0, 0, true, true);
203
+ } else {
204
+ die(sprintf('File %s is already encrypted\n', $backup_name));
205
+ }
206
+ }
207
+
208
+ // --decrypt|d decrypt backup archive
209
+ if (isset($opts['d']) || isset($opts['decrypt'])) {
210
+ $backup_name = $opts['decrypt'] . $opts['d'];
211
+ if ($xcloner_backup->get_xcloner_encryption()->is_encrypted_file($backup_name)) {
212
+ $xcloner_backup->get_xcloner_encryption()->decrypt_file($backup_name, "", $encryption_key, 0, 0, true);
213
+ } else {
214
+ die(sprintf('File %s is already decrypted\n', $backup_name));
215
+ }
216
+ }
217
+
218
+ // start schedule based on profile name
219
+ if (!empty($profile_name)) {
220
+ try {
221
+ $profile = $xcloner_backup->get_xcloner_scheduler()->get_schedule_by_id_or_name($profile_name);
222
+ } catch (Exception $e) {
223
+ die(sprintf('Could not find profile %s', $profile_name));
224
+ }
225
+
226
+ $xcloner_backup->execute_backup($profile['id']);
227
+ }
228
+ }
229
+
230
+ }
vendor/autoload.php CHANGED
@@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
9
 
10
  require_once __DIR__ . '/composer/autoload_real.php';
11
 
12
- return ComposerAutoloaderInitfaf514c95c094bb20ad810521bbe50d4::getLoader();
9
 
10
  require_once __DIR__ . '/composer/autoload_real.php';
11
 
12
+ return ComposerAutoloaderInitc8c3673197dec48c77dad81b198f29cc::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -7622,6 +7622,7 @@ return array(
7622
  'Watchfulli\\XClonerCore\\Xcloner_Sanitization' => $baseDir . '/lib/Xcloner_Sanitization.php',
7623
  'Watchfulli\\XClonerCore\\Xcloner_Scheduler' => $baseDir . '/lib/Xcloner_Scheduler.php',
7624
  'Watchfulli\\XClonerCore\\Xcloner_Settings' => $baseDir . '/lib/Xcloner_Settings.php',
 
7625
  'Watchfulli\\XClonerCore\\Xcloner_i18n' => $baseDir . '/lib/Xcloner_i18n.php',
7626
  'org\\bovigo\\vfs\\DotDirectory' => $vendorDir . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/DotDirectory.php',
7627
  'org\\bovigo\\vfs\\Quota' => $vendorDir . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/Quota.php',
7622
  'Watchfulli\\XClonerCore\\Xcloner_Sanitization' => $baseDir . '/lib/Xcloner_Sanitization.php',
7623
  'Watchfulli\\XClonerCore\\Xcloner_Scheduler' => $baseDir . '/lib/Xcloner_Scheduler.php',
7624
  'Watchfulli\\XClonerCore\\Xcloner_Settings' => $baseDir . '/lib/Xcloner_Settings.php',
7625
+ 'Watchfulli\\XClonerCore\\Xcloner_cli' => $baseDir . '/lib/Xcloner_cli.php',
7626
  'Watchfulli\\XClonerCore\\Xcloner_i18n' => $baseDir . '/lib/Xcloner_i18n.php',
7627
  'org\\bovigo\\vfs\\DotDirectory' => $vendorDir . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/DotDirectory.php',
7628
  'org\\bovigo\\vfs\\Quota' => $vendorDir . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/Quota.php',
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInitfaf514c95c094bb20ad810521bbe50d4
6
  {
7
  private static $loader;
8
 
@@ -24,18 +24,18 @@ class ComposerAutoloaderInitfaf514c95c094bb20ad810521bbe50d4
24
 
25
  require __DIR__ . '/platform_check.php';
26
 
27
- spl_autoload_register(array('ComposerAutoloaderInitfaf514c95c094bb20ad810521bbe50d4', 'loadClassLoader'), true, true);
28
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
29
- spl_autoload_unregister(array('ComposerAutoloaderInitfaf514c95c094bb20ad810521bbe50d4', 'loadClassLoader'));
30
 
31
  require __DIR__ . '/autoload_static.php';
32
- call_user_func(\Composer\Autoload\ComposerStaticInitfaf514c95c094bb20ad810521bbe50d4::getInitializer($loader));
33
 
34
  $loader->register(true);
35
 
36
- $includeFiles = \Composer\Autoload\ComposerStaticInitfaf514c95c094bb20ad810521bbe50d4::$files;
37
  foreach ($includeFiles as $fileIdentifier => $file) {
38
- composerRequirefaf514c95c094bb20ad810521bbe50d4($fileIdentifier, $file);
39
  }
40
 
41
  return $loader;
@@ -47,7 +47,7 @@ class ComposerAutoloaderInitfaf514c95c094bb20ad810521bbe50d4
47
  * @param string $file
48
  * @return void
49
  */
50
- function composerRequirefaf514c95c094bb20ad810521bbe50d4($fileIdentifier, $file)
51
  {
52
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
53
  $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInitc8c3673197dec48c77dad81b198f29cc
6
  {
7
  private static $loader;
8
 
24
 
25
  require __DIR__ . '/platform_check.php';
26
 
27
+ spl_autoload_register(array('ComposerAutoloaderInitc8c3673197dec48c77dad81b198f29cc', 'loadClassLoader'), true, true);
28
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
29
+ spl_autoload_unregister(array('ComposerAutoloaderInitc8c3673197dec48c77dad81b198f29cc', 'loadClassLoader'));
30
 
31
  require __DIR__ . '/autoload_static.php';
32
+ call_user_func(\Composer\Autoload\ComposerStaticInitc8c3673197dec48c77dad81b198f29cc::getInitializer($loader));
33
 
34
  $loader->register(true);
35
 
36
+ $includeFiles = \Composer\Autoload\ComposerStaticInitc8c3673197dec48c77dad81b198f29cc::$files;
37
  foreach ($includeFiles as $fileIdentifier => $file) {
38
+ composerRequirec8c3673197dec48c77dad81b198f29cc($fileIdentifier, $file);
39
  }
40
 
41
  return $loader;
47
  * @param string $file
48
  * @return void
49
  */
50
+ function composerRequirec8c3673197dec48c77dad81b198f29cc($fileIdentifier, $file)
51
  {
52
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
53
  $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInitfaf514c95c094bb20ad810521bbe50d4
8
  {
9
  public static $files = array (
10
  '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
@@ -7899,6 +7899,7 @@ class ComposerStaticInitfaf514c95c094bb20ad810521bbe50d4
7899
  'Watchfulli\\XClonerCore\\Xcloner_Sanitization' => __DIR__ . '/../..' . '/lib/Xcloner_Sanitization.php',
7900
  'Watchfulli\\XClonerCore\\Xcloner_Scheduler' => __DIR__ . '/../..' . '/lib/Xcloner_Scheduler.php',
7901
  'Watchfulli\\XClonerCore\\Xcloner_Settings' => __DIR__ . '/../..' . '/lib/Xcloner_Settings.php',
 
7902
  'Watchfulli\\XClonerCore\\Xcloner_i18n' => __DIR__ . '/../..' . '/lib/Xcloner_i18n.php',
7903
  'org\\bovigo\\vfs\\DotDirectory' => __DIR__ . '/..' . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/DotDirectory.php',
7904
  'org\\bovigo\\vfs\\Quota' => __DIR__ . '/..' . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/Quota.php',
@@ -7957,10 +7958,10 @@ class ComposerStaticInitfaf514c95c094bb20ad810521bbe50d4
7957
  public static function getInitializer(ClassLoader $loader)
7958
  {
7959
  return \Closure::bind(function () use ($loader) {
7960
- $loader->prefixLengthsPsr4 = ComposerStaticInitfaf514c95c094bb20ad810521bbe50d4::$prefixLengthsPsr4;
7961
- $loader->prefixDirsPsr4 = ComposerStaticInitfaf514c95c094bb20ad810521bbe50d4::$prefixDirsPsr4;
7962
- $loader->prefixesPsr0 = ComposerStaticInitfaf514c95c094bb20ad810521bbe50d4::$prefixesPsr0;
7963
- $loader->classMap = ComposerStaticInitfaf514c95c094bb20ad810521bbe50d4::$classMap;
7964
 
7965
  }, null, ClassLoader::class);
7966
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInitc8c3673197dec48c77dad81b198f29cc
8
  {
9
  public static $files = array (
10
  '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
7899
  'Watchfulli\\XClonerCore\\Xcloner_Sanitization' => __DIR__ . '/../..' . '/lib/Xcloner_Sanitization.php',
7900
  'Watchfulli\\XClonerCore\\Xcloner_Scheduler' => __DIR__ . '/../..' . '/lib/Xcloner_Scheduler.php',
7901
  'Watchfulli\\XClonerCore\\Xcloner_Settings' => __DIR__ . '/../..' . '/lib/Xcloner_Settings.php',
7902
+ 'Watchfulli\\XClonerCore\\Xcloner_cli' => __DIR__ . '/../..' . '/lib/Xcloner_cli.php',
7903
  'Watchfulli\\XClonerCore\\Xcloner_i18n' => __DIR__ . '/../..' . '/lib/Xcloner_i18n.php',
7904
  'org\\bovigo\\vfs\\DotDirectory' => __DIR__ . '/..' . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/DotDirectory.php',
7905
  'org\\bovigo\\vfs\\Quota' => __DIR__ . '/..' . '/mikey179/vfsstream/src/main/php/org/bovigo/vfs/Quota.php',
7958
  public static function getInitializer(ClassLoader $loader)
7959
  {
7960
  return \Closure::bind(function () use ($loader) {
7961
+ $loader->prefixLengthsPsr4 = ComposerStaticInitc8c3673197dec48c77dad81b198f29cc::$prefixLengthsPsr4;
7962
+ $loader->prefixDirsPsr4 = ComposerStaticInitc8c3673197dec48c77dad81b198f29cc::$prefixDirsPsr4;
7963
+ $loader->prefixesPsr0 = ComposerStaticInitc8c3673197dec48c77dad81b198f29cc::$prefixesPsr0;
7964
+ $loader->classMap = ComposerStaticInitc8c3673197dec48c77dad81b198f29cc::$classMap;
7965
 
7966
  }, null, ClassLoader::class);
7967
  }
vendor/composer/installed.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php return array(
2
  'root' => array(
3
  'name' => 'watchfulli/xcloner-wordpress',
4
- 'pretty_version' => 'v4.4.4',
5
- 'version' => '4.4.4.0',
6
- 'reference' => 'd4aac816e6c4263451b2510bf01d8fc2281ec576',
7
  'type' => 'library',
8
  'install_path' => __DIR__ . '/../../',
9
  'aliases' => array(),
@@ -404,9 +404,9 @@
404
  'dev_requirement' => false,
405
  ),
406
  'watchfulli/xcloner-wordpress' => array(
407
- 'pretty_version' => 'v4.4.4',
408
- 'version' => '4.4.4.0',
409
- 'reference' => 'd4aac816e6c4263451b2510bf01d8fc2281ec576',
410
  'type' => 'library',
411
  'install_path' => __DIR__ . '/../../',
412
  'aliases' => array(),
1
  <?php return array(
2
  'root' => array(
3
  'name' => 'watchfulli/xcloner-wordpress',
4
+ 'pretty_version' => 'v4.4.5',
5
+ 'version' => '4.4.5.0',
6
+ 'reference' => '1acbb1dc902f75b5904ee5cbace46f5d63bf027a',
7
  'type' => 'library',
8
  'install_path' => __DIR__ . '/../../',
9
  'aliases' => array(),
404
  'dev_requirement' => false,
405
  ),
406
  'watchfulli/xcloner-wordpress' => array(
407
+ 'pretty_version' => 'v4.4.5',
408
+ 'version' => '4.4.5.0',
409
+ 'reference' => '1acbb1dc902f75b5904ee5cbace46f5d63bf027a',
410
  'type' => 'library',
411
  'install_path' => __DIR__ . '/../../',
412
  'aliases' => array(),
xcloner.php CHANGED
@@ -15,7 +15,7 @@
15
  * Plugin Name: XCloner - Site Backup and Restore
16
  * Plugin URI: https://xcloner.com/
17
  * Description: XCloner is a tool that will help you manage your website backups, generate/restore/move so your website will be always secured! With XCloner you will be able to clone your site to any other location with just a few clicks, as well as transfer the backup archives to remote FTP, SFTP, DropBox, Amazon S3, Google Drive, WebDAV, Backblaze, Azure accounts.
18
- * Version: 4.4.4
19
  * Author: watchful
20
  * Author URI: https://watchful.net/
21
  * License: GPL-2.0+
@@ -23,26 +23,35 @@
23
  * Text Domain: xcloner-backup-and-restore
24
  * Domain Path: /languages
25
  */
 
26
 
27
- // If this file is called directly, abort.
28
- if (!defined('WPINC')) {
29
- die;
30
- }
31
 
32
  if (!defined("DS")) {
33
  define("DS", DIRECTORY_SEPARATOR);
34
  }
35
 
36
  if (!defined("XCLONER_PLUGIN_DIR")) {
37
- define("XCLONER_PLUGIN_DIR", plugin_dir_path(__FILE__));
38
  }
39
 
40
- // composer library autoload
41
- require_once(__DIR__ . '/vendor/autoload.php');
 
 
 
 
 
 
 
42
 
43
- use Watchfulli\XClonerCore\Xcloner_Activator;
44
- use Watchfulli\XClonerCore\Xcloner_Deactivator;
45
- use Watchfulli\XClonerCore\Xcloner;
 
46
 
47
 
48
  if (function_exists('register_activation_hook')) {
@@ -70,191 +79,7 @@ if (version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<
70
  }
71
 
72
 
73
- /**
74
- * Execute xcloner in CLI mode
75
- *
76
- * @param array $args
77
- * @param array $opts
78
- * @return void
79
- */
80
- function do_cli_execution($args = array(), $opts = array())
81
- {
82
- if (!sizeof($opts)) {
83
- $opts = getopt('v::p:h::q::e:d:k:l:', array('verbose::', 'profile:', 'help::', 'quiet::', 'encrypt:', 'decrypt:', 'key:', 'list:'));
84
- }
85
-
86
- if (!sizeof($opts)) {
87
- $opts['h'] = true;
88
- }
89
-
90
- if (isset($opts['h']) || isset($opts['help'])) {
91
- echo sprintf("-h Display help\n");
92
- echo sprintf("-p <profile name> Specify the backup profile name or ID\n");
93
- echo sprintf("-e <backup name> Encrypt backup file\n");
94
- echo sprintf("-d <backup name> Decrypt backup file\n");
95
- echo sprintf("-k <encryption key> Encryption/Decryption Key\n");
96
- echo sprintf("-l <backup name> List files inside backup\n");
97
- echo sprintf("-v Verbose output\n");
98
- echo sprintf("-q Disable output\n");
99
- return;
100
- }
101
-
102
- if (isset($opts['q']) || isset($opts['quiet'])) {
103
- define('XCLONER_DISABLE_OUTPUT', true);
104
- }
105
-
106
- if (isset($opts['v']) || isset($opts['verbose'])) {
107
- define('WP_DEBUG', true);
108
- define('WP_DEBUG_DISPLAY', true);
109
- } else {
110
- define('WP_DEBUG', false);
111
- define('WP_DEBUG_DISPLAY', false);
112
- }
113
-
114
- if (file_exists(__DIR__ . "/../../../wp-load.php")) {
115
- require_once(__DIR__ . '/../../../wp-load.php');
116
- }
117
-
118
- $profile = [
119
- 'id' => 0
120
- ];
121
-
122
- $profile_name = "";
123
-
124
- // --profile|p profile name
125
- if (isset($opts['p']) && $opts['p']) {
126
- $profile_name = $opts['p'];
127
- } elseif (isset($opts['profile']) && $opts['profile']) {
128
- $profile_name = $opts['profile'];
129
- }
130
-
131
- $xcloner_backup = new Xcloner();
132
-
133
- // --list|l list backup archive
134
- if (isset($opts['l']) || isset($opts['list'])) {
135
- $backup_file_path = $opts['list'] . $opts['l'];
136
-
137
- // function to list backup content recursively
138
- $list_backup_archive_contents = function ($backup_name, $start = 0) use ($xcloner_backup) {
139
- $xcloner_settings = $xcloner_backup->get_xcloner_settings();
140
- $xcloner_file_system = $xcloner_backup->get_xcloner_filesystem();
141
-
142
- if ($xcloner_backup->get_xcloner_encryption()->is_encrypted_file($backup_name)) {
143
- die(sprintf("%s file is encrypted, please decrypt it first! \n", $backup_name));
144
- }
145
-
146
- $tar = $xcloner_backup->get_archive_system();
147
-
148
- $backup_parts = [$backup_name];
149
-
150
- if ($xcloner_file_system->is_multipart($backup_name)) {
151
- $backup_parts = $xcloner_file_system->get_multipart_files($backup_name);
152
- }
153
-
154
- foreach ($backup_parts as $backup_name) {
155
- if (!$start) {
156
- echo sprintf("Processing %s \n", $backup_name);
157
- }
158
- $tar->open($xcloner_settings->get_xcloner_store_path() . DS . $backup_name, $start);
159
-
160
- $data = $tar->contents($xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request'));
161
-
162
- foreach ($data['extracted_files'] as $key => $file) {
163
- echo sprintf("%s (%s) \n", $file->getPath(), size_format($file->getSize()));
164
- }
165
-
166
- if (isset($data['start'])) {
167
- call_user_func(__FUNCTION__, $backup_name, $data['start']);
168
- }
169
- }
170
- };
171
-
172
- $list_backup_archive_contents($backup_file_path);
173
-
174
- exit;
175
- }
176
-
177
- // --key|k encryption key
178
- $encryption_key = "";
179
- if (isset($opts['k']) || isset($opts['key'])) {
180
- $encryption_key = $opts['key'] . $opts['k'];
181
- }
182
-
183
- // --encrypt|e encrypt backup archive
184
- if (isset($opts['e']) || isset($opts['encrypt'])) {
185
- $backup_name = $opts['encrypt'] . $opts['e'];
186
- if (!$xcloner_backup->get_xcloner_encryption()->is_encrypted_file($backup_name)) {
187
- $xcloner_backup->get_xcloner_encryption()->encrypt_file($backup_name, "", $encryption_key, 0, 0, true, true);
188
- } else {
189
- die(sprintf('File %s is already encrypted\n', $backup_name));
190
- }
191
- }
192
-
193
- // --decrypt|d decrypt backup archive
194
- if (isset($opts['d']) || isset($opts['decrypt'])) {
195
- $backup_name = $opts['decrypt'] . $opts['d'];
196
- if ($xcloner_backup->get_xcloner_encryption()->is_encrypted_file($backup_name)) {
197
- $xcloner_backup->get_xcloner_encryption()->decrypt_file($backup_name, "", $encryption_key, 0, 0, true);
198
- } else {
199
- die(sprintf('File %s is already decrypted\n', $backup_name));
200
- }
201
- }
202
-
203
- // start schedule based on profile name
204
- if (!empty($profile_name)) {
205
- try {
206
- $profile = $xcloner_backup->get_xcloner_scheduler()->get_schedule_by_id_or_name($profile_name);
207
- } catch (Exception $e) {
208
- die(sprintf('Could not find profile %s', $profile_name));
209
- }
210
-
211
- $xcloner_backup->execute_backup($profile['id']);
212
- }
213
- }
214
-
215
- $foo = function ($args, $assoc_args) {
216
- WP_CLI::success($args[0] . ' ' . $assoc_args['append']);
217
- };
218
-
219
-
220
- //detect CLI mode
221
- if (php_sapi_name() == "cli") {
222
- if (defined('WP_CLI') && WP_CLI) {
223
- WP_CLI::add_command(
224
- 'xcloner_generate_backup',
225
- /**
226
- * XCloner Generate backup based on supplied profile Name or ID
227
- *
228
- * [--profile=<profile>]
229
- * : backup profile name or id
230
- *
231
- * [--encrypt=<backup_name>]
232
- * : encrypt backup archive
233
- *
234
- * [--decrypt=<backup_name>]
235
- * : decrypt backup archive
236
- *
237
- * [--key=<encryption_key>]
238
- * : custom encryption/decryption key
239
- *
240
- * [--list=<backup_name>]
241
- * : list backup archive contents
242
- *
243
- * @when before_wp_load
244
- */
245
- function ($args, $assoc_args) {
246
- if (WP_CLI::get_config('quiet')) {
247
- $assoc_args['quiet'] = true;
248
- }
249
- do_cli_execution($args, $assoc_args);
250
- }
251
- );
252
- } elseif (isset($argv) && basename($argv[0]) == "xcloner.php") {
253
- do_cli_execution();
254
- }
255
- }
256
-
257
- //i will not load the plugin outside admin or cron
258
  if (!is_admin() && !defined('DOING_CRON')) {
259
  //Check if we are running tests before leaving
260
  if (!defined('XCLONER_TESTING')) {
@@ -275,7 +100,6 @@ if ($db_installed_ver != $xcloner_db_version) {
275
  * The core plugin class that is used to define internationalization,
276
  * admin-specific hooks, and public-facing site hooks.
277
  */
278
-
279
  function xcloner_stop_heartbeat()
280
  {
281
  wp_deregister_script('heartbeat');
@@ -310,7 +134,7 @@ function run_xcloner()
310
  }
311
 
312
  try {
313
- run_xcloner();
314
  } catch (Exception $e) {
315
  echo $e->getMessage();
316
  }
15
  * Plugin Name: XCloner - Site Backup and Restore
16
  * Plugin URI: https://xcloner.com/
17
  * Description: XCloner is a tool that will help you manage your website backups, generate/restore/move so your website will be always secured! With XCloner you will be able to clone your site to any other location with just a few clicks, as well as transfer the backup archives to remote FTP, SFTP, DropBox, Amazon S3, Google Drive, WebDAV, Backblaze, Azure accounts.
18
+ * Version: 4.4.5
19
  * Author: watchful
20
  * Author URI: https://watchful.net/
21
  * License: GPL-2.0+
23
  * Text Domain: xcloner-backup-and-restore
24
  * Domain Path: /languages
25
  */
26
+ require_once(__DIR__ . '/vendor/autoload.php');
27
 
28
+ use Watchfulli\XClonerCore\Xcloner_Activator;
29
+ use Watchfulli\XClonerCore\Xcloner_cli;
30
+ use Watchfulli\XClonerCore\Xcloner_Deactivator;
31
+ use Watchfulli\XClonerCore\Xcloner;
32
 
33
  if (!defined("DS")) {
34
  define("DS", DIRECTORY_SEPARATOR);
35
  }
36
 
37
  if (!defined("XCLONER_PLUGIN_DIR")) {
38
+ define("XCLONER_PLUGIN_DIR", dirname(__FILE__));
39
  }
40
 
41
+ $xcloner_cli = new Xcloner_cli($argv ?? []);
42
+ if ($xcloner_cli->shouldRun()) {
43
+ try {
44
+ $xcloner_cli->run();
45
+ } catch (Exception $e) {
46
+ echo $e->getMessage() . "\n";
47
+ }
48
+ return;
49
+ }
50
 
51
+ // If this file is called directly, and we're not in CLI mode, then exit.
52
+ if (!defined('WPINC')) {
53
+ die;
54
+ }
55
 
56
 
57
  if (function_exists('register_activation_hook')) {
79
  }
80
 
81
 
82
+ // Don't load the plugin outside admin or cron
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  if (!is_admin() && !defined('DOING_CRON')) {
84
  //Check if we are running tests before leaving
85
  if (!defined('XCLONER_TESTING')) {
100
  * The core plugin class that is used to define internationalization,
101
  * admin-specific hooks, and public-facing site hooks.
102
  */
 
103
  function xcloner_stop_heartbeat()
104
  {
105
  wp_deregister_script('heartbeat');
134
  }
135
 
136
  try {
137
+ run_xcloner();
138
  } catch (Exception $e) {
139
  echo $e->getMessage();
140
  }