if (isset($destination['max_chunk_size']) && $destination['max_chunk_size'] == '0') {
        continue;
    }
    pb_backupbuddy::status('details', 'Found S3 Multipart Chunking Destinations to cleanup.');
    require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
    $cleanup_result = pb_backupbuddy_destinations::multipart_cleanup($destination);
    /*
    if ( true === $cleanup_result ) {
    	pb_backupbuddy::status( 'details', 'S3 Multipart Chunking Cleanup Success.' );
    } else {
    	pb_backupbuddy::status( 'error', 'S3 Multipart Chunking Cleanup FAILURE. Manually cleanup stalled multipart send via S3 or try again later.' );
    }
    */
}
// Clean up any temp rollback or deployment database tables.
backupbuddy_core::cleanup_temp_tables();
// Cleanup any cron schedules pointing to non-existing schedules.
$cron = get_option('cron');
// Loop through each cron time to create $crons array for displaying later.
$crons = array();
foreach ((array) $cron as $time => $cron_item) {
    if (is_numeric($time)) {
        // Loop through each schedule for this time
        foreach ((array) $cron_item as $hook_name => $event) {
            foreach ((array) $event as $item_name => $item) {
                if ('pb_backupbuddy-cron_scheduled_backup' == $hook_name) {
                    // scheduled backup
                    if (!empty($item['args'])) {
                        if (!isset(pb_backupbuddy::$options['schedules'][$item['args'][0]])) {
                            // BB schedule does not exist so delete this cron item.
                            if (FALSE === backupbuddy_core::unschedule_event($time, $hook_name, $item['args'])) {
<?php

backupbuddy_core::verifyAjaxAccess();
// Note: importbuddy, backup files, etc should have already been cleaned up by importbuddy itself at this point.
$serial = pb_backupbuddy::_POST('serial');
$direction = pb_backupbuddy::_POST('direction');
pb_backupbuddy::load();
if ('pull' == $direction) {
    // Local so clean up here.
    backupbuddy_core::cleanup_temp_tables($serial);
    die('1');
} elseif ('push' == $direction) {
    // Remote so call API to clean up.
    require_once pb_backupbuddy::plugin_path() . '/classes/remote_api.php';
    $destinationID = pb_backupbuddy::_POST('destinationID');
    if (!isset(pb_backupbuddy::$options['remote_destinations'][$destinationID])) {
        die('Error #8383983: Invalid destination ID `' . htmlentities($destinationID) . '`.');
    }
    $destinationArray = pb_backupbuddy::$options['remote_destinations'][$destinationID];
    if ('site' != $destinationArray['type']) {
        die('Error #8378332: Destination with ID `' . htmlentities($destinationID) . '` not of "site" type.');
    }
    $apiKey = $destinationArray['api_key'];
    $apiSettings = backupbuddy_remote_api::key_to_array($apiKey);
    if (false === ($response = backupbuddy_remote_api::remoteCall($apiSettings, 'confirmDeployment', array('serial' => $serial), 10, null, null, null, null, null, null, null, $returnRaw = true))) {
        $message = 'Error #2378378324. Unable to confirm remote deployment with serial `' . $serial . '` via remote API.';
        pb_backupbuddy::status('error', $message);
        die($message);
    } else {
        if (false === ($response = json_decode($response, true))) {
            $message = 'Error #239872373. Unable to decode remote deployment response with serial `' . $serial . '` via remote API. Remote server response: `' . print_r($response) . '`.';
 private static function _verb_confirmDeployment()
 {
     $serial = pb_backupbuddy::_POST('serial');
     backupbuddy_core::cleanup_temp_tables($serial);
     die(json_encode(array('success' => true)));
 }