<?
            
switch ($offsite) {

    case "dropbox":
    
        $uploader = new DropboxUploader( $_POST['remote_user'], $_POST['remote_pass'] );
        
        wpTimeMachine_logger( $use_log,  '--- instantiate ' . $offsite );

        if ($_POST['remote_path'] == "") {
            $dropbox_dir = "/wpTimeMachine";
        } else {
            $dropbox_dir = "/" . $_POST['remote_path'] ;
        }
    
        if ($timestamp != "") {
            $dropbox_dir .= "-" . $timestamp;
        } 
    
        $uploader->upload( super_archive.$format, $remoteDir = $dropbox_dir );

        break;

    case "aws_s3":

        if ($_POST['remote_path'] == "") {
            $bucket = "wpTimeMachine";
        } else {
            $bucket = $_POST['remote_path'] ;
        }
    
        if ($timestamp != "") {
            $bucket .= "-" . $timestamp;
        } 
            
        $bucket = uniqid( $bucket . "-" );

        $s3 = new S3( $_POST['remote_user'], $_POST['remote_pass'] );
        
        wpTimeMachine_logger( $use_log,  '--- instantiate ' . $offsite );
        
        $s3->putBucket( $bucket, S3::ACL_PRIVATE );
        $s3->putObjectFile( super_archive.$format, $bucket, baseName( super_archive.$format ), S3::ACL_PRIVATE );

        break;

    case "ftp":
    
        $conn = ftp_connect( $_POST['remote_host'] ); 
        
        wpTimeMachine_logger( $use_log,  '--- create ftp connection ' );
                                       
        ftp_login( $conn, $_POST['remote_user'], $_POST['remote_pass'] );  
        
        wpTimeMachine_logger( $use_log,  '--- login to ftp ' );
        
        if ($timestamp != "") {
            $remote_path = "/" . $_POST['remote_path'] . "/wpTimeMachine-" . $timestamp;
        } else {
            $remote_path = "/" . $_POST['remote_path'];
        }
        
        @ftp_mkdir($conn, $remote_path);
                       
        ftp_chdir( $conn, $remote_path );                            
        
        $remote_file = baseName( super_archive.$format );
    
		if ($_POST['remote_path'] == "") {
            $remote_file = "/" . $remote_file;
        } else {
            $remote_file = "/" . $remote_path . "/" . $remote_file;
        }

        ftp_put($conn, $remote_file, super_archive.$format, FTP_BINARY);
        ftp_quit( $conn );    
                
        break;
        
    default:
    
        wpTimeMachine_logger( $use_log,  '--- error ... no offsite set, or recognized.' ); 

}

?>