UpdraftPlus WordPress Backup Plugin - Version 1.12.32

Version Description

  • 26/Jan/2017 =

  • FEATURE: Add UpdraftCentral (https://updraftcentral.com) UpdraftVault listener

  • FEATURE: Encryption and decryption is now chunked, meaning that large databases of any size can be encrypted without being prevented by memory limits

  • FIX: Fix a bug whereby if a backup set containing a manual "more files" element was imported via a remote scan, then an error would show concerning it when attempting to restore.

  • FIX: On certain combinations of changing the "more files to back up" settings, these changes might not be reflected in the "Backup Now" dialog without a page reload

  • FIX: Remove a PHP 5.5+-only construction that crept into 1.12.31

  • TWEAK: Allow UpdraftCentral command classes to provide commands via the __call method

  • TWEAK: Move the existing backups table into the templating system

  • TWEAK: When trying to restore before cleaning up a previous restore, the detailed error message shown needed tweaking

  • TWEAK: Some refactoring of the dashboard JavaScript, to abstract/harmonise all AJAX calls

  • TWEAK: Removed the triple click and replaced it with standard double click

  • TWEAK: Some refactoring of the UpdraftCentral command interface, to facilitate reduction of duplicated dashboard control code

  • TWEAK: One less HTTP round-trip when deleting from the dashboard

  • TWEAK: Updated advanced tools to allow UpdraftCentral to use wipe settings and export / import

  • TWEAK: Revamped the 'Premium / Extensions' tab in the free version

  • TWEAK: Work around HTTP 400 error from Dropbox on servers with several-year old version of curl, caused by bad interaction between curl and Dropbox over a specific header

  • TWEAK: Add a notice advising of WP-Optimize (https://wordpress.org/plugins/wp-optimize/) to the available notices

  • TWEAK: Prevent an unwanted PHP log notice when using Google Drive

  • TWEAK: More file directories are now added using a directory browser

  • TWEAK: Update plugin update checker library (paid versions) to version 3.1, which fixes some PHP 7 issues

Download this release

Release Info

Developer DavidAnderson
Plugin Icon 128x128 UpdraftPlus WordPress Backup Plugin
Version 1.12.32
Comparing to
See all releases

Code changes from version 1.12.30 to 1.12.32

admin.php CHANGED
@@ -224,13 +224,13 @@ class UpdraftPlus_Admin {
224
  ?>
225
  <tr>
226
  <?php if (isset($files_not_scheduled) && isset($database_not_scheduled)) { ?>
227
- <td colspan="2" class="not-scheduled"><?php _e('Nothing currently scheduled','updraftplus'); ?></td>
228
  <?php } else { ?>
229
- <td class="updraft_scheduled"><?php echo empty($next_scheduled_backup_database_same_time) ? __('Files','updraftplus') : __('Files and database', 'updraftplus'); ?>:</td><td class="updraft_all-files"><?php echo $next_scheduled_backup; ?></td>
230
  </tr>
231
  <?php if (empty($next_scheduled_backup_database_same_time)) { ?>
232
  <tr>
233
- <td class="updraft_scheduled"><?php _e('Database','updraftplus');?>: </td><td class="updraft_all-files"><?php echo $next_scheduled_backup_database; ?></td>
234
  </tr>
235
  <?php } ?>
236
  <?php
@@ -303,6 +303,44 @@ class UpdraftPlus_Admin {
303
  add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 99999);
304
  }
305
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  public function updraft_ajaxrestore() {
307
  // TODO: All needs testing with restricted filesystem permissions. Those credentials need to be POST-ed too - currently not.
308
  // TODO
@@ -478,9 +516,9 @@ class UpdraftPlus_Admin {
478
  wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', false, '1.7.2', false);
479
  wp_enqueue_script('jquery');
480
  // No plupload until 3.3
481
- wp_enqueue_script('updraftplus-admin-ui', UPDRAFTPLUS_URL.'/includes/updraft-admin-ui.js', array('jquery', 'jquery-ui-dialog'), $enqueue_version, true);
482
  } else {
483
- wp_enqueue_script('updraftplus-admin-ui', UPDRAFTPLUS_URL.'/includes/updraft-admin-ui.js', array('jquery', 'jquery-ui-dialog', 'plupload-all'), $enqueue_version);
484
  }
485
 
486
  }
@@ -522,53 +560,54 @@ class UpdraftPlus_Admin {
522
  $mday_selector .= "\n\t<option value='" . $mday_index . "' $selected>" . $mday_index . '</option>';
523
  }
524
 
525
- wp_localize_script('updraftplus-admin-ui', 'updraftlion', array(
526
  'sendonlyonwarnings' => __('Send a report only when there are warnings/errors', 'updraftplus'),
527
  'wholebackup' => __('When the Email storage method is enabled, also send the entire backup', 'updraftplus'),
528
- 'emailsizelimits' => esc_attr(sprintf(__('Be aware that mail servers tend to have size limits; typically around %s Mb; backups larger than any limits will likely not arrive.','updraftplus'), '10-20')),
529
- 'rescanning' => __('Rescanning (looking for backups that you have uploaded manually into the internal backup store)...','updraftplus'),
530
- 'rescanningremote' => __('Rescanning remote and local storage for backup sets...','updraftplus'),
531
  'enteremailhere' => esc_attr(__('To send to more than one address, separate each address with a comma.', 'updraftplus')),
532
  'excludedeverything' => __('If you exclude both the database and the files, then you have excluded everything!', 'updraftplus'),
533
  'nofileschosen' => __('You have chosen to backup files, but no file entities have been selected', 'updraftplus'),
534
  'restoreproceeding' => __('The restore operation has begun. Do not press stop or close your browser until it reports itself as having finished.', 'updraftplus'),
535
- 'unexpectedresponse' => __('Unexpected response:','updraftplus'),
536
  'servererrorcode' => __('The web server returned an error code (try again, or check your web server logs)', 'updraftplus'),
537
  'newuserpass' => __("The new user's RackSpace console password is (this will not be shown again):", 'updraftplus'),
538
  'trying' => __('Trying...', 'updraftplus'),
539
  'fetching' => __('Fetching...', 'updraftplus'),
540
- 'calculating' => __('calculating...','updraftplus'),
541
- 'begunlooking' => __('Begun looking for this entity','updraftplus'),
542
  'stilldownloading' => __('Some files are still downloading or being processed - please wait.', 'updraftplus'),
543
  'processing' => __('Processing files - please wait...', 'updraftplus'),
544
  'emptyresponse' => __('Error: the server sent an empty response.', 'updraftplus'),
545
- 'warnings' => __('Warnings:','updraftplus'),
546
- 'errors' => __('Errors:','updraftplus'),
547
  'jsonnotunderstood' => __('Error: the server sent us a response which we did not understand.', 'updraftplus'),
548
  'errordata' => __('Error data:', 'updraftplus'),
549
- 'error' => __('Error:','updraftplus'),
550
- 'errornocolon' => __('Error','updraftplus'),
551
- 'fileready' => __('File ready.','updraftplus'),
552
- 'youshould' => __('You should:','updraftplus'),
553
- 'deletefromserver' => __('Delete from your web server','updraftplus'),
554
- 'downloadtocomputer' => __('Download to your computer','updraftplus'),
555
- 'andthen' => __('and then, if you wish,', 'updraftplus'),
 
556
  'notunderstood' => __('Download error: the server sent us a response which we did not understand.', 'updraftplus'),
557
  'requeststart' => __('Requesting start of backup...', 'updraftplus'),
558
  'phpinfo' => __('PHP information', 'updraftplus'),
559
  'delete_old_dirs' => __('Delete Old Directories', 'updraftplus'),
560
  'raw' => __('Raw backup history', 'updraftplus'),
561
- 'notarchive' => __('This file does not appear to be an UpdraftPlus backup archive (such files are .zip or .gz files which have a name like: backup_(time)_(site name)_(code)_(type).(zip|gz)).', 'updraftplus').' '.__('However, UpdraftPlus archives are standard zip/SQL files - so if you are sure that your file has the right format, then you can rename it to match that pattern.','updraftplus'),
562
  'notarchive2' => '<p>'.__('This file does not appear to be an UpdraftPlus backup archive (such files are .zip or .gz files which have a name like: backup_(time)_(site name)_(code)_(type).(zip|gz)).', 'updraftplus').'</p> '.apply_filters('updraftplus_if_foreign_then_premium_message', '<p><a href="'.apply_filters('updraftplus_com_link', "https://updraftplus.com/shop/updraftplus-premium/").'">'.__('If this is a backup created by a different backup plugin, then UpdraftPlus Premium may be able to help you.', 'updraftplus').'</a></p>'),
563
- 'makesure' => __('(make sure that you were trying to upload a zip file previously created by UpdraftPlus)','updraftplus'),
564
- 'uploaderror' => __('Upload error:','updraftplus'),
565
- 'notdba' => __('This file does not appear to be an UpdraftPlus encrypted database archive (such files are .gz.crypt files which have a name like: backup_(time)_(site name)_(code)_db.crypt.gz).','updraftplus'),
566
  'uploaderr' => __('Upload error', 'updraftplus'),
567
- 'followlink' => __('Follow this link to attempt decryption and download the database file to your computer.','updraftplus'),
568
- 'thiskey' => __('This decryption key will be attempted:','updraftplus'),
569
- 'unknownresp' => __('Unknown server response:','updraftplus'),
570
- 'ukrespstatus' => __('Unknown server response status:','updraftplus'),
571
- 'uploaded' => __('The file was uploaded.','updraftplus'),
572
  'backupnow' => __('Backup Now', 'updraftplus'),
573
  'cancel' => __('Cancel', 'updraftplus'),
574
  'deletebutton' => __('Delete', 'updraftplus'),
@@ -595,7 +634,7 @@ class UpdraftPlus_Admin {
595
  'checkrpcsetup' => sprintf(__('You should check that the remote site is online, not firewalled, does not have security modules that may be blocking access, has UpdraftPlus version %s or later active and that the keys have been entered correctly.', 'updraftplus'), '2.10.3'),
596
  'pleasenamekey' => __('Please give this key a name (e.g. indicate the site it is for):', 'updraftplus'),
597
  'key' => __('Key', 'updraftplus'),
598
- 'nokeynamegiven' => sprintf(__("Failure: No %s was given.",'updraftplus'), __('key name','updraftplus')),
599
  'deleting' => __('Deleting...', 'updraftplus'),
600
  'enter_mothership_url' => __('Please enter a valid URL', 'updraftplus'),
601
  'delete_response_not_understood' => __("We requested to delete the file, but could not understand the server's response", 'updraftplus'),
@@ -604,8 +643,8 @@ class UpdraftPlus_Admin {
604
  'migratemodalheight' => class_exists('UpdraftPlus_Addons_Migrator') ? 555 : 300,
605
  'migratemodalwidth' => class_exists('UpdraftPlus_Addons_Migrator') ? 770 : 500,
606
  'download' => _x('Download', '(verb)', 'updraftplus'),
607
- 'unsavedsettingsbackup' => __('You have made changes to your settings, and not saved.', 'updraftplus')."\n".__('You should save your changes to ensure that they are used for making your backup.','updraftplus'),
608
- 'unsaved_settings_export' => __('You have made changes to your settings, and not saved.', 'updraftplus')."\n".__('Your export file will be of your displayed settings, not your saved ones.','updraftplus'),
609
  'dayselector' => $day_selector,
610
  'mdayselector' => $mday_selector,
611
  'day' => __('day', 'updraftplus'),
@@ -621,14 +660,14 @@ class UpdraftPlus_Admin {
621
  'testing_settings' => __('Testing %s Settings...', 'updraftplus'),
622
  'settings_test_result' => __('%s settings test result:', 'updraftplus'),
623
  'nothing_yet_logged' => __('Nothing yet logged', 'updraftplus'),
624
- 'import_select_file' => __('You have not yet selected a file to import.','updraftplus'),
625
  'updraft_settings_url' => UpdraftPlus_Options::admin_page_url().'?page=updraftplus',
626
  'network_site_url' => network_site_url(),
627
  'importing' => __('Importing...', 'updraftplus'),
628
  'importing_data_from' => __('This will import data from:', 'updraftplus'),
629
- 'exported_on' => __('Which was exported on:','updraftplus'),
630
- 'continue_import' => __('Do you want to carry out the import?','updraftplus'),
631
- 'complete' => __('Complete','updraftplus'),
632
  'remote_delete_limit' => defined('UPDRAFTPLUS_REMOTE_DELETE_LIMIT') ? UPDRAFTPLUS_REMOTE_DELETE_LIMIT : 15,
633
  'remote_files_deleted' => __('remote files deleted', 'updraftplus'),
634
  ) );
@@ -651,7 +690,7 @@ class UpdraftPlus_Admin {
651
  echo apply_filters('updraftplus_autobackup_blurb', $updraftplus_notices->do_notice('autobackup', 'autobackup', true));
652
  } else {
653
  echo '<div class="updraft-ad-container updated">';
654
- echo '<h3 style="margin-top: 2px;">'. __('Be safe with an automatic backup','updraftplus').'</h3>';
655
  echo apply_filters('updraftplus_autobackup_blurb', '');
656
  echo '</div>';
657
  }
@@ -716,7 +755,7 @@ class UpdraftPlus_Admin {
716
  $plupload_init['silverlight_xap_url'] = includes_url('js/plupload/plupload.silverlight.swf');
717
  }
718
 
719
- ?><script type="text/javascript">
720
  var updraft_credentialtest_nonce='<?php echo wp_create_nonce('updraftplus-credentialtest-nonce');?>';
721
  var updraftplus_settings_nonce='<?php echo wp_create_nonce('updraftplus-settings-nonce');?>';
722
  var updraft_siteurl = '<?php echo esc_js(site_url('', 'relative'));?>';
@@ -735,27 +774,12 @@ class UpdraftPlus_Admin {
735
  <?php
736
  $overdue = $this->howmany_overdue_crons();
737
  if ($overdue >= 4) { ?>
738
- jQuery(document).ready(function(){
739
- setTimeout(function(){updraft_check_overduecrons();}, 11000);
740
- function updraft_check_overduecrons() {
741
- jQuery.get(ajaxurl, { action: 'updraft_ajax', subaction: 'checkoverduecrons', nonce: updraft_credentialtest_nonce }, function(data, response) {
742
- if ('success' == response) {
743
- try {
744
- resp = jQuery.parseJSON(data);
745
- if (resp.m) {
746
- jQuery('#updraft-insert-admin-warning').html(resp.m);
747
- }
748
- } catch(err) {
749
- console.log(data);
750
- }
751
- }
752
  });
753
- }
754
- });
755
- <?php } ?>
756
  </script>
757
  <?php
758
-
759
  }
760
 
761
 
@@ -825,55 +849,55 @@ class UpdraftPlus_Admin {
825
  }
826
 
827
  public function show_admin_warning_execution_time() {
828
- $this->show_admin_warning('<strong>'.__('Warning','updraftplus').':</strong> '.sprintf(__('The amount of time allowed for WordPress plugins to run is very low (%s seconds) - you should increase it to avoid backup failures due to time-outs (consult your web hosting company for more help - it is the max_execution_time PHP setting; the recommended value is %s seconds or more)', 'updraftplus'), (int)@ini_get('max_execution_time'), 90));
829
  }
830
 
831
  public function show_admin_warning_disabledcron() {
832
- $this->show_admin_warning('<strong>'.__('Warning','updraftplus').':</strong> '.__('The scheduler is disabled in your WordPress install, via the DISABLE_WP_CRON setting. No backups can run (even &quot;Backup Now&quot;) unless either you have set up a facility to call the scheduler manually, or until it is enabled.','updraftplus').' <a href="'.apply_filters('updraftplus_com_link', "https://updraftplus.com/faqs/my-scheduled-backups-and-pressing-backup-now-does-nothing-however-pressing-debug-backup-does-produce-a-backup/#disablewpcron/").'">'.__('Go here for more information.','updraftplus').'</a>', 'updated updraftplus-disable-wp-cron-warning');
833
  }
834
 
835
  public function show_admin_warning_diskspace() {
836
- $this->show_admin_warning('<strong>'.__('Warning','updraftplus').':</strong> '.sprintf(__('You have less than %s of free disk space on the disk which UpdraftPlus is configured to use to create backups. UpdraftPlus could well run out of space. Contact your the operator of your server (e.g. your web hosting company) to resolve this issue.','updraftplus'),'35 MB'));
837
  }
838
 
839
  public function show_admin_warning_wordpressversion() {
840
- $this->show_admin_warning('<strong>'.__('Warning','updraftplus').':</strong> '.sprintf(__('UpdraftPlus does not officially support versions of WordPress before %s. It may work for you, but if it does not, then please be aware that no support is available until you upgrade WordPress.', 'updraftplus'), '3.2'));
841
  }
842
 
843
  public function show_admin_warning_litespeed() {
844
- $this->show_admin_warning('<strong>'.__('Warning','updraftplus').':</strong> '.sprintf(__('Your website is hosted using the %s web server.','updraftplus'),'LiteSpeed').' <a href="'.apply_filters('updraftplus_com_link', "https://updraftplus.com/faqs/i-am-having-trouble-backing-up-and-my-web-hosting-company-uses-the-litespeed-webserver/").'">'.__('Please consult this FAQ if you have problems backing up.', 'updraftplus').'</a>');
845
  }
846
 
847
  public function show_admin_debug_warning() {
848
- $this->show_admin_warning('<strong>'.__('Notice','updraftplus').':</strong> '.__('UpdraftPlus\'s debug mode is on. You may see debugging notices on this page not just from UpdraftPlus, but from any other plugin installed. Please try to make sure that the notice you are seeing is from UpdraftPlus before you raise a support request.', 'updraftplus').'</a>');
849
  }
850
 
851
  public function show_admin_warning_overdue_crons($howmany) {
852
  $ret = '<div class="updraftmessage updated"><p>';
853
- $ret .= '<strong>'.__('Warning','updraftplus').':</strong> '.sprintf(__('WordPress has a number (%d) of scheduled tasks which are overdue. Unless this is a development site, this probably means that the scheduler in your WordPress install is not working.', 'updraftplus'), $howmany).' <a href="'.apply_filters('updraftplus_com_link', "https://updraftplus.com/faqs/scheduler-wordpress-installation-working/").'">'.__('Read this page for a guide to possible causes and how to fix it.', 'updraftplus').'</a>';
854
  $ret .= '</p></div>';
855
  return $ret;
856
  }
857
 
858
  //checking remote storage
859
  public function show_admin_warning_dropbox() {
860
- $this->show_admin_warning('<strong>'.__('UpdraftPlus notice:','updraftplus').'</strong> <a class="updraft_authlink" href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&action=updraftmethod-dropbox-auth&updraftplus_dropboxauth=doit">'.sprintf(__('Follow this link to authorize access to your %s account (you will not be able to back up to %s without it).','updraftplus'), 'Dropbox', 'Dropbox').'</a>', 'updated updraft_authenticate_dropbox');
861
  }
862
 
863
  public function show_admin_warning_onedrive() {
864
- $this->show_admin_warning('<strong>'.__('UpdraftPlus notice:','updraftplus').'</strong> <a class="updraft_authlink" href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&action=updraftmethod-onedrive-auth&updraftplus_onedriveauth=doit">'.sprintf(__('Follow this link to authorize access to your %s account (you will not be able to back up to %s without it).','updraftplus'), 'OneDrive', 'OneDrive').'</a>', 'updated updraft_authenticate_onedrive');
865
  }
866
 
867
  public function show_admin_warning_updraftvault() {
868
- $this->show_admin_warning('<strong>'.__('UpdraftPlus notice:','updraftplus').'</strong> '.sprintf(__('%s has been chosen for remote storage, but you are not currently connected.', 'updraftplus'), 'UpdraftPlus Vault').' '.__('Go to the remote storage settings in order to connect.', 'updraftplus'), 'updated');
869
  }
870
 
871
  public function show_admin_warning_googledrive() {
872
- $this->show_admin_warning('<strong>'.__('UpdraftPlus notice:','updraftplus').'</strong> <a class="updraft_authlink" href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&action=updraftmethod-googledrive-auth&updraftplus_googleauth=doit">'.sprintf(__('Follow this link to authorize access to your %s account (you will not be able to back up to %s without it).','updraftplus'), 'Google Drive', 'Google Drive').'</a>', 'updated updraft_authenticate_googledrive');
873
  }
874
 
875
  public function show_admin_warning_googlecloud() {
876
- $this->show_admin_warning('<strong>'.__('UpdraftPlus notice:','updraftplus').'</strong> <a class="updraft_authlink" href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&action=updraftmethod-googlecloud-auth&updraftplus_googleauth=doit">'.sprintf(__('Follow this link to authorize access to your %s account (you will not be able to back up to %s without it).','updraftplus'), 'Google Cloud', 'Google Cloud').'</a>', 'updated updraft_authenticate_googlecloud');
877
  }
878
 
879
  // This options filter removes ABSPATH off the front of updraft_dir, if it is given absolutely and contained within it
@@ -1088,362 +1112,87 @@ class UpdraftPlus_Admin {
1088
 
1089
  }
1090
 
 
 
 
 
 
 
1091
  public function updraft_ajax_handler() {
1092
 
1093
  global $updraftplus;
1094
 
1095
- $nonce = (empty($_REQUEST['nonce'])) ? "" : $_REQUEST['nonce'];
1096
 
1097
  if (!wp_verify_nonce($nonce, 'updraftplus-credentialtest-nonce') || empty($_REQUEST['subaction'])) die('Security check');
1098
 
1099
  // Mitigation in case the nonce leaked to an unauthorised user
1100
- if (isset($_REQUEST['subaction']) && 'dismissautobackup' == $_REQUEST['subaction']) {
1101
  if (!current_user_can('update_plugins') && !current_user_can('update_themes')) return;
1102
- } elseif (isset($_REQUEST['subaction']) && ('dismissexpiry' == $_REQUEST['subaction'] || 'dismissdashnotice' == $_REQUEST['subaction'])) {
1103
  if (!current_user_can('update_plugins')) return;
1104
  } else {
1105
  if (!UpdraftPlus_Options::user_can_manage()) return;
1106
  }
1107
-
1108
- // Some of this checks that _REQUEST['subaction'] is set, which is redundant (done already in the nonce check)
1109
- /*
1110
- // This one is no longer used anywhere
1111
- if (isset($_REQUEST['subaction']) && 'lastlog' == $_REQUEST['subaction']) {
1112
 
1113
- $last_message = UpdraftPlus_Options::get_updraft_option('updraft_lastmessage');
1114
 
1115
- echo htmlspecialchars( '('.__('Nothing yet logged', 'updraftplus').')'));
1116
-
1117
- } else
1118
- */
1119
- if ('forcescheduledresumption' == $_REQUEST['subaction'] && !empty($_REQUEST['resumption']) && !empty($_REQUEST['job_id']) && is_numeric($_REQUEST['resumption'])) {
1120
- // Casting $resumption to int is absolutely necessary, as the WP cron system uses a hashed serialisation of the parameters for identifying jobs. Different type => different hash => does not match
1121
- $resumption = (int)$_REQUEST['resumption'];
1122
- $job_id = $_REQUEST['job_id'];
1123
- $get_cron = $this->get_cron($job_id);
1124
- if (!is_array($get_cron)) {
1125
- echo json_encode(array('r' => false));
1126
- } else {
1127
- $updraftplus->log("Forcing resumption: job id=$job_id, resumption=$resumption");
1128
- $time = $get_cron[0];
1129
- // wp_unschedule_event($time, 'updraft_backup_resume', array($resumption, $job_id));
1130
- wp_clear_scheduled_hook('updraft_backup_resume', array($resumption, $job_id));
1131
- $updraftplus->close_browser_connection(json_encode(array('r' => true)));
1132
- $updraftplus->jobdata_set_from_array($get_cron[1]);
1133
- $updraftplus->backup_resume($resumption, $job_id);
1134
- }
1135
- } elseif (isset($_GET['subaction']) && 'activejobs_list' == $_GET['subaction']) {
1136
 
1137
- echo json_encode($this->get_activejobs_list($_GET));
1138
-
1139
- } elseif (isset($_REQUEST['subaction']) && 'updraftcentral_delete_key' == $_REQUEST['subaction'] && isset($_REQUEST['key_id'])) {
 
 
1140
 
1141
- global $updraftplus_updraftcentral_main;
1142
- if (!is_a($updraftplus_updraftcentral_main, 'UpdraftPlus_UpdraftCentral_Main')) {
1143
- echo json_encode(array('error' => 'UpdraftPlus_UpdraftCentral_Main object not found'));
1144
- die;
1145
- }
1146
-
1147
- echo json_encode($updraftplus_updraftcentral_main->delete_key($_REQUEST['key_id']));
1148
- die;
1149
 
1150
- } elseif (isset($_REQUEST['subaction']) && ('updraftcentral_create_key' == $_REQUEST['subaction'] || 'updraftcentral_get_log' == $_REQUEST['subaction'])) {
1151
-
1152
- global $updraftplus_updraftcentral_main;
1153
- if (!is_a($updraftplus_updraftcentral_main, 'UpdraftPlus_UpdraftCentral_Main')) {
1154
- echo json_encode(array('error' => 'UpdraftPlus_UpdraftCentral_Main object not found'));
1155
- die;
 
1156
  }
1157
 
1158
- $call_method = substr($_REQUEST['subaction'], 15);
1159
-
1160
- echo json_encode(call_user_func(array($updraftplus_updraftcentral_main, $call_method), $_REQUEST));
1161
-
1162
- die;
1163
-
1164
- } elseif (isset($_REQUEST['subaction']) && 'callwpaction' == $_REQUEST['subaction'] && !empty($_REQUEST['wpaction'])) {
1165
- $this->call_wp_action($_REQUEST);
1166
- die;
1167
- } elseif (isset($_REQUEST['subaction']) && 'whichdownloadsneeded' == $_REQUEST['subaction'] && is_array($_REQUEST['downloads']) && isset($_REQUEST['timestamp']) && is_numeric($_REQUEST['timestamp'])) {
1168
- // The purpose of this is to look at the list of indicated downloads, and indicate which are not already fully downloaded. i.e. Which need further action.
1169
- $send_back = array();
1170
-
1171
- $backup = $updraftplus->get_backup_history($_REQUEST['timestamp']);
1172
- $updraft_dir = $updraftplus->backups_dir_location();
1173
- $backupable_entities = $updraftplus->get_backupable_file_entities();
1174
-
1175
- if (empty($backup)) {
1176
- echo json_encode(array('result' => 'asyouwere'));
1177
  } else {
1178
- foreach ($_REQUEST['downloads'] as $i => $download) {
1179
- if (is_array($download) && 2 == count($download) && isset($download[0]) && isset($download[1])) {
1180
- $entity = $download[0];
1181
- if (('db' == $entity || isset($backupable_entities[$entity])) && isset($backup[$entity])) {
1182
- $indexes = explode(',', $download[1]);
1183
- $retain_string = '';
1184
- foreach ($indexes as $index) {
1185
- $retain = true; // default
1186
- $findex = (0 == $index) ? '' : (string)$index;
1187
- $files = $backup[$entity];
1188
- if (!is_array($files)) $files = array($files);
1189
- $size_key = $entity.$findex.'-size';
1190
- if (isset($files[$index]) && isset($backup[$size_key])) {
1191
- $file = $updraft_dir.'/'.$files[$index];
1192
- if (file_exists($file) && filesize($file) >= $backup[$size_key]) {
1193
- $retain = false;
1194
- }
1195
- }
1196
- if ($retain) {
1197
- $retain_string .= ('' === $retain_string) ? $index : ','.$index;
1198
- $send_back[$i][0] = $entity;
1199
- $send_back[$i][1] = $retain_string;
1200
- }
1201
- }
1202
- } else {
1203
- $send_back[$i][0] = $entity;
1204
- $send_back[$i][1] = $download[$i][1];
1205
- }
1206
- } else {
1207
- // Format not understood. Just send it back as-is.
1208
- $send_back[$i] = $download[$i];
1209
- }
1210
- }
1211
- // Finally, renumber the keys (to usual PHP style - 0, 1, ...). Otherwise, in order to preserve the indexes, json_encode() will create an object instead of an array in the case where $send_back only has one element (and is indexed with an index > 0)
1212
- $send_back = array_values($send_back);
1213
- echo json_encode(array('downloads' => $send_back));
1214
- }
1215
- } elseif (isset($_REQUEST['subaction']) && 'httpget' == $_REQUEST['subaction']) {
1216
- // httpget
1217
- echo $this->http_get($_REQUEST['uri']);
1218
- } elseif (isset($_REQUEST['subaction']) && 'dismissautobackup' == $_REQUEST['subaction']) {
1219
- UpdraftPlus_Options::update_updraft_option('updraftplus_dismissedautobackup', time() + 84*86400);
1220
- } elseif (isset($_REQUEST['subaction']) && 'dismiss_notice' == $_REQUEST['subaction']) {
1221
- UpdraftPlus_Options::update_updraft_option('dismissed_general_notices_until', time() + 84*86400);
1222
- } elseif (isset($_REQUEST['subaction']) && 'dismiss_season' == $_REQUEST['subaction']) {
1223
- UpdraftPlus_Options::update_updraft_option('dismissed_season_notices_until', time() + 366*86400);
1224
- } elseif (isset($_REQUEST['subaction']) && 'set_autobackup_default' == $_REQUEST['subaction']) {
1225
- // This option when set should have integers, not bools
1226
- $default = empty($_REQUEST['default']) ? 0 : 1;
1227
- UpdraftPlus_Options::update_updraft_option('updraft_autobackup_default', $default);
1228
- } elseif (isset($_REQUEST['subaction']) && 'dismissexpiry' == $_REQUEST['subaction']) {
1229
- UpdraftPlus_Options::update_updraft_option('updraftplus_dismissedexpiry', time() + 14*86400);
1230
- } elseif (isset($_REQUEST['subaction']) && 'dismissdashnotice' == $_REQUEST['subaction']) {
1231
- UpdraftPlus_Options::update_updraft_option('updraftplus_dismisseddashnotice', time() + 366*86400);
1232
- } elseif (isset($_REQUEST['subaction']) && 'poplog' == $_REQUEST['subaction']){
1233
-
1234
- echo json_encode($this->fetch_log($_REQUEST['backup_nonce']));
1235
-
1236
- } elseif (isset($_REQUEST['subaction']) && 'restore_alldownloaded' == $_REQUEST['subaction'] && isset($_REQUEST['restoreopts']) && isset($_REQUEST['timestamp'])) {
1237
-
1238
- $backups = $updraftplus->get_backup_history();
1239
- $updraft_dir = $updraftplus->backups_dir_location();
1240
-
1241
- $timestamp = (int)$_REQUEST['timestamp'];
1242
- if (!isset($backups[$timestamp])) {
1243
- echo json_encode(array('m' => '', 'w' => '', 'e' => __('No such backup set exists', 'updraftplus')));
1244
- die;
1245
- }
1246
-
1247
- $mess = array();
1248
- parse_str(stripslashes($_REQUEST['restoreopts']), $res);
1249
-
1250
- if (isset($res['updraft_restore'])) {
1251
-
1252
- set_error_handler(array($this, 'get_php_errors'), E_ALL & ~E_STRICT);
1253
-
1254
- $elements = array_flip($res['updraft_restore']);
1255
-
1256
- $warn = array(); $err = array();
1257
-
1258
- @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);
1259
- $max_execution_time = (int)@ini_get('max_execution_time');
1260
-
1261
- if ($max_execution_time>0 && $max_execution_time<61) {
1262
- $warn[] = sprintf(__('The PHP setup on this webserver allows only %s seconds for PHP to run, and does not allow this limit to be raised. If you have a lot of data to import, and if the restore operation times out, then you will need to ask your web hosting company for ways to raise this limit (or attempt the restoration piece-by-piece).', 'updraftplus'), $max_execution_time);
1263
- }
1264
-
1265
- if (isset($backups[$timestamp]['native']) && false == $backups[$timestamp]['native']) {
1266
- $warn[] = __('This backup set was not known by UpdraftPlus to be created by the current WordPress installation, but was either found in remote storage, or was sent from a remote site.', 'updraftplus').' '.__('You should make sure that this really is a backup set intended for use on this website, before you restore (rather than a backup set of an unrelated website).', 'updraftplus');
1267
- }
1268
-
1269
- if (isset($elements['db'])) {
1270
-
1271
- // Analyse the header of the database file + display results
1272
- list ($mess2, $warn2, $err2, $info) = $updraftplus->analyse_db_file($timestamp, $res);
1273
- $mess = array_merge($mess, $mess2);
1274
- $warn = array_merge($warn, $warn2);
1275
- $err = array_merge($err, $err2);
1276
- foreach ($backups[$timestamp] as $bid => $bval) {
1277
- if ('db' != $bid && 'db' == substr($bid, 0, 2) && '-size' != substr($bid, -5, 5)) {
1278
- $warn[] = __('Only the WordPress database can be restored; you will need to deal with the external database manually.', 'updraftplus');
1279
- break;
1280
- }
1281
- }
1282
- }
1283
-
1284
- $backupable_entities = $updraftplus->get_backupable_file_entities(true, true);
1285
- $backupable_plus_db = $backupable_entities;
1286
- $backupable_plus_db['db'] = array('path' => 'path-unused', 'description' => __('Database', 'updraftplus'));
1287
-
1288
- if (!empty($backups[$timestamp]['meta_foreign'])) {
1289
- $foreign_known = apply_filters('updraftplus_accept_archivename', array());
1290
- if (!is_array($foreign_known) || empty($foreign_known[$backups[$timestamp]['meta_foreign']])) {
1291
- $err[] = sprintf(__('Backup created by unknown source (%s) - cannot be restored.', 'updraftplus'), $backups[$timestamp]['meta_foreign']);
1292
- } else {
1293
- // For some reason, on PHP 5.5 passing by reference in a single array stopped working with apply_filters_ref_array (though not with do_action_ref_array).
1294
- $backupable_plus_db = apply_filters_ref_array("updraftplus_importforeign_backupable_plus_db", array($backupable_plus_db, array($foreign_known[$backups[$timestamp]['meta_foreign']], &$mess, &$warn, &$err)));
1295
- }
1296
- }
1297
-
1298
- foreach ($backupable_plus_db as $type => $entity_info) {
1299
- if (!isset($elements[$type])) continue;
1300
- $whatwegot = $backups[$timestamp][$type];
1301
- if (is_string($whatwegot)) $whatwegot = array($whatwegot);
1302
- $expected_index = 0;
1303
- $missing = '';
1304
- ksort($whatwegot);
1305
- $outof = false;
1306
- foreach ($whatwegot as $index => $file) {
1307
- if (preg_match('/\d+of(\d+)\.zip/', $file, $omatch)) { $outof = max($matches[1], 1); }
1308
- if ($index != $expected_index) {
1309
- $missing .= ($missing == '') ? (1+$expected_index) : ",".(1+$expected_index);
1310
- }
1311
- if (!file_exists($updraft_dir.'/'.$file)) {
1312
- $err[] = sprintf(__('File not found (you need to upload it): %s', 'updraftplus'), $updraft_dir.'/'.$file);
1313
- } elseif (filesize($updraft_dir.'/'.$file) == 0) {
1314
- $err[] = sprintf(__('File was found, but is zero-sized (you need to re-upload it): %s', 'updraftplus'), $file);
1315
- } else {
1316
- $itext = (0 == $index) ? '' : $index;
1317
- if (!empty($backups[$timestamp][$type.$itext.'-size']) && $backups[$timestamp][$type.$itext.'-size'] != filesize($updraft_dir.'/'.$file)) {
1318
- if (empty($warn['doublecompressfixed'])) {
1319
- $warn[] = sprintf(__('File (%s) was found, but has a different size (%s) from what was expected (%s) - it may be corrupt.', 'updraftplus'), $file, filesize($updraft_dir.'/'.$file), $backups[$timestamp][$type.$itext.'-size']);
1320
- }
1321
- }
1322
- do_action_ref_array("updraftplus_checkzip_$type", array($updraft_dir.'/'.$file, &$mess, &$warn, &$err));
1323
- }
1324
- $expected_index++;
1325
- }
1326
- do_action_ref_array("updraftplus_checkzip_end_$type", array(&$mess, &$warn, &$err));
1327
- // Detect missing archives where they are missing from the end of the set
1328
- if ($outof>0 && $expected_index < $outof) {
1329
- for ($j = $expected_index; $j<$outof; $j++) {
1330
- $missing .= ($missing == '') ? (1+$j) : ",".(1+$j);
1331
- }
1332
- }
1333
- if ('' != $missing) {
1334
- $warn[] = sprintf(__("This multi-archive backup set appears to have the following archives missing: %s", 'updraftplus'), $missing.' ('.$entity_info['description'].')');
1335
- }
1336
- }
1337
-
1338
- if (0 == count($err) && 0 == count($warn)) {
1339
- $mess_first = __('The backup archive files have been successfully processed. Now press Restore again to proceed.', 'updraftplus');
1340
- } elseif (0 == count($err)) {
1341
- $mess_first = __('The backup archive files have been processed, but with some warnings. If all is well, then now press Restore again to proceed. Otherwise, cancel and correct any problems first.', 'updraftplus');
1342
- } else {
1343
- $mess_first = __('The backup archive files have been processed, but with some errors. You will need to cancel and correct any problems before retrying.', 'updraftplus');
1344
- }
1345
-
1346
- if (count($this->logged) >0) {
1347
- foreach ($this->logged as $lwarn) $warn[] = $lwarn;
1348
- }
1349
- restore_error_handler();
1350
-
1351
- // Get the info if it hasn't already come from the DB scan
1352
- if (!isset($info) || !is_array($info)) $info = array();
1353
-
1354
- // Not all chracters can be json-encoded, and we don't need this potentially-arbitrary user-supplied info.
1355
- unset($info['label']);
1356
-
1357
- if (!isset($info['created_by_version']) && !empty($backups[$timestamp]['created_by_version'])) $info['created_by_version'] = $backups[$timestamp]['created_by_version'];
1358
-
1359
- if (!isset($info['multisite']) && !empty($backups[$timestamp]['is_multisite'])) $info['multisite'] = $backups[$timestamp]['is_multisite'];
1360
-
1361
- do_action_ref_array('updraftplus_restore_all_downloaded_postscan', array($backups, $timestamp, $elements, &$info, &$mess, &$warn, &$err));
1362
-
1363
- echo json_encode(array('m' => '<p>'.$mess_first.'</p>'.implode('<br>', $mess), 'w' => implode('<br>', $warn), 'e' => implode('<br>', $err), 'i' => json_encode($info)));
1364
- }
1365
- } elseif ('sid_reset' == $_REQUEST['subaction']) {
1366
-
1367
- delete_site_option('updraftplus-addons_siteid');
1368
- echo json_encode(array('newsid' => $updraftplus->siteid()));
1369
-
1370
- } elseif (('vault_connect' == $_REQUEST['subaction'] && isset($_REQUEST['email']) && isset($_REQUEST['pass'])) || 'vault_disconnect' == $_REQUEST['subaction'] || 'vault_recountquota' == $_REQUEST['subaction']) {
1371
-
1372
- $vault = $this->get_updraftvault();
1373
- call_user_func(array($vault, 'ajax_'.$_REQUEST['subaction']));
1374
-
1375
- } elseif (isset($_POST['backup_timestamp']) && 'deleteset' == $_REQUEST['subaction']) {
1376
-
1377
- echo json_encode($this->delete_set($_POST));
1378
-
1379
- } elseif ('rawbackuphistory' == $_REQUEST['subaction']) {
1380
- $show_raw_data = $this->show_raw_backups();
1381
- echo $show_raw_data['html'];
1382
- } elseif ('countbackups' == $_REQUEST['subaction']) {
1383
- $backup_history = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
1384
- $backup_history = (is_array($backup_history))?$backup_history:array();
1385
- #echo sprintf(__('%d set(s) available', 'updraftplus'), count($backup_history));
1386
- echo __('Existing Backups', 'updraftplus').' ('.count($backup_history).')';
1387
- } elseif ('ping' == $_REQUEST['subaction']) {
1388
- // The purpose of this is to detect brokenness caused by extra line feeds in plugins/themes - before it breaks other AJAX operations and leads to support requests
1389
- echo 'pong';
1390
- } elseif ('checkoverduecrons' == $_REQUEST['subaction']) {
1391
- $how_many_overdue = $this->howmany_overdue_crons();
1392
- if ($how_many_overdue >= 4) echo json_encode(array('m' => $this->show_admin_warning_overdue_crons($how_many_overdue)));
1393
- } elseif ('delete_old_dirs' == $_REQUEST['subaction']) {
1394
- $this->delete_old_dirs_go(false);
1395
- } elseif ('phpinfo' == $_REQUEST['subaction']) {
1396
- phpinfo(INFO_ALL ^ (INFO_CREDITS | INFO_LICENSE));
1397
-
1398
- echo '<h3 id="ud-debuginfo-constants">'.__('Constants', 'updraftplus').'</h3>';
1399
- $opts = @get_defined_constants();
1400
- ksort($opts);
1401
- // <tr><th>'.__('Key','updraftplus').'</th><th>'.__('Value','updraftplus').'</th></tr>
1402
- echo '<table><thead></thead><tbody>';
1403
- foreach ($opts as $key => $opt) {
1404
- echo '<tr><td>'.htmlspecialchars($key).'</td><td>'.htmlspecialchars(print_r($opt, true)).'</td>';
1405
  }
1406
- echo '</tbody></table>';
1407
-
1408
- } elseif ('doaction' == $_REQUEST['subaction'] && !empty($_REQUEST['subsubaction']) && 'updraft_' == substr($_REQUEST['subsubaction'], 0, 8)) {
1409
- do_action($_REQUEST['subsubaction']);
1410
- } elseif ('backupnow' == $_REQUEST['subaction']) {
1411
-
1412
- $this->request_backupnow($_REQUEST);
1413
 
1414
- # Old-style: schedule an event in 5 seconds time. This has the advantage of testing out the scheduler, and alerting the user if it doesn't work... but has the disadvantage of not working in that case.
1415
- # I don't think the </div>s should be here - in case this is ever re-activated
1416
- // if (wp_schedule_single_event(time()+5, $event, array($backupnow_nocloud)) === false) {
1417
- // $updraftplus->log("A backup run failed to schedule");
1418
- // echo __("Failed.", 'updraftplus');
1419
- // } else {
1420
- // echo htmlspecialchars(__('OK. You should soon see activity in the "Last log message" field below.','updraftplus'))." <a href=\"https://updraftplus.com/faqs/my-scheduled-backups-and-pressing-backup-now-does-nothing-however-pressing-debug-backup-does-produce-a-backup/\"><br>".__('Nothing happening? Follow this link for help.','updraftplus')."</a>";
1421
- // $updraftplus->log("A backup run has been scheduled");
1422
- // }
1423
-
1424
- } elseif (isset($_GET['subaction']) && 'lastbackup' == $_GET['subaction']) {
1425
- echo $this->last_backup_html();
1426
- } elseif (isset($_GET['subaction']) && 'activejobs_delete' == $_GET['subaction'] && isset($_GET['jobid'])) {
1427
-
1428
- echo json_encode($this->activejobs_delete((string)$_GET['jobid']));
1429
-
1430
- } elseif (isset($_GET['subaction']) && 'diskspaceused' == $_GET['subaction'] && isset($_GET['entity'])) {
1431
- $entity = $_GET['entity'];
1432
- // This can count either the size of the Updraft directory, or of the data to be backed up
1433
- echo $this->get_disk_space_used($entity);
1434
- } elseif (isset($_GET['subaction']) && 'historystatus' == $_GET['subaction']) {
1435
- $remotescan = !empty($_GET['remotescan']);
1436
- $rescan = ($remotescan || !empty($_GET['rescan']));
1437
-
1438
- $history_status = $this->get_history_status($rescan, $remotescan);
1439
- echo @json_encode($history_status);
1440
 
1441
- } elseif (isset($_POST['subaction']) && $_POST['subaction'] == 'credentials_test') {
1442
 
1443
- $this->do_credentials_test($_POST);
1444
- die;
 
1445
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1446
  }
 
1447
  die;
1448
 
1449
  }
@@ -1476,7 +1225,7 @@ class UpdraftPlus_Admin {
1476
  restore_error_handler();
1477
  }
1478
 
1479
- // Relevant options (array keys): backup_timestamp, delete_remote,
1480
  public function delete_set($opts) {
1481
 
1482
  global $updraftplus;
@@ -1814,7 +1563,7 @@ class UpdraftPlus_Admin {
1814
 
1815
  $msg = array(
1816
  'nonce' => $nonce,
1817
- 'm' => '<strong>'.__('Start backup', 'updraftplus').':</strong> '.htmlspecialchars(__('OK. You should soon see activity in the "Last log message" field below.','updraftplus'))
1818
  );
1819
 
1820
  if ($close_connection_callable && is_callable($close_connection_callable)) {
@@ -1826,7 +1575,7 @@ class UpdraftPlus_Admin {
1826
  $options = array('nocloud' => $backupnow_nocloud, 'use_nonce' => $nonce);
1827
  if (!empty($request['onlythisfileentity']) && is_string($request['onlythisfileentity'])) {
1828
  // Something to see in the 'last log' field when it first appears, before the backup actually starts
1829
- $updraftplus->log(__('Start backup','updraftplus'));
1830
  $options['restrict_files_to_override'] = explode(',', $request['onlythisfileentity']);
1831
  }
1832
 
@@ -1837,9 +1586,9 @@ class UpdraftPlus_Admin {
1837
  do_action($event, apply_filters('updraft_backupnow_options', $options, $request));
1838
  }
1839
 
1840
- public function fetch_log($backup_nonce, $log_pointer=0) {
1841
  global $updraftplus;
1842
-
1843
  if (empty($backup_nonce)) {
1844
  list($mod_time, $log_file, $nonce) = $updraftplus->last_modified_log();
1845
  } else {
@@ -1873,15 +1622,15 @@ class UpdraftPlus_Admin {
1873
  $log_content = implode("", $templog_array);
1874
 
1875
  } else {
1876
- $log_content .= __('The log file could not be read.','updraftplus');
1877
  }
1878
 
1879
  } else {
1880
- $log_content .= __('The log file could not be read.','updraftplus');
1881
  }
1882
 
1883
  $ret_array = array(
1884
- 'html' => $log_content,
1885
  'nonce' => $nonce,
1886
  'pointer' => $new_pointer
1887
  );
@@ -1939,6 +1688,8 @@ class UpdraftPlus_Admin {
1939
  $response['s'] = (int)$matches[1];
1940
  $response['t'] = (int)$matches[1];
1941
  $response['m'] = __('File ready.', 'updraftplus');
 
 
1942
  } elseif (preg_match('/^downloading:(\d+):(.*)$/', $file, $matches) && file_exists($matches[2])) {
1943
  // Convert to bytes
1944
  $response['f'] = $matches[2];
@@ -2070,7 +1821,7 @@ class UpdraftPlus_Admin {
2070
  $response['dm'] = sprintf(__('This backup was created by %s, and can be imported.', 'updraftplus'), $accepted);
2071
  } else {
2072
  @unlink($status['file']);
2073
- echo json_encode(array('e' => sprintf(__('Error: %s', 'updraftplus'),__('Bad filename format - this does not look like a file created by UpdraftPlus','updraftplus'))));
2074
  exit;
2075
  }
2076
  } else {
@@ -2078,7 +1829,7 @@ class UpdraftPlus_Admin {
2078
  $type = isset($matches[3]) ? $matches[3] : '';
2079
  if (!preg_match('/^log\.[a-f0-9]{12}\.txt/', $file) && 'db' != $type && !isset($backupable_entities[$type])) {
2080
  @unlink($status['file']);
2081
- echo json_encode(array('e' => sprintf(__('Error: %s', 'updraftplus'),sprintf(__('This looks like a file created by UpdraftPlus, but this install does not know about this type of object: %s. Perhaps you need to install an add-on?','updraftplus'), htmlspecialchars($type)))));
2082
  exit;
2083
  }
2084
  }
@@ -2160,7 +1911,7 @@ class UpdraftPlus_Admin {
2160
  if (!preg_match('/^backup_([\-0-9]{15})_.*_([0-9a-f]{12})-db([0-9]+)?\.(gz\.crypt)$/i', $file)) {
2161
 
2162
  @unlink($status['file']);
2163
- echo 'ERROR:'.__('Bad filename format - this does not look like an encrypted database file created by UpdraftPlus','updraftplus');
2164
 
2165
  exit;
2166
  }
@@ -2241,7 +1992,7 @@ class UpdraftPlus_Admin {
2241
  }
2242
  $pval = ($updraftplus->have_addons) ? 1 : 0;
2243
 
2244
- echo '<strong>'.__('Actions','updraftplus').':</strong> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&updraft_restore_success='.$s_val.'&pval='.$pval.'">'.__('Return to UpdraftPlus Configuration','updraftplus').'</a>';
2245
  return;
2246
  } elseif (is_wp_error($backup_success)) {
2247
  echo '<p>';
@@ -2250,7 +2001,7 @@ class UpdraftPlus_Admin {
2250
  $updraftplus->log_wp_error($backup_success);
2251
  $updraftplus->log("Restore failed");
2252
  $updraftplus->list_errors();
2253
- echo '<strong>'.__('Actions','updraftplus').':</strong> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus">'.__('Return to UpdraftPlus Configuration','updraftplus').'</a>';
2254
  return;
2255
  } elseif (false === $backup_success) {
2256
  # This means, "not yet - but stay on the page because we may be able to do it later, e.g. if the user types in the requested information"
@@ -2259,7 +2010,7 @@ class UpdraftPlus_Admin {
2259
  echo '</p>';
2260
  $updraftplus->log("Restore failed");
2261
  $updraftplus->list_errors();
2262
- echo '<strong>'.__('Actions','updraftplus').':</strong> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus">'.__('Return to UpdraftPlus Configuration','updraftplus').'</a>';
2263
  return;
2264
  }
2265
  }
@@ -2301,24 +2052,14 @@ class UpdraftPlus_Admin {
2301
  } elseif ($created !== false) {
2302
  echo '<p>'.__('Backup directory successfully created.', 'updraftplus').'</p><br>';
2303
  }
2304
- echo '<b>'.__('Actions','updraftplus').':</b> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus">'.__('Return to UpdraftPlus Configuration', 'updraftplus').'</a>';
2305
  return;
2306
  }
2307
 
2308
  echo '<div id="updraft_backup_started" class="updated updraft-hidden" style="display:none;"></div>';
2309
 
2310
  if (isset($_POST['action']) && 'updraft_wipesettings' == $_POST['action']) {
2311
- $settings = $updraftplus->get_settings_keys();
2312
- foreach ($settings as $s) UpdraftPlus_Options::delete_updraft_option($s);
2313
-
2314
- // These aren't in get_settings_keys() because they are always in the options table, regardless of context
2315
- global $wpdb;
2316
- $wpdb->query("DELETE FROM $wpdb->options WHERE ( option_name LIKE 'updraftplus_unlocked_%' OR option_name LIKE 'updraftplus_locked_%' OR option_name LIKE 'updraftplus_last_lock_time_%' OR option_name LIKE 'updraftplus_semaphore_%' OR option_name LIKE 'updraft_jobdata_%' OR option_name LIKE 'updraft_last_scheduled_%' )");
2317
-
2318
- $site_options = array('updraft_oneshotnonce');
2319
- foreach ($site_options as $s) delete_site_option($s);
2320
-
2321
- $this->show_admin_warning(__("Your settings have been wiped.", 'updraftplus'));
2322
  }
2323
 
2324
  // This opens a div
@@ -2347,9 +2088,9 @@ class UpdraftPlus_Admin {
2347
  if (get_template() === 'optimizePressTheme' || is_plugin_active('optimizePressPlugin') || is_plugin_active_for_network('optimizePressPlugin')){
2348
  $this->show_admin_warning("<a href='https://optimizepress.zendesk.com/hc/en-us/articles/203699826-Update-URL-References-after-moving-domain' target='_blank'>" . __("OptimizePress 2.0 encodes its contents, so search/replace does not work.","updraftplus") . ' ' . __("To fix this problem go here.","updraftplus") . "</a>", "notice notice-warning");
2349
  }
2350
- $success_advert = (isset($_GET['pval']) && 0 == $_GET['pval'] && !$updraftplus->have_addons) ? '<p>'.__('For even more features and personal support, check out ','updraftplus').'<strong><a href="'.apply_filters("updraftplus_com_link",'https://updraftplus.com/shop/updraftplus-premium/').'" target="_blank">UpdraftPlus Premium</a>.</strong></p>' : "";
2351
 
2352
- echo "<div class=\"updated backup-restored\"><span><strong>".__('Your backup has been restored.','updraftplus').'</strong></span><br>';
2353
  // Unnecessary - will be advised of this below
2354
  // if (2 == $_GET['updraft_restore_success']) echo ' '.__('Your old (themes, uploads, plugins, whatever) directories have been retained with "-old" appended to their name. Remove them when you are satisfied that the backup worked properly.');
2355
  echo $success_advert;
@@ -2431,7 +2172,7 @@ class UpdraftPlus_Admin {
2431
  </div>
2432
 
2433
  <div id="updraft-navtab-settings-content" <?php if (3 != $tabflag) echo 'class="updraft-hidden"'; ?> style="<?php if (3 != $tabflag) echo 'display:none;'; ?>">
2434
- <h2 class="updraft_settings_sectionheading"><?php _e('Backup Contents And Schedule','updraftplus');?></h2>
2435
  <?php UpdraftPlus_Options::options_form_begin(); ?>
2436
  <?php $this->settings_formcontents(); ?>
2437
  </form>
@@ -2503,7 +2244,7 @@ class UpdraftPlus_Admin {
2503
 
2504
  $ret = $this->backup_now_widgetry();
2505
 
2506
- // $ret .= '<p>'.__('Does nothing happen when you attempt backups?','updraftplus').' <a href="https://updraftplus.com/faqs/my-scheduled-backups-and-pressing-backup-now-does-nothing-however-pressing-debug-backup-does-produce-a-backup/">'.__('Go here for help.', 'updraftplus').'</a></p>';
2507
 
2508
  return $ret;
2509
  }
@@ -2552,14 +2293,14 @@ class UpdraftPlus_Admin {
2552
  <?php if ($wide_format) {
2553
  // Hide for now - too ugly
2554
  ?>
2555
- <td colspan="2" class="last-message"><strong><?php _e('Last log message','updraftplus');?>:</strong><br>
2556
- <span id="updraft_lastlogcontainer"><?php echo htmlspecialchars(UpdraftPlus_Options::get_updraft_option('updraft_lastmessage', __('(Nothing yet logged)','updraftplus'))); ?></span><br>
2557
  <?php $this->most_recently_modified_log_link(); ?>
2558
  </td>
2559
  <?php } else { ?>
2560
- <th><?php _e('Last log message','updraftplus');?>:</th>
2561
  <td>
2562
- <span id="updraft_lastlogcontainer"><?php echo htmlspecialchars(UpdraftPlus_Options::get_updraft_option('updraft_lastmessage', __('(Nothing yet logged)','updraftplus'))); ?></span><br>
2563
  <?php $this->most_recently_modified_log_link(); ?>
2564
  </td>
2565
  <?php } ?>
@@ -2615,19 +2356,19 @@ class UpdraftPlus_Admin {
2615
  if ($include_div) {
2616
  echo '<div id="updraft_delete_old_dirs_pagediv" class="updated delete-old-directories">';
2617
  }
2618
- echo '<p>'.__('Your WordPress install has old directories from its state before you restored/migrated (technical information: these are suffixed with -old). You should press this button to delete them as soon as you have verified that the restoration worked.','updraftplus').'</p>';
2619
  }
2620
  ?>
2621
- <form method="post" onsubmit="return updraft_delete_old_dirs();" action="<?php echo esc_url(add_query_arg(array('error' => false, 'updraft_restore_success' => false, 'action' => false, 'page' => 'updraftplus'))); ?>">
2622
  <?php wp_nonce_field('updraftplus-credentialtest-nonce'); ?>
2623
  <input type="hidden" name="action" value="updraft_delete_old_dirs">
2624
- <input type="submit" class="button-primary" value="<?php echo esc_attr(__('Delete Old Directories', 'updraftplus'));?>" />
2625
  </form>
2626
  <?php
2627
  if ($include_blurb && $include_div) echo '</div>';
2628
  }
2629
 
2630
- private function get_cron($job_id = false) {
2631
 
2632
  $cron = get_option('cron');
2633
  if (!is_array($cron)) $cron = array();
@@ -2861,11 +2602,11 @@ class UpdraftPlus_Admin {
2861
  echo ($show_return) ? '<h1>UpdraftPlus - '.__('Remove old directories', 'updraftplus').'</h1>' : '<h2>'.__('Remove old directories', 'updraftplus').'</h2>';
2862
 
2863
  if ($this->delete_old_dirs()) {
2864
- echo '<p>'.__('Old directories successfully removed.','updraftplus').'</p><br>';
2865
  } else {
2866
- echo '<p>',__('Old directory removal failed for some reason. You may want to do this manually.','updraftplus').'</p><br>';
2867
  }
2868
- if ($show_return) echo '<b>'.__('Actions','updraftplus').':</b> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus">'.__('Return to UpdraftPlus Configuration','updraftplus').'</a>';
2869
  }
2870
 
2871
  //deletes the -old directories that are created when a backup is restored.
@@ -2891,7 +2632,7 @@ class UpdraftPlus_Admin {
2891
  // $ret2 = $this->delete_old_dirs_dir($wp_filesystem->abspath());
2892
  $plugs = untrailingslashit($wp_filesystem->wp_plugins_dir());
2893
  if ($wp_filesystem->is_dir($plugs.'-old')) {
2894
- print "<strong>".__('Delete','updraftplus').": </strong>plugins-old: ";
2895
  if (!$wp_filesystem->delete($plugs.'-old', true)) {
2896
  $ret3 = false;
2897
  print "<strong>".__('Failed', 'updraftplus')."</strong><br>";
@@ -2924,7 +2665,7 @@ class UpdraftPlus_Admin {
2924
  $name = (is_array($item)) ? $item['name'] : $item;
2925
  if ("-old" == substr($name, -4, 4)) {
2926
  //recursively delete
2927
- print "<strong>".__('Delete','updraftplus').": </strong>".htmlspecialchars($name).": ";
2928
 
2929
  if ($wpfs) {
2930
  if (!$wp_filesystem->delete($dir.$name, true)) {
@@ -3031,7 +2772,7 @@ class UpdraftPlus_Admin {
3031
  <?php
3032
  }
3033
 
3034
- private function last_backup_html() {
3035
 
3036
  global $updraftplus;
3037
 
@@ -3076,11 +2817,11 @@ class UpdraftPlus_Admin {
3076
  $updraft_dir = $updraftplus->backups_dir_location();
3077
 
3078
  $potential_log_file = $updraft_dir."/log.".$updraft_last_backup['backup_nonce'].".txt";
3079
- if (is_readable($potential_log_file)) $last_backup_text .= "<a href=\"?page=updraftplus&action=downloadlog&updraftplus_backup_nonce=".$updraft_last_backup['backup_nonce']."\" class=\"updraft-log-link\" onclick=\"event.preventDefault(); updraft_popuplog('".$updraft_last_backup['backup_nonce']."');\">".__('Download log file','updraftplus')."</a>";
3080
  }
3081
 
3082
  } else {
3083
- $last_backup_text = "<span style=\"color:blue;\">".__('No backup has been completed','updraftplus')."</span>";
3084
  }
3085
 
3086
  return $last_backup_text;
@@ -3102,15 +2843,15 @@ class UpdraftPlus_Admin {
3102
 
3103
  public function really_writable_message($really_is_writable, $updraft_dir){
3104
  if ($really_is_writable) {
3105
- $dir_info = '<span style="color:green;">'.__('Backup directory specified is writable, which is good.','updraftplus').'</span>';
3106
  } else {
3107
  $dir_info = '<span style="color:red;">';
3108
  if (!is_dir($updraft_dir)) {
3109
- $dir_info .= __('Backup directory specified does <b>not</b> exist.','updraftplus');
3110
  } else {
3111
- $dir_info .= __('Backup directory specified exists, but is <b>not</b> writable.','updraftplus');
3112
  }
3113
- $dir_info .= '<span class="updraft-directory-not-writable-blurb"><span class="directory-permissions"><a class="updraft_create_backup_dir" href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&action=updraft_create_backup_dir&nonce='.wp_create_nonce('create_backup_dir').'">'.__('Follow this link to attempt to create the directory and set the permissions','updraftplus').'</a></span>, '.__('or, to reset this option','updraftplus').' <a href="#" class="updraft_backup_dir_reset">'.__('click here','updraftplus').'</a>. '.__('If that is unsuccessful check the permissions on your server or change it to another directory that is writable by your web server process.','updraftplus').'</span>';
3114
  }
3115
  return $dir_info;
3116
  }
@@ -3227,16 +2968,16 @@ class UpdraftPlus_Admin {
3227
  // Check requirements
3228
  if (!function_exists("curl_init") || !function_exists('curl_exec')) {
3229
 
3230
- $ret .= $this->show_double_warning('<strong>'.__('Warning','updraftplus').':</strong> '.sprintf(__("Your web server's PHP installation does not included a <strong>required</strong> (for %s) module (%s). Please contact your web hosting provider's support and ask for them to enable it.", 'updraftplus'), $service, 'Curl').' ', $extraclass, false);
3231
 
3232
  } else {
3233
  $curl_version = curl_version();
3234
  $curl_ssl_supported= ($curl_version['features'] & CURL_VERSION_SSL);
3235
  if (!$curl_ssl_supported) {
3236
  if ($has_fallback) {
3237
- $ret .= '<p><strong>'.__('Warning','updraftplus').':</strong> '.sprintf(__("Your web server's PHP/Curl installation does not support https access. Communications with %s will be unencrypted. ask your web host to install Curl/SSL in order to gain the ability for encryption (via an add-on).",'updraftplus'),$service).'</p>';
3238
  } else {
3239
- $ret .= $this->show_double_warning('<p><strong>'.__('Warning','updraftplus').':</strong> '.sprintf(__("Your web server's PHP/Curl installation does not support https access. We cannot access %s without this support. Please contact your web hosting provider's support. %s <strong>requires</strong> Curl+https. Please do not file any support requests; there is no alternative.",'updraftplus'),$service).'</p>', $extraclass, false);
3240
  }
3241
  } else {
3242
  $ret .= '<p><em>'.sprintf(__("Good news: Your site's communications with %s can be encrypted. If you see any errors to do with encryption, then look in the 'Expert Settings' for more help.", 'updraftplus'),$service).'</em></p>';
@@ -3405,136 +3146,17 @@ class UpdraftPlus_Admin {
3405
  global $updraftplus;
3406
 
3407
  if (false === $backup_history) $backup_history = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
3408
- if (!is_array($backup_history)) $backup_history=array();
3409
- if (empty($backup_history)) return "<p><em>".__('You have not yet made any backups.', 'updraftplus')."</em></p>";
3410
-
3411
- $updraft_dir = $updraftplus->backups_dir_location();
3412
- $backupable_entities = $updraftplus->get_backupable_file_entities(true, true);
3413
-
3414
- $accept = apply_filters('updraftplus_accept_archivename', array());
3415
- if (!is_array($accept)) $accept = array();
3416
-
3417
- $ret = '<table class="existing-backups-table">';
3418
-
3419
- //".__('Actions', 'updraftplus')."
3420
- $ret .= "<thead>
3421
- <tr style=\"margin-bottom: 4px;\">
3422
- <th class=\"backup-date\">".__('Backup date', 'updraftplus')."</th>
3423
- <th class=\"backup-data\">".__('Backup data (click to download)', 'updraftplus')."</th>
3424
- <th class=\"updraft_backup_actions\">".__('Actions', 'updraftplus')."</th>
3425
- </tr>
3426
- <tr style=\"height:2px; padding:1px; margin:0px;\">
3427
- <td colspan=\"4\" style=\"margin:0; padding:0\"><div style=\"height: 2px; background-color:#888888;\">&nbsp;</div></td>
3428
- </tr>
3429
- </thead>
3430
- <tbody>";
3431
- // $ret .= "<thead>
3432
- // </thead>
3433
- // <tbody>";
3434
-
3435
- krsort($backup_history);
3436
- foreach ($backup_history as $key => $backup) {
3437
-
3438
- $remote_sent = (!empty($backup['service']) && ((is_array($backup['service']) && in_array('remotesend', $backup['service'])) || 'remotesend' === $backup['service'])) ? true : false;
3439
-
3440
- # https://core.trac.wordpress.org/ticket/25331 explains why the following line is wrong
3441
- # $pretty_date = date_i18n('Y-m-d G:i',$key);
3442
- // Convert to blog time zone
3443
- // $pretty_date = get_date_from_gmt(gmdate('Y-m-d H:i:s', (int)$key), 'Y-m-d G:i');
3444
- $pretty_date = get_date_from_gmt(gmdate('Y-m-d H:i:s', (int)$key), 'M d, Y G:i');
3445
-
3446
- $esc_pretty_date = esc_attr($pretty_date);
3447
- $entities = '';
3448
-
3449
- $non = $backup['nonce'];
3450
- $rawbackup = $this->raw_backup_info($backup_history, $key, $non);
3451
-
3452
- $jobdata = $updraftplus->jobdata_getarray($non);
3453
-
3454
- $delete_button = $this->delete_button($key, $non, $backup);
3455
-
3456
- $date_label = $this->date_label($pretty_date, $key, $backup, $jobdata, $non);
3457
-
3458
- $log_button = $this->log_button($backup);
3459
-
3460
- // Remote backups with no log result in useless empty rows
3461
- // However, not showing anything messes up the "Existing Backups (14)" display, until we tweak that code to count differently
3462
- // if ($remote_sent && !$log_button) continue;
3463
-
3464
- $ret .= <<<ENDHERE
3465
- <tr class="updraft_existing_backups_row updraft_existing_backups_row_$key" data-key="$key" data-nonce="$non">
3466
-
3467
- <td class="updraft_existingbackup_date " data-rawbackup="$rawbackup">
3468
- $date_label
3469
- </td>
3470
- ENDHERE;
3471
-
3472
- $ret .= "<td>";
3473
-
3474
- if ($remote_sent) {
3475
-
3476
- $ret .= __('Backup sent to remote site - not available for download.', 'updraftplus');
3477
- if (!empty($backup['remotesend_url'])) $ret .= '<br>'.__('Site', 'updraftplus').': '.htmlspecialchars($backup['remotesend_url']);
3478
-
3479
- } else {
3480
-
3481
- if (empty($backup['meta_foreign']) || !empty($accept[$backup['meta_foreign']]['separatedb'])) {
3482
-
3483
- if (isset($backup['db'])) {
3484
- $entities .= '/db=0/';
3485
-
3486
- // Set a flag according to whether or not $backup['db'] ends in .crypt, then pick this up in the display of the decrypt field.
3487
- $db = is_array($backup['db']) ? $backup['db'][0] : $backup['db'];
3488
- if ($updraftplus->is_db_encrypted($db)) $entities .= '/dbcrypted=1/';
3489
-
3490
- $ret .= $this->download_db_button('db', $key, $esc_pretty_date, $backup, $accept);
3491
- } else {
3492
- // $ret .= sprintf(_x('(No %s)','Message shown when no such object is available','updraftplus'), __('database', 'updraftplus'));
3493
- }
3494
-
3495
- # External databases
3496
- foreach ($backup as $bkey => $binfo) {
3497
- if ('db' == $bkey || 'db' != substr($bkey, 0, 2) || '-size' == substr($bkey, -5, 5)) continue;
3498
- $ret .= $this->download_db_button($bkey, $key, $esc_pretty_date, $backup);
3499
- }
3500
-
3501
- } else {
3502
- # Foreign without separate db
3503
- $entities = '/db=0/meta_foreign=1/';
3504
- }
3505
-
3506
- if (!empty($backup['meta_foreign']) && !empty($accept[$backup['meta_foreign']]) && !empty($accept[$backup['meta_foreign']]['separatedb'])) {
3507
- $entities .= '/meta_foreign=2/';
3508
- }
3509
-
3510
- $download_buttons = $this->download_buttons($backup, $key, $accept, $entities, $esc_pretty_date);
3511
-
3512
- $ret .= $download_buttons;
3513
-
3514
- // $ret .="</td>";
3515
-
3516
- // No logs expected for foreign backups
3517
- if (empty($backup['meta_foreign'])) {
3518
- // $ret .= '<td>'.$this->log_button($backup)."</td>";
3519
- }
3520
- }
3521
-
3522
- $ret .= "</td>";
3523
-
3524
- $ret .= '<td class="before-restore-button">';
3525
- $ret .= $this->restore_button($backup, $key, $pretty_date, $entities);
3526
- $ret .= $delete_button;
3527
- if (empty($backup['meta_foreign'])) $ret .= $log_button;
3528
- $ret .= '</td>';
3529
-
3530
- $ret .= '</tr>';
3531
-
3532
- $ret .= "<tr style=\"height:2px; padding:1px; margin:0px;\"><td colspan=\"4\" style=\"margin:0; padding:0\"><div style=\"height: 2px; background-color:#aaaaaa;\">&nbsp;</div></td></tr>";
3533
-
3534
- }
3535
 
3536
- $ret .= '</tbody></table>';
3537
- return $ret;
 
 
 
 
 
 
3538
  }
3539
 
3540
  private function download_db_button($bkey, $key, $esc_pretty_date, $backup, $accept = array()) {
@@ -3548,9 +3170,9 @@ ENDHERE;
3548
  $ret = '';
3549
 
3550
  if ('db' == $bkey) {
3551
- $dbt = empty($backup['meta_foreign']) ? esc_attr(__('Database','updraftplus')) : esc_attr(sprintf(__('Database (created by %s)', 'updraftplus'), $desc_source));
3552
  } else {
3553
- $dbt = __('External database','updraftplus').' ('.substr($bkey, 2).')';
3554
  }
3555
 
3556
  $ret .= $this->download_button($bkey, $key, 0, null, '', $dbt, $esc_pretty_date, '0');
@@ -3559,28 +3181,16 @@ ENDHERE;
3559
  }
3560
 
3561
  // Go through each of the file entities
3562
- private function download_buttons($backup, $key, $accept, &$entities, $esc_pretty_date) {
3563
  global $updraftplus;
3564
  $ret = '';
3565
  $backupable_entities = $updraftplus->get_backupable_file_entities(true, true);
3566
 
3567
- // $colspan = 1;
3568
- // if (!empty($backup['meta_foreign'])) {
3569
- // $colspan = 2;
3570
- // if (empty($accept[$backup['meta_foreign']]['separatedb'])) $colspan++;
3571
- // }
3572
- // $ret .= (1 == $colspan) ? '<td>' : '<td colspan="'.$colspan.'">';
3573
-
3574
  $first_entity = true;
3575
 
3576
  foreach ($backupable_entities as $type => $info) {
3577
  if (!empty($backup['meta_foreign']) && 'wpcore' != $type) continue;
3578
- // $colspan = 1;
3579
- // if (!empty($backup['meta_foreign'])) {
3580
- // $colspan = (1+count($backupable_entities));
3581
- // if (empty($accept[$backup['meta_foreign']]['separatedb'])) $colspan++;
3582
- // }
3583
- // $ret .= (1 == $colspan) ? '<td>' : '<td colspan="'.$colspan.'">';
3584
  $ide = '';
3585
  if ('wpcore' == $type) $wpcore_restore_descrip = $info['description'];
3586
  if (empty($backup['meta_foreign'])) {
@@ -3648,12 +3258,8 @@ ENDHERE;
3648
  $printing_first = false;
3649
  }
3650
  }
3651
- } else {
3652
- // $ret .= sprintf(_x('(No %s)','Message shown when no such object is available','updraftplus'), preg_replace('/\s\(.{12,}\)/', '', strtolower($sdescrip)));
3653
  }
3654
- // $ret .= '</td>';
3655
  }
3656
- // $ret .= '</td>';
3657
  return $ret;
3658
  }
3659
 
@@ -3670,7 +3276,7 @@ ENDHERE;
3670
  return $ret;
3671
  }
3672
 
3673
- private function download_button($type, $backup_timestamp, $findex, $info, $title, $pdescrip, $esc_pretty_date, $set_contents) {
3674
 
3675
  $ret = '';
3676
 
@@ -3683,7 +3289,7 @@ ENDHERE;
3683
  return $ret;
3684
  }
3685
 
3686
- private function restore_button($backup, $key, $pretty_date, $entities = '') {
3687
  $ret = '<div class="restore-button">';
3688
 
3689
  if ($entities) {
@@ -3692,26 +3298,26 @@ ENDHERE;
3692
  $show_data .= ' '.__('(backup set imported from remote location)', 'updraftplus');
3693
  }
3694
 
3695
- $ret .= '<button data-showdata="'.esc_attr($show_data).'" data-backup_timestamp="'.$key.'" data-entities="'.esc_attr($entities).'" title="'.__('After pressing this button, you will be given the option to choose which components you wish to restore','updraftplus').'" type="button" style="float:left; clear:none;" class="button-primary choose-components-button">'.__('Restore', 'updraftplus').'</button>';
3696
  }
3697
  $ret .= "</div>\n";
3698
  return $ret;
3699
  }
3700
 
3701
- private function delete_button($key, $nonce, $backup) {
3702
  $sval = ((isset($backup['service']) && $backup['service'] != 'email' && $backup['service'] != 'none')) ? '1' : '0';
3703
  return '<div class="updraftplus-remove" style="float: left; clear: none;" data-hasremote="'.$sval.'">
3704
  <a data-hasremote="'.$sval.'" data-nonce="'.$nonce.'" data-key="'.$key.'" class="no-decoration updraft-delete-link" href="#" title="'.esc_attr(__('Delete this backup set', 'updraftplus')).'">'.__('Delete', 'updraftplus').'</a>
3705
  </div>';
3706
  }
3707
 
3708
- private function log_button($backup) {
3709
  global $updraftplus;
3710
  $updraft_dir = $updraftplus->backups_dir_location();
3711
  $ret = '';
3712
  if (isset($backup['nonce']) && preg_match("/^[0-9a-f]{12}$/",$backup['nonce']) && is_readable($updraft_dir.'/log.'.$backup['nonce'].'.txt')) {
3713
  $nval = $backup['nonce'];
3714
- // $lt = esc_attr(__('View Log','updraftplus'));
3715
  $lt = __('View Log', 'updraftplus');
3716
  $url = esc_attr(UpdraftPlus_Options::admin_page()."?page=updraftplus&action=downloadlog&amp;updraftplus_backup_nonce=$nval");
3717
  $ret .= <<<ENDHERE
@@ -3743,7 +3349,7 @@ ENDHERE;
3743
  global $wp_filesystem, $updraftplus;
3744
  $backup_history = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
3745
  if (!isset($backup_history[$timestamp]) || !is_array($backup_history[$timestamp])) {
3746
- echo '<p>'.__('This backup does not exist in the backup history - restoration aborted. Timestamp:','updraftplus')." $timestamp</p><br>";
3747
  return new WP_Error('does_not_exist', __('Backup does not exist in the backup history', 'updraftplus'));
3748
  }
3749
 
@@ -3838,7 +3444,7 @@ ENDHERE;
3838
 
3839
  if (0 == count($_POST['updraft_restore'])) {
3840
  echo '<p>'.__('ABORT: Could not find the information on which entities to restore.', 'updraftplus').'</p>';
3841
- echo '<p>'.__('If making a request for support, please include this information:','updraftplus').' '.count($_POST).' : '.htmlspecialchars(serialize($_POST)).'</p>';
3842
  return new WP_Error('missing_info', 'Backup information not found');
3843
  }
3844
 
@@ -3957,9 +3563,9 @@ ENDHERE;
3957
  $print_message = __("Archive is expected to be size:",'updraftplus')." ".round($fs/1024, 1)." KB: ";
3958
  $as = @filesize($fullpath);
3959
  if ($as == $fs) {
3960
- $updraftplus->log($print_message.__('OK','updraftplus'), 'notice-restore');
3961
  } else {
3962
- $updraftplus->log($print_message.__('Error:','updraftplus')." ".__('file is size:', 'updraftplus')." ".round($as/1024)." ($fs, $as)", 'warning-restore');
3963
  }
3964
  } else {
3965
  $updraftplus->log(__("The backup records do not contain information about the proper size of this file.",'updraftplus'), 'notice-restore');
@@ -4043,7 +3649,7 @@ ENDHERE;
4043
  # Types: uploads, themes, plugins, others, db
4044
  $info = (isset($backupable_entities[$type])) ? $backupable_entities[$type] : array();
4045
 
4046
- echo ('db' == $type) ? "<h2>".__('Database','updraftplus')."</h2>" : "<h2>".$info['description']."</h2>";
4047
  $updraftplus->log("Entity: ".$type);
4048
 
4049
  if (is_string($files)) $files = array($files);
@@ -4213,7 +3819,12 @@ ENDHERE;
4213
  return '<input type="checkbox" id="backupnow_includecloud" checked="checked"> <label for="backupnow_includecloud">'.__("Send this backup to remote storage", 'updraftplus').'</label>';
4214
  }
4215
  }
4216
-
 
 
 
 
 
4217
  public function save_settings($settings) {
4218
 
4219
  global $updraftplus;
@@ -4236,6 +3847,14 @@ ENDHERE;
4236
  $_POST[$key] = $settings[$key];
4237
  }
4238
  }
 
 
 
 
 
 
 
 
4239
 
4240
  // Wipe the extra retention rules, as they are not saved correctly if the last one is deleted
4241
  UpdraftPlus_Options::update_updraft_option('updraft_retain_extrarules', array());
@@ -4252,7 +3871,7 @@ ENDHERE;
4252
  $settings = UpdraftPlus_Options::mass_options_update($settings);
4253
  $mass_updated = true;
4254
  }
4255
-
4256
  foreach ($settings as $key => $value) {
4257
  // $exclude_keys = array('option_page', 'action', '_wpnonce', '_wp_http_referer');
4258
 
@@ -4275,6 +3894,7 @@ ENDHERE;
4275
  $value = UpdraftPlus_Options::get_updraft_option($key);
4276
  if (is_string($value)) $return_array['changed'][$key] = $value;
4277
  }
 
4278
  } else {
4279
  // When last active, it was catching: option_page, action, _wpnonce, _wp_http_referer, updraft_s3_endpoint, updraft_dreamobjects_endpoint. The latter two are empty; probably don't need to be in the page at all.
4280
  //error_log("Non-UD key when saving from POSTed data: ".$key);
@@ -4290,6 +3910,11 @@ ENDHERE;
4290
  $return_array['backup_now_message'] = $this->backup_now_remote_message();
4291
 
4292
  $return_array['backup_dir'] = array('writable' => $really_is_writable, 'message' => $dir_info, 'button_title' => $button_title);
 
 
 
 
 
4293
 
4294
  //Because of the single AJAX call, we need to remove the existing UD messages from the 'all_admin_notices' action
4295
  remove_all_actions('all_admin_notices');
@@ -4330,18 +3955,48 @@ ENDHERE;
4330
  return $return_array;
4331
 
4332
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4333
 
4334
  //this get the details for updraft vault and to be used globally
4335
- public function get_updraftvault(){
4336
  require_once(UPDRAFTPLUS_DIR.'/methods/updraftvault.php');
4337
  $vault = new UpdraftPlus_BackupModule_updraftvault();
4338
  return $vault;
4339
  }
4340
 
4341
- //http_get will allow the HTTP Fetch execute available in advanced tools
4342
- public function http_get($uri=null, $curl=null){
4343
 
4344
- if (!empty($_REQUEST['curl']) || $curl == true) {
4345
  if (!function_exists('curl_exec')) {
4346
  return json_encode(array('e' => 'No Curl installed'));
4347
  die;
@@ -4392,14 +4047,13 @@ ENDHERE;
4392
  }
4393
  }
4394
 
4395
-
4396
  //This will bring back all the details for raw backup and file list
4397
  public function show_raw_backups($no_pre_tags = false){
4398
  global $updraftplus;
4399
 
4400
  $response = array();
4401
 
4402
- $response['html'] .= '<h3 id="ud-debuginfo-rawbackups">'.__('Known backups (raw)', 'updraftplus').'</h3><pre>';
4403
  ob_start();
4404
  var_dump($updraftplus->get_backup_history());
4405
  $response["html"] .= ob_get_clean();
@@ -4432,7 +4086,7 @@ ENDHERE;
4432
  $response['html'] .= '<h3 id="ud-debuginfo-options">'.__('Options (raw)', 'updraftplus').'</h3>';
4433
  $opts = $updraftplus->get_settings_keys();
4434
  asort($opts);
4435
- // <tr><th>'.__('Key','updraftplus').'</th><th>'.__('Value','updraftplus').'</th></tr>
4436
  $response['html'] .= '<table><thead></thead><tbody>';
4437
  foreach ($opts as $opt) {
4438
  $response['html'] .= '<tr><td>'.htmlspecialchars($opt).'</td><td>'.htmlspecialchars(print_r(UpdraftPlus_Options::get_updraft_option($opt), true)).'</td>';
@@ -4451,8 +4105,8 @@ ENDHERE;
4451
  return $response;
4452
  }
4453
 
4454
- //this will call any wp_action
4455
- public function call_wp_action($data=null){
4456
  global $updraftplus;
4457
 
4458
  ob_start();
@@ -4465,6 +4119,7 @@ ENDHERE;
4465
  $res .= "The parameters (should be JSON) could not be decoded";
4466
  $action = false;
4467
  } else {
 
4468
  $res .= "Will despatch action: ".htmlspecialchars($action).", parameters: ".htmlspecialchars(implode(',', $args));
4469
  }
4470
  } else {
@@ -4472,14 +4127,15 @@ ENDHERE;
4472
  $res .= "Will despatch action: ".htmlspecialchars($action).", no parameters";
4473
  }
4474
 
4475
- //this is used for UDP call
4476
- echo json_encode(array('r' => $res));
4477
-
4478
  $ret = ob_get_clean();
4479
 
4480
  //need to add this as the close browser should only work for UDP
4481
- if (isset($_REQUEST['wpaction'])) {
4482
- $updraftplus->close_browser_connection($ret);
 
 
 
 
4483
  }
4484
 
4485
  if (!empty($action)) {
@@ -4504,4 +4160,15 @@ ENDHERE;
4504
 
4505
  return $response;
4506
  }
 
 
 
 
 
 
 
 
 
 
 
4507
  }
224
  ?>
225
  <tr>
226
  <?php if (isset($files_not_scheduled) && isset($database_not_scheduled)) { ?>
227
+ <td colspan="2" class="not-scheduled"><?php _e('Nothing currently scheduled', 'updraftplus'); ?></td>
228
  <?php } else { ?>
229
+ <td class="updraft_scheduled"><?php echo empty($next_scheduled_backup_database_same_time) ? __('Files', 'updraftplus') : __('Files and database', 'updraftplus'); ?>:</td><td class="updraft_all-files"><?php echo $next_scheduled_backup; ?></td>
230
  </tr>
231
  <?php if (empty($next_scheduled_backup_database_same_time)) { ?>
232
  <tr>
233
+ <td class="updraft_scheduled"><?php _e('Database', 'updraftplus');?>: </td><td class="updraft_all-files"><?php echo $next_scheduled_backup_database; ?></td>
234
  </tr>
235
  <?php } ?>
236
  <?php
303
  add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 99999);
304
  }
305
 
306
+ /**
307
+ * Sets up what is needed to allow an in-page backup to be run. Will enqueue scripts and output appropriate HTML (so, should be run when at a suitable place). Not intended for use on the UpdraftPlus settings page.
308
+ *
309
+ * @param string $title Text to use for the title of the modal
310
+ * @param callable $callback Callable function to output the contents of the updraft_inpage_prebackup element - i.e. what shows in the modal before a backup beings.
311
+ *
312
+ */
313
+ public function add_backup_scaffolding($title, $callback) {
314
+ $this->admin_enqueue_scripts();
315
+ ?>
316
+ <script>
317
+ // TODO: This is not the best way.
318
+ var updraft_credentialtest_nonce='<?php echo wp_create_nonce('updraftplus-credentialtest-nonce');?>';
319
+ </script>
320
+ <div id="updraft-poplog" >
321
+ <pre id="updraft-poplog-content" style="white-space: pre-wrap;"></pre>
322
+ </div>
323
+
324
+ <div id="updraft-backupnow-inpage-modal" title="UpdraftPlus - <?php echo $title; ?>">
325
+
326
+ <div id="updraft_inpage_prebackup" style="float:left; clear:both;">
327
+ <?php call_user_func($callback); ?>
328
+ </div>
329
+
330
+ <div id="updraft_inpage_backup" style="float:left; clear:both;">
331
+
332
+ <h2><?php echo $title;?></h2>
333
+
334
+ <div id="updraft_backup_started" class="updated" style="display:none; max-width: 560px; font-size:100%; line-height: 100%; padding:6px; clear:left;"></div>
335
+
336
+ <?php $this->render_active_jobs_and_log_table(true, false); ?>
337
+
338
+ </div>
339
+
340
+ </div>
341
+ <?php
342
+ }
343
+
344
  public function updraft_ajaxrestore() {
345
  // TODO: All needs testing with restricted filesystem permissions. Those credentials need to be POST-ed too - currently not.
346
  // TODO
516
  wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', false, '1.7.2', false);
517
  wp_enqueue_script('jquery');
518
  // No plupload until 3.3
519
+ wp_enqueue_script('updraftplus-admin', UPDRAFTPLUS_URL.'/includes/updraft-admin.js', array('jquery', 'jquery-ui-dialog'), $enqueue_version, true);
520
  } else {
521
+ wp_enqueue_script('updraftplus-admin', UPDRAFTPLUS_URL.'/includes/updraft-admin.js', array('jquery', 'jquery-ui-dialog', 'plupload-all'), $enqueue_version);
522
  }
523
 
524
  }
560
  $mday_selector .= "\n\t<option value='" . $mday_index . "' $selected>" . $mday_index . '</option>';
561
  }
562
 
563
+ wp_localize_script('updraftplus-admin', 'updraftlion', array(
564
  'sendonlyonwarnings' => __('Send a report only when there are warnings/errors', 'updraftplus'),
565
  'wholebackup' => __('When the Email storage method is enabled, also send the entire backup', 'updraftplus'),
566
+ 'emailsizelimits' => esc_attr(sprintf(__('Be aware that mail servers tend to have size limits; typically around %s Mb; backups larger than any limits will likely not arrive.', 'updraftplus'), '10-20')),
567
+ 'rescanning' => __('Rescanning (looking for backups that you have uploaded manually into the internal backup store)...', 'updraftplus'),
568
+ 'rescanningremote' => __('Rescanning remote and local storage for backup sets...', 'updraftplus'),
569
  'enteremailhere' => esc_attr(__('To send to more than one address, separate each address with a comma.', 'updraftplus')),
570
  'excludedeverything' => __('If you exclude both the database and the files, then you have excluded everything!', 'updraftplus'),
571
  'nofileschosen' => __('You have chosen to backup files, but no file entities have been selected', 'updraftplus'),
572
  'restoreproceeding' => __('The restore operation has begun. Do not press stop or close your browser until it reports itself as having finished.', 'updraftplus'),
573
+ 'unexpectedresponse' => __('Unexpected response:', 'updraftplus'),
574
  'servererrorcode' => __('The web server returned an error code (try again, or check your web server logs)', 'updraftplus'),
575
  'newuserpass' => __("The new user's RackSpace console password is (this will not be shown again):", 'updraftplus'),
576
  'trying' => __('Trying...', 'updraftplus'),
577
  'fetching' => __('Fetching...', 'updraftplus'),
578
+ 'calculating' => __('calculating...', 'updraftplus'),
579
+ 'begunlooking' => __('Begun looking for this entity', 'updraftplus'),
580
  'stilldownloading' => __('Some files are still downloading or being processed - please wait.', 'updraftplus'),
581
  'processing' => __('Processing files - please wait...', 'updraftplus'),
582
  'emptyresponse' => __('Error: the server sent an empty response.', 'updraftplus'),
583
+ 'warnings' => __('Warnings:', 'updraftplus'),
584
+ 'errors' => __('Errors:', 'updraftplus'),
585
  'jsonnotunderstood' => __('Error: the server sent us a response which we did not understand.', 'updraftplus'),
586
  'errordata' => __('Error data:', 'updraftplus'),
587
+ 'error' => __('Error:', 'updraftplus'),
588
+ 'errornocolon' => __('Error', 'updraftplus'),
589
+ 'existing_backups' => __('Existing Backups', 'updraftplus'),
590
+ 'fileready' => __('File ready.', 'updraftplus'),
591
+ 'actions' => __('Actions', 'updraftplus'),
592
+ 'deletefromserver' => __('Delete from your web server', 'updraftplus'),
593
+ 'downloadtocomputer' => __('Download to your computer', 'updraftplus'),
594
+ 'show_contents' => __('Show contents', 'updraftplus'),
595
  'notunderstood' => __('Download error: the server sent us a response which we did not understand.', 'updraftplus'),
596
  'requeststart' => __('Requesting start of backup...', 'updraftplus'),
597
  'phpinfo' => __('PHP information', 'updraftplus'),
598
  'delete_old_dirs' => __('Delete Old Directories', 'updraftplus'),
599
  'raw' => __('Raw backup history', 'updraftplus'),
600
+ 'notarchive' => __('This file does not appear to be an UpdraftPlus backup archive (such files are .zip or .gz files which have a name like: backup_(time)_(site name)_(code)_(type).(zip|gz)).', 'updraftplus').' '.__('However, UpdraftPlus archives are standard zip/SQL files - so if you are sure that your file has the right format, then you can rename it to match that pattern.', 'updraftplus'),
601
  'notarchive2' => '<p>'.__('This file does not appear to be an UpdraftPlus backup archive (such files are .zip or .gz files which have a name like: backup_(time)_(site name)_(code)_(type).(zip|gz)).', 'updraftplus').'</p> '.apply_filters('updraftplus_if_foreign_then_premium_message', '<p><a href="'.apply_filters('updraftplus_com_link', "https://updraftplus.com/shop/updraftplus-premium/").'">'.__('If this is a backup created by a different backup plugin, then UpdraftPlus Premium may be able to help you.', 'updraftplus').'</a></p>'),
602
+ 'makesure' => __('(make sure that you were trying to upload a zip file previously created by UpdraftPlus)', 'updraftplus'),
603
+ 'uploaderror' => __('Upload error:', 'updraftplus'),
604
+ 'notdba' => __('This file does not appear to be an UpdraftPlus encrypted database archive (such files are .gz.crypt files which have a name like: backup_(time)_(site name)_(code)_db.crypt.gz).', 'updraftplus'),
605
  'uploaderr' => __('Upload error', 'updraftplus'),
606
+ 'followlink' => __('Follow this link to attempt decryption and download the database file to your computer.', 'updraftplus'),
607
+ 'thiskey' => __('This decryption key will be attempted:', 'updraftplus'),
608
+ 'unknownresp' => __('Unknown server response:', 'updraftplus'),
609
+ 'ukrespstatus' => __('Unknown server response status:', 'updraftplus'),
610
+ 'uploaded' => __('The file was uploaded.', 'updraftplus'),
611
  'backupnow' => __('Backup Now', 'updraftplus'),
612
  'cancel' => __('Cancel', 'updraftplus'),
613
  'deletebutton' => __('Delete', 'updraftplus'),
634
  'checkrpcsetup' => sprintf(__('You should check that the remote site is online, not firewalled, does not have security modules that may be blocking access, has UpdraftPlus version %s or later active and that the keys have been entered correctly.', 'updraftplus'), '2.10.3'),
635
  'pleasenamekey' => __('Please give this key a name (e.g. indicate the site it is for):', 'updraftplus'),
636
  'key' => __('Key', 'updraftplus'),
637
+ 'nokeynamegiven' => sprintf(__("Failure: No %s was given.",'updraftplus'), __('key name', 'updraftplus')),
638
  'deleting' => __('Deleting...', 'updraftplus'),
639
  'enter_mothership_url' => __('Please enter a valid URL', 'updraftplus'),
640
  'delete_response_not_understood' => __("We requested to delete the file, but could not understand the server's response", 'updraftplus'),
643
  'migratemodalheight' => class_exists('UpdraftPlus_Addons_Migrator') ? 555 : 300,
644
  'migratemodalwidth' => class_exists('UpdraftPlus_Addons_Migrator') ? 770 : 500,
645
  'download' => _x('Download', '(verb)', 'updraftplus'),
646
+ 'unsavedsettingsbackup' => __('You have made changes to your settings, and not saved.', 'updraftplus')."\n".__('You should save your changes to ensure that they are used for making your backup.', 'updraftplus'),
647
+ 'unsaved_settings_export' => __('You have made changes to your settings, and not saved.', 'updraftplus')."\n".__('Your export file will be of your displayed settings, not your saved ones.', 'updraftplus'),
648
  'dayselector' => $day_selector,
649
  'mdayselector' => $mday_selector,
650
  'day' => __('day', 'updraftplus'),
660
  'testing_settings' => __('Testing %s Settings...', 'updraftplus'),
661
  'settings_test_result' => __('%s settings test result:', 'updraftplus'),
662
  'nothing_yet_logged' => __('Nothing yet logged', 'updraftplus'),
663
+ 'import_select_file' => __('You have not yet selected a file to import.', 'updraftplus'),
664
  'updraft_settings_url' => UpdraftPlus_Options::admin_page_url().'?page=updraftplus',
665
  'network_site_url' => network_site_url(),
666
  'importing' => __('Importing...', 'updraftplus'),
667
  'importing_data_from' => __('This will import data from:', 'updraftplus'),
668
+ 'exported_on' => __('Which was exported on:', 'updraftplus'),
669
+ 'continue_import' => __('Do you want to carry out the import?', 'updraftplus'),
670
+ 'complete' => __('Complete', 'updraftplus'),
671
  'remote_delete_limit' => defined('UPDRAFTPLUS_REMOTE_DELETE_LIMIT') ? UPDRAFTPLUS_REMOTE_DELETE_LIMIT : 15,
672
  'remote_files_deleted' => __('remote files deleted', 'updraftplus'),
673
  ) );
690
  echo apply_filters('updraftplus_autobackup_blurb', $updraftplus_notices->do_notice('autobackup', 'autobackup', true));
691
  } else {
692
  echo '<div class="updraft-ad-container updated">';
693
+ echo '<h3 style="margin-top: 2px;">'. __('Be safe with an automatic backup', 'updraftplus').'</h3>';
694
  echo apply_filters('updraftplus_autobackup_blurb', '');
695
  echo '</div>';
696
  }
755
  $plupload_init['silverlight_xap_url'] = includes_url('js/plupload/plupload.silverlight.swf');
756
  }
757
 
758
+ ?><script>
759
  var updraft_credentialtest_nonce='<?php echo wp_create_nonce('updraftplus-credentialtest-nonce');?>';
760
  var updraftplus_settings_nonce='<?php echo wp_create_nonce('updraftplus-settings-nonce');?>';
761
  var updraft_siteurl = '<?php echo esc_js(site_url('', 'relative'));?>';
774
  <?php
775
  $overdue = $this->howmany_overdue_crons();
776
  if ($overdue >= 4) { ?>
777
+ jQuery(document).ready(function(){
778
+ setTimeout(function(){updraft_check_overduecrons();}, 11000);
 
 
 
 
 
 
 
 
 
 
 
 
779
  });
780
+ <?php } ?>
 
 
781
  </script>
782
  <?php
 
783
  }
784
 
785
 
849
  }
850
 
851
  public function show_admin_warning_execution_time() {
852
+ $this->show_admin_warning('<strong>'.__('Warning', 'updraftplus').':</strong> '.sprintf(__('The amount of time allowed for WordPress plugins to run is very low (%s seconds) - you should increase it to avoid backup failures due to time-outs (consult your web hosting company for more help - it is the max_execution_time PHP setting; the recommended value is %s seconds or more)', 'updraftplus'), (int)@ini_get('max_execution_time'), 90));
853
  }
854
 
855
  public function show_admin_warning_disabledcron() {
856
+ $this->show_admin_warning('<strong>'.__('Warning', 'updraftplus').':</strong> '.__('The scheduler is disabled in your WordPress install, via the DISABLE_WP_CRON setting. No backups can run (even &quot;Backup Now&quot;) unless either you have set up a facility to call the scheduler manually, or until it is enabled.', 'updraftplus').' <a href="'.apply_filters('updraftplus_com_link', "https://updraftplus.com/faqs/my-scheduled-backups-and-pressing-backup-now-does-nothing-however-pressing-debug-backup-does-produce-a-backup/#disablewpcron/").'">'.__('Go here for more information.', 'updraftplus').'</a>', 'updated updraftplus-disable-wp-cron-warning');
857
  }
858
 
859
  public function show_admin_warning_diskspace() {
860
+ $this->show_admin_warning('<strong>'.__('Warning', 'updraftplus').':</strong> '.sprintf(__('You have less than %s of free disk space on the disk which UpdraftPlus is configured to use to create backups. UpdraftPlus could well run out of space. Contact your the operator of your server (e.g. your web hosting company) to resolve this issue.', 'updraftplus'),'35 MB'));
861
  }
862
 
863
  public function show_admin_warning_wordpressversion() {
864
+ $this->show_admin_warning('<strong>'.__('Warning', 'updraftplus').':</strong> '.sprintf(__('UpdraftPlus does not officially support versions of WordPress before %s. It may work for you, but if it does not, then please be aware that no support is available until you upgrade WordPress.', 'updraftplus'), '3.2'));
865
  }
866
 
867
  public function show_admin_warning_litespeed() {
868
+ $this->show_admin_warning('<strong>'.__('Warning', 'updraftplus').':</strong> '.sprintf(__('Your website is hosted using the %s web server.', 'updraftplus'),'LiteSpeed').' <a href="'.apply_filters('updraftplus_com_link', "https://updraftplus.com/faqs/i-am-having-trouble-backing-up-and-my-web-hosting-company-uses-the-litespeed-webserver/").'">'.__('Please consult this FAQ if you have problems backing up.', 'updraftplus').'</a>');
869
  }
870
 
871
  public function show_admin_debug_warning() {
872
+ $this->show_admin_warning('<strong>'.__('Notice', 'updraftplus').':</strong> '.__('UpdraftPlus\'s debug mode is on. You may see debugging notices on this page not just from UpdraftPlus, but from any other plugin installed. Please try to make sure that the notice you are seeing is from UpdraftPlus before you raise a support request.', 'updraftplus').'</a>');
873
  }
874
 
875
  public function show_admin_warning_overdue_crons($howmany) {
876
  $ret = '<div class="updraftmessage updated"><p>';
877
+ $ret .= '<strong>'.__('Warning', 'updraftplus').':</strong> '.sprintf(__('WordPress has a number (%d) of scheduled tasks which are overdue. Unless this is a development site, this probably means that the scheduler in your WordPress install is not working.', 'updraftplus'), $howmany).' <a href="'.apply_filters('updraftplus_com_link', "https://updraftplus.com/faqs/scheduler-wordpress-installation-working/").'">'.__('Read this page for a guide to possible causes and how to fix it.', 'updraftplus').'</a>';
878
  $ret .= '</p></div>';
879
  return $ret;
880
  }
881
 
882
  //checking remote storage
883
  public function show_admin_warning_dropbox() {
884
+ $this->show_admin_warning('<strong>'.__('UpdraftPlus notice:', 'updraftplus').'</strong> <a class="updraft_authlink" href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&action=updraftmethod-dropbox-auth&updraftplus_dropboxauth=doit">'.sprintf(__('Follow this link to authorize access to your %s account (you will not be able to back up to %s without it).', 'updraftplus'), 'Dropbox', 'Dropbox').'</a>', 'updated updraft_authenticate_dropbox');
885
  }
886
 
887
  public function show_admin_warning_onedrive() {
888
+ $this->show_admin_warning('<strong>'.__('UpdraftPlus notice:', 'updraftplus').'</strong> <a class="updraft_authlink" href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&action=updraftmethod-onedrive-auth&updraftplus_onedriveauth=doit">'.sprintf(__('Follow this link to authorize access to your %s account (you will not be able to back up to %s without it).', 'updraftplus'), 'OneDrive', 'OneDrive').'</a>', 'updated updraft_authenticate_onedrive');
889
  }
890
 
891
  public function show_admin_warning_updraftvault() {
892
+ $this->show_admin_warning('<strong>'.__('UpdraftPlus notice:', 'updraftplus').'</strong> '.sprintf(__('%s has been chosen for remote storage, but you are not currently connected.', 'updraftplus'), 'UpdraftPlus Vault').' '.__('Go to the remote storage settings in order to connect.', 'updraftplus'), 'updated');
893
  }
894
 
895
  public function show_admin_warning_googledrive() {
896
+ $this->show_admin_warning('<strong>'.__('UpdraftPlus notice:', 'updraftplus').'</strong> <a class="updraft_authlink" href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&action=updraftmethod-googledrive-auth&updraftplus_googleauth=doit">'.sprintf(__('Follow this link to authorize access to your %s account (you will not be able to back up to %s without it).', 'updraftplus'), 'Google Drive', 'Google Drive').'</a>', 'updated updraft_authenticate_googledrive');
897
  }
898
 
899
  public function show_admin_warning_googlecloud() {
900
+ $this->show_admin_warning('<strong>'.__('UpdraftPlus notice:', 'updraftplus').'</strong> <a class="updraft_authlink" href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&action=updraftmethod-googlecloud-auth&updraftplus_googleauth=doit">'.sprintf(__('Follow this link to authorize access to your %s account (you will not be able to back up to %s without it).', 'updraftplus'), 'Google Cloud', 'Google Cloud').'</a>', 'updated updraft_authenticate_googlecloud');
901
  }
902
 
903
  // This options filter removes ABSPATH off the front of updraft_dir, if it is given absolutely and contained within it
1112
 
1113
  }
1114
 
1115
+ // This is used as a callback
1116
+ public function _updraftplus_background_operation_started($msg) {
1117
+ global $updraftplus;
1118
+ $updraftplus->close_browser_connection(json_encode($msg));
1119
+ }
1120
+
1121
  public function updraft_ajax_handler() {
1122
 
1123
  global $updraftplus;
1124
 
1125
+ $nonce = empty($_REQUEST['nonce']) ? '' : $_REQUEST['nonce'];
1126
 
1127
  if (!wp_verify_nonce($nonce, 'updraftplus-credentialtest-nonce') || empty($_REQUEST['subaction'])) die('Security check');
1128
 
1129
  // Mitigation in case the nonce leaked to an unauthorised user
1130
+ if ('dismissautobackup' == $_REQUEST['subaction']) {
1131
  if (!current_user_can('update_plugins') && !current_user_can('update_themes')) return;
1132
+ } elseif ('dismissexpiry' == $_REQUEST['subaction'] || 'dismissdashnotice' == $_REQUEST['subaction']) {
1133
  if (!current_user_can('update_plugins')) return;
1134
  } else {
1135
  if (!UpdraftPlus_Options::user_can_manage()) return;
1136
  }
 
 
 
 
 
1137
 
1138
+ $subaction = $_REQUEST['subaction'];
1139
 
1140
+ // All others use _POST
1141
+ $data_in_get = array('get_log', 'get_fragment');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1142
 
1143
+ // UpdraftPlus_WPAdmin_Commands extends UpdraftPlus_Commands - i.e. all commands are in there
1144
+ if (!class_exists('UpdraftPlus_WPAdmin_Commands')) require_once(UPDRAFTPLUS_DIR.'/includes/class-wpadmin-commands.php');
1145
+ $commands = new UpdraftPlus_WPAdmin_Commands($this);
1146
+
1147
+ if (method_exists($commands, $subaction)) {
1148
 
1149
+ $data = in_array($subaction, $data_in_get) ? $_GET : $_POST;
1150
+ // TODO: Once all commands come through here and through updraft_send_command(), the data should always come from this attribute (once updraft_send_command() is modified appropriately).
1151
+ if (isset($data['action_data'])) $data = $data['action_data'];
1152
+ $results = call_user_func(array($commands, $subaction), $data);
 
 
 
 
1153
 
1154
+ if (is_wp_error($results)) {
1155
+ $results = array(
1156
+ 'result' => false,
1157
+ 'error_code' => $results->get_error_code(),
1158
+ 'error_message' => $results->get_error_message(),
1159
+ 'error_data' => $results->get_error_data(),
1160
+ );
1161
  }
1162
 
1163
+ if (is_string($results)) {
1164
+ // A handful of legacy methods, and some which are directly the source for iframes, for which JSON is not appropriate.
1165
+ echo $results;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1166
  } else {
1167
+ echo json_encode($results);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1168
  }
1169
+ die;
 
 
 
 
 
 
1170
 
1171
+ }
1172
+
1173
+ // Below are all the commands not ported over into class-commands.php or class-wpadmin-commands.php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1174
 
1175
+ if ('activejobs_list' == $subaction) {
1176
 
1177
+ // N.B. Also called from autobackup.php
1178
+ // TODO: This should go into UpdraftPlus_Commands, once the add-ons have been ported to use updraft_send_command()
1179
+ echo json_encode($this->get_activejobs_list($_GET));
1180
 
1181
+ } elseif ('httpget' == $_REQUEST['subaction']) {
1182
+
1183
+ // httpget
1184
+ $curl = empty($_REQUEST['curl']) ? false : true;
1185
+ echo $this->http_get($_REQUEST['uri'], $curl);
1186
+
1187
+ } elseif ('doaction' == $_REQUEST['subaction'] && !empty($_REQUEST['subsubaction']) && 'updraft_' == substr($_REQUEST['subsubaction'], 0, 8)) {
1188
+
1189
+ // These generally echo and die - they will need further work to port to one of the command classes. Some may already have equivalents in UpdraftPlus_Commands, if they are used from UpdraftCentral.
1190
+ do_action($_REQUEST['subsubaction']);
1191
+ } else {
1192
+ // These can be removed after a couple of releases
1193
+ include(UPDRAFTPLUS_DIR.'/includes/deprecated-actions.php');
1194
  }
1195
+
1196
  die;
1197
 
1198
  }
1225
  restore_error_handler();
1226
  }
1227
 
1228
+ // Relevant options (array keys): backup_timestamp, delete_remote, [remote_delete_limit]
1229
  public function delete_set($opts) {
1230
 
1231
  global $updraftplus;
1563
 
1564
  $msg = array(
1565
  'nonce' => $nonce,
1566
+ 'm' => '<strong>'.__('Start backup', 'updraftplus').':</strong> '.htmlspecialchars(__('OK. You should soon see activity in the "Last log message" field below.', 'updraftplus'))
1567
  );
1568
 
1569
  if ($close_connection_callable && is_callable($close_connection_callable)) {
1575
  $options = array('nocloud' => $backupnow_nocloud, 'use_nonce' => $nonce);
1576
  if (!empty($request['onlythisfileentity']) && is_string($request['onlythisfileentity'])) {
1577
  // Something to see in the 'last log' field when it first appears, before the backup actually starts
1578
+ $updraftplus->log(__('Start backup', 'updraftplus'));
1579
  $options['restrict_files_to_override'] = explode(',', $request['onlythisfileentity']);
1580
  }
1581
 
1586
  do_action($event, apply_filters('updraft_backupnow_options', $options, $request));
1587
  }
1588
 
1589
+ public function fetch_log($backup_nonce, $log_pointer = 0) {
1590
  global $updraftplus;
1591
+
1592
  if (empty($backup_nonce)) {
1593
  list($mod_time, $log_file, $nonce) = $updraftplus->last_modified_log();
1594
  } else {
1622
  $log_content = implode("", $templog_array);
1623
 
1624
  } else {
1625
+ $log_content .= __('The log file could not be read.', 'updraftplus');
1626
  }
1627
 
1628
  } else {
1629
+ $log_content .= __('The log file could not be read.', 'updraftplus');
1630
  }
1631
 
1632
  $ret_array = array(
1633
+ 'log' => $log_content,
1634
  'nonce' => $nonce,
1635
  'pointer' => $new_pointer
1636
  );
1688
  $response['s'] = (int)$matches[1];
1689
  $response['t'] = (int)$matches[1];
1690
  $response['m'] = __('File ready.', 'updraftplus');
1691
+ // TODO: Code to allow them to browse the contents
1692
+ $response['can_show_contents'] = false;
1693
  } elseif (preg_match('/^downloading:(\d+):(.*)$/', $file, $matches) && file_exists($matches[2])) {
1694
  // Convert to bytes
1695
  $response['f'] = $matches[2];
1821
  $response['dm'] = sprintf(__('This backup was created by %s, and can be imported.', 'updraftplus'), $accepted);
1822
  } else {
1823
  @unlink($status['file']);
1824
+ echo json_encode(array('e' => sprintf(__('Error: %s', 'updraftplus'),__('Bad filename format - this does not look like a file created by UpdraftPlus', 'updraftplus'))));
1825
  exit;
1826
  }
1827
  } else {
1829
  $type = isset($matches[3]) ? $matches[3] : '';
1830
  if (!preg_match('/^log\.[a-f0-9]{12}\.txt/', $file) && 'db' != $type && !isset($backupable_entities[$type])) {
1831
  @unlink($status['file']);
1832
+ echo json_encode(array('e' => sprintf(__('Error: %s', 'updraftplus'),sprintf(__('This looks like a file created by UpdraftPlus, but this install does not know about this type of object: %s. Perhaps you need to install an add-on?', 'updraftplus'), htmlspecialchars($type)))));
1833
  exit;
1834
  }
1835
  }
1911
  if (!preg_match('/^backup_([\-0-9]{15})_.*_([0-9a-f]{12})-db([0-9]+)?\.(gz\.crypt)$/i', $file)) {
1912
 
1913
  @unlink($status['file']);
1914
+ echo 'ERROR:'.__('Bad filename format - this does not look like an encrypted database file created by UpdraftPlus', 'updraftplus');
1915
 
1916
  exit;
1917
  }
1992
  }
1993
  $pval = ($updraftplus->have_addons) ? 1 : 0;
1994
 
1995
+ echo '<strong>'.__('Actions', 'updraftplus').':</strong> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&updraft_restore_success='.$s_val.'&pval='.$pval.'">'.__('Return to UpdraftPlus Configuration', 'updraftplus').'</a>';
1996
  return;
1997
  } elseif (is_wp_error($backup_success)) {
1998
  echo '<p>';
2001
  $updraftplus->log_wp_error($backup_success);
2002
  $updraftplus->log("Restore failed");
2003
  $updraftplus->list_errors();
2004
+ echo '<strong>'.__('Actions', 'updraftplus').':</strong> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus">'.__('Return to UpdraftPlus Configuration', 'updraftplus').'</a>';
2005
  return;
2006
  } elseif (false === $backup_success) {
2007
  # This means, "not yet - but stay on the page because we may be able to do it later, e.g. if the user types in the requested information"
2010
  echo '</p>';
2011
  $updraftplus->log("Restore failed");
2012
  $updraftplus->list_errors();
2013
+ echo '<strong>'.__('Actions', 'updraftplus').':</strong> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus">'.__('Return to UpdraftPlus Configuration', 'updraftplus').'</a>';
2014
  return;
2015
  }
2016
  }
2052
  } elseif ($created !== false) {
2053
  echo '<p>'.__('Backup directory successfully created.', 'updraftplus').'</p><br>';
2054
  }
2055
+ echo '<b>'.__('Actions', 'updraftplus').':</b> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus">'.__('Return to UpdraftPlus Configuration', 'updraftplus').'</a>';
2056
  return;
2057
  }
2058
 
2059
  echo '<div id="updraft_backup_started" class="updated updraft-hidden" style="display:none;"></div>';
2060
 
2061
  if (isset($_POST['action']) && 'updraft_wipesettings' == $_POST['action']) {
2062
+ $this->updraft_wipe_settings();
 
 
 
 
 
 
 
 
 
 
2063
  }
2064
 
2065
  // This opens a div
2088
  if (get_template() === 'optimizePressTheme' || is_plugin_active('optimizePressPlugin') || is_plugin_active_for_network('optimizePressPlugin')){
2089
  $this->show_admin_warning("<a href='https://optimizepress.zendesk.com/hc/en-us/articles/203699826-Update-URL-References-after-moving-domain' target='_blank'>" . __("OptimizePress 2.0 encodes its contents, so search/replace does not work.","updraftplus") . ' ' . __("To fix this problem go here.","updraftplus") . "</a>", "notice notice-warning");
2090
  }
2091
+ $success_advert = (isset($_GET['pval']) && 0 == $_GET['pval'] && !$updraftplus->have_addons) ? '<p>'.__('For even more features and personal support, check out ', 'updraftplus').'<strong><a href="'.apply_filters("updraftplus_com_link",'https://updraftplus.com/shop/updraftplus-premium/').'" target="_blank">UpdraftPlus Premium</a>.</strong></p>' : "";
2092
 
2093
+ echo "<div class=\"updated backup-restored\"><span><strong>".__('Your backup has been restored.', 'updraftplus').'</strong></span><br>';
2094
  // Unnecessary - will be advised of this below
2095
  // if (2 == $_GET['updraft_restore_success']) echo ' '.__('Your old (themes, uploads, plugins, whatever) directories have been retained with "-old" appended to their name. Remove them when you are satisfied that the backup worked properly.');
2096
  echo $success_advert;
2172
  </div>
2173
 
2174
  <div id="updraft-navtab-settings-content" <?php if (3 != $tabflag) echo 'class="updraft-hidden"'; ?> style="<?php if (3 != $tabflag) echo 'display:none;'; ?>">
2175
+ <h2 class="updraft_settings_sectionheading"><?php _e('Backup Contents And Schedule', 'updraftplus');?></h2>
2176
  <?php UpdraftPlus_Options::options_form_begin(); ?>
2177
  <?php $this->settings_formcontents(); ?>
2178
  </form>
2244
 
2245
  $ret = $this->backup_now_widgetry();
2246
 
2247
+ // $ret .= '<p>'.__('Does nothing happen when you attempt backups?', 'updraftplus').' <a href="https://updraftplus.com/faqs/my-scheduled-backups-and-pressing-backup-now-does-nothing-however-pressing-debug-backup-does-produce-a-backup/">'.__('Go here for help.', 'updraftplus').'</a></p>';
2248
 
2249
  return $ret;
2250
  }
2293
  <?php if ($wide_format) {
2294
  // Hide for now - too ugly
2295
  ?>
2296
+ <td colspan="2" class="last-message"><strong><?php _e('Last log message', 'updraftplus');?>:</strong><br>
2297
+ <span id="updraft_lastlogcontainer"><?php echo htmlspecialchars(UpdraftPlus_Options::get_updraft_option('updraft_lastmessage', __('(Nothing yet logged)', 'updraftplus'))); ?></span><br>
2298
  <?php $this->most_recently_modified_log_link(); ?>
2299
  </td>
2300
  <?php } else { ?>
2301
+ <th><?php _e('Last log message', 'updraftplus');?>:</th>
2302
  <td>
2303
+ <span id="updraft_lastlogcontainer"><?php echo htmlspecialchars(UpdraftPlus_Options::get_updraft_option('updraft_lastmessage', __('(Nothing yet logged)', 'updraftplus'))); ?></span><br>
2304
  <?php $this->most_recently_modified_log_link(); ?>
2305
  </td>
2306
  <?php } ?>
2356
  if ($include_div) {
2357
  echo '<div id="updraft_delete_old_dirs_pagediv" class="updated delete-old-directories">';
2358
  }
2359
+ echo '<p>'.__('Your WordPress install has old directories from its state before you restored/migrated (technical information: these are suffixed with -old). You should press this button to delete them as soon as you have verified that the restoration worked.', 'updraftplus').'</p>';
2360
  }
2361
  ?>
2362
+ <form method="post" action="<?php echo esc_url(add_query_arg(array('error' => false, 'updraft_restore_success' => false, 'action' => false, 'page' => 'updraftplus'))); ?>">
2363
  <?php wp_nonce_field('updraftplus-credentialtest-nonce'); ?>
2364
  <input type="hidden" name="action" value="updraft_delete_old_dirs">
2365
+ <input type="submit" class="button-primary" value="<?php echo esc_attr(__('Delete Old Directories', 'updraftplus'));?>">
2366
  </form>
2367
  <?php
2368
  if ($include_blurb && $include_div) echo '</div>';
2369
  }
2370
 
2371
+ public function get_cron($job_id = false) {
2372
 
2373
  $cron = get_option('cron');
2374
  if (!is_array($cron)) $cron = array();
2602
  echo ($show_return) ? '<h1>UpdraftPlus - '.__('Remove old directories', 'updraftplus').'</h1>' : '<h2>'.__('Remove old directories', 'updraftplus').'</h2>';
2603
 
2604
  if ($this->delete_old_dirs()) {
2605
+ echo '<p>'.__('Old directories successfully removed.', 'updraftplus').'</p><br>';
2606
  } else {
2607
+ echo '<p>',__('Old directory removal failed for some reason. You may want to do this manually.', 'updraftplus').'</p><br>';
2608
  }
2609
+ if ($show_return) echo '<b>'.__('Actions', 'updraftplus').':</b> <a href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus">'.__('Return to UpdraftPlus Configuration', 'updraftplus').'</a>';
2610
  }
2611
 
2612
  //deletes the -old directories that are created when a backup is restored.
2632
  // $ret2 = $this->delete_old_dirs_dir($wp_filesystem->abspath());
2633
  $plugs = untrailingslashit($wp_filesystem->wp_plugins_dir());
2634
  if ($wp_filesystem->is_dir($plugs.'-old')) {
2635
+ print "<strong>".__('Delete', 'updraftplus').": </strong>plugins-old: ";
2636
  if (!$wp_filesystem->delete($plugs.'-old', true)) {
2637
  $ret3 = false;
2638
  print "<strong>".__('Failed', 'updraftplus')."</strong><br>";
2665
  $name = (is_array($item)) ? $item['name'] : $item;
2666
  if ("-old" == substr($name, -4, 4)) {
2667
  //recursively delete
2668
+ print "<strong>".__('Delete', 'updraftplus').": </strong>".htmlspecialchars($name).": ";
2669
 
2670
  if ($wpfs) {
2671
  if (!$wp_filesystem->delete($dir.$name, true)) {
2772
  <?php
2773
  }
2774
 
2775
+ public function last_backup_html() {
2776
 
2777
  global $updraftplus;
2778
 
2817
  $updraft_dir = $updraftplus->backups_dir_location();
2818
 
2819
  $potential_log_file = $updraft_dir."/log.".$updraft_last_backup['backup_nonce'].".txt";
2820
+ if (is_readable($potential_log_file)) $last_backup_text .= "<a href=\"?page=updraftplus&action=downloadlog&updraftplus_backup_nonce=".$updraft_last_backup['backup_nonce']."\" class=\"updraft-log-link\" onclick=\"event.preventDefault(); updraft_popuplog('".$updraft_last_backup['backup_nonce']."');\">".__('Download log file', 'updraftplus')."</a>";
2821
  }
2822
 
2823
  } else {
2824
+ $last_backup_text = "<span style=\"color:blue;\">".__('No backup has been completed', 'updraftplus')."</span>";
2825
  }
2826
 
2827
  return $last_backup_text;
2843
 
2844
  public function really_writable_message($really_is_writable, $updraft_dir){
2845
  if ($really_is_writable) {
2846
+ $dir_info = '<span style="color:green;">'.__('Backup directory specified is writable, which is good.', 'updraftplus').'</span>';
2847
  } else {
2848
  $dir_info = '<span style="color:red;">';
2849
  if (!is_dir($updraft_dir)) {
2850
+ $dir_info .= __('Backup directory specified does <b>not</b> exist.', 'updraftplus');
2851
  } else {
2852
+ $dir_info .= __('Backup directory specified exists, but is <b>not</b> writable.', 'updraftplus');
2853
  }
2854
+ $dir_info .= '<span class="updraft-directory-not-writable-blurb"><span class="directory-permissions"><a class="updraft_create_backup_dir" href="'.UpdraftPlus_Options::admin_page_url().'?page=updraftplus&action=updraft_create_backup_dir&nonce='.wp_create_nonce('create_backup_dir').'">'.__('Follow this link to attempt to create the directory and set the permissions', 'updraftplus').'</a></span>, '.__('or, to reset this option', 'updraftplus').' <a href="#" class="updraft_backup_dir_reset">'.__('click here', 'updraftplus').'</a>. '.__('If that is unsuccessful check the permissions on your server or change it to another directory that is writable by your web server process.', 'updraftplus').'</span>';
2855
  }
2856
  return $dir_info;
2857
  }
2968
  // Check requirements
2969
  if (!function_exists("curl_init") || !function_exists('curl_exec')) {
2970
 
2971
+ $ret .= $this->show_double_warning('<strong>'.__('Warning', 'updraftplus').':</strong> '.sprintf(__("Your web server's PHP installation does not included a <strong>required</strong> (for %s) module (%s). Please contact your web hosting provider's support and ask for them to enable it.", 'updraftplus'), $service, 'Curl').' ', $extraclass, false);
2972
 
2973
  } else {
2974
  $curl_version = curl_version();
2975
  $curl_ssl_supported= ($curl_version['features'] & CURL_VERSION_SSL);
2976
  if (!$curl_ssl_supported) {
2977
  if ($has_fallback) {
2978
+ $ret .= '<p><strong>'.__('Warning', 'updraftplus').':</strong> '.sprintf(__("Your web server's PHP/Curl installation does not support https access. Communications with %s will be unencrypted. ask your web host to install Curl/SSL in order to gain the ability for encryption (via an add-on).",'updraftplus'),$service).'</p>';
2979
  } else {
2980
+ $ret .= $this->show_double_warning('<p><strong>'.__('Warning', 'updraftplus').':</strong> '.sprintf(__("Your web server's PHP/Curl installation does not support https access. We cannot access %s without this support. Please contact your web hosting provider's support. %s <strong>requires</strong> Curl+https. Please do not file any support requests; there is no alternative.",'updraftplus'),$service).'</p>', $extraclass, false);
2981
  }
2982
  } else {
2983
  $ret .= '<p><em>'.sprintf(__("Good news: Your site's communications with %s can be encrypted. If you see any errors to do with encryption, then look in the 'Expert Settings' for more help.", 'updraftplus'),$service).'</em></p>';
3146
  global $updraftplus;
3147
 
3148
  if (false === $backup_history) $backup_history = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
3149
+
3150
+ if (!is_array($backup_history) || empty($backup_history)) return "<p><em>".__('You have not yet made any backups.', 'updraftplus')."</em></p>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3151
 
3152
+ $pass_values = array(
3153
+ 'backup_history' => $backup_history,
3154
+ 'updraft_dir' => $updraftplus->backups_dir_location(),
3155
+ 'backupable_entities' => $updraftplus->get_backupable_file_entities(true, true)
3156
+ );
3157
+
3158
+ return $this->include_template('wp-admin/settings/existing-backups-table.php', true, $pass_values);
3159
+
3160
  }
3161
 
3162
  private function download_db_button($bkey, $key, $esc_pretty_date, $backup, $accept = array()) {
3170
  $ret = '';
3171
 
3172
  if ('db' == $bkey) {
3173
+ $dbt = empty($backup['meta_foreign']) ? esc_attr(__('Database', 'updraftplus')) : esc_attr(sprintf(__('Database (created by %s)', 'updraftplus'), $desc_source));
3174
  } else {
3175
+ $dbt = __('External database', 'updraftplus').' ('.substr($bkey, 2).')';
3176
  }
3177
 
3178
  $ret .= $this->download_button($bkey, $key, 0, null, '', $dbt, $esc_pretty_date, '0');
3181
  }
3182
 
3183
  // Go through each of the file entities
3184
+ public function download_buttons($backup, $key, $accept, &$entities, $esc_pretty_date) {
3185
  global $updraftplus;
3186
  $ret = '';
3187
  $backupable_entities = $updraftplus->get_backupable_file_entities(true, true);
3188
 
 
 
 
 
 
 
 
3189
  $first_entity = true;
3190
 
3191
  foreach ($backupable_entities as $type => $info) {
3192
  if (!empty($backup['meta_foreign']) && 'wpcore' != $type) continue;
3193
+
 
 
 
 
 
3194
  $ide = '';
3195
  if ('wpcore' == $type) $wpcore_restore_descrip = $info['description'];
3196
  if (empty($backup['meta_foreign'])) {
3258
  $printing_first = false;
3259
  }
3260
  }
 
 
3261
  }
 
3262
  }
 
3263
  return $ret;
3264
  }
3265
 
3276
  return $ret;
3277
  }
3278
 
3279
+ public function download_button($type, $backup_timestamp, $findex, $info, $title, $pdescrip, $esc_pretty_date, $set_contents) {
3280
 
3281
  $ret = '';
3282
 
3289
  return $ret;
3290
  }
3291
 
3292
+ public function restore_button($backup, $key, $pretty_date, $entities = '') {
3293
  $ret = '<div class="restore-button">';
3294
 
3295
  if ($entities) {
3298
  $show_data .= ' '.__('(backup set imported from remote location)', 'updraftplus');
3299
  }
3300
 
3301
+ $ret .= '<button data-showdata="'.esc_attr($show_data).'" data-backup_timestamp="'.$key.'" data-entities="'.esc_attr($entities).'" title="'.__('After pressing this button, you will be given the option to choose which components you wish to restore', 'updraftplus').'" type="button" style="float:left; clear:none;" class="button-primary choose-components-button">'.__('Restore', 'updraftplus').'</button>';
3302
  }
3303
  $ret .= "</div>\n";
3304
  return $ret;
3305
  }
3306
 
3307
+ public function delete_button($key, $nonce, $backup) {
3308
  $sval = ((isset($backup['service']) && $backup['service'] != 'email' && $backup['service'] != 'none')) ? '1' : '0';
3309
  return '<div class="updraftplus-remove" style="float: left; clear: none;" data-hasremote="'.$sval.'">
3310
  <a data-hasremote="'.$sval.'" data-nonce="'.$nonce.'" data-key="'.$key.'" class="no-decoration updraft-delete-link" href="#" title="'.esc_attr(__('Delete this backup set', 'updraftplus')).'">'.__('Delete', 'updraftplus').'</a>
3311
  </div>';
3312
  }
3313
 
3314
+ public function log_button($backup) {
3315
  global $updraftplus;
3316
  $updraft_dir = $updraftplus->backups_dir_location();
3317
  $ret = '';
3318
  if (isset($backup['nonce']) && preg_match("/^[0-9a-f]{12}$/",$backup['nonce']) && is_readable($updraft_dir.'/log.'.$backup['nonce'].'.txt')) {
3319
  $nval = $backup['nonce'];
3320
+ // $lt = esc_attr(__('View Log', 'updraftplus'));
3321
  $lt = __('View Log', 'updraftplus');
3322
  $url = esc_attr(UpdraftPlus_Options::admin_page()."?page=updraftplus&action=downloadlog&amp;updraftplus_backup_nonce=$nval");
3323
  $ret .= <<<ENDHERE
3349
  global $wp_filesystem, $updraftplus;
3350
  $backup_history = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
3351
  if (!isset($backup_history[$timestamp]) || !is_array($backup_history[$timestamp])) {
3352
+ echo '<p>'.__('This backup does not exist in the backup history - restoration aborted. Timestamp:', 'updraftplus')." $timestamp</p><br>";
3353
  return new WP_Error('does_not_exist', __('Backup does not exist in the backup history', 'updraftplus'));
3354
  }
3355
 
3444
 
3445
  if (0 == count($_POST['updraft_restore'])) {
3446
  echo '<p>'.__('ABORT: Could not find the information on which entities to restore.', 'updraftplus').'</p>';
3447
+ echo '<p>'.__('If making a request for support, please include this information:', 'updraftplus').' '.count($_POST).' : '.htmlspecialchars(serialize($_POST)).'</p>';
3448
  return new WP_Error('missing_info', 'Backup information not found');
3449
  }
3450
 
3563
  $print_message = __("Archive is expected to be size:",'updraftplus')." ".round($fs/1024, 1)." KB: ";
3564
  $as = @filesize($fullpath);
3565
  if ($as == $fs) {
3566
+ $updraftplus->log($print_message.__('OK', 'updraftplus'), 'notice-restore');
3567
  } else {
3568
+ $updraftplus->log($print_message.__('Error:', 'updraftplus')." ".__('file is size:', 'updraftplus')." ".round($as/1024)." ($fs, $as)", 'warning-restore');
3569
  }
3570
  } else {
3571
  $updraftplus->log(__("The backup records do not contain information about the proper size of this file.",'updraftplus'), 'notice-restore');
3649
  # Types: uploads, themes, plugins, others, db
3650
  $info = (isset($backupable_entities[$type])) ? $backupable_entities[$type] : array();
3651
 
3652
+ echo ('db' == $type) ? "<h2>".__('Database', 'updraftplus')."</h2>" : "<h2>".$info['description']."</h2>";
3653
  $updraftplus->log("Entity: ".$type);
3654
 
3655
  if (is_string($files)) $files = array($files);
3819
  return '<input type="checkbox" id="backupnow_includecloud" checked="checked"> <label for="backupnow_includecloud">'.__("Send this backup to remote storage", 'updraftplus').'</label>';
3820
  }
3821
  }
3822
+
3823
+ /**
3824
+ * This method works through the passed in settings array and saves the settings to the database clearing old data and setting up a return array with content to update the page via ajax
3825
+ * @param [Array] $settings - an array of settings taking from the admin page ready to be saved to the database
3826
+ * @return [Array] - an array response containing the status of the update along with content to be used to update the admin page.
3827
+ */
3828
  public function save_settings($settings) {
3829
 
3830
  global $updraftplus;
3847
  $_POST[$key] = $settings[$key];
3848
  }
3849
  }
3850
+
3851
+ // Check if updraft_include_more_path is set, if it is then we need to update the page, if it's not set but there's content already in the database that is cleared down below so again we should update the page.
3852
+ $more_files_path_updated = false;
3853
+
3854
+ // i.e. If an option has been set, or if it was currently active in the settings
3855
+ if (isset($settings['updraft_include_more_path']) || UpdraftPlus_Options::get_updraft_option('updraft_include_more_path')) {
3856
+ $more_files_path_updated = true;
3857
+ }
3858
 
3859
  // Wipe the extra retention rules, as they are not saved correctly if the last one is deleted
3860
  UpdraftPlus_Options::update_updraft_option('updraft_retain_extrarules', array());
3871
  $settings = UpdraftPlus_Options::mass_options_update($settings);
3872
  $mass_updated = true;
3873
  }
3874
+
3875
  foreach ($settings as $key => $value) {
3876
  // $exclude_keys = array('option_page', 'action', '_wpnonce', '_wp_http_referer');
3877
 
3894
  $value = UpdraftPlus_Options::get_updraft_option($key);
3895
  if (is_string($value)) $return_array['changed'][$key] = $value;
3896
  }
3897
+
3898
  } else {
3899
  // When last active, it was catching: option_page, action, _wpnonce, _wp_http_referer, updraft_s3_endpoint, updraft_dreamobjects_endpoint. The latter two are empty; probably don't need to be in the page at all.
3900
  //error_log("Non-UD key when saving from POSTed data: ".$key);
3910
  $return_array['backup_now_message'] = $this->backup_now_remote_message();
3911
 
3912
  $return_array['backup_dir'] = array('writable' => $really_is_writable, 'message' => $dir_info, 'button_title' => $button_title);
3913
+
3914
+ // Check if $more_files_path_updated is true, is so then there's a change and we should update the backup modal
3915
+ if ($more_files_path_updated) {
3916
+ $return_array['updraft_include_more_path'] = $this->files_selector_widgetry('backupnow_files_', false, 'sometimes');
3917
+ }
3918
 
3919
  //Because of the single AJAX call, we need to remove the existing UD messages from the 'all_admin_notices' action
3920
  remove_all_actions('all_admin_notices');
3955
  return $return_array;
3956
 
3957
  }
3958
+
3959
+ /**
3960
+ * A method to remove UpdraftPlus settings from the options table.
3961
+ * @param boolean $wipe_all_settings Set to true as default as we want to remove all options, set to false if calling from UpdraftCentral, as we do not want to remove the UpdraftCentral key or we will lose connection to the site.
3962
+ */
3963
+ public function updraft_wipe_settings($wipe_all_settings = true) {
3964
+
3965
+ global $updraftplus;
3966
+
3967
+ $settings = $updraftplus->get_settings_keys();
3968
+
3969
+ // if this is false the UDC has called it we don't want to remove the UDC key other wise we will lose connection to the remote site.
3970
+ if (false == $wipe_all_settings) {
3971
+ $key = array_search('updraft_central_localkeys', $settings);
3972
+ unset($settings[$key]);
3973
+ }
3974
+
3975
+ foreach ($settings as $s) UpdraftPlus_Options::delete_updraft_option($s);
3976
+
3977
+ // These aren't in get_settings_keys() because they are always in the options table, regardless of context
3978
+ global $wpdb;
3979
+ $wpdb->query("DELETE FROM $wpdb->options WHERE ( option_name LIKE 'updraftplus_unlocked_%' OR option_name LIKE 'updraftplus_locked_%' OR option_name LIKE 'updraftplus_last_lock_time_%' OR option_name LIKE 'updraftplus_semaphore_%' OR option_name LIKE 'updraft_jobdata_%' OR option_name LIKE 'updraft_last_scheduled_%' )");
3980
+
3981
+ $site_options = array('updraft_oneshotnonce');
3982
+ foreach ($site_options as $s) delete_site_option($s);
3983
+
3984
+ $this->show_admin_warning(__("Your settings have been wiped.", 'updraftplus'));
3985
+
3986
+ return true;
3987
+ }
3988
 
3989
  //this get the details for updraft vault and to be used globally
3990
+ public function get_updraftvault() {
3991
  require_once(UPDRAFTPLUS_DIR.'/methods/updraftvault.php');
3992
  $vault = new UpdraftPlus_BackupModule_updraftvault();
3993
  return $vault;
3994
  }
3995
 
3996
+ // http_get will allow the HTTP Fetch execute available in advanced tools
3997
+ public function http_get($uri = null, $curl = false) {
3998
 
3999
+ if ($curl) {
4000
  if (!function_exists('curl_exec')) {
4001
  return json_encode(array('e' => 'No Curl installed'));
4002
  die;
4047
  }
4048
  }
4049
 
 
4050
  //This will bring back all the details for raw backup and file list
4051
  public function show_raw_backups($no_pre_tags = false){
4052
  global $updraftplus;
4053
 
4054
  $response = array();
4055
 
4056
+ $response['html'] = '<h3 id="ud-debuginfo-rawbackups">'.__('Known backups (raw)', 'updraftplus').'</h3><pre>';
4057
  ob_start();
4058
  var_dump($updraftplus->get_backup_history());
4059
  $response["html"] .= ob_get_clean();
4086
  $response['html'] .= '<h3 id="ud-debuginfo-options">'.__('Options (raw)', 'updraftplus').'</h3>';
4087
  $opts = $updraftplus->get_settings_keys();
4088
  asort($opts);
4089
+ // <tr><th>'.__('Key', 'updraftplus').'</th><th>'.__('Value', 'updraftplus').'</th></tr>
4090