public/wordpress/wp-content/plugins/backupbuddy/destinations/stash2/init.php
/*	send()
	 *	
	 *	Send one or more files.
	 *	
	 *	@param		array			$files			Array of one or more files to send.
	 *	@return		boolean|array					True on success, false on failure, array if a multipart chunked send so there is no status yet.
	 */
send()

Send one or more files.

@param          array                   $files                  Array of one or more files to send.
@return         boolean|array                                   True on success, false on failure, array if a multipart chunked send so there is no status yet.
send () Send one or more files . @param array $files Array of one or more files to send . @return boolean|array True on success false on failure array if a multipart chunked send so there is no status yet .
public static function send( $settings = array(), $file, $send_id = '', $delete_after = false, $clear_uploads = false ) {
		pb_backupbuddy::status( 'details', 'Starting Stash2 send().' );
		$settings = self::_init( $settings );
		if ( '1' == $settings['disabled'] ) {
			self::_error( __( 'Error #48933: This destination is currently disabled. Enable it under this destination\'s Advanced Settings.', 'it-l10n-backupbuddy' ) );
			return false;
		}
		if ( is_array( $file ) ) {
			$file = $files[0];
		}
		if ( '' == $settings['_multipart_id'] ) { 
			$file_size = filesize( $file );
			$remote_path = self::get_remote_path(); 
			$backup_type = backupbuddy_core::getBackupTypeFromFile( $file, $quiet = false, $skip_fileoptions = false );
			if ( '' == $backup_type ) { 
				$backup_type_path = '';
			} else { 
				$backup_type_path = $backup_type . '/';
			}
			$additionalParams =array(
				'filename' => $remote_path . $backup_type_path . basename( $file ),
				'size'     => $file_size,
				'timezone' => get_option('timezone_string')
			);
			$stashAction = 'upload';
			$response = self::stashAPI( $settings, $stashAction, $additionalParams );
			if ( ! is_array( $response ) ) {
				$error = 'Error #832973: Unable to initiate Stash (v2) upload. Details: `' . $response . '`.';
				self::_error( $error );
				return false;
			}
			if ( pb_backupbuddy::$options['log_level'] == '3' ) { 
				pb_backupbuddy::status( 'details', 'Stash API upload action response due to logging level: `' . print_r( $response, true ) . '`. Call params: `' . print_r( $additionalParams, true ) . ' `.' );
			}
			$settings['stash_mode'] = '1'; 
			$settings['bucket'] = $response['bucket'];
			$settings['credentials'] = $response['credentials'];
			if ( isset( $response['object'] ) ) {
				$settings['_stash_object'] = $response['object'];
			}
			if ( isset( $response['upload_id'] ) ) {
				$settings['_stash_upload_id'] = $response['upload_id'];
			}
		}
		$result = pb_backupbuddy_destination_s32::send( $settings, $file, $send_id, $delete_after, $clear_uploads );
		if ( false === $result ) { 
			self::_uploadFailed( $settings );
		} elseif ( is_array( $result ) ) { 
			self::cron_kick_api( $settings, $blocking = false );
		} elseif ( true === $result ) {
		}
		return $result;
	}
public static function send ( $ settings = array ( ) , $ file , $ send_id = '' , $ delete_after = false , $ clear_uploads = false ) { pb_backupbuddy :: status ( 'details' , 'Starting Stash2 send().' ) ; $ settings = self :: _init ( $ settings ) ; if ( '1' == $ settings [ 'disabled' ] ) { self :: _error ( __ ( 'Error #48933: This destination is currently disabled. Enable it under this destination\'s Advanced Settings.' , 'it-l10n-backupbuddy' ) ) ; return false ; } if ( is_array ( $ file ) ) { $ file = $ files [ 0 ] ; } if ( '' == $ settings [ '_multipart_id' ] ) { $ file_size = filesize ( $ file ) ; $ remote_path = self :: get_remote_path ( ) ; $ backup_type = backupbuddy_core :: getBackupTypeFromFile ( $ file , $ quiet = false , $ skip_fileoptions = false ) ; if ( '' == $ backup_type ) { $ backup_type_path = '' ; } else { $ backup_type_path = $ backup_type . '/' ; } $ additionalParams = array ( 'filename' => $ remote_path . $ backup_type_path . basename ( $ file ) , 'size' => $ file_size , 'timezone' => get_option ( 'timezone_string' ) ) ; $ stashAction = 'upload' ; $ response = self :: stashAPI ( $ settings , $ stashAction , $ additionalParams ) ; if ( ! is_array ( $ response ) ) { $ error = 'Error #832973: Unable to initiate Stash (v2) upload. Details: `' . $ response . '`.' ; self :: _error ( $ error ) ; return false ; } if ( pb_backupbuddy :: $ options [ 'log_level' ] == '3' ) { pb_backupbuddy :: status ( 'details' , 'Stash API upload action response due to logging level: `' . print_r ( $ response , true ) . '`. Call params: `' . print_r ( $ additionalParams , true ) . ' `.' ) ; } $ settings [ 'stash_mode' ] = '1' ; $ settings [ 'bucket' ] = $ response [ 'bucket' ] ; $ settings [ 'credentials' ] = $ response [ 'credentials' ] ; if ( isset ( $ response [ 'object' ] ) ) { $ settings [ '_stash_object' ] = $ response [ 'object' ] ; } if ( isset ( $ response [ 'upload_id' ] ) ) { $ settings [ '_stash_upload_id' ] = $ response [ 'upload_id' ] ; } } $ result = pb_backupbuddy_destination_s32 :: send ( $ settings , $ file , $ send_id , $ delete_after , $ clear_uploads ) ; if ( false === $ result ) { self :: _uploadFailed ( $ settings ) ; } elseif ( is_array ( $ result ) ) { self :: cron_kick_api ( $ settings , $ blocking = false ) ; } elseif ( true === $ result ) { } return $ result ; }
send()
send ()
// New transfer. Populate initial Stash settings. // Has leading and trailng slashes. // unknown backup type // known backup type. store in subdir. // Full logging enabled. // Stash is calling the s32 destination. //error_log( print_r( $settings, true ) ); // Send file. // Notify Stash if failure. // Chunking. Notify Stash API to kick cron.