Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp...
File: admin.php
$this->setup_all_admin_notices_global($service);
[5500] Fix | Delete
$this->setup_all_admin_notices_udonly($service);
[5501] Fix | Delete
[5502] Fix | Delete
do_action('all_admin_notices');
[5503] Fix | Delete
[5504] Fix | Delete
if (!$really_is_writable) { // Check if writable
[5505] Fix | Delete
$this->show_admin_warning_unwritable();
[5506] Fix | Delete
}
[5507] Fix | Delete
[5508] Fix | Delete
if ($return_array['saved']) { //
[5509] Fix | Delete
$this->show_admin_warning(__('Your settings have been saved.', 'updraftplus'), 'updated fade');
[5510] Fix | Delete
} else {
[5511] Fix | Delete
if (isset($return_array['error_message'])) {
[5512] Fix | Delete
$this->show_admin_warning($return_array['error_message'], 'error');
[5513] Fix | Delete
} else {
[5514] Fix | Delete
$this->show_admin_warning(__('Your settings failed to save. Please refresh the settings page and try again', 'updraftplus'), 'error');
[5515] Fix | Delete
}
[5516] Fix | Delete
}
[5517] Fix | Delete
[5518] Fix | Delete
$messages_output = ob_get_contents();
[5519] Fix | Delete
[5520] Fix | Delete
ob_clean();
[5521] Fix | Delete
[5522] Fix | Delete
// Backup schedule output
[5523] Fix | Delete
$this->next_scheduled_backups_output('line');
[5524] Fix | Delete
[5525] Fix | Delete
$scheduled_output = ob_get_clean();
[5526] Fix | Delete
[5527] Fix | Delete
$return_array['messages'] = $messages_output;
[5528] Fix | Delete
$return_array['scheduled'] = $scheduled_output;
[5529] Fix | Delete
$return_array['files_scheduled'] = $this->next_scheduled_files_backups_output(true);
[5530] Fix | Delete
$return_array['database_scheduled'] = $this->next_scheduled_database_backups_output(true);
[5531] Fix | Delete
[5532] Fix | Delete
[5533] Fix | Delete
// Add the updated options to the return message, so we can update on screen
[5534] Fix | Delete
return $return_array;
[5535] Fix | Delete
[5536] Fix | Delete
}
[5537] Fix | Delete
[5538] Fix | Delete
/**
[5539] Fix | Delete
* Authenticate remote storage instance
[5540] Fix | Delete
*
[5541] Fix | Delete
* @param array - $data It consists of below key elements:
[5542] Fix | Delete
* $remote_method - Remote storage service
[5543] Fix | Delete
* $instance_id - Remote storage instance id
[5544] Fix | Delete
* @return array An array response containing the status of the authentication
[5545] Fix | Delete
*/
[5546] Fix | Delete
public function auth_remote_method($data) {
[5547] Fix | Delete
global $updraftplus;
[5548] Fix | Delete
[5549] Fix | Delete
$response = array();
[5550] Fix | Delete
[5551] Fix | Delete
if (isset($data['remote_method']) && isset($data['instance_id'])) {
[5552] Fix | Delete
$response['result'] = 'success';
[5553] Fix | Delete
$remote_method = $data['remote_method'];
[5554] Fix | Delete
$instance_id = $data['instance_id'];
[5555] Fix | Delete
[5556] Fix | Delete
$storage_objects_and_ids = UpdraftPlus_Storage_Methods_Interface::get_storage_objects_and_ids(array($remote_method));
[5557] Fix | Delete
[5558] Fix | Delete
try {
[5559] Fix | Delete
$storage_objects_and_ids[$remote_method]['object']->authenticate_storage($instance_id);
[5560] Fix | Delete
} catch (Exception $e) {
[5561] Fix | Delete
$response['result'] = 'error';
[5562] Fix | Delete
$response['message'] = $updraftplus->backup_methods[$remote_method] . ' ' . __('authentication error', 'updraftplus') . ' ' . $e->getMessage();
[5563] Fix | Delete
}
[5564] Fix | Delete
} else {
[5565] Fix | Delete
$response['result'] = 'error';
[5566] Fix | Delete
$response['message'] = __('Remote storage method and instance id are required for authentication.', 'updraftplus');
[5567] Fix | Delete
}
[5568] Fix | Delete
[5569] Fix | Delete
return $response;
[5570] Fix | Delete
}
[5571] Fix | Delete
[5572] Fix | Delete
/**
[5573] Fix | Delete
* Deauthenticate remote storage instance
[5574] Fix | Delete
*
[5575] Fix | Delete
* @param array - $data It consists of below key elements:
[5576] Fix | Delete
* $remote_method - Remote storage service
[5577] Fix | Delete
* $instance_id - Remote storage instance id
[5578] Fix | Delete
* @return array An array response containing the status of the deauthentication
[5579] Fix | Delete
*/
[5580] Fix | Delete
public function deauth_remote_method($data) {
[5581] Fix | Delete
global $updraftplus;
[5582] Fix | Delete
[5583] Fix | Delete
$response = array();
[5584] Fix | Delete
[5585] Fix | Delete
if (isset($data['remote_method']) && isset($data['instance_id'])) {
[5586] Fix | Delete
$response['result'] = 'success';
[5587] Fix | Delete
$remote_method = $data['remote_method'];
[5588] Fix | Delete
$instance_id = $data['instance_id'];
[5589] Fix | Delete
[5590] Fix | Delete
$storage_objects_and_ids = UpdraftPlus_Storage_Methods_Interface::get_storage_objects_and_ids(array($remote_method));
[5591] Fix | Delete
[5592] Fix | Delete
try {
[5593] Fix | Delete
$storage_objects_and_ids[$remote_method]['object']->deauthenticate_storage($instance_id);
[5594] Fix | Delete
} catch (Exception $e) {
[5595] Fix | Delete
$response['result'] = 'error';
[5596] Fix | Delete
$response['message'] = $updraftplus->backup_methods[$remote_method] . ' deauthentication error ' . $e->getMessage();
[5597] Fix | Delete
}
[5598] Fix | Delete
} else {
[5599] Fix | Delete
$response['result'] = 'error';
[5600] Fix | Delete
$response['message'] = 'Remote storage method and instance id are required for deauthentication.';
[5601] Fix | Delete
}
[5602] Fix | Delete
[5603] Fix | Delete
return $response;
[5604] Fix | Delete
}
[5605] Fix | Delete
[5606] Fix | Delete
/**
[5607] Fix | Delete
* A method to remove UpdraftPlus settings from the options table.
[5608] Fix | Delete
*
[5609] Fix | Delete
* @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.
[5610] Fix | Delete
* @return boolean
[5611] Fix | Delete
*/
[5612] Fix | Delete
public function wipe_settings($wipe_all_settings = true) {
[5613] Fix | Delete
[5614] Fix | Delete
global $updraftplus;
[5615] Fix | Delete
[5616] Fix | Delete
$settings = $updraftplus->get_settings_keys();
[5617] Fix | Delete
[5618] Fix | Delete
// 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.
[5619] Fix | Delete
if (false == $wipe_all_settings) {
[5620] Fix | Delete
$key = array_search('updraft_central_localkeys', $settings);
[5621] Fix | Delete
unset($settings[$key]);
[5622] Fix | Delete
}
[5623] Fix | Delete
[5624] Fix | Delete
foreach ($settings as $s) UpdraftPlus_Options::delete_updraft_option($s);
[5625] Fix | Delete
[5626] Fix | Delete
if (is_multisite()) $updraftplus->wipe_state_data(true, 'sitemeta');
[5627] Fix | Delete
$updraftplus->wipe_state_data(true);
[5628] Fix | Delete
[5629] Fix | Delete
$site_options = array('updraft_oneshotnonce');
[5630] Fix | Delete
foreach ($site_options as $s) delete_site_option($s);
[5631] Fix | Delete
[5632] Fix | Delete
$this->show_admin_warning(__("Your settings have been wiped.", 'updraftplus'));
[5633] Fix | Delete
[5634] Fix | Delete
return true;
[5635] Fix | Delete
}
[5636] Fix | Delete
[5637] Fix | Delete
/**
[5638] Fix | Delete
* This get the details for updraft vault and to be used globally
[5639] Fix | Delete
*
[5640] Fix | Delete
* @param string $instance_id - the instance_id of the current instance being used
[5641] Fix | Delete
* @return object - the UpdraftVault option setup to use the passed in instance id or if one wasn't passed then use the default set of options
[5642] Fix | Delete
*/
[5643] Fix | Delete
public function get_updraftvault($instance_id = '') {
[5644] Fix | Delete
$storage_objects_and_ids = UpdraftPlus_Storage_Methods_Interface::get_storage_objects_and_ids(array('updraftvault'));
[5645] Fix | Delete
[5646] Fix | Delete
if (isset($storage_objects_and_ids['updraftvault']['instance_settings'][$instance_id])) {
[5647] Fix | Delete
$opts = $storage_objects_and_ids['updraftvault']['instance_settings'][$instance_id];
[5648] Fix | Delete
$vault = $storage_objects_and_ids['updraftvault']['object'];
[5649] Fix | Delete
$vault->set_options($opts, false, $instance_id);
[5650] Fix | Delete
} else {
[5651] Fix | Delete
include_once(UPDRAFTPLUS_DIR.'/methods/updraftvault.php');
[5652] Fix | Delete
$vault = new UpdraftPlus_BackupModule_updraftvault();
[5653] Fix | Delete
}
[5654] Fix | Delete
[5655] Fix | Delete
return $vault;
[5656] Fix | Delete
}
[5657] Fix | Delete
[5658] Fix | Delete
/**
[5659] Fix | Delete
* http_get will allow the HTTP Fetch execute available in advanced tools
[5660] Fix | Delete
*
[5661] Fix | Delete
* @param String $uri Specific URL passed to curl
[5662] Fix | Delete
* @param Boolean $curl True or False if cURL is to be used
[5663] Fix | Delete
* @return String - JSON encoded results
[5664] Fix | Delete
*/
[5665] Fix | Delete
public function http_get($uri = null, $curl = false) {
[5666] Fix | Delete
[5667] Fix | Delete
if (!preg_match('/^https?/', $uri)) return json_encode(array('e' => 'Non-http URL specified'));
[5668] Fix | Delete
[5669] Fix | Delete
if ($curl) {
[5670] Fix | Delete
if (!function_exists('curl_exec')) {
[5671] Fix | Delete
return json_encode(array('e' => 'No Curl installed'));
[5672] Fix | Delete
die;
[5673] Fix | Delete
}
[5674] Fix | Delete
$ch = curl_init();
[5675] Fix | Delete
curl_setopt($ch, CURLOPT_URL, $uri);
[5676] Fix | Delete
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
[5677] Fix | Delete
curl_setopt($ch, CURLOPT_FAILONERROR, true);
[5678] Fix | Delete
curl_setopt($ch, CURLOPT_HEADER, false);
[5679] Fix | Delete
curl_setopt($ch, CURLOPT_VERBOSE, true);
[5680] Fix | Delete
curl_setopt($ch, CURLOPT_STDERR, $output = fopen('php://temp', "w+"));
[5681] Fix | Delete
$response = curl_exec($ch);
[5682] Fix | Delete
$error = curl_error($ch);
[5683] Fix | Delete
$getinfo = curl_getinfo($ch);
[5684] Fix | Delete
curl_close($ch);
[5685] Fix | Delete
[5686] Fix | Delete
rewind($output);
[5687] Fix | Delete
$verb = stream_get_contents($output);
[5688] Fix | Delete
[5689] Fix | Delete
$resp = array();
[5690] Fix | Delete
if (false === $response) {
[5691] Fix | Delete
$resp['e'] = htmlspecialchars($error);
[5692] Fix | Delete
}
[5693] Fix | Delete
$resp['r'] = (empty($response)) ? '' : htmlspecialchars(substr($response, 0, 2048));
[5694] Fix | Delete
[5695] Fix | Delete
if (!empty($verb)) $resp['r'] = htmlspecialchars($verb)."\n\n".$resp['r'];
[5696] Fix | Delete
[5697] Fix | Delete
// Extra info returned for Central
[5698] Fix | Delete
$resp['verb'] = $verb;
[5699] Fix | Delete
$resp['response'] = $response;
[5700] Fix | Delete
$resp['status'] = $getinfo;
[5701] Fix | Delete
[5702] Fix | Delete
return json_encode($resp);
[5703] Fix | Delete
} else {
[5704] Fix | Delete
$response = wp_remote_get($uri, array('timeout' => 10));
[5705] Fix | Delete
if (is_wp_error($response)) {
[5706] Fix | Delete
return json_encode(array('e' => htmlspecialchars($response->get_error_message())));
[5707] Fix | Delete
}
[5708] Fix | Delete
return json_encode(
[5709] Fix | Delete
array(
[5710] Fix | Delete
'r' => wp_remote_retrieve_response_code($response).': '.htmlspecialchars(substr(wp_remote_retrieve_body($response), 0, 2048)),
[5711] Fix | Delete
'code' => wp_remote_retrieve_response_code($response),
[5712] Fix | Delete
'html_response' => htmlspecialchars(substr(wp_remote_retrieve_body($response), 0, 2048)),
[5713] Fix | Delete
'response' => $response
[5714] Fix | Delete
)
[5715] Fix | Delete
);
[5716] Fix | Delete
}
[5717] Fix | Delete
}
[5718] Fix | Delete
[5719] Fix | Delete
/**
[5720] Fix | Delete
* This will return all the details for raw backup and file list, in HTML format
[5721] Fix | Delete
*
[5722] Fix | Delete
* @param Boolean $no_pre_tags - if set, then <pre></pre> tags will be removed from the output
[5723] Fix | Delete
*
[5724] Fix | Delete
* @return String
[5725] Fix | Delete
*/
[5726] Fix | Delete
public function show_raw_backups($no_pre_tags = false) {
[5727] Fix | Delete
global $updraftplus;
[5728] Fix | Delete
[5729] Fix | Delete
$response = array();
[5730] Fix | Delete
[5731] Fix | Delete
$response['html'] = '<h3 id="ud-debuginfo-rawbackups">'.__('Known backups (raw)', 'updraftplus').'</h3><pre>';
[5732] Fix | Delete
ob_start();
[5733] Fix | Delete
$history = UpdraftPlus_Backup_History::get_history();
[5734] Fix | Delete
var_dump($history);
[5735] Fix | Delete
$response["html"] .= ob_get_clean();
[5736] Fix | Delete
$response['html'] .= '</pre>';
[5737] Fix | Delete
[5738] Fix | Delete
$response['html'] .= '<h3 id="ud-debuginfo-files">'.__('Files', 'updraftplus').'</h3><pre>';
[5739] Fix | Delete
$updraft_dir = $updraftplus->backups_dir_location();
[5740] Fix | Delete
$raw_output = array();
[5741] Fix | Delete
$d = dir($updraft_dir);
[5742] Fix | Delete
while (false !== ($entry = $d->read())) {
[5743] Fix | Delete
$fp = $updraft_dir.'/'.$entry;
[5744] Fix | Delete
$mtime = filemtime($fp);
[5745] Fix | Delete
if (is_dir($fp)) {
[5746] Fix | Delete
$size = ' d';
[5747] Fix | Delete
} elseif (is_link($fp)) {
[5748] Fix | Delete
$size = ' l';
[5749] Fix | Delete
} elseif (is_file($fp)) {
[5750] Fix | Delete
$size = sprintf("%8.1f", round(filesize($fp)/1024, 1)).' '.gmdate('r', $mtime);
[5751] Fix | Delete
} else {
[5752] Fix | Delete
$size = ' ?';
[5753] Fix | Delete
}
[5754] Fix | Delete
if (preg_match('/^log\.(.*)\.txt$/', $entry, $lmatch)) $entry = '<a target="_top" href="?action=downloadlog&amp;page=updraftplus&amp;updraftplus_backup_nonce='.htmlspecialchars($lmatch[1]).'">'.$entry.'</a>';
[5755] Fix | Delete
$raw_output[$mtime] = empty($raw_output[$mtime]) ? sprintf("%s %s\n", $size, $entry) : $raw_output[$mtime].sprintf("%s %s\n", $size, $entry);
[5756] Fix | Delete
}
[5757] Fix | Delete
@$d->close();// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
[5758] Fix | Delete
krsort($raw_output, SORT_NUMERIC);
[5759] Fix | Delete
[5760] Fix | Delete
foreach ($raw_output as $line) {
[5761] Fix | Delete
$response['html'] .= $line;
[5762] Fix | Delete
}
[5763] Fix | Delete
[5764] Fix | Delete
$response['html'] .= '</pre>';
[5765] Fix | Delete
[5766] Fix | Delete
$response['html'] .= '<h3 id="ud-debuginfo-options">'.__('Options (raw)', 'updraftplus').'</h3>';
[5767] Fix | Delete
$opts = $updraftplus->get_settings_keys();
[5768] Fix | Delete
asort($opts);
[5769] Fix | Delete
// <tr><th>'.__('Key', 'updraftplus').'</th><th>'.__('Value', 'updraftplus').'</th></tr>
[5770] Fix | Delete
$response['html'] .= '<table><thead></thead><tbody>';
[5771] Fix | Delete
foreach ($opts as $opt) {
[5772] Fix | Delete
$response['html'] .= '<tr><td>'.htmlspecialchars($opt).'</td><td>'.htmlspecialchars(print_r(UpdraftPlus_Options::get_updraft_option($opt), true)).'</td>';
[5773] Fix | Delete
}
[5774] Fix | Delete
[5775] Fix | Delete
// Get the option saved by yahnis-elsts/plugin-update-checker
[5776] Fix | Delete
$response['html'] .= '<tr><td>external_updates-updraftplus</td><td><pre>'.htmlspecialchars(print_r(get_site_option('external_updates-updraftplus'), true)).'</pre></td>';
[5777] Fix | Delete
[5778] Fix | Delete
$response['html'] .= '</tbody></table>';
[5779] Fix | Delete
[5780] Fix | Delete
ob_start();
[5781] Fix | Delete
do_action('updraftplus_showrawinfo');
[5782] Fix | Delete
$response['html'] .= ob_get_clean();
[5783] Fix | Delete
[5784] Fix | Delete
if (true == $no_pre_tags) {
[5785] Fix | Delete
$response['html'] = str_replace('<pre>', '', $response['html']);
[5786] Fix | Delete
$response['html'] = str_replace('</pre>', '', $response['html']);
[5787] Fix | Delete
}
[5788] Fix | Delete
[5789] Fix | Delete
return $response;
[5790] Fix | Delete
}
[5791] Fix | Delete
[5792] Fix | Delete
/**
[5793] Fix | Delete
* This will call any wp_action
[5794] Fix | Delete
*
[5795] Fix | Delete
* @param Array|Null $data The array of data with the vaules for wpaction
[5796] Fix | Delete
* @param Callable|Boolean $close_connection_callable A callable to call to close the browser connection, or true for a default suitable for internal use, or false for none
[5797] Fix | Delete
* @return Array - results
[5798] Fix | Delete
*/
[5799] Fix | Delete
public function call_wp_action($data = null, $close_connection_callable = false) {
[5800] Fix | Delete
global $updraftplus;
[5801] Fix | Delete
[5802] Fix | Delete
ob_start();
[5803] Fix | Delete
[5804] Fix | Delete
$res = '<em>Request received: </em>';
[5805] Fix | Delete
[5806] Fix | Delete
if (preg_match('/^([^:]+)+:(.*)$/', $data['wpaction'], $matches)) {
[5807] Fix | Delete
$action = $matches[1];
[5808] Fix | Delete
if (null === ($args = json_decode($matches[2], true))) {
[5809] Fix | Delete
$res .= "The parameters (should be JSON) could not be decoded";
[5810] Fix | Delete
$action = false;
[5811] Fix | Delete
} else {
[5812] Fix | Delete
if (is_string($args)) $args = array($args);
[5813] Fix | Delete
$res .= "Will despatch action: ".htmlspecialchars($action).", parameters: ".htmlspecialchars(implode(',', $args));
[5814] Fix | Delete
}
[5815] Fix | Delete
} else {
[5816] Fix | Delete
$action = $data['wpaction'];
[5817] Fix | Delete
$res .= "Will despatch action: ".htmlspecialchars($action).", no parameters";
[5818] Fix | Delete
}
[5819] Fix | Delete
[5820] Fix | Delete
ob_get_clean();
[5821] Fix | Delete
[5822] Fix | Delete
// Need to add this as the close browser should only work for UDP
[5823] Fix | Delete
if ($close_connection_callable) {
[5824] Fix | Delete
if (is_callable($close_connection_callable)) {
[5825] Fix | Delete
call_user_func($close_connection_callable, array('r' => $res));
[5826] Fix | Delete
} else {
[5827] Fix | Delete
$updraftplus->close_browser_connection(json_encode(array('r' => $res)));
[5828] Fix | Delete
}
[5829] Fix | Delete
}
[5830] Fix | Delete
[5831] Fix | Delete
if (!empty($action)) {
[5832] Fix | Delete
if (!empty($args)) {
[5833] Fix | Delete
ob_start();
[5834] Fix | Delete
$returned = do_action_ref_array($action, $args);
[5835] Fix | Delete
$output = ob_get_clean();
[5836] Fix | Delete
$res .= " - do_action_ref_array Trigger ";
[5837] Fix | Delete
} else {
[5838] Fix | Delete
ob_start();
[5839] Fix | Delete
do_action($action);
[5840] Fix | Delete
$output = ob_get_contents();
[5841] Fix | Delete
ob_end_clean();
[5842] Fix | Delete
$res .= " - do_action Trigger ";
[5843] Fix | Delete
}
[5844] Fix | Delete
}
[5845] Fix | Delete
$response = array();
[5846] Fix | Delete
$response['response'] = $res;
[5847] Fix | Delete
$response['log'] = $output;
[5848] Fix | Delete
[5849] Fix | Delete
// Check if response is empty
[5850] Fix | Delete
if (!empty($returned)) $response['status'] = $returned;
[5851] Fix | Delete
[5852] Fix | Delete
return $response;
[5853] Fix | Delete
}
[5854] Fix | Delete
[5855] Fix | Delete
/**
[5856] Fix | Delete
* Enqueue JSTree JavaScript and CSS, taking into account whether it is already enqueued, and current debug settings
[5857] Fix | Delete
*/
[5858] Fix | Delete
public function enqueue_jstree() {
[5859] Fix | Delete
global $updraftplus;
[5860] Fix | Delete
[5861] Fix | Delete
static $already_enqueued = false;
[5862] Fix | Delete
if ($already_enqueued) return;
[5863] Fix | Delete
[5864] Fix | Delete
$already_enqueued = true;
[5865] Fix | Delete
$jstree_enqueue_version = $updraftplus->use_unminified_scripts() ? '3.3.12-rc.0'.'.'.time() : '3.3.12-rc.0';
[5866] Fix | Delete
$min_or_not = $updraftplus->use_unminified_scripts() ? '' : '.min';
[5867] Fix | Delete
[5868] Fix | Delete
wp_enqueue_script('jstree', UPDRAFTPLUS_URL.'/includes/jstree/jstree'.$min_or_not.'.js', array('jquery'), $jstree_enqueue_version);
[5869] Fix | Delete
wp_enqueue_style('jstree', UPDRAFTPLUS_URL.'/includes/jstree/themes/default/style'.$min_or_not.'.css', array(), $jstree_enqueue_version);
[5870] Fix | Delete
}
[5871] Fix | Delete
[5872] Fix | Delete
/**
[5873] Fix | Delete
* Detects byte-order mark at the start of common files and change waning message texts
[5874] Fix | Delete
*
[5875] Fix | Delete
* @return string|boolean BOM warning text or false if not bom characters detected
[5876] Fix | Delete
*/
[5877] Fix | Delete
public function get_bom_warning_text() {
[5878] Fix | Delete
$files_to_check = array(
[5879] Fix | Delete
ABSPATH.'wp-config.php',
[5880] Fix | Delete
get_template_directory().DIRECTORY_SEPARATOR.'functions.php',
[5881] Fix | Delete
);
[5882] Fix | Delete
if (is_child_theme()) {
[5883] Fix | Delete
$files_to_check[] = get_stylesheet_directory().DIRECTORY_SEPARATOR.'functions.php';
[5884] Fix | Delete
}
[5885] Fix | Delete
$corrupted_files = array();
[5886] Fix | Delete
foreach ($files_to_check as $file) {
[5887] Fix | Delete
if (!file_exists($file)) continue;
[5888] Fix | Delete
if (false === ($fp = fopen($file, 'r'))) continue;
[5889] Fix | Delete
if (false === ($file_data = fread($fp, 8192)));
[5890] Fix | Delete
fclose($fp);
[5891] Fix | Delete
$substr_file_data = array();
[5892] Fix | Delete
for ($substr_length = 2; $substr_length <= 5; $substr_length++) {
[5893] Fix | Delete
$substr_file_data[$substr_length] = substr($file_data, 0, $substr_length);
[5894] Fix | Delete
}
[5895] Fix | Delete
// Detect UTF-7, UTF-8, UTF-16 (BE), UTF-16 (LE), UTF-32 (BE) & UTF-32 (LE) Byte order marks (BOM)
[5896] Fix | Delete
$bom_decimal_representations = array(
[5897] Fix | Delete
array(43, 47, 118, 56), // UTF-7 (Hexadecimal: 2B 2F 76 38)
[5898] Fix | Delete
array(43, 47, 118, 57), // UTF-7 (Hexadecimal: 2B 2F 76 39)
[5899] Fix | Delete
array(43, 47, 118, 43), // UTF-7 (Hexadecimal: 2B 2F 76 2B)
[5900] Fix | Delete
array(43, 47, 118, 47), // UTF-7 (Hexadecimal: 2B 2F 76 2F)
[5901] Fix | Delete
array(43, 47, 118, 56, 45), // UTF-7 (Hexadecimal: 2B 2F 76 38 2D)
[5902] Fix | Delete
array(239, 187, 191), // UTF-8 (Hexadecimal: 2B 2F 76 38 2D)
[5903] Fix | Delete
array(254, 255), // UTF-16 (BE) (Hexadecimal: FE FF)
[5904] Fix | Delete
array(255, 254), // UTF-16 (LE) (Hexadecimal: FF FE)
[5905] Fix | Delete
array(0, 0, 254, 255), // UTF-32 (BE) (Hexadecimal: 00 00 FE FF)
[5906] Fix | Delete
array(255, 254, 0, 0), // UTF-32 (LE) (Hexadecimal: FF FE 00 00)
[5907] Fix | Delete
);
[5908] Fix | Delete
foreach ($bom_decimal_representations as $bom_decimal_representation) {
[5909] Fix | Delete
$no_of_chars = count($bom_decimal_representation);
[5910] Fix | Delete
array_unshift($bom_decimal_representation, 'C*');
[5911] Fix | Delete
$binary = call_user_func_array('pack', $bom_decimal_representation);
[5912] Fix | Delete
if ($binary == $substr_file_data[$no_of_chars]) {
[5913] Fix | Delete
$corrupted_files[] = $file;
[5914] Fix | Delete
break;
[5915] Fix | Delete
}
[5916] Fix | Delete
}
[5917] Fix | Delete
}
[5918] Fix | Delete
if (empty($corrupted_files)) {
[5919] Fix | Delete
return false;
[5920] Fix | Delete
} else {
[5921] Fix | Delete
$corrupted_files_count = count($corrupted_files);
[5922] Fix | Delete
return '<strong>'.__('Warning', 'updraftplus').':</strong> '.sprintf(_n('The file %s has a "byte order mark" (BOM) at its beginning.', 'The files %s have a "byte order mark" (BOM) at their beginning.', $corrupted_files_count, 'updraftplus'), '<strong>'.implode('</strong>, <strong>', $corrupted_files).'</strong>').' <a href="'.apply_filters('updraftplus_com_link', "https://updraftplus.com/problems-with-extra-white-space/").'" target="_blank">'.__('Follow this link for more information', 'updraftplus').'</a>';
[5923] Fix | Delete
}
[5924] Fix | Delete
}
[5925] Fix | Delete
[5926] Fix | Delete
/**
[5927] Fix | Delete
* Gets an instance of the "UpdraftPlus_UpdraftCentral_Cloud" class which will be
[5928] Fix | Delete
* used to login or register the user to the UpdraftCentral cloud
[5929] Fix | Delete
*
[5930] Fix | Delete
* @return object
[5931] Fix | Delete
*/
[5932] Fix | Delete
public function get_updraftcentral_cloud() {
[5933] Fix | Delete
if (!class_exists('UpdraftPlus_UpdraftCentral_Cloud')) include_once(UPDRAFTPLUS_DIR.'/includes/updraftcentral.php');
[5934] Fix | Delete
return new UpdraftPlus_UpdraftCentral_Cloud();
[5935] Fix | Delete
}
[5936] Fix | Delete
[5937] Fix | Delete
/**
[5938] Fix | Delete
* This function will build and return the UpdraftPlus tempoaray clone ui widget
[5939] Fix | Delete
*
[5940] Fix | Delete
* @param boolean $include_testing_ui - a boolean to indicate if testing-only UI elements should be shown (N.B. they can only work if the user also has testing permissions)
[5941] Fix | Delete
* @param array $supported_wp_versions - an array of supported WordPress versions
[5942] Fix | Delete
* @param array $supported_packages - an array of supported clone packages
[5943] Fix | Delete
* @param array $supported_regions - an array of supported clone regions
[5944] Fix | Delete
* @param string $nearest_region - the user's nearest region
[5945] Fix | Delete
*
[5946] Fix | Delete
* @return string - the clone UI widget
[5947] Fix | Delete
*/
[5948] Fix | Delete
public function updraftplus_clone_ui_widget($include_testing_ui, $supported_wp_versions, $supported_packages, $supported_regions, $nearest_region = '') {
[5949] Fix | Delete
global $updraftplus;
[5950] Fix | Delete
[5951] Fix | Delete
$output = '<p class="updraftplus-option updraftplus-option-inline php-version">';
[5952] Fix | Delete
$output .= '<span class="updraftplus-option-label">'.sprintf(__('%s version:', 'updraftplus'), 'PHP').'</span> ';
[5953] Fix | Delete
$output .= $this->output_select_data($this->php_versions, 'php');
[5954] Fix | Delete
$output .= '</p>';
[5955] Fix | Delete
$output .= '<p class="updraftplus-option updraftplus-option-inline wp-version">';
[5956] Fix | Delete
$output .= ' <span class="updraftplus-option-label">'.sprintf(__('%s version:', 'updraftplus'), 'WordPress').'</span> ';
[5957] Fix | Delete
$output .= $this->output_select_data($this->get_wordpress_versions($supported_wp_versions), 'wp');
[5958] Fix | Delete
$output .= '</p>';
[5959] Fix | Delete
$output .= '<p class="updraftplus-option updraftplus-option-inline region">';
[5960] Fix | Delete
$output .= ' <span class="updraftplus-option-label">'.__('Clone region:', 'updraftplus').'</span> ';
[5961] Fix | Delete
$output .= $this->output_select_data($supported_regions, 'region', $nearest_region);
[5962] Fix | Delete
$output .= '</p>';
[5963] Fix | Delete
[5964] Fix | Delete
$backup_history = UpdraftPlus_Backup_History::get_history();
[5965] Fix | Delete
[5966] Fix | Delete
foreach ($backup_history as $key => $backup) {
[5967] Fix | Delete
$backup_complete = $this->check_backup_is_complete($backup, false, true, false);
[5968] Fix | Delete
$remote_sent = !empty($backup['service']) && ((is_array($backup['service']) && in_array('remotesend', $backup['service'])) || 'remotesend' === $backup['service']);
[5969] Fix | Delete
if (!$backup_complete || $remote_sent) unset($backup_history[$key]);
[5970] Fix | Delete
}
[5971] Fix | Delete
[5972] Fix | Delete
[5973] Fix | Delete
$output .= '<p class="updraftplus-option updraftplus-option-inline updraftclone-backup">';
[5974] Fix | Delete
$output .= ' <span class="updraftplus-option-label">'.__('Clone:', 'updraftplus').'</span> ';
[5975] Fix | Delete
$output .= '<select id="updraftplus_clone_backup_options" name="updraftplus_clone_backup_options">';
[5976] Fix | Delete
$output .= '<option value="current" data-nonce="current" data-timestamp="current" selected="selected">'. __('This current site', 'updraftplus') .'</option>';
[5977] Fix | Delete
$output .= '<option value="wp_only" data-nonce="wp_only" data-timestamp="wp_only">'. __('An empty WordPress install', 'updraftplus') .'</option>';
[5978] Fix | Delete
[5979] Fix | Delete
if (!empty($backup_history)) {
[5980] Fix | Delete
foreach ($backup_history as $key => $backup) {
[5981] Fix | Delete
$total_size = round($updraftplus->get_total_backup_size($backup) / 1073741824, 1);
[5982] Fix | Delete
$pretty_date = get_date_from_gmt(gmdate('Y-m-d H:i:s', (int) $key), 'M d, Y G:i');
[5983] Fix | Delete
$label = isset($backup['label']) ? ' ' . $backup['label'] : '';
[5984] Fix | Delete
$output .= '<option value="'.$key. '" data-nonce="'.$backup['nonce'].'" data-timestamp="'.$key.'" data-size="'.$total_size.'">' . $pretty_date . $label . '</option>';
[5985] Fix | Delete
}
[5986] Fix | Delete
}
[5987] Fix | Delete
$output .= '</select>';
[5988] Fix | Delete
$output .= '</p>';
[5989] Fix | Delete
$output .= '<p class="updraftplus-option updraftplus-option-inline package">';
[5990] Fix | Delete
$output .= ' <span class="updraftplus-option-label">'.__('Clone package', 'updraftplus').' (<a href="'.$updraftplus->get_url('clone_packages').'" target="_blank">'.__('more info', 'updraftplus').'</a>):</span> ';
[5991] Fix | Delete
$output .= '<select id="updraftplus_clone_package_options" name="updraftplus_clone_package_options" data-package_version="starter">';
[5992] Fix | Delete
foreach ($supported_packages as $key => $value) {
[5993] Fix | Delete
$output .= '<option value="'.esc_attr($key).'" data-size="'.esc_attr($value).'"';
[5994] Fix | Delete
if ('starter' == $key) $output .= 'selected="selected"';
[5995] Fix | Delete
$output .= ">".htmlspecialchars($key) . ('starter' == $key ? ' ' . __('(current version)', 'updraftplus') : '')."</option>\n";
[5996] Fix | Delete
}
[5997] Fix | Delete
$output .= '</select>';
[5998] Fix | Delete
$output .= '</p>';
[5999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function