Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp...
File: admin.php
</tr>';
[4000] Fix | Delete
}
[4001] Fix | Delete
[4002] Fix | Delete
/**
[4003] Fix | Delete
* Get HTML suitable for the admin area for the status of the last backup
[4004] Fix | Delete
*
[4005] Fix | Delete
* @return String
[4006] Fix | Delete
*/
[4007] Fix | Delete
public function last_backup_html() {
[4008] Fix | Delete
[4009] Fix | Delete
global $updraftplus;
[4010] Fix | Delete
[4011] Fix | Delete
$updraft_last_backup = UpdraftPlus_Options::get_updraft_option('updraft_last_backup');
[4012] Fix | Delete
[4013] Fix | Delete
if ($updraft_last_backup) {
[4014] Fix | Delete
[4015] Fix | Delete
// Convert to GMT, then to blog time
[4016] Fix | Delete
$backup_time = (int) $updraft_last_backup['backup_time'];
[4017] Fix | Delete
[4018] Fix | Delete
$print_time = get_date_from_gmt(gmdate('Y-m-d H:i:s', $backup_time), 'D, F j, Y H:i');
[4019] Fix | Delete
[4020] Fix | Delete
if (empty($updraft_last_backup['backup_time_incremental'])) {
[4021] Fix | Delete
$last_backup_text = "<span style=\"color:".(($updraft_last_backup['success']) ? 'green' : 'black').";\">".$print_time.'</span>';
[4022] Fix | Delete
} else {
[4023] Fix | Delete
$inc_time = get_date_from_gmt(gmdate('Y-m-d H:i:s', $updraft_last_backup['backup_time_incremental']), 'D, F j, Y H:i');
[4024] Fix | Delete
$last_backup_text = "<span style=\"color:".(($updraft_last_backup['success']) ? 'green' : 'black').";\">$inc_time</span> (".sprintf(__('incremental backup; base backup: %s', 'updraftplus'), $print_time).')';
[4025] Fix | Delete
}
[4026] Fix | Delete
[4027] Fix | Delete
$last_backup_text .= '<br>';
[4028] Fix | Delete
[4029] Fix | Delete
// Show errors + warnings
[4030] Fix | Delete
if (is_array($updraft_last_backup['errors'])) {
[4031] Fix | Delete
foreach ($updraft_last_backup['errors'] as $err) {
[4032] Fix | Delete
$level = (is_array($err)) ? $err['level'] : 'error';
[4033] Fix | Delete
$message = (is_array($err)) ? $err['message'] : $err;
[4034] Fix | Delete
$last_backup_text .= ('warning' == $level) ? "<span style=\"color:orange;\">" : "<span style=\"color:red;\">";
[4035] Fix | Delete
if ('warning' == $level) {
[4036] Fix | Delete
$message = sprintf(__("Warning: %s", 'updraftplus'), make_clickable(htmlspecialchars($message)));
[4037] Fix | Delete
} else {
[4038] Fix | Delete
$message = htmlspecialchars($message);
[4039] Fix | Delete
}
[4040] Fix | Delete
$last_backup_text .= $message;
[4041] Fix | Delete
$last_backup_text .= '</span><br>';
[4042] Fix | Delete
}
[4043] Fix | Delete
}
[4044] Fix | Delete
[4045] Fix | Delete
// Link log
[4046] Fix | Delete
if (!empty($updraft_last_backup['backup_nonce'])) {
[4047] Fix | Delete
$updraft_dir = $updraftplus->backups_dir_location();
[4048] Fix | Delete
[4049] Fix | Delete
$potential_log_file = $updraft_dir."/log.".$updraft_last_backup['backup_nonce'].".txt";
[4050] Fix | Delete
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>";
[4051] Fix | Delete
}
[4052] Fix | Delete
[4053] Fix | Delete
} else {
[4054] Fix | Delete
$last_backup_text = "<span style=\"color:blue;\">".__('No backup has been completed', 'updraftplus')."</span>";
[4055] Fix | Delete
}
[4056] Fix | Delete
[4057] Fix | Delete
return $last_backup_text;
[4058] Fix | Delete
[4059] Fix | Delete
}
[4060] Fix | Delete
[4061] Fix | Delete
/**
[4062] Fix | Delete
* Get a list of backup intervals
[4063] Fix | Delete
*
[4064] Fix | Delete
* @param String $what_for - 'files' or 'db'
[4065] Fix | Delete
*
[4066] Fix | Delete
* @return Array - keys are used as identifiers in the UI drop-down; values are user-displayed text describing the interval
[4067] Fix | Delete
*/
[4068] Fix | Delete
public function get_intervals($what_for = 'db') {
[4069] Fix | Delete
global $updraftplus;
[4070] Fix | Delete
[4071] Fix | Delete
if ($updraftplus->is_restricted_hosting('only_one_backup_per_month')) {
[4072] Fix | Delete
$intervals = array(
[4073] Fix | Delete
'manual' => _x('Manual', 'i.e. Non-automatic', 'updraftplus'),
[4074] Fix | Delete
'monthly' => __('Monthly', 'updraftplus')
[4075] Fix | Delete
);
[4076] Fix | Delete
} else {
[4077] Fix | Delete
$intervals = array(
[4078] Fix | Delete
'manual' => _x('Manual', 'i.e. Non-automatic', 'updraftplus'),
[4079] Fix | Delete
'everyhour' => __('Every hour', 'updraftplus'),
[4080] Fix | Delete
'every2hours' => sprintf(__('Every %s hours', 'updraftplus'), '2'),
[4081] Fix | Delete
'every4hours' => sprintf(__('Every %s hours', 'updraftplus'), '4'),
[4082] Fix | Delete
'every8hours' => sprintf(__('Every %s hours', 'updraftplus'), '8'),
[4083] Fix | Delete
'twicedaily' => sprintf(__('Every %s hours', 'updraftplus'), '12'),
[4084] Fix | Delete
'daily' => __('Daily', 'updraftplus'),
[4085] Fix | Delete
'weekly' => __('Weekly', 'updraftplus'),
[4086] Fix | Delete
'fortnightly' => __('Fortnightly', 'updraftplus'),
[4087] Fix | Delete
'monthly' => __('Monthly', 'updraftplus'),
[4088] Fix | Delete
);
[4089] Fix | Delete
[4090] Fix | Delete
if ('files' == $what_for) unset($intervals['everyhour']);
[4091] Fix | Delete
}
[4092] Fix | Delete
[4093] Fix | Delete
return apply_filters('updraftplus_backup_intervals', $intervals, $what_for);
[4094] Fix | Delete
}
[4095] Fix | Delete
[4096] Fix | Delete
public function really_writable_message($really_is_writable, $updraft_dir) {
[4097] Fix | Delete
if ($really_is_writable) {
[4098] Fix | Delete
$dir_info = '<span style="color:green;">'.__('Backup directory specified is writable, which is good.', 'updraftplus').'</span>';
[4099] Fix | Delete
} else {
[4100] Fix | Delete
$dir_info = '<span style="color:red;">';
[4101] Fix | Delete
if (!is_dir($updraft_dir)) {
[4102] Fix | Delete
$dir_info .= __('Backup directory specified does <b>not</b> exist.', 'updraftplus');
[4103] Fix | Delete
} else {
[4104] Fix | Delete
$dir_info .= __('Backup directory specified exists, but is <b>not</b> writable.', 'updraftplus');
[4105] Fix | Delete
}
[4106] Fix | Delete
$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="'.UpdraftPlus::get_current_clean_url().'" class="updraft_backup_dir_reset">'.__('press 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>';
[4107] Fix | Delete
}
[4108] Fix | Delete
return $dir_info;
[4109] Fix | Delete
}
[4110] Fix | Delete
[4111] Fix | Delete
/**
[4112] Fix | Delete
* Directly output the settings form (suitable for the admin area)
[4113] Fix | Delete
*
[4114] Fix | Delete
* @param Array $options current options (passed on to the template)
[4115] Fix | Delete
*/
[4116] Fix | Delete
public function settings_formcontents($options = array()) {
[4117] Fix | Delete
$this->include_template('wp-admin/settings/form-contents.php', false, array(
[4118] Fix | Delete
'options' => $options
[4119] Fix | Delete
));
[4120] Fix | Delete
if (!(defined('UPDRAFTCENTRAL_COMMAND') && UPDRAFTCENTRAL_COMMAND)) {
[4121] Fix | Delete
$this->include_template('wp-admin/settings/exclude-modal.php', false);
[4122] Fix | Delete
}
[4123] Fix | Delete
}
[4124] Fix | Delete
[4125] Fix | Delete
public function get_settings_js($method_objects, $really_is_writable, $updraft_dir, $active_service) {// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found -- Filter use
[4126] Fix | Delete
[4127] Fix | Delete
global $updraftplus;
[4128] Fix | Delete
[4129] Fix | Delete
ob_start();
[4130] Fix | Delete
?>
[4131] Fix | Delete
jQuery(function() {
[4132] Fix | Delete
<?php
[4133] Fix | Delete
if (!$really_is_writable) echo "jQuery('.backupdirrow').show();\n";
[4134] Fix | Delete
?>
[4135] Fix | Delete
<?php
[4136] Fix | Delete
if (!empty($active_service)) {
[4137] Fix | Delete
if (is_array($active_service)) {
[4138] Fix | Delete
foreach ($active_service as $serv) {
[4139] Fix | Delete
echo "jQuery('.".esc_js($serv)."').show();\n";
[4140] Fix | Delete
}
[4141] Fix | Delete
} else {
[4142] Fix | Delete
echo "jQuery('.".esc_js($active_service)."').show();\n";
[4143] Fix | Delete
}
[4144] Fix | Delete
} else {
[4145] Fix | Delete
echo "jQuery('.none').show();\n";
[4146] Fix | Delete
}
[4147] Fix | Delete
foreach ($updraftplus->backup_methods as $method => $description) {
[4148] Fix | Delete
// already done: require_once(UPDRAFTPLUS_DIR.'/methods/'.$method.'.php');
[4149] Fix | Delete
$call_method = "UpdraftPlus_BackupModule_$method";
[4150] Fix | Delete
if (method_exists($call_method, 'config_print_javascript_onready')) {
[4151] Fix | Delete
$method_objects[$method]->config_print_javascript_onready();
[4152] Fix | Delete
}
[4153] Fix | Delete
}
[4154] Fix | Delete
?>
[4155] Fix | Delete
});
[4156] Fix | Delete
<?php
[4157] Fix | Delete
$ret = ob_get_contents();
[4158] Fix | Delete
ob_end_clean();
[4159] Fix | Delete
return $ret;
[4160] Fix | Delete
}
[4161] Fix | Delete
[4162] Fix | Delete
/**
[4163] Fix | Delete
* Return the HTML for the files selector widget
[4164] Fix | Delete
*
[4165] Fix | Delete
* @param String $prefix Prefix for the ID
[4166] Fix | Delete
* @param Boolean $show_exclusion_options True or False for exclusion options
[4167] Fix | Delete
* @param Boolean|String $include_more $include_more can be (bool) or (string)"sometimes"
[4168] Fix | Delete
*
[4169] Fix | Delete
* @return String
[4170] Fix | Delete
*/
[4171] Fix | Delete
public function files_selector_widgetry($prefix = '', $show_exclusion_options = true, $include_more = true) {
[4172] Fix | Delete
[4173] Fix | Delete
$ret = '';
[4174] Fix | Delete
[4175] Fix | Delete
global $updraftplus;
[4176] Fix | Delete
$for_updraftcentral = defined('UPDRAFTCENTRAL_COMMAND') && UPDRAFTCENTRAL_COMMAND;
[4177] Fix | Delete
$backupable_entities = $updraftplus->get_backupable_file_entities(true, true);
[4178] Fix | Delete
// The true (default value if non-existent) here has the effect of forcing a default of on.
[4179] Fix | Delete
$include_more_paths = UpdraftPlus_Options::get_updraft_option('updraft_include_more_path');
[4180] Fix | Delete
foreach ($backupable_entities as $key => $info) {
[4181] Fix | Delete
$included = (UpdraftPlus_Options::get_updraft_option("updraft_include_$key", apply_filters("updraftplus_defaultoption_include_".$key, true))) ? 'checked="checked"' : "";
[4182] Fix | Delete
if ('others' == $key || 'uploads' == $key) {
[4183] Fix | Delete
[4184] Fix | Delete
$data_toggle_exclude_field = $show_exclusion_options ? 'data-toggle_exclude_field="'.$key.'"' : '';
[4185] Fix | Delete
[4186] Fix | Delete
$ret .= '<label '.(('others' == $key) ? 'title="'.sprintf(__('Your wp-content directory server path: %s', 'updraftplus'), WP_CONTENT_DIR).'" ' : '').' for="'.$prefix.'updraft_include_'.$key.'" class="updraft_checkbox"><input class="updraft_include_entity" id="'.$prefix.'updraft_include_'.$key.'" '.$data_toggle_exclude_field.' type="checkbox" name="updraft_include_'.$key.'" value="1" '.$included.'> '.(('others' == $key) ? __('Any other directories found inside wp-content', 'updraftplus') : htmlspecialchars($info['description'])).'</label>';
[4187] Fix | Delete
[4188] Fix | Delete
if ($show_exclusion_options) {
[4189] Fix | Delete
$include_exclude = UpdraftPlus_Options::get_updraft_option('updraft_include_'.$key.'_exclude', ('others' == $key) ? UPDRAFT_DEFAULT_OTHERS_EXCLUDE : UPDRAFT_DEFAULT_UPLOADS_EXCLUDE);
[4190] Fix | Delete
[4191] Fix | Delete
$display = ($included) ? '' : 'class="updraft-hidden" style="display:none;"';
[4192] Fix | Delete
$exclude_container_class = $prefix.'updraft_include_'.$key.'_exclude';
[4193] Fix | Delete
if (!$for_updraftcentral) $exclude_container_class .= '_container';
[4194] Fix | Delete
[4195] Fix | Delete
$ret .= "<div id=\"".$exclude_container_class."\" $display class=\"updraft_exclude_container\">";
[4196] Fix | Delete
[4197] Fix | Delete
$ret .= '<label class="updraft-exclude-label" for="'.$prefix.'updraft_include_'.$key.'_exclude">'.__('Exclude these from', 'updraftplus').' '.htmlspecialchars($info['description']).':</label> <span class="updraft-fs-italic">'.__('(the asterisk character matches zero or more characters)', 'updraftplus').'</span>';
[4198] Fix | Delete
[4199] Fix | Delete
$exclude_input_type = $for_updraftcentral ? "text" : "hidden";
[4200] Fix | Delete
$exclude_input_extra_attr = $for_updraftcentral ? 'title="'.__('If entering multiple files/directories, then separate them with commas. For entities at the top level, you can use a * at the start or end of the entry as a wildcard.', 'updraftplus').'" size="54"' : '';
[4201] Fix | Delete
$ret .= '<input type="'.$exclude_input_type.'" id="'.$prefix.'updraft_include_'.$key.'_exclude" name="updraft_include_'.$key.'_exclude" '.$exclude_input_extra_attr.' value="'.htmlspecialchars($include_exclude).'" />';
[4202] Fix | Delete
[4203] Fix | Delete
if (!$for_updraftcentral) {
[4204] Fix | Delete
global $updraftplus;
[4205] Fix | Delete
$backupable_file_entities = $updraftplus->get_backupable_file_entities();
[4206] Fix | Delete
[4207] Fix | Delete
if ('uploads' == $key) {
[4208] Fix | Delete
$path = UpdraftPlus_Manipulation_Functions::wp_normalize_path($backupable_file_entities['uploads']);
[4209] Fix | Delete
} elseif ('others' == $key) {
[4210] Fix | Delete
$path = UpdraftPlus_Manipulation_Functions::wp_normalize_path($backupable_file_entities['others']);
[4211] Fix | Delete
}
[4212] Fix | Delete
$ret .= $this->include_template('wp-admin/settings/file-backup-exclude.php', true, array(
[4213] Fix | Delete
'key' => $key,
[4214] Fix | Delete
'include_exclude' => $include_exclude,
[4215] Fix | Delete
'path' => $path,
[4216] Fix | Delete
'show_exclusion_options' => $show_exclusion_options,
[4217] Fix | Delete
));
[4218] Fix | Delete
}
[4219] Fix | Delete
$ret .= '</div>';
[4220] Fix | Delete
}
[4221] Fix | Delete
[4222] Fix | Delete
} else {
[4223] Fix | Delete
[4224] Fix | Delete
if ('more' != $key || true === $include_more || ('sometimes' === $include_more && !empty($include_more_paths))) {
[4225] Fix | Delete
[4226] Fix | Delete
$data_toggle_exclude_field = $show_exclusion_options ? 'data-toggle_exclude_field="'.$key.'"' : '';
[4227] Fix | Delete
[4228] Fix | Delete
$ret .= "<label for=\"".$prefix."updraft_include_$key\"".((isset($info['htmltitle'])) ? ' title="'.htmlspecialchars($info['htmltitle']).'"' : '')." class=\"updraft_checkbox\"><input class=\"updraft_include_entity\" $data_toggle_exclude_field id=\"".$prefix."updraft_include_$key\" type=\"checkbox\" name=\"updraft_include_$key\" value=\"1\" $included /> ".htmlspecialchars($info['description']);
[4229] Fix | Delete
[4230] Fix | Delete
$ret .= "</label>";
[4231] Fix | Delete
$ret .= apply_filters("updraftplus_config_option_include_$key", '', $prefix, $for_updraftcentral);
[4232] Fix | Delete
}
[4233] Fix | Delete
}
[4234] Fix | Delete
}
[4235] Fix | Delete
[4236] Fix | Delete
return $ret;
[4237] Fix | Delete
}
[4238] Fix | Delete
[4239] Fix | Delete
/**
[4240] Fix | Delete
* Output or echo HTML for an error condition relating to a remote storage method
[4241] Fix | Delete
*
[4242] Fix | Delete
* @param String $text - the text of the message; this should already be escaped (no more is done)
[4243] Fix | Delete
* @param String $extraclass - a CSS class for the resulting DOM node
[4244] Fix | Delete
* @param Integer $echo - if set, then the results will be echoed as well as returned
[4245] Fix | Delete
*
[4246] Fix | Delete
* @return String - the results
[4247] Fix | Delete
*/
[4248] Fix | Delete
public function show_double_warning($text, $extraclass = '', $echo = true) {
[4249] Fix | Delete
[4250] Fix | Delete
$ret = "<div class=\"error updraftplusmethod $extraclass\"><p>$text</p></div>";
[4251] Fix | Delete
$ret .= "<div class=\"notice error below-h2\"><p>$text</p></div>";
[4252] Fix | Delete
[4253] Fix | Delete
if ($echo) echo $ret;
[4254] Fix | Delete
return $ret;
[4255] Fix | Delete
[4256] Fix | Delete
}
[4257] Fix | Delete
[4258] Fix | Delete
public function optionfilter_split_every($value) {
[4259] Fix | Delete
return max(absint($value), UPDRAFTPLUS_SPLIT_MIN);
[4260] Fix | Delete
}
[4261] Fix | Delete
[4262] Fix | Delete
/**
[4263] Fix | Delete
* Check if curl exists; if not, print or return appropriate error messages
[4264] Fix | Delete
*
[4265] Fix | Delete
* @param String $service the service description (used only for user-visible messages - so, use the description)
[4266] Fix | Delete
* @param Boolean $has_fallback set as true if the lack of Curl only affects the ability to connect over SSL
[4267] Fix | Delete
* @param String $extraclass an extra CSS class for any resulting message, passed on to show_double_warning()
[4268] Fix | Delete
* @param Boolean $echo_instead_of_return whether the result should be echoed or returned
[4269] Fix | Delete
* @return String any resulting message, if $echo_instead_of_return was set
[4270] Fix | Delete
*/
[4271] Fix | Delete
public function curl_check($service, $has_fallback = false, $extraclass = '', $echo_instead_of_return = true) {
[4272] Fix | Delete
[4273] Fix | Delete
$ret = '';
[4274] Fix | Delete
[4275] Fix | Delete
// Check requirements
[4276] Fix | Delete
if (!function_exists("curl_init") || !function_exists('curl_exec')) {
[4277] Fix | Delete
[4278] Fix | Delete
$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);
[4279] Fix | Delete
[4280] Fix | Delete
} else {
[4281] Fix | Delete
$curl_version = curl_version();
[4282] Fix | Delete
$curl_ssl_supported= ($curl_version['features'] & CURL_VERSION_SSL);
[4283] Fix | Delete
if (!$curl_ssl_supported) {
[4284] Fix | Delete
if ($has_fallback) {
[4285] Fix | Delete
$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>';
[4286] Fix | Delete
} else {
[4287] Fix | Delete
$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, $service).'</p>', $extraclass, false);
[4288] Fix | Delete
}
[4289] Fix | Delete
} else {
[4290] Fix | Delete
$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>';
[4291] Fix | Delete
}
[4292] Fix | Delete
}
[4293] Fix | Delete
if ($echo_instead_of_return) {
[4294] Fix | Delete
echo $ret;
[4295] Fix | Delete
} else {
[4296] Fix | Delete
return $ret;
[4297] Fix | Delete
}
[4298] Fix | Delete
}
[4299] Fix | Delete
[4300] Fix | Delete
/**
[4301] Fix | Delete
* Get backup information in HTML format for a specific backup
[4302] Fix | Delete
*
[4303] Fix | Delete
* @param Array $backup_history all backups history
[4304] Fix | Delete
* @param String $key backup timestamp
[4305] Fix | Delete
* @param String $nonce backup nonce (job ID)
[4306] Fix | Delete
* @param Array|Null $job_data if an array, then use this as the job data (if null, then it will be fetched directly)
[4307] Fix | Delete
*
[4308] Fix | Delete
* @return string HTML-formatted backup information
[4309] Fix | Delete
*/
[4310] Fix | Delete
public function raw_backup_info($backup_history, $key, $nonce, $job_data = null) {
[4311] Fix | Delete
[4312] Fix | Delete
global $updraftplus;
[4313] Fix | Delete
[4314] Fix | Delete
$backup = $backup_history[$key];
[4315] Fix | Delete
[4316] Fix | Delete
$only_remote_sent = !empty($backup['service']) && (array('remotesend') === $backup['service'] || 'remotesend' === $backup['service']);
[4317] Fix | Delete
[4318] Fix | Delete
$pretty_date = get_date_from_gmt(gmdate('Y-m-d H:i:s', (int) $key), 'M d, Y G:i');
[4319] Fix | Delete
[4320] Fix | Delete
$rawbackup = "<h2 title=\"$key\">$pretty_date</h2>";
[4321] Fix | Delete
[4322] Fix | Delete
if (!empty($backup['label'])) $rawbackup .= '<span class="raw-backup-info">'.$backup['label'].'</span>';
[4323] Fix | Delete
[4324] Fix | Delete
if (null === $job_data) $job_data = empty($nonce) ? array() : $updraftplus->jobdata_getarray($nonce);
[4325] Fix | Delete
[4326] Fix | Delete
if (!$only_remote_sent) {
[4327] Fix | Delete
$rawbackup .= '<hr>';
[4328] Fix | Delete
$rawbackup .= '<input type="checkbox" name="always_keep_this_backup" id="always_keep_this_backup" data-backup_key="'.$key.'" '.(empty($backup['always_keep']) ? '' : 'checked ').'><label for="always_keep_this_backup">'.__('Only allow this backup to be deleted manually (i.e. keep it even if retention limits are hit).', 'updraftplus').'</label>';
[4329] Fix | Delete
}
[4330] Fix | Delete
[4331] Fix | Delete
$rawbackup .= '<hr><p>';
[4332] Fix | Delete
[4333] Fix | Delete
$backupable_entities = $updraftplus->get_backupable_file_entities(true, true);
[4334] Fix | Delete
[4335] Fix | Delete
$checksums = $updraftplus->which_checksums();
[4336] Fix | Delete
[4337] Fix | Delete
foreach ($backupable_entities as $type => $info) {
[4338] Fix | Delete
if (!isset($backup[$type])) continue;
[4339] Fix | Delete
[4340] Fix | Delete
$rawbackup .= $updraftplus->printfile($info['description'], $backup, $type, $checksums, $job_data, true);
[4341] Fix | Delete
}
[4342] Fix | Delete
[4343] Fix | Delete
$total_size = 0;
[4344] Fix | Delete
foreach ($backup as $ekey => $files) {
[4345] Fix | Delete
if ('db' == strtolower(substr($ekey, 0, 2)) && '-size' != substr($ekey, -5, 5)) {
[4346] Fix | Delete
$rawbackup .= $updraftplus->printfile(__('Database', 'updraftplus'), $backup, $ekey, $checksums, $job_data, true);
[4347] Fix | Delete
}
[4348] Fix | Delete
if (!isset($backupable_entities[$ekey]) && ('db' != substr($ekey, 0, 2) || '-size' == substr($ekey, -5, 5))) continue;
[4349] Fix | Delete
if (is_string($files)) $files = array($files);
[4350] Fix | Delete
foreach ($files as $findex => $file) {
[4351] Fix | Delete
$size_key = (0 == $findex) ? $ekey.'-size' : $ekey.$findex.'-size';
[4352] Fix | Delete
$total_size = (false === $total_size || !isset($backup[$size_key]) || !is_numeric($backup[$size_key])) ? false : $total_size + $backup[$size_key];
[4353] Fix | Delete
}
[4354] Fix | Delete
}
[4355] Fix | Delete
[4356] Fix | Delete
$services = empty($backup['service']) ? array('none') : $backup['service'];
[4357] Fix | Delete
if (!is_array($services)) $services = array('none');
[4358] Fix | Delete
[4359] Fix | Delete
$rawbackup .= '<strong>'.__('Uploaded to:', 'updraftplus').'</strong> ';
[4360] Fix | Delete
[4361] Fix | Delete
$show_services = '';
[4362] Fix | Delete
foreach ($services as $serv) {
[4363] Fix | Delete
if ('none' == $serv || '' == $serv) {
[4364] Fix | Delete
$add_none = true;
[4365] Fix | Delete
} elseif (isset($updraftplus->backup_methods[$serv])) {
[4366] Fix | Delete
$show_services .= $show_services ? ', '.$updraftplus->backup_methods[$serv] : $updraftplus->backup_methods[$serv];
[4367] Fix | Delete
} else {
[4368] Fix | Delete
$show_services .= $show_services ? ', '.$serv : $serv;
[4369] Fix | Delete
}
[4370] Fix | Delete
}
[4371] Fix | Delete
if ('' == $show_services && $add_none) $show_services .= __('None', 'updraftplus');
[4372] Fix | Delete
[4373] Fix | Delete
$rawbackup .= $show_services;
[4374] Fix | Delete
[4375] Fix | Delete
if (false !== $total_size) {
[4376] Fix | Delete
$rawbackup .= '</p><strong>'.__('Total backup size:', 'updraftplus').'</strong> '.UpdraftPlus_Manipulation_Functions::convert_numeric_size_to_text($total_size).'<p>';
[4377] Fix | Delete
}
[4378] Fix | Delete
[4379] Fix | Delete
$rawbackup .= '</p><hr><p><pre>'.print_r($backup, true).'</pre></p>';
[4380] Fix | Delete
[4381] Fix | Delete
if (!empty($job_data) && is_array($job_data)) {
[4382] Fix | Delete
$rawbackup .= '<p><pre>'.htmlspecialchars(print_r($job_data, true)).'</pre></p>';
[4383] Fix | Delete
}
[4384] Fix | Delete
[4385] Fix | Delete
return esc_attr($rawbackup);
[4386] Fix | Delete
}
[4387] Fix | Delete
[4388] Fix | Delete
private function download_db_button($bkey, $key, $esc_pretty_date, $backup, $accept = array()) {
[4389] Fix | Delete
[4390] Fix | Delete
if (!empty($backup['meta_foreign']) && isset($accept[$backup['meta_foreign']])) {
[4391] Fix | Delete
$desc_source = $accept[$backup['meta_foreign']]['desc'];
[4392] Fix | Delete
} else {
[4393] Fix | Delete
$desc_source = __('unknown source', 'updraftplus');
[4394] Fix | Delete
}
[4395] Fix | Delete
[4396] Fix | Delete
$ret = '';
[4397] Fix | Delete
[4398] Fix | Delete
if ('db' == $bkey) {
[4399] Fix | Delete
$dbt = empty($backup['meta_foreign']) ? esc_attr(__('Database', 'updraftplus')) : esc_attr(sprintf(__('Database (created by %s)', 'updraftplus'), $desc_source));
[4400] Fix | Delete
} else {
[4401] Fix | Delete
$dbt = __('External database', 'updraftplus').' ('.substr($bkey, 2).')';
[4402] Fix | Delete
}
[4403] Fix | Delete
[4404] Fix | Delete
$ret .= $this->download_button($bkey, $key, 0, null, '', $dbt, $esc_pretty_date, '0');
[4405] Fix | Delete
[4406] Fix | Delete
return $ret;
[4407] Fix | Delete
}
[4408] Fix | Delete
[4409] Fix | Delete
/**
[4410] Fix | Delete
* Go through each of the file entities
[4411] Fix | Delete
*
[4412] Fix | Delete
* @param Array $backup An array of meta information
[4413] Fix | Delete
* @param Integer $key Backup timestamp (epoch time)
[4414] Fix | Delete
* @param Array $accept An array of values to be accepted from vaules within $backup
[4415] Fix | Delete
* @param String $entities Entities to be added
[4416] Fix | Delete
* @param String $esc_pretty_date Whether the button needs to escape the pretty date format
[4417] Fix | Delete
* @return String - the resulting HTML
[4418] Fix | Delete
*/
[4419] Fix | Delete
public function download_buttons($backup, $key, $accept, &$entities, $esc_pretty_date) {
[4420] Fix | Delete
global $updraftplus;
[4421] Fix | Delete
$ret = '';
[4422] Fix | Delete
$backupable_entities = $updraftplus->get_backupable_file_entities(true, true);
[4423] Fix | Delete
[4424] Fix | Delete
$first_entity = true;// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- template
[4425] Fix | Delete
[4426] Fix | Delete
foreach ($backupable_entities as $type => $info) {
[4427] Fix | Delete
if (!empty($backup['meta_foreign']) && 'wpcore' != $type) continue;
[4428] Fix | Delete
[4429] Fix | Delete
$ide = '';
[4430] Fix | Delete
[4431] Fix | Delete
if (empty($backup['meta_foreign'])) {
[4432] Fix | Delete
$sdescrip = preg_replace('/ \(.*\)$/', '', $info['description']);
[4433] Fix | Delete
if (strlen($sdescrip) > 20 && isset($info['shortdescription'])) $sdescrip = $info['shortdescription'];
[4434] Fix | Delete
} else {
[4435] Fix | Delete
$info['description'] = 'WordPress';
[4436] Fix | Delete
[4437] Fix | Delete
if (isset($accept[$backup['meta_foreign']])) {
[4438] Fix | Delete
$desc_source = $accept[$backup['meta_foreign']]['desc'];
[4439] Fix | Delete
$ide .= sprintf(__('Backup created by: %s.', 'updraftplus'), $accept[$backup['meta_foreign']]['desc']).' ';
[4440] Fix | Delete
} else {
[4441] Fix | Delete
$desc_source = __('unknown source', 'updraftplus');
[4442] Fix | Delete
$ide .= __('Backup created by unknown source (%s) - cannot be restored.', 'updraftplus').' ';
[4443] Fix | Delete
}
[4444] Fix | Delete
[4445] Fix | Delete
$sdescrip = (empty($accept[$backup['meta_foreign']]['separatedb'])) ? sprintf(__('Files and database WordPress backup (created by %s)', 'updraftplus'), $desc_source) : sprintf(__('Files backup (created by %s)', 'updraftplus'), $desc_source);
[4446] Fix | Delete
}
[4447] Fix | Delete
if (isset($backup[$type])) {
[4448] Fix | Delete
if (!is_array($backup[$type])) $backup[$type] = array($backup[$type]);
[4449] Fix | Delete
$howmanyinset = count($backup[$type]);
[4450] Fix | Delete
$expected_index = 0;
[4451] Fix | Delete
$index_missing = false;
[4452] Fix | Delete
$set_contents = '';
[4453] Fix | Delete
$entities .= "/$type=";
[4454] Fix | Delete
$whatfiles = $backup[$type];
[4455] Fix | Delete
ksort($whatfiles);
[4456] Fix | Delete
$total_file_size = 0;
[4457] Fix | Delete
foreach ($whatfiles as $findex => $bfile) {
[4458] Fix | Delete
$set_contents .= ('' == $set_contents) ? $findex : ",$findex";
[4459] Fix | Delete
if ($findex != $expected_index) $index_missing = true;
[4460] Fix | Delete
$expected_index++;
[4461] Fix | Delete
[4462] Fix | Delete
if ($howmanyinset > 0) {
[4463] Fix | Delete
if (!empty($backup[$type.(($findex > 0) ? $findex : '')."-size"]) && $findex < $howmanyinset) $total_file_size += $backup[$type.(($findex > 0) ? $findex : '')."-size"];
[4464] Fix | Delete
}
[4465] Fix | Delete
}
[4466] Fix | Delete
[4467] Fix | Delete
$ide = __('Press here to download or browse', 'updraftplus').' '.strtolower($info['description']);
[4468] Fix | Delete
$ide .= ' '.sprintf(__('(%d archive(s) in set, total %s).', 'updraftplus'), $howmanyinset, '%UP_backups_total_file_size%');
[4469] Fix | Delete
if ($index_missing) $ide .= ' '.__('You appear to be missing one or more archives from this multi-archive set.', 'updraftplus');
[4470] Fix | Delete
[4471] Fix | Delete
$entities .= $set_contents.'/';
[4472] Fix | Delete
if (!empty($backup['meta_foreign'])) {
[4473] Fix | Delete
$entities .= '/plugins=0//themes=0//uploads=0//others=0/';
[4474] Fix | Delete
}
[4475] Fix | Delete
[4476] Fix | Delete
$ret .= $this->download_button($type, $key, 0, null, $ide, $sdescrip, $esc_pretty_date, $set_contents);
[4477] Fix | Delete
[4478] Fix | Delete
$ret = str_replace('%UP_backups_total_file_size%', UpdraftPlus_Manipulation_Functions::convert_numeric_size_to_text($total_file_size), $ret);
[4479] Fix | Delete
}
[4480] Fix | Delete
}
[4481] Fix | Delete
return $ret;
[4482] Fix | Delete
}
[4483] Fix | Delete
[4484] Fix | Delete
public function date_label($pretty_date, $key, $backup, $jobdata, $nonce, $simple_format = false) {
[4485] Fix | Delete
[4486] Fix | Delete
$pretty_date = $simple_format ? $pretty_date : '<div class="clear-right">'.$pretty_date.'</div>';
[4487] Fix | Delete
[4488] Fix | Delete
$ret = apply_filters('updraftplus_showbackup_date', $pretty_date, $backup, $jobdata, (int) $key, $simple_format);
[4489] Fix | Delete
if (is_array($jobdata) && !empty($jobdata['resume_interval']) && (empty($jobdata['jobstatus']) || 'finished' != $jobdata['jobstatus'])) {
[4490] Fix | Delete
if ($simple_format) {
[4491] Fix | Delete
$ret .= ' '.__('(Not finished)', 'updraftplus');
[4492] Fix | Delete
} else {
[4493] Fix | Delete
$ret .= apply_filters('updraftplus_msg_unfinishedbackup', "<br><span title=\"".esc_attr(__('If you are seeing more backups than you expect, then it is probably because the deletion of old backup sets does not happen until a fresh backup completes.', 'updraftplus'))."\">".__('(Not finished)', 'updraftplus').'</span>', $jobdata, $nonce);
[4494] Fix | Delete
}
[4495] Fix | Delete
}
[4496] Fix | Delete
return $ret;
[4497] Fix | Delete
}
[4498] Fix | Delete
[4499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function