PluginProbe
UpdraftPlus: WP Backup & Migration Plugin / 1.22.24
UpdraftPlus: WP Backup & Migration Plugin v1.22.24
1.26.7 1.26.6 1.26.5 1.26.4 1.26.3 1.9.19 1.9.25 1.9.26 1.9.30 1.9.31 1.9.32 1.9.4 1.9.40 1.9.41 1.9.42 1.9.43 1.9.44 1.9.45 1.9.46 1.9.5 1.9.50 1.9.51 1.9.60 1.9.62 1.9.63 All 371 releases
updraftplus / methods / dreamobjects.php

dreamobjects.php in UpdraftPlus: WP Backup & Migration Plugin 1.22.24, at methods/dreamobjects.php

199 lines 10.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('UPDRAFTPLUS_DIR')) die('No direct access allowed.');
4
5 updraft_try_include_file('methods/s3.php', 'require_once');
6
7 /**
8 * Converted to multi-options (Feb 2017-) and previous options conversion removed: Yes
9 */
10 class UpdraftPlus_BackupModule_dreamobjects extends UpdraftPlus_BackupModule_s3 {
11
12 // This gets populated in the constructor
13 private $dreamobjects_endpoints = array();
14
15 protected $provider_can_use_aws_sdk = false;
16
17 protected $provider_has_regions = true;
18
19 /**
20 * Class constructor
21 */
22 public function __construct() {
23 // 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()
24 // Put the default first
25 $this->dreamobjects_endpoints = array(
26 // Endpoint, then the label
27 'objects-us-east-1.dream.io' => 'objects-us-east-1.dream.io',
28 'objects-us-west-1.dream.io' => 'objects-us-west-1.dream.io ('.__('Closing 1st October 2018', 'updraftplus').')',
29 );
30 }
31
32 protected $use_v4 = false;
33
34 /**
35 * Given an S3 object, possibly set the region on it
36 *
37 * @param Object $obj - like UpdraftPlus_S3
38 * @param String $region - or empty to fetch one from saved configuration
39 * @param String $bucket_name
40 */
41 protected function set_region($obj, $region = '', $bucket_name = '') {// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- $bucket_name
42
43 $config = $this->get_config();
44 $endpoint = ('' != $region && 'n/a' != $region) ? $region : $config['endpoint'];
45 global $updraftplus;
46 if ($updraftplus->backup_time) {
47 $updraftplus->log("Set endpoint (".get_class($obj)."): $endpoint");
48
49 // Warning for objects-us-west-1 shutdown in Oct 2018
50 if ('objects-us-west-1.dream.io' == $endpoint) {
51 $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');
52 }
53 }
54
55 $obj->setEndpoint($endpoint);
56 }
57
58 /**
59 * This method overrides the parent method and lists the supported features of this remote storage option.
60 *
61 * @return Array - an array of supported features (any features not mentioned are asuumed to not be supported)
62 */
63 public function get_supported_features() {
64 // This options format is handled via only accessing options via $this->get_options()
65 return array('multi_options', 'config_templates', 'multi_storage', 'conditional_logic');
66 }
67
68 /**
69 * Retrieve default options for this remote storage module.
70 *
71 * @return Array - an array of options
72 */
73 public function get_default_options() {
74 return array(
75 'accesskey' => '',
76 'secretkey' => '',
77 'path' => '',
78 );
79 }
80
81 /**
82 * Retrieve specific options for this remote storage module
83 *
84 * @param Boolean $force_refresh - if set, and if relevant, don't use cached credentials, but get them afresh
85 *
86 * @return Array - an array of options
87 */
88 protected function get_config($force_refresh = false) {// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- $force_refresh unused
89 $opts = $this->get_options();
90 $opts['whoweare'] = 'DreamObjects';
91 $opts['whoweare_long'] = 'DreamObjects';
92 $opts['key'] = 'dreamobjects';
93 if (empty($opts['endpoint'])) {
94 $endpoints = array_keys($this->dreamobjects_endpoints);
95 $opts['endpoint'] = $endpoints[0];
96 }
97 return $opts;
98 }
99
100 /**
101 * Get the pre configuration template
102 */
103 public function get_pre_configuration_template() {
104 ?>
105 <tr class="{{get_template_css_classes false}} {{method_display_name}}_pre_config_container">
106 <td colspan="2">
107 <a href="https://dreamhost.com/cloud/dreamobjects/" target="_blank"><img alt="{{method_display_name}}" src="{{storage_image_url}}"></a>
108 <br>
109 {{{xmlwriter_existence_label}}}
110 {{{simplexmlelement_existence_label}}}
111 {{{curl_existence_label}}}
112 <br>
113 {{{console_url_text}}}
114 <p>
115 <a href="{{updraftplus_com_link}}" target="_blank">{{ssl_error_text}}</a>
116 </p>
117 </td>
118 </tr>
119 <?php
120 }
121
122 /**
123 * Get the configuration template
124 *
125 * @return String - the template, ready for substitutions to be carried out
126 */
127 public function get_configuration_template() {
128 // 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>');
129 ob_start();
130 ?>
131 <tr class="{{get_template_css_classes true}}">
132 <th>{{input_accesskey_label}}:</th>
133 <td><input class="updraft_input--wide udc-wd-600" data-updraft_settings_test="accesskey" type="text" autocomplete="off" id="{{get_template_input_attribute_value "id" "accesskey"}}" name="{{get_template_input_attribute_value "name" "accesskey"}}" value="{{accesskey}}" /></td>
134 </tr>
135 <tr class="{{get_template_css_classes true}}">
136 <th>{{input_secretkey_label}}:</th>
137 <td><input class="updraft_input--wide udc-wd-600" data-updraft_settings_test="secretkey" type="{{input_secretkey_type}}" autocomplete="off" id="{{get_template_input_attribute_value "id" "secretkey"}}" name="{{get_template_input_attribute_value "name" "secretkey"}}" value="{{secretkey}}" /></td>
138 </tr>
139 <tr class="{{get_template_css_classes true}}">
140 <th>{{input_location_label}}:</th>
141 <td>{{method_id}}://<input class="updraft_input--wide udc-wd-600" data-updraft_settings_test="path" title="{{input_location_title}}" type="text" id="{{get_template_input_attribute_value "id" "path"}}" name="{{get_template_input_attribute_value "name" "path"}}" value="{{path}}" /></td>
142 </tr>
143 <tr class="{{get_template_css_classes true}}">
144 <th>{{input_endpoint_label}}</th>
145 <td>
146 <select data-updraft_settings_test="endpoint" id="{{get_template_input_attribute_value "id" "endpoint"}}" name="{{get_template_input_attribute_value "name" "endpoint"}}" style="width: 360px">
147 {{#each dreamobjects_endpoints as |description endpoint|}}
148 <option value="{{endpoint}}" {{#ifeq ../endpoint endpoint}}selected="selected"{{/ifeq}}>{{description}}</option>
149 {{/each}}
150 </select>
151 </td>
152 </tr>
153 {{{get_template_test_button_html "DreamObjects"}}}
154 <?php
155 return ob_get_clean();
156 }
157
158 /**
159 * Modifies handerbar template options
160 *
161 * @param array $opts
162 * @return Array - Modified handerbar template options
163 */
164 public function transform_options_for_template($opts) {
165 $opts['endpoint'] = empty($opts['endpoint']) ? '' : $opts['endpoint'];
166 $opts['dreamobjects_endpoints'] = $this->dreamobjects_endpoints;
167 return $opts;
168 }
169
170 /**
171 * Retrieve a list of template properties by taking all the persistent variables and methods of the parent class and combining them with the ones that are unique to this module, also the necessary HTML element attributes and texts which are also unique only to this backup module
172 * NOTE: Please sanitise all strings that are required to be shown as HTML content on the frontend side (i.e. wp_kses()), or any other technique to prevent XSS attacks that could come via WP hooks
173 *
174 * @return Array an associative array keyed by names that describe themselves as they are
175 */
176 public function get_template_properties() {
177 global $updraftplus, $updraftplus_admin;
178 $properties = array(
179 'storage_image_url' => UPDRAFTPLUS_URL."/images/dreamobjects_logo-horiz-2013.png",
180 'curl_existence_label' => wp_kses($updraftplus_admin->curl_check($updraftplus->backup_methods[$this->get_id()], false, $this->get_id()." hidden-in-updraftcentral", false), $this->allowed_html_for_content_sanitisation()),
181 'simplexmlelement_existence_label' => !apply_filters('updraftplus_dreamobjects_simplexmlelement_exists', class_exists('SimpleXMLElement')) ? wp_kses($updraftplus_admin->show_double_warning('<strong>'.__('Warning', 'updraftplus').':</strong> '.sprintf(__("Your web server's PHP installation does not included a required module (%s). Please contact your web hosting provider's support.", 'updraftplus'), 'SimpleXMLElement').' '.sprintf(__("UpdraftPlus's %s module <strong>requires</strong> %s. Please do not file any support requests; there is no alternative.", 'updraftplus'), $updraftplus->backup_methods[$this->get_id()], 'SimpleXMLElement'), $this->get_id(), false), $this->allowed_html_for_content_sanitisation()) : '',
182 'xmlwriter_existence_label' => !apply_filters('updraftplus_dreamobjects_xmlwriter_exists', 'UpdraftPlus_S3_Compat' != $this->indicate_s3_class() || !class_exists('XMLWriter')) ? wp_kses($updraftplus_admin->show_double_warning('<strong>'.__('Warning', 'updraftplus').':</strong> '. sprintf(__("Your web server's PHP installation does not included a required module (%s). Please contact your web hosting provider's support and ask for them to enable it.", 'updraftplus'), 'XMLWriter'), $this->get_id(), false), $this->allowed_html_for_content_sanitisation()) : '',
183 'console_url_text' => sprintf(__('Get your access key and secret key from your <a href="%s">%s console</a>, then pick a (globally unique - all %s users) bucket name (letters and numbers) (and optionally a path) to use for storage. This bucket will be created for you if it does not already exist.', 'updraftplus'), 'https://panel.dreamhost.com/index.cgi?tree=storage.dreamhostobjects', $updraftplus->backup_methods[$this->get_id()], $updraftplus->backup_methods[$this->get_id()]),
184 'updraftplus_com_link' => apply_filters("updraftplus_com_link", "https://updraftplus.com/faqs/i-get-ssl-certificate-errors-when-backing-up-andor-restoring/"),
185 'ssl_error_text' => __('If you see errors about SSL certificates, then please go here for help.', 'updraftplus'),
186 'credentials_creation_link_text' => __('Create Azure credentials in your Azure developer console.', 'updraftplus'),
187 'configuration_helper_link_text' => __('For more detailed instructions, follow this link.', 'updraftplus'),
188 'input_accesskey_label' => sprintf(__('%s access key', 'updraftplus'), $updraftplus->backup_methods[$this->get_id()]),
189 'input_secretkey_label' => sprintf(__('%s secret key', 'updraftplus'), $updraftplus->backup_methods[$this->get_id()]),
190 'input_secretkey_type' => apply_filters('updraftplus_admin_secret_field_type', 'password'),
191 'input_location_label' => sprintf(__('%s location', 'updraftplus'), $updraftplus->backup_methods[$this->get_id()]),
192 'input_location_title' => __('Enter only a bucket name or a bucket and path. Examples: mybucket, mybucket/mypath', 'updraftplus'),
193 'input_endpoint_label' => sprintf(__('%s end-point', 'updraftplus'), $updraftplus->backup_methods[$this->get_id()]),
194 'input_test_label' => sprintf(__('Test %s Settings', 'updraftplus'), $updraftplus->backup_methods[$this->get_id()]),
195 );
196 return wp_parse_args($properties, $this->get_persistent_variables_and_methods());
197 }
198 }
199