本文整理汇总了PHP中AmazonS3::set_region方法的典型用法代码示例。如果您正苦于以下问题:PHP AmazonS3::set_region方法的具体用法?PHP AmazonS3::set_region怎么用?PHP AmazonS3::set_region使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AmazonS3
的用法示例。
在下文中一共展示了AmazonS3::set_region方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_ajax
/**
* @param string $args
*/
public function edit_ajax($args = '')
{
$error = '';
if (is_array($args)) {
$ajax = FALSE;
} else {
if (!current_user_can('backwpup_jobs_edit')) {
wp_die(-1);
}
check_ajax_referer('backwpup_ajax_nonce');
$args['s3accesskey'] = $_POST['s3accesskey'];
$args['s3secretkey'] = $_POST['s3secretkey'];
$args['s3bucketselected'] = $_POST['s3bucketselected'];
$args['s3base_url'] = $_POST['s3base_url'];
$args['s3region'] = $_POST['s3region'];
$ajax = TRUE;
}
echo '<span id="s3bucketerror" style="color:red;">';
if (!empty($args['s3accesskey']) && !empty($args['s3secretkey'])) {
try {
$s3 = new AmazonS3(array('key' => $args['s3accesskey'], 'secret' => BackWPup_Encryption::decrypt($args['s3secretkey']), 'certificate_authority' => TRUE));
$base_url = $this->get_s3_base_url($args['s3region'], $args['s3base_url']);
if (stristr($base_url, 'amazonaws.com')) {
$s3->set_region(str_replace(array('http://', 'https://'), '', $base_url));
} else {
$s3->set_hostname(str_replace(array('http://', 'https://'), '', $base_url));
$s3->allow_hostname_override(FALSE);
if (substr($base_url, -1) == '/') {
$s3->enable_path_style(TRUE);
}
}
if (stristr($base_url, 'http://')) {
$s3->disable_ssl();
}
$buckets = $s3->list_buckets();
} catch (Exception $e) {
$error = $e->getMessage();
}
}
if (empty($args['s3accesskey'])) {
_e('Missing access key!', 'backwpup');
} elseif (empty($args['s3secretkey'])) {
_e('Missing secret access key!', 'backwpup');
} elseif (!empty($error) && $error == 'Access Denied') {
echo '<input type="text" name="s3bucket" id="s3bucket" value="' . esc_attr($args['s3bucketselected']) . '" >';
} elseif (!empty($error)) {
echo esc_html($error);
} elseif (!isset($buckets) || count($buckets->body->Buckets->Bucket) < 1) {
_e('No bucket found!', 'backwpup');
}
echo '</span>';
if (!empty($buckets->body->Buckets->Bucket)) {
echo '<select name="s3bucket" id="s3bucket">';
foreach ($buckets->body->Buckets->Bucket as $bucket) {
echo "<option " . selected($args['s3bucketselected'], esc_attr($bucket->Name), FALSE) . ">" . esc_attr($bucket->Name) . "</option>";
}
echo '</select>';
}
if ($ajax) {
die;
}
}
示例2: connect
public function connect()
{
$this->connection = new \AmazonS3($this->s3_options);
$this->connection->set_region($this->region);
}