| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('UPDRAFTPLUS_DIR')) die('No direct access allowed.'); |
| 4 |
|
| 5 |
require_once(UPDRAFTPLUS_DIR.'/methods/s3.php'); |
| 6 |
|
| 7 |
# Migrate options to new-style storage - Jan 2014 |
| 8 |
if (!is_array(UpdraftPlus_Options::get_updraft_option('updraft_s3generic')) && '' != UpdraftPlus_Options::get_updraft_option('updraft_s3generic_login', '')) { |
| 9 |
$opts = array( |
| 10 |
'accesskey' => UpdraftPlus_Options::get_updraft_option('updraft_s3generic_login'), |
| 11 |
'secretkey' => UpdraftPlus_Options::get_updraft_option('updraft_s3generic_pass'), |
| 12 |
'path' => UpdraftPlus_Options::get_updraft_option('updraft_s3generic_remote_path'), |
| 13 |
'endpoint' => UpdraftPlus_Options::get_updraft_option('updraft_s3generic_endpoint') |
| 14 |
); |
| 15 |
UpdraftPlus_Options::update_updraft_option('updraft_s3generic', $opts); |
| 16 |
UpdraftPlus_Options::delete_updraft_option('updraft_s3generic_login'); |
| 17 |
UpdraftPlus_Options::delete_updraft_option('updraft_s3generic_pass'); |
| 18 |
UpdraftPlus_Options::delete_updraft_option('updraft_s3generic_remote_path'); |
| 19 |
UpdraftPlus_Options::delete_updraft_option('updraft_s3generic_endpoint'); |
| 20 |
} |
| 21 |
|
| 22 |
class UpdraftPlus_BackupModule_s3generic extends UpdraftPlus_BackupModule_s3 { |
| 23 |
|
| 24 |
protected function set_region($obj, $region = '', $bucket_name = '') { |
| 25 |
$config = $this->get_config(); |
| 26 |
$endpoint = ($region != '' && $region != 'n/a') ? $region : $config['endpoint']; |
| 27 |
global $updraftplus; |
| 28 |
$updraftplus->log("Set endpoint: $endpoint"); |
| 29 |
$obj->setEndpoint($endpoint); |
| 30 |
} |
| 31 |
|
| 32 |
public function get_credentials() { |
| 33 |
return array('updraft_s3generic'); |
| 34 |
} |
| 35 |
|
| 36 |
protected function get_config() { |
| 37 |
global $updraftplus; |
| 38 |
$opts = $updraftplus->get_job_option('updraft_s3generic'); |
| 39 |
if (!is_array($opts)) $opts = array('accesskey' => '', 'secretkey' => '', 'path' => ''); |
| 40 |
$opts['whoweare'] = 'S3'; |
| 41 |
$opts['whoweare_long'] = __('S3 (Compatible)', 'updraftplus'); |
| 42 |
$opts['key'] = 's3generic'; |
| 43 |
return $opts; |
| 44 |
} |
| 45 |
|
| 46 |
public function config_print() { |
| 47 |
// 5th parameter = control panel URL |
| 48 |
// 6th = image HTML |
| 49 |
$this->config_print_engine('s3generic', 'S3', __('S3 (Compatible)', 'updraftplus'), 'S3', '', '', true); |
| 50 |
} |
| 51 |
|
| 52 |
public function credentials_test($posted_settings) { |
| 53 |
$this->credentials_test_engine($this->get_config(), $posted_settings); |
| 54 |
} |
| 55 |
|
| 56 |
} |
| 57 |
|