Migration, Backup, Staging – WPvivid - Version 0.9.22

Version Description

  • Fixed: Backup created in web hosting/shared hosting optimization mode was incomplete in some cases.
  • Fixed: Backup actually failed but was reported as a success in some cases.
  • Refined error messages of migration process.
  • Added a notice to the situation where backup schedules were unusable because the WP Cron on the server was disabled.
  • Optimized the plugin code.
Download this release

Release Info

Developer wpvivid
Plugin Icon 128x128 Migration, Backup, Staging – WPvivid
Version 0.9.22
Comparing to
See all releases

Code changes from version 0.9.21 to 0.9.22

Files changed (31) hide show
  1. admin/class-wpvivid-admin.php +293 -0
  2. admin/js/wpvivid-admin.js +37 -12
  3. admin/partials/wpvivid-admin-display.php +31 -75
  4. admin/partials/wpvivid-backup-restore-page-display.php +280 -235
  5. admin/partials/wpvivid-log-read-page-display.php +0 -3
  6. admin/partials/wpvivid-logs-page-display.php +0 -45
  7. admin/partials/wpvivid-remote-storage-page-display.php +0 -18
  8. admin/partials/wpvivid-schedule-page-display.php +6 -16
  9. admin/partials/wpvivid-settings-page-display.php +0 -13
  10. admin/partials/wpvivid-website-info-page-display.php +0 -61
  11. includes/class-wpvivid-backup-database.php +20 -39
  12. includes/class-wpvivid-backup-uploader.php +116 -28
  13. includes/class-wpvivid-backup.php +123 -126
  14. includes/class-wpvivid-crypt.php +2 -0
  15. includes/class-wpvivid-function-realize.php +104 -0
  16. includes/class-wpvivid-migrate.php +885 -823
  17. includes/class-wpvivid-mysqldump.php +2 -1
  18. includes/class-wpvivid-public-interface.php +446 -0
  19. includes/class-wpvivid-schedule.php +9 -65
  20. includes/class-wpvivid-setting.php +2 -2
  21. includes/class-wpvivid-upload.php +0 -26
  22. includes/class-wpvivid-zipclass.php +18 -15
  23. includes/class-wpvivid.php +67 -50
  24. includes/customclass/class-wpvivid-amazons3-plus.php +1 -1
  25. includes/customclass/class-wpvivid-dropbox.php +1 -1
  26. includes/customclass/class-wpvivid-ftpclass.php +3 -2
  27. includes/customclass/class-wpvivid-s3compat.php +1 -1
  28. includes/customclass/class-wpvivid-send-to-site.php +2 -2
  29. includes/customclass/class-wpvivid-sftpclass.php +1 -1
  30. readme.txt +7 -1
  31. wpvivid-backuprestore.php +2 -2
admin/class-wpvivid-admin.php CHANGED
@@ -441,5 +441,298 @@ class WPvivid_Admin {
441
  if (!class_exists('PclZip')) {
442
  _e('<div class="notice notice-error"><p>Class PclZip is not detected. Please update or reinstall your WordPress.</p></div>');
443
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  }
445
  }
441
  if (!class_exists('PclZip')) {
442
  _e('<div class="notice notice-error"><p>Class PclZip is not detected. Please update or reinstall your WordPress.</p></div>');
443
  }
444
+
445
+ if(defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON){
446
+ _e('<div class="notice notice-error"><p>In order to execute the scheduled backups properly, please set the DISABLE_WP_CRON constant to false.</p></div>');
447
+ }
448
+ }
449
+
450
+ public function wpvivid_add_default_tab_page($page_array){
451
+ $page_array['backup_restore'] = array('index' => '1', 'tab_func' => array($this, 'wpvivid_add_tab_backup_restore'), 'page_func' => array($this, 'wpvivid_add_page_backup'));
452
+ $page_array['schedule'] = array('index' => '2', 'tab_func' => array($this, 'wpvivid_add_tab_schedule'), 'page_func' => array($this, 'wpvivid_add_page_schedule'));
453
+ $page_array['remote_storage'] = array('index' => '4', 'tab_func' => array($this, 'wpvivid_add_tab_remote_storage'), 'page_func' => array($this, 'wpvivid_add_page_remote_storage'));
454
+ $page_array['setting'] = array('index' => '5', 'tab_func' => array($this, 'wpvivid_add_tab_setting'), 'page_func' => array($this, 'wpvivid_add_page_setting'));
455
+ $page_array['website_info'] = array('index' => '6', 'tab_func' => array($this, 'wpvivid_add_tab_website_info'), 'page_func' => array($this, 'wpvivid_add_page_website_info'));
456
+ $page_array['log'] = array('index' => '7', 'tab_func' => array($this, 'wpvivid_add_tab_log'), 'page_func' => array($this, 'wpvivid_add_page_log'));
457
+ $page_array['read_log'] = array('index' => '9', 'tab_func' => array($this, 'wpvivid_add_tab_read_log'), 'page_func' => array($this, 'wpvivid_add_page_read_log'));
458
+ return $page_array;
459
+ }
460
+
461
+ public function wpvivid_add_tab_backup_restore(){
462
+ ?>
463
+ <a href="#" id="wpvivid_tab_general" class="nav-tab wrap-nav-tab nav-tab-active" onclick="switchTabs(event,'general-page')"><?php _e('Backup & Restore', 'wpvivid'); ?></a>
464
+ <?php
465
+ }
466
+
467
+ public function wpvivid_add_tab_schedule(){
468
+ ?>
469
+ <a href="#" id="wpvivid_tab_schedule" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,'schedule-page')"><?php _e('Schedule', 'wpvivid'); ?></a>
470
+ <?php
471
+ }
472
+
473
+ public function wpvivid_add_tab_remote_storage(){
474
+ ?>
475
+ <a href="#" id="wpvivid_tab_remote_storage" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,'storage-page')"><?php _e('Remote Storage', 'wpvivid'); ?></a>
476
+ <?php
477
+ }
478
+
479
+ public function wpvivid_add_tab_setting(){
480
+ ?>
481
+ <a href="#" id="wpvivid_tab_setting" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,'settings-page')"><?php _e('Settings', 'wpvivid'); ?></a>
482
+ <?php
483
+ }
484
+
485
+ public function wpvivid_add_tab_website_info(){
486
+ ?>
487
+ <a href="#" id="wpvivid_tab_debug" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,'debug-page')"><?php _e('Website Info', 'wpvivid'); ?></a>
488
+ <?php
489
+ }
490
+
491
+ public function wpvivid_add_tab_log(){
492
+ ?>
493
+ <a href="#" id="wpvivid_tab_log" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,'logs-page')"><?php _e('Logs', 'wpvivid'); ?></a>
494
+ <?php
495
+ }
496
+
497
+ public function wpvivid_add_tab_read_log(){
498
+ ?>
499
+ <a href="#" id="wpvivid_tab_read_log" class="nav-tab wrap-nav-tab delete" onclick="switchTabs(event,'log-read-page')" style="display: none;">
500
+ <div style="margin-right: 15px;"><?php _e('Log', 'wpvivid'); ?></div>
501
+ <div class="nav-tab-delete-img">
502
+ <img src="<?php echo esc_url( WPVIVID_PLUGIN_URL.'/admin/partials/images/delete-tab.png' ); ?>" style="vertical-align:middle; cursor:pointer;" onclick="wpvivid_close_tab(event, 'wpvivid_tab_read_log', 'wrap', 'wpvivid_tab_log');" />
503
+ </div>
504
+ </a>
505
+ <?php
506
+ }
507
+
508
+ public function wpvivid_add_page_backup(){
509
+ $html_progress = '';
510
+ $html_backup = '';
511
+ $html_schedule = '';
512
+ ?>
513
+ <div id="general-page" class="wrap-tab-content wpvivid_tab_general" name="tab-backup" style="width:100%;">
514
+ <div class="meta-box-sortables ui-sortable">
515
+ <?php
516
+ echo apply_filters('wpvivid_backuppage_load_progress_module', $html_progress);
517
+ echo apply_filters('wpvivid_backuppage_load_backup_module', $html_backup);
518
+ echo apply_filters('wpvivid_backuppage_load_schedule_module', $html_schedule);
519
+ ?>
520
+ <h2 class="nav-tab-wrapper" id="wpvivid_backup_tab" style="padding-bottom:0!important;">
521
+ <?php
522
+ $backuplist_array = array();
523
+ $backuplist_array = apply_filters('wpvivid_backuppage_load_backuplist', $backuplist_array);
524
+ foreach ($backuplist_array as $list_name) {
525
+ add_action('wpvivid_backuppage_add_tab', $list_name['tab_func'], $list_name['index']);
526
+ add_action('wpvivid_backuppage_add_page', $list_name['page_func'], $list_name['index']);
527
+ }
528
+ do_action('wpvivid_backuppage_add_tab');
529
+ ?>
530
+ </h2>
531
+ <?php do_action('wpvivid_backuppage_add_page'); ?>
532
+ </div>
533
+ </div>
534
+ <script>
535
+ <?php do_action('wpvivid_backup_do_js'); ?>
536
+ </script>
537
+ <?php
538
+ }
539
+
540
+ public function wpvivid_add_page_schedule(){
541
+ ?>
542
+ <div id="schedule-page" class="wrap-tab-content wpvivid_tab_schedule" name="tab-schedule" style="display: none;">
543
+ <div>
544
+ <table class="widefat">
545
+ <tbody>
546
+ <?php do_action('wpvivid_schedule_add_cell'); ?>
547
+ <tfoot>
548
+ <tr>
549
+ <th class="row-title"><input class="button-primary storage-account-button" id="wpvivid_schedule_save" type="submit" name="" value="<?php esc_attr_e( 'Save Changes', 'wpvivid' ); ?>" /></th>
550
+ <th></th>
551
+ </tr>
552
+ </tfoot>
553
+ </tbody>
554
+ </table>
555
+ </div>
556
+ </div>
557
+ <?php
558
+ }
559
+
560
+ public function wpvivid_add_page_remote_storage(){
561
+ ?>
562
+ <div id="storage-page" class="wrap-tab-content wpvivid_tab_remote_storage" name="tab-storage" style="display:none;">
563
+ <div>
564
+ <div class="storage-content" id="storage-brand-2" style="">
565
+ <div class="postbox">
566
+ <?php do_action('wpvivid_add_storage_tab'); ?>
567
+ </div>
568
+ <div class="postbox storage-account-block" id="wpvivid_storage_account_block">
569
+ <?php do_action('wpvivid_add_storage_page'); ?>
570
+ </div>
571
+ <?php
572
+ $html = '';
573
+ $html = apply_filters('wpvivid_storage_list', $html);
574
+ echo $html;
575
+ ?>
576
+ <div class="storage-tab-content wpvivid_tab_storage_edit" id="page-storage_edit" style="display:none;">
577
+ <div><?php do_action('wpvivid_edit_remote_page'); ?></div>
578
+ </div>
579
+ </div>
580
+ </div>
581
+ </div>
582
+ <?php
583
+ }
584
+
585
+ public function wpvivid_add_page_setting(){
586
+ ?>
587
+ <div id="settings-page" class="wrap-tab-content wpvivid_tab_setting" name="tab-setting" style="display:none;">
588
+ <div>
589
+ <table class="widefat">
590
+ <tbody>
591
+ <?php do_action('wpvivid_setting_add_cell'); ?>
592
+ <tfoot>
593
+ <tr>
594
+ <th class="row-title"><input class="button-primary storage-account-button" id="wpvivid_setting_general_save" type="submit" name="" value="<?php esc_attr_e( 'Save Changes', 'wpvivid' ); ?>" /></th>
595
+ <th></th>
596
+ </tr>
597
+ </tfoot>
598
+ </tbody>
599
+ </table>
600
+ </div>
601
+ </div>
602
+ <?php
603
+ }
604
+
605
+ public function wpvivid_add_page_website_info(){
606
+ ?>
607
+ <div id="debug-page" class="wrap-tab-content wpvivid_tab_debug" name="tab-debug" style="display:none;">
608
+ <table class="widefat">
609
+ <div style="padding: 0 0 20px 10px;">There are two ways available to send us the debug information. The first one is recommended.</div>
610
+ <div style="padding-left: 10px;">
611
+ <strong><?php _e('Method 1.'); ?></strong> <?php _e('If you have configured SMTP on your site, enter your email address and click the button below to send us the relevant information (website info and errors logs) when you are encountering errors. This will help us figure out what happened. Once the issue is resolved, we will inform you by your email address.', 'wpvivid'); ?>
612
+ </div>
613
+ <div style="padding:10px 10px 0">
614
+ <span>WPvivid support email:</span><input type="text" id="wpvivid_support_mail" value="support@wpvivid.com" readonly />
615
+ <span>Your email:</span><input type="text" id="wpvivid_user_mail" />
616
+ </div>
617
+ <div class="schedule-tab-block">
618
+ <input class="button-primary" type="submit" value="<?php esc_attr_e( 'Send Debug Information to Us', 'wpvivid' ); ?>" onclick="wpvivid_click_send_debug_info();" />
619
+ </div>
620
+ <div style="clear:both;"></div>
621
+ <div style="padding-left: 10px;">
622
+ <strong><?php _e('Method 2.'); ?></strong> <?php _e('If you didn’t configure SMTP on your site, click the button below to download the relevant information (website info and error logs) to your PC when you are encountering some errors. Sending the files to us will help us diagnose what happened.', 'wpvivid'); ?>
623
+ </div>
624
+ <div class="schedule-tab-block">
625
+ <input class="button-primary" id="wpvivid_download_website_info" type="submit" name="download-website-info" value="<?php esc_attr_e( 'Download', 'wpvivid' ); ?>" />
626
+ </div>
627
+ <thead class="website-info-head">
628
+ <tr>
629
+ <th class="row-title" style="min-width: 260px;"><?php _e( 'Website Info Key', 'wpvivid' ); ?></th>
630
+ <th><?php _e( 'Website Info Value', 'wpvivid' ); ?></th>
631
+ </tr>
632
+ </thead>
633
+ <tbody class="wpvivid-websiteinfo-list" id="wpvivid_websiteinfo_list">
634
+ <?php
635
+ if(!empty($website_info['data'])){
636
+ foreach ($website_info['data'] as $key=>$value) { ?>
637
+ <?php
638
+ $website_value='';
639
+ if (is_array($value)) {
640
+ foreach ($value as $arr_value) {
641
+ if (empty($website_value)) {
642
+ $website_value = $website_value . $arr_value;
643
+ } else {
644
+ $website_value = $website_value . ', ' . $arr_value;
645
+ }
646
+ }
647
+ }
648
+ else{
649
+ if($value === true || $value === false){
650
+ if($value === true) {
651
+ $website_value = 'true';
652
+ }
653
+ else{
654
+ $website_value = 'false';
655
+ }
656
+ }
657
+ else {
658
+ $website_value = $value;
659
+ }
660
+ }
661
+ ?>
662
+ <tr>
663
+ <td class="row-title tablelistcolumn"><label for="tablecell"><?php _e($key, 'wpvivid'); ?></label></td>
664
+ <td class="tablelistcolumn"><?php _e($website_value, 'wpvivid'); ?></td>
665
+ </tr>
666
+ <?php }} ?>
667
+ </tbody>
668
+ </table>
669
+ </div>
670
+ <?php
671
+ }
672
+
673
+ public function wpvivid_add_page_log(){
674
+ global $wpvivid_pulgin;
675
+ $display_log_count=array(0=>"10",1=>"20",2=>"30",3=>"40",4=>"50");
676
+ $max_log_diaplay=20;
677
+ $loglist=$wpvivid_pulgin->get_log_list_ex();
678
+ ?>
679
+ <div id="logs-page" class="wrap-tab-content wpvivid_tab_log" name="tab-logs" style="display:none;">
680
+ <div style="padding-bottom: 10px; float: right;">
681
+ <select name="" id="wpvivid_display_log_count">
682
+ <?php
683
+ foreach ($display_log_count as $value){
684
+ if($value == $max_log_diaplay){
685
+ _e('<option selected="selected" value="' . $value . '">' . $value . '</option>', 'wpvivid');
686
+ }
687
+ else {
688
+ _e('<option value="' . $value . '">' . $value . '</option>', 'wpvivid');
689
+ }
690
+ }
691
+ ?>
692
+ </select>
693
+ </div>
694
+ <table class="wp-list-table widefat plugins">
695
+ <thead class="log-head">
696
+ <tr>
697
+ <th class="row-title"><?php _e( 'Date', 'wpvivid' ); ?></th>
698
+ <th><?php _e( 'Log Type', 'wpvivid' ); ?></th>
699
+ <th><?php _e( 'Log File Name', 'wpvivid' ); ?></th>
700
+ <th><?php _e( 'Action', 'wpvivid' ); ?></th>
701
+ </tr>
702
+ </thead>
703
+ <tbody class="wpvivid-loglist" id="wpvivid_loglist">
704
+ <?php
705
+ $html = '';
706
+ $html = apply_filters('wpvivid_get_log_list', $html);
707
+ echo $html['html'];
708
+ ?>
709
+ </tbody>
710
+ </table>
711
+ <div style="padding-top: 10px; text-align: center;">
712
+ <input class="button-secondary log-page" id="wpvivid_pre_log_page" type="submit" value="<?php esc_attr_e( ' < Pre page ', 'wpvivid' ); ?>" />
713
+ <div style="font-size: 12px; display: inline-block; padding-left: 10px;">
714
+ <span id="wpvivid_log_page_info" style="line-height: 35px;">
715
+ <?php
716
+ $current_page=1;
717
+ $max_page=ceil(sizeof($loglist['log_list']['file'])/$max_log_diaplay);
718
+ if($max_page == 0) $max_page = 1;
719
+ _e($current_page.' / '.$max_page, 'wpvivid');
720
+ ?>
721
+ </span>
722
+ </div>
723
+ <input class="button-secondary log-page" id="wpvivid_next_log_page" type="submit" value="<?php esc_attr_e( ' Next page > ', 'wpvivid' ); ?>" />
724
+ </div>
725
+ </div>
726
+ <?php
727
+ }
728
+
729
+ public function wpvivid_add_page_read_log(){
730
+ ?>
731
+ <div id="log-read-page" class="wrap-tab-content wpvivid_tab_read_log" style="display:none;">
732
+ <div class="postbox restore_log" id="wpvivid_read_log_content">
733
+ <div></div>
734
+ </div>
735
+ </div>
736
+ <?php
737
  }
738
  }
admin/js/wpvivid-admin.js CHANGED
@@ -157,6 +157,10 @@ var wpvivid_resotre_is_migrate=0;
157
  wpvivid_delete_incompleted_restore();
158
  });
159
 
 
 
 
 
160
  $('#wpvivid_rollback_btn').click(function(){
161
  wpvivid_start_rollback();
162
  });
@@ -1820,16 +1824,18 @@ function wpvivid_init_restore_data(restore_type)
1820
  jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
1821
  jQuery('#wpvivid_clean_'+restore_method+'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
1822
  jQuery('#wpvivid_rollback_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
 
1823
  jQuery('#wpvivid_restore_'+restore_method+'part').show();
1824
  jQuery('#wpvivid_clean_'+restore_method+'part').hide();
1825
  jQuery('#wpvivid_rollback_'+restore_method+'part').hide();
1826
- if(wpvivid_restore_backup_type == 'Migration' || wpvivid_restore_backup_type == 'Upload') {
 
1827
  jQuery('#wpvivid_restore_is_migrate').show();
1828
  jQuery('#wpvivid_restore_is_migrate').css({'pointer-events': 'none', 'opacity': '0.4'});
1829
  }
1830
  else{
1831
  jQuery('#wpvivid_restore_is_migrate').hide();
1832
- }
1833
  jQuery('#wpvivid_init_restore_data').addClass('is-active');
1834
  var ajax_data = {
1835
  'action':'wpvivid_init_restore_page',
@@ -1840,6 +1846,11 @@ function wpvivid_init_restore_data(restore_type)
1840
  var jsonarray = jQuery.parseJSON(data);
1841
  var init_status = false;
1842
  if(jsonarray.result === 'success') {
 
 
 
 
 
1843
  init_status = true;
1844
  }
1845
  else if (jsonarray.result === "need_download"){
@@ -1859,7 +1870,10 @@ function wpvivid_init_restore_data(restore_type)
1859
  });
1860
  wpvivid_restore_download_index=0;
1861
  wpvivid_restore_need_download = true;
1862
- wpvivid_download_restore_file(restore_type);
 
 
 
1863
  }
1864
  else if (jsonarray.result === "failed") {
1865
  jQuery('#wpvivid_init_restore_data').removeClass('is-active');
@@ -1903,8 +1917,7 @@ function wpvivid_init_restore_data(restore_type)
1903
  wpvivid_resotre_is_migrate = jsonarray.is_migrate;
1904
 
1905
  if (jsonarray.is_migrate_ui === 1) {
1906
- jQuery('#wpvivid_restore_is_migrate').show();
1907
- jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
1908
  jQuery('#wpvivid_replace_domain').prop('checked', false);
1909
  jQuery('#wpvivid_keep_domain').prop('checked', false);
1910
  }
@@ -1954,7 +1967,6 @@ function wpvivid_restore_is_migrate(restore_type){
1954
  if (jsonarray.is_migrate_ui === 1)
1955
  {
1956
  jQuery('#wpvivid_restore_is_migrate').show();
1957
- jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
1958
  jQuery('#wpvivid_replace_domain').prop('checked', false);
1959
  jQuery('#wpvivid_keep_domain').prop('checked', false);
1960
  }
@@ -2044,6 +2056,8 @@ function wpvivid_download_restore_file(restore_type)
2044
  restore_method = 'transfer_';
2045
  }
2046
 
 
 
2047
  if(wpvivid_restore_download_array.length===0)
2048
  {
2049
  wpvivid_display_restore_msg("Downloading backup file failed. Backup file might be deleted or network doesn't work properly. Please verify the file and confirm the network connection and try again later.", restore_type);
@@ -2059,9 +2073,11 @@ function wpvivid_download_restore_file(restore_type)
2059
  jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'auto', 'opacity': '1'});
2060
  jQuery('#wpvivid_clean_' + restore_method + 'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
2061
  jQuery('#wpvivid_rollback_' + restore_method + 'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
 
2062
  jQuery('#wpvivid_restore_' + restore_method + 'part').show();
2063
  jQuery('#wpvivid_clean_' + restore_method + 'part').hide();
2064
  jQuery('#wpvivid_rollback_' + restore_method + 'part').hide();
 
2065
  //wpvivid_start_restore(restore_type);
2066
  }
2067
  else
@@ -2114,38 +2130,45 @@ function wpvivid_monitor_download_restore_task(restore_type)
2114
  wpvivid_display_restore_msg(wpvivid_restore_download_array[wpvivid_restore_download_index]['file_name'] + ' download succeeded.', restore_type, wpvivid_restore_download_index, false);
2115
  wpvivid_restore_download_index++;
2116
  wpvivid_download_restore_file(restore_type);
 
2117
  }
2118
  else if(jsonarray.status==='error')
2119
  {
2120
- jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'auto', 'opacity': '1'});
2121
  jQuery('#wpvivid_clean_'+restore_method+'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
2122
  jQuery('#wpvivid_rollback_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2123
- jQuery('#wpvivid_restore_'+restore_method+'part').show();
 
2124
  jQuery('#wpvivid_clean_'+restore_method+'part').hide();
2125
  jQuery('#wpvivid_rollback_'+restore_method+'part').hide();
 
2126
  var error_message = jsonarray.error;
2127
  wpvivid_display_restore_msg(error_message,restore_type,wpvivid_restore_download_array[wpvivid_restore_download_index]['file_name'],false);
2128
  wpvivid_restore_unlock();
2129
  }
2130
  else if(jsonarray.status==='running')
2131
  {
 
2132
  wpvivid_display_restore_msg(jsonarray.log, restore_type, wpvivid_restore_download_index, false);
2133
  setTimeout(function()
2134
  {
2135
  wpvivid_monitor_download_restore_task(restore_type);
2136
  }, 3000);
 
2137
  }
2138
  else if(jsonarray.status==='timeout')
2139
  {
2140
  wpvivid_get_download_restore_progress_retry++;
2141
  if(wpvivid_get_download_restore_progress_retry>10)
2142
  {
2143
- jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'auto', 'opacity': '1'});
2144
  jQuery('#wpvivid_clean_'+restore_method+'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
2145
  jQuery('#wpvivid_rollback_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2146
- jQuery('#wpvivid_restore_'+restore_method+'part').show();
 
2147
  jQuery('#wpvivid_clean_'+restore_method+'part').hide();
2148
  jQuery('#wpvivid_rollback_'+restore_method+'part').hide();
 
2149
  var error_message = jsonarray.error;
2150
  wpvivid_display_restore_msg(error_message, restore_type);
2151
  wpvivid_restore_unlock();
@@ -2171,12 +2194,14 @@ function wpvivid_monitor_download_restore_task(restore_type)
2171
  wpvivid_get_download_restore_progress_retry++;
2172
  if(wpvivid_get_download_restore_progress_retry>10)
2173
  {
2174
- jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'auto', 'opacity': '1'});
2175
  jQuery('#wpvivid_clean_'+restore_method+'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
2176
  jQuery('#wpvivid_rollback_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2177
- jQuery('#wpvivid_restore_'+restore_method+'part').show();
 
2178
  jQuery('#wpvivid_clean_'+restore_method+'part').hide();
2179
  jQuery('#wpvivid_rollback_'+restore_method+'part').hide();
 
2180
  var error_message = jsonarray.error;
2181
  wpvivid_display_restore_msg(error_message, restore_type);
2182
  wpvivid_restore_unlock();
157
  wpvivid_delete_incompleted_restore();
158
  });
159
 
160
+ $('#wpvivid_download_btn').click(function(){
161
+ wpvivid_download_restore_file('backup');
162
+ });
163
+
164
  $('#wpvivid_rollback_btn').click(function(){
165
  wpvivid_start_rollback();
166
  });
1824
  jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
1825
  jQuery('#wpvivid_clean_'+restore_method+'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
1826
  jQuery('#wpvivid_rollback_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
1827
+ jQuery('#wpvivid_download_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
1828
  jQuery('#wpvivid_restore_'+restore_method+'part').show();
1829
  jQuery('#wpvivid_clean_'+restore_method+'part').hide();
1830
  jQuery('#wpvivid_rollback_'+restore_method+'part').hide();
1831
+ jQuery('#wpvivid_download_'+restore_method+'part').hide();
1832
+ /*if(wpvivid_restore_backup_type == 'Migration' || wpvivid_restore_backup_type == 'Upload') {
1833
  jQuery('#wpvivid_restore_is_migrate').show();
1834
  jQuery('#wpvivid_restore_is_migrate').css({'pointer-events': 'none', 'opacity': '0.4'});
1835
  }
1836
  else{
1837
  jQuery('#wpvivid_restore_is_migrate').hide();
1838
+ }*/
1839
  jQuery('#wpvivid_init_restore_data').addClass('is-active');
1840
  var ajax_data = {
1841
  'action':'wpvivid_init_restore_page',
1846
  var jsonarray = jQuery.parseJSON(data);
1847
  var init_status = false;
1848
  if(jsonarray.result === 'success') {
1849
+ jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'auto', 'opacity': '1'});
1850
+ jQuery('#wpvivid_download_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
1851
+ jQuery('#wpvivid_restore_'+restore_method+'part').show();
1852
+ jQuery('#wpvivid_download_'+restore_method+'part').hide();
1853
+ wpvivid_restore_need_download = false;
1854
  init_status = true;
1855
  }
1856
  else if (jsonarray.result === "need_download"){
1870
  });
1871
  wpvivid_restore_download_index=0;
1872
  wpvivid_restore_need_download = true;
1873
+ jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
1874
+ jQuery('#wpvivid_download_'+restore_method+'btn').css({'pointer-events': 'auto', 'opacity': '1'});
1875
+ jQuery('#wpvivid_restore_'+restore_method+'part').hide();
1876
+ jQuery('#wpvivid_download_'+restore_method+'part').show();
1877
  }
1878
  else if (jsonarray.result === "failed") {
1879
  jQuery('#wpvivid_init_restore_data').removeClass('is-active');
1917
  wpvivid_resotre_is_migrate = jsonarray.is_migrate;
1918
 
1919
  if (jsonarray.is_migrate_ui === 1) {
1920
+ jQuery('#wpvivid_restore_is_migrate').show()
 
1921
  jQuery('#wpvivid_replace_domain').prop('checked', false);
1922
  jQuery('#wpvivid_keep_domain').prop('checked', false);
1923
  }
1967
  if (jsonarray.is_migrate_ui === 1)
1968
  {
1969
  jQuery('#wpvivid_restore_is_migrate').show();
 
1970
  jQuery('#wpvivid_replace_domain').prop('checked', false);
1971
  jQuery('#wpvivid_keep_domain').prop('checked', false);
1972
  }
2056
  restore_method = 'transfer_';
2057
  }
2058
 
2059
+ jQuery('#wpvivid_download_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2060
+ wpvivid_restore_lock();
2061
  if(wpvivid_restore_download_array.length===0)
2062
  {
2063
  wpvivid_display_restore_msg("Downloading backup file failed. Backup file might be deleted or network doesn't work properly. Please verify the file and confirm the network connection and try again later.", restore_type);
2073
  jQuery('#wpvivid_restore_' + restore_method + 'btn').css({'pointer-events': 'auto', 'opacity': '1'});
2074
  jQuery('#wpvivid_clean_' + restore_method + 'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
2075
  jQuery('#wpvivid_rollback_' + restore_method + 'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2076
+ jQuery('#wpvivid_download_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2077
  jQuery('#wpvivid_restore_' + restore_method + 'part').show();
2078
  jQuery('#wpvivid_clean_' + restore_method + 'part').hide();
2079
  jQuery('#wpvivid_rollback_' + restore_method + 'part').hide();
2080
+ jQuery('#wpvivid_download_'+restore_method+'part').hide();
2081
  //wpvivid_start_restore(restore_type);
2082
  }
2083
  else
2130
  wpvivid_display_restore_msg(wpvivid_restore_download_array[wpvivid_restore_download_index]['file_name'] + ' download succeeded.', restore_type, wpvivid_restore_download_index, false);
2131
  wpvivid_restore_download_index++;
2132
  wpvivid_download_restore_file(restore_type);
2133
+ wpvivid_restore_unlock();
2134
  }
2135
  else if(jsonarray.status==='error')
2136
  {
2137
+ jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2138
  jQuery('#wpvivid_clean_'+restore_method+'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
2139
  jQuery('#wpvivid_rollback_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2140
+ jQuery('#wpvivid_download_'+restore_method+'btn').css({'pointer-events': 'auto', 'opacity': '1'});
2141
+ jQuery('#wpvivid_restore_'+restore_method+'part').hide();
2142
  jQuery('#wpvivid_clean_'+restore_method+'part').hide();
2143
  jQuery('#wpvivid_rollback_'+restore_method+'part').hide();
2144
+ jQuery('#wpvivid_download_'+restore_method+'part').show();
2145
  var error_message = jsonarray.error;
2146
  wpvivid_display_restore_msg(error_message,restore_type,wpvivid_restore_download_array[wpvivid_restore_download_index]['file_name'],false);
2147
  wpvivid_restore_unlock();
2148
  }
2149
  else if(jsonarray.status==='running')
2150
  {
2151
+ jQuery('#wpvivid_download_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2152
  wpvivid_display_restore_msg(jsonarray.log, restore_type, wpvivid_restore_download_index, false);
2153
  setTimeout(function()
2154
  {
2155
  wpvivid_monitor_download_restore_task(restore_type);
2156
  }, 3000);
2157
+ wpvivid_restore_lock();
2158
  }
2159
  else if(jsonarray.status==='timeout')
2160
  {
2161
  wpvivid_get_download_restore_progress_retry++;
2162
  if(wpvivid_get_download_restore_progress_retry>10)
2163
  {
2164
+ jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2165
  jQuery('#wpvivid_clean_'+restore_method+'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
2166
  jQuery('#wpvivid_rollback_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2167
+ jQuery('#wpvivid_download_'+restore_method+'btn').css({'pointer-events': 'auto', 'opacity': '1'});
2168
+ jQuery('#wpvivid_restore_'+restore_method+'part').hide();
2169
  jQuery('#wpvivid_clean_'+restore_method+'part').hide();
2170
  jQuery('#wpvivid_rollback_'+restore_method+'part').hide();
2171
+ jQuery('#wpvivid_download_'+restore_method+'part').show();
2172
  var error_message = jsonarray.error;
2173
  wpvivid_display_restore_msg(error_message, restore_type);
2174
  wpvivid_restore_unlock();
2194
  wpvivid_get_download_restore_progress_retry++;
2195
  if(wpvivid_get_download_restore_progress_retry>10)
2196
  {
2197
+ jQuery('#wpvivid_restore_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2198
  jQuery('#wpvivid_clean_'+restore_method+'restore').css({'pointer-events': 'none', 'opacity': '0.4'});
2199
  jQuery('#wpvivid_rollback_'+restore_method+'btn').css({'pointer-events': 'none', 'opacity': '0.4'});
2200
+ jQuery('#wpvivid_download_'+restore_method+'btn').css({'pointer-events': 'auto', 'opacity': '1'});
2201
+ jQuery('#wpvivid_restore_'+restore_method+'part').hide();
2202
  jQuery('#wpvivid_clean_'+restore_method+'part').hide();
2203
  jQuery('#wpvivid_rollback_'+restore_method+'part').hide();
2204
+ jQuery('#wpvivid_download_'+restore_method+'part').show();
2205
  var error_message = jsonarray.error;
2206
  wpvivid_display_restore_msg(error_message, restore_type);
2207
  wpvivid_restore_unlock();
admin/partials/wpvivid-admin-display.php CHANGED
@@ -11,6 +11,14 @@
11
  * @subpackage WPvivid/admin/partials
12
  */
13
 
 
 
 
 
 
 
 
 
14
  if (!defined('WPVIVID_PLUGIN_DIR'))
15
  {
16
  die;
@@ -28,8 +36,6 @@ $out_of_date=$wpvivid_pulgin->_get_out_of_date_info();
28
  $junk_file=$wpvivid_pulgin->_junk_files_info();
29
  $website_info=$wpvivid_pulgin->get_website_info();
30
  $loglist=$wpvivid_pulgin->get_log_list_ex();
31
- $display_log_count=array(0=>"10",1=>"20",2=>"30",3=>"40",4=>"50");
32
- $max_log_diaplay=20;
33
  $default_remote_storage='';
34
  foreach ($remoteslist['remote_selected'] as $value) {
35
  $default_remote_storage=$value;
@@ -38,63 +44,25 @@ $backup_task=$wpvivid_pulgin->_list_tasks(false);
38
  $wpvivid_version=WPVIVID_PLUGIN_VERSION;
39
 
40
  do_action('show_notice');
41
- ?>
42
 
43
- <?php
44
- function add_tab_general(){
45
- ?>
46
- <a href="#" id="wpvivid_tab_general" class="nav-tab wrap-nav-tab nav-tab-active" onclick="switchTabs(event,'general-page')"><?php _e('Backup & Restore', 'wpvivid'); ?></a>
47
- <?php
48
- }
49
 
50
- function add_tab_setting(){
51
- ?>
52
- <a href="#" id="wpvivid_tab_setting" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,'settings-page')"><?php _e('Settings', 'wpvivid'); ?></a>
53
- <?php
54
  }
 
55
 
56
- function add_tab_schedule(){
57
- ?>
58
- <a href="#" id="wpvivid_tab_schedule" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,'schedule-page')"><?php _e('Schedule', 'wpvivid'); ?></a>
59
- <?php
60
- }
61
-
62
- function add_tab_remote_storage(){
63
- ?>
64
- <a href="#" id="wpvivid_tab_remote_storage" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,'storage-page')"><?php _e('Remote Storage', 'wpvivid'); ?></a>
65
- <?php
66
- }
67
-
68
- function add_tab_website_info(){
69
- ?>
70
- <a href="#" id="wpvivid_tab_debug" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,'debug-page')"><?php _e('Website Info', 'wpvivid'); ?></a>
71
- <?php
72
- }
73
 
74
- function add_tab_log(){
75
- ?>
76
- <a href="#" id="wpvivid_tab_log" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,'logs-page')"><?php _e('Logs', 'wpvivid'); ?></a>
77
- <?php
78
- }
79
 
80
- function add_tab_read_log(){
81
- ?>
82
- <a href="#" id="wpvivid_tab_read_log" class="nav-tab wrap-nav-tab delete" onclick="switchTabs(event,'log-read-page')" style="display: none;">
83
- <div style="margin-right: 15px;"><?php _e('Log', 'wpvivid'); ?></div>
84
- <div class="nav-tab-delete-img">
85
- <img src="<?php echo esc_url(plugins_url( 'images/delete-tab.png', __FILE__ )); ?>" style="vertical-align:middle; cursor:pointer;" onclick="wpvivid_close_tab(event, 'wpvivid_tab_read_log', 'wrap', 'wpvivid_tab_log');" />
86
- </div>
87
- </a>
88
- <?php
89
  }
90
 
91
- add_action('wpvivid_backuprestore_add_tab', 'add_tab_general', 10);
92
- add_action('wpvivid_backuprestore_add_tab', 'add_tab_setting', 14);
93
- add_action('wpvivid_backuprestore_add_tab', 'add_tab_schedule', 11);
94
- add_action('wpvivid_backuprestore_add_tab', 'add_tab_remote_storage', 13);
95
- add_action('wpvivid_backuprestore_add_tab', 'add_tab_website_info', 15);
96
- add_action('wpvivid_backuprestore_add_tab', 'add_tab_log', 16);
97
- add_action('wpvivid_backuprestore_add_tab', 'add_tab_read_log', 18);
98
  ?>
99
 
100
  <div class="wrap">
@@ -114,35 +82,18 @@ add_action('wpvivid_backuprestore_add_tab', 'add_tab_read_log', 18);
114
  <div id="wpvivid_remote_notice"></div>
115
  </div>
116
  <h2 class="nav-tab-wrapper">
117
- <?php do_action('wpvivid_backuprestore_add_tab');?>
 
 
118
  </h2>
119
  <div class="wrap" style="max-width:1720px;">
120
  <div id="poststuff">
121
  <div id="post-body" class="metabox-holder columns-2">
122
  <div id="post-body-content">
123
  <div class="inside" style="margin-top:0;">
124
- <div id="general-page" class="wrap-tab-content wpvivid_tab_general" name="tab-backup" style="width:100%;">
125
- <?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-backup-restore-page-display.php'; ?>
126
- </div>
127
- <div id="storage-page" class="wrap-tab-content wpvivid_tab_remote_storage" name="tab-storage" style="display:none;">
128
- <?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-remote-storage-page-display.php'; ?>
129
- </div>
130
- <div id="settings-page" class="wrap-tab-content wpvivid_tab_setting" name="tab-setting" style="display:none;">
131
- <?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-settings-page-display.php'; ?>
132
- </div>
133
- <div id="schedule-page" class="wrap-tab-content wpvivid_tab_schedule" name="tab-schedule" style="display: none;">
134
- <?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-schedule-page-display.php'; ?>
135
- </div>
136
- <div id="debug-page" class="wrap-tab-content wpvivid_tab_debug" name="tab-debug" style="display:none;">
137
- <?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-website-info-page-display.php'; ?>
138
- </div>
139
- <div id="logs-page" class="wrap-tab-content wpvivid_tab_log" name="tab-logs" style="display:none;">
140
- <?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-logs-page-display.php'; ?>
141
- </div>
142
- <div id="log-read-page" class="wrap-tab-content wpvivid_tab_read_log" style="display:none;">
143
- <?php include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-log-read-page-display.php'; ?>
144
- </div>
145
- <?php do_action('wpvivid_backuprestore_add_page');?>
146
  </div>
147
 
148
  </div>
@@ -152,7 +103,12 @@ add_action('wpvivid_backuprestore_add_tab', 'add_tab_read_log', 18);
152
  <div class="postbox">
153
  <h2><span>Current Version: <?php _e($wpvivid_version, 'wpvivid'); ?></span></h2>
154
  </div>
155
-
 
 
 
 
 
156
  <div class="postbox">
157
  <h2><span>How-to</span></h2>
158
  <div class="inside">
11
  * @subpackage WPvivid/admin/partials
12
  */
13
 
14
+ include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-backup-restore-page-display.php';
15
+ include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-remote-storage-page-display.php';
16
+ include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-settings-page-display.php';
17
+ include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-schedule-page-display.php';
18
+ include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-website-info-page-display.php';
19
+ include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-logs-page-display.php';
20
+ include_once WPVIVID_PLUGIN_DIR .'/admin/partials/wpvivid-log-read-page-display.php';
21
+
22
  if (!defined('WPVIVID_PLUGIN_DIR'))
23
  {
24
  die;
36
  $junk_file=$wpvivid_pulgin->_junk_files_info();
37
  $website_info=$wpvivid_pulgin->get_website_info();
38
  $loglist=$wpvivid_pulgin->get_log_list_ex();
 
 
39
  $default_remote_storage='';
40
  foreach ($remoteslist['remote_selected'] as $value) {
41
  $default_remote_storage=$value;
44
  $wpvivid_version=WPVIVID_PLUGIN_VERSION;
45
 
46
  do_action('show_notice');
 
47
 
 
 
 
 
 
 
48
 
49
+ function wpvivid_schedule_module($html){
50
+ $html = '';
51
+ return $html;
 
52
  }
53
+ add_filter('wpvivid_schedule_module', 'wpvivid_schedule_module', 10);
54
 
55
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
+ <?php
 
 
 
 
58
 
59
+ $page_array = array();
60
+ $page_array = apply_filters('wpvivid_add_tab_page', $page_array);
61
+ foreach ($page_array as $page_name){
62
+ add_action('wpvivid_backuprestore_add_tab', $page_name['tab_func'], $page_name['index']);
63
+ add_action('wpvivid_backuprestore_add_page', $page_name['page_func'], $page_name['index']);
 
 
 
 
64
  }
65
 
 
 
 
 
 
 
 
66
  ?>
67
 
68
  <div class="wrap">
82
  <div id="wpvivid_remote_notice"></div>
83
  </div>
84
  <h2 class="nav-tab-wrapper">
85
+ <?php
86
+ do_action('wpvivid_backuprestore_add_tab');
87
+ ?>
88
  </h2>
89
  <div class="wrap" style="max-width:1720px;">
90
  <div id="poststuff">
91
  <div id="post-body" class="metabox-holder columns-2">
92
  <div id="post-body-content">
93
  <div class="inside" style="margin-top:0;">
94
+ <?php
95
+ do_action('wpvivid_backuprestore_add_page');
96
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  </div>
98
 
99
  </div>
103
  <div class="postbox">
104
  <h2><span>Current Version: <?php _e($wpvivid_version, 'wpvivid'); ?></span></h2>
105
  </div>
106
+ <div>
107
+ <?php
108
+ $schedule_html = '';
109
+ echo apply_filters('wpvivid_schedule_module', $schedule_html);
110
+ ?>
111
+ </div>
112
  <div class="postbox">
113
  <h2><span>How-to</span></h2>
114
  <div class="inside">
admin/partials/wpvivid-backup-restore-page-display.php CHANGED
@@ -1,156 +1,201 @@
1
  <?php
2
 
3
-
4
- function wpvivid_backup_progress_rate(){
5
- ?>
6
- <div class="postbox" id="wpvivid_postbox_backup_percent" style="display: none;">
7
- <div class="action-progress-bar" id="wpvivid_action_progress_bar">
8
- <div class="action-progress-bar-percent" id="wpvivid_action_progress_bar_percent" style="height:24px;width:0"></div>
9
- </div>
10
- <div id="wpvivid_estimate_backup_info" style="float: left;">
11
- <div class="backup-basic-info"><span><?php _e('Database Size:', 'wpvivid'); ?></span><span id="wpvivid_backup_database_size">N/A</span></div>
12
- <div class="backup-basic-info"><span><?php _e('File Size:', 'wpvivid'); ?></span><span id="wpvivid_backup_file_size">N/A</span></div>
13
- </div>
14
- <div id="wpvivid_estimate_upload_info" style="float: left;">
15
- <div class="backup-basic-info"><span><?php _e('Total Size:', 'wpvivid'); ?></span><span>N/A</span></div>
16
- <div class="backup-basic-info"><span><?php _e('Uploaded:', 'wpvivid'); ?></span><span>N/A</span></div>
17
- <div class="backup-basic-info"><span><?php _e('Speed:', 'wpvivid'); ?></span><span>N/A</span></div>
18
- </div>
19
- <div style="float: left;">
20
- <div class="backup-basic-info"><span><?php _e('Network Connection:', 'wpvivid'); ?></span><span>N/A</span></div>
21
- </div>
22
- <div style="clear:both;"></div>
23
- <div style="margin-left:10px; float: left; width:100%;"><p id="wpvivid_current_doing"></p></div>
24
- <div style="clear: both;"></div>
25
- <div>
26
- <div id="wpvivid_backup_cancel" class="backup-log-btn"><input class="button-primary" id="wpvivid_backup_cancel_btn" type="submit" value="<?php esc_attr_e( 'Cancel', 'wpvivid' ); ?>" /></div>
27
- <div id="wpvivid_backup_log" class="backup-log-btn"><input class="button-primary backup-log-btn" id="wpvivid_backup_log_btn" type="submit" value="<?php esc_attr_e( 'Log', 'wpvivid' ); ?>" /></div>
28
- </div>
29
- <div style="clear: both;"></div>
30
- </div>
31
- <?php
32
- }
33
-
34
- function wpvivid_backup_manual(){
35
- $backupdir=WPvivid_Setting::get_backupdir();
36
- ?>
37
- <div class="postbox quickbackup" id="wpvivid_postbox_backup">
38
- <h2><span><?php _e( 'Back Up Manually','wpvivid'); ?></span></h2>
39
- <div class="quickstart-storage-setting">
40
- <span class="list-top-chip backup" name="ismerge" value="1"><?php _e('Local Storage Directory: '); ?></span>
41
- <span class="list-top-chip" id="wpvivid_local_storage_path"><?php echo WP_CONTENT_DIR.'/'.$backupdir; ?></span>
42
- <span class="list-top-chip" id=""><a href="#" onclick="wpvivid_click_switch_page('wrap', 'wpvivid_tab_setting', true);"><?php _e(' rename directory', 'wpvivid'); ?></a></span>
43
- </div>
44
- <div class="quickstart-archive-block">
45
- <fieldset>
46
- <legend class="screen-reader-text"><span>input type="radio"</span></legend>
47
- <?php do_action('wpvivid_add_backup_type'); ?>
48
- <label style="display: none;">
49
- <input type="checkbox" option="backup" name="ismerge" value="1" checked />
50
  </label><br>
51
- </fieldset>
52
- </div>
53
- <div class="quickstart-storage-block">
54
- <fieldset>
55
- <legend class="screen-reader-text"><span>input type="checkbox"</span></legend>
56
- <label>
57
- <input type="radio" id="wpvivid_backup_local" option="backup_ex" name="local_remote" value="local" checked />
58
- <span><?php _e( 'Save Backups to Local', 'wpvivid' ); ?></span>
59
- </label>
60
-
61
- <div style="clear:both;"></div>
62
  <label>
63
- <input type="radio" id="wpvivid_backup_remote" option="backup_ex" name="local_remote" value="remote" />
64
- <span><?php _e( 'Send Backup to Remote Storage:', 'wpvivid' ); ?></span>
65
  </label><br>
66
- <div id="upload_storage" style="cursor:pointer;" title="Highlighted icon illuminates that you have choosed a remote storage to store backups">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  <?php
68
- $pic='';
69
- $pic= apply_filters('wpvivid_schedule_add_remote_pic',$pic);
70
- echo $pic;
71
  ?>
72
- </div>
73
- </fieldset>
74
- </div>
75
- <div class="quickstart-btn" style="padding-top:20px;">
76
- <input class="button-primary quickbackup-btn" id="wpvivid_quickbackup_btn" type="submit" value="<?php esc_attr_e( 'Backup Now', 'wpvivid'); ?>" />
77
- <div class="schedule-tab-block" style="text-align:center;">
78
- <fieldset>
79
- <label>
80
- <input type="checkbox" id="wpvivid_backup_lock" option="backup" name="lock" value="" />
81
- <span><?php _e( 'This backup can only be deleted manually', 'wpvivid' ); ?></span>
82
- </label>
83
- </fieldset>
84
- </div>
85
- </div>
86
- <div class="custom-info" style="float:left; width:100%;">
87
- <strong><?php _e('Tips', 'wpvivid'); ?></strong><?php _e(': The settings are only for manual backup, which won\'t affect schedule settings.', 'wpvivid'); ?>
88
- </div>
89
- </div>
90
- <?php
91
  }
92
 
93
- function wpvivid_add_backup_type()
94
- {
95
- ?>
96
- <label>
97
- <input type="radio" option="backup" name="backup_files" value="files+db" checked />
98
- <span><?php _e( 'Database + Files (Entire website)', 'wpvivid' ); ?></span>
99
- </label><br>
100
- <label>
101
- <input type="radio" option="backup" name="backup_files" value="files" />
102
- <span><?php _e( 'All Files (Exclude Database)', 'wpvivid' ); ?></span>
103
- </label><br>
104
- <label>
105
- <input type="radio" option="backup" name="backup_files" value="db" />
106
- <span><?php _e( 'Only Database', 'wpvivid' ); ?></span>
107
- </label><br>
108
- <?php
109
  }
110
 
111
- function wpvivid_backup_schedule(){
112
- ?>
113
- <div class="postbox qucikbackup-schedule" id="wpvivid_postbox_backup_schedule">
114
- <h2><span><?php _e( 'Backup Schedule','wpvivid'); ?></span></h2>
115
- <div class="schedule-block">
116
- <?php
117
- $schedule=WPvivid_Schedule::get_schedule();
118
- if($schedule['enable']){
119
- $schedule_status='Enabled';
120
- $next_backup_time=date("l, F d, Y H:i", $schedule['next_start']);
121
- }
122
- else{
123
- $schedule_status='Disabled';
124
- $next_backup_time='N/A';
125
- }
126
- ?>
127
- <p id="wpvivid_schedule_status"><strong><?php _e('Schedule Status: '); ?></strong><?php _e($schedule_status, 'wpvivid'); ?></p>
128
- <div id="wpvivid_schedule_info">
129
- <p><strong><?php _e('Server Time: '); ?></strong><?php _e(date("l, F d, Y H:i",time()), 'wpvivid'); ?></p>
130
- <p><span id="wpvivid_last_backup_msg"><?php
131
- $html='';
132
- $html=apply_filters('wpvivid_get_last_backup_message', $html);
133
- echo $html;
134
- ?></span></p>
135
- <p id="wpvivid_next_backup"><strong><?php _e('Next Backup: '); ?></strong><?php _e($next_backup_time, 'wpvivid'); ?></p>
136
- </div>
137
- </div>
138
  </div>
139
- <div style="clear:both;"></div>
140
- <?php
141
  }
142
 
143
- function wpvivid_add_tab_backup(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  ?>
145
  <a href="#" id="wpvivid_tab_backup" class="nav-tab backup-nav-tab nav-tab-active" onclick="switchrestoreTabs(event,'page-backups')"><?php _e('Backups', 'wpvivid'); ?></a>
146
  <?php
147
  }
148
 
149
- function wpvivid_add_tab_upload(){
150
- do_action('wpvivid_add_tab_upload');
151
- }
152
-
153
- function wpvivid_add_tab_log(){
154
  ?>
155
  <a href="#" id="wpvivid_tab_backup_log" class="nav-tab backup-nav-tab delete" onclick="switchrestoreTabs(event,'page-log')" style="display: none;">
156
  <div style="margin-right: 15px;"><?php _e('Log', 'wpvivid'); ?></div>
@@ -161,7 +206,7 @@ function wpvivid_add_tab_log(){
161
  <?php
162
  }
163
 
164
- function wpvivid_add_tab_restore(){
165
  ?>
166
  <a href="#" id="wpvivid_tab_restore" class="nav-tab backup-nav-tab delete" onclick="switchrestoreTabs(event,'page-restore')" style="display: none;">
167
  <div style="margin-right: 15px;"><?php _e('Restore', 'wpvivid'); ?></div>
@@ -172,7 +217,7 @@ function wpvivid_add_tab_restore(){
172
  <?php
173
  }
174
 
175
- function wpvivid_add_page_backup(){
176
  $backuplist=WPvivid_Backuplist::get_backuplist();
177
  ?>
178
  <div class="backup-tab-content wpvivid_tab_backup" id="page-backups">
@@ -318,11 +363,7 @@ function wpvivid_add_page_backup(){
318
  <?php
319
  }
320
 
321
- function wpvivid_add_page_upload(){
322
- do_action('wpvivid_add_page_upload');
323
- }
324
-
325
- function wpvivid_add_page_log(){
326
  ?>
327
  <div class="backup-tab-content wpvivid_tab_backup_log" id="page-log" style="display:none;">
328
  <div class="postbox restore_log" id="wpvivid_display_log_content">
@@ -332,14 +373,14 @@ function wpvivid_add_page_log(){
332
  <?php
333
  }
334
 
335
- function wpvivid_add_page_restore(){
336
  ?>
337
  <div class="backup-tab-content wpvivid_tab_restore" id="page-restore" style="display:none;">
338
  <div>
339
  <h3><?php _e('Restore backup from:', 'wpvivid'); ?><span id="wpvivid_restore_backup_time"></span></h3>
340
  <p><strong><?php _e('Please do not close the page or switch to other pages when a restore task is running, as it could trigger some unexpected errors.', 'wpvivid'); ?></strong></p>
341
  <p><?php _e('Restore function will replace the current site\'s themes, plugins, uploads, database and/or other content directories with the existing equivalents in the selected backup.', 'wpvivid'); ?></p>
342
- <div id="wpvivid_restore_is_migrate" style="padding-bottom: 10px;">
343
  <label >
344
  <input type="radio" id="wpvivid_replace_domain" option="restore" name="restore_domain" value="1" /><?php echo 'Restore and replace original domain(URL) with '.home_url().'(migration)'; ?>
345
  </label><br>
@@ -347,10 +388,17 @@ function wpvivid_add_page_restore(){
347
  <input type="radio" id="wpvivid_keep_domain" option="restore" name="restore_domain" value="0" /><?php _e('Restore and keep the original domain(URL) unchanged', 'wpvivid'); ?>
348
  </label><br>
349
  </div>
 
 
 
350
  <div id="wpvivid_restore_check"></div>
351
  <div class="restore-button-position" id="wpvivid_restore_part"><input class="button-primary" id="wpvivid_restore_btn" type="submit" name="restore" value="<?php esc_attr_e( 'Restore', 'wpvivid' ); ?>" onclick="wpvivid_start_restore();" /></div>
352
  <div class="restore-button-position" id="wpvivid_clean_part"><input class="button-primary" id="wpvivid_clean_restore" type="submit" name="clear_restore" value="<?php esc_attr_e( 'Terminate', 'wpvivid' ); ?>" /></div>
353
  <div class="restore-button-position" id="wpvivid_rollback_part"><input class="button-primary" id="wpvivid_rollback_btn" type="submit" name="rollback" value="<?php esc_attr_e( 'Rollback', 'wpvivid' ); ?>" /></div>
 
 
 
 
354
  <div class="spinner" id="wpvivid_init_restore_data" style="float:left;width:auto;height:auto;padding:10px 20px 20px 0;background-position:0 10px;"></div>
355
  </div>
356
  <div class="postbox restore_log" id="wpvivid_restore_log"></div>
@@ -358,107 +406,104 @@ function wpvivid_add_page_restore(){
358
  <?php
359
  }
360
 
361
- function wpvivid_backup_do_js(){
362
- global $wpvivid_pulgin;
363
- $backup_task=$wpvivid_pulgin->_list_tasks(false);
364
- $general_setting=WPvivid_Setting::get_setting(true, "");
365
- if($general_setting['options']['wpvivid_common_setting']['estimate_backup'] == 0){
366
- ?>
367
- jQuery('#wpvivid_estimate_backup_info').hide();
368
- <?php
369
- }
370
- if(empty($backup_task['backup']['data'])){
371
- ?>
372
- jQuery('#wpvivid_postbox_backup_percent').hide();
373
- jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'auto', 'opacity': '1'});
374
- jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
375
- <?php
376
- }
377
- else{
378
- foreach($backup_task['backup']['data'] as $key=>$value){
379
- if($value['status']['str'] === 'running'){
380
- $percent=$value['data']['progress'];
381
- ?>
382
- jQuery('#wpvivid_postbox_backup_percent').show();
383
- jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'nano', 'opacity': '0.4'});
384
- jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'nano', 'opacity': '0.4'});
385
- jQuery('#wpvivid_action_progress_bar_percent').css('width', <?php echo $percent; ?>+'%');
386
- jQuery('#wpvivid_backup_database_size').html('<?php echo $value['size']['db_size']; ?>');
387
- jQuery('#wpvivid_backup_file_size').html('<?php echo $value['size']['files_size']['sum']; ?>');
388
- <?php
389
- if($value['is_canceled'] == false){
390
- $descript=$value['data']['descript'];
391
- if($value['data']['type']){
392
- $find_str = 'Total size: ';
393
- if(stripos($descript, $find_str) != false) {
394
- $pos = stripos($descript, $find_str);
395
- $descript = substr($descript, 0, $pos);
396
- }
397
- }
398
- $backup_running_time=$value['data']['running_stamp'];
399
- $output = '';
400
- foreach (array(86400 => 'day', 3600 => 'hour', 60 => 'min', 1 => 'second') as $key => $value) {
401
- if ($backup_running_time >= $key) $output .= floor($backup_running_time/$key) . $value;
402
- $backup_running_time %= $key;
403
- }
404
- if($output==''){
405
- $output=0;
406
- }
407
- ?>
408
- jQuery('#wpvivid_current_doing').html('<?php echo $descript; ?> Progress: <?php echo $percent; ?>%, running time: <?php echo $output; ?>');
409
- <?php
410
- }
411
- else{
412
- ?>
413
- jQuery('#wpvivid_current_doing').html('The backup will be canceled after backing up the current chunk ends.');
414
- <?php
415
- }
416
- }
417
- }
418
- }
419
  }
420
 
421
- function wpvivid_download_backup_descript($html){
422
- $html = '<p><strong>'.__('About backup download', 'wpvivid').'</strong></p>';
423
- $html .= '<ul>';
424
- $html .= '<li>'.__('->If backups are stored in remote storage, our plugin will retrieve the backup to your web server first. This may take a little time depending on the size of backup files. Please be patient. Then you can download them to your PC.', 'wpvivid').'</li>';
425
- $html .= '<li>'.__('->If backups are stored in web server, the plugin will list all relevant files immediately.', 'wpvivid').'</li>';
426
- $html .= '</ul>';
 
 
 
 
 
 
 
 
 
 
427
  return $html;
428
  }
429
 
430
- function wpvivid_restore_website_dexcript($html){
431
- $html = '<p><a href="#" id="wpvivid_how_to_restore_backup_describe" onclick="wpvivid_click_how_to_restore_backup();">'.__('How to restore your website from a backup(scheduled, manual, uploaded and received backup)', 'wpvivid').'</a></p>';
432
- $html .= '<div id="wpvivid_how_to_restore_backup"></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
433
  return $html;
434
  }
435
 
436
- add_action('wpvivid_backup_add_module', 'wpvivid_backup_progress_rate', 10);
437
- add_action('wpvivid_backup_add_module', 'wpvivid_backup_manual', 11);
438
- add_action('wpvivid_backup_add_module', 'wpvivid_backup_schedule', 12);
439
- add_action('wpvivid_backup_add_tab', 'wpvivid_add_tab_backup', 13);
440
- add_action('wpvivid_backup_add_tab', 'wpvivid_add_tab_log', 15);
441
- add_action('wpvivid_backup_add_tab', 'wpvivid_add_tab_restore', 16);
442
- add_action('wpvivid_backup_add_page', 'wpvivid_add_page_backup', 13);
443
- add_action('wpvivid_backup_add_page', 'wpvivid_add_page_log', 15);
444
- add_action('wpvivid_backup_add_page', 'wpvivid_add_page_restore', 16);
445
- add_action('wpvivid_add_backup_type', 'wpvivid_add_backup_type', 11);
446
  add_action('wpvivid_backup_do_js', 'wpvivid_backup_do_js', 10);
447
  add_filter('wpvivid_download_backup_descript', 'wpvivid_download_backup_descript', 10);
448
  add_filter('wpvivid_restore_website_dexcript', 'wpvivid_restore_website_dexcript', 10);
 
 
 
 
 
 
 
 
 
 
449
 
450
- ?>
451
-
452
- <div class="meta-box-sortables ui-sortable">
453
- <?php do_action('wpvivid_backup_add_module'); ?>
454
-
455
- <h2 class="nav-tab-wrapper" id="wpvivid_backup_tab" style="padding-bottom:0!important;">
456
- <?php do_action('wpvivid_backup_add_tab'); ?>
457
- </h2>
458
-
459
- <?php do_action('wpvivid_backup_add_page'); ?>
460
- </div>
461
-
462
- <script>
463
- <?php do_action('wpvivid_backup_do_js'); ?>
464
- </script>
1
  <?php
2
 
3
+ function wpvivid_add_backup_type($html, $type_name)
4
+ {
5
+ $html .= '<label>
6
+ <input type="radio" option="backup" name="'.$type_name.'" value="files+db" checked />
7
+ <span>'.__( 'Database + Files (Entire website)', 'wpvivid' ).'</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  </label><br>
 
 
 
 
 
 
 
 
 
 
 
9
  <label>
10
+ <input type="radio" option="backup" name="'.$type_name.'" value="files" />
11
+ <span>'.__( 'All Files (Exclude Database)', 'wpvivid' ).'</span>
12
  </label><br>
13
+ <label>
14
+ <input type="radio" option="backup" name="'.$type_name.'" value="db" />
15
+ <span>'.__( 'Only Database', 'wpvivid' ).'</span>
16
+ </label><br>';
17
+ return $html;
18
+ }
19
+
20
+ function wpvivid_backup_do_js(){
21
+ global $wpvivid_pulgin;
22
+ $backup_task=$wpvivid_pulgin->_list_tasks(false);
23
+ $general_setting=WPvivid_Setting::get_setting(true, "");
24
+ if($general_setting['options']['wpvivid_common_setting']['estimate_backup'] == 0){
25
+ ?>
26
+ jQuery('#wpvivid_estimate_backup_info').hide();
27
+ <?php
28
+ }
29
+ if(empty($backup_task['backup']['data'])){
30
+ ?>
31
+ jQuery('#wpvivid_postbox_backup_percent').hide();
32
+ jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'auto', 'opacity': '1'});
33
+ jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
34
+ <?php
35
+ }
36
+ else{
37
+ foreach($backup_task['backup']['data'] as $key=>$value){
38
+ if($value['status']['str'] === 'running'){
39
+ $percent=$value['data']['progress'];
40
+ ?>
41
+ jQuery('#wpvivid_postbox_backup_percent').show();
42
+ jQuery('#wpvivid_backup_cancel_btn').css({'pointer-events': 'nano', 'opacity': '0.4'});
43
+ jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'nano', 'opacity': '0.4'});
44
+ jQuery('#wpvivid_action_progress_bar_percent').css('width', <?php echo $percent; ?>+'%');
45
+ jQuery('#wpvivid_backup_database_size').html('<?php echo $value['size']['db_size']; ?>');
46
+ jQuery('#wpvivid_backup_file_size').html('<?php echo $value['size']['files_size']['sum']; ?>');
47
+ <?php
48
+ if($value['is_canceled'] == false){
49
+ $descript=$value['data']['descript'];
50
+ if($value['data']['type']){
51
+ $find_str = 'Total size: ';
52
+ if(stripos($descript, $find_str) != false) {
53
+ $pos = stripos($descript, $find_str);
54
+ $descript = substr($descript, 0, $pos);
55
+ }
56
+ }
57
+ $backup_running_time=$value['data']['running_stamp'];
58
+ $output = '';
59
+ foreach (array(86400 => 'day', 3600 => 'hour', 60 => 'min', 1 => 'second') as $key => $value) {
60
+ if ($backup_running_time >= $key) $output .= floor($backup_running_time/$key) . $value;
61
+ $backup_running_time %= $key;
62
+ }
63
+ if($output==''){
64
+ $output=0;
65
+ }
66
+ ?>
67
+ jQuery('#wpvivid_current_doing').html('<?php echo $descript; ?> Progress: <?php echo $percent; ?>%, running time: <?php echo $output; ?>');
68
  <?php
69
+ }
70
+ else{
 
71
  ?>
72
+ jQuery('#wpvivid_current_doing').html('The backup will be canceled after backing up the current chunk ends.');
73
+ <?php
74
+ }
75
+ }
76
+ }
77
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
79
 
80
+ function wpvivid_download_backup_descript($html){
81
+ $html = '<p><strong>'.__('About backup download', 'wpvivid').'</strong></p>';
82
+ $html .= '<ul>';
83
+ $html .= '<li>'.__('->If backups are stored in remote storage, our plugin will retrieve the backup to your web server first. This may take a little time depending on the size of backup files. Please be patient. Then you can download them to your PC.', 'wpvivid').'</li>';
84
+ $html .= '<li>'.__('->If backups are stored in web server, the plugin will list all relevant files immediately.', 'wpvivid').'</li>';
85
+ $html .= '</ul>';
86
+ return $html;
 
 
 
 
 
 
 
 
 
87
  }
88
 
89
+ function wpvivid_restore_website_dexcript($html){
90
+ $html = '<p><a href="#" id="wpvivid_how_to_restore_backup_describe" onclick="wpvivid_click_how_to_restore_backup();">'.__('How to restore your website from a backup(scheduled, manual, uploaded and received backup)', 'wpvivid').'</a></p>';
91
+ $html .= '<div id="wpvivid_how_to_restore_backup"></div>';
92
+ return $html;
93
+ }
94
+
95
+ function wpvivid_backup_module($html){
96
+ $html = '';
97
+ $backup_descript = '';
98
+ $backup_part_type = '';
99
+ $backup_part_pos = '';
100
+ $backup_part_exec = '';
101
+ $backup_part_tip = '';
102
+ $html .= '
103
+ <div class="postbox quickbackup" id="wpvivid_postbox_backup">
104
+ '.apply_filters('wpvivid_backup_descript', $backup_descript).'
105
+ '.apply_filters('wpvivid_backup_part_type', $backup_part_type).'
106
+ '.apply_filters('wpvivid_backup_part_pos', $backup_part_pos).'
107
+ '.apply_filters('wpvivid_backup_part_exec', $backup_part_exec).'
108
+ '.apply_filters('wpvivid_backup_part_tip', $backup_part_tip).'
 
 
 
 
 
 
 
109
  </div>
110
+ ';
111
+ return $html;
112
  }
113
 
114
+ function wpvivid_backup_descript($html){
115
+ $backupdir=WPvivid_Setting::get_backupdir();
116
+ $html .= '<h2><span>'.__( 'Back Up Manually','wpvivid').'</span></h2>
117
+ <div class="quickstart-storage-setting">
118
+ <span class="list-top-chip backup" name="ismerge" value="1">'.__('Local Storage Directory: ').'</span>
119
+ <span class="list-top-chip" id="wpvivid_local_storage_path">'.WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$backupdir.'</span>
120
+ <span class="list-top-chip" id=""><a href="#" onclick="wpvivid_click_switch_page(\'wrap\', \'wpvivid_tab_setting\', true);">'.__(' rename directory', 'wpvivid').'</a></span>
121
+ </div>';
122
+ return $html;
123
+ }
124
+
125
+ function wpvivid_backup_part_type($html){
126
+ $backup_type = '';
127
+ $type_name = 'backup_files';
128
+ $html .= '<div class="quickstart-archive-block">
129
+ <fieldset>
130
+ <legend class="screen-reader-text"><span>input type="radio"</span></legend>
131
+ '.apply_filters('wpvivid_add_backup_type', $backup_type, $type_name).'
132
+ <label style="display: none;">
133
+ <input type="checkbox" option="backup" name="ismerge" value="1" checked />
134
+ </label><br>
135
+ </fieldset>
136
+ </div>';
137
+ return $html;
138
+ }
139
+
140
+ function wpvivid_backup_part_pos($html){
141
+ $pic='';
142
+ $html .= '<div class="quickstart-storage-block">
143
+ <fieldset>
144
+ <legend class="screen-reader-text"><span>input type="checkbox"</span></legend>
145
+ <label>
146
+ <input type="radio" id="wpvivid_backup_local" option="backup_ex" name="local_remote" value="local" checked />
147
+ <span>'.__( 'Save Backups to Local', 'wpvivid' ).'</span>
148
+ </label>
149
+ <div style="clear:both;"></div>
150
+ <label>
151
+ <input type="radio" id="wpvivid_backup_remote" option="backup_ex" name="local_remote" value="remote" />
152
+ <span>'.__( 'Send Backup to Remote Storage:', 'wpvivid' ).'</span>
153
+ </label><br>
154
+ <div id="upload_storage" style="cursor:pointer;" title="Highlighted icon illuminates that you have choosed a remote storage to store backups">
155
+ '.apply_filters('wpvivid_schedule_add_remote_pic',$pic).'
156
+ </div>
157
+ </fieldset>
158
+ </div>';
159
+ return $html;
160
+ }
161
+
162
+ function wpvivid_backup_part_exec($html){
163
+ $html .= '<div class="quickstart-btn" style="padding-top:20px;">
164
+ <input class="button-primary quickbackup-btn" id="wpvivid_quickbackup_btn" type="submit" value="'.esc_attr( 'Backup Now', 'wpvivid').'" />
165
+ <div class="schedule-tab-block" style="text-align:center;">
166
+ <fieldset>
167
+ <label>
168
+ <input type="checkbox" id="wpvivid_backup_lock" option="backup" name="lock" value="" />
169
+ <span>'.__( 'This backup can only be deleted manually', 'wpvivid' ).'</span>
170
+ </label>
171
+ </fieldset>
172
+ </div>
173
+ </div>';
174
+ return $html;
175
+ }
176
+
177
+ function wpvivid_backup_part_tip($html){
178
+ $html .= '<div class="custom-info" style="float:left; width:100%;">
179
+ <strong>'.__('Tips', 'wpvivid').'</strong>'.__(': The settings are only for manual backup, which won\'t affect schedule settings.', 'wpvivid').'
180
+ </div>';
181
+ return $html;
182
+ }
183
+
184
+
185
+ function wpvivid_backuppage_load_backuplist($backuplist_array){
186
+ $backuplist_array['list_backup'] = array('index' => '1', 'tab_func' => 'wpvivid_backuppage_add_tab_backup', 'page_func' => 'wpvivid_backuppage_add_page_backup');
187
+ $backuplist_array['list_log'] = array('index' => '3', 'tab_func' => 'wpvivid_backuppage_add_tab_log', 'page_func' => 'wpvivid_backuppage_add_page_log');
188
+ $backuplist_array['list_restore'] = array('index' => '4', 'tab_func' => 'wpvivid_backuppage_add_tab_restore', 'page_func' => 'wpvivid_backuppage_add_page_restore');
189
+ return $backuplist_array;
190
+ }
191
+
192
+ function wpvivid_backuppage_add_tab_backup(){
193
  ?>
194
  <a href="#" id="wpvivid_tab_backup" class="nav-tab backup-nav-tab nav-tab-active" onclick="switchrestoreTabs(event,'page-backups')"><?php _e('Backups', 'wpvivid'); ?></a>
195
  <?php
196
  }
197
 
198
+ function wpvivid_backuppage_add_tab_log(){
 
 
 
 
199
  ?>
200
  <a href="#" id="wpvivid_tab_backup_log" class="nav-tab backup-nav-tab delete" onclick="switchrestoreTabs(event,'page-log')" style="display: none;">
201
  <div style="margin-right: 15px;"><?php _e('Log', 'wpvivid'); ?></div>
206
  <?php
207
  }
208
 
209
+ function wpvivid_backuppage_add_tab_restore(){
210
  ?>
211
  <a href="#" id="wpvivid_tab_restore" class="nav-tab backup-nav-tab delete" onclick="switchrestoreTabs(event,'page-restore')" style="display: none;">
212
  <div style="margin-right: 15px;"><?php _e('Restore', 'wpvivid'); ?></div>
217
  <?php
218
  }
219
 
220
+ function wpvivid_backuppage_add_page_backup(){
221
  $backuplist=WPvivid_Backuplist::get_backuplist();
222
  ?>
223
  <div class="backup-tab-content wpvivid_tab_backup" id="page-backups">
363
  <?php
364
  }
365
 
366
+ function wpvivid_backuppage_add_page_log(){
 
 
 
 
367
  ?>
368
  <div class="backup-tab-content wpvivid_tab_backup_log" id="page-log" style="display:none;">
369
  <div class="postbox restore_log" id="wpvivid_display_log_content">
373
  <?php
374
  }
375
 
376
+ function wpvivid_backuppage_add_page_restore(){
377
  ?>
378
  <div class="backup-tab-content wpvivid_tab_restore" id="page-restore" style="display:none;">
379
  <div>
380
  <h3><?php _e('Restore backup from:', 'wpvivid'); ?><span id="wpvivid_restore_backup_time"></span></h3>
381
  <p><strong><?php _e('Please do not close the page or switch to other pages when a restore task is running, as it could trigger some unexpected errors.', 'wpvivid'); ?></strong></p>
382
  <p><?php _e('Restore function will replace the current site\'s themes, plugins, uploads, database and/or other content directories with the existing equivalents in the selected backup.', 'wpvivid'); ?></p>
383
+ <div id="wpvivid_restore_is_migrate" style="padding-bottom: 10px; display: none;">
384
  <label >
385
  <input type="radio" id="wpvivid_replace_domain" option="restore" name="restore_domain" value="1" /><?php echo 'Restore and replace original domain(URL) with '.home_url().'(migration)'; ?>
386
  </label><br>
388
  <input type="radio" id="wpvivid_keep_domain" option="restore" name="restore_domain" value="0" /><?php _e('Restore and keep the original domain(URL) unchanged', 'wpvivid'); ?>
389
  </label><br>
390
  </div>
391
+ <div>
392
+ <p><strong>Tips:</strong> The plugin detects automatically either site restoration or migration (replacing the domain name) based on the current domain name. If the domain name in backup file is same as the current one, it starts restoring. On the contrary, restoring backup means to replace with the current domain name. The precondition is that the backup is created by version 0.9.21 or later.</p>
393
+ </div>
394
  <div id="wpvivid_restore_check"></div>
395
  <div class="restore-button-position" id="wpvivid_restore_part"><input class="button-primary" id="wpvivid_restore_btn" type="submit" name="restore" value="<?php esc_attr_e( 'Restore', 'wpvivid' ); ?>" onclick="wpvivid_start_restore();" /></div>
396
  <div class="restore-button-position" id="wpvivid_clean_part"><input class="button-primary" id="wpvivid_clean_restore" type="submit" name="clear_restore" value="<?php esc_attr_e( 'Terminate', 'wpvivid' ); ?>" /></div>
397
  <div class="restore-button-position" id="wpvivid_rollback_part"><input class="button-primary" id="wpvivid_rollback_btn" type="submit" name="rollback" value="<?php esc_attr_e( 'Rollback', 'wpvivid' ); ?>" /></div>
398
+ <div class="restore-button-position" id="wpvivid_download_part">
399
+ <input class="button-primary" id="wpvivid_download_btn" type="submit" name="download" value="<?php esc_attr_e( 'Retrieve the backup to localhost', 'wpvivid' ); ?>" />
400
+ <span>The backup is stored on the remote storage, click on the button to download it to localhost.</span>
401
+ </div>
402
  <div class="spinner" id="wpvivid_init_restore_data" style="float:left;width:auto;height:auto;padding:10px 20px 20px 0;background-position:0 10px;"></div>
403
  </div>
404
  <div class="postbox restore_log" id="wpvivid_restore_log"></div>
406
  <?php
407
  }
408
 
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+ function wpvivid_backuppage_load_progress_module($html){
417
+ $html = '
418
+ <div class="postbox" id="wpvivid_postbox_backup_percent" style="display: none;">
419
+ <div class="action-progress-bar" id="wpvivid_action_progress_bar">
420
+ <div class="action-progress-bar-percent" id="wpvivid_action_progress_bar_percent" style="height:24px;width:0"></div>
421
+ </div>
422
+ <div id="wpvivid_estimate_backup_info" style="float: left;">
423
+ <div class="backup-basic-info"><span>'.__('Database Size:', 'wpvivid').'</span><span id="wpvivid_backup_database_size">N/A</span></div>
424
+ <div class="backup-basic-info"><span>'.__('File Size:', 'wpvivid').'</span><span id="wpvivid_backup_file_size">N/A</span></div>
425
+ </div>
426
+ <div id="wpvivid_estimate_upload_info" style="float: left;">
427
+ <div class="backup-basic-info"><span>'.__('Total Size:', 'wpvivid').'</span><span>N/A</span></div>
428
+ <div class="backup-basic-info"><span>'.__('Uploaded:', 'wpvivid').'</span><span>N/A</span></div>
429
+ <div class="backup-basic-info"><span>'.__('Speed:', 'wpvivid').'</span><span>N/A</span></div>
430
+ </div>
431
+ <div style="float: left;">
432
+ <div class="backup-basic-info"><span>'.__('Network Connection:', 'wpvivid').'</span><span>N/A</span></div>
433
+ </div>
434
+ <div style="clear:both;"></div>
435
+ <div style="margin-left:10px; float: left; width:100%;"><p id="wpvivid_current_doing"></p></div>
436
+ <div style="clear: both;"></div>
437
+ <div>
438
+ <div id="wpvivid_backup_cancel" class="backup-log-btn"><input class="button-primary" id="wpvivid_backup_cancel_btn" type="submit" value="'.esc_attr( 'Cancel', 'wpvivid' ).'" /></div>
439
+ <div id="wpvivid_backup_log" class="backup-log-btn"><input class="button-primary backup-log-btn" id="wpvivid_backup_log_btn" type="submit" value="'.esc_attr( 'Log', 'wpvivid' ).'" /></div>
440
+ </div>
441
+ <div style="clear: both;"></div>
442
+ </div>';
443
+ return $html;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  }
445
 
446
+ function wpvivid_backuppage_load_backup_module($html){
447
+ $html = '';
448
+ $backup_descript = '';
449
+ $backup_part_type = '';
450
+ $backup_part_pos = '';
451
+ $backup_part_exec = '';
452
+ $backup_part_tip = '';
453
+ $html .= '
454
+ <div class="postbox quickbackup" id="wpvivid_postbox_backup">
455
+ '.apply_filters('wpvivid_backup_descript', $backup_descript).'
456
+ '.apply_filters('wpvivid_backup_part_type', $backup_part_type).'
457
+ '.apply_filters('wpvivid_backup_part_pos', $backup_part_pos).'
458
+ '.apply_filters('wpvivid_backup_part_exec', $backup_part_exec).'
459
+ '.apply_filters('wpvivid_backup_part_tip', $backup_part_tip).'
460
+ </div>
461
+ ';
462
  return $html;
463
  }
464
 
465
+ function wpvivid_backuppage_load_schedule_module($html){
466
+ $schedule=WPvivid_Schedule::get_schedule();
467
+ if($schedule['enable']){
468
+ $schedule_status='Enabled';
469
+ $next_backup_time=date("l, F d, Y H:i", $schedule['next_start']);
470
+ }
471
+ else{
472
+ $schedule_status='Disabled';
473
+ $next_backup_time='N/A';
474
+ }
475
+ $last_message = '';
476
+ $last_message = apply_filters('wpvivid_get_last_backup_message', $last_message);
477
+ $html = '
478
+ <div class="postbox qucikbackup-schedule" id="wpvivid_postbox_backup_schedule">
479
+ <h2><span>'.__( 'Backup Schedule','wpvivid').'</span></h2>
480
+ <div class="schedule-block">
481
+ <p id="wpvivid_schedule_status"><strong>'.__('Schedule Status: ', 'wpvivid').'</strong>'.$schedule_status.'</p>
482
+ <div id="wpvivid_schedule_info">
483
+ <p><strong>'.__('Server Time: ', 'wpvivid').'</strong>'.date("l, F d, Y H:i",time()).'</p>
484
+ <p><span id="wpvivid_last_backup_msg">'.$last_message.'</span></p>
485
+ <p id="wpvivid_next_backup"><strong>'.__('Next Backup: ', 'wpvivid').'</strong>'.$next_backup_time.'</p>
486
+ </div>
487
+ </div>
488
+ </div>
489
+ <div style="clear:both;"></div>
490
+ ';
491
  return $html;
492
  }
493
 
494
+ add_filter('wpvivid_add_backup_type', 'wpvivid_add_backup_type', 11, 2);
 
 
 
 
 
 
 
 
 
495
  add_action('wpvivid_backup_do_js', 'wpvivid_backup_do_js', 10);
496
  add_filter('wpvivid_download_backup_descript', 'wpvivid_download_backup_descript', 10);
497
  add_filter('wpvivid_restore_website_dexcript', 'wpvivid_restore_website_dexcript', 10);
498
+ add_filter('wpvivid_backup_module', 'wpvivid_backup_module');
499
+ add_filter('wpvivid_backup_descript', 'wpvivid_backup_descript');
500
+ add_filter('wpvivid_backup_part_type', 'wpvivid_backup_part_type');
501
+ add_filter('wpvivid_backup_part_pos', 'wpvivid_backup_part_pos');
502
+ add_filter('wpvivid_backup_part_exec', 'wpvivid_backup_part_exec');
503
+ add_filter('wpvivid_backup_part_tip', 'wpvivid_backup_part_tip');
504
+ add_filter('wpvivid_backuppage_load_progress_module', 'wpvivid_backuppage_load_progress_module', 10);
505
+ add_filter('wpvivid_backuppage_load_backup_module', 'wpvivid_backuppage_load_backup_module', 10);
506
+ add_filter('wpvivid_backuppage_load_schedule_module', 'wpvivid_backuppage_load_schedule_module', 10);
507
+ add_filter('wpvivid_backuppage_load_backuplist', 'wpvivid_backuppage_load_backuplist', 10);
508
 
509
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/partials/wpvivid-log-read-page-display.php CHANGED
@@ -1,3 +0,0 @@
1
- <div class="postbox restore_log" id="wpvivid_read_log_content">
2
- <div></div>
3
- </div>
 
 
 
admin/partials/wpvivid-logs-page-display.php CHANGED
@@ -1,45 +0,0 @@
1
- <div style="padding-bottom: 10px; float: right;">
2
- <select name="" id="wpvivid_display_log_count">
3
- <?php
4
- foreach ($display_log_count as $value){
5
- if($value == $max_log_diaplay){
6
- _e('<option selected="selected" value="' . $value . '">' . $value . '</option>', 'wpvivid');
7
- }
8
- else {
9
- _e('<option value="' . $value . '">' . $value . '</option>', 'wpvivid');
10
- }
11
- }
12
- ?>
13
- </select>
14
- </div>
15
- <table class="wp-list-table widefat plugins">
16
- <thead class="log-head">
17
- <tr>
18
- <th class="row-title"><?php _e( 'Date', 'wpvivid' ); ?></th>
19
- <th><?php _e( 'Log Type', 'wpvivid' ); ?></th>
20
- <th><?php _e( 'Log File Name', 'wpvivid' ); ?></th>
21
- <th><?php _e( 'Action', 'wpvivid' ); ?></th>
22
- </tr>
23
- </thead>
24
- <tbody class="wpvivid-loglist" id="wpvivid_loglist">
25
- <?php
26
- $html = '';
27
- $html = apply_filters('wpvivid_get_log_list', $html);
28
- echo $html['html'];
29
- ?>
30
- </tbody>
31
- </table>
32
- <div style="padding-top: 10px; text-align: center;">
33
- <input class="button-secondary log-page" id="wpvivid_pre_log_page" type="submit" value="<?php esc_attr_e( ' < Pre page ', 'wpvivid' ); ?>" />
34
- <div style="font-size: 12px; display: inline-block; padding-left: 10px;">
35
- <span id="wpvivid_log_page_info" style="line-height: 35px;">
36
- <?php
37
- $current_page=1;
38
- $max_page=ceil(sizeof($loglist['log_list']['file'])/$max_log_diaplay);
39
- if($max_page == 0) $max_page = 1;
40
- _e($current_page.' / '.$max_page, 'wpvivid');
41
- ?>
42
- </span>
43
- </div>
44
- <input class="button-secondary log-page" id="wpvivid_next_log_page" type="submit" value="<?php esc_attr_e( ' Next page > ', 'wpvivid' ); ?>" />
45
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/partials/wpvivid-remote-storage-page-display.php CHANGED
@@ -128,24 +128,6 @@ function wpvivid_storage_list($html)
128
  add_filter('wpvivid_storage_list','wpvivid_storage_list',10);
129
  ?>
130
 
131
- <div>
132
- <div class="storage-content" id="storage-brand-2" style="">
133
- <div class="postbox">
134
- <?php do_action('wpvivid_add_storage_tab'); ?>
135
- </div>
136
- <div class="postbox storage-account-block" id="wpvivid_storage_account_block">
137
- <?php do_action('wpvivid_add_storage_page'); ?>
138
- </div>
139
- <?php
140
- $html = '';
141
- $html = apply_filters('wpvivid_storage_list', $html);
142
- echo $html;
143
- ?>
144
- <div class="storage-tab-content wpvivid_tab_storage_edit" id="page-storage_edit" style="display:none;">
145
- <div><?php do_action('wpvivid_edit_remote_page'); ?></div>
146
- </div>
147
- </div>
148
- </div>
149
 
150
 
151
  <script>
128
  add_filter('wpvivid_storage_list','wpvivid_storage_list',10);
129
  ?>
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
 
133
  <script>
admin/partials/wpvivid-schedule-page-display.php CHANGED
@@ -128,14 +128,17 @@ function wpvivid_schedule_do_js()
128
  ?>
129
  jQuery("input:radio[value='<?php echo $schedule['recurrence']?>']").prop('checked', true);
130
  jQuery("input:radio[value='<?php echo $schedule['backup']['backup_files']?>']").prop('checked', true);
131
- jQuery("input:radio[name='save_local_remote'][value='remote']").click(function(){
 
132
  <?php
133
  $remote_id_array = WPvivid_Setting::get_user_history('remote_selected');
134
  $remote_id = '';
135
- foreach ($remote_id_array as $value){
 
136
  $remote_id = $value;
137
  }
138
- if(empty($remote_id)){
 
139
  ?>
140
  alert("There is no default remote storage configured. Please set it up first.");
141
  jQuery("input:radio[name='save_local_remote'][value='local']").prop('checked', true);
@@ -152,16 +155,3 @@ add_filter('wpvivid_schedule_backup_type','wpvivid_schedule_backup_type');
152
  add_filter('wpvivid_schedule_notice','wpvivid_schedule_notice',10);
153
  ?>
154
 
155
- <div>
156
- <table class="widefat">
157
- <tbody>
158
- <?php do_action('wpvivid_schedule_add_cell'); ?>
159
- <tfoot>
160
- <tr>
161
- <th class="row-title"><input class="button-primary storage-account-button" id="wpvivid_schedule_save" type="submit" name="" value="<?php esc_attr_e( 'Save Changes', 'wpvivid' ); ?>" /></th>
162
- <th></th>
163
- </tr>
164
- </tfoot>
165
- </tbody>
166
- </table>
167
- </div>
128
  ?>
129
  jQuery("input:radio[value='<?php echo $schedule['recurrence']?>']").prop('checked', true);
130
  jQuery("input:radio[value='<?php echo $schedule['backup']['backup_files']?>']").prop('checked', true);
131
+ jQuery("input:radio[name='save_local_remote'][value='remote']").click(function()
132
+ {
133
  <?php
134
  $remote_id_array = WPvivid_Setting::get_user_history('remote_selected');
135
  $remote_id = '';
136
+ foreach ($remote_id_array as $value)
137
+ {
138
  $remote_id = $value;
139
  }
140
+ if(empty($remote_id))
141
+ {
142
  ?>
143
  alert("There is no default remote storage configured. Please set it up first.");
144
  jQuery("input:radio[name='save_local_remote'][value='local']").prop('checked', true);
155
  add_filter('wpvivid_schedule_notice','wpvivid_schedule_notice',10);
156
  ?>
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/partials/wpvivid-settings-page-display.php CHANGED
@@ -408,16 +408,3 @@ add_action('wpvivid_setting_add_cell','wpvivid_clean_junk',14);
408
  add_action('wpvivid_setting_add_cell','wpvivid_advanced_settings',15);
409
  add_action('wpvivid_setting_add_cell','wpvivid_export_import_settings',16);
410
  ?>
411
- <div>
412
- <table class="widefat">
413
- <tbody>
414
- <?php do_action('wpvivid_setting_add_cell'); ?>
415
- <tfoot>
416
- <tr>
417
- <th class="row-title"><input class="button-primary storage-account-button" id="wpvivid_setting_general_save" type="submit" name="" value="<?php esc_attr_e( 'Save Changes', 'wpvivid' ); ?>" /></th>
418
- <th></th>
419
- </tr>
420
- </tfoot>
421
- </tbody>
422
- </table>
423
- </div>
408
  add_action('wpvivid_setting_add_cell','wpvivid_advanced_settings',15);
409
  add_action('wpvivid_setting_add_cell','wpvivid_export_import_settings',16);
410
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/partials/wpvivid-website-info-page-display.php CHANGED
@@ -1,64 +1,3 @@
1
- <table class="widefat">
2
- <div style="padding: 0 0 20px 10px;">There are two ways available to send us the debug information. The first one is recommended.</div>
3
- <div style="padding-left: 10px;">
4
- <strong><?php _e('Method 1.'); ?></strong> <?php _e('If you have configured SMTP on your site, enter your email address and click the button below to send us the relevant information (website info and errors logs) when you are encountering errors. This will help us figure out what happened. Once the issue is resolved, we will inform you by your email address.', 'wpvivid'); ?>
5
- </div>
6
- <div style="padding:10px 10px 0">
7
- <span>WPvivid support email:</span><input type="text" id="wpvivid_support_mail" value="support@wpvivid.com" readonly />
8
- <span>Your email:</span><input type="text" id="wpvivid_user_mail" />
9
- </div>
10
- <div class="schedule-tab-block">
11
- <input class="button-primary" type="submit" value="<?php esc_attr_e( 'Send Debug Information to Us', 'wpvivid' ); ?>" onclick="wpvivid_click_send_debug_info();" />
12
- </div>
13
- <div style="clear:both;"></div>
14
- <div style="padding-left: 10px;">
15
- <strong><?php _e('Method 2.'); ?></strong> <?php _e('If you didn’t configure SMTP on your site, click the button below to download the relevant information (website info and error logs) to your PC when you are encountering some errors. Sending the files to us will help us diagnose what happened.', 'wpvivid'); ?>
16
- </div>
17
- <div class="schedule-tab-block">
18
- <input class="button-primary" id="wpvivid_download_website_info" type="submit" name="download-website-info" value="<?php esc_attr_e( 'Download', 'wpvivid' ); ?>" />
19
- </div>
20
- <thead class="website-info-head">
21
- <tr>
22
- <th class="row-title" style="min-width: 260px;"><?php _e( 'Website Info Key', 'wpvivid' ); ?></th>
23
- <th><?php _e( 'Website Info Value', 'wpvivid' ); ?></th>
24
- </tr>
25
- </thead>
26
- <tbody class="wpvivid-websiteinfo-list" id="wpvivid_websiteinfo_list">
27
- <?php
28
- if(!empty($website_info['data'])){
29
- foreach ($website_info['data'] as $key=>$value) { ?>
30
- <?php
31
- $website_value='';
32
- if (is_array($value)) {
33
- foreach ($value as $arr_value) {
34
- if (empty($website_value)) {
35
- $website_value = $website_value . $arr_value;
36
- } else {
37
- $website_value = $website_value . ', ' . $arr_value;
38
- }
39
- }
40
- }
41
- else{
42
- if($value === true || $value === false){
43
- if($value === true) {
44
- $website_value = 'true';
45
- }
46
- else{
47
- $website_value = 'false';
48
- }
49
- }
50
- else {
51
- $website_value = $value;
52
- }
53
- }
54
- ?>
55
- <tr>
56
- <td class="row-title tablelistcolumn"><label for="tablecell"><?php _e($key, 'wpvivid'); ?></label></td>
57
- <td class="tablelistcolumn"><?php _e($website_value, 'wpvivid'); ?></td>
58
- </tr>
59
- <?php }} ?>
60
- </tbody>
61
- </table>
62
  <script>
63
  function wpvivid_get_ini_memory_limit() {
64
  var ajax_data = {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <script>
2
  function wpvivid_get_ini_memory_limit() {
3
  var ajax_data = {
includes/class-wpvivid-backup-database.php CHANGED
@@ -7,23 +7,10 @@ define('NECESSARY','1');
7
  define('OPTION','0');
8
  class WPvivid_Backup_Database
9
  {
10
- public $wpdb_obj;
11
- public $ConfigFile;
12
- public $UserName;
13
- public $Password;
14
- public $DBName;
15
- public $HOST;
16
- public $DOMAIN;
17
- public $blogversion;
18
- public $requiredphp;
19
- public $requiredmysql;
20
- private $CharsetArray;
21
- private $CollateArray;
22
  private $task_id;
23
 
24
- public function __construct() {
25
- $this->CharsetArray = array();
26
- $this->CollateArray = array();
27
  }
28
 
29
  public function backup_database($data,$task_id = '')
@@ -34,23 +21,6 @@ class WPvivid_Backup_Database
34
  try
35
  {
36
  $this->task_id=$task_id;
37
- global $wpdb, $wp_version, $required_php_version, $required_mysql_version;
38
- if (is_multisite() && !defined('MULTISITE'))
39
- {
40
- $prefix = $wpdb->base_prefix;
41
- } else {
42
- $prefix = $wpdb->get_blog_prefix(0);
43
- }
44
-
45
- $this->blogversion = $wp_version;
46
- $this->wpdb_obj = $wpdb;
47
- $this->requiredmysql = $required_mysql_version;
48
- $this->requiredphp = $required_php_version;
49
- $this->UserName = DB_USER;
50
- $this->Password = DB_PASSWORD;
51
- $this->DBName = DB_NAME;
52
- $this->HOST = DB_HOST;
53
- $this->DOMAIN = filter_input(INPUT_SERVER, 'HTTP_HOST');
54
 
55
  $backup_file =$data['sql_file_name'];
56
 
@@ -70,13 +40,10 @@ class WPvivid_Backup_Database
70
  }
71
 
72
  $db_method->check_max_allowed_packet();
 
 
 
73
 
74
- if($data['key'] == WPVIVID_BACKUP_TYPE_DB) {
75
- $exclude = array('/^(?!' . $prefix . ')/');
76
- }
77
- else{
78
- $exclude = apply_filters('wpvivid_exclude_db_table', $data);
79
- }
80
  //$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME;
81
  $dump = new WPvivid_Mysqldump(DB_HOST,DB_NAME, DB_USER, DB_PASSWORD , array('exclude-tables'=>$exclude,'add-drop-table' => true,'extended-insert'=>false));
82
 
@@ -86,7 +53,8 @@ class WPvivid_Backup_Database
86
  $dump->task_id=$task_id;
87
  $dump->start($backup_file);
88
  unset($pdo);
89
- }catch (Exception $e)
 
90
  {
91
  $str_last_query_string='';
92
  if(!is_null($dump))
@@ -105,4 +73,17 @@ class WPvivid_Backup_Database
105
  $files[] = $backup_file;
106
  return array('result'=>WPVIVID_SUCCESS,'files'=>$files);
107
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
7
  define('OPTION','0');
8
  class WPvivid_Backup_Database
9
  {
 
 
 
 
 
 
 
 
 
 
 
 
10
  private $task_id;
11
 
12
+ public function __construct()
13
+ {
 
14
  }
15
 
16
  public function backup_database($data,$task_id = '')
21
  try
22
  {
23
  $this->task_id=$task_id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  $backup_file =$data['sql_file_name'];
26
 
40
  }
41
 
42
  $db_method->check_max_allowed_packet();
43
+ add_filter('wpvivid_exclude_db_table', array($this, 'exclude_table'),10,2);
44
+ $exclude=array();
45
+ $exclude = apply_filters('wpvivid_exclude_db_table',$exclude, $data);
46
 
 
 
 
 
 
 
47
  //$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME;
48
  $dump = new WPvivid_Mysqldump(DB_HOST,DB_NAME, DB_USER, DB_PASSWORD , array('exclude-tables'=>$exclude,'add-drop-table' => true,'extended-insert'=>false));
49
 
53
  $dump->task_id=$task_id;
54
  $dump->start($backup_file);
55
  unset($pdo);
56
+ }
57
+ catch (Exception $e)
58
  {
59
  $str_last_query_string='';
60
  if(!is_null($dump))
73
  $files[] = $backup_file;
74
  return array('result'=>WPVIVID_SUCCESS,'files'=>$files);
75
  }
76
+
77
+ public function exclude_table($exclude,$data)
78
+ {
79
+ global $wpdb;
80
+ if (is_multisite() && !defined('MULTISITE'))
81
+ {
82
+ $prefix = $wpdb->base_prefix;
83
+ } else {
84
+ $prefix = $wpdb->get_blog_prefix(0);
85
+ }
86
+ $exclude = array('/^(?!' . $prefix . ')/');
87
+ return $exclude;
88
+ }
89
  }
includes/class-wpvivid-backup-uploader.php CHANGED
@@ -41,19 +41,19 @@ class Wpvivid_BackupUploader
41
  else
42
  {
43
  $ret['result']=WPVIVID_FAILED;
44
- $ret['error']='The backup is not created by WPvivid backup plugin.';
45
  }
46
  }
47
  else
48
  {
49
  $ret['result']=WPVIVID_FAILED;
50
- $ret['error']='The backup is not created by WPvivid backup plugin.';
51
  }
52
  }
53
  else
54
  {
55
  $ret['result']=WPVIVID_FAILED;
56
- $ret['error']='The backup is not created by WPvivid backup plugin.';
57
  }
58
 
59
  echo json_encode($ret);
@@ -107,7 +107,7 @@ class Wpvivid_BackupUploader
107
 
108
  if (isset($status['error']))
109
  {
110
- echo json_encode(array('e' => $status['error']));
111
  exit;
112
  }
113
 
@@ -140,10 +140,21 @@ class Wpvivid_BackupUploader
140
  }
141
  }
142
  }
143
-
144
  die();
145
  }
146
 
 
 
 
 
 
 
 
 
 
 
 
147
  function upload_files_finish()
148
  {
149
  $ret['html']=false;
@@ -153,6 +164,8 @@ class Wpvivid_BackupUploader
153
  $files =json_decode($files,true);
154
  if(is_null($files))
155
  {
 
 
156
  die();
157
  }
158
 
@@ -166,9 +179,12 @@ class Wpvivid_BackupUploader
166
  {
167
  $id= $matches[0];
168
  $id=substr($id,0,strlen($id)-1);
 
 
169
  foreach ($files as $file)
170
  {
171
- if($this->check_is_a_wpvivid_backup($path.$file['name']))
 
172
  {
173
  $add_file['file_name']=$file['name'];
174
  $add_file['size']=filesize($path.$file['name']);
@@ -176,38 +192,74 @@ class Wpvivid_BackupUploader
176
  }
177
  else
178
  {
179
- @unlink($path.$file['name']);
 
180
  }
181
  }
182
- if(!empty($backup_data['files']))
183
- {
184
  global $wpvivid_pulgin;
185
  $wpvivid_pulgin->wpvivid_log=new WPvivid_Log();
186
- $wpvivid_pulgin->wpvivid_log->CreateLogFile($id.'_backup','no_folder','backup');
187
  $wpvivid_pulgin->wpvivid_log->WriteLogHander();
188
  $wpvivid_pulgin->wpvivid_log->WriteLog('Upload finished.','notice');
189
  WPvivid_Backuplist::add_new_upload_backup($id,$backup_data,$wpvivid_pulgin->wpvivid_log->log_file);
190
  $html = '';
191
  $html = apply_filters('wpvivid_add_backup_list', $html);
 
192
  $ret['html'] = $html;
193
  }
 
 
 
 
 
 
 
 
 
 
 
194
  }
195
  else
196
  {
 
 
197
  $ret['result']=WPVIVID_FAILED;
198
  $ret['error']='The backup is not created by WPvivid backup plugin.';
199
  }
200
  }
201
  else
202
  {
 
 
203
  $ret['result']=WPVIVID_FAILED;
204
  $ret['error']='The backup is not created by WPvivid backup plugin.';
205
  }
206
  }
 
 
 
 
 
 
207
  echo json_encode($ret);
208
  die();
209
  }
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  function rescan_local_folder_set_backup()
212
  {
213
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR;
@@ -231,7 +283,7 @@ class Wpvivid_BackupUploader
231
  {
232
  if($this->zip_check_sum($path . $filename))
233
  {
234
- if($this->check_is_a_wpvivid_backup($path.$filename))
235
  $backups[$backup_id]['files'][]=$filename;
236
  }
237
  }
@@ -241,6 +293,16 @@ class Wpvivid_BackupUploader
241
  if($handler)
242
  @closedir($handler);
243
  }
 
 
 
 
 
 
 
 
 
 
244
 
245
  if(!empty($backups))
246
  {
@@ -256,13 +318,13 @@ class Wpvivid_BackupUploader
256
  }
257
  global $wpvivid_pulgin;
258
  $wpvivid_pulgin->wpvivid_log=new WPvivid_Log();
259
- $wpvivid_pulgin->wpvivid_log->CreateLogFile($backup_id.'_backup','no_folder','backup');
260
  $wpvivid_pulgin->wpvivid_log->WriteLogHander();
261
  $wpvivid_pulgin->wpvivid_log->WriteLog('Upload finished.','notice');
262
  WPvivid_Backuplist::add_new_upload_backup($backup_id,$backup_data,$wpvivid_pulgin->wpvivid_log->log_file);
263
  }
264
  }
265
- $ret['result']='success';
266
  $html = '';
267
  $tour = true;
268
  $html = apply_filters('wpvivid_add_backup_list', $html, $tour);
@@ -339,16 +401,15 @@ class Wpvivid_BackupUploader
339
  'container' => 'wpvivid_plupload-upload-ui',
340
  'drop_element' => 'drag-drop-area',
341
  'file_data_name' => 'async-upload',
 
342
  'multiple_queues' => true,
343
  'max_file_size' => '10Gb',
344
- 'chunk_size' => $chunk_size.'b',
345
  'url' => admin_url('admin-ajax.php'),
346
  'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
347
  'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
348
- //'filters' => array(array('title' => __('Allowed Files'), 'extensions' => '*')),
349
  'multipart' => true,
350
  'urlstream_upload' => true,
351
-
352
  // additional post data to send to our ajax hook
353
  'multipart_params' => array(
354
  'action' => 'wpvivid_upload_files', // the ajax action name
@@ -431,6 +492,7 @@ class Wpvivid_BackupUploader
431
  }
432
  else
433
  {
 
434
  plupload.each(files, function(file)
435
  {
436
  var brepeat=false;
@@ -460,9 +522,18 @@ class Wpvivid_BackupUploader
460
  }
461
  }
462
  else{
463
- alert("The backup file already exists in upload list.");
 
 
 
 
 
464
  }
465
  });
 
 
 
 
466
  }
467
  }
468
 
@@ -470,11 +541,16 @@ class Wpvivid_BackupUploader
470
 
471
  uploader.bind('Error', function(up, error)
472
  {
 
473
  console.log(error);
474
  });
475
 
476
  uploader.bind('FileUploaded', function(up, file, response)
477
  {
 
 
 
 
478
  });
479
 
480
  uploader.bind('UploadProgress', function(up, file)
@@ -496,10 +572,24 @@ class Wpvivid_BackupUploader
496
  {
497
  try {
498
  var jsonarray = jQuery.parseJSON(data);
499
- if(jsonarray.html !== false){
500
- jQuery('#wpvivid_backuplist').html('');
501
- jQuery('#wpvivid_backuplist').append(jsonarray.html);
502
- wpvivid_click_switch_page('backup', 'wpvivid_tab_backup', true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
503
  }
504
  }
505
  catch(err) {
@@ -565,15 +655,13 @@ class Wpvivid_BackupUploader
565
 
566
  private function check_is_a_wpvivid_backup($file_name)
567
  {
568
- $info=WPvivid_Backup_Item::get_backup_file_info($file_name);
569
- if($info===false)
570
- {
571
- return false;
572
- }
573
- else
574
- {
575
  return true;
576
  }
 
 
 
577
  }
578
 
579
  private function zip_check_sum($file_name)
41
  else
42
  {
43
  $ret['result']=WPVIVID_FAILED;
44
+ $ret['error']=$_POST['file_name'] . ' is not created by WPvivid backup plugin.';
45
  }
46
  }
47
  else
48
  {
49
  $ret['result']=WPVIVID_FAILED;
50
+ $ret['error']=$_POST['file_name'] . ' is not created by WPvivid backup plugin.';
51
  }
52
  }
53
  else
54
  {
55
  $ret['result']=WPVIVID_FAILED;
56
+ $ret['error']='Failed to post file name.';
57
  }
58
 
59
  echo json_encode($ret);
107
 
108
  if (isset($status['error']))
109
  {
110
+ echo json_encode(array('result'=>WPVIVID_FAILED, 'error' => $status['error']));
111
  exit;
112
  }
113
 
140
  }
141
  }
142
  }
143
+ echo json_encode(array('result'=>WPVIVID_SUCCESS));
144
  die();
145
  }
146
 
147
+ function wpvivid_write_upload_log($message, $id = ''){
148
+ if($id === ''){
149
+ $id=uniqid('wpvivid-');
150
+ }
151
+ global $wpvivid_pulgin;
152
+ $wpvivid_pulgin->upload_log=new WPvivid_Log();
153
+ $wpvivid_pulgin->upload_log->CreateLogFile($id.'_upload','no_folder','upload');
154
+ $wpvivid_pulgin->upload_log->WriteLogHander();
155
+ $wpvivid_pulgin->upload_log->WriteLog($message,'notice');
156
+ }
157
+
158
  function upload_files_finish()
159
  {
160
  $ret['html']=false;
164
  $files =json_decode($files,true);
165
  if(is_null($files))
166
  {
167
+ $message = 'Failed to decode files.';
168
+ $this->wpvivid_write_upload_log($message);
169
  die();
170
  }
171
 
179
  {
180
  $id= $matches[0];
181
  $id=substr($id,0,strlen($id)-1);
182
+ $unlinked_file = '';
183
+ $check_result=true;
184
  foreach ($files as $file)
185
  {
186
+ $res=$this->check_is_a_wpvivid_backup($path.$file['name']);
187
+ if($res === true)
188
  {
189
  $add_file['file_name']=$file['name'];
190
  $add_file['size']=filesize($path.$file['name']);
192
  }
193
  else
194
  {
195
+ $check_result=false;
196
+ $unlinked_file .= 'file name: '.$file['name'].', error: '.$res;
197
  }
198
  }
199
+ if($check_result === true){
 
200
  global $wpvivid_pulgin;
201
  $wpvivid_pulgin->wpvivid_log=new WPvivid_Log();
202
+ $wpvivid_pulgin->wpvivid_log->CreateLogFile($id.'_upload','no_folder','upload');
203
  $wpvivid_pulgin->wpvivid_log->WriteLogHander();
204
  $wpvivid_pulgin->wpvivid_log->WriteLog('Upload finished.','notice');
205
  WPvivid_Backuplist::add_new_upload_backup($id,$backup_data,$wpvivid_pulgin->wpvivid_log->log_file);
206
  $html = '';
207
  $html = apply_filters('wpvivid_add_backup_list', $html);
208
+ $ret['result']=WPVIVID_SUCCESS;
209
  $ret['html'] = $html;
210
  }
211
+ else{
212
+ foreach ($files as $file) {
213
+ $this->clean_tmp_files($path, $file['name']);
214
+ @unlink($path . $file['name']);
215
+ }
216
+ $ret['result']=WPVIVID_FAILED;
217
+ $ret['error']='Upload file failed.';
218
+ $ret['unlinked']=$unlinked_file;
219
+ $message = $ret['error'] . $unlinked_file;
220
+ $this->wpvivid_write_upload_log($message);
221
+ }
222
  }
223
  else
224
  {
225
+ $message = 'The backup is not created by WPvivid backup plugin.';
226
+ $this->wpvivid_write_upload_log($message);
227
  $ret['result']=WPVIVID_FAILED;
228
  $ret['error']='The backup is not created by WPvivid backup plugin.';
229
  }
230
  }
231
  else
232
  {
233
+ $message = 'The backup is not created by WPvivid backup plugin.';
234
+ $this->wpvivid_write_upload_log($message);
235
  $ret['result']=WPVIVID_FAILED;
236
  $ret['error']='The backup is not created by WPvivid backup plugin.';
237
  }
238
  }
239
+ else{
240
+ $message = 'Failed to post file name.';
241
+ $this->wpvivid_write_upload_log($message);
242
+ $ret['result']=WPVIVID_FAILED;
243
+ $ret['error']='Failed to post file name.';
244
+ }
245
  echo json_encode($ret);
246
  die();
247
  }
248
 
249
+ function clean_tmp_files($path, $filename){
250
+ $handler=opendir($path);
251
+ while(($file=readdir($handler))!==false) {
252
+ if (!is_dir($path.$file) && preg_match('/wpvivid-.*_.*_.*\.tmp$/', $file)) {
253
+ $iPos = strrpos($file, '_');
254
+ $file_temp = substr($file, 0, $iPos);
255
+ if($file_temp === $filename) {
256
+ @unlink($path.$file);
257
+ }
258
+ }
259
+ }
260
+ @closedir($handler);
261
+ }
262
+
263
  function rescan_local_folder_set_backup()
264
  {
265
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir().DIRECTORY_SEPARATOR;
283
  {
284
  if($this->zip_check_sum($path . $filename))
285
  {
286
+ if($this->check_is_a_wpvivid_backup($path.$filename) === true)
287
  $backups[$backup_id]['files'][]=$filename;
288
  }
289
  }
293
  if($handler)
294
  @closedir($handler);
295
  }
296
+ else{
297
+ global $wpvivid_pulgin;
298
+ $wpvivid_pulgin->wpvivid_log=new WPvivid_Log();
299
+ $id=uniqid('wpvivid-');
300
+ $wpvivid_pulgin->wpvivid_log->CreateLogFile($id.'_scan','no_folder','scan');
301
+ $wpvivid_pulgin->wpvivid_log->WriteLogHander();
302
+ $wpvivid_pulgin->wpvivid_log->WriteLog('Failed to get local storage directory.','notice');
303
+ $ret['result']=WPVIVID_FAILED;
304
+ $ret['error']='Failed to get local storage directory.';
305
+ }
306
 
307
  if(!empty($backups))
308
  {
318
  }
319
  global $wpvivid_pulgin;
320
  $wpvivid_pulgin->wpvivid_log=new WPvivid_Log();
321
+ $wpvivid_pulgin->wpvivid_log->CreateLogFile($backup_id.'_scan','no_folder','scan');
322
  $wpvivid_pulgin->wpvivid_log->WriteLogHander();
323
  $wpvivid_pulgin->wpvivid_log->WriteLog('Upload finished.','notice');
324
  WPvivid_Backuplist::add_new_upload_backup($backup_id,$backup_data,$wpvivid_pulgin->wpvivid_log->log_file);
325
  }
326
  }
327
+ $ret['result']=WPVIVID_SUCCESS;
328
  $html = '';
329
  $tour = true;
330
  $html = apply_filters('wpvivid_add_backup_list', $html, $tour);
401
  'container' => 'wpvivid_plupload-upload-ui',
402
  'drop_element' => 'drag-drop-area',
403
  'file_data_name' => 'async-upload',
404
+ 'max_retries' => 3,
405
  'multiple_queues' => true,
406
  'max_file_size' => '10Gb',
407
+ 'chunk_size' => $chunk_size.'b',
408
  'url' => admin_url('admin-ajax.php'),
409
  'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
410
  'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
 
411
  'multipart' => true,
412
  'urlstream_upload' => true,
 
413
  // additional post data to send to our ajax hook
414
  'multipart_params' => array(
415
  'action' => 'wpvivid_upload_files', // the ajax action name
492
  }
493
  else
494
  {
495
+ var repeat_files = '';
496
  plupload.each(files, function(file)
497
  {
498
  var brepeat=false;
522
  }
523
  }
524
  else{
525
+ if(repeat_files === ''){
526
+ repeat_files += file.name;
527
+ }
528
+ else{
529
+ repeat_files += ', ' + file.name;
530
+ }
531
  }
532
  });
533
+ if(repeat_files !== ''){
534
+ alert(repeat_files + " already exists in upload list.");
535
+ repeat_files = '';
536
+ }
537
  }
538
  }
539
 
541
 
542
  uploader.bind('Error', function(up, error)
543
  {
544
+ alert('Upload ' + error.file.name +' error, error code: ' + error.code + ', ' + error.message);
545
  console.log(error);
546
  });
547
 
548
  uploader.bind('FileUploaded', function(up, file, response)
549
  {
550
+ var jsonarray = jQuery.parseJSON(response.response);
551
+ if(jsonarray.result == 'failed'){
552
+ alert('upload ' + file.name + ' failed, ' + jsonarray.error);
553
+ }
554
  });
555
 
556
  uploader.bind('UploadProgress', function(up, file)
572
  {
573
  try {
574
  var jsonarray = jQuery.parseJSON(data);
575
+ if(jsonarray.result === 'success') {
576
+ if (jsonarray.html !== false) {
577
+ var unlinked = '';
578
+ if(typeof jsonarray.unlinked !== 'undefined'){
579
+ unlinked = jsonarray.unlinked;
580
+ }
581
+ alert('The upload has completed. ' + unlinked);
582
+ jQuery('#wpvivid_backuplist').html('');
583
+ jQuery('#wpvivid_backuplist').append(jsonarray.html);
584
+ wpvivid_click_switch_page('backup', 'wpvivid_tab_backup', true);
585
+ }
586
+ }
587
+ else if(jsonarray.result === 'failed'){
588
+ var unlinked = '';
589
+ if(typeof jsonarray.unlinked !== 'undefined'){
590
+ unlinked = jsonarray.unlinked;
591
+ }
592
+ alert(jsonarray.error + ' ' + unlinked);
593
  }
594
  }
595
  catch(err) {
655
 
656
  private function check_is_a_wpvivid_backup($file_name)
657
  {
658
+ $ret=WPvivid_Backup_Item::get_backup_file_info($file_name);
659
+ if($ret['result'] === WPVIVID_SUCCESS){
 
 
 
 
 
660
  return true;
661
  }
662
+ elseif($ret['result'] === WPVIVID_FAILED){
663
+ return $ret['error'];
664
+ }
665
  }
666
 
667
  private function zip_check_sum($file_name)
includes/class-wpvivid-backup.php CHANGED
@@ -20,6 +20,8 @@ class WPvivid_Backup_Task
20
  {
21
  private $task;
22
 
 
 
23
  public function __construct($task_id=false,$task=false)
24
  {
25
  if($task_id!==false)
@@ -31,6 +33,17 @@ class WPvivid_Backup_Task
31
  {
32
  $this->task=$task;
33
  }
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
  public function get_id()
@@ -138,6 +151,8 @@ class WPvivid_Backup_Task
138
  $this->task['options']['backup_options']['dir']=WPvivid_Setting::get_backupdir();
139
  $this->task['options']['backup_options']['backup']=array();
140
 
 
 
141
  if(isset($options['backup_files']))
142
  {
143
  if($options['backup_files']=='files+db')
@@ -185,29 +200,10 @@ class WPvivid_Backup_Task
185
  {
186
  $this->set_backup(WPVIVID_BACKUP_TYPE_DB);
187
  }
188
- else{
189
- $this->task['options']['backup_options']['backup'] = apply_filters('wpvivid_set_backup_type', $options, $this->task);
190
- if(empty($this->task['options']['backup_options']['backup'])){
191
- if($options['backup_files']['backup_db'] == '1'){
192
- $this->set_backup(WPVIVID_BACKUP_TYPE_DB);
193
- }
194
- if($options['backup_files']['backup_themes'] == '1'){
195
- $this->set_backup(WPVIVID_BACKUP_TYPE_THEMES);
196
- }
197
- if($options['backup_files']['backup_plugin'] == '1'){
198
- $this->set_backup(WPVIVID_BACKUP_TYPE_PLUGIN);
199
- }
200
- if($options['backup_files']['backup_uploads'] == '1'){
201
- $this->set_backup(WPVIVID_BACKUP_TYPE_UPLOADS);
202
- }
203
- if($options['backup_files']['backup_content'] == '1'){
204
- $this->set_backup(WPVIVID_BACKUP_TYPE_CONTENT);
205
- }
206
- if($options['backup_files']['backup_core'] == '1'){
207
- $this->set_backup(WPVIVID_BACKUP_TYPE_CORE);
208
- }
209
- }
210
- }
211
  }
212
  $this->task['data']['doing']='backup';
213
  $this->task['data']['backup']['doing']='';
@@ -269,6 +265,10 @@ class WPvivid_Backup_Task
269
  {
270
  $backup_data['root_path']=WP_CONTENT_DIR;
271
  $backup_data['prefix']=$this->get_prefix().'_backup_plugin';
 
 
 
 
272
  $backup_data['files_root']=$this->transfer_path(WP_PLUGIN_DIR);
273
  $exclude_regex[]='#^'.preg_quote($this -> transfer_path(WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.'wpvivid-backuprestore'), '/').'#';
274
  $backup_data['exclude_regex']=$exclude_regex;
@@ -289,6 +289,7 @@ class WPvivid_Backup_Task
289
  {
290
  $backup_data['root_path']=WP_CONTENT_DIR;
291
  $backup_data['prefix']=$this->get_prefix().'_backup_uploads';
 
292
  $upload_dir = wp_upload_dir();
293
  $backup_data['files_root']=$this -> transfer_path($upload_dir['basedir']);
294
  $exclude_regex[]='#^'.preg_quote($this -> transfer_path($upload_dir['basedir']).DIRECTORY_SEPARATOR.'backwpup', '/').'#'; // BackWPup backup directory
@@ -362,7 +363,6 @@ class WPvivid_Backup_Task
362
  }
363
  if($backup_data!==false)
364
  {
365
- add_filter('wpvivid_set_backup', array($this, 'wpvivid_set_backup'),10);
366
  $backup_data=apply_filters('wpvivid_set_backup',$backup_data);
367
  $this->task['options']['backup_options']['backup'][$backup_data['key']]=$backup_data;
368
  }
@@ -371,34 +371,30 @@ class WPvivid_Backup_Task
371
 
372
  public function wpvivid_set_backup($backup_data)
373
  {
374
- if($backup_data['key']==WPVIVID_BACKUP_TYPE_PLUGIN)
375
  {
376
- $general_setting=WPvivid_Setting::get_setting(true, "");
377
- if(isset($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload']) && !empty($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload'])){
378
- if($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload']){
379
- $backup_data['resume_packages'] = 1;
380
- }
381
- }
382
  }
383
  else if($backup_data['key']==WPVIVID_BACKUP_TYPE_MERGE)
384
  {
385
  $backup_data['resume_packages'] = 1;
386
  }
387
- else if($backup_data['key']==WPVIVID_BACKUP_TYPE_UPLOADS_FILES)
388
- {
389
- $general_setting=WPvivid_Setting::get_setting(true, "");
390
- if(isset($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload']) && !empty($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload'])){
391
- if($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload']){
392
- $backup_data['resume_packages'] = 1;
393
- }
394
- }
395
- }
396
 
397
  return $backup_data;
398
  }
399
 
400
  public function get_need_backup_files($backup_data)
401
  {
 
 
 
 
 
 
 
 
 
 
402
  if(isset($backup_data['files'])&&!empty($backup_data['files']))
403
  {
404
  return $backup_data['files'];
@@ -486,41 +482,38 @@ class WPvivid_Backup_Task
486
  {
487
  if(!isset($backup_data['dump_db']))
488
  {
489
- if($backup_data['key']==WPVIVID_BACKUP_TYPE_PLUGIN)
490
  {
491
- $general_setting=WPvivid_Setting::get_setting(true, "");
492
- if(isset($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload']) && !empty($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload'])){
493
- if($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload']){
494
- $backup_data['files']=$this->get_need_backup_folder($backup_data);
495
- $this->task['options']['backup_options']['backup'][$backup_data['key']]=$backup_data;
496
- WPvivid_Setting::update_task($this->task['id'],$this->task);
497
- }
498
- }
499
- else{
500
- $backup_data['files']=$this->get_need_backup_files($backup_data);
501
- }
502
  }
503
- else if ($backup_data['key']==WPVIVID_BACKUP_TYPE_UPLOADS_FILES)
504
  {
505
- $general_setting=WPvivid_Setting::get_setting(true, "");
506
- if(isset($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload']) && !empty($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload'])){
507
- if($general_setting['options']['wpvivid_compress_setting']['subpackage_plugin_upload']){
508
- $backup_data['files']=$this->get_need_uploads_backup_folder($backup_data);
509
- $this->task['options']['backup_options']['backup'][$backup_data['key']]=$backup_data;
510
- WPvivid_Setting::update_task($this->task['id'],$this->task);
511
- }
512
- }
513
- else{
514
- $backup_data['files']=$this->get_need_backup_files($backup_data);
515
- }
516
  }
517
- else {
518
- $backup_data['files']=$this->get_need_backup_files($backup_data);
 
 
 
 
 
519
  }
520
  }
521
  return $backup_data;
522
  }
523
 
 
 
 
 
 
 
 
 
 
 
 
 
524
  public function update_backup_result($backup_data,$result)
525
  {
526
  $this->task=WPvivid_taskmanager::get_task($this->task['id']);
@@ -538,6 +531,7 @@ class WPvivid_Backup_Task
538
  if($result['result']==WPVIVID_FAILED)
539
  {
540
  WPvivid_taskmanager::update_backup_task_status($this->task['id'],false,'error',false,false,$result['error']);
 
541
  }
542
  }
543
 
@@ -556,7 +550,7 @@ class WPvivid_Backup_Task
556
  {
557
  WPvivid_taskmanager::update_backup_main_task_progress($this->task['id'],'backup',100,1);
558
  }
559
- WPvivid_Setting::update_task($this->task['id'],$this->task);
560
  }
561
 
562
  public function wpvivid_backup_update_result($result,$backup_data)
@@ -568,23 +562,10 @@ class WPvivid_Backup_Task
568
  {
569
  $exist_files_name[$temp_file_data['file_name']]=$temp_file_data['file_name'];
570
  }
571
- if(WPVIVID_BACKUP_TYPE_PLUGIN==$backup_data['key'])
572
- {
573
- $packages_files_info = $this->get_packages_files_info(WPVIVID_BACKUP_TYPE_PLUGIN);
574
- if ($packages_files_info !== false)
575
- {
576
- foreach ($packages_files_info as $file_data)
577
- {
578
- if(!array_key_exists($file_data['file_name'],$exist_files_name))
579
- {
580
- $result['files'][]=$file_data;
581
- }
582
- }
583
- }
584
- }
585
- else if(WPVIVID_BACKUP_TYPE_UPLOADS_FILES==$backup_data['key'])
586
  {
587
- $packages_files_info = $this->get_packages_files_info(WPVIVID_BACKUP_TYPE_UPLOADS_FILES);
588
  if ($packages_files_info !== false)
589
  {
590
  foreach ($packages_files_info as $file_data)
@@ -632,7 +613,7 @@ class WPvivid_Backup_Task
632
  return $files;
633
  }
634
 
635
- public function getFileLoop(&$files,$path,$exclude_regex=array(),$include_regex=array(),$exclude_file_size,$include_dir = true)
636
  {
637
  $count = 0;
638
  if(is_dir($path))
@@ -739,8 +720,6 @@ class WPvivid_Backup_Task
739
  if ($packages_files_info !== false) {
740
  foreach ($packages_files_info as $file_data) {
741
  $path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $this->task['options']['backup_options']['dir'] . DIRECTORY_SEPARATOR . $file_data['file_name'];
742
- global $wpvivid_pulgin;
743
- $wpvivid_pulgin->wpvivid_log->WriteLog('test:' . $path, 'notice');
744
  if (!in_array($path, $files))
745
  $files[] = $path;
746
  }
@@ -802,13 +781,18 @@ class WPvivid_Backup_Task
802
 
803
  $files=array();
804
 
805
- $exclude_size= $this->task['options']['backup_options']['compress']['exclude_file_size'];
806
-
807
  foreach ($this->task['options']['backup_options']['backup'] as $backup_data)
808
  {
809
  if(!isset($backup_data['dump_db']))
810
  {
811
- $backup_files=$this->get_need_backup_files($backup_data);
 
 
 
 
 
 
 
812
  $files=array_merge($backup_files,$files);
813
  }
814
  }
@@ -1316,7 +1300,7 @@ class WPvivid_Backup_Item
1316
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file['file_name'];
1317
  if(file_exists($path))
1318
  {
1319
- if(filesize($path) === $file['size']){
1320
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
1321
  $res = TRUE;
1322
  }
@@ -1392,18 +1376,24 @@ class WPvivid_Backup_Item
1392
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file['file_name'];
1393
  if(file_exists($path))
1394
  {
1395
- $json=$zip->get_json_data($path);
1396
- $json=json_decode($json,1);
1397
- if(!is_null($json))
1398
- {
1399
- if(isset($json['home_url'])&&home_url()!=$json['home_url'])
1400
- {
1401
- return 1;
 
 
 
 
1402
  }
1403
  }
 
 
 
1404
  }
1405
  }
1406
-
1407
  return 0;
1408
  }
1409
  else
@@ -1579,15 +1569,15 @@ class WPvivid_Backup_Item
1579
 
1580
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file_name;
1581
 
1582
- $json=$zip->get_json_data($path);
1583
 
1584
- $json=json_decode($json,1);
1585
-
1586
- $files=array();
1587
-
1588
- if(isset($json['has_child']))
1589
- {
1590
- $files=$zip->list_file($path);
1591
  }
1592
 
1593
  return $files;
@@ -1599,31 +1589,36 @@ class WPvivid_Backup_Item
1599
 
1600
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file_name;
1601
 
1602
- $json=$zip->get_json_data($path);
1603
-
1604
- $json=json_decode($json,1);
1605
- if(is_null($json))
1606
- {
1607
- return false;
 
 
 
1608
  }
1609
- else
1610
- {
1611
- return $json;
1612
  }
1613
  }
1614
 
1615
  static public function get_backup_file_info($file_name)
1616
  {
1617
  $zip=new WPvivid_ZipClass();
1618
- $json=$zip->get_json_data($file_name);
1619
- $json=json_decode($json,1);
1620
- if(is_null($json))
1621
- {
1622
- return false;
 
 
 
 
1623
  }
1624
- else
1625
- {
1626
- return $json;
1627
  }
1628
  }
1629
 
@@ -1685,8 +1680,9 @@ class WPvivid_Backup_Item
1685
  {
1686
  $need_download=false;
1687
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file['file_name'];
 
1688
  if(file_exists($path)) {
1689
- if(filesize($path) === $file['size']){
1690
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
1691
  $res = TRUE;
1692
  }
@@ -1781,6 +1777,7 @@ class WPvivid_Backup_Item
1781
  WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
1782
  $ret['files'][$file['file_name']]['status']='completed';
1783
  $ret['files'][$file['file_name']]['download_path']=$path;
 
1784
  $ret['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
1785
  <span>Part'.$format_part.'</span></br>
1786
  <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_download(\''.$backup_id.'\', \''.$check_type.'\', \''.$file['file_name'].'\');" style="cursor: pointer;">Download</a></span></br>
@@ -1914,11 +1911,11 @@ class WPvivid_Backup
1914
  global $wpvivid_pulgin;
1915
  $wpvivid_pulgin->wpvivid_log->WriteLog('Start compressing '.$data['key'],'notice');
1916
 
1917
- if($data['key']==WPVIVID_BACKUP_TYPE_PLUGIN)
1918
  {
1919
  $ret =$zip->get_plugin_packages($data);
1920
  }
1921
- else if($data['key']==WPVIVID_BACKUP_TYPE_UPLOADS_FILES)
1922
  {
1923
  $ret =$zip->get_upload_packages($data);
1924
  }
20
  {
21
  private $task;
22
 
23
+ public $backup_type_collect;
24
+
25
  public function __construct($task_id=false,$task=false)
26
  {
27
  if($task_id!==false)
33
  {
34
  $this->task=$task;
35
  }
36
+
37
+ $this->backup_type_collect[WPVIVID_BACKUP_TYPE_DB]=1;
38
+ $this->backup_type_collect[WPVIVID_BACKUP_TYPE_THEMES]=1;
39
+ $this->backup_type_collect[WPVIVID_BACKUP_TYPE_PLUGIN]=1;
40
+ $this->backup_type_collect[WPVIVID_BACKUP_TYPE_UPLOADS]=1;
41
+ $this->backup_type_collect[WPVIVID_BACKUP_TYPE_UPLOADS_FILES]=1;
42
+ $this->backup_type_collect[WPVIVID_BACKUP_TYPE_UPLOADS_FILES_OTHER]=1;
43
+ $this->backup_type_collect[WPVIVID_BACKUP_TYPE_CONTENT]=1;
44
+ $this->backup_type_collect[WPVIVID_BACKUP_TYPE_CORE]=1;
45
+ $this->backup_type_collect[WPVIVID_BACKUP_TYPE_OTHERS]=1;
46
+ $this->backup_type_collect[WPVIVID_BACKUP_TYPE_MERGE]=1;
47
  }
48
 
49
  public function get_id()
151
  $this->task['options']['backup_options']['dir']=WPvivid_Setting::get_backupdir();
152
  $this->task['options']['backup_options']['backup']=array();
153
 
154
+ add_filter('wpvivid_set_backup', array($this, 'wpvivid_set_backup'),10);
155
+
156
  if(isset($options['backup_files']))
157
  {
158
  if($options['backup_files']=='files+db')
200
  {
201
  $this->set_backup(WPVIVID_BACKUP_TYPE_DB);
202
  }
203
+ }
204
+ else
205
+ {
206
+ $this->task['options']['backup_options'] = apply_filters('wpvivid_set_backup_type', $this->task['options']['backup_options'],$options);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  }
208
  $this->task['data']['doing']='backup';
209
  $this->task['data']['backup']['doing']='';
265
  {
266
  $backup_data['root_path']=WP_CONTENT_DIR;
267
  $backup_data['prefix']=$this->get_prefix().'_backup_plugin';
268
+ if(isset($backup_data['compress']['subpackage_plugin_upload'])&&$backup_data['compress']['subpackage_plugin_upload'])
269
+ {
270
+ $backup_data['plugin_subpackage']=1;
271
+ }
272
  $backup_data['files_root']=$this->transfer_path(WP_PLUGIN_DIR);
273
  $exclude_regex[]='#^'.preg_quote($this -> transfer_path(WP_PLUGIN_DIR.DIRECTORY_SEPARATOR.'wpvivid-backuprestore'), '/').'#';
274
  $backup_data['exclude_regex']=$exclude_regex;
289
  {
290
  $backup_data['root_path']=WP_CONTENT_DIR;
291
  $backup_data['prefix']=$this->get_prefix().'_backup_uploads';
292
+ $backup_data['uploads_subpackage']=1;
293
  $upload_dir = wp_upload_dir();
294
  $backup_data['files_root']=$this -> transfer_path($upload_dir['basedir']);
295
  $exclude_regex[]='#^'.preg_quote($this -> transfer_path($upload_dir['basedir']).DIRECTORY_SEPARATOR.'backwpup', '/').'#'; // BackWPup backup directory
363
  }
364
  if($backup_data!==false)
365
  {
 
366
  $backup_data=apply_filters('wpvivid_set_backup',$backup_data);
367
  $this->task['options']['backup_options']['backup'][$backup_data['key']]=$backup_data;
368
  }
371
 
372
  public function wpvivid_set_backup($backup_data)
373
  {
374
+ if(isset($backup_data['uploads_subpackage'])||isset($backup_data['plugin_subpackage']))
375
  {
376
+ $backup_data['resume_packages'] = 1;
 
 
 
 
 
377
  }
378
  else if($backup_data['key']==WPVIVID_BACKUP_TYPE_MERGE)
379
  {
380
  $backup_data['resume_packages'] = 1;
381
  }
 
 
 
 
 
 
 
 
 
382
 
383
  return $backup_data;
384
  }
385
 
386
  public function get_need_backup_files($backup_data)
387
  {
388
+ if(isset($backup_data['uploads_subpackage']))
389
+ {
390
+ return $backup_data['files']=$this->get_need_uploads_backup_folder($backup_data);
391
+ }
392
+
393
+ if(isset($backup_data['plugin_subpackage']))
394
+ {
395
+ return $backup_data['files']=$this->get_need_backup_folder($backup_data);
396
+ }
397
+
398
  if(isset($backup_data['files'])&&!empty($backup_data['files']))
399
  {
400
  return $backup_data['files'];
482
  {
483
  if(!isset($backup_data['dump_db']))
484
  {
485
+ if(array_key_exists($backup_data['key'],$this->backup_type_collect))
486
  {
487
+ $backup_data['files'] = $this->get_need_backup_files($backup_data);
 
 
 
 
 
 
 
 
 
 
488
  }
489
+ else
490
  {
491
+ $backup_data['files'] =apply_filters('wpvivid_get_custom_need_backup_files', $backup_data['files'],$backup_data,$this->task['options']['backup_options']['compress']);
 
 
 
 
 
 
 
 
 
 
492
  }
493
+
494
+ $need=false;
495
+ add_filter('wpvivid_need_backup_files_update', array($this, 'need_backup_files_update'), 10, 2);
496
+ if(apply_filters('wpvivid_need_backup_files_update',$need,$backup_data))
497
+ {
498
+ $this->task['options']['backup_options']['backup'][$backup_data['key']]=$backup_data;
499
+ WPvivid_Setting::update_task($this->task['id'],$this->task);
500
  }
501
  }
502
  return $backup_data;
503
  }
504
 
505
+ public function need_backup_files_update($need,$backup_data)
506
+ {
507
+ if(isset($backup_data['uploads_subpackage'])||isset($backup_data['plugin_subpackage']))
508
+ {
509
+ return true;
510
+ }
511
+ else
512
+ {
513
+ return $need;
514
+ }
515
+ }
516
+
517
  public function update_backup_result($backup_data,$result)
518
  {
519
  $this->task=WPvivid_taskmanager::get_task($this->task['id']);
531
  if($result['result']==WPVIVID_FAILED)
532
  {
533
  WPvivid_taskmanager::update_backup_task_status($this->task['id'],false,'error',false,false,$result['error']);
534
+ return ;
535
  }
536
  }
537
 
550
  {
551
  WPvivid_taskmanager::update_backup_main_task_progress($this->task['id'],'backup',100,1);
552
  }
553
+ //WPvivid_Setting::update_task($this->task['id'],$this->task);
554
  }
555
 
556
  public function wpvivid_backup_update_result($result,$backup_data)
562
  {
563
  $exist_files_name[$temp_file_data['file_name']]=$temp_file_data['file_name'];
564
  }
565
+
566
+ if(isset($backup_data['resume_packages'])&&$backup_data['resume_packages'])
 
 
 
 
 
 
 
 
 
 
 
 
 
567
  {
568
+ $packages_files_info = $this->get_packages_files_info($backup_data['key']);
569
  if ($packages_files_info !== false)
570
  {
571
  foreach ($packages_files_info as $file_data)
613
  return $files;
614
  }
615
 
616
+ public function getFileLoop(&$files,$path,$exclude_regex=array(),$include_regex=array(),$exclude_file_size=0,$include_dir = true)
617
  {
618
  $count = 0;
619
  if(is_dir($path))
720
  if ($packages_files_info !== false) {
721
  foreach ($packages_files_info as $file_data) {
722
  $path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $this->task['options']['backup_options']['dir'] . DIRECTORY_SEPARATOR . $file_data['file_name'];
 
 
723
  if (!in_array($path, $files))
724
  $files[] = $path;
725
  }
781
 
782
  $files=array();
783
 
 
 
784
  foreach ($this->task['options']['backup_options']['backup'] as $backup_data)
785
  {
786
  if(!isset($backup_data['dump_db']))
787
  {
788
+ if(array_key_exists($backup_data['key'],$this->backup_type_collect))
789
+ {
790
+ $backup_files = $this->get_need_backup_files($backup_data);
791
+ }
792
+ else
793
+ {
794
+ $backup_files =apply_filters('wpvivid_get_custom_need_backup_files', $backup_data['files'],$backup_data,$this->task['options']['backup_options']['compress']);
795
+ }
796
  $files=array_merge($backup_files,$files);
797
  }
798
  }
1300
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file['file_name'];
1301
  if(file_exists($path))
1302
  {
1303
+ if(filesize($path) == $file['size']){
1304
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
1305
  $res = TRUE;
1306
  }
1376
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file['file_name'];
1377
  if(file_exists($path))
1378
  {
1379
+ $ret=$zip->get_json_data($path);
1380
+ if($ret['result'] === WPVIVID_SUCCESS) {
1381
+ $json=$ret['json_data'];
1382
+ $json = json_decode($json, 1);
1383
+ if (!is_null($json)) {
1384
+ if (isset($json['home_url'])) {
1385
+ return 1;
1386
+ }
1387
+ }
1388
+ else{
1389
+ return 0;
1390
  }
1391
  }
1392
+ elseif($ret['result'] === WPVIVID_FAILED){
1393
+ return 0;
1394
+ }
1395
  }
1396
  }
 
1397
  return 0;
1398
  }
1399
  else
1569
 
1570
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file_name;
1571
 
1572
+ $files = array();
1573
 
1574
+ $ret=$zip->get_json_data($path);
1575
+ if($ret['result'] === WPVIVID_SUCCESS) {
1576
+ $json=$ret['json_data'];
1577
+ $json = json_decode($json, 1);
1578
+ if (isset($json['has_child'])) {
1579
+ $files = $zip->list_file($path);
1580
+ }
1581
  }
1582
 
1583
  return $files;
1589
 
1590
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file_name;
1591
 
1592
+ $ret=$zip->get_json_data($path);
1593
+ if($ret['result'] === WPVIVID_SUCCESS) {
1594
+ $json=$ret['json_data'];
1595
+ $json = json_decode($json, 1);
1596
+ if (is_null($json)) {
1597
+ return false;
1598
+ } else {
1599
+ return $json;
1600
+ }
1601
  }
1602
+ elseif($ret['result'] === WPVIVID_FAILED){
1603
+ return false;
 
1604
  }
1605
  }
1606
 
1607
  static public function get_backup_file_info($file_name)
1608
  {
1609
  $zip=new WPvivid_ZipClass();
1610
+ $ret=$zip->get_json_data($file_name);
1611
+ if($ret['result'] === WPVIVID_SUCCESS) {
1612
+ $json=$ret['json_data'];
1613
+ $json = json_decode($json, 1);
1614
+ if (is_null($json)) {
1615
+ return array('result'=>WPVIVID_FAILED,'error'=>'Failed to decode json');
1616
+ } else {
1617
+ return array('result'=>WPVIVID_SUCCESS,'json_data'=>$json);
1618
+ }
1619
  }
1620
+ elseif($ret['result'] === WPVIVID_FAILED){
1621
+ return $ret;
 
1622
  }
1623
  }
1624
 
1680
  {
1681
  $need_download=false;
1682
  $path=WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file['file_name'];
1683
+ $download_url=content_url().DIRECTORY_SEPARATOR.$this->config['local']['path'].DIRECTORY_SEPARATOR.$file['file_name'];
1684
  if(file_exists($path)) {
1685
+ if(filesize($path) == $file['size']){
1686
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
1687
  $res = TRUE;
1688
  }
1777
  WPvivid_taskmanager::delete_download_task_v2($file['file_name']);
1778
  $ret['files'][$file['file_name']]['status']='completed';
1779
  $ret['files'][$file['file_name']]['download_path']=$path;
1780
+ $ret['files'][$file['file_name']]['download_url']=$download_url;
1781
  $ret['files'][$file['file_name']]['html']='<div style="float:left;margin:10px 10px 10px 0;text-align:center; width:180px;">
1782
  <span>Part'.$format_part.'</span></br>
1783
  <span id=\''.$backup_id.'-text-part-'.$file_part_num.'\'><a onclick="wpvivid_download(\''.$backup_id.'\', \''.$check_type.'\', \''.$file['file_name'].'\');" style="cursor: pointer;">Download</a></span></br>
1911
  global $wpvivid_pulgin;
1912
  $wpvivid_pulgin->wpvivid_log->WriteLog('Start compressing '.$data['key'],'notice');
1913
 
1914
+ if(isset($data['plugin_subpackage']))
1915
  {
1916
  $ret =$zip->get_plugin_packages($data);
1917
  }
1918
+ else if(isset($data['uploads_subpackage']))
1919
  {
1920
  $ret =$zip->get_upload_packages($data);
1921
  }
includes/class-wpvivid-crypt.php CHANGED
@@ -32,6 +32,8 @@ class WPvivid_crypt
32
  $key=$this->encrypt_key();
33
  $len=str_pad(dechex(strlen($key)),3,'0', STR_PAD_LEFT);
34
  $message=$this->rij->encrypt($message);
 
 
35
  $message_len = str_pad(dechex(strlen($message)), 16, '0', STR_PAD_LEFT);
36
  return $len.$key.$message_len.$message;
37
  }
32
  $key=$this->encrypt_key();
33
  $len=str_pad(dechex(strlen($key)),3,'0', STR_PAD_LEFT);
34
  $message=$this->rij->encrypt($message);
35
+ if($message===false)
36
+ return false;
37
  $message_len = str_pad(dechex(strlen($message)), 16, '0', STR_PAD_LEFT);
38
  return $len.$key.$message_len.$message;
39
  }
includes/class-wpvivid-function-realize.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WPvivid_Function_Realize
4
+ {
5
+ public function __construct()
6
+ {
7
+
8
+ }
9
+
10
+ public function _backup_cancel($task_id)
11
+ {
12
+ global $wpvivid_pulgin;
13
+ if (WPvivid_taskmanager::get_task($task_id) !== false) {
14
+ $file_name = WPvivid_taskmanager::get_task_options($task_id, 'file_prefix');
15
+ $backup_options = WPvivid_taskmanager::get_task_options($task_id, 'backup_options');
16
+ $file = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $backup_options['dir'] . DIRECTORY_SEPARATOR . $file_name . '_cancel';
17
+ touch($file);
18
+ }
19
+
20
+ $timestamp = wp_next_scheduled(WPVIVID_TASK_MONITOR_EVENT, array($task_id));
21
+
22
+ if ($timestamp === false) {
23
+ $wpvivid_pulgin->add_monitor_event($task_id, 10);
24
+ }
25
+ $ret['result'] = 'success';
26
+ $ret['msg'] = __('The backup will be canceled after backing up the current chunk ends.', 'wpvivid');
27
+ return $ret;
28
+ }
29
+
30
+ public function _get_log_file($read_type, $param){
31
+ global $wpvivid_pulgin;
32
+ $ret['result']='failed';
33
+ if($read_type == 'backuplist'){
34
+ $backup_id = $param;
35
+ $backup = WPvivid_Backuplist::get_backuplist_by_key($backup_id);
36
+ if(!$backup) {
37
+ $ret['result']='failed';
38
+ $ret['error']=__('Retrieving the backup information failed while showing log. Please try again later.', 'wpvivid');
39
+ return $ret;
40
+ }
41
+ if(!file_exists($backup['log'])) {
42
+ $ret['result']='failed';
43
+ $ret['error']=__('The log not found.', 'wpvivid');
44
+ return $ret;
45
+ }
46
+ $ret['result']='success';
47
+ $ret['log_file']=$backup['log'];
48
+ }
49
+ else if($read_type == 'lastlog'){
50
+ $option = $param;
51
+ $log_file_name= $wpvivid_pulgin->wpvivid_log->GetSaveLogFolder().$option.'_log.txt';
52
+ if(!file_exists($log_file_name))
53
+ {
54
+ $information['result']='failed';
55
+ $information['error']=__('The log not found.', 'wpvivid');
56
+ return $information;
57
+ }
58
+ $ret['result']='success';
59
+ $ret['log_file']=$log_file_name;
60
+ }
61
+ else if($read_type == 'tasklog'){
62
+ $backup_task_id = $param;
63
+ $option=WPvivid_taskmanager::get_task_options($backup_task_id,'log_file_name');
64
+ if(!$option) {
65
+ $information['result']='failed';
66
+ $information['error']=__('Retrieving the backup information failed while showing log. Please try again later.', 'wpvivid');
67
+ return $information;
68
+ }
69
+ $log_file_name= $wpvivid_pulgin->wpvivid_log->GetSaveLogFolder().$option.'_log.txt';
70
+ if(!file_exists($log_file_name)) {
71
+ $information['result']='failed';
72
+ $information['error']=__('The log not found.', 'wpvivid');
73
+ return $information;
74
+ }
75
+ $ret['result']='success';
76
+ $ret['log_file']=$log_file_name;
77
+ }
78
+ return $ret;
79
+ }
80
+
81
+ public function _set_remote($remote){
82
+ WPvivid_Setting::update_option('wpvivid_upload_setting',$remote['upload']);
83
+ $history=WPvivid_Setting::get_option('wpvivid_user_history');
84
+ $history['remote_selected']=$remote['history']['remote_selected'];
85
+ WPvivid_Setting::update_option('wpvivid_user_history',$history);
86
+ }
87
+
88
+ public function _get_default_remote_storage(){
89
+ $remote_storage_type = '';
90
+ $remoteslist=WPvivid_Setting::get_all_remote_options();
91
+ $default_remote_storage='';
92
+ foreach ($remoteslist['remote_selected'] as $value) {
93
+ $default_remote_storage=$value;
94
+ }
95
+ foreach ($remoteslist as $key=>$value)
96
+ {
97
+ if($key === $default_remote_storage)
98
+ {
99
+ $remote_storage_type=$value['type'];
100
+ }
101
+ }
102
+ return $remote_storage_type;
103
+ }
104
+ }
includes/class-wpvivid-migrate.php CHANGED
@@ -9,13 +9,11 @@ class WPvivid_Migrate
9
  {
10
  public function __construct()
11
  {
12
- add_action('wpvivid_backuprestore_add_tab',array($this,'add_addon_tab_transfer'), 12);
13
- add_action('wpvivid_backuprestore_add_tab',array($this,'add_addon_tab_key'), 17);
14
- add_action('wpvivid_backuprestore_add_page',array($this,'add_addon_page_transfer'));
15
- add_action('wpvivid_backuprestore_add_page',array($this,'add_addon_page_key'));
16
  add_action('wp_ajax_wpvivid_generate_url',array( $this,'generate_url'));
17
  add_action('wp_ajax_wpvivid_send_backup_to_site',array( $this,'send_backup_to_site'));
18
  add_action('wp_ajax_wpvivid_migrate_now',array( $this,'migrate_now'));
 
19
 
20
  add_action('wp_ajax_wpvivid_export_download_backup',array( $this,'export_download_backup'));
21
  add_action('wp_ajax_wpvivid_list_upload_tasks',array( $this,'list_tasks'));
@@ -25,794 +23,360 @@ class WPvivid_Migrate
25
  add_filter('wpvivid_put_transfer_key', array($this, 'wpvivid_put_transfer_key'));
26
  add_action('wpvivid_handle_backup_failed',array($this,'wpvivid_handle_backup_failed'),9);
27
 
28
- add_action('wpvivid_backup_add_tab', array($this, 'wpvivid_add_tab_upload'), 14);
29
- add_action('wpvivid_backup_add_page', array($this, 'wpvivid_add_page_upload'), 14);
30
  add_action('wpvivid_rescan_backup_list', array($this, 'wpvivid_rescan_backup_list'));
31
  add_action('wpvivid_handle_upload_succeed',array($this,'wpvivid_deal_upload_succeed'),11);
 
 
 
 
 
 
 
32
  }
33
 
34
- public function test_connect_site()
35
- {
36
- if(isset($_POST['url']))
37
- {
38
- $url=strtok($_POST['url'],'?');
39
 
40
- if (filter_var($url, FILTER_VALIDATE_URL) === FALSE)
41
- {
42
- $ret['result']=WPVIVID_FAILED;
43
- $ret['error']='The key is invalid.';
44
- echo json_encode($ret);
45
- die();
46
- }
47
 
48
- if($url==home_url())
49
- {
50
- $ret['result']=WPVIVID_FAILED;
51
- $ret['error']='The key generated by this site cannot be added into this site.';
52
- echo json_encode($ret);
53
- die();
54
- }
55
- $query=parse_url ($_POST['url'],PHP_URL_QUERY);
56
- parse_str($query,$query_arr);
57
- $token=$query_arr['token'];
58
- $expires=$query_arr['expires'];
59
- $domain=$query_arr['domain'];
60
 
61
- if ($expires != 0 && time() > $expires) {
62
- $ret['result'] = 'failed';
63
- $ret['error'] = 'The key has expired.';
64
- echo json_encode($ret);
65
- die();
66
- }
 
 
 
 
 
 
 
67
 
68
- $json['test_connect']=1;
69
- $json=json_encode($json);
70
- $crypt=new WPvivid_crypt(base64_decode($token));
71
- $data=$crypt->encrypt_message($json);
72
 
73
- $data=base64_encode($data);
74
-
75
- $args['body']=array('wpvivid_content'=>$data,'wpvivid_action'=>'send_to_site_connect');
76
- $response=wp_remote_post($url,$args);
 
 
 
 
 
 
 
 
77
 
78
- if ( is_wp_error( $response ) )
79
- {
80
- $ret['result']=WPVIVID_FAILED;
81
- $ret['error']= $response->get_error_message();
82
- }
83
- else
84
- {
85
- if($response['response']['code']==200)
86
- {
87
- $res=json_decode($response['body'],1);
88
- if($res!=null)
89
- {
90
- if($res['result']==WPVIVID_SUCCESS)
91
- {
92
- $ret['result']=WPVIVID_SUCCESS;
93
 
94
- $options=WPvivid_Setting::get_option('wpvivid_saved_api_token');
95
 
96
- $options[$url]['token']=$token;
97
- $options[$url]['url']=$url;
98
- $options[$url]['expires']=$expires;
99
- $options[$url]['domain']=$domain;
100
 
101
- delete_option('wpvivid_saved_api_token');
102
- update_option('wpvivid_saved_api_token',$options);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
- $html='';
105
- $i=0;
106
- foreach ($options as $key=>$site)
107
- {
108
- $check_status='';
109
- if($key==$url)
110
- {
111
- $check_status='checked';
112
- }
113
 
114
- if($site['expires']>time())
115
- {
116
- $date=date("l, F d, Y H:i", $site['expires']);
117
- }
118
- else
119
- {
120
- $date='Token has expired';
121
- }
 
 
 
122
 
123
- $i++;
124
- $html = apply_filters('wpvivid_put_transfer_key', $html);
125
- }
126
- $ret['html']= $html;
 
 
 
127
 
 
 
 
 
 
 
 
 
 
 
128
  }
129
  else
130
  {
131
- $ret['result']=WPVIVID_FAILED;
132
- $ret['error']= $res['error'];
133
  }
134
  }
135
- else
136
  {
137
- $ret['result']=WPVIVID_FAILED;
138
- $ret['error']= $response['body'];
139
- //$ret['error']= 'failed to parse returned data. Unable to retrieve the correct authorization data via HTTP request.';
140
  }
141
- }
142
- else
143
  {
144
- $ret['result']=WPVIVID_FAILED;
145
- $ret['error']= 'upload error '.$response['response']['code'].' '.$response['body'];
146
- //$response['body']
147
- }
148
  }
149
 
150
- echo json_encode($ret);
151
- }
152
- die();
153
- }
154
-
155
- public function delete_transfer_key(){
156
- $ret['result']=WPVIVID_SUCCESS;
157
- delete_option('wpvivid_saved_api_token');
158
- $html='';
159
- $html = apply_filters('wpvivid_put_transfer_key', $html);
160
- $ret['html']=$html;
161
- echo json_encode($ret);
162
- die();
163
- }
164
-
165
- public function send_backup_to_site()
166
- {
167
- try {
168
- $options = WPvivid_Setting::get_option('wpvivid_saved_api_token');
169
 
170
- if (empty($options)) {
171
- $ret['result'] = 'failed';
172
- $ret['error'] = 'A key is required.';
173
- echo json_encode($ret);
174
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  }
176
 
177
- $url = '';
178
- foreach ($options as $key => $value) {
179
- $url = $value['url'];
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  }
181
 
182
- if ($url === '') {
183
- $ret['result'] = 'failed';
184
- $ret['error'] = 'The key is invalid.';
185
- echo json_encode($ret);
186
- die();
187
  }
188
 
189
- if ($options[$url]['expires'] != 0 && $options[$url]['expires'] < time()) {
190
- $ret['result'] = 'failed';
191
- $ret['error'] = 'The key has expired.';
192
- echo json_encode($ret);
193
- die();
194
  }
195
 
196
- $json['test_connect']=1;
197
- $json=json_encode($json);
198
- $crypt=new WPvivid_crypt(base64_decode($options[$url]['token']));
199
- $data=$crypt->encrypt_message($json);
200
- $data=base64_encode($data);
201
- $args['body']=array('wpvivid_content'=>$data,'wpvivid_action'=>'send_to_site_connect');
202
- $response=wp_remote_post($url,$args);
203
-
204
- if ( is_wp_error( $response ) )
205
- {
206
- $ret['result']=WPVIVID_FAILED;
207
- $ret['error']= $response->get_error_message();
208
- echo json_encode($ret);
209
- die();
210
- }
211
- else
212
  {
213
- if($response['response']['code']==200) {
214
- $res=json_decode($response['body'],1);
215
- if($res!=null) {
216
- if($res['result']==WPVIVID_SUCCESS) {
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  }
218
- else {
219
- $ret['result']=WPVIVID_FAILED;
220
- $ret['error']= $res['error'];
221
- echo json_encode($ret);
222
- die();
223
  }
224
  }
225
- else {
226
- $ret['result']=WPVIVID_FAILED;
227
- $ret['error']= 'failed to parse returned data, unable to establish connection with the target site.';
228
- $ret['response']=$response;
229
- echo json_encode($ret);
230
- die();
231
  }
232
- }
233
- else {
234
- $ret['result']=WPVIVID_FAILED;
235
- $ret['error']= 'upload error '.$response['response']['code'].' '.$response['body'];
236
- echo json_encode($ret);
237
- die();
238
- }
239
  }
240
 
241
- if (WPvivid_taskmanager::is_tasks_backup_running()) {
242
- $ret['result'] = 'failed';
243
- $ret['error'] = __('A task is already running. Please wait until the running task is complete, and try again.', 'wpvivid');
244
- echo json_encode($ret);
245
- die();
 
 
 
 
 
246
  }
247
 
248
- $remote_option['url'] = $options[$url]['url'];
249
- $remote_option['token'] = $options[$url]['token'];
250
- $remote_option['type'] = WPVIVID_REMOTE_SEND_TO_SITE;
251
- $remote_options['temp'] = $remote_option;
252
-
253
- $backup_options = stripslashes($_POST['backup_options']);
254
- $backup_options = json_decode($backup_options, true);
255
- $backup['backup_files'] = $backup_options['transfer_type'];
256
- $backup['local'] = 0;
257
- $backup['remote'] = 1;
258
- $backup['ismerge'] = 1;
259
- $backup['lock'] = 0;
260
- $backup['remote_options'] = $remote_options;
261
-
262
- $backup_task = new WPvivid_Backup_Task();
263
- $ret = $backup_task->new_backup_task($backup, 'Manual', 'transfer');
264
-
265
- $task_id = $ret['task_id'];
266
-
267
- global $wpvivid_pulgin;
268
- $wpvivid_pulgin->check_backup($task_id, $backup['backup_files']);
269
- echo json_encode($ret);
270
- die();
271
- }
272
- catch (Exception $e){
273
- $ret['result'] = 'failed';
274
- $ret['error'] = $e->getMessage();
275
- echo json_encode($ret);
276
- die();
277
- }
278
- }
279
-
280
- public function migrate_now()
281
- {
282
- if (!isset($_POST['task_id'])||empty($_POST['task_id'])||!is_string($_POST['task_id']))
283
- {
284
- $ret['result']='failed';
285
- $ret['error']=__('Error occurred while parsing the request data. Please try to run backup again.', 'wpvivid');
286
- echo json_encode($ret);
287
- die();
288
- }
289
- $task_id=sanitize_key($_POST['task_id']);
290
-
291
- //Start backup site
292
- global $wpvivid_pulgin;
293
- $wpvivid_pulgin->backup($task_id);
294
- die();
295
- }
296
-
297
- function export_download_backup()
298
- {
299
- $schedule_options=WPvivid_Schedule::get_schedule();
300
- if(empty($schedule_options))
301
- {
302
- die();
303
- }
304
- $backup_options = stripslashes($_POST['backup_options']);
305
- $backup_options = json_decode($backup_options, true);
306
- $backup['backup_files']= $backup_options['transfer_type'];
307
- $backup['local']=1;
308
- $backup['remote']=0;
309
- $backup['ismerge']=1;
310
- $backup['lock']=0;
311
- //$backup['remote_options']='';
312
-
313
- $backup_task=new WPvivid_Backup_Task();
314
- $task=$backup_task->new_backup_task($backup,'Manual', 'export');
315
-
316
- $task_id=$task['task_id'];
317
- global $wpvivid_pulgin;
318
- //add_action('wpvivid_handle_upload_succeed',array($this,'wpvivid_deal_upload_succeed'),11);
319
- $wpvivid_pulgin->check_backup($task_id,$backup['backup_files']);
320
- $wpvivid_pulgin->backup($task_id);
321
- //}
322
- die();
323
- }
324
-
325
- function wpvivid_handle_backup_failed($task)
326
- {
327
- global $wpvivid_pulgin;
328
- if($task['action'] === 'transfer') {
329
- $backup_error_array = WPvivid_Setting::get_option('wpvivid_transfer_error_array');
330
- if (empty($backup_error_array)) {
331
- $backup_error_array = array();
332
- }
333
- if (!array_key_exists($task['id'], $backup_error_array['bu_error'])) {
334
- $backup_error_array['bu_error']['task_id'] = $task['id'];
335
- $backup_error_array['bu_error']['error_msg'] = $task['status']['error'];
336
- WPvivid_Setting::update_option('wpvivid_transfer_error_array', $backup_error_array);
337
  }
338
- $backup=new WPvivid_Backup($task['id']);
339
- $backup->clean_backup();
340
- $wpvivid_pulgin->wpvivid_log->WriteLog('Upload failed. Delete task '.$task['id'], 'notice');
341
- WPvivid_Backuplist::delete_backup($task['id']);
342
- }
343
- }
344
 
345
- public function wpvivid_deal_upload_succeed($task)
346
- {
347
- global $wpvivid_pulgin;
348
- if($task['action'] === 'transfer')
349
- {
350
- $backup_success_count = WPvivid_Setting::get_option('wpvivid_transfer_success_count');
351
- if (empty($backup_success_count))
352
  {
353
- $backup_success_count = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
354
  }
355
- $backup_success_count++;
356
- WPvivid_Setting::update_option('wpvivid_transfer_success_count', $backup_success_count);
357
-
358
- $wpvivid_pulgin->wpvivid_log->WriteLog('Upload finished. Delete task '.$task['id'], 'notice');
359
- WPvivid_Backuplist::delete_backup($task['id']);
360
- }
361
- }
362
 
363
- public function generate_url()
364
- {
365
- include_once WPVIVID_PLUGIN_DIR . '/vendor/autoload.php';
366
 
367
- $expires=time()+3600;
 
 
 
368
 
369
- if(isset($_POST['expires']))
370
- {
371
- if($_POST['expires']=='1 month')
372
- {
373
- $expires=time()+2592000;
374
- }
375
- else if($_POST['expires']=='1 day')
376
- {
377
- $expires=time()+86400;
378
- }
379
- else if($_POST['expires']=='2 hour')
380
- {
381
- $expires=time()+7200;
382
- }
383
- else if($_POST['expires']=='8 hour')
384
- {
385
- $expires=time()+28800;
386
- }
387
- else if($_POST['expires']=='24 hour')
388
- {
389
- $expires=time()+86400;
390
- }
391
- else if($_POST['expires']=='Never')
392
- {
393
- $expires=0;
394
- }
395
- }
396
-
397
- $key_size = 2048;
398
- $rsa = new Crypt_RSA();
399
- $keys = $rsa->createKey($key_size);
400
- $options['public_key']=base64_encode($keys['publickey']);
401
- $options['private_key']=base64_encode($keys['privatekey']);
402
- $options['expires']=$expires;
403
- $options['domain']=home_url();
404
-
405
- update_option('wpvivid_api_token',$options);
406
-
407
- $url= $options['domain'];
408
- $url=$url.'?domain='.$options['domain'].'&token='.$options['public_key'].'&expires='.$expires;
409
- echo $url;
410
- die();
411
- }
412
-
413
- public function add_addon_tab_transfer()
414
- {
415
- $html=' <a href="#" id="wpvivid_tab_migrate" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,\'migrate-page\')">Auto-Migration</a>';
416
- echo $html;
417
- }
418
-
419
- public function add_addon_tab_key(){
420
- $html='<a href="#" id="wpvivid_tab_key" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,\'key-page\')">Key</a>';
421
- echo $html;
422
- }
423
-
424
- public function wpvivid_put_transfer_key($html){
425
- $html='';
426
- $options=WPvivid_Setting::get_option('wpvivid_saved_api_token');
427
- if(empty($options)){
428
- $html .= '<div style="padding: 0 0 10px 0;"><strong>'.__('Please paste the key below.', 'wpvivid').'</strong><a href="#" style="margin-left: 5px;" onclick="wpvivid_click_how_to_get_key();">How to get a site key?</a></div>
429
- <div id="wpvivid_how_to_get_key"></div>
430
- <div><textarea type="text" id="wpvivid_transfer_key_text" onKeyUp="wpvivid_check_key(this.value)" style="width: 100%; height: 140px;"/></textarea></div>
431
- <div><input class="button-primary" id="wpvivid_save_url_button" type="submit" value="'.esc_attr( 'Save', 'wpvivid' ).'" onclick="wpvivid_click_save_site_url();" /></div>';
432
- }
433
- else{
434
- foreach ($options as $key => $value)
435
- {
436
- $token = $value['token'];
437
- $source_dir=home_url();
438
- $target_dir=$value['domain'];
439
- $expires=$value['expires'];
440
-
441
- if ($expires != 0 && time() > $expires) {
442
- $key_status='The key has expired. Please delete it first and generate a new one.';
443
- }
444
- else{
445
- $time_diff = $expires - time();
446
- $key_status = 'The key will expire in: '.date("H:i:s",$time_diff).'. Once the key expires, you need to generate a new key.';
447
- }
448
- }
449
- $html .= '<div style="padding: 10px 0 10px 0;">
450
- <span>Key:</span>
451
- <input type="text" id="wpvivid_send_remote_site_url_text" value="'.$token.'" readonly="readonly" />
452
- <input class="button-primary" id="wpvivid_delete_key_button" type="submit" value="'.esc_attr( 'Delete', 'wpvivid' ).'" onclick="wpvivid_click_delete_transfer_key();" />
453
- </div>
454
- <p>'.$key_status.'</p>
455
- <p>The connection is ok. Now you can transfer the site <strong>'.$source_dir.'</strong> to the site <strong>'.$target_dir.'</strong></p>';
456
- }
457
- return $html;
458
- }
459
-
460
- public function add_addon_page_transfer()
461
- {
462
- $backupdir=WPvivid_Setting::get_backupdir();
463
- ?>
464
- <div id="migrate-page" class="wrap-tab-content wpvivid_tab_migrate" name="tab-migrate" style="display: none;">
465
- <div style="padding: 0 0 10px 0;">
466
- <?php
467
- _e('The feature can help you transfer a Wordpress site to a new domain(site). It would be a convenient way to migrate your WP site from dev environment to live server or from old server to the new.', 'wpvivid');
468
- ?>
469
- </div>
470
-
471
- <div id="wpvivid_transfer_key">
472
- <?php
473
- $html = '';
474
- $html = apply_filters('wpvivid_put_transfer_key', $html);
475
- echo $html;
476
- ?>
477
- </div>
478
- <div style="clear: both;"></div>
479
-
480
- <div style="padding: 0 0 10px 0;">
481
- <div class="postbox" id="wpvivid_upload_backup_percent" >
482
- <div class="action-progress-bar" id="wpvivid_upload_progress_bar">
483
- <div class="action-progress-bar-percent" id="wpvivid_upload_progress_bar_percent" style="height:24px;width:0"></div>
484
- </div>
485
- <div style="margin-left:10px; float: left; width:100%;"><p id="wpvivid_upload_current_doing"></p></div>
486
- <div style="clear: both;"></div>
487
- <div>
488
- <div id="wpvivid_transfer_cancel" class="backup-log-btn"><input class="button-primary" id="wpvivid_transfer_cancel_btn" type="submit" value="<?php esc_attr_e( 'Cancel', 'wpvivid' ); ?>" /></div>
489
- </div>
490
- </div>
491
- </div>
492
-
493
- <div style="padding: 0 0 10px 0;">
494
- <div class="postbox quicktransfer">
495
- <h2><span><?php _e( 'Choose the content you want to transfer','wpvivid'); ?></span></h2>
496
- <div class="quickstart-archive-block">
497
- <fieldset>
498
- <legend class="screen-reader-text"><span>input type="radio"</span></legend>
499
- <label>
500
- <input type="radio" option="migrate" name="transfer_type" value="files+db" checked />
501
- <span><?php _e( 'Database + Files (Entire website)', 'wpvivid' ); ?></span>
502
- </label><br>
503
- <label>
504
- <input type="radio" option="migrate" name="transfer_type" value="files" />
505
- <span><?php _e( 'All Files (Exclude Database)', 'wpvivid' ); ?></span>
506
- </label><br>
507
- <label>
508
- <input type="radio" option="migrate" name="transfer_type" value="db" />
509
- <span><?php _e( 'Only Database', 'wpvivid' ); ?></span>
510
- </label><br>
511
- </fieldset>
512
- </div>
513
- </div>
514
-
515
- <p>Note: </p>
516
- <p>1. In order to successfully complete the migration, you'd better deactivate <a href="https://wpvivid.com/best-redirect-plugins.html" target="_blank">301 redirect plugin</a>, <a href="https://wpvivid.com/8-best-wordpress-firewall-plugins.html" target="_blank">firewall and security plugin</a>, and <a href="https://wpvivid.com/best-free-wordpress-caching-plugins.html" target="_blank">caching plugin</a> (if they exist) before transferring website.</p>
517
- <p>2. Please migrate website with the manual way when using <strong>Local by Flywheel</strong> environment.</p>
518
-
519
- <div style="padding: 0 0 10px 0;">
520
- <div id="wpvivid_transfer_btn" style="float: left;">
521
- <input class="button-primary quicktransfer-btn" type="submit" value="<?php esc_attr_e( 'Clone then Transfer', 'wpvivid'); ?>" onclick="wpvivid_click_send_backup();" />
522
- </div>
523
- </div>
524
- <div style="clear: both;"></div>
525
- <div style="padding: 10px 0 10px 0;">
526
- <p><strong>Tips: </strong>The unstable connection between sites could cause a failure of files transfer. In this case, uploading backups to destination site is a good alternative to the automatic website migration.</p>
527
- <p><strong>How to migrate Wordpress site manually to a new domain(site) with WPvivid backup plugin?</strong></p>
528
- <p>1. Download a backup in backups list to your computer.</p>
529
- <p>2. Upload the backup to destination site. There are two ways available to use:</p>
530
- <p style="margin-left: 20px;">2.1 Upload the backup to the upload section of WPvivid backup plugin in destination site.</p>
531
- <p style="margin-left: 20px;">2.2 Upload the backup with FTP client to backup directory <?php echo WP_CONTENT_DIR.'/'.$backupdir; ?> in destination site, then click <strong>Scan uploaded backup or received backup</strong> button.</p>
532
- <p>3. Once done, the backup appears in backups list. Then, restore the backup.</p>
533
- </div>
534
- </div>
535
- </div>
536
- <script>
537
- var wpvivid_home_url = '<?php
538
- $wpvivid_siteurl = array();
539
- $wpvivid_siteurl=WPvivid_Admin::wpvivid_get_siteurl();
540
- echo esc_url($wpvivid_siteurl['home_url']);
541
- ?>';
542
- var source_site = '<?php echo admin_url('admin-ajax.php'); ?>';
543
- jQuery('input:radio[option=migrate][name=transfer]').click(function(){
544
- var value = jQuery(this).prop('value');
545
- if(value === 'transfer'){
546
- jQuery('#wpvivid_transfer_btn').show();
547
- jQuery('#wpvivid_export_download_btn').hide();
548
- }
549
- else if(value === 'export'){
550
- jQuery('#wpvivid_transfer_btn').hide();
551
- jQuery('#wpvivid_export_download_btn').show();
552
- }
553
- });
554
- //wpvivid_edit_url_button
555
- jQuery('#wpvivid_add_remote_site_url').show();
556
- jQuery('#wpvivid_upload_backup_percent').hide();
557
-
558
- var wpvivid_transfer_id = '';
559
-
560
- function wpvivid_check_key(value){
561
- var pos = value.indexOf('?');
562
- var site_url = value.substring(0, pos);
563
- if(site_url == source_site){
564
- alert('The key generated by this site cannot be added into this site.');
565
- jQuery('#wpvivid_save_url_button').prop('disabled', true);
566
- }
567
- else{
568
- jQuery("#wpvivid_save_url_button").prop('disabled', false);
569
  }
570
  }
571
 
572
- function wpvivid_click_save_site_url()
573
  {
574
- var url= jQuery('#wpvivid_transfer_key_text').val();
575
- var ajax_data = {
576
- 'action': 'wpvivid_test_connect_site',
577
- 'url':url
578
- };
579
-
580
- jQuery("#wpvivid_save_url_button").prop('disabled', true);
581
- wpvivid_post_request(ajax_data, function (data)
582
- {
583
- jQuery("#wpvivid_save_url_button").prop('disabled', false);
584
- try
585
- {
586
- var jsonarray = jQuery.parseJSON(data);
587
- if(jsonarray.result==='success')
588
- {
589
- jQuery('#wpvivid_transfer_key').html(jsonarray.html);
590
- }
591
- else
592
- {
593
- alert(jsonarray.error);
594
- }
595
- }
596
- catch(err)
597
- {
598
- alert(err);
599
- }
600
- }, function (XMLHttpRequest, textStatus, errorThrown)
601
- {
602
- jQuery("#wpvivid_save_url_button").prop('disabled', false);
603
- var error_message = wpvivid_output_ajaxerror('saving key', textStatus, errorThrown);
604
- alert(error_message);
605
  });
606
  }
607
 
608
- function wpvivid_click_delete_transfer_key()
609
  {
610
- var ajax_data = {
611
- 'action': 'wpvivid_delete_transfer_key'
 
612
  };
613
-
614
- jQuery("#wpvivid_delete_key_button").css({'pointer-events': 'none', 'opacity': '0.4'});
615
- wpvivid_post_request(ajax_data, function (data)
616
- {
617
- jQuery("#wpvivid_delete_key_button").css({'pointer-events': 'none', 'opacity': '0.4'});
618
- try
619
- {
620
  var jsonarray = jQuery.parseJSON(data);
621
- if(jsonarray.result==='success')
622
- {
623
- jQuery('#wpvivid_transfer_key').html(jsonarray.html);
624
- }
625
  }
626
- catch(err)
627
- {
628
  alert(err);
629
  }
630
- }, function (XMLHttpRequest, textStatus, errorThrown)
631
- {
632
- jQuery("#wpvivid_delete_key_button").css({'pointer-events': 'auto', 'opacity': '1'});
633
- var error_message = wpvivid_output_ajaxerror('deleting key', textStatus, errorThrown);
634
- alert(error_message);
635
  });
636
  }
637
 
638
- function wpvivid_click_generate_url()
 
 
639
  {
640
- //
641
- var expires=jQuery('#wpvivid_generate_url_expires').val();
642
  var ajax_data = {
643
- 'action': 'wpvivid_generate_url',
644
- 'expires':expires
645
- };
646
- wpvivid_post_request(ajax_data, function (data)
647
- {
648
- jQuery('#wpvivid_test_remote_site_url_text').val(data);
649
- }, function (XMLHttpRequest, textStatus, errorThrown)
650
- {
651
- var error_message = wpvivid_output_ajaxerror('generating key', textStatus, errorThrown);
652
- alert(error_message);
653
- });
654
- }
655
-
656
- function wpvivid_control_transfer_lock(){
657
- jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
658
- jQuery('#wpvivid_transfer_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
659
- jQuery("#wpvivid_delete_key_button").css({'pointer-events': 'none', 'opacity': '0.4'});
660
- }
661
-
662
- function wpvivid_control_transfer_unlock(){
663
- jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
664
- jQuery('#wpvivid_transfer_btn').css({'pointer-events': 'auto', 'opacity': '1'});
665
- jQuery("#wpvivid_delete_key_button").css({'pointer-events': 'auto', 'opacity': '1'});
666
- }
667
-
668
- function wpvivid_click_send_backup()
669
- {
670
- //send_to_remote
671
- var option_data = wpvivid_ajax_data_transfer('migrate');
672
- var ajax_data = {
673
- 'action': 'wpvivid_send_backup_to_site',
674
- 'backup_options':option_data
675
- };
676
- migrate_task_need_update=true;
677
- wpvivid_clear_notice('wpvivid_backup_notice');
678
- wpvivid_control_transfer_lock();
679
- wpvivid_post_request(ajax_data, function (data)
680
- {
681
- try
682
- {
683
- var jsonarray = jQuery.parseJSON(data);
684
- if(jsonarray.result==='failed')
685
- {
686
- wpvivid_delete_transfer_ready_task(jsonarray.error);
687
- }
688
- else{
689
- wpvivid_transfer_id = jsonarray.task_id;
690
- wpvivid_migrate_now(jsonarray.task_id);
691
- }
692
- }
693
- catch(err)
694
- {
695
- wpvivid_delete_transfer_ready_task(err);
696
- }
697
- }, function (XMLHttpRequest, textStatus, errorThrown)
698
- {
699
- var error_message = wpvivid_output_ajaxerror('trying to establish communication with your server', textStatus, errorThrown);
700
- wpvivid_delete_transfer_ready_task(error_message);
701
- });
702
- }
703
-
704
- function wpvivid_migrate_now(task_id){
705
- var ajax_data = {
706
- 'action': 'wpvivid_migrate_now',
707
- 'task_id': task_id
708
- };
709
- task_recheck_times = 0;
710
- migrate_task_need_update=true;
711
- wpvivid_post_request(ajax_data, function(data){
712
- }, function(XMLHttpRequest, textStatus, errorThrown) {
713
- });
714
- }
715
-
716
- function wpvivid_delete_transfer_ready_task(error){
717
- var ajax_data={
718
- 'action': 'wpvivid_delete_ready_task'
719
- };
720
- wpvivid_post_request(ajax_data, function (data) {
721
- try {
722
- var jsonarray = jQuery.parseJSON(data);
723
- if (jsonarray.result === 'success') {
724
- wpvivid_add_notice('Backup', 'Error', error);
725
- wpvivid_control_transfer_unlock();
726
- jQuery('#wpvivid_upload_backup_percent').hide();
727
- }
728
- }
729
- catch(err){
730
- wpvivid_add_notice('Backup', 'Error', err);
731
- wpvivid_control_transfer_unlock();
732
- jQuery('#wpvivid_upload_backup_percent').hide();
733
- }
734
- }, function (XMLHttpRequest, textStatus, errorThrown) {
735
- setTimeout(function () {
736
- wpvivid_delete_transfer_ready_task(error);
737
- }, 3000);
738
- });
739
- }
740
-
741
- function wpvivid_click_export_backup()
742
- {
743
- var option_data = wpvivid_ajax_data_transfer('migrate');
744
- var ajax_data = {
745
- 'action': 'wpvivid_export_download_backup',
746
- 'backup_options':option_data
747
- };
748
- migrate_task_need_update=true;
749
- jQuery('#wpvivid_export_download_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
750
- wpvivid_post_request(ajax_data, function (data)
751
- {
752
- }, function (XMLHttpRequest, textStatus, errorThrown)
753
- {
754
- var error_message = wpvivid_output_ajaxerror('test generate url', textStatus, errorThrown);
755
- alert(error_message);
756
- });
757
- }
758
-
759
- var wpvivid_display_get_key = false;
760
-
761
- function click_dismiss_key_notice(obj){
762
- wpvivid_display_get_key = false;
763
- jQuery(obj).parent().remove();
764
- }
765
-
766
- function wpvivid_click_how_to_get_key(){
767
- if(!wpvivid_display_get_key) {
768
- wpvivid_display_get_key = true;
769
- var div = "<div class='notice notice-info is-dismissible inline'>" +
770
- "<p>1. Visit Key tab page of WPvivid backup plugin of destination site.</p>" +
771
- "<p>2. Generate a key by clicking Generate button and copy it.</p>" +
772
- "<p>3. Go back to this page and paste the key in key box below. Lastly, click Save button.</p>" +
773
- "<button type='button' class='notice-dismiss' onclick='click_dismiss_key_notice(this);'>" +
774
- "<span class='screen-reader-text'>Dismiss this notice.</span>" +
775
- "</button>" +
776
- "</div>";
777
- jQuery('#wpvivid_how_to_get_key').append(div);
778
- }
779
- }
780
-
781
- function wpvivid_transfer_cancel_flow()
782
- {
783
- jQuery('#wpvivid_transfer_cancel_btn').click(function(){
784
- wpvivid_cancel_transfer();
785
- });
786
- }
787
-
788
- function wpvivid_cancel_transfer()
789
- {
790
- var ajax_data= {
791
- 'action': 'wpvivid_backup_cancel',
792
- 'task_id': wpvivid_transfer_id
793
- };
794
- jQuery('#wpvivid_transfer_cancel_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
795
- wpvivid_post_request(ajax_data, function(data){
796
- try {
797
- var jsonarray = jQuery.parseJSON(data);
798
- jQuery('#wpvivid_upload_current_doing').html(jsonarray.msg);
799
- }
800
- catch(err){
801
- alert(err);
802
- }
803
- }, function(XMLHttpRequest, textStatus, errorThrown) {
804
- jQuery('#wpvivid_transfer_cancel_btn').css({'pointer-events': 'auto', 'opacity': '1'});
805
- var error_message = wpvivid_output_ajaxerror('cancelling the backup', textStatus, errorThrown);
806
- wpvivid_add_notice('Backup', 'Error', error_message);
807
- });
808
- }
809
-
810
- var migrate_task_need_update=true;
811
- var task_recheck_times=0;
812
- function wpvivid_check_upload_runningtask()
813
- {
814
- var ajax_data = {
815
- 'action': 'wpvivid_list_upload_tasks',
816
  };
817
  if(wpvivid_restoring === false) {
818
  wpvivid_post_request(ajax_data, function (data) {
@@ -901,114 +465,607 @@ class WPvivid_Migrate
901
  }
902
  }
903
 
904
- }, function (XMLHttpRequest, textStatus, errorThrown) {
905
- migrate_task_need_update = true;
906
- setTimeout(function () {
907
- wpvivid_manage_upload_task();
908
- }, 3000);
909
- });
910
- }
911
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
912
 
913
- function wpvivid_resume_transfer(backup_id, next_resume_time){
914
- if(next_resume_time < 0){
915
- next_resume_time = 0;
916
- }
917
- next_resume_time = next_resume_time * 1000;
918
- setTimeout("wpvivid_activate_migrate_cron()", next_resume_time);
919
- setTimeout(function(){
920
- task_recheck_times = 0;
921
- migrate_task_need_update=true;
922
- }, next_resume_time);
 
 
 
 
 
 
 
 
 
 
 
923
  }
 
 
 
 
 
 
924
 
925
- function wpvivid_manage_upload_task()
 
 
 
 
 
 
926
  {
927
- if(migrate_task_need_update){
928
- migrate_task_need_update=false;
929
- wpvivid_check_upload_runningtask();
930
- }
931
- else {
932
- setTimeout(function () {
933
- wpvivid_manage_upload_task();
934
- }, 3000);
935
- }
936
  }
 
 
937
 
938
- wpvivid_manage_upload_task();
 
 
 
939
 
940
- function wpvivid_activate_migrate_cron(){
941
- var next_get_time = 3 * 60 * 1000;
942
- jQuery.get(wpvivid_home_url+'/wp-cron.php');
943
- setTimeout("wpvivid_activate_migrate_cron()", next_get_time);
944
- setTimeout(function(){
945
- migrate_task_need_update=true;
946
- }, 10000);
 
 
 
 
 
 
 
 
947
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
948
 
949
- wpvivid_activate_migrate_cron();
 
 
 
 
 
 
950
 
951
- function switchmigrateTabs(evt,contentName,storage_page_id) {
952
- // Declare all variables
953
- var i, tabcontent, tablinks;
954
 
955
- // Get all elements with class="table-list-content" and hide them
956
- tabcontent = document.getElementsByClassName("migrate-tab-content");
957
- for (i = 0; i < tabcontent.length; i++) {
958
- tabcontent[i].style.display = "none";
959
- }
960
 
961
- // Get all elements with class="table-nav-tab" and remove the class "nav-tab-active"
962
- tablinks = document.getElementsByClassName("migrate-nav-tab");
963
- for (i = 0; i < tablinks.length; i++) {
964
- tablinks[i].className = tablinks[i].className.replace(" nav-tab-active", "");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
965
  }
 
 
 
 
 
 
 
 
 
 
 
 
966
 
967
- // Show the current tab, and add an "storage-menu-active" class to the button that opened the tab
968
- document.getElementById(contentName).style.display = "block";
969
- evt.currentTarget.className += " nav-tab-active";
 
 
 
970
 
971
- var top = jQuery('#'+storage_page_id).offset().top-jQuery('#'+storage_page_id).height();
972
- jQuery('html, body').animate({scrollTop:top}, 'slow');
973
- }
 
 
 
 
 
 
 
 
 
 
 
974
 
975
- </script>
976
- <?php
 
 
 
 
977
  }
978
 
979
- public function add_addon_page_key(){
980
- ?>
981
- <div id="key-page" class="wrap-tab-content wpvivid_tab_key" name="tab-key" style="display: none;">
982
- <div style="padding: 0 0 0 10px">
983
- <div style="padding: 0 0 10px 0">
984
- <span>In order to allow another site to send a backup to this site, please generate a key below. Once the key is generated, this site is ready to receive a backup from another site. Then, please copy and paste the key in sending site and save it.</span>
985
- </div>
986
- <strong><?php _e('The key will expire in ', 'wpvivid'); ?></strong>
987
- <select id="wpvivid_generate_url_expires" style="margin-bottom: 2px;">
988
- <option value="2 hour">2 hours</option>
989
- <option selected="selected" value="8 hour">8 hours</option>
990
- <option value="24 hour">24 hours</option>
991
- <!--<option value="Never">Never</option>-->
992
- </select>
993
- <p>Tips: For security reason, please choose an appropriate expiration time for the key.</p>
994
- <div>
995
- <input class="button-primary" id="wpvivid_generate_url" type="submit" value="<?php esc_attr_e( 'Generate', 'wpvivid' ); ?>" onclick="wpvivid_click_generate_url();" />
996
- </div>
997
- <div id="wpvivid_test_generate_url" style="padding-top: 10px;">
998
- <textarea id="wpvivid_test_remote_site_url_text" style="width: 100%; height: 140px;"></textarea>
999
- </div>
1000
- </div>
1001
- </div>
1002
- <script>
1003
- jQuery("#wpvivid_test_remote_site_url_text").focus(function() {
1004
- jQuery(this).select();
1005
- jQuery(this).mouseup(function() {
1006
- jQuery(this).unbind("mouseup");
1007
- return false;
1008
- });
1009
- });
1010
- </script>
1011
- <?php
1012
  }
1013
 
1014
  public function list_tasks()
@@ -1105,6 +1162,21 @@ class WPvivid_Migrate
1105
  die();
1106
  }
1107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1108
  function wpvivid_add_tab_upload(){
1109
  ?>
1110
  <a href="#" id="wpvivid_tab_upload" class="nav-tab backup-nav-tab" onclick="switchrestoreTabs(event,'page-upload')"><?php _e('Upload', 'wpvivid'); ?></a>
@@ -1117,7 +1189,7 @@ class WPvivid_Migrate
1117
  <div class="backup-tab-content wpvivid_tab_upload" id="page-upload" style="display:none;">
1118
  <div style="padding: 10px 0 10px 0;">
1119
  <div style="padding-bottom: 10px;">
1120
- <span>The backups will be uploaded to <?php echo WP_CONTENT_DIR.'/'.$backupdir; ?> directory.</span>
1121
  </div>
1122
  <div style="padding-bottom: 10px;">
1123
  <span>Note: The files you want to upload must be a backup created by WPvivid backup plugin. Make sure that uploading every part of a backup to the directory if the backup is split into many parts</span>
@@ -1129,14 +1201,4 @@ class WPvivid_Migrate
1129
  </div>
1130
  <?php
1131
  }
1132
-
1133
- function wpvivid_rescan_backup_list(){
1134
- ?>
1135
- <div style="padding: 0 0 10px 0;">
1136
- <?php
1137
- Wpvivid_BackupUploader::rescan_local_folder();
1138
- ?>
1139
- </div>
1140
- <?php
1141
- }
1142
  }
9
  {
10
  public function __construct()
11
  {
12
+ add_filter('wpvivid_add_tab_page', array($this, 'wpvivid_add_migrate_tab_page'));
 
 
 
13
  add_action('wp_ajax_wpvivid_generate_url',array( $this,'generate_url'));
14
  add_action('wp_ajax_wpvivid_send_backup_to_site',array( $this,'send_backup_to_site'));
15
  add_action('wp_ajax_wpvivid_migrate_now',array( $this,'migrate_now'));
16
+ add_filter('wpvivid_backuppage_load_backuplist', array($this, 'wpvivid_backuppage_load_backuplist'));
17
 
18
  add_action('wp_ajax_wpvivid_export_download_backup',array( $this,'export_download_backup'));
19
  add_action('wp_ajax_wpvivid_list_upload_tasks',array( $this,'list_tasks'));
23
  add_filter('wpvivid_put_transfer_key', array($this, 'wpvivid_put_transfer_key'));
24
  add_action('wpvivid_handle_backup_failed',array($this,'wpvivid_handle_backup_failed'),9);
25
 
 
 
26
  add_action('wpvivid_rescan_backup_list', array($this, 'wpvivid_rescan_backup_list'));
27
  add_action('wpvivid_handle_upload_succeed',array($this,'wpvivid_deal_upload_succeed'),11);
28
+
29
+ add_filter('wpvivid_add_migrate_type', array($this, 'wpvivid_add_migrate_type'), 11, 2);
30
+ add_filter('wpvivid_migrate_descript', array($this, 'wpvivid_migrate_descript'));
31
+ add_filter('wpvivid_migrate_part_type', array($this, 'wpvivid_migrate_part_type'));
32
+ add_filter('wpvivid_migrate_part_exec', array($this, 'wpvivid_migrate_part_exec'));
33
+ add_filter('wpvivid_migrate_part_note', array($this, 'wpvivid_migrate_part_note'));
34
+ add_filter('wpvivid_migrate_part_tip', array($this, 'wpvivid_migrate_part_tip'));
35
  }
36
 
37
+ public function wpvivid_add_migrate_tab_page($page_array){
38
+ $page_array['migrate'] = array('index' => '3', 'tab_func' => array($this, 'wpvivid_add_tab_migrate'), 'page_func' => array($this, 'wpvivid_add_page_migrate'));
39
+ $page_array['key'] = array('index' => '8', 'tab_func' => array($this, 'wpvivid_add_tab_key'), 'page_func' => array($this, 'wpvivid_add_page_key'));
40
+ return $page_array;
41
+ }
42
 
43
+ public function wpvivid_add_tab_migrate()
44
+ {
45
+ ?>
46
+ <a href="#" id="wpvivid_tab_migrate" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,'migrate-page')"><?php _e('Auto-Migration', 'wpvivid'); ?></a>
47
+ <?php
48
+ }
 
49
 
50
+ public function wpvivid_add_tab_key(){
51
+ ?>
52
+ <a href="#" id="wpvivid_tab_key" class="nav-tab wrap-nav-tab" onclick="switchTabs(event,'key-page')"><?php _e('Key', 'wpvivid'); ?></a>
53
+ <?php
54
+ }
 
 
 
 
 
 
 
55
 
56
+ public function wpvivid_add_page_migrate(){
57
+ $migrate_descript = '';
58
+ $migrate_key = '';
59
+ $migrate_part_type = '';
60
+ $migrate_part_exec = '';
61
+ $migrate_part_note = '';
62
+ $migrate_part_tip = '';
63
+ ?>
64
+ <div id="migrate-page" class="wrap-tab-content wpvivid_tab_migrate" name="tab-migrate" style="display: none;">
65
+ <?php
66
+ echo apply_filters('wpvivid_migrate_descript', $migrate_descript);
67
+ echo apply_filters('wpvivid_put_transfer_key', $migrate_key);
68
+ ?>
69
 
70
+ <div style="clear: both;"></div>
 
 
 
71
 
72
+ <div style="padding: 0 0 10px 0;">
73
+ <div class="postbox" id="wpvivid_upload_backup_percent" style="display: none;">
74
+ <div class="action-progress-bar" id="wpvivid_upload_progress_bar">
75
+ <div class="action-progress-bar-percent" id="wpvivid_upload_progress_bar_percent" style="height:24px;width:0"></div>
76
+ </div>
77
+ <div style="margin-left:10px; float: left; width:100%;"><p id="wpvivid_upload_current_doing"></p></div>
78
+ <div style="clear: both;"></div>
79
+ <div>
80
+ <div id="wpvivid_transfer_cancel" class="backup-log-btn"><input class="button-primary" id="wpvivid_transfer_cancel_btn" type="submit" value="<?php esc_attr_e( 'Cancel', 'wpvivid' ); ?>" /></div>
81
+ </div>
82
+ </div>
83
+ </div>
84
 
85
+ <div style="padding: 0 0 10px 0;">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
+ <?php echo apply_filters('wpvivid_migrate_part_type', $migrate_part_type); ?>
88
 
89
+ <?php echo apply_filters('wpvivid_migrate_part_note', $migrate_part_note); ?>
 
 
 
90
 
91
+ <div style="padding: 0 0 10px 0;">
92
+ <?php echo apply_filters('wpvivid_migrate_part_exec', $migrate_part_exec); ?>
93
+ </div>
94
+ <div style="clear: both;"></div>
95
+ <div style="padding: 10px 0 10px 0;">
96
+ <?php echo apply_filters('wpvivid_migrate_part_tip', $migrate_part_tip); ?>
97
+ </div>
98
+ </div>
99
+ </div>
100
+ <script>
101
+ var wpvivid_home_url = '<?php
102
+ $wpvivid_siteurl = array();
103
+ $wpvivid_siteurl=WPvivid_Admin::wpvivid_get_siteurl();
104
+ echo esc_url($wpvivid_siteurl['home_url']);
105
+ ?>';
106
+ var source_site = '<?php echo admin_url('admin-ajax.php'); ?>';
107
+ jQuery('input:radio[option=migrate][name=transfer]').click(function(){
108
+ var value = jQuery(this).prop('value');
109
+ if(value === 'transfer'){
110
+ jQuery('#wpvivid_transfer_btn').show();
111
+ jQuery('#wpvivid_export_download_btn').hide();
112
+ }
113
+ else if(value === 'export'){
114
+ jQuery('#wpvivid_transfer_btn').hide();
115
+ jQuery('#wpvivid_export_download_btn').show();
116
+ }
117
+ });
118
+ //wpvivid_edit_url_button
119
+ jQuery('#wpvivid_add_remote_site_url').show();
120
+ jQuery('#wpvivid_upload_backup_percent').hide();
121
 
122
+ var wpvivid_transfer_id = '';
 
 
 
 
 
 
 
 
123
 
124
+ function wpvivid_check_key(value){
125
+ var pos = value.indexOf('?');
126
+ var site_url = value.substring(0, pos);
127
+ if(site_url == source_site){
128
+ alert('The key generated by this site cannot be added into this site.');
129
+ jQuery('#wpvivid_save_url_button').prop('disabled', true);
130
+ }
131
+ else{
132
+ jQuery("#wpvivid_save_url_button").prop('disabled', false);
133
+ }
134
+ }
135
 
136
+ function wpvivid_click_save_site_url()
137
+ {
138
+ var url= jQuery('#wpvivid_transfer_key_text').val();
139
+ var ajax_data = {
140
+ 'action': 'wpvivid_test_connect_site',
141
+ 'url':url
142
+ };
143
 
144
+ jQuery("#wpvivid_save_url_button").prop('disabled', true);
145
+ wpvivid_post_request(ajax_data, function (data)
146
+ {
147
+ jQuery("#wpvivid_save_url_button").prop('disabled', false);
148
+ try
149
+ {
150
+ var jsonarray = jQuery.parseJSON(data);
151
+ if(jsonarray.result==='success')
152
+ {
153
+ jQuery('#wpvivid_transfer_key').html(jsonarray.html);
154
  }
155
  else
156
  {
157
+ alert(jsonarray.error);
 
158
  }
159
  }
160
+ catch(err)
161
  {
162
+ alert(err);
 
 
163
  }
164
+ }, function (XMLHttpRequest, textStatus, errorThrown)
 
165
  {
166
+ jQuery("#wpvivid_save_url_button").prop('disabled', false);
167
+ var error_message = wpvivid_output_ajaxerror('saving key', textStatus, errorThrown);
168
+ alert(error_message);
169
+ });
170
  }
171
 
172
+ function wpvivid_click_delete_transfer_key()
173
+ {
174
+ var ajax_data = {
175
+ 'action': 'wpvivid_delete_transfer_key'
176
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
 
178
+ jQuery("#wpvivid_delete_key_button").css({'pointer-events': 'none', 'opacity': '0.4'});
179
+ wpvivid_post_request(ajax_data, function (data)
180
+ {
181
+ jQuery("#wpvivid_delete_key_button").css({'pointer-events': 'none', 'opacity': '0.4'});
182
+ try
183
+ {
184
+ var jsonarray = jQuery.parseJSON(data);
185
+ if(jsonarray.result==='success')
186
+ {
187
+ jQuery('#wpvivid_transfer_key').html(jsonarray.html);
188
+ }
189
+ }
190
+ catch(err)
191
+ {
192
+ alert(err);
193
+ }
194
+ }, function (XMLHttpRequest, textStatus, errorThrown)
195
+ {
196
+ jQuery("#wpvivid_delete_key_button").css({'pointer-events': 'auto', 'opacity': '1'});
197
+ var error_message = wpvivid_output_ajaxerror('deleting key', textStatus, errorThrown);
198
+ alert(error_message);
199
+ });
200
  }
201
 
202
+ function wpvivid_click_generate_url()
203
+ {
204
+ //
205
+ var expires=jQuery('#wpvivid_generate_url_expires').val();
206
+ var ajax_data = {
207
+ 'action': 'wpvivid_generate_url',
208
+ 'expires':expires
209
+ };
210
+ wpvivid_post_request(ajax_data, function (data)
211
+ {
212
+ jQuery('#wpvivid_test_remote_site_url_text').val(data);
213
+ }, function (XMLHttpRequest, textStatus, errorThrown)
214
+ {
215
+ var error_message = wpvivid_output_ajaxerror('generating key', textStatus, errorThrown);
216
+ alert(error_message);
217
+ });
218
  }
219
 
220
+ function wpvivid_control_transfer_lock(){
221
+ jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
222
+ jQuery('#wpvivid_transfer_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
223
+ jQuery("#wpvivid_delete_key_button").css({'pointer-events': 'none', 'opacity': '0.4'});
 
224
  }
225
 
226
+ function wpvivid_control_transfer_unlock(){
227
+ jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'auto', 'opacity': '1'});
228
+ jQuery('#wpvivid_transfer_btn').css({'pointer-events': 'auto', 'opacity': '1'});
229
+ jQuery("#wpvivid_delete_key_button").css({'pointer-events': 'auto', 'opacity': '1'});
 
230
  }
231
 
232
+ function wpvivid_click_send_backup()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  {
234
+ //send_to_remote
235
+ var option_data = wpvivid_ajax_data_transfer('migrate');
236
+ var ajax_data = {
237
+ 'action': 'wpvivid_send_backup_to_site',
238
+ 'backup_options':option_data
239
+ };
240
+ migrate_task_need_update=true;
241
+ wpvivid_clear_notice('wpvivid_backup_notice');
242
+ wpvivid_control_transfer_lock();
243
+ wpvivid_post_request(ajax_data, function (data)
244
+ {
245
+ try
246
+ {
247
+ var jsonarray = jQuery.parseJSON(data);
248
+ if(jsonarray.result==='failed')
249
+ {
250
+ wpvivid_delete_transfer_ready_task(jsonarray.error);
251
  }
252
+ else{
253
+ wpvivid_transfer_id = jsonarray.task_id;
254
+ wpvivid_migrate_now(jsonarray.task_id);
 
 
255
  }
256
  }
257
+ catch(err)
258
+ {
259
+ wpvivid_delete_transfer_ready_task(err);
 
 
 
260
  }
261
+ }, function (XMLHttpRequest, textStatus, errorThrown)
262
+ {
263
+ var error_message = wpvivid_output_ajaxerror('trying to establish communication with your server', textStatus, errorThrown);
264
+ wpvivid_delete_transfer_ready_task(error_message);
265
+ });
 
 
266
  }
267
 
268
+ function wpvivid_migrate_now(task_id){
269
+ var ajax_data = {
270
+ 'action': 'wpvivid_migrate_now',
271
+ 'task_id': task_id
272
+ };
273
+ task_recheck_times = 0;
274
+ migrate_task_need_update=true;
275
+ wpvivid_post_request(ajax_data, function(data){
276
+ }, function(XMLHttpRequest, textStatus, errorThrown) {
277
+ });
278
  }
279
 
280
+ function wpvivid_delete_transfer_ready_task(error){
281
+ var ajax_data={
282
+ 'action': 'wpvivid_delete_ready_task'
283
+ };
284
+ wpvivid_post_request(ajax_data, function (data) {
285
+ try {
286
+ var jsonarray = jQuery.parseJSON(data);
287
+ if (jsonarray.result === 'success') {
288
+ wpvivid_add_notice('Backup', 'Error', error);
289
+ wpvivid_control_transfer_unlock();
290
+ jQuery('#wpvivid_upload_backup_percent').hide();
291
+ }
292
+ }
293
+ catch(err){
294
+ wpvivid_add_notice('Backup', 'Error', err);
295
+ wpvivid_control_transfer_unlock();
296
+ jQuery('#wpvivid_upload_backup_percent').hide();
297
+ }
298
+ }, function (XMLHttpRequest, textStatus, errorThrown) {
299
+ setTimeout(function () {
300
+ wpvivid_delete_transfer_ready_task(error);
301
+ }, 3000);
302
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  }
 
 
 
 
 
 
304
 
305
+ function wpvivid_click_export_backup()
 
 
 
 
 
 
306
  {
307
+ var option_data = wpvivid_ajax_data_transfer('migrate');
308
+ var ajax_data = {
309
+ 'action': 'wpvivid_export_download_backup',
310
+ 'backup_options':option_data
311
+ };
312
+ migrate_task_need_update=true;
313
+ jQuery('#wpvivid_export_download_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
314
+ wpvivid_post_request(ajax_data, function (data)
315
+ {
316
+ }, function (XMLHttpRequest, textStatus, errorThrown)
317
+ {
318
+ var error_message = wpvivid_output_ajaxerror('test generate url', textStatus, errorThrown);
319
+ alert(error_message);
320
+ });
321
  }
 
 
 
 
 
 
 
322
 
323
+ var wpvivid_display_get_key = false;
 
 
324
 
325
+ function click_dismiss_key_notice(obj){
326
+ wpvivid_display_get_key = false;
327
+ jQuery(obj).parent().remove();
328
+ }
329
 
330
+ function wpvivid_click_how_to_get_key(){
331
+ if(!wpvivid_display_get_key) {
332
+ wpvivid_display_get_key = true;
333
+ var div = "<div class='notice notice-info is-dismissible inline'>" +
334
+ "<p>1. Visit Key tab page of WPvivid backup plugin of destination site.</p>" +
335
+ "<p>2. Generate a key by clicking Generate button and copy it.</p>" +
336
+ "<p>3. Go back to this page and paste the key in key box below. Lastly, click Save button.</p>" +
337
+ "<button type='button' class='notice-dismiss' onclick='click_dismiss_key_notice(this);'>" +
338
+ "<span class='screen-reader-text'>Dismiss this notice.</span>" +
339
+ "</button>" +
340
+ "</div>";
341
+ jQuery('#wpvivid_how_to_get_key').append(div);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
  }
343
  }
344
 
345
+ function wpvivid_transfer_cancel_flow()
346
  {
347
+ jQuery('#wpvivid_transfer_cancel_btn').click(function(){
348
+ wpvivid_cancel_transfer();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  });
350
  }
351
 
352
+ function wpvivid_cancel_transfer()
353
  {
354
+ var ajax_data= {
355
+ 'action': 'wpvivid_backup_cancel',
356
+ 'task_id': wpvivid_transfer_id
357
  };
358
+ jQuery('#wpvivid_transfer_cancel_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
359
+ wpvivid_post_request(ajax_data, function(data){
360
+ try {
 
 
 
 
361
  var jsonarray = jQuery.parseJSON(data);
362
+ jQuery('#wpvivid_upload_current_doing').html(jsonarray.msg);
 
 
 
363
  }
364
+ catch(err){
 
365
  alert(err);
366
  }
367
+ }, function(XMLHttpRequest, textStatus, errorThrown) {
368
+ jQuery('#wpvivid_transfer_cancel_btn').css({'pointer-events': 'auto', 'opacity': '1'});
369
+ var error_message = wpvivid_output_ajaxerror('cancelling the backup', textStatus, errorThrown);
370
+ wpvivid_add_notice('Backup', 'Error', error_message);
 
371
  });
372
  }
373
 
374
+ var migrate_task_need_update=true;
375
+ var task_recheck_times=0;
376
+ function wpvivid_check_upload_runningtask()
377
  {
 
 
378
  var ajax_data = {
379
+ 'action': 'wpvivid_list_upload_tasks',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
380
  };
381
  if(wpvivid_restoring === false) {
382
  wpvivid_post_request(ajax_data, function (data) {
465
  }
466
  }
467
 
468
+ }, function (XMLHttpRequest, textStatus, errorThrown) {
469
+ migrate_task_need_update = true;
470
+ setTimeout(function () {
471
+ wpvivid_manage_upload_task();
472
+ }, 3000);
473
+ });
474
+ }
475
+ }
476
+
477
+ function wpvivid_resume_transfer(backup_id, next_resume_time){
478
+ if(next_resume_time < 0){
479
+ next_resume_time = 0;
480
+ }
481
+ next_resume_time = next_resume_time * 1000;
482
+ setTimeout("wpvivid_activate_migrate_cron()", next_resume_time);
483
+ setTimeout(function(){
484
+ task_recheck_times = 0;
485
+ migrate_task_need_update=true;
486
+ }, next_resume_time);
487
+ }
488
+
489
+ function wpvivid_manage_upload_task()
490
+ {
491
+ if(migrate_task_need_update){
492
+ migrate_task_need_update=false;
493
+ wpvivid_check_upload_runningtask();
494
+ }
495
+ else {
496
+ setTimeout(function () {
497
+ wpvivid_manage_upload_task();
498
+ }, 3000);
499
+ }
500
+ }
501
+
502
+ wpvivid_manage_upload_task();
503
+
504
+ function wpvivid_activate_migrate_cron(){
505
+ var next_get_time = 3 * 60 * 1000;
506
+ jQuery.get(wpvivid_home_url+'/wp-cron.php');
507
+ setTimeout("wpvivid_activate_migrate_cron()", next_get_time);
508
+ setTimeout(function(){
509
+ migrate_task_need_update=true;
510
+ }, 10000);
511
+ }
512
+
513
+ wpvivid_activate_migrate_cron();
514
+
515
+ function switchmigrateTabs(evt,contentName,storage_page_id) {
516
+ // Declare all variables
517
+ var i, tabcontent, tablinks;
518
+
519
+ // Get all elements with class="table-list-content" and hide them
520
+ tabcontent = document.getElementsByClassName("migrate-tab-content");
521
+ for (i = 0; i < tabcontent.length; i++) {
522
+ tabcontent[i].style.display = "none";
523
+ }
524
+
525
+ // Get all elements with class="table-nav-tab" and remove the class "nav-tab-active"
526
+ tablinks = document.getElementsByClassName("migrate-nav-tab");
527
+ for (i = 0; i < tablinks.length; i++) {
528
+ tablinks[i].className = tablinks[i].className.replace(" nav-tab-active", "");
529
+ }
530
+
531
+ // Show the current tab, and add an "storage-menu-active" class to the button that opened the tab
532
+ document.getElementById(contentName).style.display = "block";
533
+ evt.currentTarget.className += " nav-tab-active";
534
+
535
+ var top = jQuery('#'+storage_page_id).offset().top-jQuery('#'+storage_page_id).height();
536
+ jQuery('html, body').animate({scrollTop:top}, 'slow');
537
+ }
538
+
539
+ </script>
540
+ <?php
541
+ }
542
+
543
+ public function wpvivid_add_page_key(){
544
+ ?>
545
+ <div id="key-page" class="wrap-tab-content wpvivid_tab_key" name="tab-key" style="display: none;">
546
+ <div style="padding: 0 0 0 10px">
547
+ <div style="padding: 0 0 10px 0">
548
+ <span>In order to allow another site to send a backup to this site, please generate a key below. Once the key is generated, this site is ready to receive a backup from another site. Then, please copy and paste the key in sending site and save it.</span>
549
+ </div>
550
+ <strong><?php _e('The key will expire in ', 'wpvivid'); ?></strong>
551
+ <select id="wpvivid_generate_url_expires" style="margin-bottom: 2px;">
552
+ <option value="2 hour">2 hours</option>
553
+ <option selected="selected" value="8 hour">8 hours</option>
554
+ <option value="24 hour">24 hours</option>
555
+ <!--<option value="Never">Never</option>-->
556
+ </select>
557
+ <p>Tips: For security reason, please choose an appropriate expiration time for the key.</p>
558
+ <div>
559
+ <input class="button-primary" id="wpvivid_generate_url" type="submit" value="<?php esc_attr_e( 'Generate', 'wpvivid' ); ?>" onclick="wpvivid_click_generate_url();" />
560
+ </div>
561
+ <div id="wpvivid_test_generate_url" style="padding-top: 10px;">
562
+ <textarea id="wpvivid_test_remote_site_url_text" style="width: 100%; height: 140px;"></textarea>
563
+ </div>
564
+ </div>
565
+ </div>
566
+ <script>
567
+ jQuery("#wpvivid_test_remote_site_url_text").focus(function() {
568
+ jQuery(this).select();
569
+ jQuery(this).mouseup(function() {
570
+ jQuery(this).unbind("mouseup");
571
+ return false;
572
+ });
573
+ });
574
+ </script>
575
+ <?php
576
+ }
577
+
578
+ public function test_connect_site()
579
+ {
580
+ if(isset($_POST['url']))
581
+ {
582
+ $url=strtok($_POST['url'],'?');
583
+
584
+ if (filter_var($url, FILTER_VALIDATE_URL) === FALSE)
585
+ {
586
+ $ret['result']=WPVIVID_FAILED;
587
+ $ret['error']='The key is invalid.';
588
+ echo json_encode($ret);
589
+ die();
590
+ }
591
+
592
+ if($url==home_url())
593
+ {
594
+ $ret['result']=WPVIVID_FAILED;
595
+ $ret['error']='The key generated by this site cannot be added into this site.';
596
+ echo json_encode($ret);
597
+ die();
598
+ }
599
+
600
+ $query=parse_url ($_POST['url'],PHP_URL_QUERY);
601
+ if($query===null)
602
+ {
603
+ $query=strtok('?');
604
+ }
605
+ parse_str($query,$query_arr);
606
+ $token=$query_arr['token'];
607
+ $expires=$query_arr['expires'];
608
+ $domain=$query_arr['domain'];
609
+
610
+ if ($expires != 0 && time() > $expires) {
611
+ $ret['result'] = 'failed';
612
+ $ret['error'] = 'The key has expired.';
613
+ echo json_encode($ret);
614
+ die();
615
+ }
616
+
617
+ $json['test_connect']=1;
618
+ $json=json_encode($json);
619
+ $crypt=new WPvivid_crypt(base64_decode($token));
620
+ $data=$crypt->encrypt_message($json);
621
+ if($data===false)
622
+ {
623
+ $ret['result'] = 'failed';
624
+ $ret['error'] = 'Data encryption failed.';
625
+ echo json_encode($ret);
626
+ die();
627
+ }
628
+ $data=base64_encode($data);
629
+
630
+ $args['body']=array('wpvivid_content'=>$data,'wpvivid_action'=>'send_to_site_connect');
631
+ $args['timeout']=30;
632
+ $response=wp_remote_post($url,$args);
633
+
634
+ if ( is_wp_error( $response ) )
635
+ {
636
+ $ret['result']=WPVIVID_FAILED;
637
+ $ret['error']= $response->get_error_message();
638
+ }
639
+ else
640
+ {
641
+ if($response['response']['code']==200)
642
+ {
643
+ $res=json_decode($response['body'],1);
644
+ if($res!=null)
645
+ {
646
+ if($res['result']==WPVIVID_SUCCESS)
647
+ {
648
+ $ret['result']=WPVIVID_SUCCESS;
649
+
650
+ $options=WPvivid_Setting::get_option('wpvivid_saved_api_token');
651
+
652
+ $options[$url]['token']=$token;
653
+ $options[$url]['url']=$url;
654
+ $options[$url]['expires']=$expires;
655
+ $options[$url]['domain']=$domain;
656
+
657
+ delete_option('wpvivid_saved_api_token');
658
+ update_option('wpvivid_saved_api_token',$options);
659
+
660
+ $html='';
661
+ $i=0;
662
+ foreach ($options as $key=>$site)
663
+ {
664
+ $check_status='';
665
+ if($key==$url)
666
+ {
667
+ $check_status='checked';
668
+ }
669
+
670
+ if($site['expires']>time())
671
+ {
672
+ $date=date("l, F d, Y H:i", $site['expires']);
673
+ }
674
+ else
675
+ {
676
+ $date='Token has expired';
677
+ }
678
+
679
+ $i++;
680
+ $html = apply_filters('wpvivid_put_transfer_key', $html);
681
+ }
682
+ $ret['html']= $html;
683
+
684
+ }
685
+ else
686
+ {
687
+ $ret['result']=WPVIVID_FAILED;
688
+ $ret['error']= $res['error'];
689
+ }
690
+ }
691
+ else
692
+ {
693
+ $ret['result']=WPVIVID_FAILED;
694
+ $ret['error']= $response['body'];
695
+ //$ret['error']= 'failed to parse returned data. Unable to retrieve the correct authorization data via HTTP request.';
696
+ }
697
+ }
698
+ else
699
+ {
700
+ $ret['result']=WPVIVID_FAILED;
701
+ $ret['error']= 'upload error '.$response['response']['code'].' '.$response['body'];
702
+ //$response['body']
703
+ }
704
+ }
705
+
706
+ echo json_encode($ret);
707
+ }
708
+ die();
709
+ }
710
+
711
+ public function delete_transfer_key(){
712
+ $ret['result']=WPVIVID_SUCCESS;
713
+ delete_option('wpvivid_saved_api_token');
714
+ $html='';
715
+ $html = apply_filters('wpvivid_put_transfer_key', $html);
716
+ $ret['html']=$html;
717
+ echo json_encode($ret);
718
+ die();
719
+ }
720
+
721
+ public function send_backup_to_site()
722
+ {
723
+ try {
724
+ $options = WPvivid_Setting::get_option('wpvivid_saved_api_token');
725
+
726
+ if (empty($options)) {
727
+ $ret['result'] = 'failed';
728
+ $ret['error'] = 'A key is required.';
729
+ echo json_encode($ret);
730
+ die();
731
+ }
732
+
733
+ $url = '';
734
+ foreach ($options as $key => $value) {
735
+ $url = $value['url'];
736
+ }
737
+
738
+ if ($url === '') {
739
+ $ret['result'] = 'failed';
740
+ $ret['error'] = 'The key is invalid.';
741
+ echo json_encode($ret);
742
+ die();
743
+ }
744
+
745
+ if ($options[$url]['expires'] != 0 && $options[$url]['expires'] < time()) {
746
+ $ret['result'] = 'failed';
747
+ $ret['error'] = 'The key has expired.';
748
+ echo json_encode($ret);
749
+ die();
750
+ }
751
+
752
+ $json['test_connect']=1;
753
+ $json=json_encode($json);
754
+ $crypt=new WPvivid_crypt(base64_decode($options[$url]['token']));
755
+ $data=$crypt->encrypt_message($json);
756
+ $data=base64_encode($data);
757
+ $args['body']=array('wpvivid_content'=>$data,'wpvivid_action'=>'send_to_site_connect');
758
+ $response=wp_remote_post($url,$args);
759
+
760
+ if ( is_wp_error( $response ) )
761
+ {
762
+ $ret['result']=WPVIVID_FAILED;
763
+ $ret['error']= $response->get_error_message();
764
+ echo json_encode($ret);
765
+ die();
766
+ }
767
+ else
768
+ {
769
+ if($response['response']['code']==200) {
770
+ $res=json_decode($response['body'],1);
771
+ if($res!=null) {
772
+ if($res['result']==WPVIVID_SUCCESS) {
773
+ }
774
+ else {
775
+ $ret['result']=WPVIVID_FAILED;
776
+ $ret['error']= $res['error'];
777
+ echo json_encode($ret);
778
+ die();
779
+ }
780
+ }
781
+ else {
782
+ $ret['result']=WPVIVID_FAILED;
783
+ $ret['error']= 'failed to parse returned data, unable to establish connection with the target site.';
784
+ $ret['response']=$response;
785
+ echo json_encode($ret);
786
+ die();
787
+ }
788
+ }
789
+ else {
790
+ $ret['result']=WPVIVID_FAILED;
791
+ $ret['error']= 'upload error '.$response['response']['code'].' '.$response['body'];
792
+ echo json_encode($ret);
793
+ die();
794
+ }
795
+ }
796
+
797
+ if (WPvivid_taskmanager::is_tasks_backup_running()) {
798
+ $ret['result'] = 'failed';
799
+ $ret['error'] = __('A task is already running. Please wait until the running task is complete, and try again.', 'wpvivid');
800
+ echo json_encode($ret);
801
+ die();
802
+ }
803
+
804
+ $remote_option['url'] = $options[$url]['url'];
805
+ $remote_option['token'] = $options[$url]['token'];
806
+ $remote_option['type'] = WPVIVID_REMOTE_SEND_TO_SITE;
807
+ $remote_options['temp'] = $remote_option;
808
+
809
+ $backup_options = stripslashes($_POST['backup_options']);
810
+ $backup_options = json_decode($backup_options, true);
811
+ $backup['backup_files'] = $backup_options['transfer_type'];
812
+ $backup['local'] = 0;
813
+ $backup['remote'] = 1;
814
+ $backup['ismerge'] = 1;
815
+ $backup['lock'] = 0;
816
+ $backup['remote_options'] = $remote_options;
817
+
818
+ $backup_task = new WPvivid_Backup_Task();
819
+ $ret = $backup_task->new_backup_task($backup, 'Manual', 'transfer');
820
+
821
+ $task_id = $ret['task_id'];
822
+
823
+ global $wpvivid_pulgin;
824
+ $wpvivid_pulgin->check_backup($task_id, $backup['backup_files']);
825
+ echo json_encode($ret);
826
+ die();
827
+ }
828
+ catch (Exception $e){
829
+ $ret['result'] = 'failed';
830
+ $ret['error'] = $e->getMessage();
831
+ echo json_encode($ret);
832
+ die();
833
+ }
834
+ }
835
+
836
+ public function migrate_now()
837
+ {
838
+ if (!isset($_POST['task_id'])||empty($_POST['task_id'])||!is_string($_POST['task_id']))
839
+ {
840
+ $ret['result']='failed';
841
+ $ret['error']=__('Error occurred while parsing the request data. Please try to run backup again.', 'wpvivid');
842
+ echo json_encode($ret);
843
+ die();
844
+ }
845
+ $task_id=sanitize_key($_POST['task_id']);
846
+
847
+ //Start backup site
848
+ global $wpvivid_pulgin;
849
+ $wpvivid_pulgin->backup($task_id);
850
+ die();
851
+ }
852
+
853
+ function export_download_backup()
854
+ {
855
+ $schedule_options=WPvivid_Schedule::get_schedule();
856
+ if(empty($schedule_options))
857
+ {
858
+ die();
859
+ }
860
+ $backup_options = stripslashes($_POST['backup_options']);
861
+ $backup_options = json_decode($backup_options, true);
862
+ $backup['backup_files']= $backup_options['transfer_type'];
863
+ $backup['local']=1;
864
+ $backup['remote']=0;
865
+ $backup['ismerge']=1;
866
+ $backup['lock']=0;
867
+ //$backup['remote_options']='';
868
+
869
+ $backup_task=new WPvivid_Backup_Task();
870
+ $task=$backup_task->new_backup_task($backup,'Manual', 'export');
871
 
872
+ $task_id=$task['task_id'];
873
+ global $wpvivid_pulgin;
874
+ //add_action('wpvivid_handle_upload_succeed',array($this,'wpvivid_deal_upload_succeed'),11);
875
+ $wpvivid_pulgin->check_backup($task_id,$backup['backup_files']);
876
+ $wpvivid_pulgin->backup($task_id);
877
+ //}
878
+ die();
879
+ }
880
+
881
+ function wpvivid_handle_backup_failed($task)
882
+ {
883
+ global $wpvivid_pulgin;
884
+ if($task['action'] === 'transfer') {
885
+ $backup_error_array = WPvivid_Setting::get_option('wpvivid_transfer_error_array');
886
+ if (empty($backup_error_array)) {
887
+ $backup_error_array = array();
888
+ }
889
+ if (!array_key_exists($task['id'], $backup_error_array['bu_error'])) {
890
+ $backup_error_array['bu_error']['task_id'] = $task['id'];
891
+ $backup_error_array['bu_error']['error_msg'] = $task['status']['error'];
892
+ WPvivid_Setting::update_option('wpvivid_transfer_error_array', $backup_error_array);
893
  }
894
+ $backup=new WPvivid_Backup($task['id']);
895
+ $backup->clean_backup();
896
+ $wpvivid_pulgin->wpvivid_log->WriteLog('Upload failed. Delete task '.$task['id'], 'notice');
897
+ WPvivid_Backuplist::delete_backup($task['id']);
898
+ }
899
+ }
900
 
901
+ public function wpvivid_deal_upload_succeed($task)
902
+ {
903
+ global $wpvivid_pulgin;
904
+ if($task['action'] === 'transfer')
905
+ {
906
+ $backup_success_count = WPvivid_Setting::get_option('wpvivid_transfer_success_count');
907
+ if (empty($backup_success_count))
908
  {
909
+ $backup_success_count = 0;
 
 
 
 
 
 
 
 
910
  }
911
+ $backup_success_count++;
912
+ WPvivid_Setting::update_option('wpvivid_transfer_success_count', $backup_success_count);
913
 
914
+ $wpvivid_pulgin->wpvivid_log->WriteLog('Upload finished. Delete task '.$task['id'], 'notice');
915
+ WPvivid_Backuplist::delete_backup($task['id']);
916
+ }
917
+ }
918
 
919
+ public function generate_url()
920
+ {
921
+ include_once WPVIVID_PLUGIN_DIR . '/vendor/autoload.php';
922
+
923
+ $expires=time()+3600;
924
+
925
+ if(isset($_POST['expires']))
926
+ {
927
+ if($_POST['expires']=='1 month')
928
+ {
929
+ $expires=time()+2592000;
930
+ }
931
+ else if($_POST['expires']=='1 day')
932
+ {
933
+ $expires=time()+86400;
934
  }
935
+ else if($_POST['expires']=='2 hour')
936
+ {
937
+ $expires=time()+7200;
938
+ }
939
+ else if($_POST['expires']=='8 hour')
940
+ {
941
+ $expires=time()+28800;
942
+ }
943
+ else if($_POST['expires']=='24 hour')
944
+ {
945
+ $expires=time()+86400;
946
+ }
947
+ else if($_POST['expires']=='Never')
948
+ {
949
+ $expires=0;
950
+ }
951
+ }
952
 
953
+ $key_size = 2048;
954
+ $rsa = new Crypt_RSA();
955
+ $keys = $rsa->createKey($key_size);
956
+ $options['public_key']=base64_encode($keys['publickey']);
957
+ $options['private_key']=base64_encode($keys['privatekey']);
958
+ $options['expires']=$expires;
959
+ $options['domain']=home_url();
960
 
961
+ update_option('wpvivid_api_token',$options);
 
 
962
 
963
+ $url= $options['domain'];
964
+ $url=$url.'?domain='.$options['domain'].'&token='.$options['public_key'].'&expires='.$expires;
965
+ echo $url;
966
+ die();
967
+ }
968
 
969
+ public function wpvivid_put_transfer_key($html){
970
+ $html='<div id="wpvivid_transfer_key">';
971
+ $options=WPvivid_Setting::get_option('wpvivid_saved_api_token');
972
+ if(empty($options)){
973
+ $html .= '<div style="padding: 0 0 10px 0;"><strong>'.__('Please paste the key below.', 'wpvivid').'</strong><a href="#" style="margin-left: 5px;" onclick="wpvivid_click_how_to_get_key();">How to get a site key?</a></div>
974
+ <div id="wpvivid_how_to_get_key"></div>
975
+ <div><textarea type="text" id="wpvivid_transfer_key_text" onKeyUp="wpvivid_check_key(this.value)" style="width: 100%; height: 140px;"/></textarea></div>
976
+ <div><input class="button-primary" id="wpvivid_save_url_button" type="submit" value="'.esc_attr( 'Save', 'wpvivid' ).'" onclick="wpvivid_click_save_site_url();" /></div>';
977
+ }
978
+ else{
979
+ foreach ($options as $key => $value)
980
+ {
981
+ $token = $value['token'];
982
+ $source_dir=home_url();
983
+ $target_dir=$value['domain'];
984
+ $expires=$value['expires'];
985
+
986
+ if ($expires != 0 && time() > $expires) {
987
+ $key_status='The key has expired. Please delete it first and generate a new one.';
988
+ }
989
+ else{
990
+ $time_diff = $expires - time();
991
+ $key_status = 'The key will expire in: '.date("H:i:s",$time_diff).'. Once the key expires, you need to generate a new key.';
992
  }
993
+ }
994
+ $html .= '<div style="padding: 10px 0 10px 0;">
995
+ <span>Key:</span>
996
+ <input type="text" id="wpvivid_send_remote_site_url_text" value="'.$token.'" readonly="readonly" />
997
+ <input class="button-primary" id="wpvivid_delete_key_button" type="submit" value="'.esc_attr( 'Delete', 'wpvivid' ).'" onclick="wpvivid_click_delete_transfer_key();" />
998
+ </div>
999
+ <p>'.$key_status.'</p>
1000
+ <p>The connection is ok. Now you can transfer the site <strong>'.$source_dir.'</strong> to the site <strong>'.$target_dir.'</strong></p>';
1001
+ }
1002
+ $html.='</div>';
1003
+ return $html;
1004
+ }
1005
 
1006
+ public function wpvivid_migrate_descript($html){
1007
+ $html .= '<div style="padding: 0 0 10px 0;">
1008
+ '.__('The feature can help you transfer a Wordpress site to a new domain(site). It would be a convenient way to migrate your WP site from dev environment to live server or from old server to the new.', 'wpvivid').'
1009
+ </div>';
1010
+ return $html;
1011
+ }
1012
 
1013
+ public function wpvivid_migrate_part_type($html){
1014
+ $migrate_type = '';
1015
+ $type_name = 'transfer_type';
1016
+ $html = '<div class="postbox quicktransfer">
1017
+ <h2><span>'.__( 'Choose the content you want to transfer', 'wpvivid').'</span></h2>
1018
+ <div class="quickstart-archive-block">
1019
+ <fieldset>
1020
+ <legend class="screen-reader-text"><span>input type="radio"</span></legend>
1021
+ '.apply_filters('wpvivid_add_migrate_type', $migrate_type, $type_name).'
1022
+ </fieldset>
1023
+ </div>
1024
+ </div>';
1025
+ return $html;
1026
+ }
1027
 
1028
+ public function wpvivid_migrate_part_exec($html){
1029
+ $html = '';
1030
+ $html .= '<div id="wpvivid_transfer_btn" style="float: left;">
1031
+ <input class="button-primary quicktransfer-btn" type="submit" value="'.esc_attr( 'Clone then Transfer', 'wpvivid').'" onclick="wpvivid_click_send_backup();" />
1032
+ </div>';
1033
+ return $html;
1034
  }
1035
 
1036
+ public function wpvivid_migrate_part_note($html){
1037
+ $html .= ' <p>Note: </p>
1038
+ <p>1. In order to successfully complete the migration, you\'d better deactivate <a href="https://wpvivid.com/best-redirect-plugins.html" target="_blank">301 redirect plugin</a>, <a href="https://wpvivid.com/8-best-wordpress-firewall-plugins.html" target="_blank">firewall and security plugin</a>, and <a href="https://wpvivid.com/best-free-wordpress-caching-plugins.html" target="_blank">caching plugin</a> (if they exist) before transferring website.</p>
1039
+ <p>2. Please migrate website with the manual way when using <strong>Local by Flywheel</strong> environment.</p>';
1040
+ return $html;
1041
+ }
1042
+
1043
+ public function wpvivid_migrate_part_tip($html){
1044
+ $backupdir=WPvivid_Setting::get_backupdir();
1045
+ $html .= '<p><strong>Tips: </strong>The unstable connection between sites could cause a failure of files transfer. In this case, uploading backups to destination site is a good alternative to the automatic website migration.</p>
1046
+ <p><strong>How to migrate Wordpress site manually to a new domain(site) with WPvivid backup plugin?</strong></p>
1047
+ <p>1. Download a backup in backups list to your computer.</p>
1048
+ <p>2. Upload the backup to destination site. There are two ways available to use:</p>
1049
+ <p style="margin-left: 20px;">2.1 Upload the backup to the upload section of WPvivid backup plugin in destination site.</p>
1050
+ <p style="margin-left: 20px;">2.2 Upload the backup with FTP client to backup directory '.WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$backupdir.' in destination site, then click <strong>Scan uploaded backup or received backup</strong> button.</p>
1051
+ <p>3. Once done, the backup appears in backups list. Then, restore the backup.</p>';
1052
+ return $html;
1053
+ }
1054
+
1055
+ public function wpvivid_add_migrate_type($html, $name_type){
1056
+ $html .= '<label>
1057
+ <input type="radio" option="migrate" name="'.$name_type.'" value="files+db" checked />
1058
+ <span>'.__( 'Database + Files (Entire website)', 'wpvivid' ).'</span>
1059
+ </label><br>
1060
+ <label>
1061
+ <input type="radio" option="migrate" name="'.$name_type.'" value="files" />
1062
+ <span>'.__( 'All Files (Exclude Database)', 'wpvivid' ).'</span>
1063
+ </label><br>
1064
+ <label>
1065
+ <input type="radio" option="migrate" name="'.$name_type.'" value="db" />
1066
+ <span>'.__( 'Only Database', 'wpvivid' ).'</span>
1067
+ </label><br>';
1068
+ return $html;
1069
  }
1070
 
1071
  public function list_tasks()
1162
  die();
1163
  }
1164
 
1165
+ function wpvivid_rescan_backup_list(){
1166
+ ?>
1167
+ <div style="padding: 0 0 10px 0;">
1168
+ <?php
1169
+ Wpvivid_BackupUploader::rescan_local_folder();
1170
+ ?>
1171
+ </div>
1172
+ <?php
1173
+ }
1174
+
1175
+ public function wpvivid_backuppage_load_backuplist($backuplist_array){
1176
+ $backuplist_array['list_upload'] = array('index' => '2', 'tab_func' => array($this, 'wpvivid_add_tab_upload'), 'page_func' => array($this, 'wpvivid_add_page_upload'));
1177
+ return $backuplist_array;
1178
+ }
1179
+
1180
  function wpvivid_add_tab_upload(){
1181
  ?>
1182
  <a href="#" id="wpvivid_tab_upload" class="nav-tab backup-nav-tab" onclick="switchrestoreTabs(event,'page-upload')"><?php _e('Upload', 'wpvivid'); ?></a>
1189
  <div class="backup-tab-content wpvivid_tab_upload" id="page-upload" style="display:none;">
1190
  <div style="padding: 10px 0 10px 0;">
1191
  <div style="padding-bottom: 10px;">
1192
+ <span>The backups will be uploaded to <?php echo WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$backupdir; ?> directory.</span>
1193
  </div>
1194
  <div style="padding-bottom: 10px;">
1195
  <span>Note: The files you want to upload must be a backup created by WPvivid backup plugin. Make sure that uploading every part of a backup to the directory if the backup is split into many parts</span>
1201
  </div>
1202
  <?php
1203
  }
 
 
 
 
 
 
 
 
 
 
1204
  }
includes/class-wpvivid-mysqldump.php CHANGED
@@ -1002,7 +1002,8 @@ class WPvivid_Mysqldump
1002
  $i=0;
1003
  $i_check_cancel=0;
1004
  $count=0;
1005
- foreach ($resultSet as $row) {
 
1006
  $i++;
1007
  $vals = $this->escape($tableName, $row);
1008
 
1002
  $i=0;
1003
  $i_check_cancel=0;
1004
  $count=0;
1005
+ foreach ($resultSet as $row)
1006
+ {
1007
  $i++;
1008
  $vals = $this->escape($tableName, $row);
1009
 
includes/class-wpvivid-public-interface.php ADDED
@@ -0,0 +1,446 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WPvivid_Public_Interface
4
+ {
5
+ public function __construct()
6
+ {
7
+
8
+ }
9
+
10
+ public function prepare_backup($backup_options){
11
+ global $wpvivid_pulgin;
12
+ if(isset($backup_options)&&!empty($backup_options)){
13
+ if (is_null($backup_options)) {
14
+ $ret['error']='Invalid parameter param:'.$backup_options;
15
+ return $ret;
16
+ }
17
+ $ret = $wpvivid_pulgin->check_backup_option($backup_options);
18
+ if($ret['result']!='success') {
19
+ return $ret;
20
+ }
21
+ $ret=$wpvivid_pulgin->pre_backup($backup_options,'Manual');
22
+ if($ret['result']=='success') {
23
+ //Check the website data to be backed up
24
+ $ret['check']=$wpvivid_pulgin->check_backup($ret['task_id'],$backup_options['backup_files']);
25
+ if(isset($ret['check']['result']) && $ret['check']['result'] == 'failed') {
26
+ $ret['error']=$ret['check']['error'];
27
+ return $ret;
28
+ }
29
+ }
30
+ }
31
+ else{
32
+ $ret['error']='Error occurred while parsing the request data. Please try to run backup again.';
33
+ return $ret;
34
+ }
35
+ return $ret;
36
+ }
37
+
38
+ public function backup_now($task_id){
39
+ global $wpvivid_pulgin;
40
+ if (!isset($task_id)||empty($task_id)||!is_string($task_id))
41
+ {
42
+ $ret['error']=__('Error occurred while parsing the request data. Please try to run backup again.', 'wpvivid');
43
+ return $ret;
44
+ }
45
+ $task_id=sanitize_key($task_id);
46
+ $ret['result']='success';
47
+ $txt = '<mainwp>' . base64_encode( serialize( $ret ) ) . '</mainwp>';
48
+ // Close browser connection so that it can resume AJAX polling
49
+ header( 'Content-Length: ' . ( ( ! empty( $txt ) ) ? strlen( $txt ) : '0' ) );
50
+ header( 'Connection: close' );
51
+ header( 'Content-Encoding: none' );
52
+ if ( session_id() ) {
53
+ session_write_close();
54
+ }
55
+ echo $txt;
56
+ // These two added - 19-Feb-15 - started being required on local dev machine, for unknown reason (probably some plugin that started an output buffer).
57
+ if ( ob_get_level() ) {
58
+ ob_end_flush();
59
+ }
60
+ flush();
61
+
62
+ //Start backup site
63
+ $wpvivid_pulgin->backup($task_id);
64
+ $ret['result']='success';
65
+ }
66
+
67
+ public function get_status(){
68
+ $ret['result']='success';
69
+ $list_tasks=array();
70
+ $tasks=WPvivid_Setting::get_tasks();
71
+ foreach ($tasks as $task)
72
+ {
73
+ $backup = new WPvivid_Backup_Task($task['id']);
74
+ $list_tasks[$task['id']]=$backup->get_backup_task_info($task['id']);
75
+ if($list_tasks[$task['id']]['task_info']['need_update_last_task']===true){
76
+ $task_msg = WPvivid_taskmanager::get_task($task['id']);
77
+ WPvivid_Setting::update_option('wpvivid_last_msg',$task_msg);
78
+ }
79
+ }
80
+ $ret['wpvivid']['task']=$list_tasks;
81
+ $backuplist=WPvivid_Backuplist::get_backuplist();
82
+ $schedule=WPvivid_Schedule::get_schedule();
83
+ $ret['wpvivid']['backup_list']=$backuplist;
84
+ $ret['wpvivid']['schedule']=$schedule;
85
+ $ret['wpvivid']['schedule']['last_message']=WPvivid_Setting::get_last_backup_message('wpvivid_last_msg');
86
+ WPvivid_taskmanager::delete_marked_task();
87
+ return $ret;
88
+ }
89
+
90
+ public function get_backup_schedule(){
91
+ $schedule=WPvivid_Schedule::get_schedule();
92
+ $ret['result']='success';
93
+ $ret['wpvivid']['schedule']=$schedule;
94
+ $ret['wpvivid']['schedule']['last_message']=WPvivid_Setting::get_last_backup_message('wpvivid_last_msg');
95
+ return $ret;
96
+ }
97
+
98
+ public function get_backup_list(){
99
+ $backuplist=WPvivid_Backuplist::get_backuplist();
100
+ $ret['result']='success';
101
+ $ret['wpvivid']['backup_list']=$backuplist;
102
+ return $ret;
103
+ }
104
+
105
+ public function get_default_remote(){
106
+ global $wpvivid_pulgin;
107
+ $ret['result']='success';
108
+ $ret['remote_storage_type']=$wpvivid_pulgin->function_realize->_get_default_remote_storage();
109
+ return $ret;
110
+ }
111
+
112
+ public function delete_backup($backup_id, $force_del){
113
+ global $wpvivid_pulgin;
114
+ if(!isset($backup_id)||empty($backup_id)||!is_string($backup_id)) {
115
+ $ret['error']='Invalid parameter param: backup_id.';
116
+ return $ret;
117
+ }
118
+ if(!isset($force_del)){
119
+ $ret['error']='Invalid parameter param: force.';
120
+ return $ret;
121
+ }
122
+ if($force_del==0||$force_del==1) {
123
+ }
124
+ else {
125
+ $force_del=0;
126
+ }
127
+ $backup_id=sanitize_key($backup_id);
128
+ $ret=$wpvivid_pulgin->delete_backup_by_id($backup_id, $force_del);
129
+ $backuplist=WPvivid_Backuplist::get_backuplist();
130
+ $ret['wpvivid']['backup_list']=$backuplist;
131
+ return $ret;
132
+ }
133
+
134
+ public function delete_backup_array($backup_id_array){
135
+ global $wpvivid_pulgin;
136
+ if(!isset($backup_id_array)||empty($backup_id_array)||!is_array($backup_id_array)) {
137
+ $ret['error']='Invalid parameter param: backup_id';
138
+ return $ret;
139
+ }
140
+ $ret=array();
141
+ foreach($backup_id_array as $backup_id)
142
+ {
143
+ $backup_id=sanitize_key($backup_id);
144
+ $ret=$wpvivid_pulgin->delete_backup_by_id($backup_id);
145
+ }
146
+ $backuplist=WPvivid_Backuplist::get_backuplist();
147
+ $ret['wpvivid']['backup_list']=$backuplist;
148
+ return $ret;
149
+ }
150
+
151
+ public function set_security_lock($backup_id, $lock){
152
+ if(!isset($backup_id)||empty($backup_id)||!is_string($backup_id)){
153
+ $ret['error']='Backup id not found';
154
+ return $ret;
155
+ }
156
+ if(!isset($lock)){
157
+ $ret['error']='Invalid parameter param: lock';
158
+ return $ret;
159
+ }
160
+ $backup_id=sanitize_key($backup_id);
161
+ if($lock==0||$lock==1) {
162
+ }
163
+ else {
164
+ $lock=0;
165
+ }
166
+ WPvivid_Backuplist::set_security_lock($backup_id,$lock);
167
+ $backuplist=WPvivid_Backuplist::get_backuplist();
168
+ $ret['wpvivid']['backup_list']=$backuplist;
169
+ return $ret;
170
+ }
171
+
172
+ public function view_log($backup_id){
173
+ global $wpvivid_pulgin;
174
+ if (!isset($backup_id)||empty($backup_id)||!is_string($backup_id)){
175
+ $ret['error']='Backup id not found';
176
+ return $ret;
177
+ }
178
+ $backup_id=sanitize_key($backup_id);
179
+ $ret=$wpvivid_pulgin->function_realize->_get_log_file('backuplist', $backup_id);
180
+ if($ret['result'] == 'success') {
181
+ $file = fopen($ret['log_file'], 'r');
182
+ if (!$file) {
183
+ $ret['result'] = 'failed';
184
+ $ret['error'] = __('Unable to open the log file.', 'wpvivid');
185
+ return $ret;
186
+ }
187
+ $buffer = '';
188
+ while (!feof($file)) {
189
+ $buffer .= fread($file, 1024);
190
+ }
191
+ fclose($file);
192
+ $ret['data'] = $buffer;
193
+ }
194
+ else{
195
+ $ret['error']='Unknown error';
196
+ }
197
+ return $ret;
198
+ }
199
+
200
+ public function read_last_backup_log($log_file_name){
201
+ global $wpvivid_pulgin;
202
+ if(!isset($log_file_name)||empty($log_file_name)||!is_string($log_file_name))
203
+ {
204
+ $ret['result']='failed';
205
+ $ret['error']=__('Reading the log failed. Please try again.', 'wpvivid');
206
+ return $ret;
207
+ }
208
+ $log_file_name=sanitize_text_field($log_file_name);
209
+ $ret=$wpvivid_pulgin->function_realize->_get_log_file('lastlog', $log_file_name);
210
+ if($ret['result'] == 'success') {
211
+ $file = fopen($ret['log_file'], 'r');
212
+ if (!$file) {
213
+ $ret['result'] = 'failed';
214
+ $ret['error'] = __('Unable to open the log file.', 'wpvivid');
215
+ return $ret;
216
+ }
217
+ $buffer = '';
218
+ while (!feof($file)) {
219
+ $buffer .= fread($file, 1024);
220
+ }
221
+ fclose($file);
222
+ $ret['result'] = 'success';
223
+ $ret['data'] = $buffer;
224
+ }
225
+ else{
226
+ $ret['error']='Unknown error';
227
+ }
228
+ return $ret;
229
+ }
230
+
231
+ public function view_backup_task_log($backup_task_id){
232
+ global $wpvivid_pulgin;
233
+ if (!isset($backup_task_id)||empty($backup_task_id)||!is_string($backup_task_id)){
234
+ $ret['error']='Reading the log failed. Please try again.';
235
+ return $ret;
236
+ }
237
+ $backup_task_id = sanitize_key($backup_task_id);
238
+ $ret=$wpvivid_pulgin->function_realize->_get_log_file('tasklog', $backup_task_id);
239
+ if($ret['result'] == 'success') {
240
+ $file = fopen($ret['log_file'], 'r');
241
+ if (!$file) {
242
+ $ret['result'] = 'failed';
243
+ $ret['error'] = __('Unable to open the log file.', 'wpvivid');
244
+ return $ret;
245
+ }
246
+ $buffer = '';
247
+ while (!feof($file)) {
248
+ $buffer .= fread($file, 1024);
249
+ }
250
+ fclose($file);
251
+ $ret['result'] = 'success';
252
+ $ret['data'] = $buffer;
253
+ }
254
+ else{
255
+ $ret['error']='Unknown error';
256
+ }
257
+ return $ret;
258
+ }
259
+
260
+ public function backup_cancel($task_id){
261
+ global $wpvivid_pulgin;
262
+ if (!isset($task_id)||empty($task_id)||!is_string($task_id)){
263
+ $ret['error']='Backup id not found';
264
+ return $ret;
265
+ }
266
+ $task_id=sanitize_key($task_id);
267
+ $ret=$wpvivid_pulgin->function_realize->_backup_cancel($task_id);
268
+ return $ret;
269
+ }
270
+
271
+ public function init_download_page($backup_id){
272
+ global $wpvivid_pulgin;
273
+ if(!isset($backup_id)||empty($backup_id)||!is_string($backup_id)) {
274
+ $ret['error']='Invalid parameter param:'.$backup_id;
275
+ return $ret;
276
+ }
277
+ else {
278
+ $backup_id=sanitize_key($backup_id);
279
+ return $wpvivid_pulgin->init_download($backup_id);
280
+ }
281
+ }
282
+
283
+ public function prepare_download_backup($backup_id, $file_name){
284
+ if(!isset($backup_id)||empty($backup_id)||!is_string($backup_id))
285
+ {
286
+ $ret['error']='Invalid parameter param:'.$backup_id;
287
+ return $ret;
288
+ }
289
+ if(!isset($file_name)||empty($file_name)||!is_string($file_name))
290
+ {
291
+ $ret['error']='Invalid parameter param:'.$file_name;
292
+ return $ret;
293
+ }
294
+ $download_info=array();
295
+ $download_info['backup_id']=sanitize_key($backup_id);
296
+ $download_info['file_name'] = $file_name;
297
+
298
+ set_time_limit(600);
299
+ if (session_id())
300
+ session_write_close();
301
+ try
302
+ {
303
+ $downloader=new WPvivid_downloader();
304
+ $downloader->ready_download($download_info);
305
+ }
306
+ catch (Exception $e)
307
+ {
308
+ $message = 'A exception ('.get_class($e).') occurred '.$e->getMessage().' (Code: '.$e->getCode().', line '.$e->getLine().' in '.$e->getFile().')';
309
+ error_log($message);
310
+ return array('error'=>$message);
311
+ }
312
+ catch (Error $e)
313
+ {
314
+ $message = 'A error ('.get_class($e).') has occurred: '.$e->getMessage().' (Code: '.$e->getCode().', line '.$e->getLine().' in '.$e->getFile().')';
315
+ error_log($message);
316
+ return array('error'=>$message);
317
+ }
318
+
319
+ $ret['result']='success';
320
+ return $ret;
321
+ }
322
+
323
+ public function get_download_task($backup_id){
324
+ if(!isset($backup_id)||empty($backup_id)||!is_string($backup_id)) {
325
+ $ret['error']='Invalid parameter param:'.$backup_id;
326
+ return $ret;
327
+ }
328
+ else {
329
+ $backup = WPvivid_Backuplist::get_backuplist_by_key($backup_id);
330
+ if ($backup === false) {
331
+ $ret['result'] = WPVIVID_FAILED;
332
+ $ret['error'] = 'backup id not found';
333
+ return $ret;
334
+ }
335
+ $backup_item = new WPvivid_Backup_Item($backup);
336
+ $ret = $backup_item->update_download_page($backup_id);
337
+ return $ret;
338
+ }
339
+ }
340
+
341
+ public function download_backup($backup_id, $file_name){
342
+ global $wpvivid_pulgin;
343
+ if(!isset($backup_id)||empty($backup_id)||!is_string($backup_id)) {
344
+ $ret['error']='Invalid parameter param: backup_id';
345
+ return $ret;
346
+ }
347
+ if(!isset($file_name)||empty($file_name)||!is_string($file_name)) {
348
+ $ret['error']='Invalid parameter param: file_name';
349
+ return $ret;
350
+ }
351
+ $backup_id=sanitize_key($backup_id);
352
+ $cache=WPvivid_taskmanager::get_download_cache($backup_id);
353
+ if($cache===false) {
354
+ $wpvivid_pulgin->init_download($backup_id);
355
+ $cache=WPvivid_taskmanager::get_download_cache($backup_id);
356
+ }
357
+ $path=false;
358
+ if(array_key_exists($file_name,$cache['files'])) {
359
+ if($cache['files'][$file_name]['status']=='completed') {
360
+ $path=$cache['files'][$file_name]['download_path'];
361
+ $download_url = $cache['files'][$file_name]['download_url'];
362
+ }
363
+ }
364
+ if($path!==false) {
365
+ if (file_exists($path)) {
366
+ $ret['download_url'] = $download_url;
367
+ $ret['size'] = filesize($path);
368
+ }
369
+ }
370
+ return $ret;
371
+ }
372
+
373
+ public function set_general_setting($setting){
374
+ $ret=array();
375
+ try {
376
+ if(isset($setting)&&!empty($setting)) {
377
+ $json_setting = $setting;
378
+ $json_setting = stripslashes($json_setting);
379
+ $setting = json_decode($json_setting, true);
380
+ if (is_null($setting)) {
381
+ $ret['error']='bad parameter';
382
+ return $ret;
383
+ }
384
+ WPvivid_Setting::update_setting($setting);
385
+ }
386
+
387
+ $ret['result']='success';
388
+ }
389
+ catch (Exception $error) {
390
+ $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
391
+ error_log($message);
392
+ return array('error'=>$message);
393
+ }
394
+ return $ret;
395
+ }
396
+
397
+ public function set_schedule($schedule){
398
+ $ret=array();
399
+ try {
400
+ if(isset($schedule)&&!empty($schedule)) {
401
+ $json = $schedule;
402
+ $json = stripslashes($json);
403
+ $schedule = json_decode($json, true);
404
+ if (is_null($schedule)) {
405
+ $ret['error']='bad parameter';
406
+ return $ret;
407
+ }
408
+ $ret=WPvivid_Schedule::set_schedule_ex($schedule);
409
+ if($ret['result']!='success') {
410
+ return $ret;
411
+ }
412
+ }
413
+ $ret['result']='success';
414
+ }
415
+ catch (Exception $error) {
416
+ $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
417
+ error_log($message);
418
+ return array('error'=>$message);
419
+ }
420
+ return $ret;
421
+ }
422
+
423
+ public function set_remote($remote){
424
+ global $wpvivid_pulgin;
425
+ $ret=array();
426
+ try {
427
+ if(isset($remote)&&!empty($remote)) {
428
+ $json = $remote;
429
+ $json = stripslashes($json);
430
+ $remote = json_decode($json, true);
431
+ if (is_null($remote)) {
432
+ $ret['error']='bad parameter';
433
+ return $ret;
434
+ }
435
+ $wpvivid_pulgin->function_realize->_set_remote($remote);
436
+ }
437
+ $ret['result']='success';
438
+ }
439
+ catch (Exception $error) {
440
+ $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';';
441
+ error_log($message);
442
+ return array('error'=>$message);
443
+ }
444
+ return $ret;
445
+ }
446
+ }
includes/class-wpvivid-schedule.php CHANGED
@@ -164,72 +164,18 @@ class WPvivid_Schedule
164
  }
165
  }
166
  }
167
-
168
- /*if($time['type']=='wpvivid_12hours' || $time['type']=='twicedaily')
169
- {
170
- if(strtotime('now')>strtotime($current_day))
171
- {
172
- $temp=$current_day.' +1 day';
173
- return strtotime($temp);
174
- }
175
- else
176
- {
177
- return strtotime($current_day);
178
- }
179
- }
180
-
181
- if($time['type']=='wpvivid_daily')
182
- {
183
- if(strtotime('now')>strtotime($current_day))
184
- {
185
- $temp=$current_day.' +1 day';
186
- return strtotime($temp);
187
- }
188
- else
189
- {
190
- return strtotime($current_day);
191
- }
192
- }
193
-
194
- if($time['type']=='wpvivid_weekly')
195
- {
196
- $temp=$week.' '.$current_day;
197
-
198
- if(strtotime('now')>strtotime($temp))
199
- {
200
- $temp=$week.' '.$temp.' next week';
201
- return strtotime($temp);
202
- }
203
- return strtotime($temp);
204
- }
205
-
206
- if($time['type']=='wpvivid_fortnightly')
207
- {
208
- $temp=$week.' '.$current_day;
209
- if(strtotime('now')>strtotime($temp))
210
- {
211
- $temp=$week.' '.$temp.' next week';
212
- }
213
- return strtotime($temp);
214
- }
215
-
216
- if($time['type']=='wpvivid_monthly')
217
- {
218
- $date_now =date("Y-m-",time());
219
- $temp=$date_now.$day.' '.$current_day;
220
- if(strtotime('now')>strtotime($temp))
221
- {
222
- $date_now=date("Y-m-",strtotime('+1 month'));
223
- $temp=$date_now.$day.' '.$current_day;
224
- }
225
-
226
- return strtotime($temp);
227
- }*/
228
-
229
  return false;
230
  }
231
 
232
- public static function get_schedule()
 
 
 
 
 
 
 
 
233
  {
234
  $schedule=WPvivid_Setting::get_option('wpvivid_schedule_setting');
235
 
@@ -254,9 +200,7 @@ class WPvivid_Schedule
254
  $schedule['recurrence']=$recurrence;
255
  $timestamp=wp_next_scheduled(WPVIVID_MAIN_SCHEDULE_EVENT);
256
 
257
-
258
  $schedule['next_start']=$timestamp;
259
-
260
  return $schedule;
261
  }
262
 
164
  }
165
  }
166
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  return false;
168
  }
169
 
170
+ public static function get_schedule($schedule_id = '')
171
+ {
172
+ add_filter('wpvivid_get_schedule', array('WPvivid_Schedule', 'get_schedule_ex'),10,2);
173
+ $schedule=array();
174
+ $schedule=apply_filters('wpvivid_get_schedule',$schedule,$schedule_id);
175
+ return $schedule;
176
+ }
177
+
178
+ public static function get_schedule_ex($schedule,$schedule_id)
179
  {
180
  $schedule=WPvivid_Setting::get_option('wpvivid_schedule_setting');
181
 
200
  $schedule['recurrence']=$recurrence;
201
  $timestamp=wp_next_scheduled(WPVIVID_MAIN_SCHEDULE_EVENT);
202
 
 
203
  $schedule['next_start']=$timestamp;
 
204
  return $schedule;
205
  }
206
 
includes/class-wpvivid-setting.php CHANGED
@@ -283,7 +283,7 @@ class WPvivid_Setting
283
  return true;
284
  }
285
 
286
- public static function get_backup_options($post)
287
  {
288
  self::check_compress_options();
289
  self::check_local_options();
@@ -317,7 +317,7 @@ class WPvivid_Setting
317
  $backup_options['compress']=self::get_option('wpvivid_compress_setting');
318
  $backup_options['dir']=self::get_backupdir();
319
  return $backup_options;
320
- }
321
 
322
  public static function get_remote_option($id)
323
  {
283
  return true;
284
  }
285
 
286
+ /*public static function get_backup_options($post)
287
  {
288
  self::check_compress_options();
289
  self::check_local_options();
317
  $backup_options['compress']=self::get_option('wpvivid_compress_setting');
318
  $backup_options['dir']=self::get_backupdir();
319
  return $backup_options;
320
+ }*/
321
 
322
  public static function get_remote_option($id)
323
  {
includes/class-wpvivid-upload.php CHANGED
@@ -117,32 +117,6 @@ class WPvivid_Upload
117
  $backup_item=new WPvivid_Backup_Item($backup);
118
 
119
  return $backup_item->get_files();
120
-
121
- /*$path=WP_CONTENT_DIR.'/'.$backup['local']['path'];
122
- $files=array();
123
- $files_list=array();
124
-
125
- if($backup['backup']['ismerge']==1)
126
- {
127
- $files=$backup['backup']['data']['meta']['files'];
128
- }
129
- else
130
- {
131
- foreach ($backup['backup']['data']['type'] as $type)
132
- {
133
- foreach ($type['files'] as $file)
134
- {
135
- $files[]=$file;
136
- }
137
- }
138
- }
139
-
140
- foreach ($files as $file)
141
- {
142
- $files_list[] = $path . DIRECTORY_SEPARATOR . $file['file_name'];
143
- }
144
-
145
- return $files_list;*/
146
  }
147
 
148
  public function clean_remote_backup($remotes,$files)
117
  $backup_item=new WPvivid_Backup_Item($backup);
118
 
119
  return $backup_item->get_files();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  }
121
 
122
  public function clean_remote_backup($remotes,$files)
includes/class-wpvivid-zipclass.php CHANGED
@@ -489,24 +489,27 @@ class WPvivid_ZipClass extends Wpvivid_Compress_Default
489
  {
490
  $archive = new PclZip($path);
491
  $list = $archive->listContent();
492
- foreach ($list as $item)
493
- {
494
- //index
495
- if(basename($item['filename'])==='wpvivid_package_info.json')
496
- {
497
- $result = $archive->extract(PCLZIP_OPT_BY_NAME, 'wpvivid_package_info.json',PCLZIP_OPT_EXTRACT_AS_STRING);
498
- if($result != 0)
499
- {
500
- return $result[0]['content'];
501
- }
502
- else
503
- {
504
- return false;
 
505
  }
506
  }
 
 
 
507
  }
508
-
509
- return false;
510
  }
511
 
512
  public function list_file($path)
489
  {
490
  $archive = new PclZip($path);
491
  $list = $archive->listContent();
492
+ if($list == false){
493
+ return array('result'=>WPVIVID_FAILED,'error'=>$archive->errorInfo(true));
494
+ }
495
+ else {
496
+ $b_exist = false;
497
+ foreach ($list as $item) {
498
+ if (basename($item['filename']) === 'wpvivid_package_info.json') {
499
+ $b_exist = true;
500
+ $result = $archive->extract(PCLZIP_OPT_BY_NAME, 'wpvivid_package_info.json', PCLZIP_OPT_EXTRACT_AS_STRING);
501
+ if ($result != 0) {
502
+ return array('result'=>WPVIVID_SUCCESS,'json_data'=>$result[0]['content']);
503
+ } else {
504
+ return array('result'=>WPVIVID_FAILED,'error'=>$archive->errorInfo(true));
505
+ }
506
  }
507
  }
508
+ if(!$b_exist){
509
+ return array('result'=>WPVIVID_FAILED,'error'=>'Failed to get json, this may be a old version backup.');
510
+ }
511
  }
512
+ return array('result'=>WPVIVID_FAILED,'error'=>'Unknown error');
 
513
  }
514
 
515
  public function list_file($path)
includes/class-wpvivid.php CHANGED
@@ -46,6 +46,8 @@ class WPvivid {
46
 
47
  public $remote_collection;
48
 
 
 
49
  public $end_shutdown_function;
50
 
51
  public $restore_data;
@@ -116,6 +118,7 @@ class WPvivid {
116
 
117
  add_action('wpvivid_handle_backup_failed',array($this,'wpvivid_mark_task'),20);
118
  add_action('init', array($this, 'init_pclzip_tmp_folder'));
 
119
  //Initialisation schedule hook
120
  $this->init_cron();
121
  //Initialisation log object
@@ -156,15 +159,19 @@ class WPvivid {
156
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-restore.php';
157
 
158
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-remote-collection.php';
 
159
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-upload.php';
160
 
161
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-backup-uploader.php';
162
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-crypt.php';
163
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-migrate.php';
164
 
165
- include_once WPVIVID_PLUGIN_DIR.'/includes/class-wpvivid-db-method.php';
 
 
166
 
167
  $this->remote_collection=new WPvivid_Remote_collection();
 
168
  $this->migrate=new WPvivid_Migrate();
169
  $this->backup_uploader=new Wpvivid_BackupUploader();
170
  }
@@ -202,6 +209,8 @@ class WPvivid {
202
  add_filter('plugin_action_links_' . $plugin_basename, array( $plugin_admin,'add_action_links'));
203
 
204
  add_filter('wpvivid_pre_add_remote',array($this, 'pre_add_remote'),10,2);
 
 
205
  //
206
  }
207
 
@@ -375,7 +384,7 @@ class WPvivid {
375
  if($ret['result']=='success')
376
  {
377
  //Check the website data to be backed up
378
- $ret['check']=$this->check_backup($ret['task_id'],$backup_options['backup_files']);
379
  if(isset($ret['check']['result']) && $ret['check']['result'] == WPVIVID_FAILED)
380
  {
381
  $this->end_shutdown_function=true;
@@ -440,6 +449,14 @@ class WPvivid {
440
  }
441
 
442
  public function check_backup_option($data, $backup_method = 'Manual')
 
 
 
 
 
 
 
 
443
  {
444
  $ret['result']=WPVIVID_FAILED;
445
  if(!isset($data['backup_files']))
@@ -471,20 +488,22 @@ class WPvivid {
471
  return $ret;
472
  }
473
 
474
- if($backup_method == 'Manual') {
475
- if ($data['remote'] === '1') {
 
 
476
  $remote_storage = WPvivid_Setting::get_remote_options();
477
- if ($remote_storage == false) {
 
478
  $ret['error'] = __('There is no default remote storage configured. Please set it up first.', 'wpvivid');
479
  return $ret;
480
  }
481
  }
482
  }
483
-
484
  $ret['result']=WPVIVID_SUCCESS;
485
- $ret=apply_filters('wpvivid_check_backup_options_valid',$ret,$data);
486
  return $ret;
487
  }
 
488
  /**
489
  * Delete tasks had [ready] status.
490
  *
@@ -724,20 +743,7 @@ class WPvivid {
724
  try {
725
  if (isset($_POST['task_id']) && !empty($_POST['task_id']) && is_string($_POST['task_id'])) {
726
  $task_id = sanitize_key($_POST['task_id']);
727
- if (WPvivid_taskmanager::get_task($task_id) !== false) {
728
- $file_name = WPvivid_taskmanager::get_task_options($task_id, 'file_prefix');
729
- $backup_options = WPvivid_taskmanager::get_task_options($task_id, 'backup_options');
730
- $file = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $backup_options['dir'] . DIRECTORY_SEPARATOR . $file_name . '_cancel';
731
- touch($file);
732
- }
733
-
734
- $timestamp = wp_next_scheduled(WPVIVID_TASK_MONITOR_EVENT, array($task_id));
735
-
736
- if ($timestamp === false) {
737
- $this->add_monitor_event($task_id, 10);
738
- }
739
- $json['result'] = 'success';
740
- $json['msg'] = __('The backup will be canceled after backing up the current chunk ends.', 'wpvivid');
741
  echo json_encode($json);
742
  }
743
  }
@@ -749,19 +755,13 @@ class WPvivid {
749
  }
750
  die();
751
  }
752
- /**
753
- * Main backup schedule.
754
- *
755
- * Start a backup task schedule.
756
- *
757
- * @since 0.9.1
758
- */
759
- public function main_schedule()
760
  {
761
  //get backup options
762
  $this->end_shutdown_function=false;
763
  register_shutdown_function(array($this,'deal_prepare_shutdown_error'));
764
- $schedule_options=WPvivid_Schedule::get_schedule();
765
  if(empty($schedule_options))
766
  {
767
  $this->end_shutdown_function=true;
@@ -772,18 +772,17 @@ class WPvivid {
772
  $schedule_options['backup']['remote'] = strval($schedule_options['backup']['remote']);
773
  $schedule_options['backup']['ismerge'] = strval($schedule_options['backup']['ismerge']);
774
  $schedule_options['backup']['lock'] = strval($schedule_options['backup']['lock']);
775
-
776
  $ret = $this->check_backup_option($schedule_options['backup'], 'Cron');
777
  if ($ret['result'] != WPVIVID_SUCCESS) {
778
  $this->end_shutdown_function=true;
779
  echo json_encode($ret);
780
  die();
781
  }
782
-
783
  $ret = $this->pre_backup($schedule_options['backup'], 'Cron');
784
  if ($ret['result'] == 'success') {
785
  //Check the website data to be backed up.
786
- $this->check_backup($ret['task_id'], $schedule_options['backup']['backup_files']);
787
  //start backup task.
788
  $this->backup($ret['task_id']);
789
  }
@@ -796,6 +795,7 @@ class WPvivid {
796
  $ret['result']='failed';
797
  $message = 'An exception has occurred. class:'.get_class($error).';msg:'.$error->getMessage().';code:'.$error->getCode().';line:'.$error->getLine().';in_file:'.$error->getFile().';';
798
  $ret['error'] = $message;
 
799
  $id=uniqid('wpvivid-');
800
  $log_file_name=$id.'_backup';
801
  $log=new WPvivid_Log();
@@ -1270,7 +1270,7 @@ class WPvivid {
1270
  if($this->end_shutdown_function===false)
1271
  {
1272
  $last_error = error_get_last();
1273
- if (!empty($last_error) && !in_array($last_error['type'], array(E_NOTICE,E_WARNING), true))
1274
  {
1275
  $error = $last_error;
1276
  } else {
@@ -1529,7 +1529,7 @@ class WPvivid {
1529
  *
1530
  * @since 0.9.1
1531
  */
1532
- public function check_backup($task_id,$backup_files)
1533
  {
1534
  $options=WPvivid_Setting::get_option('wpvivid_common_setting');
1535
  if(isset($options['estimate_backup']))
@@ -1545,22 +1545,13 @@ class WPvivid {
1545
  }
1546
 
1547
  $file_size=false;
1548
- $check_file=false;
1549
- $check_db=false;
1550
 
1551
- if($backup_files=='files+db')
1552
- {
1553
- $check_file=true;
1554
- $check_db=true;
1555
- }
1556
- else if($backup_files=='files')
1557
- {
1558
- $check_file=true;
1559
- }
1560
- else if($backup_files=='db')
1561
- {
1562
- $check_db=true;
1563
- }
1564
 
1565
  $sapi_type=php_sapi_name();
1566
 
@@ -1633,6 +1624,28 @@ class WPvivid {
1633
  }
1634
  return $ret;
1635
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1636
  /**
1637
  * Add a backup task resume schedule.
1638
  *
@@ -4908,6 +4921,10 @@ class WPvivid {
4908
  $row_style = '';
4909
  $upload_title = '';
4910
  }
 
 
 
 
4911
 
4912
  if(empty($value['lock'])){
4913
  $backup_lock='/admin/partials/images/unlocked.png';
46
 
47
  public $remote_collection;
48
 
49
+ public $function_realize;
50
+
51
  public $end_shutdown_function;
52
 
53
  public $restore_data;
118
 
119
  add_action('wpvivid_handle_backup_failed',array($this,'wpvivid_mark_task'),20);
120
  add_action('init', array($this, 'init_pclzip_tmp_folder'));
121
+
122
  //Initialisation schedule hook
123
  $this->init_cron();
124
  //Initialisation log object
159
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-restore.php';
160
 
161
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-remote-collection.php';
162
+ include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-function-realize.php';
163
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-upload.php';
164
 
165
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-backup-uploader.php';
166
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-crypt.php';
167
  include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-migrate.php';
168
 
169
+ include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-db-method.php';
170
+
171
+ include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-public-interface.php';
172
 
173
  $this->remote_collection=new WPvivid_Remote_collection();
174
+ $this->function_realize=new WPvivid_Function_Realize();
175
  $this->migrate=new WPvivid_Migrate();
176
  $this->backup_uploader=new Wpvivid_BackupUploader();
177
  }
209
  add_filter('plugin_action_links_' . $plugin_basename, array( $plugin_admin,'add_action_links'));
210
 
211
  add_filter('wpvivid_pre_add_remote',array($this, 'pre_add_remote'),10,2);
212
+
213
+ add_filter('wpvivid_add_tab_page', array($plugin_admin, 'wpvivid_add_default_tab_page'));
214
  //
215
  }
216
 
384
  if($ret['result']=='success')
385
  {
386
  //Check the website data to be backed up
387
+ $ret['check']=$this->check_backup($ret['task_id'],$backup_options);
388
  if(isset($ret['check']['result']) && $ret['check']['result'] == WPVIVID_FAILED)
389
  {
390
  $this->end_shutdown_function=true;
449
  }
450
 
451
  public function check_backup_option($data, $backup_method = 'Manual')
452
+ {
453
+ $ret['result']=WPVIVID_SUCCESS;
454
+ add_filter('wpvivid_check_backup_options_valid',array($this, 'check_backup_options_valid'),10,3);
455
+ $ret=apply_filters('wpvivid_check_backup_options_valid',$ret,$data,$backup_method);
456
+ return $ret;
457
+ }
458
+
459
+ public function check_backup_options_valid($ret,$data,$backup_method)
460
  {
461
  $ret['result']=WPVIVID_FAILED;
462
  if(!isset($data['backup_files']))
488
  return $ret;
489
  }
490
 
491
+ if($backup_method == 'Manual')
492
+ {
493
+ if ($data['remote'] === '1')
494
+ {
495
  $remote_storage = WPvivid_Setting::get_remote_options();
496
+ if ($remote_storage == false)
497
+ {
498
  $ret['error'] = __('There is no default remote storage configured. Please set it up first.', 'wpvivid');
499
  return $ret;
500
  }
501
  }
502
  }
 
503
  $ret['result']=WPVIVID_SUCCESS;
 
504
  return $ret;
505
  }
506
+
507
  /**
508
  * Delete tasks had [ready] status.
509
  *
743
  try {
744
  if (isset($_POST['task_id']) && !empty($_POST['task_id']) && is_string($_POST['task_id'])) {
745
  $task_id = sanitize_key($_POST['task_id']);
746
+ $json = $this->function_realize->_backup_cancel($task_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
747
  echo json_encode($json);
748
  }
749
  }
755
  }
756
  die();
757
  }
758
+
759
+ public function main_schedule($schedule_id='')
 
 
 
 
 
 
760
  {
761
  //get backup options
762
  $this->end_shutdown_function=false;
763
  register_shutdown_function(array($this,'deal_prepare_shutdown_error'));
764
+ $schedule_options=WPvivid_Schedule::get_schedule($schedule_id);
765
  if(empty($schedule_options))
766
  {
767
  $this->end_shutdown_function=true;
772
  $schedule_options['backup']['remote'] = strval($schedule_options['backup']['remote']);
773
  $schedule_options['backup']['ismerge'] = strval($schedule_options['backup']['ismerge']);
774
  $schedule_options['backup']['lock'] = strval($schedule_options['backup']['lock']);
 
775
  $ret = $this->check_backup_option($schedule_options['backup'], 'Cron');
776
  if ($ret['result'] != WPVIVID_SUCCESS) {
777
  $this->end_shutdown_function=true;
778
  echo json_encode($ret);
779
  die();
780
  }
781
+ file_put_contents('F:\wamp64_3.19\www\wordpress\test_premium\wp-content\wpvividbackups\test.txt','test2');
782
  $ret = $this->pre_backup($schedule_options['backup'], 'Cron');
783
  if ($ret['result'] == 'success') {
784
  //Check the website data to be backed up.
785
+ $this->check_backup($ret['task_id'], $schedule_options['backup']);
786
  //start backup task.
787
  $this->backup($ret['task_id']);
788
  }
795
  $ret['result']='failed';
796
  $message = 'An exception has occurred. class:'.get_class($error).';msg:'.$error->getMessage().';code:'.$error->getCode().';line:'.$error->getLine().';in_file:'.$error->getFile().';';
797
  $ret['error'] = $message;
798
+ file_put_contents('F:\wamp64_3.19\www\wordpress\test_premium\wp-content\wpvividbackups\test.txt',$message);
799
  $id=uniqid('wpvivid-');
800
  $log_file_name=$id.'_backup';
801
  $log=new WPvivid_Log();
1270
  if($this->end_shutdown_function===false)
1271
  {
1272
  $last_error = error_get_last();
1273
+ if (!empty($last_error) && !in_array($last_error['type'], array(E_NOTICE,E_WARNING,E_USER_NOTICE,E_USER_WARNING), true))
1274
  {
1275
  $error = $last_error;
1276
  } else {
1529
  *
1530
  * @since 0.9.1
1531
  */
1532
+ public function check_backup($task_id,$backup_option)
1533
  {
1534
  $options=WPvivid_Setting::get_option('wpvivid_common_setting');
1535
  if(isset($options['estimate_backup']))
1545
  }
1546
 
1547
  $file_size=false;
 
 
1548
 
1549
+ $check['check_file']=false;
1550
+ $check['check_db']=false;
1551
+ add_filter('wpvivid_check_backup_size',array($this, 'check_backup_size'),10,2);
1552
+ $check = apply_filters('wpvivid_check_backup_size', $check,$backup_option);
1553
+ $check_file=$check['check_file'];
1554
+ $check_db=$check['check_db'];
 
 
 
 
 
 
 
1555
 
1556
  $sapi_type=php_sapi_name();
1557
 
1624
  }
1625
  return $ret;
1626
  }
1627
+
1628
+ public function check_backup_size($check,$backup_option)
1629
+ {
1630
+ if(isset($backup_option['backup_files']))
1631
+ {
1632
+ if($backup_option['backup_files']=='files+db')
1633
+ {
1634
+ $check['check_file']=true;
1635
+ $check['check_db']=true;
1636
+ }
1637
+ else if($backup_option['backup_files']=='files')
1638
+ {
1639
+ $check['check_file']=true;
1640
+ }
1641
+ else if($backup_option['backup_files']=='db')
1642
+ {
1643
+ $check['check_db']=true;
1644
+ }
1645
+ }
1646
+ return $check;
1647
+ }
1648
+
1649
  /**
1650
  * Add a backup task resume schedule.
1651
  *
4921
  $row_style = '';
4922
  $upload_title = '';
4923
  }
4924
+ else
4925
+ {
4926
+ $upload_title='';
4927
+ }
4928
 
4929
  if(empty($value['lock'])){
4930
  $backup_lock='/admin/partials/images/unlocked.png';
includes/customclass/class-wpvivid-amazons3-plus.php CHANGED
@@ -429,7 +429,7 @@ class WPvivid_AMAZONS3Class extends WPvivid_Remote{
429
  }
430
  @fclose($fh);
431
 
432
- if(filesize($file_path) === $file['size']){
433
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
434
  $res = TRUE;
435
  }
429
  }
430
  @fclose($fh);
431
 
432
+ if(filesize($file_path) == $file['size']){
433
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
434
  $res = TRUE;
435
  }
includes/customclass/class-wpvivid-dropbox.php CHANGED
@@ -235,7 +235,7 @@ class WPvivid_Dropbox extends WPvivid_Remote {
235
  }
236
  @fclose($fh);
237
 
238
- if(filesize($file_path) === $file['size']){
239
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
240
  $res = TRUE;
241
  }
235
  }
236
  @fclose($fh);
237
 
238
+ if(filesize($file_path) == $file['size']){
239
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
240
  $res = TRUE;
241
  }
includes/customclass/class-wpvivid-ftpclass.php CHANGED
@@ -4,7 +4,8 @@ if (!defined('WPVIVID_PLUGIN_DIR')){
4
  die;
5
  }
6
 
7
- define('WPVIVID_REMOTE_FTP','ftp');
 
8
 
9
  require_once WPVIVID_PLUGIN_DIR .'/includes/customclass/class-wpvivid-remote.php';
10
  class WPvivid_FTPClass extends WPvivid_Remote{
@@ -421,7 +422,7 @@ class WPvivid_FTPClass extends WPvivid_Remote{
421
  }
422
  }
423
 
424
- if(filesize($local_path) === $file['size']){
425
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
426
  $res = TRUE;
427
  }
4
  die;
5
  }
6
 
7
+ if(!defined('WPVIVID_REMOTE_FTP'))
8
+ define('WPVIVID_REMOTE_FTP','ftp');
9
 
10
  require_once WPVIVID_PLUGIN_DIR .'/includes/customclass/class-wpvivid-remote.php';
11
  class WPvivid_FTPClass extends WPvivid_Remote{
422
  }
423
  }
424
 
425
+ if(filesize($local_path) == $file['size']){
426
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
427
  $res = TRUE;
428
  }
includes/customclass/class-wpvivid-s3compat.php CHANGED
@@ -296,7 +296,7 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
296
  }
297
  @fclose($fh);
298
 
299
- if(filesize($file_path) === $file['size']){
300
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
301
  $res = TRUE;
302
  }
296
  }
297
  @fclose($fh);
298
 
299
+ if(filesize($file_path) == $file['size']){
300
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
301
  $res = TRUE;
302
  }
includes/customclass/class-wpvivid-send-to-site.php CHANGED
@@ -466,7 +466,7 @@ class WPvivid_Send_to_site extends WPvivid_Remote
466
  $data = $crypt->decrypt_message($body);
467
  if (!is_string($data)) {
468
  $ret['result'] = WPVIVID_FAILED;
469
- $ret['error'] = 'The key is invalid.';
470
  echo json_encode($ret);
471
  die();
472
  }
@@ -474,7 +474,7 @@ class WPvivid_Send_to_site extends WPvivid_Remote
474
  $params = json_decode($data, 1);
475
  if (is_null($params)) {
476
  $ret['result'] = WPVIVID_FAILED;
477
- $ret['error'] = 'The key is invalid.';
478
  echo json_encode($ret);
479
  die();
480
  }
466
  $data = $crypt->decrypt_message($body);
467
  if (!is_string($data)) {
468
  $ret['result'] = WPVIVID_FAILED;
469
+ $ret['error'] = 'Data decryption failed.';
470
  echo json_encode($ret);
471
  die();
472
  }
474
  $params = json_decode($data, 1);
475
  if (is_null($params)) {
476
  $ret['result'] = WPVIVID_FAILED;
477
+ $ret['error'] = 'Data decode failed.';
478
  echo json_encode($ret);
479
  die();
480
  }
includes/customclass/class-wpvivid-sftpclass.php CHANGED
@@ -395,7 +395,7 @@ class WPvivid_SFTPClass extends WPvivid_Remote{
395
  $result = $conn->get($remote_file_name, $local_file, $offset, -1, array($this, 'download_callback'));
396
  @fclose($local_file);
397
 
398
- if(filesize($local_path) === $file['size']){
399
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
400
  $res = TRUE;
401
  }
395
  $result = $conn->get($remote_file_name, $local_file, $offset, -1, array($this, 'download_callback'));
396
  @fclose($local_file);
397
 
398
+ if(filesize($local_path) == $file['size']){
399
  if($wpvivid_pulgin->wpvivid_check_zip_valid()) {
400
  $res = TRUE;
401
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: move, clone, migrate, copy, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
  Tested up to: 5.2
6
  Requires PHP: 5.3
7
- Stable tag: 0.9.21
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
@@ -146,6 +146,12 @@ Yes, we do. Here are the guides for [copying your site to a new host](https://wp
146
  Feel free to let us know how we can help using the [support forum](https://wordpress.org/support/plugin/wpvivid-backuprestore) for the plugin on WordPress.org or our [contact form](https://wpvivid.com/contact-us). You can also reach us with a direct message on [Twitter](https://twitter.com/WPvividcom).
147
 
148
  == Changelog ==
 
 
 
 
 
 
149
  = 0.9.21 =
150
  - Fixed: Special data in some database tables could not be replaced during a restore, which would cause failure of the restore.
151
  - Fixed: Migration between sites that have different backup storage directories would fail.
4
  Requires at least: 4.5
5
  Tested up to: 5.2
6
  Requires PHP: 5.3
7
+ Stable tag: 0.9.22
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
146
  Feel free to let us know how we can help using the [support forum](https://wordpress.org/support/plugin/wpvivid-backuprestore) for the plugin on WordPress.org or our [contact form](https://wpvivid.com/contact-us). You can also reach us with a direct message on [Twitter](https://twitter.com/WPvividcom).
147
 
148
  == Changelog ==
149
+ = 0.9.22 =
150
+ - Fixed: Backup created in web hosting/shared hosting optimization mode was incomplete in some cases.
151
+ - Fixed: Backup actually failed but was reported as a success in some cases.
152
+ - Refined error messages of migration process.
153
+ - Added a notice to the situation where backup schedules were unusable because the WP Cron on the server was disabled.
154
+ - Optimized the plugin code.
155
  = 0.9.21 =
156
  - Fixed: Special data in some database tables could not be replaced during a restore, which would cause failure of the restore.
157
  - Fixed: Migration between sites that have different backup storage directories would fail.
wpvivid-backuprestore.php CHANGED
@@ -7,7 +7,7 @@
7
  * @wordpress-plugin
8
  * Plugin Name: WPvivid Backup Plugin
9
  * Description: Clone or copy WP sites then move or migrate them to new host (new domain), schedule backups, transfer backups to leading remote storage. All in one.
10
- * Version: 0.9.21
11
  * Author: WPvivid Team
12
  * Author URI: https://wpvivid.com
13
  * License: GPL-3.0+
@@ -21,7 +21,7 @@ if ( ! defined( 'WPINC' ) ) {
21
  die;
22
  }
23
 
24
- define( 'WPVIVID_PLUGIN_VERSION', '0.9.21' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');
7
  * @wordpress-plugin
8
  * Plugin Name: WPvivid Backup Plugin
9
  * Description: Clone or copy WP sites then move or migrate them to new host (new domain), schedule backups, transfer backups to leading remote storage. All in one.
10
+ * Version: 0.9.22
11
  * Author: WPvivid Team
12
  * Author URI: https://wpvivid.com
13
  * License: GPL-3.0+
21
  die;
22
  }
23
 
24
+ define( 'WPVIVID_PLUGIN_VERSION', '0.9.22' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');