C:\xampp\htdocs\landing\wp-content\updraft\plugins-old\updraftplus\methods\dreamobjects.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php

if (!defined('UPDRAFTPLUS_DIR')) die('No direct access allowed.');

require_once(
UPDRAFTPLUS_DIR.'/methods/s3.php');

/**
 * Converted to multi-options (Feb 2017-) and previous options conversion removed: Yes
 */
class UpdraftPlus_BackupModule_dreamobjects extends UpdraftPlus_BackupModule_s3 {

    private 
$dreamobjects_endpoints = array();

    
/**
     * Class constructor
     */
    
public function __construct() {
        
// 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()
        // Put the default first
        
$this->dreamobjects_endpoints = array(
            
// Endpoint, then the label
            
'objects-us-east-1.dream.io' => 'objects-us-east-1.dream.io',
            
'objects-us-west-1.dream.io' => 'objects-us-west-1.dream.io ('.__('Closing 1st October 2018''updraftplus').')',
        );
    }
    
    protected 
$use_v4 false;

    
/**
     * Given an S3 object, possibly set the region on it
     *
     * @param Object $obj          - like UpdraftPlus_S3
     * @param String $region
     * @param String $bucket_name
     */
    
protected function set_region($obj$region ''$bucket_name '') {// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found - $bucket_name

        
$config $this->get_config();
        
$endpoint = ('' != $region && 'n/a' != $region) ? $region $config['endpoint'];
        global 
$updraftplus;
        if (
$updraftplus->backup_time) {
            
$updraftplus->log("Set endpoint: $endpoint");
        
            
// Warning for objects-us-west-1 shutdown in Oct 2018
            
if ('objects-us-west-1.dream.io' == $endpoint) {
                
// Are we after the shutdown date?
                
if (time() >= 1538438400) {
                    
$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');
                } else {
                    
$updraftplus->log("The objects-us-west-1.dream.io endpoint is scheduled to shut down on the 1st October 2018. You will need to switch to a different end-point and migrate your data before that date. Please see the following article for more information https://help.dreamhost.com/hc/en-us/articles/360002135871-Cluster-migration-procedure"'warning''dreamobjects_west_shutdown');
                }
            }
        }
        
        
$obj->setEndpoint($endpoint);
    }

    
/**
     * This method overrides the parent method and lists the supported features of this remote storage option.
     *
     * @return Array - an array of supported features (any features not mentioned are asuumed to not be supported)
     */
    
public function get_supported_features() {
        
// This options format is handled via only accessing options via $this->get_options()
        
return array('multi_options''config_templates''multi_storage''conditional_logic');
    }

    
/**
     * Retrieve default options for this remote storage module.
     *
     * @return Array - an array of options
     */
    
public function get_default_options() {
        return array(
            
'accesskey' => '',
            
'secretkey' => '',
            
'path' => '',
        );
    }

    
/**
     * Retrieve specific options for this remote storage module
     *
     * @param Boolean $force_refresh - if set, and if relevant, don't use cached credentials, but get them afresh
     *
     * @return Array - an array of options
     */
    
protected function get_config($force_refresh false) {// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- $force_refresh unused
        
$opts $this->get_options();
        
$opts['whoweare'] = 'DreamObjects';
        
$opts['whoweare_long'] = 'DreamObjects';
        
$opts['key'] = 'dreamobjects';
        if (empty(
$opts['endpoint'])) {
            
$endpoints array_keys($this->dreamobjects_endpoints);
            
$opts['endpoint'] = $endpoints[0];
        }
        return 
$opts;
    }

    
/**
     * Get the pre configuration template
     *
     * @return String - the template
     */
    
public function get_pre_configuration_template() {
        
$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>');
    }

    
/**
     * Get the configuration template
     *
     * @return String - the template, ready for substitutions to be carried out
     */
    
public function get_configuration_template() {
        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>');
    }
    
    
/**
     * Get handlebar partial template string for endpoint of s3 compatible remote storage method. Other child class can extend it.
     *
     * @return string the partial template string
     */
    
protected function get_partial_configuration_template_for_endpoint() {
        
// 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
        
return '<tr class="'.$this->get_css_classes().'">
                    <th>'
.sprintf(__('%s end-point''updraftplus'), 'DreamObjects').'</th>
                    <td>
                        <select data-updraft_settings_test="endpoint" '
.$this->output_settings_field_name_and_id('endpoint'true).' style="width: 360px">                            
                            {{#each dreamobjects_endpoints as |description endpoint|}}
                                <option value="{{endpoint}}" {{#ifeq ../endpoint endpoint}}selected="selected"{{/ifeq}}>{{description}}</option>
                            {{/each}}
                        </select>
                    </td>
                </tr>'
;
    }
    
    
/**
     * Modifies handerbar template options
     *
     * @param array $opts
     * @return array - Modified handerbar template options
     */
    
public function transform_options_for_template($opts) {
        
$opts['endpoint'] = empty($opts['endpoint']) ? '' $opts['endpoint'];
        
$opts['dreamobjects_endpoints'] = $this->dreamobjects_endpoints;
        return 
$opts;
    }
    
    public function 
credentials_test($posted_settings) {
        
$this->credentials_test_engine($this->get_config(), $posted_settings);
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586