本文整理汇总了PHP中AmazonS3::disable_ssl方法的典型用法代码示例。如果您正苦于以下问题:PHP AmazonS3::disable_ssl方法的具体用法?PHP AmazonS3::disable_ssl怎么用?PHP AmazonS3::disable_ssl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AmazonS3
的用法示例。
在下文中一共展示了AmazonS3::disable_ssl方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
public static function test($settings)
{
$remote_path = self::get_remote_path($settings['directory']);
// Has leading and trailng slashes.
$manage_data = pb_backupbuddy_destination_stash::get_manage_data($settings);
if (!is_array($manage_data['credentials'])) {
// Credentials were somehow faulty. User changed password after prior page? Unlikely but you never know...
$error_msg = 'Error #8484383c: Your authentication credentials for Stash failed. Verify your login and password to Stash. You may need to update the Stash destination settings. Perhaps you recently changed your password?';
pb_backupbuddy::status('error', $error_msg);
return $error_msg;
}
// Try sending a file.
$send_response = pb_backupbuddy_destinations::send($settings, dirname(dirname(__FILE__)) . '/remote-send-test.php', $send_id = 'TEST-' . pb_backupbuddy::random_string(12));
// 3rd param true forces clearing of any current uploads.
if (false === $send_response) {
$send_response = 'Error sending test file to Stash.';
} else {
$send_response = 'Success.';
}
// S3 object for managing files.
$credentials = pb_backupbuddy_destination_stash::get_manage_data($settings);
$s3_manage = new AmazonS3($manage_data['credentials']);
if ($settings['ssl'] == 0) {
@$s3_manage->disable_ssl(true);
}
// Delete sent file.
$delete_response = 'Success.';
$delete_response = $s3_manage->delete_object($manage_data['bucket'], $manage_data['subkey'] . $remote_path . 'remote-send-test.php');
if (!$delete_response->isOK()) {
$delete_response = 'Unable to delete test Stash file `remote-send-test.php`. Details: `' . print_r($response, true) . '`.';
pb_backupbuddy::status('details', $delete_response);
} else {
$delete_response = 'Success.';
}
// Load destination fileoptions.
pb_backupbuddy::status('details', 'About to load fileoptions data.');
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
$fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
if (true !== ($result = $fileoptions_obj->is_ok())) {
pb_backupbuddy::status('error', __('Fatal Error #9034.84838. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
return false;
}
pb_backupbuddy::status('details', 'Fileoptions data loaded.');
$fileoptions =& $fileoptions_obj->options;
if ('Success.' != $send_response || 'Success.' != $delete_response) {
$fileoptions['status'] = 'failure';
$fileoptions_obj->save();
unset($fileoptions_obj);
return 'Send details: `' . $send_response . '`. Delete details: `' . $delete_response . '`.';
} else {
$fileoptions['status'] = 'success';
$fileoptions['finish_time'] = time();
}
$fileoptions_obj->save();
unset($fileoptions_obj);
return true;
}
示例2: test
public static function test($settings)
{
$remote_path = self::get_remote_path($settings['directory']);
// Has leading and trailng slashes.
// Try sending a file.
$test_result = self::send($settings, dirname(__FILE__) . '/icon.png', true);
// 3rd param true forces clearing of any current uploads.
// S3 object for managing files.
$manage_data = pb_backupbuddy_destination_stash::get_manage_data($settings);
$s3_manage = new AmazonS3($manage_data['credentials']);
if ($settings['ssl'] == 0) {
@$s3_manage->disable_ssl(true);
}
// Delete sent file.
$response = $s3_manage->delete_object($manage_data['bucket'], $manage_data['subkey'] . $remote_path . 'icon.png');
if (!$response->isOK()) {
pb_backupbuddy::status('details', 'Unable to delete test Stash file `' . $buname . '`. Details: `' . print_r($response, true) . '`.');
}
delete_transient('pb_backupbuddy_stashquota_' . $settings['itxapi_username']);
// Delete quota transient since it probably has changed now.
return $test_result;
}
示例3: 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;
}
}
示例4: array
<td><input type="password" name="itxapi_password_raw"></td>
</tr>
<tr>
<th> </th>
<td><input type="submit" name="submit" value="Re-Authenticate" class="button button-primary"></td>
</tr>
</table>
</form>
<?php
die;
}
$s3 = new AmazonS3($manage_data['credentials']);
// the key, secret, token
if ($settings['ssl'] == '0') {
@$s3->disable_ssl(true);
}
// Handle deletion.
if (pb_backupbuddy::_POST('bulk_action') == 'delete_backup') {
pb_backupbuddy::verify_nonce();
$deleted_files = array();
foreach ((array) pb_backupbuddy::_POST('items') as $item) {
$response = $s3->delete_object($manage_data['bucket'], $manage_data['subkey'] . $remote_path . $item);
if ($response->isOK()) {
$deleted_files[] = $item;
} else {
pb_backupbuddy::alert('Error: Unable to delete `' . $item . '`. Verify permissions.');
}
}
if (count($deleted_files) > 0) {
pb_backupbuddy::alert('Deleted ' . implode(', ', $deleted_files) . '.');
示例5: multipart_cleanup
public static function multipart_cleanup($settings, $lessLogs = true)
{
$settings['bucket'] = strtolower($settings['bucket']);
// Buckets must be lowercase.
$max_age = 60 * 60 * 72;
// Seconds of max age to allow a stalled multipart upload.
require_once dirname(dirname(__FILE__)) . '/_s3lib/aws-sdk/sdk.class.php';
pb_backupbuddy::status('details', 'Amazon S3 Multipart Remote Housekeeping Starting ...');
$manage_data = pb_backupbuddy_destination_s3::get_credentials($settings);
// Create S3 instance.
pb_backupbuddy::status('details', 'Creating S3 instance.');
$s3 = new AmazonS3($manage_data);
// the key, secret, token
if ($settings['ssl'] == 0) {
@$s3->disable_ssl(true);
}
pb_backupbuddy::status('details', 'S3 instance created. Listing in progress multipart uploads ...');
// Verify bucket exists; create if not. Also set region to the region bucket exists in.
if (false === self::_prepareBucketAndRegion($s3, $settings, $createBucket = false)) {
return false;
}
// Get the in progress multipart uploads
$response = $s3->list_multipart_uploads($settings['bucket'], array('prefix' => 'backup'));
if (!$response->isOK()) {
pb_backupbuddy::status('error', 'Error listing multipart uploads. Details: `' . print_r($response, true) . '`');
return;
} else {
if (true !== $lessLogs) {
pb_backupbuddy::status('details', 'Multipart upload check retrieved. Found `' . count($response->body->Upload) . '` multipart uploads in progress / stalled. Details: `' . print_r($response, true) . '`');
} else {
pb_backupbuddy::status('details', 'Multipart upload check retrieved. Found `' . count($response->body->Upload) . '` multipart uploads in progress / stalled. Old BackupBuddy parts will be cleaned up (if any found) ...');
}
foreach ($response->body->Upload as $upload) {
if (true !== $lessLogs) {
pb_backupbuddy::status('details', 'Checking upload: ' . print_r($upload, true));
}
if (FALSE !== stristr($upload->Key, 'backup-')) {
// BackupBuddy backup file.
$initiated = strtotime($upload->Initiated);
if (true !== $lessLogs) {
pb_backupbuddy::status('details', 'BackupBuddy Multipart Chunked Upload(s) detected in progress. Age: `' . pb_backupbuddy::$format->time_ago($initiated) . '`.');
}
if ($initiated + $max_age < time()) {
$abort_response = $s3->abort_multipart_upload($settings['bucket'], $upload->Key, $upload->UploadId);
if (!$abort_response->isOK()) {
// abort fail.
pb_backupbuddy::status('error', 'Stalled Amazon S3 Multipart Chunked abort of file `' . $upload->Key . '` with ID `' . $upload->UploadId . '` FAILED. Manually abort it.');
} else {
// aborted.
pb_backupbuddy::status('details', 'Stalled Amazon S3 Multipart Chunked Uploads ABORTED ID `' . $upload->UploadId . '` of age `' . pb_backupbuddy::$format->time_ago($initiated) . '`.');
}
} else {
if (true !== $lessLogs) {
pb_backupbuddy::status('details', 'Amazon S3 Multipart Chunked Uploads not aborted as not too old.');
}
}
}
}
// end foreach uploads.
}
pb_backupbuddy::status('details', 'Amazon S3 Multipart Remote Housekeeping Finished.');
return true;
}
示例6: test
public static function test($settings)
{
$remote_path = self::get_remote_path($settings['directory']);
// Has leading and trailng slashes.
// Try sending a file.
$test_result = self::send($settings, dirname(__FILE__) . '/icon.png', true);
// 3rd param true forces clearing of any current uploads.
// S3 object for managing files.
$manage_data = self::get_manage_data($settings);
$s3_manage = new AmazonS3(self::get_manage_data($settings));
if ($settings['ssl'] == 0) {
@$s3_manage->disable_ssl(true);
}
// Delete sent file.
$response = $s3_manage->delete_object($settings['bucket'], $remote_path . 'icon.png');
if (!$response->isOK()) {
pb_backupbuddy::status('details', 'Unable to delete test S3 file `' . $settings['bucket'], $remote_path . 'icon.png' . '`. Details: `' . print_r($response, true) . '`.');
}
return $test_result;
}