Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp.../methods
File: dreamobjects.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if (!defined('UPDRAFTPLUS_DIR')) die('No direct access allowed.');
[2] Fix | Delete
[3] Fix | Delete
require_once(UPDRAFTPLUS_DIR.'/methods/s3.php');
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Converted to multi-options (Feb 2017-) and previous options conversion removed: Yes
[7] Fix | Delete
*/
[8] Fix | Delete
class UpdraftPlus_BackupModule_dreamobjects extends UpdraftPlus_BackupModule_s3 {
[9] Fix | Delete
[10] Fix | Delete
// This gets populated in the constructor
[11] Fix | Delete
private $dreamobjects_endpoints = array();
[12] Fix | Delete
[13] Fix | Delete
protected $provider_can_use_aws_sdk = false;
[14] Fix | Delete
[15] Fix | Delete
protected $provider_has_regions = true;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Class constructor
[19] Fix | Delete
*/
[20] Fix | Delete
public function __construct() {
[21] Fix | Delete
// When new endpoint introduced in future, Please add it here and also add it as hard coded option for endpoint dropdown in self::get_partial_configuration_template_for_endpoint()
[22] Fix | Delete
// Put the default first
[23] Fix | Delete
$this->dreamobjects_endpoints = array(
[24] Fix | Delete
// Endpoint, then the label
[25] Fix | Delete
'objects-us-east-1.dream.io' => 'objects-us-east-1.dream.io',
[26] Fix | Delete
'objects-us-west-1.dream.io' => 'objects-us-west-1.dream.io ('.__('Closing 1st October 2018', 'updraftplus').')',
[27] Fix | Delete
);
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
protected $use_v4 = false;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Given an S3 object, possibly set the region on it
[34] Fix | Delete
*
[35] Fix | Delete
* @param Object $obj - like UpdraftPlus_S3
[36] Fix | Delete
* @param String $region - or empty to fetch one from saved configuration
[37] Fix | Delete
* @param String $bucket_name
[38] Fix | Delete
*/
[39] Fix | Delete
protected function set_region($obj, $region = '', $bucket_name = '') {// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- $bucket_name
[40] Fix | Delete
[41] Fix | Delete
$config = $this->get_config();
[42] Fix | Delete
$endpoint = ('' != $region && 'n/a' != $region) ? $region : $config['endpoint'];
[43] Fix | Delete
global $updraftplus;
[44] Fix | Delete
if ($updraftplus->backup_time) {
[45] Fix | Delete
$updraftplus->log("Set endpoint: $endpoint");
[46] Fix | Delete
[47] Fix | Delete
// Warning for objects-us-west-1 shutdown in Oct 2018
[48] Fix | Delete
if ('objects-us-west-1.dream.io' == $endpoint) {
[49] Fix | Delete
$updraftplus->log("The objects-us-west-1.dream.io endpoint shut down on the 1st October 2018. The upload is expected to fail. Please see the following article for more information https://help.dreamhost.com/hc/en-us/articles/360002135871-Cluster-migration-procedure", 'warning', 'dreamobjects_west_shutdown');
[50] Fix | Delete
}
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
$obj->setEndpoint($endpoint);
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* This method overrides the parent method and lists the supported features of this remote storage option.
[58] Fix | Delete
*
[59] Fix | Delete
* @return Array - an array of supported features (any features not mentioned are asuumed to not be supported)
[60] Fix | Delete
*/
[61] Fix | Delete
public function get_supported_features() {
[62] Fix | Delete
// This options format is handled via only accessing options via $this->get_options()
[63] Fix | Delete
return array('multi_options', 'config_templates', 'multi_storage', 'conditional_logic');
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Retrieve default options for this remote storage module.
[68] Fix | Delete
*
[69] Fix | Delete
* @return Array - an array of options
[70] Fix | Delete
*/
[71] Fix | Delete
public function get_default_options() {
[72] Fix | Delete
return array(
[73] Fix | Delete
'accesskey' => '',
[74] Fix | Delete
'secretkey' => '',
[75] Fix | Delete
'path' => '',
[76] Fix | Delete
);
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
/**
[80] Fix | Delete
* Retrieve specific options for this remote storage module
[81] Fix | Delete
*
[82] Fix | Delete
* @param Boolean $force_refresh - if set, and if relevant, don't use cached credentials, but get them afresh
[83] Fix | Delete
*
[84] Fix | Delete
* @return Array - an array of options
[85] Fix | Delete
*/
[86] Fix | Delete
protected function get_config($force_refresh = false) {// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- $force_refresh unused
[87] Fix | Delete
$opts = $this->get_options();
[88] Fix | Delete
$opts['whoweare'] = 'DreamObjects';
[89] Fix | Delete
$opts['whoweare_long'] = 'DreamObjects';
[90] Fix | Delete
$opts['key'] = 'dreamobjects';
[91] Fix | Delete
if (empty($opts['endpoint'])) {
[92] Fix | Delete
$endpoints = array_keys($this->dreamobjects_endpoints);
[93] Fix | Delete
$opts['endpoint'] = $endpoints[0];
[94] Fix | Delete
}
[95] Fix | Delete
return $opts;
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
/**
[99] Fix | Delete
* Get the pre configuration template
[100] Fix | Delete
*
[101] Fix | Delete
* @return String - the template
[102] Fix | Delete
*/
[103] Fix | Delete
public function get_pre_configuration_template() {
[104] Fix | Delete
$this->get_pre_configuration_template_engine('dreamobjects', 'DreamObjects', 'DreamObjects', 'DreamObjects', 'https://panel.dreamhost.com/index.cgi?tree=storage.dreamhostobjects', '<a href="https://dreamhost.com/cloud/dreamobjects/" target="_blank"><img alt="DreamObjects" src="'.UPDRAFTPLUS_URL.'/images/dreamobjects_logo-horiz-2013.png"></a>');
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* Get the configuration template
[109] Fix | Delete
*
[110] Fix | Delete
* @return String - the template, ready for substitutions to be carried out
[111] Fix | Delete
*/
[112] Fix | Delete
public function get_configuration_template() {
[113] Fix | Delete
return $this->get_configuration_template_engine('dreamobjects', 'DreamObjects', 'DreamObjects', 'DreamObjects', 'https://panel.dreamhost.com/index.cgi?tree=storage.dreamhostobjects', '<a href="https://dreamhost.com/cloud/dreamobjects/" target="_blank"><img alt="DreamObjects" src="'.UPDRAFTPLUS_URL.'/images/dreamobjects_logo-horiz-2013.png"></a>');
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* Get handlebar partial template string for endpoint of s3 compatible remote storage method. Other child class can extend it.
[118] Fix | Delete
*
[119] Fix | Delete
* @return String the partial template string
[120] Fix | Delete
*/
[121] Fix | Delete
protected function get_partial_configuration_template_for_endpoint() {
[122] Fix | Delete
// When new endpoint introduced in future, Please add it as hard coded option for below endpoint dropdown and also add as array value in private $dreamobjects_endpoints variable
[123] Fix | Delete
return '<tr class="'.$this->get_css_classes().'">
[124] Fix | Delete
<th>'.sprintf(__('%s end-point', 'updraftplus'), 'DreamObjects').'</th>
[125] Fix | Delete
<td>
[126] Fix | Delete
<select data-updraft_settings_test="endpoint" '.$this->output_settings_field_name_and_id('endpoint', true).' style="width: 360px">
[127] Fix | Delete
{{#each dreamobjects_endpoints as |description endpoint|}}
[128] Fix | Delete
<option value="{{endpoint}}" {{#ifeq ../endpoint endpoint}}selected="selected"{{/ifeq}}>{{description}}</option>
[129] Fix | Delete
{{/each}}
[130] Fix | Delete
</select>
[131] Fix | Delete
</td>
[132] Fix | Delete
</tr>';
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
/**
[136] Fix | Delete
* Modifies handerbar template options
[137] Fix | Delete
*
[138] Fix | Delete
* @param array $opts
[139] Fix | Delete
* @return Array - Modified handerbar template options
[140] Fix | Delete
*/
[141] Fix | Delete
public function transform_options_for_template($opts) {
[142] Fix | Delete
$opts['endpoint'] = empty($opts['endpoint']) ? '' : $opts['endpoint'];
[143] Fix | Delete
$opts['dreamobjects_endpoints'] = $this->dreamobjects_endpoints;
[144] Fix | Delete
return $opts;
[145] Fix | Delete
}
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function