client;
}
public function get_openstack_service($opts, $useservercerts = false, $disablesslverify = null) {
$user = $opts['user'];
$apikey = $opts['apikey'];
$authurl = $opts['authurl'];
$region = (!empty($opts['region'])) ? $opts['region'] : null;
include_once(UPDRAFTPLUS_DIR.'/vendor/autoload.php');
// The new authentication APIs don't match the values we were storing before
$new_authurl = ('https://lon.auth.api.rackspacecloud.com' == $authurl || 'uk' == $authurl) ? Rackspace::UK_IDENTITY_ENDPOINT : Rackspace::US_IDENTITY_ENDPOINT;
if (null === $disablesslverify) $disablesslverify = UpdraftPlus_Options::get_updraft_option('updraft_ssl_disableverify');
if (empty($user) || empty($apikey)) throw new Exception(__('Authorisation failed (check your credentials)', 'updraftplus'));
$this->log("authentication URL: ".$new_authurl);
$client = new Rackspace($new_authurl, array(
'username' => $user,
'apiKey' => $apikey
));
$this->client = $client;
if ($disablesslverify) {
$client->setSslVerification(false);
} else {
if ($useservercerts) {
$client->setConfig(array($client::SSL_CERT_AUTHORITY, 'system'));
} else {
$client->setSslVerification(UPDRAFTPLUS_DIR.'/includes/cacert.pem', true, 2);
}
}
return $client->objectStoreService('cloudFiles', $region);
}
/**
* 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 assumed 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(
'user' => '',
'authurl' => 'https://auth.api.rackspacecloud.com',
'apikey' => '',
'path' => '',
'region' => null
);
}
/**
* This gives the partial template string to the settings page for the CloudFiles settings.
*
* @return String - the partial template, ready for substitutions to be carried out
*/
public function get_configuration_middlesection_template() {
global $updraftplus;
$classes = $this->get_css_classes();
$template_str = '
'.__('US or UK-based Rackspace Account', 'updraftplus').':
';
{{{get_template_test_button_html "Rackspace Cloud Files"}}}
!empty($this->img_url) ? UPDRAFTPLUS_URL.$this->img_url : '',
'storage_long_description' => $this->long_desc,
'mb_substr_existence_label' => !apply_filters('updraftplus_openstack_mbsubstr_exists', function_exists('mb_substr')) ? wp_kses($updraftplus_admin->show_double_warning(''.__('Warning', 'updraftplus').': '.sprintf(__('Your web server\'s PHP installation does not include a required module (%s). Please contact your web hosting provider\'s support.', 'updraftplus'), 'mbstring').' '.sprintf(__("UpdraftPlus's %s module requires %s. Please do not file any support requests; there is no alternative.", 'updraftplus'), $this->desc, 'mbstring'), $this->method, false), $this->allowed_html_for_content_sanitisation()) : '',
'json_last_error_existence_label' => !apply_filters('updraftplus_rackspace_jsonlasterror_exists', function_exists('json_last_error')) ? wp_kses($updraftplus_admin->show_double_warning(''.__('Warning', 'updraftplus').': '.sprintf(__('Your web server\'s PHP installation does not include a required module (%s). Please contact your web hosting provider\'s support.', 'updraftplus'), 'json').' '.sprintf(__("UpdraftPlus's %s module requires %s. Please do not file any support requests; there is no alternative.", 'updraftplus'), 'Cloud Files', 'json'), 'cloudfiles', false), $this->allowed_html_for_content_sanitisation()) : '',
'curl_existence_label' => wp_kses($updraftplus_admin->curl_check($this->long_desc, false, $this->method.' hidden-in-updraftcentral', false), $this->allowed_html_for_content_sanitisation()),
'rackspace_text_description' => wp_kses(__('Get your API key from your Rackspace Cloud console (read instructions here), then pick a container name to use for storage. This container will be created for you if it does not already exist.', 'updraftplus'), $this->allowed_html_for_content_sanitisation()),
'faq_link_text' => __('Also, you should read this important FAQ.', 'updraftplus'),
'faq_link_url' => wp_kses(apply_filters("updraftplus_com_link", "https://updraftplus.com/faqs/there-appear-to-be-lots-of-extra-files-in-my-rackspace-cloud-files-container/"), array(), array('http', 'https')),
'input_account_label' => __('US or UK-based Rackspace Account', 'updraftplus'),
'input_account_title' => __('Accounts created at rackspacecloud.com are US accounts; accounts created at rackspace.co.uk are UK accounts.', 'updraftplus'),
'input_account_option_labels' => array(
'https://auth.api.rackspacecloud.com' => __('US (default)', 'updraftplus'),
'https://lon.auth.api.rackspacecloud.com' => __('UK', 'updraftplus'),
),
'input_region_label' => __('Cloud Files Storage Region', 'updraftplus'),
'input_username_label' => __('Cloud Files Username', 'updraftplus'),
'input_username_title' => wp_kses(apply_filters('updraft_cloudfiles_apikeysetting', ''.__('To create a new Rackspace API sub-user and API key that has access only to this Rackspace container, use Premium.', 'updraftplus').''), $this->allowed_html_for_content_sanitisation()),
'input_apikey_label' => __('Cloud Files API Key', 'updraftplus'),
'input_apikey_type' => apply_filters('updraftplus_admin_secret_field_type', 'password'),
'input_container_label' => wp_kses(apply_filters('updraftplus_cloudfiles_location_description', __('Cloud Files Container', 'updraftplus')), $this->allowed_html_for_content_sanitisation()),
'input_test_label' => sprintf(__('Test %s Settings', 'updraftplus'), $updraftplus->backup_methods[$this->get_id()]),
);
return wp_parse_args($properties, $this->get_persistent_variables_and_methods());
}
}