public/wordpress/wp-content/plugins/backupbuddy/destinations/s33/init.php
/* _prepareBucketAndRegion()
	 *
	 * Validates bucket existance, creating if needed.  Sets region for non-US usage.
	 *
	 * @param	array 		$settings		Destination settings array.
	 * @param	bool		$createBucket	Whether or not to create bucket if it does not currently exist.
	 * @return	bool						true on all okay, false otherwise.
	 *
	 */
_prepareBucketAndRegion()
Validates bucket existance, creating if needed.  Sets region for non-US usage.

@param       array           $settings               Destination settings array.
@param       bool            $createBucket   Whether or not to create bucket if it does not currently exist.
@return      bool                                            true on all okay, false otherwise.
_prepareBucketAndRegion () Validates bucket existance creating if needed . Sets region for non - US usage . @param array $settings Destination settings array . @param bool $createBucket Whether or not to create bucket if it does not currently exist . @return bool true on all okay false otherwise .
private static function _prepareBucketAndRegion( $settings, $createBucket = true ) {
		$error = 'BackupBuddy Error #32823893: Obsolete function call.';
		error_log( $error );
		echo $error;
		return false;
		$settings = self::_formatSettings( $settings ); 
		if ( '1' == $settings['skip_bucket_prepare'] ) {
			pb_backupbuddy::status( 'details', 'Skipping bucket preparation based on destination settings.' );
			return true;
		}
		$maybe_create_bucket = false;
		pb_backupbuddy::status( 'details', 'Getting region for bucket: `' . $settings['bucket'] . "`." );
		try {
			$detectedRegion = self::get_bucket_region( $settings['bucket'] );
			$result = self::$_client->getBucketLocation(array(
				'Bucket' => $settings['bucket'],
			));
			pb_backupbuddy::status( 'details', 'Server indicates region: ' . $detectedRegion );
			$settings['region'] = $detectedRegion; 
		} catch( Exception $e ) {
			$detectedRegion = '';
			$maybe_create_bucket = true;
			$message = 'Exception retrieving information for bucket `' . $settings['bucket'] . '`. Assuming region in $settings correct. If using IAM security, verify this resource ALLOWs the action "s3:GetBucketLocation". Details: `' . $e->getMessage() . '`. Full result: `' . print_r( $result, true ) . '`.';
			if ( pb_backupbuddy::$options['log_level'] == '3' ) { 
				pb_backupbuddy::status( 'details', 'Settings used due to log level: `' . print_r( $settings, true ) . '`.' );
			}
			echo $message;
			pb_backupbuddy::status( 'warning', $message );
		}
		try {
			self::$_client->setRegion( $settings['region'] );
		} catch( Exception $e ) {
			throw new Exception( 'Unable to set region. Details: `' . $e->getMessage() . '`.' );
		}
		if ( ( true === $createBucket ) && ( true === $maybe_create_bucket ) ) {
			pb_backupbuddy::status( 'details', 'Attempting to create bucket `' . $settings['bucket'] . '` at region endpoint `' . $settings['region'] . '` (detected region: `' . $detectedRegion . '`).' );
			try {
				$response = self::$_client->createBucket( array(
					'ACL' => 'private',
					'Bucket' => $settings['bucket'],
					'LocationConstraint' => $settings['region']
				) );
			} catch( Exception $e ) {
				return self::_error( 'Error #3892833b: Unable to create bucket. Details: `' . $e->getMessage() . '`.' );
			}
		} 
		return true;
	}
private static function _prepareBucketAndRegion ( $ settings , $ createBucket = true ) { $ error = 'BackupBuddy Error #32823893: Obsolete function call.' ; error_log ( $ error ) ; echo $ error ; return false ; $ settings = self :: _formatSettings ( $ settings ) ; if ( '1' == $ settings [ 'skip_bucket_prepare' ] ) { pb_backupbuddy :: status ( 'details' , 'Skipping bucket preparation based on destination settings.' ) ; return true ; } $ maybe_create_bucket = false ; pb_backupbuddy :: status ( 'details' , 'Getting region for bucket: `' . $ settings [ 'bucket' ] . " `. " ) ; try { $ detectedRegion = self :: get_bucket_region ( $ settings [ 'bucket' ] ) ; $ result = self :: $ _client -> getBucketLocation ( array ( 'Bucket' => $ settings [ 'bucket' ] , ) ) ; pb_backupbuddy :: status ( 'details' , 'Server indicates region: ' . $ detectedRegion ) ; $ settings [ 'region' ] = $ detectedRegion ; } catch ( Exception $ e ) { $ detectedRegion = '' ; $ maybe_create_bucket = true ; $ message = 'Exception retrieving information for bucket `' . $ settings [ 'bucket' ] . '`. Assuming region in $settings correct. If using IAM security, verify this resource ALLOWs the action "s3:GetBucketLocation". Details: `' . $ e -> getMessage ( ) . '`. Full result: `' . print_r ( $ result , true ) . '`.' ; if ( pb_backupbuddy :: $ options [ 'log_level' ] == '3' ) { pb_backupbuddy :: status ( 'details' , 'Settings used due to log level: `' . print_r ( $ settings , true ) . '`.' ) ; } echo $ message ; pb_backupbuddy :: status ( 'warning' , $ message ) ; } try { self :: $ _client -> setRegion ( $ settings [ 'region' ] ) ; } catch ( Exception $ e ) { throw new Exception ( 'Unable to set region. Details: `' . $ e -> getMessage ( ) . '`.' ) ; } if ( ( true === $ createBucket ) && ( true === $ maybe_create_bucket ) ) { pb_backupbuddy :: status ( 'details' , 'Attempting to create bucket `' . $ settings [ 'bucket' ] . '` at region endpoint `' . $ settings [ 'region' ] . '` (detected region: `' . $ detectedRegion . '`).' ) ; try { $ response = self :: $ _client -> createBucket ( array ( 'ACL' => 'private' , 'Bucket' => $ settings [ 'bucket' ] , 'LocationConstraint' => $ settings [ 'region' ] ) ) ; } catch ( Exception $ e ) { return self :: _error ( 'Error #3892833b: Unable to create bucket. Details: `' . $ e -> getMessage ( ) . '`.' ) ; } } return true ; }
_prepareBucketAndRegion()
 Validates bucket existance, creating if needed.
_prepareBucketAndRegion () Validates bucket existance creating if needed .
// Format all settings. // Get bucket region to determine if a bucket already exists. // Assume we will not have to try and create a bucket /*
		echo 'Settings:<pre>';
		print_r( $settings );
		echo '</pre>';
		*/ // Override passed region. // Full logging enabled. //self::_error ( $message ); // In bucket creation mode AND bucket did not already exist. // end if create bucket.