public function remote_send() { if (defined('PB_DEMO_MODE')) { die('Access denied in demo mode.'); } $success_output = false; // Set to true onece a leading 1 has been sent to the javascript to indicate success. $destination_id = pb_backupbuddy::_POST('destination_id'); if (pb_backupbuddy::_POST('file') != 'importbuddy.php') { $backup_file = pb_backupbuddy::$options['backup_directory'] . pb_backupbuddy::_POST('file'); } else { $backup_file = ''; } if (pb_backupbuddy::_POST('send_importbuddy') == '1') { $send_importbuddy = true; pb_backupbuddy::status('details', 'Cron send to be scheduled with importbuddy sending.'); } else { $send_importbuddy = false; pb_backupbuddy::status('details', 'Cron send to be scheduled WITHOUT importbuddy sending.'); } // For Stash we will check the quota prior to initiating send. if (pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash') { // Pass off to destination handler. require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $send_result = pb_backupbuddy_destinations::get_info('stash'); // Used to kick the Stash destination into life. $stash_quota = pb_backupbuddy_destination_stash::get_quota(pb_backupbuddy::$options['remote_destinations'][$destination_id], true); //print_r( $stash_quota ); if ($backup_file != '') { $backup_file_size = filesize($backup_file); } else { $backip_file_size = 50000; } if ($backup_file_size + $stash_quota['quota_used'] > $stash_quota['quota_total']) { echo "You do not have enough Stash storage space to send this file. Please upgrade your Stash storage or delete files to make space.\n\n"; echo 'Attempting to send file of size ' . pb_backupbuddy::$format->file_size($backup_file_size) . ' but you only have ' . $stash_quota['quota_available_nice'] . ' available. '; echo 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).'; die; } else { if (isset($stash_quota['quota_warning']) && $stash_quota['quota_warning'] != '') { echo '1Warning: ' . $stash_quota['quota_warning'] . "\n\n"; $success_output = true; } } } wp_schedule_single_event(time(), pb_backupbuddy::cron_tag('remote_send'), array($destination_id, $backup_file, pb_backupbuddy::_POST('trigger'), $send_importbuddy)); spawn_cron(time() + 150); // Adds > 60 seconds to get around once per minute cron running limit. update_option('_transient_doing_cron', 0); // Prevent cron-blocking for next item. // SEE cron.php remote_send() for sending function that we pass to via the cron above. if ($success_output === false) { echo 1; } die; }
public function remote_send() { $success_output = false; // Set to true onece a leading 1 has been sent to the javascript to indicate success. $destination_id = pb_backupbuddy::_POST('destination_id'); if (pb_backupbuddy::_POST('file') != 'importbuddy.php') { $backup_file = backupbuddy_core::getBackupDirectory() . pb_backupbuddy::_POST('file'); if (!file_exists($backup_file)) { // Error if file to send did not exist! $error_message = 'Unable to find file `' . $backup_file . '` to send. File does not appear to exist. You can try again in a moment or turn on full error logging and try again to log for support.'; pb_backupbuddy::status('error', $error_message); pb_backupbuddy::alert($error_message, true); die; } } else { $backup_file = ''; } // Send ImportBuddy along-side? if (pb_backupbuddy::_POST('send_importbuddy') == '1') { $send_importbuddy = true; pb_backupbuddy::status('details', 'Cron send to be scheduled with importbuddy sending.'); } else { $send_importbuddy = false; pb_backupbuddy::status('details', 'Cron send to be scheduled WITHOUT importbuddy sending.'); } // Delete local copy after send completes? if (pb_backupbuddy::_POST('delete_after') == 'true') { $delete_after = true; pb_backupbuddy::status('details', 'Remote send set to delete after successful send.'); } else { $delete_after = false; pb_backupbuddy::status('details', 'Remote send NOT set to delete after successful send.'); } // For Stash we will check the quota prior to initiating send. if (pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash') { // Pass off to destination handler. require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $send_result = pb_backupbuddy_destinations::get_info('stash'); // Used to kick the Stash destination into life. $stash_quota = pb_backupbuddy_destination_stash::get_quota(pb_backupbuddy::$options['remote_destinations'][$destination_id], true); if (isset($stash_quota['error'])) { echo ' Error accessing Stash account. Send aborted. Details: `' . implode(' - ', $stash_quota['error']) . '`.'; die; } if ($backup_file != '') { $backup_file_size = filesize($backup_file); } else { $backup_file_size = 50000; } if ($backup_file_size + $stash_quota['quota_used'] > $stash_quota['quota_total']) { echo "You do not have enough Stash storage space to send this file. Please upgrade your Stash storage or delete files to make space.\n\n"; echo 'Attempting to send file of size ' . pb_backupbuddy::$format->file_size($backup_file_size) . ' but you only have ' . $stash_quota['quota_available_nice'] . ' available. '; echo 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).'; die; } else { if (isset($stash_quota['quota_warning']) && $stash_quota['quota_warning'] != '') { echo '1Warning: ' . $stash_quota['quota_warning'] . "\n\n"; $success_output = true; } } } // end if Stash. pb_backupbuddy::status('details', 'Scheduling cron to send to this remote destination...'); $schedule_result = backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('remote_send'), array($destination_id, $backup_file, pb_backupbuddy::_POST('trigger'), $send_importbuddy, $delete_after)); if ($schedule_result === FALSE) { $error = 'Error scheduling file transfer. Please check your BackupBuddy error log for details. A plugin may have prevented scheduling or the database rejected it.'; pb_backupbuddy::status('error', $error); echo $error; } else { pb_backupbuddy::status('details', 'Cron to send to remote destination scheduled.'); } spawn_cron(time() + 150); // Adds > 60 seconds to get around once per minute cron running limit. update_option('_transient_doing_cron', 0); // Prevent cron-blocking for next item. // SEE cron.php remote_send() for sending function that we pass to via the cron above. if ($success_output === false) { echo 1; } die; }
public static function send_remote_destination($destination_id, $file, $trigger = '', $send_importbuddy = false, $delete_after = false, $identifier = '', $destination_settings = '') { if (defined('PB_DEMO_MODE')) { return false; } if (!file_exists($file)) { pb_backupbuddy::status('error', 'Error #8583489734: Unable to send file `' . $file . '` to remote destination as it no longer exists. It may have been deleted or permissions are invalid.'); return false; } $migrationkey_transient_time = 60 * 60 * 24; if ('' == $file) { $backup_file_size = 50000; // not sure why anything current would be sending importbuddy but NOT sending a backup but just in case... } else { $backup_file_size = filesize($file); } // Generate remote send ID for reference and add it as a new logging serial for better recording details. if ('' == $identifier) { $identifier = pb_backupbuddy::random_string(12); } // Set migration key for later determining last initiated migration. if ('migration' == $trigger) { set_transient('pb_backupbuddy_migrationkey', $identifier, $migrationkey_transient_time); } pb_backupbuddy::status('details', 'Sending file `' . $file . '` to remote destination `' . $destination_id . '` with ID `' . $identifier . '` triggered by `' . $trigger . '`.'); //pb_backupbuddy::status( 'details', 'About to create initial fileoptions data.' ); require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; pb_backupbuddy::status('details', 'Fileoptions instance #35.'); $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $identifier . '.txt', $read_only = false, $ignore_lock = true, $create_file = true); if (true !== ($result = $fileoptions_obj->is_ok())) { pb_backupbuddy::status('error', __('Fatal Error #9034 A. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result); return false; } //pb_backupbuddy::status( 'details', 'Fileoptions data loaded.' ); $fileoptions =& $fileoptions_obj->options; // Set reference. // Record some statistics. $fileoptions = array_merge(self::get_remote_send_defaults(), array('destination' => $destination_id, 'file' => $file, 'file_size' => $backup_file_size, 'trigger' => $trigger, 'send_importbuddy' => $send_importbuddy, 'start_time' => time(), 'finish_time' => 0, 'status' => 'running', 'write_speed' => 0)); pb_backupbuddy::save(); // Destination settings were not passed so get them based on the destination ID provided. if (!is_array($destination_settings)) { $destination_settings =& pb_backupbuddy::$options['remote_destinations'][$destination_id]; } // For Stash we will check the quota prior to initiating send. if (pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash') { // Pass off to destination handler. require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $send_result = pb_backupbuddy_destinations::get_info('stash'); // Used to kick the Stash destination into life. $stash_quota = pb_backupbuddy_destination_stash::get_quota(pb_backupbuddy::$options['remote_destinations'][$destination_id], true); if ($file != '') { $backup_file_size = filesize($file); } else { $backup_file_size = 50000; } if ($backup_file_size + $stash_quota['quota_used'] > $stash_quota['quota_total']) { $message = ''; $message .= "You do not have enough Stash storage space to send this file. Please upgrade your Stash storage at http://ithemes.com/member/panel/stash.php or delete files to make space.\n\n"; $message .= 'Attempting to send file of size ' . pb_backupbuddy::$format->file_size($backup_file_size) . ' but you only have ' . $stash_quota['quota_available_nice'] . ' available. '; $message .= 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).'; pb_backupbuddy::status('error', $message); backupbuddy_core::mail_error($message); $fileoptions['status'] = 'Failure. Insufficient destination space.'; $fileoptions_obj->save(); return false; } else { if (isset($stash_quota['quota_warning']) && $stash_quota['quota_warning'] != '') { // We log warning of usage but dont send error email. $message = ''; $message .= 'WARNING: ' . $stash_quota['quota_warning'] . "\n\nPlease upgrade your Stash storage at http://ithemes.com/member/panel/stash.php or delete files to make space.\n\n"; $message .= 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).'; pb_backupbuddy::status('details', $message); //backupbuddy_core::mail_error( $message ); } } } // end if stash. /* if ( $send_importbuddy === true ) { pb_backupbuddy::status( 'details', 'Generating temporary importbuddy.php file for remote send.' ); pb_backupbuddy::anti_directory_browsing( backupbuddy_core::getTempDirectory(), $die = false ); $importbuddy_temp = backupbuddy_core::getTempDirectory() . 'importbuddy.php'; // Full path & filename to temporary importbuddy self::importbuddy( $importbuddy_temp ); // Create temporary importbuddy. pb_backupbuddy::status( 'details', 'Generated temporary importbuddy.' ); $files[] = $importbuddy_temp; // Add importbuddy file to the list of files to send. $send_importbuddy = true; // Track to delete after finished. } else { pb_backupbuddy::status( 'details', 'Not sending importbuddy.' ); } */ // Clear fileoptions so other stuff can access it if needed. $fileoptions_obj->save(); $fileoptions_obj->unlock(); unset($fileoptions_obj); // Pass off to destination handler. require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; pb_backupbuddy::status('details', 'Calling destination send() function.'); $send_result = pb_backupbuddy_destinations::send($destination_settings, $file, $identifier, $delete_after); pb_backupbuddy::status('details', 'Finished destination send() function.'); self::kick_db(); // Kick the database to make sure it didn't go away, preventing options saving. // Reload fileoptions. pb_backupbuddy::status('details', 'About to load fileoptions data for saving send status.'); require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; pb_backupbuddy::status('details', 'Fileoptions instance #34.'); $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $identifier . '.txt', $read_only = false, $ignore_lock = false, $create_file = false); if (true !== ($result = $fileoptions_obj->is_ok())) { pb_backupbuddy::status('error', __('Fatal Error #9034 G. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result); return false; } pb_backupbuddy::status('details', 'Fileoptions data loaded for ID `' . $identifier . '`.'); $fileoptions =& $fileoptions_obj->options; // Set reference. // Update stats. $fileoptions[$identifier]['finish_time'] = microtime(true); if ($send_result === true) { // succeeded. $fileoptions['status'] = 'success'; $fileoptions['finish_time'] = microtime(true); pb_backupbuddy::status('details', 'Remote send SUCCESS.'); } elseif ($send_result === false) { // failed. $fileoptions['status'] = 'failure'; pb_backupbuddy::status('details', 'Remote send FAILURE.'); } elseif (is_array($send_result)) { // Array so multipart. $fileoptions['status'] = 'multipart'; $fileoptions['finish_time'] = 0; $fileoptions['_multipart_id'] = $send_result[0]; $fileoptions['_multipart_status'] = $send_result[1]; pb_backupbuddy::status('details', 'Multipart send in progress.'); } else { pb_backupbuddy::status('error', 'Error #5485785576463. Invalid status send result: `' . $send_result . '`.'); } $fileoptions_obj->save(); // If we sent importbuddy then delete the local copy to clean up. if ($send_importbuddy !== false) { @unlink($importbuddy_temp); // Delete temporary importbuddy. } // As of v5.0: Post-send deletion now handled within destinations/bootstrap.php send() to support chunked sends. return $send_result; }
// Delete local copy after send completes? if (pb_backupbuddy::_POST('delete_after') == 'true') { $delete_after = true; pb_backupbuddy::status('details', 'Remote send set to delete after successful send.'); } else { $delete_after = false; pb_backupbuddy::status('details', 'Remote send NOT set to delete after successful send.'); } if (!isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) { die('Error #833383: Invalid destination ID `' . htmlentities($destination_id) . '`.'); } // For Stash we will check the quota prior to initiating send. if (pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash') { // Pass off to destination handler. require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $send_result = pb_backupbuddy_destinations::get_info('stash'); // Used to kick the Stash destination into life. $stash_quota = pb_backupbuddy_destination_stash::get_quota(pb_backupbuddy::$options['remote_destinations'][$destination_id], true); if (isset($stash_quota['error'])) { echo ' Error accessing Stash account. Send aborted. Details: `' . implode(' - ', $stash_quota['error']) . '`.'; die; } if ($backup_file != '') { $backup_file_size = filesize($backup_file); } else { $backup_file_size = 50000; } if ($backup_file_size + $stash_quota['quota_used'] > $stash_quota['quota_total']) { echo "You do not have enough Stash storage space to send this file. Please upgrade your Stash storage or delete files to make space.\n\n"; echo 'Attempting to send file of size ' . pb_backupbuddy::$format->file_size($backup_file_size) . ' but you only have ' . $stash_quota['quota_available_nice'] . ' available. '; echo 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).';
function send_remote_destination($destination_id, $file, $trigger = '', $send_importbuddy = false) { pb_backupbuddy::status('details', 'Sending file `' . $file . '` to remote destination `' . $destination_id . '` triggered by `' . $trigger . '`.'); if (defined('PB_DEMO_MODE')) { return false; } // Record some statistics. $identifier = pb_backupbuddy::random_string(12); pb_backupbuddy::$options['remote_sends'][$identifier] = array('destination' => $destination_id, 'file' => $file, 'file_size' => filesize($file), 'trigger' => $trigger, 'send_importbuddy' => $send_importbuddy, 'start_time' => time(), 'finish_time' => 0, 'status' => 'timeout'); pb_backupbuddy::save(); // Prepare variables to pass to remote destination handler. $files = array($file); $destination_settings =& pb_backupbuddy::$options['remote_destinations'][$destination_id]; // For Stash we will check the quota prior to initiating send. if (pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash') { // Pass off to destination handler. require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $send_result = pb_backupbuddy_destinations::get_info('stash'); // Used to kick the Stash destination into life. $stash_quota = pb_backupbuddy_destination_stash::get_quota(pb_backupbuddy::$options['remote_destinations'][$destination_id], true); if ($file != '') { $backup_file_size = filesize($file); } else { $backip_file_size = 50000; } if ($backup_file_size + $stash_quota['quota_used'] > $stash_quota['quota_total']) { $message = ''; $message .= "You do not have enough Stash storage space to send this file. Please upgrade your Stash storage at http://ithemes.com/member/stash.php or delete files to make space.\n\n"; $message .= 'Attempting to send file of size ' . pb_backupbuddy::$format->file_size($backup_file_size) . ' but you only have ' . $stash_quota['quota_available_nice'] . ' available. '; $message .= 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).'; pb_backupbuddy::status('error', $message); pb_backupbuddy::$classes['core']->mail_error($message); pb_backupbuddy::$options['remote_sends'][$identifier]['status'] = 'Failure. Insufficient destination space.'; pb_backupbuddy::save(); return false; } else { if (isset($stash_quota['quota_warning']) && $stash_quota['quota_warning'] != '') { // We log warning of usage but dont send error email. $message = ''; $message .= 'WARNING: ' . $stash_quota['quota_warning'] . "\n\nPlease upgrade your Stash storage at http://ithemes.com/member/stash.php or delete files to make space.\n\n"; $message .= 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).'; pb_backupbuddy::status('details', $message); //pb_backupbuddy::$classes['core']->mail_error( $message ); } } } if ($send_importbuddy === true) { pb_backupbuddy::status('details', 'Generating temporary importbuddy.php file for remote send.'); $importbuddy_temp = pb_backupbuddy::$options['temp_directory'] . 'importbuddy.php'; // Full path & filename to temporary importbuddy $this->importbuddy($importbuddy_temp); // Create temporary importbuddy. pb_backupbuddy::status('details', 'Generated temporary importbuddy.'); $files[] = $importbuddy_temp; // Add importbuddy file to the list of files to send. $send_importbuddy = true; // Track to delete after finished. } else { pb_backupbuddy::status('details', 'Not sending importbuddy.'); } // Pass off to destination handler. require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $send_result = pb_backupbuddy_destinations::send($destination_settings, $files); $this->kick_db(); // Kick the database to make sure it didn't go away, preventing options saving. // Update stats. pb_backupbuddy::$options['remote_sends'][$identifier]['finish_time'] = time(); if ($send_result === true) { // succeeded. pb_backupbuddy::$options['remote_sends'][$identifier]['status'] = 'success'; pb_backupbuddy::status('details', 'Remote send SUCCESS.'); } elseif ($send_result === false) { // failed. pb_backupbuddy::$options['remote_sends'][$identifier]['status'] = 'failure'; pb_backupbuddy::status('details', 'Remote send FAILURE.'); } elseif (is_array($send_result)) { // Array so multipart. pb_backupbuddy::$options['remote_sends'][$identifier]['status'] = 'multipart'; pb_backupbuddy::$options['remote_sends'][$identifier]['finish_time'] = 0; pb_backupbuddy::$options['remote_sends'][$identifier]['_multipart_id'] = $send_result[0]; pb_backupbuddy::$options['remote_sends'][$identifier]['_multipart_status'] = $send_result[1]; pb_backupbuddy::status('details', 'Multipart send in progress.'); } else { pb_backupbuddy::status('error', 'Error #5485785576463. Invalid status send result: `' . $send_result . '`.'); } pb_backupbuddy::save(); // If we sent importbuddy then delete the local copy to clean up. if ($send_importbuddy !== false) { @unlink($importbuddy_temp); // Delete temporary importbuddy. } return $send_result; }
function send_remote_destination($destination_id, $file, $trigger = '', $send_importbuddy = false, $delete_after = false) { if (defined('PB_DEMO_MODE')) { return false; } if ('' == $file) { $backup_file_size = 50000; // not sure why anything current would be sending importbuddy but NOT sending a backup but just in case... } else { $backup_file_size = filesize($file); } pb_backupbuddy::status('details', 'Sending file `' . $file . '` (size: `' . $backup_file_size . '`) to remote destination `' . $destination_id . '` triggered by `' . $trigger . '`.'); // Record some statistics. $identifier = pb_backupbuddy::random_string(12); pb_backupbuddy::$options['remote_sends'][$identifier] = array('destination' => $destination_id, 'file' => $file, 'file_size' => $backup_file_size, 'trigger' => $trigger, 'send_importbuddy' => $send_importbuddy, 'start_time' => time(), 'finish_time' => 0, 'status' => 'timeout'); pb_backupbuddy::save(); // Prepare variables to pass to remote destination handler. if ('' == $file) { // No file to send (blank string file typically happens when just sending importbuddy). $files = array(); } else { $files = array($file); } $destination_settings =& pb_backupbuddy::$options['remote_destinations'][$destination_id]; // For Stash we will check the quota prior to initiating send. if (pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash') { // Pass off to destination handler. require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $send_result = pb_backupbuddy_destinations::get_info('stash'); // Used to kick the Stash destination into life. $stash_quota = pb_backupbuddy_destination_stash::get_quota(pb_backupbuddy::$options['remote_destinations'][$destination_id], true); if ($file != '') { $backup_file_size = filesize($file); } else { $backup_file_size = 50000; } if ($backup_file_size + $stash_quota['quota_used'] > $stash_quota['quota_total']) { $message = ''; $message .= "You do not have enough Stash storage space to send this file. Please upgrade your Stash storage at http://ithemes.com/member/stash.php or delete files to make space.\n\n"; $message .= 'Attempting to send file of size ' . pb_backupbuddy::$format->file_size($backup_file_size) . ' but you only have ' . $stash_quota['quota_available_nice'] . ' available. '; $message .= 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).'; pb_backupbuddy::status('error', $message); pb_backupbuddy::$classes['core']->mail_error($message); pb_backupbuddy::$options['remote_sends'][$identifier]['status'] = 'Failure. Insufficient destination space.'; pb_backupbuddy::save(); return false; } else { if (isset($stash_quota['quota_warning']) && $stash_quota['quota_warning'] != '') { // We log warning of usage but dont send error email. $message = ''; $message .= 'WARNING: ' . $stash_quota['quota_warning'] . "\n\nPlease upgrade your Stash storage at http://ithemes.com/member/stash.php or delete files to make space.\n\n"; $message .= 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).'; pb_backupbuddy::status('details', $message); //pb_backupbuddy::$classes['core']->mail_error( $message ); } } } if ($send_importbuddy === true) { pb_backupbuddy::status('details', 'Generating temporary importbuddy.php file for remote send.'); $importbuddy_temp = pb_backupbuddy::$options['temp_directory'] . 'importbuddy.php'; // Full path & filename to temporary importbuddy $this->importbuddy($importbuddy_temp); // Create temporary importbuddy. pb_backupbuddy::status('details', 'Generated temporary importbuddy.'); $files[] = $importbuddy_temp; // Add importbuddy file to the list of files to send. $send_importbuddy = true; // Track to delete after finished. } else { pb_backupbuddy::status('details', 'Not sending importbuddy.'); } // Pass off to destination handler. require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php'; $send_result = pb_backupbuddy_destinations::send($destination_settings, $files); $this->kick_db(); // Kick the database to make sure it didn't go away, preventing options saving. // Update stats. pb_backupbuddy::$options['remote_sends'][$identifier]['finish_time'] = time(); if ($send_result === true) { // succeeded. pb_backupbuddy::$options['remote_sends'][$identifier]['status'] = 'success'; pb_backupbuddy::status('details', 'Remote send SUCCESS.'); } elseif ($send_result === false) { // failed. pb_backupbuddy::$options['remote_sends'][$identifier]['status'] = 'failure'; pb_backupbuddy::status('details', 'Remote send FAILURE.'); } elseif (is_array($send_result)) { // Array so multipart. pb_backupbuddy::$options['remote_sends'][$identifier]['status'] = 'multipart'; pb_backupbuddy::$options['remote_sends'][$identifier]['finish_time'] = 0; pb_backupbuddy::$options['remote_sends'][$identifier]['_multipart_id'] = $send_result[0]; pb_backupbuddy::$options['remote_sends'][$identifier]['_multipart_status'] = $send_result[1]; pb_backupbuddy::status('details', 'Multipart send in progress.'); } else { pb_backupbuddy::status('error', 'Error #5485785576463. Invalid status send result: `' . $send_result . '`.'); } pb_backupbuddy::save(); // If we sent importbuddy then delete the local copy to clean up. if ($send_importbuddy !== false) { @unlink($importbuddy_temp); // Delete temporary importbuddy. } // Handle post-send deletion on success. pb_backupbuddy::status('details', 'Checking if local file should be deleted after remote send based on settings.'); if (true === $send_result) { // Success; only continue on bool true. false indicates failure, array chunking. if (true == $delete_after) { // Delete enabled so delete file. pb_backupbuddy::status('details', 'Local file should be deleted based on settings & success. Deleting local copy of file sent to destination.'); if (file_exists($file)) { $unlink_result = @unlink($file); if (true !== $unlink_result) { pb_backupbuddy::status('error', 'Unable to unlink local file `' . $file . '`.'); } } if (file_exists($file)) { // File still exists. pb_backupbuddy::status('details', __('Error. Unable to delete local file `' . $file . '` after send as set in settings.', 'it-l10n-backupbuddy')); $this->mail_error('BackupBuddy was unable to delete local file `' . $file . '` after successful remove transfer though post-remote send deletion is enabled. You may want to delete it manually. This can be caused by permission problems or improper server configuration.'); } else { // Deleted. pb_backupbuddy::status('details', __('Deleted local archive after successful remote destination send based on settings.', 'it-l10n-backupbuddy')); pb_backupbuddy::status('action', 'archive_deleted'); } } else { // Delete after disabled. pb_backupbuddy::status('details', 'Post-send local file deletion disabled so skipping.'); } } else { // Send failed or not complete (chunking). pb_backupbuddy::status('details', 'Remote send not completed so skipping post-send deletion check.'); } return $send_result; }
:</h3> <div class="bb-dest clearfix pb_backupbuddy_destination_list"> <?php foreach (pb_backupbuddy::$options['remote_destinations'] as $destination_id => $destination) { if ($mode == 'migration') { if ($destination['type'] != 'local' && $destination['type'] != 'ftp') { // if not local or ftp when in migration mode then skip. continue; } } // Destinations may hide the add and test buttons by altering these variables. $pb_hide_save = false; $pb_hide_test = false; $destination_info = pb_backupbuddy_destinations::get_info($destination['type']); ?> <div class="bb-dest-option" id="pb_backupbuddy_destpicker_dest_<?php echo $destination_id; ?> " rel="<?php echo $destination_id; ?> "> <a href="#select" class="info added dest_select_select" title="Click here<?php echo $action_verb; ?> ."> <span class="icon <?php echo $destination['type'];
echo '<br>'; } global $pb_hide_save; if (pb_backupbuddy::_GET('add') != '') { $destination_type = pb_backupbuddy::_GET('add'); //echo '<h2>Add New Destination</h2>'; // the following scrollTo is so that once scrolling page down to look at long list of destinations to add, coming here bumps them back to the proper place up top. ?> <script> var win = window.dialogArguments || opener || parent || top; win.window.scrollTo(0,0); </script> <?php $destination_info = pb_backupbuddy_destinations::get_info($destination_type); echo '<h3>' . $destination_info['name'] . '</h3>'; echo '<div class="pb_backupbuddy_destpicker_id bb-dest-option" rel="NEW">'; $settings = pb_backupbuddy_destinations::configure(array('type' => $destination_type), 'add'); if ($settings === false) { echo 'Error #556656a. Unable to display configuration.'; } else { if ($pb_hide_test !== true) { $test_button = '<a href="#" class="button secondary-button pb_backupbuddy_destpicker_test" href="#" title="Test destination settings.">Test Settings<img class="pb_backupbuddy_destpicker_testload" src="' . pb_backupbuddy::plugin_url() . '/images/loading.gif" title="Testing... This may take several seconds..."></a> '; } else { $test_button = ''; } if ($pb_hide_save !== true) { $save_button = '<img class="pb_backupbuddy_destpicker_saveload" src="' . pb_backupbuddy::plugin_url() . '/images/loading.gif" title="Saving... This may take a few seconds...">'; echo $settings->display_settings('+ Add Destination', $test_button, $save_button, 'pb_backupbuddy_destpicker_save'); // title, before, after, class