Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp...
File: admin.php
[2000] Fix | Delete
if (!array_key_exists($instance_id, $deletion_errors)) {
[2001] Fix | Delete
$deletion_errors[$instance_id] = array('error_code' => $deleted, 'service' => $service);
[2002] Fix | Delete
}
[2003] Fix | Delete
}
[2004] Fix | Delete
[2005] Fix | Delete
$itext = $index ? (string) $index : '';
[2006] Fix | Delete
if ($was_string) {
[2007] Fix | Delete
unset($backups[$timestamp][$key]);
[2008] Fix | Delete
if ('db' == strtolower(substr($key, 0, 2))) unset($backups[$timestamp][$key][$index.'-size']);
[2009] Fix | Delete
} else {
[2010] Fix | Delete
unset($backups[$timestamp][$key][$index]);
[2011] Fix | Delete
unset($backups[$timestamp][$key.$itext.'-size']);
[2012] Fix | Delete
if (empty($backups[$timestamp][$key])) unset($backups[$timestamp][$key]);
[2013] Fix | Delete
}
[2014] Fix | Delete
if (isset($backups[$timestamp]['checksums']) && is_array($backups[$timestamp]['checksums'])) {
[2015] Fix | Delete
foreach (array_keys($backups[$timestamp]['checksums']) as $algo) {
[2016] Fix | Delete
unset($backups[$timestamp]['checksums'][$algo][$key.$index]);
[2017] Fix | Delete
}
[2018] Fix | Delete
}
[2019] Fix | Delete
[2020] Fix | Delete
// If we don't save the array back, then the above section will fire again for the same files - and the remote storage will be requested to delete already-deleted files, which then means no time is actually saved by the browser-backend loop method.
[2021] Fix | Delete
UpdraftPlus_Backup_History::save_history($backups);
[2022] Fix | Delete
}
[2023] Fix | Delete
}
[2024] Fix | Delete
}
[2025] Fix | Delete
}
[2026] Fix | Delete
}
[2027] Fix | Delete
[2028] Fix | Delete
unset($backups[$timestamp]);
[2029] Fix | Delete
unset($timestamps[$i]);
[2030] Fix | Delete
if ('' != $deleted_timestamps) $deleted_timestamps .= ',';
[2031] Fix | Delete
$deleted_timestamps .= $timestamp;
[2032] Fix | Delete
UpdraftPlus_Backup_History::save_history($backups);
[2033] Fix | Delete
$sets_removed++;
[2034] Fix | Delete
}
[2035] Fix | Delete
[2036] Fix | Delete
$timestamps_list = implode(',', $timestamps);
[2037] Fix | Delete
[2038] Fix | Delete
return $this->remove_backup_set_cleanup(true, $backups, $local_deleted, $remote_deleted, $sets_removed, $timestamps_list, $deleted_timestamps, $deletion_errors);
[2039] Fix | Delete
[2040] Fix | Delete
}
[2041] Fix | Delete
[2042] Fix | Delete
/**
[2043] Fix | Delete
* This function sorts the array of instance ids currently saved so that any instance id that is in both the saved settings and the backup history move to the top of the array, as these are likely to work. Then values that don't appear in the backup history move to the bottom.
[2044] Fix | Delete
*
[2045] Fix | Delete
* @param String $a - the first instance id
[2046] Fix | Delete
* @param String $b - the second instance id
[2047] Fix | Delete
* @return Integer - returns an integer to indicate what position the $b value should be moved in
[2048] Fix | Delete
*/
[2049] Fix | Delete
public function instance_ids_sort($a, $b) {
[2050] Fix | Delete
if (in_array($a, $this->backups_instance_ids)) {
[2051] Fix | Delete
if (in_array($b, $this->backups_instance_ids)) return 0;
[2052] Fix | Delete
return -1;
[2053] Fix | Delete
}
[2054] Fix | Delete
return in_array($b, $this->backups_instance_ids) ? 1 : 0;
[2055] Fix | Delete
}
[2056] Fix | Delete
[2057] Fix | Delete
/**
[2058] Fix | Delete
* Called by self::delete_set() to finish up before returning (whether the complete deletion is finished or not)
[2059] Fix | Delete
*
[2060] Fix | Delete
* @param Boolean $delete_complete - whether the whole set is now gone (i.e. last round)
[2061] Fix | Delete
* @param Array $backups - the backup history
[2062] Fix | Delete
* @param Integer $local_deleted - how many backup archives were deleted from local storage
[2063] Fix | Delete
* @param Integer $remote_deleted - how many backup archives were deleted from remote storage
[2064] Fix | Delete
* @param Integer $sets_removed - how many complete sets were removed
[2065] Fix | Delete
* @param String $timestamps - a csv of remaining timestamps
[2066] Fix | Delete
* @param String $deleted_timestamps - a csv of deleted timestamps
[2067] Fix | Delete
* @param Array $deletion_errors - an array of abstracted deletion errors, consisting of [error_code, service, instance]. For user notification purposes only, main error logging occurs at service.
[2068] Fix | Delete
*
[2069] Fix | Delete
* @return Array - information on the status, suitable for returning to the UI
[2070] Fix | Delete
*/
[2071] Fix | Delete
public function remove_backup_set_cleanup($delete_complete, $backups, $local_deleted, $remote_deleted, $sets_removed, $timestamps, $deleted_timestamps, $deletion_errors = array()) {// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- $deletion_errors was used below but the code has been commented out. Can both be removed?
[2072] Fix | Delete
[2073] Fix | Delete
global $updraftplus;
[2074] Fix | Delete
[2075] Fix | Delete
$updraftplus->register_wp_http_option_hooks(false);
[2076] Fix | Delete
[2077] Fix | Delete
UpdraftPlus_Backup_History::save_history($backups);
[2078] Fix | Delete
[2079] Fix | Delete
$updraftplus->log("Local files deleted: $local_deleted. Remote files deleted: $remote_deleted");
[2080] Fix | Delete
[2081] Fix | Delete
/*
[2082] Fix | Delete
Disable until next release
[2083] Fix | Delete
$error_messages = array();
[2084] Fix | Delete
$storage_details = array();
[2085] Fix | Delete
[2086] Fix | Delete
foreach ($deletion_errors as $instance => $entry) {
[2087] Fix | Delete
$service = $entry['service'];
[2088] Fix | Delete
[2089] Fix | Delete
if (!array_key_exists($service, $storage_details)) {
[2090] Fix | Delete
// As errors from multiple instances of a service can be present, store the service storage object for possible use later
[2091] Fix | Delete
$new_service = UpdraftPlus_Storage_Methods_Interface::get_storage_objects_and_ids(array($service));
[2092] Fix | Delete
$storage_details = array_merge($storage_details, $new_service);
[2093] Fix | Delete
}
[2094] Fix | Delete
[2095] Fix | Delete
$intance_label = !empty($storage_details[$service]['instance_settings'][$instance]['instance_label']) ? $storage_details[$service]['instance_settings'][$instance]['instance_label'] : $service;
[2096] Fix | Delete
[2097] Fix | Delete
switch ($entry['error_code']) {
[2098] Fix | Delete
case 'authentication_fail':
[2099] Fix | Delete
$error_messages[] = sprintf(__("The authentication failed for '%s'.", 'updraftplus').' '.__('Please check your credentials.', 'updraftplus'), $intance_label);
[2100] Fix | Delete
break;
[2101] Fix | Delete
case 'service_unavailable':
[2102] Fix | Delete
$error_messages[] = sprintf(__("We were unable to access '%s'.", 'updraftplus').' '.__('Service unavailable.', 'updraftplus'), $intance_label);
[2103] Fix | Delete
break;
[2104] Fix | Delete
case 'container_access_error':
[2105] Fix | Delete
$error_messages[] = sprintf(__("We were unable to access the folder/container for '%s'.", 'updraftplus').' '.__('Please check your permissions.', 'updraftplus'), $intance_label);
[2106] Fix | Delete
break;
[2107] Fix | Delete
case 'file_access_error':
[2108] Fix | Delete
$error_messages[] = sprintf(__("We were unable to access a file on '%s'.", 'updraftplus').' '.__('Please check your permissions.', 'updraftplus'), $intance_label);
[2109] Fix | Delete
break;
[2110] Fix | Delete
case 'file_delete_error':
[2111] Fix | Delete
$error_messages[] = sprintf(__("We were unable to delete a file on '%s'.", 'updraftplus').' '.__('The file may no longer exist or you may not have permission to delete.', 'updraftplus'), $intance_label);
[2112] Fix | Delete
break;
[2113] Fix | Delete
default:
[2114] Fix | Delete
$error_messages[] = sprintf(__("An error occurred while attempting to delete from '%s'.", 'updraftplus'), $intance_label);
[2115] Fix | Delete
break;
[2116] Fix | Delete
}
[2117] Fix | Delete
}
[2118] Fix | Delete
*/
[2119] Fix | Delete
[2120] Fix | Delete
// $error_message_string = implode("\n", $error_messages);
[2121] Fix | Delete
$error_message_string = '';
[2122] Fix | Delete
[2123] Fix | Delete
if ($delete_complete) {
[2124] Fix | Delete
$set_message = __('Backup sets removed:', 'updraftplus');
[2125] Fix | Delete
$local_message = __('Local files deleted:', 'updraftplus');
[2126] Fix | Delete
$remote_message = __('Remote files deleted:', 'updraftplus');
[2127] Fix | Delete
[2128] Fix | Delete
if (UpdraftPlus_Options::get_updraft_option('updraft_debug_mode')) {
[2129] Fix | Delete
restore_error_handler();
[2130] Fix | Delete
}
[2131] Fix | Delete
[2132] Fix | Delete
return array('result' => 'success', 'set_message' => $set_message, 'local_message' => $local_message, 'remote_message' => $remote_message, 'backup_sets' => $sets_removed, 'backup_local' => $local_deleted, 'backup_remote' => $remote_deleted, 'error_messages' => $error_message_string);
[2133] Fix | Delete
} else {
[2134] Fix | Delete
[2135] Fix | Delete
return array('result' => 'continue', 'backup_local' => $local_deleted, 'backup_remote' => $remote_deleted, 'backup_sets' => $sets_removed, 'timestamps' => $timestamps, 'deleted_timestamps' => $deleted_timestamps, 'error_messages' => $error_message_string);
[2136] Fix | Delete
}
[2137] Fix | Delete
}
[2138] Fix | Delete
[2139] Fix | Delete
/**
[2140] Fix | Delete
* Get the history status HTML and other information
[2141] Fix | Delete
*
[2142] Fix | Delete
* @param Boolean $rescan - whether to rescan local storage
[2143] Fix | Delete
* @param Boolean $remotescan - whether to also rescan remote storage
[2144] Fix | Delete
* @param Boolean $debug - whether to return debugging information also
[2145] Fix | Delete
* @param Integer $backup_count - a count of the total backups we want to display on the front end for use by UpdraftPlus_Backup_History::existing_backup_table()
[2146] Fix | Delete
*
[2147] Fix | Delete
* @return Array - the information requested
[2148] Fix | Delete
*/
[2149] Fix | Delete
public function get_history_status($rescan, $remotescan, $debug = false, $backup_count = 0) {
[2150] Fix | Delete
[2151] Fix | Delete
global $updraftplus;
[2152] Fix | Delete
[2153] Fix | Delete
if ($rescan) $messages = UpdraftPlus_Backup_History::rebuild($remotescan, false, $debug);
[2154] Fix | Delete
$backup_history = UpdraftPlus_Backup_History::get_history();
[2155] Fix | Delete
$output = UpdraftPlus_Backup_History::existing_backup_table($backup_history, $backup_count);
[2156] Fix | Delete
[2157] Fix | Delete
$data = array();
[2158] Fix | Delete
[2159] Fix | Delete
if (!empty($messages) && is_array($messages)) {
[2160] Fix | Delete
$noutput = '';
[2161] Fix | Delete
foreach ($messages as $msg) {
[2162] Fix | Delete
if (empty($msg['code']) || 'file-listing' != $msg['code']) {
[2163] Fix | Delete
$noutput .= '<li>'.(empty($msg['desc']) ? '' : $msg['desc'].': ').'<em>'.$msg['message'].'</em></li>';
[2164] Fix | Delete
}
[2165] Fix | Delete
if (!empty($msg['data'])) {
[2166] Fix | Delete
$key = $msg['method'].'-'.$msg['service_instance_id'];
[2167] Fix | Delete
$data[$key] = $msg['data'];
[2168] Fix | Delete
}
[2169] Fix | Delete
}
[2170] Fix | Delete
if ($noutput) {
[2171] Fix | Delete
$output = '<div style="margin-left: 100px; margin-top: 10px;"><ul style="list-style: disc inside;">'.$noutput.'</ul></div>'.$output;
[2172] Fix | Delete
}
[2173] Fix | Delete
}
[2174] Fix | Delete
[2175] Fix | Delete
$logs_exist = (false !== strpos($output, 'downloadlog'));
[2176] Fix | Delete
if (!$logs_exist) {
[2177] Fix | Delete
list($mod_time, $log_file, $nonce) = $updraftplus->last_modified_log();// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
[2178] Fix | Delete
if ($mod_time) $logs_exist = true;
[2179] Fix | Delete
}
[2180] Fix | Delete
[2181] Fix | Delete
return apply_filters('updraftplus_get_history_status_result', array(
[2182] Fix | Delete
'n' => __('Existing backups', 'updraftplus').' <span class="updraft_existing_backups_count">'.count($backup_history).'</span>',
[2183] Fix | Delete
't' => $output, // table
[2184] Fix | Delete
'data' => $data,
[2185] Fix | Delete
'cksum' => md5($output),
[2186] Fix | Delete
'logs_exist' => $logs_exist,
[2187] Fix | Delete
'web_server_disk_space' => UpdraftPlus_Filesystem_Functions::web_server_disk_space(true),
[2188] Fix | Delete
));
[2189] Fix | Delete
}
[2190] Fix | Delete
[2191] Fix | Delete
/**
[2192] Fix | Delete
* Stop an active backup job
[2193] Fix | Delete
*
[2194] Fix | Delete
* @param String $job_id - job ID of the job to stop
[2195] Fix | Delete
*
[2196] Fix | Delete
* @return Array - information on the outcome of the attempt
[2197] Fix | Delete
*/
[2198] Fix | Delete
public function activejobs_delete($job_id) {
[2199] Fix | Delete
[2200] Fix | Delete
if (preg_match("/^[0-9a-f]{12}$/", $job_id)) {
[2201] Fix | Delete
[2202] Fix | Delete
global $updraftplus;
[2203] Fix | Delete
$cron = get_option('cron', array());
[2204] Fix | Delete
$found_it = false;
[2205] Fix | Delete
[2206] Fix | Delete
$jobdata = $updraftplus->jobdata_getarray($job_id);
[2207] Fix | Delete
[2208] Fix | Delete
if (!empty($jobdata['clone_job']) && !empty($jobdata['clone_id']) && !empty($jobdata['secret_token'])) {
[2209] Fix | Delete
$clone_id = $jobdata['clone_id'];
[2210] Fix | Delete
$secret_token = $jobdata['secret_token'];
[2211] Fix | Delete
$updraftplus->get_updraftplus_clone()->clone_failed_delete(array('clone_id' => $clone_id, 'secret_token' => $secret_token));
[2212] Fix | Delete
}
[2213] Fix | Delete
[2214] Fix | Delete
$updraft_dir = $updraftplus->backups_dir_location();
[2215] Fix | Delete
if (file_exists($updraft_dir.'/log.'.$job_id.'.txt')) touch($updraft_dir.'/deleteflag-'.$job_id.'.txt');
[2216] Fix | Delete
[2217] Fix | Delete
foreach ($cron as $time => $job) {
[2218] Fix | Delete
if (!isset($job['updraft_backup_resume'])) continue;
[2219] Fix | Delete
foreach ($job['updraft_backup_resume'] as $hook => $info) {
[2220] Fix | Delete
if (isset($info['args'][1]) && $info['args'][1] == $job_id) {
[2221] Fix | Delete
$args = $cron[$time]['updraft_backup_resume'][$hook]['args'];
[2222] Fix | Delete
wp_unschedule_event($time, 'updraft_backup_resume', $args);
[2223] Fix | Delete
if (!$found_it) return array('ok' => 'Y', 'c' => 'deleted', 'm' => __('Job deleted', 'updraftplus'));
[2224] Fix | Delete
$found_it = true;
[2225] Fix | Delete
}
[2226] Fix | Delete
}
[2227] Fix | Delete
}
[2228] Fix | Delete
}
[2229] Fix | Delete
[2230] Fix | Delete
if (!$found_it) return array('ok' => 'N', 'c' => 'not_found', 'm' => __('Could not find that job - perhaps it has already finished?', 'updraftplus'));
[2231] Fix | Delete
[2232] Fix | Delete
}
[2233] Fix | Delete
[2234] Fix | Delete
/**
[2235] Fix | Delete
* Input: an array of items
[2236] Fix | Delete
* Each item is in the format: <base>,<timestamp>,<type>(,<findex>)
[2237] Fix | Delete
* The 'base' is not for us: we just pass it straight back
[2238] Fix | Delete
*
[2239] Fix | Delete
* @param array $downloaders Array of Items to download
[2240] Fix | Delete
* @return array
[2241] Fix | Delete
*/
[2242] Fix | Delete
public function get_download_statuses($downloaders) {
[2243] Fix | Delete
global $updraftplus;
[2244] Fix | Delete
$download_status = array();
[2245] Fix | Delete
foreach ($downloaders as $downloader) {
[2246] Fix | Delete
// prefix, timestamp, entity, index
[2247] Fix | Delete
if (preg_match('/^([^,]+),(\d+),([-a-z]+|db[0-9]+),(\d+)$/', $downloader, $matches)) {
[2248] Fix | Delete
$findex = (empty($matches[4])) ? '0' : $matches[4];
[2249] Fix | Delete
$updraftplus->nonce = dechex($matches[2]).$findex.substr(md5($matches[3]), 0, 3);
[2250] Fix | Delete
$updraftplus->jobdata_reset();
[2251] Fix | Delete
$status = $this->download_status($matches[2], $matches[3], $matches[4]);
[2252] Fix | Delete
if (is_array($status)) {
[2253] Fix | Delete
$status['base'] = $matches[1];
[2254] Fix | Delete
$status['timestamp'] = $matches[2];
[2255] Fix | Delete
$status['what'] = $matches[3];
[2256] Fix | Delete
$status['findex'] = $findex;
[2257] Fix | Delete
$download_status[] = $status;
[2258] Fix | Delete
}
[2259] Fix | Delete
}
[2260] Fix | Delete
}
[2261] Fix | Delete
return $download_status;
[2262] Fix | Delete
}
[2263] Fix | Delete
[2264] Fix | Delete
/**
[2265] Fix | Delete
* Get, as HTML output, a list of active jobs
[2266] Fix | Delete
*
[2267] Fix | Delete
* @param Array $request - details on the request being made (e.g. extra info to include)
[2268] Fix | Delete
*
[2269] Fix | Delete
* @return String
[2270] Fix | Delete
*/
[2271] Fix | Delete
public function get_activejobs_list($request) {
[2272] Fix | Delete
[2273] Fix | Delete
global $updraftplus;
[2274] Fix | Delete
[2275] Fix | Delete
$download_status = empty($request['downloaders']) ? array() : $this->get_download_statuses(explode(':', $request['downloaders']));
[2276] Fix | Delete
[2277] Fix | Delete
if (!empty($request['oneshot'])) {
[2278] Fix | Delete
$job_id = get_site_option('updraft_oneshotnonce', false);
[2279] Fix | Delete
// print_active_job() for one-shot jobs that aren't in cron
[2280] Fix | Delete
$active_jobs = (false === $job_id) ? '' : $this->print_active_job($job_id, true);
[2281] Fix | Delete
} elseif (!empty($request['thisjobonly'])) {
[2282] Fix | Delete
// print_active_jobs() is for resumable jobs where we want the cron info to be included in the output
[2283] Fix | Delete
$active_jobs = $this->print_active_jobs($request['thisjobonly']);
[2284] Fix | Delete
} else {
[2285] Fix | Delete
$active_jobs = $this->print_active_jobs();
[2286] Fix | Delete
}
[2287] Fix | Delete
$logupdate_array = array();
[2288] Fix | Delete
if (!empty($request['log_fetch'])) {
[2289] Fix | Delete
if (isset($request['log_nonce'])) {
[2290] Fix | Delete
$log_nonce = $request['log_nonce'];
[2291] Fix | Delete
$log_pointer = isset($request['log_pointer']) ? absint($request['log_pointer']) : 0;
[2292] Fix | Delete
$logupdate_array = $this->fetch_log($log_nonce, $log_pointer);
[2293] Fix | Delete
}
[2294] Fix | Delete
}
[2295] Fix | Delete
$res = array(
[2296] Fix | Delete
// We allow the front-end to decide what to do if there's nothing logged - we used to (up to 1.11.29) send a pre-defined message
[2297] Fix | Delete
'l' => htmlspecialchars(UpdraftPlus_Options::get_updraft_lastmessage()),
[2298] Fix | Delete
'j' => $active_jobs,
[2299] Fix | Delete
'ds' => $download_status,
[2300] Fix | Delete
'u' => $logupdate_array,
[2301] Fix | Delete
'automatic_updates' => $updraftplus->is_automatic_updating_enabled()
[2302] Fix | Delete
);
[2303] Fix | Delete
[2304] Fix | Delete
$res['hosting_restriction'] = $updraftplus->is_hosting_backup_limit_reached();
[2305] Fix | Delete
[2306] Fix | Delete
return $res;
[2307] Fix | Delete
}
[2308] Fix | Delete
[2309] Fix | Delete
/**
[2310] Fix | Delete
* Start a new backup
[2311] Fix | Delete
*
[2312] Fix | Delete
* @param Array $request
[2313] Fix | Delete
* @param Boolean|Callable $close_connection_callable
[2314] Fix | Delete
*/
[2315] Fix | Delete
public function request_backupnow($request, $close_connection_callable = false) {
[2316] Fix | Delete
global $updraftplus;
[2317] Fix | Delete
[2318] Fix | Delete
$abort_before_booting = false;
[2319] Fix | Delete
$backupnow_nocloud = !empty($request['backupnow_nocloud']);
[2320] Fix | Delete
[2321] Fix | Delete
$request['incremental'] = !empty($request['incremental']);
[2322] Fix | Delete
[2323] Fix | Delete
$entities = !empty($request['onlythisfileentity']) ? explode(',', $request['onlythisfileentity']) : array();
[2324] Fix | Delete
[2325] Fix | Delete
$remote_storage_instances = array();
[2326] Fix | Delete
[2327] Fix | Delete
// if only_these_cloud_services is not an array then all connected remote storage locations are being backed up to and we don't need to do this
[2328] Fix | Delete
if (!empty($request['only_these_cloud_services']) && is_array($request['only_these_cloud_services'])) {
[2329] Fix | Delete
$remote_storage_locations = $request['only_these_cloud_services'];
[2330] Fix | Delete
[2331] Fix | Delete
foreach ($remote_storage_locations as $key => $value) {
[2332] Fix | Delete
/*
[2333] Fix | Delete
This name key inside the value array is the remote storage method name prefixed by 31 characters (updraft_include_remote_service_) so we need to remove them to get the actual name, then the value key inside the value array has the instance id.
[2334] Fix | Delete
*/
[2335] Fix | Delete
$remote_storage_instances[substr($value['name'], 31)][$key] = $value['value'];
[2336] Fix | Delete
}
[2337] Fix | Delete
}
[2338] Fix | Delete
[2339] Fix | Delete
$incremental = $request['incremental'] ? apply_filters('updraftplus_prepare_incremental_run', false, $entities) : false;
[2340] Fix | Delete
[2341] Fix | Delete
// The call to backup_time_nonce() allows us to know the nonce in advance, and return it
[2342] Fix | Delete
$nonce = $updraftplus->backup_time_nonce();
[2343] Fix | Delete
[2344] Fix | Delete
$msg = array(
[2345] Fix | Delete
'nonce' => $nonce,
[2346] Fix | Delete
'm' => apply_filters('updraftplus_backupnow_start_message', '<strong>'.__('Start backup', 'updraftplus').':</strong> '.htmlspecialchars(__('OK. You should soon see activity in the "Last log message" field below.', 'updraftplus')), $nonce)
[2347] Fix | Delete
);
[2348] Fix | Delete
[2349] Fix | Delete
if (!empty($request['backup_nonce']) && 'current' != $request['backup_nonce']) $msg['nonce'] = $request['backup_nonce'];
[2350] Fix | Delete
[2351] Fix | Delete
if (!empty($request['incremental']) && !$incremental) {
[2352] Fix | Delete
$msg = array(
[2353] Fix | Delete
'error' => __('No suitable backup set (that already contains a full backup of all the requested file component types) was found, to add increments to. Aborting this backup.', 'updraftplus')
[2354] Fix | Delete
);
[2355] Fix | Delete
$abort_before_booting = true;
[2356] Fix | Delete
}
[2357] Fix | Delete
[2358] Fix | Delete
if ($close_connection_callable && is_callable($close_connection_callable)) {
[2359] Fix | Delete
call_user_func($close_connection_callable, $msg);
[2360] Fix | Delete
} else {
[2361] Fix | Delete
$updraftplus->close_browser_connection(json_encode($msg));
[2362] Fix | Delete
}
[2363] Fix | Delete
[2364] Fix | Delete
if ($abort_before_booting) die;
[2365] Fix | Delete
[2366] Fix | Delete
$options = array('nocloud' => $backupnow_nocloud, 'use_nonce' => $nonce);
[2367] Fix | Delete
if (!empty($request['onlythisfileentity']) && is_string($request['onlythisfileentity'])) {
[2368] Fix | Delete
// Something to see in the 'last log' field when it first appears, before the backup actually starts
[2369] Fix | Delete
$updraftplus->log(__('Start backup', 'updraftplus'));
[2370] Fix | Delete
$options['restrict_files_to_override'] = explode(',', $request['onlythisfileentity']);
[2371] Fix | Delete
}
[2372] Fix | Delete
[2373] Fix | Delete
if ($request['incremental'] && !$incremental) {
[2374] Fix | Delete
$updraftplus->log('An incremental backup was requested but no suitable backup found to add increments to; will proceed with a new backup');
[2375] Fix | Delete
$request['incremental'] = false;
[2376] Fix | Delete
}
[2377] Fix | Delete
[2378] Fix | Delete
if (!empty($request['extradata'])) $options['extradata'] = $request['extradata'];
[2379] Fix | Delete
[2380] Fix | Delete
if (!empty($remote_storage_instances)) $options['remote_storage_instances'] = $remote_storage_instances;
[2381] Fix | Delete
[2382] Fix | Delete
$options['always_keep'] = !empty($request['always_keep']);
[2383] Fix | Delete
[2384] Fix | Delete
$event = empty($request['backupnow_nofiles']) ? (empty($request['backupnow_nodb']) ? 'updraft_backupnow_backup_all' : 'updraft_backupnow_backup') : 'updraft_backupnow_backup_database';
[2385] Fix | Delete
[2386] Fix | Delete
do_action($event, apply_filters('updraft_backupnow_options', $options, $request));
[2387] Fix | Delete
}
[2388] Fix | Delete
[2389] Fix | Delete
/**
[2390] Fix | Delete
* Get the contents of a log file
[2391] Fix | Delete
*
[2392] Fix | Delete
* @param String $backup_nonce - the backup id; or empty, for the most recently modified
[2393] Fix | Delete
* @param Integer $log_pointer - the byte count to fetch from
[2394] Fix | Delete
* @param String $output_format - the format to return in; allowed as 'html' (which will escape HTML entities in what is returned) and 'raw'
[2395] Fix | Delete
*
[2396] Fix | Delete
* @return String
[2397] Fix | Delete
*/
[2398] Fix | Delete
public function fetch_log($backup_nonce = '', $log_pointer = 0, $output_format = 'html') {
[2399] Fix | Delete
global $updraftplus;
[2400] Fix | Delete
[2401] Fix | Delete
if (empty($backup_nonce)) {
[2402] Fix | Delete
list($mod_time, $log_file, $nonce) = $updraftplus->last_modified_log();// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
[2403] Fix | Delete
} else {
[2404] Fix | Delete
$nonce = $backup_nonce;
[2405] Fix | Delete
}
[2406] Fix | Delete
[2407] Fix | Delete
if (!preg_match('/^[0-9a-f]+$/', $nonce)) die('Security check');
[2408] Fix | Delete
[2409] Fix | Delete
$log_content = '';
[2410] Fix | Delete
$new_pointer = $log_pointer;
[2411] Fix | Delete
[2412] Fix | Delete
if (!empty($nonce)) {
[2413] Fix | Delete
$updraft_dir = $updraftplus->backups_dir_location();
[2414] Fix | Delete
[2415] Fix | Delete
$potential_log_file = $updraft_dir."/log.".$nonce.".txt";
[2416] Fix | Delete
[2417] Fix | Delete
if (is_readable($potential_log_file)) {
[2418] Fix | Delete
[2419] Fix | Delete
$templog_array = array();
[2420] Fix | Delete
$log_file = fopen($potential_log_file, "r");
[2421] Fix | Delete
if ($log_pointer > 0) fseek($log_file, $log_pointer);
[2422] Fix | Delete
[2423] Fix | Delete
while (($buffer = fgets($log_file, 4096)) !== false) {
[2424] Fix | Delete
$templog_array[] = $buffer;
[2425] Fix | Delete
}
[2426] Fix | Delete
if (!feof($log_file)) {
[2427] Fix | Delete
$templog_array[] = __('Error: unexpected file read fail', 'updraftplus');
[2428] Fix | Delete
}
[2429] Fix | Delete
[2430] Fix | Delete
$new_pointer = ftell($log_file);
[2431] Fix | Delete
$log_content = implode("", $templog_array);
[2432] Fix | Delete
[2433] Fix | Delete
[2434] Fix | Delete
} else {
[2435] Fix | Delete
$log_content .= __('The log file could not be read.', 'updraftplus');
[2436] Fix | Delete
}
[2437] Fix | Delete
[2438] Fix | Delete
} else {
[2439] Fix | Delete
$log_content .= __('The log file could not be read.', 'updraftplus');
[2440] Fix | Delete
}
[2441] Fix | Delete
[2442] Fix | Delete
if ('html' == $output_format) $log_content = htmlspecialchars($log_content);
[2443] Fix | Delete
[2444] Fix | Delete
$ret_array = array(
[2445] Fix | Delete
'log' => $log_content,
[2446] Fix | Delete
'nonce' => $nonce,
[2447] Fix | Delete
'pointer' => $new_pointer
[2448] Fix | Delete
);
[2449] Fix | Delete
[2450] Fix | Delete
return $ret_array;
[2451] Fix | Delete
}
[2452] Fix | Delete
[2453] Fix | Delete
/**
[2454] Fix | Delete
* Get a count for the number of overdue cron jobs
[2455] Fix | Delete
*
[2456] Fix | Delete
* @return Integer - how many cron jobs are overdue
[2457] Fix | Delete
*/
[2458] Fix | Delete
public function howmany_overdue_crons() {
[2459] Fix | Delete
$how_many_overdue = 0;
[2460] Fix | Delete
if (function_exists('_get_cron_array') || (is_file(ABSPATH.WPINC.'/cron.php') && include_once(ABSPATH.WPINC.'/cron.php') && function_exists('_get_cron_array'))) {
[2461] Fix | Delete
$crons = _get_cron_array();
[2462] Fix | Delete
if (is_array($crons)) {
[2463] Fix | Delete
$timenow = time();
[2464] Fix | Delete
foreach ($crons as $jt => $job) {
[2465] Fix | Delete
if ($jt < $timenow) $how_many_overdue++;
[2466] Fix | Delete
}
[2467] Fix | Delete
}
[2468] Fix | Delete
}
[2469] Fix | Delete
return $how_many_overdue;
[2470] Fix | Delete
}
[2471] Fix | Delete
[2472] Fix | Delete
public function get_php_errors($errno, $errstr, $errfile, $errline) {
[2473] Fix | Delete
global $updraftplus;
[2474] Fix | Delete
if (0 == error_reporting()) return true;
[2475] Fix | Delete
$logline = $updraftplus->php_error_to_logline($errno, $errstr, $errfile, $errline);
[2476] Fix | Delete
if (false !== $logline) $this->logged[] = $logline;
[2477] Fix | Delete
// Don't pass it up the chain (since it's going to be output to the user always)
[2478] Fix | Delete
return true;
[2479] Fix | Delete
}
[2480] Fix | Delete
[2481] Fix | Delete
private function download_status($timestamp, $type, $findex) {
[2482] Fix | Delete
global $updraftplus;
[2483] Fix | Delete
$response = array('m' => $updraftplus->jobdata_get('dlmessage_'.$timestamp.'_'.$type.'_'.$findex).'<br>');
[2484] Fix | Delete
if ($file = $updraftplus->jobdata_get('dlfile_'.$timestamp.'_'.$type.'_'.$findex)) {
[2485] Fix | Delete
if ('failed' == $file) {
[2486] Fix | Delete
$response['e'] = __('Download failed', 'updraftplus').'<br>';
[2487] Fix | Delete
$response['failed'] = true;
[2488] Fix | Delete
$errs = $updraftplus->jobdata_get('dlerrors_'.$timestamp.'_'.$type.'_'.$findex);
[2489] Fix | Delete
if (is_array($errs) && !empty($errs)) {
[2490] Fix | Delete
$response['e'] .= '<ul class="disc">';
[2491] Fix | Delete
foreach ($errs as $err) {
[2492] Fix | Delete
if (is_array($err)) {
[2493] Fix | Delete
$response['e'] .= '<li>'.htmlspecialchars($err['message']).'</li>';
[2494] Fix | Delete
} else {
[2495] Fix | Delete
$response['e'] .= '<li>'.htmlspecialchars($err).'</li>';
[2496] Fix | Delete
}
[2497] Fix | Delete
}
[2498] Fix | Delete
$response['e'] .= '</ul>';
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function