コード例 #1
0
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
     if (true === ($results = pb_backupbuddy_destinations::test($settings))) {
         return array('api' => '0', 'status' => 'ok', 'message' => 'Supported destinations retrieved.');
     } else {
         return array('api' => '0', 'status' => 'error', 'message' => $results);
     }
 }
コード例 #2
0
ファイル: init.php プロジェクト: Offirmo/base-wordpress
 public static function test($settings)
 {
     /*
     if ( ( $settings['address'] == '' ) || ( $settings['username'] == '' ) || ( $settings['password'] == '' ) ) {
     	return __('Missing required input.', 'it-l10n-backupbuddy' );
     }
     */
     // Try sending a file.
     return pb_backupbuddy_destinations::send($settings, dirname(dirname(__FILE__)) . '/remote-send-test.php', $send_id = 'TEST-' . pb_backupbuddy::random_string(12));
     // 3rd param true forces clearing of any current uploads.
 }
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
     $response = pb_backupbuddy_destinations::delete($arguments['id'], true);
     if (true === $response) {
         return array('api' => '0', 'status' => 'ok', 'message' => 'Destination deleted.');
     } else {
         return array('api' => '0', 'status' => 'error', 'message' => 'Error #384783783: Failure deleting destination.');
     }
 }
コード例 #4
0
                backupbuddy_core::mail_error($message);
            }
        }
    }
}
// Cleanup remote S3 multipart chunking.
foreach (pb_backupbuddy::$options['remote_destinations'] as $destination) {
    if ($destination['type'] != 's3') {
        continue;
    }
    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) {
コード例 #5
0
ファイル: cron.php プロジェクト: elephantcode/elephantcode
 function process_destination_copy($destination_settings, $remote_file, $fileID = '')
 {
     pb_backupbuddy::set_greedy_script_limits();
     if (!class_exists('backupbuddy_core')) {
         require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
     }
     require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
     $local_file = backupbuddy_core::getBackupDirectory() . basename($remote_file);
     if (file_exists(basename($local_file))) {
         $local_file = str_replace('backup-', 'backup_copy_' . pb_backupbuddy::random_string(5) . '-', $local_file);
     }
     if ($fileID != '') {
         $remote_file = $fileID;
     }
     if (true === pb_backupbuddy_destinations::getFile($destination_settings, $remote_file, $local_file)) {
         pb_backupbuddy::status('message', 'Success copying remote file to local.');
         return true;
     } else {
         pb_backupbuddy::status('error', 'Failure copying remote file to local.');
         return false;
     }
 }
コード例 #6
0
    $url = pb_backupbuddy::ajax_url('remoteClient') . '&destination_id=' . $destination_id;
    echo '<iframe id="pb_backupbuddy_iframe-dest-' . $destination_id . '" src="' . $url . '" width="100%" height="3000" frameBorder="0">Error #4584594579. Browser not compatible with iframes.</iframe>';
    echo '</div>';
    pb_backupbuddy::$ui->end_tab();
}
pb_backupbuddy::$ui->start_tab('add_new');
$destination_type = pb_backupbuddy::_GET('add');
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
?>
	<div class="bb_destinations" style="display: block; margin: 0;">
		<div class="bb_destinations-group bb_destinations-new" style="display: block;">
			<h3>What kind of destination do you want to add?</h3>
			<ul>
				<?php 
$i = 0;
foreach (pb_backupbuddy_destinations::get_destinations_list($showUnavailable = true) as $destination_name => $destination) {
    $i++;
    if (true === $destination['compatible']) {
        echo '<li class="bb_destination-item bb_destination-' . $destination_name . ' bb_destination-new-item">';
        /*
        if ( 's32' == $destination_name ) {
        	echo '<div class="bb-ribbon"><span>New</span></div>';
        }
        */
        if ('stash2' == $destination_name) {
            echo '<div class="bb-ribbon"><span>New</span></div>';
        }
        echo '<a href="javascript:void(0)" rel="' . $destination_name . '">';
        echo $destination['name'];
        echo '</a></li>';
    } else {
コード例 #7
0
ファイル: _destination_picker.php プロジェクト: emjayoh/bhag
function pb_bb_add_box($mode, $picker_url, $hideBack = false)
{
    ?>
	<div class="bb_destinations-group bb_destinations-new">
		<h3>What kind of destination do you want to add?</h3>
		<ul>
			<?php 
    $i = 0;
    foreach (pb_backupbuddy_destinations::get_destinations_list() as $destination_name => $destination) {
        if ($mode == 'migration') {
            if ($destination_name != 'local' && $destination_name != 'ftp' && $destination_name != 'sftp') {
                // if not local or ftp when in migration mode then skip.
                continue;
            }
        }
        // Filter only showing certain destination type.
        if ('' != pb_backupbuddy::_GET('filter')) {
            if ($destination_name != pb_backupbuddy::_GET('filter')) {
                continue;
                // Move along to next destination.
            }
        }
        $i++;
        echo '<li class="bb_destination-item bb_destination-' . $destination_name . ' bb_destination-new-item"><a href="' . $picker_url . '&add=' . $destination_name . '&callback_data=' . pb_backupbuddy::_GET('callback_data') . '&sending=' . pb_backupbuddy::_GET('sending') . '" rel="' . $destination_name . '">' . $destination['name'] . '</a></li>';
        if ($i >= 5) {
            echo '<span class="bb_destination-break"></span>';
            $i = 0;
        }
    }
    if (false === $hideBack) {
        ?>
				<br><br>
				<a href="javascript:void(0)" class="btn btn-small btn-white btn-with-icon btn-back btn-back-add"  onClick="jQuery('.bb_destinations-new').hide(); jQuery('.bb_destinations-existing').show();"><span class="btn-icon"></span>Back to existing destinations</a>
			<?php 
    }
    ?>
		</ul>
	</div>
	<?php 
}
コード例 #8
0
// 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'] . '%).';
コード例 #9
0
<?php

if (!is_admin()) {
    die('Access denied.');
}
/* remote_delete()
*
* description
*
*/
pb_backupbuddy::verify_nonce();
// Security check.
// Destination ID.
$destination_id = pb_backupbuddy::_GET('pb_backupbuddy_destinationid');
// Delete the destination.
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
$delete_response = pb_backupbuddy_destinations::delete_destination($destination_id, true);
// Response.
if ($delete_response !== true) {
    // Some kind of error so just echo it.
    echo 'Error #544558: `' . $delete_response . '`.';
} else {
    // Success.
    echo 'Destination deleted.';
}
die;
コード例 #10
0
ファイル: init.php プロジェクト: shelbyneilsmith/wptools
 public static function test($settings)
 {
     $settings = self::_init($settings);
     // Try sending a file.
     $send_response = pb_backupbuddy_destinations::send($settings, dirname(dirname(__FILE__)) . '/remote-send-test.php', $send_id = 'TEST-' . pb_backupbuddy::random_string(12));
     // 3rd param true forces clearing of any current uploads.
     if (false === $send_response) {
         $send_response = 'Error sending test file to S3.';
     } else {
         $send_response = 'Success.';
     }
     // Delete sent file.
     $delete_response = 'Success.';
     try {
         $delete_response = self::$_client->delete_object(array('Bucket' => $settings['bucket'], 'Key' => $settings['directory'] . 'remote-send-test.php'));
         $delete_response = 'Success.';
     } catch (Exception $e) {
         pb_backupbuddy::status('details', 'Unable to delete test S3 file `remote-send-test.php`. Details: `' . $e->getMessage() . '`.');
     }
     // Load destination fileoptions.
     pb_backupbuddy::status('details', 'About to load fileoptions data.');
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     pb_backupbuddy::status('details', 'Fileoptions instance #7.');
     $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
     if (true !== ($result = $fileoptions_obj->is_ok())) {
         return self::_error(__('Fatal Error #9034.84838. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
     }
     pb_backupbuddy::status('details', 'Fileoptions data loaded.');
     $fileoptions =& $fileoptions_obj->options;
     if ('Success.' != $send_response || 'Success.' != $delete_response) {
         $fileoptions['status'] = 'failure';
         $fileoptions_obj->save();
         unset($fileoptions_obj);
         return 'Send details: `' . $send_response . '`. Delete details: `' . $delete_response . '`.';
     } else {
         $fileoptions['status'] = 'success';
         $fileoptions['finish_time'] = time();
     }
     $fileoptions_obj->save();
     unset($fileoptions_obj);
     return true;
 }
コード例 #11
0
ファイル: core.php プロジェクト: netfor/nextrading
 public static function periodic_cleanup($backup_age_limit = 172800, $die_on_fail = true)
 {
     $max_importbuddy_age = 60 * 60 * 1;
     // 1hr - Max age, in seconds, importbuddy files can be there before cleaning up (delay useful if just imported and testing out site).
     $max_status_log_age = 48;
     // Max age in hours.
     $max_site_log_size = pb_backupbuddy::$options['max_site_log_size'] * 1024 * 1024;
     // in bytes.
     pb_backupbuddy::status('message', 'Starting cleanup procedure for BackupBuddy v' . pb_backupbuddy::settings('version') . '.');
     if (!isset(pb_backupbuddy::$options)) {
         self::load();
     }
     // Alert user if no new backups FINISHED within X number of days if enabled. Max 1 email notification per 24 hours period.
     if (pb_backupbuddy::$options['no_new_backups_error_days'] > 0) {
         if (pb_backupbuddy::$options['last_backup_finish'] > 0) {
             $time_since_last = time() - pb_backupbuddy::$options['last_backup_finish'];
             $days_since_last = $time_since_last / 60 / 60 / 24;
             if ($days_since_last > pb_backupbuddy::$options['no_new_backups_error_days']) {
                 $last_sent = get_transient('pb_backupbuddy_no_new_backup_error');
                 if (false === $last_sent) {
                     $last_sent = time();
                     set_transient('pb_backupbuddy_no_new_backup_error', $last_sent, 60 * 60 * 24);
                 }
                 if (time() - $last_sent > 60 * 60 * 24) {
                     // 24hrs+ elapsed since last email sent.
                     $message = 'Alert! BackupBuddy is configured to notify you if no new backups have completed in `' . pb_backupbuddy::$options['no_new_backups_error_days'] . '` days. It has been `' . $days_since_last . '` days since your last completed backups.';
                     pb_backupbuddy::status('warning', $message);
                     backupbuddy_core::mail_error($message);
                 }
             }
         }
     }
     // TODO: Check for orphaned .gz files in root from PCLZip.
     // Cleanup backup itegrity portion of array (status logging info inside function).
     // DEPRECATED: self::trim_backups_integrity_stats();
     /***** BEGIN CLEANUP LOGS *****/
     // Purge old logs.
     pb_backupbuddy::status('details', 'Cleaning up old logs.');
     $log_directory = backupbuddy_core::getLogDirectory();
     // Purge individual backup status logs unmodified in certain number of hours.
     $files = glob($log_directory . 'status-*.txt');
     if (is_array($files) && !empty($files)) {
         // For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match.
         foreach ($files as $file) {
             $file_stats = stat($file);
             if (time() - $file_stats['mtime'] > $max_status_log_age) {
                 @unlink($file);
             }
         }
     }
     // Purge site-wide log if over certain size.
     $files = glob($log_directory . 'log-*.txt');
     if (is_array($files) && !empty($files)) {
         // For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match.
         foreach ($files as $file) {
             $file_stats = stat($file);
             if ($file_stats['size'] > $max_site_log_size) {
                 self::mail_error('NOTICE ONLY (not an error): A BackupBuddy log file has exceeded the size threshold of ' . $max_site_log_size . ' KB and has been deleted to maintain performance. This is only a notice. Deleted log file: ' . $file . '.');
                 @unlink($file);
             }
         }
     }
     /***** END CLEANUP LOGS *****/
     // Cleanup any temporary local destinations.
     pb_backupbuddy::status('details', 'Cleaning up any temporary local destinations.');
     foreach (pb_backupbuddy::$options['remote_destinations'] as $destination_id => $destination) {
         if ($destination['type'] == 'local' && (isset($destination['temporary']) && $destination['temporary'] === true)) {
             // If local and temporary.
             if (time() - $destination['created'] > $backup_age_limit) {
                 // Older than 12 hours; clear out!
                 pb_backupbuddy::status('details', 'Cleaned up stale local destination `' . $destination_id . '`.');
                 unset(pb_backupbuddy::$options['remote_destinations'][$destination_id]);
                 pb_backupbuddy::save();
             }
         }
     }
     // Cleanup excess remote sending stats.
     pb_backupbuddy::status('details', 'Cleaning up remote send stats.');
     self::trim_remote_send_stats($backup_age_limit);
     // Verify directory existance and anti-directory browsing is in place everywhere.
     self::verify_directories();
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     // Purge fileoptions files without matching backup file in existance that are older than 30 days.
     pb_backupbuddy::status('details', 'Cleaning up old backup fileoptions option files.');
     $fileoptions_directory = backupbuddy_core::getLogDirectory() . 'fileoptions/';
     $files = glob($fileoptions_directory . '*.txt');
     if (!is_array($files)) {
         $files = array();
     }
     foreach ($files as $file) {
         $backup_options = new pb_backupbuddy_fileoptions($file, $read_only = true);
         if (true !== ($result = $backup_options->is_ok())) {
             pb_backupbuddy::status('error', 'Error retrieving fileoptions file `' . $file . '`. Err 335353266.');
         } else {
             if (isset($backup_options->options['archive_file'])) {
                 if (!file_exists($backup_options->options['archive_file'])) {
                     // No corresponding backup ZIP file.
                     $modified = filemtime($file);
                     if (time() - $modified > self::MAX_SECONDS_TO_KEEP_ORPHANED_FILEOPTIONS_FILES) {
                         // Too many days old so delete.
                         if (false === unlink($file)) {
                             pb_backupbuddy::status('error', 'Unable to delete orphaned fileoptions file `' . $file . '`.');
                         }
                         if (file_exists($file . '.lock')) {
                             @unlink($file . '.lock');
                         }
                     } else {
                         // Do not delete orphaned fileoptions because it is not old enough. Recent backups page needs these to list the backup.
                     }
                 } else {
                     // Backup ZIP file exists.
                 }
             }
         }
     }
     // end foreach.
     // Handle high security mode archives directory .htaccess system. If high security backup directory mode: Make sure backup archives are NOT downloadable by default publicly. This is only lifted for ~8 seconds during a backup download for security. Overwrites any existing .htaccess in this location.
     if (pb_backupbuddy::$options['lock_archives_directory'] == '0') {
         // Normal security mode. Put normal .htaccess.
         pb_backupbuddy::status('details', 'Removing .htaccess high security mode for backups directory. Normal mode .htaccess to be added next.');
         // Remove high security .htaccess.
         if (file_exists(backupbuddy_core::getBackupDirectory() . '.htaccess')) {
             $unlink_status = @unlink(backupbuddy_core::getBackupDirectory() . '.htaccess');
             if ($unlink_status === false) {
                 pb_backupbuddy::alert('Error #844594. Unable to temporarily remove .htaccess security protection on archives directory to allow downloading. Please verify permissions of the BackupBuddy archives directory or manually download via FTP.');
             }
         }
         // Place normal .htaccess.
         pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getBackupDirectory(), $die_on_fail);
     } else {
         // High security mode. Make sure high security .htaccess in place.
         pb_backupbuddy::status('details', 'Adding .htaccess high security mode for backups directory.');
         $htaccess_creation_status = @file_put_contents(backupbuddy_core::getBackupDirectory() . '.htaccess', 'deny from all');
         if ($htaccess_creation_status === false) {
             pb_backupbuddy::alert('Error #344894545. Security Warning! Unable to create security file (.htaccess) in backups archive directory. This file prevents unauthorized downloading of backups should someone be able to guess the backup location and filenames. This is unlikely but for best security should be in place. Please verify permissions on the backups directory.');
         }
     }
     // Remove any copy of importbuddy.php in root.
     pb_backupbuddy::status('details', 'Cleaning up importbuddy.php script in site root if it exists & is not very recent.');
     if (file_exists(ABSPATH . 'importbuddy.php')) {
         $modified = filemtime(ABSPATH . 'importbuddy.php');
         if (FALSE === $modified || time() > $modified + $max_importbuddy_age) {
             // If time modified unknown OR was modified long enough ago.
             pb_backupbuddy::status('details', 'Unlinked importbuddy.php in root of site.');
             unlink(ABSPATH . 'importbuddy.php');
         } else {
             pb_backupbuddy::status('details', 'SKIPPED unlinking importbuddy.php in root of site as it is fresh and may still be in use.');
         }
     }
     // Remove any copy of importbuddy directory in root.
     pb_backupbuddy::status('details', 'Cleaning up importbuddy directory in site root if it exists & is not very recent.');
     if (file_exists(ABSPATH . 'importbuddy/')) {
         $modified = filemtime(ABSPATH . 'importbuddy/');
         if (FALSE === $modified || time() > $modified + $max_importbuddy_age) {
             // If time modified unknown OR was modified long enough ago.
             pb_backupbuddy::status('details', 'Unlinked importbuddy directory recursively in root of site.');
             pb_backupbuddy::$filesystem->unlink_recursive(ABSPATH . 'importbuddy/');
         } else {
             pb_backupbuddy::status('details', 'SKIPPED unlinked importbuddy directory recursively in root of site as it is fresh and may still be in use.');
         }
     }
     // Remove any old temporary directories in wp-content/uploads/backupbuddy_temp/. Logs any directories it cannot delete.
     pb_backupbuddy::status('details', 'Cleaning up any old temporary zip directories in: wp-content/uploads/backupbuddy_temp/');
     $temp_directory = WP_CONTENT_DIR . '/uploads/backupbuddy_temp/';
     $files = glob($temp_directory . '*');
     if (is_array($files) && !empty($files)) {
         // For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match.
         foreach ($files as $file) {
             if (strpos($file, 'index.') !== false || strpos($file, '.htaccess') !== false) {
                 // Index file or htaccess dont get deleted so go to next file.
                 continue;
             }
             $file_stats = stat($file);
             if (0 == $backup_age_limit || time() - $file_stats['mtime'] > $backup_age_limit) {
                 // If older than 12 hours, delete the log.
                 if (@pb_backupbuddy::$filesystem->unlink_recursive($file) === false) {
                     pb_backupbuddy::status('error', 'Unable to clean up (delete) temporary directory/file: `' . $file . '`. You should manually delete it or check permissions.');
                 }
             }
         }
     }
     // Cleanup any temp files from a failed restore within WordPress. (extract file feature).
     $temp_dir = get_temp_dir();
     pb_backupbuddy::status('details', 'Cleaning up temporary files from individual file / directory restores in directory `' . $temp_dir . '`...');
     $possibly_temp_restore_dirs = glob($temp_dir . 'backupbuddy-*');
     if (!is_array($possibly_temp_restore_dirs)) {
         $possibly_temp_restore_dirs = array();
     }
     foreach ($possibly_temp_restore_dirs as $possibly_temp_restore_dir) {
         if (false === pb_backupbuddy::$filesystem->unlink_recursive($possibly_temp_restore_dir)) {
             // Delete.
             pb_backupbuddy::status('details', 'Unable to delete temporary holding directory `' . $possibly_temp_restore_dir . '`.');
         } else {
             pb_backupbuddy::status('details', 'Cleaned up temporary files.');
         }
     }
     pb_backupbuddy::status('details', 'Individual file / directory restore cleanup complete.');
     // Remove any old temporary zip directories: wp-content/uploads/backupbuddy_backups/temp_zip_XXXX/. Logs any directories it cannot delete.
     pb_backupbuddy::status('details', 'Cleaning up any old temporary zip directories in backup directory temp location `' . backupbuddy_core::getBackupDirectory() . 'temp_zip_XXXX/`.');
     // $temp_directory = WP_CONTENT_DIR . '/uploads/backupbuddy_backups/temp_zip_*';
     $temp_directory = backupbuddy_core::getBackupDirectory() . 'temp_zip_*';
     $files = glob($temp_directory . '*');
     if (is_array($files) && !empty($files)) {
         // For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match.
         foreach ($files as $file) {
             if (strpos($file, 'index.') !== false || strpos($file, '.htaccess') !== false) {
                 // Index file or htaccess dont get deleted so go to next file.
                 continue;
             }
             $file_stats = stat($file);
             if (time() - $file_stats['mtime'] > $backup_age_limit) {
                 // If older than 12 hours, delete the log.
                 if (@pb_backupbuddy::$filesystem->unlink_recursive($file) === false) {
                     $message = 'BackupBuddy was unable to clean up (delete) temporary directory/file: `' . $file . '`. You should manually delete it and/or verify proper file permissions to allow BackupBuddy to clean up for you.';
                     pb_backupbuddy::status('error', $message);
                     self::mail_error($message);
                 }
             }
         }
     }
     // Cleanup remote S3 multipart chunking.
     foreach (pb_backupbuddy::$options['remote_destinations'] as $destination) {
         if ($destination['type'] != 's3') {
             continue;
         }
         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.' );
         }
         */
     }
     @clearstatcache();
     // Clears file info stat cache.
     pb_backupbuddy::status('message', 'Finished cleanup procedure.');
 }
コード例 #12
0
<?php

backupbuddy_core::verifyAjaxAccess();
pb_backupbuddy::$ui->ajax_header();
if (isset(pb_backupbuddy::$options['remote_destinations'][pb_backupbuddy::_GET('destination_id')])) {
    $destination = pb_backupbuddy::$options['remote_destinations'][$_GET['destination_id']];
} else {
    echo 'Error #438934894349. Invalid destination ID `' . pb_backupbuddy::_GET('destination_id') . '`.';
    return;
}
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
pb_backupbuddy_destinations::manage($destination, $_GET['destination_id']);
/*
echo '<br><br><br>';
echo '<a class="button" href="';
if ( is_network_admin() ) {
	echo network_admin_url( 'admin.php' );
} else {
	echo admin_url( 'admin.php' );
}
echo '?page=pb_backupbuddy_destinations">&larr; back to destinations</a><br><br>';
*/
pb_backupbuddy::$ui->ajax_footer();
die;
コード例 #13
0
 public function run($arguments)
 {
     $arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
     require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
     return array('api' => '0', 'status' => 'ok', 'message' => 'Supported destinations retrieved.', 'destinations' => pb_backupbuddy_destinations::get_destinations_list());
 }
コード例 #14
0
ファイル: housekeeping.php プロジェクト: arobbins/spellestate
 public static function s32_cancel_multipart_pieces()
 {
     foreach (pb_backupbuddy::$options['remote_destinations'] as $destination) {
         if ($destination['type'] != 's32') {
             continue;
         }
         pb_backupbuddy::status('details', 'Found S32 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', 'S32 Multipart Chunking Cleanup Success.');
         } else {
             pb_backupbuddy::status('warning', 'Warning #2389328: S32 Multipart Chunking Cleanup FAILURE. Manually cleanup stalled multipart send via S3 or try again later.');
         }
     }
 }
コード例 #15
0
<?php

backupbuddy_core::verifyAjaxAccess();
pb_backupbuddy::$ui->ajax_header($js = true, $padding = true);
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
require_once pb_backupbuddy::plugin_path() . '/destinations/live/live.php';
require_once pb_backupbuddy::plugin_path() . '/destinations/live/live_periodic.php';
$destination_id = backupbuddy_live::getLiveID();
$destination_settings = backupbuddy_live_periodic::get_destination_settings();
echo '<h2>' . __('BackupBuddy Stash Live Settings', 'it-l10n-backupbuddy') . '</h2>';
// Settings form setup.
$settings_form = pb_backupbuddy_destinations::configure($destination_settings, $mode = 'edit', $destination_id, $url = pb_backupbuddy::ajax_url('live_settings'));
// Process saving.
if ('' != pb_backupbuddy::_POST('pb_backupbuddy_')) {
    pb_backupbuddy::verify_nonce();
    $save_result = $settings_form->process();
    if (count($save_result['errors']) == 0) {
        // NO ERRORS SO SAVE.
        pb_backupbuddy::$options['remote_destinations'][$destination_id] = array_merge(pb_backupbuddy::$options['remote_destinations'][$destination_id], $save_result['data']);
        pb_backupbuddy::save();
        pb_backupbuddy::alert(__('Settings saved. Restarting Live process so they take immediate effect.', 'it-l10n-backupbuddy'));
        set_transient('backupbuddy_live_jump', array('daily_init', array()), 60 * 60 * 48);
        // Tells Live process to restart from the beginning (if mid-process) so new settigns apply.
        // Add final entry to log if disabled
        if ($destination_settings['disable_logging'] == 0 && $save_result['data']['disable_logging'] == 1) {
            $previous_status_serial = pb_backupbuddy::get_status_serial();
            // Hold current serial.
            pb_backupbuddy::set_status_serial('live_periodic');
            // Redirect logging output to a certain log file.
            pb_backupbuddy::status('details', '-----');
            pb_backupbuddy::status('details', 'Logging disabled in Stash Live --> Settings --> Advanced.');
コード例 #16
0
ファイル: _remote_client.php プロジェクト: FelixNong1990/andy
<?php

if (isset(pb_backupbuddy::$options['remote_destinations'][$_GET['destination_id']])) {
    $destination =& pb_backupbuddy::$options['remote_destinations'][$_GET['destination_id']];
} else {
    echo __('Error #438934894349. Invalid destination ID.', 'it-l10n-backupbuddy');
    return;
}
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
pb_backupbuddy_destinations::manage($destination);
echo '<br><br><br>';
echo '<a class="button" href="';
if (is_network_admin()) {
    echo network_admin_url('admin.php');
} else {
    echo admin_url('admin.php');
}
echo '?page=pb_backupbuddy_destinations">&larr; back to destinations</a><br><br>';
コード例 #17
0
ファイル: init.php プロジェクト: AgilData/WordPress-Skeleton
 public static function test($settings)
 {
     $settings = self::_init($settings);
     $sendOK = false;
     $deleteOK = false;
     $send_id = 'TEST-' . pb_backupbuddy::random_string(12);
     // Try sending a file.
     if ('1' == $settings['stash_mode']) {
         // Stash mode.
         $settings['type'] = 'stash2';
     }
     $send_response = pb_backupbuddy_destinations::send($settings, dirname(dirname(__FILE__)) . '/remote-send-test.php', $send_id);
     // 3rd param true forces clearing of any current uploads.
     if (true === $send_response) {
         $send_response = __('Success.', 'it-l10n-backupbuddy');
         $sendOK = true;
     } else {
         global $pb_backupbuddy_destination_errors;
         $send_response = 'Error sending test file to S3 (v2). Details: `' . implode(', ', $pb_backupbuddy_destination_errors) . '`.';
     }
     pb_backupbuddy::add_status_serial('remote_send-' . $send_id);
     // Delete sent file if it was sent.
     $delete_response = 'n/a';
     if (true === $sendOK) {
         pb_backupbuddy::status('details', 'Preparing to delete sent test file.');
         if ('1' == $settings['stash_mode']) {
             // Stash mode.
             if (true === ($delete_response = pb_backupbuddy_destination_stash2::deleteFile($settings, 'remote-send-test.php'))) {
                 // success
                 $delete_response = __('Success.', 'it-l10n-backupbuddy');
                 $deleteOK = true;
             } else {
                 // error
                 $error = 'Unable to delete Stash test file `remote-send-test.php`. Details: `' . $delete_response . '`.';
                 $delete_response = $error;
                 $deleteOK = false;
             }
         } else {
             // S3 mode.
             if (true === ($delete_response = self::deleteFile($settings, 'remote-send-test.php'))) {
                 $delete_response = __('Success.', 'it-l10n-backupbuddy');
                 $deleteOK = true;
             } else {
                 $error = 'Unable to delete test file `remote-send-test.php`. Details: `' . $delete_response . '`.';
                 pb_backupbuddy::status('details', $error);
                 $delete_response = $error;
                 $deleteOK = false;
             }
         }
     } else {
         // end if $sendOK.
         pb_backupbuddy::status('details', 'Skipping test delete due to failed send.');
     }
     // Load destination fileoptions.
     pb_backupbuddy::status('details', 'About to load fileoptions data.');
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     pb_backupbuddy::status('details', 'Fileoptions instance #7.');
     $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
     if (true !== ($result = $fileoptions_obj->is_ok())) {
         return self::_error(__('Fatal Error #9034.84838. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
     }
     pb_backupbuddy::status('details', 'Fileoptions data loaded.');
     $fileoptions =& $fileoptions_obj->options;
     if (true !== $sendOK || true !== $deleteOK) {
         $fileoptions['status'] = 'failure';
         $fileoptions_obj->save();
         unset($fileoptions_obj);
         return 'Send details: `' . $send_response . '`. Delete details: `' . $delete_response . '`.';
     } else {
         $fileoptions['status'] = 'success';
         $fileoptions['finish_time'] = time();
     }
     $fileoptions_obj->save();
     unset($fileoptions_obj);
     pb_backupbuddy::status('details', 'Finished test function.');
     return true;
 }
コード例 #18
0
    }
    if ('enable' == pb_backupbuddy::_GET('deploy')) {
        $identifier = pb_backupbuddy::random_string(12);
        $deployFile = backupbuddy_core::getTempDirectory() . 'deploy-' . backupbuddy_core::backup_prefix() . '.dat';
        // . '-' . $identifier .
        $meta = array('siteurl' => site_url(), 'deployEnabled' => time());
        $deployFileContents = json_encode($meta);
        pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
        if (false === file_put_contents($deployFile, $deployFileContents)) {
            pb_backupbuddy::alert('Error #848383: Unable to write temporary deployment file `' . $deployFile . '`. Verify permissions on the directory.');
        } else {
            $destinationSettings = pb_backupbuddy::$options['remote_destinations'][$stashDestination];
            $destinationSettings['meta'] = $meta;
            $destinationSettings['forceRootUpload'] = true;
            require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
            $send_result = pb_backupbuddy_destinations::send($destinationSettings, array($deployFile), $identifier, $delete_after = true);
            if (true === $send_result) {
                pb_backupbuddy::$options['deployment_allowed'] = '1';
                pb_backupbuddy::save();
                pb_backupbuddy::alert(__('Deployments have been enabled for this site. Other sites sharing this Stash account may Push to or Pull from this site as long as your iThemes Member password is correctly provided.', 'it-l10n-backupbuddy'));
            } else {
                pb_backupbuddy::alert(__('Error #84838: Failure notifying Stash of new deployment site. See Remote Destinations page Recent Transfers listing for details.', 'it-l10n-backupbuddy'));
            }
        }
    } elseif ('disable' == pb_backupbuddy::_GET('deploy')) {
        pb_backupbuddy::$options['deployment_allowed'] = '0';
        pb_backupbuddy::save();
        pb_backupbuddy::alert(__('Deployments have been disabled for this site.', 'it-l10n-backupbuddy'));
    }
}
if (false !== $stashDestination) {
コード例 #19
0
ファイル: core.php プロジェクト: brettex/pspark
 public function destination_send($destination_settings, $files)
 {
     // Pass off to destination handler.
     require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
     $send_result = pb_backupbuddy_destinations::send($destination_settings, $files);
     return $send_result;
 }
コード例 #20
0
ファイル: live.php プロジェクト: brettex/pspark
 public function process_queue()
 {
     // open queue file.
     $max_session_size = '50';
     // Size (MB) that is the max size sum of all files sent per instance. TODO: On timeout failure detect and scale back some to help with timeouts.
     $max_session_time = '30';
     // Currently only used to determine if we should auto-reduce the max session size if we are getting close to going over our time limit (help automatically avoid timeouts).
     $send_now_files = array();
     // Files that will be queued up to be sent this PHP instance.
     $send_now_size = 0;
     // Running sum of the size of all files queued up to be send this PHP instance.
     $need_save = false;
     // Whether or not we have updated something in the queue that needs saving.
     $unsent_files = false;
     foreach ($files as &$file) {
         // Loop through files in queue that need sent to Live.
         if ($send_now_size + $file['size'] <= $max_session_size) {
             // There is room to add this file.
             pb_backupbuddy::status('details', 'Added file `file.png` into queue.', 'live');
             if ($file['attempts'] >= 3) {
                 // send error email notifying that its not going to make it. give suggestions. chunking?
                 pb_backupbuddy::status('error', 'Large 94 MB file `file.png` has timed out X times and has is on hold pending user intervention.', 'live');
             } else {
                 $send_now_files .= $file;
                 $file['attempts']++;
                 $need_save = true;
             }
         } else {
             // There is not room for this file.
             if (count($send_now_files) == 0 && $file['size'] > $max_session_size) {
                 // If no files are queued in this send now list yet then we will try to send just this one big file on its own.
                 pb_backupbuddy::status('details', 'Large 94 MB file `file.png` exceeds max session size so it will be sent by itself to improve transfer success.', 'live');
                 $send_now_files .= $file;
                 $file['attempts']++;
                 $need_save = true;
                 $unsent_files = true;
                 break;
                 // We have maxed out the size with a single file so no need to keep going.
             }
             $unsent_files = true;
             break;
             // No more room for any other files if we made it here so stop looping.
         }
     }
     // end foreach.
     if ($need_save === true) {
         pb_backupbuddy::status('details', 'Saving queue file.', 'live');
         // Code to save the updated data structure to file.
         // After saving add this file itself to the send queue so it (the queue file) gets backed up soon?
     }
     // Call Stash to send these files.
     require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
     $send_result = pb_backupbuddy_destinations::send($destination_settings, $send_now_files);
     pb_backupbuddy::status('message', '4 MB file `file.png` Stashed in 12 seconds.', 'live');
     pb_backupbuddy::status('message', '4 MB file `file.png` did not complete after 60 seconds. Stashing it will be re-attempted in 30 seconds.', 'live');
     // remove all succesful transfers from the queue file and re-save it. be quick as we may be running out of time.
     //
     $this->kick_db();
     // Kick the database to make sure it didn't go away, preventing options saving.
     if ($unsent_files === true) {
         // schedule next queue_process() call.
     }
     // make note in data structure the last time the queue was processed & status (sent X mb in Y seconds. all files succeeded[4/5 files succeded])
 }
コード例 #21
0
 *	
 *	Remote destination testing. Echos.
 *	
 *	@return		null
 */
if (defined('PB_DEMO_MODE')) {
    die('Access denied in demo mode.');
}
global $pb_backupbuddy_destination_errors;
$pb_backupbuddy_destination_errors = array();
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
$form_settings = array();
foreach (pb_backupbuddy::_POST() as $post_id => $post) {
    if (substr($post_id, 0, 15) == 'pb_backupbuddy_') {
        $id = substr($post_id, 15);
        if ($id != '') {
            $form_settings[$id] = $post;
        }
    }
}
$test_result = pb_backupbuddy_destinations::test($form_settings);
if ($test_result === true) {
    echo 'Test successful.';
} else {
    echo "Test failed.\n\n";
    echo $test_result;
    foreach ($pb_backupbuddy_destination_errors as $pb_backupbuddy_destination_error) {
        echo $pb_backupbuddy_destination_error . "\n";
    }
}
die;
コード例 #22
0
		<!--
		<div class="step limit">
			<h4><span class="number">3.</span> How many backups should be ket locally before deleting the oldest?</h4>
			<label>Number of backups to keep</label>
			<input type="email" id="pb_backupbuddy_quickstart_archive_limit name="archive_limit" size="7" style="width: 180px;" value="12">
			<img src="<?php 
echo pb_backupbuddy::plugin_url();
?>
/images/check.png" class="check" id="pb_backupbuddy_quickstart_archive_limit_check">
		</div>
	-->
	
	
	<?php 
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
$destinations = pb_backupbuddy_destinations::get_destinations_list();
?>
		
		<div class="step destination">
			<h4><span class="number">3.</span> Where do you want to send your backups (scheduled or manually sent)?</h4>
			<div class="backupbuddy-quickstart-indent">
				<div id="dest" class="box-options">
					
					<input type="hidden" id="pb_backupbuddy_quickstart_destinationid" name="destination_id" value="">
					<select id="pb_backupbuddy_quickstart_destination"  name="destination" class="change">
						<option value="">Local Only (no remote destination)</option>
						<?php 
$stash2support = false;
foreach ($destinations as $destinationSlug => $destination) {
    $checkHTML = '';
    if ('stash' == $destinationSlug) {
コード例 #23
0
ファイル: core.php プロジェクト: bunnywong/freshlinker
 public static function destination_send($destination_settings, $files, $send_id = '', $delete_after = false, $isRetry = false)
 {
     // Pass off to destination handler.
     require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
     $send_result = pb_backupbuddy_destinations::send($destination_settings, $files, $send_id, $delete_after, $isRetry);
     return $send_result;
 }
コード例 #24
0
ファイル: init.php プロジェクト: ryankrieg/wordpress-base
 public static function test($settings)
 {
     if ($settings['address'] == '' || $settings['username'] == '' || $settings['password'] == '') {
         return __('Missing required input.', 'it-l10n-backupbuddy');
     }
     // Try sending a file.
     $send_response = pb_backupbuddy_destinations::send($settings, dirname(dirname(__FILE__)) . '/remote-send-test.php', $send_id = 'TEST-' . pb_backupbuddy::random_string(12));
     // 3rd param true forces clearing of any current uploads.
     if (false === $send_response) {
         $send_response = 'Error sending test file to FTP.';
     } else {
         $send_response = 'Success.';
     }
     // Now we will need to go and cleanup this potentially uploaded file.
     $delete_response = 'Error deleting test file from FTP.';
     // Default.
     // Settings.
     $server = $settings['address'];
     $username = $settings['username'];
     $password = $settings['password'];
     $path = $settings['path'];
     $ftps = $settings['ftps'];
     if ($settings['active_mode'] == '0') {
         $active_mode = false;
     } else {
         $active_mode = true;
     }
     $url = $settings['url'];
     // optional url for using with migration.
     $port = '21';
     if (strstr($server, ':')) {
         $server_params = explode(':', $server);
         $server = $server_params[0];
         $port = $server_params[1];
     }
     // Connect.
     if ($ftps == '0') {
         $conn_id = @ftp_connect($server, $port, 10);
         // timeout of 10 seconds.
         if ($conn_id === false) {
             $error = __('Unable to connect to FTP address `' . $server . '` on port `' . $port . '`.', 'it-l10n-backupbuddy');
             $error .= "\n" . __('Verify the server address and port (default 21). Verify your host allows outgoing FTP connections.', 'it-l10n-backupbuddy');
             return $send_response . ' ' . $error;
         }
     } else {
         if (function_exists('ftp_ssl_connect')) {
             $conn_id = @ftp_ssl_connect($server, $port);
             if ($conn_id === false) {
                 return $send_response . ' ' . __('Destination server does not support FTPS?', 'it-l10n-backupbuddy');
             }
         } else {
             return $send_response . ' ' . __('Your web server doesnt support FTPS.', 'it-l10n-backupbuddy');
         }
     }
     $login_result = @ftp_login($conn_id, $username, $password);
     if (!$conn_id || !$login_result) {
         pb_backupbuddy::status('details', 'FTP test: Invalid user/pass.');
         $response = __('Unable to login. Bad user/pass.', 'it-l10n-backupbuddy');
         if ($ftps != '0') {
             $response .= "\n\nNote: You have FTPs enabled. You may get this error if your host does not support encryption at this address/port.";
         }
         return $send_response . ' ' . $response;
     }
     pb_backupbuddy::status('details', 'FTP test: Success logging in.');
     // Handle active/pasive mode.
     if ($active_mode === true) {
         // do nothing, active is default.
         pb_backupbuddy::status('details', 'Active FTP mode based on settings.');
     } elseif ($active_mode === false) {
         // Turn passive mode on.
         pb_backupbuddy::status('details', 'Passive FTP mode based on settings.');
         ftp_pasv($conn_id, true);
     } else {
         pb_backupbuddy::status('error', 'Unknown FTP active/passive mode: `' . $active_mode . '`.');
     }
     // Delete test file.
     pb_backupbuddy::status('details', 'FTP test: Deleting temp test file.');
     if (true === ftp_delete($conn_id, $path . '/remote-send-test.php')) {
         $delete_response = 'Success.';
     }
     // Close FTP connection.
     pb_backupbuddy::status('details', 'FTP test: Closing FTP connection.');
     @ftp_close($conn_id);
     // Load destination fileoptions.
     pb_backupbuddy::status('details', 'About to load fileoptions data.');
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     pb_backupbuddy::status('details', 'Fileoptions instance #12.');
     $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
     if (true !== ($result = $fileoptions_obj->is_ok())) {
         pb_backupbuddy::status('error', __('Fatal Error #9034.72373. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
         return false;
     }
     pb_backupbuddy::status('details', 'Fileoptions data loaded.');
     $fileoptions =& $fileoptions_obj->options;
     if ('Success.' != $send_response || 'Success.' != $delete_response) {
         $fileoptions['status'] = 'failure';
         $fileoptions_obj->save();
         unset($fileoptions_obj);
         return 'Send details: `' . $send_response . '`. Delete details: `' . $delete_response . '`.';
     } else {
         $fileoptions['status'] = 'success';
         $fileoptions['finish_time'] = time();
     }
     $fileoptions_obj->save();
     unset($fileoptions_obj);
     return true;
 }
コード例 #25
0
    update_option('_transient_doing_cron', 0);
    // Prevent cron-blocking for next item.
}
// Delete selected dropbox backup(s) from form submission.
if ('delete_backup' == pb_backupbuddy::_POST('bulk_action')) {
    pb_backupbuddy::verify_nonce();
    if (is_array(pb_backupbuddy::_POST('items'))) {
        if (true === ($result = pb_backupbuddy_destinations::delete($destination, pb_backupbuddy::_POST('items')))) {
            pb_backupbuddy::alert(__('Selected file(s) deleted.', 'it-l10n-backupbuddy'));
        } else {
            pb_backupbuddy::alert(__('Unable to delete one or more files. Details: ', 'it-l10n-backupbuddy') . $result);
        }
        echo '<br>';
    }
}
$files_result = pb_backupbuddy_destinations::listFiles($destination);
$backup_files = array();
foreach ((array) $files_result['contents'] as $file) {
    // Loop through files looking for backups.
    if ($file['is_dir'] == '1') {
        // Do NOT display subdirectories.
        continue;
    }
    $filename = str_ireplace($files_result['path'] . '/', '', $file['path']);
    // Remove path from filename.
    if (isset($file['client_mtime'])) {
        $last_modified = strtotime($file['client_mtime']);
        $last_modified = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($last_modified)) . '<br /><span class="description">(' . pb_backupbuddy::$format->time_ago($last_modified) . ' ago)</span>';
    } else {
        $last_modified = '<i>' . __('Unknown', 'it-l10n-backupbuddy') . '</i>';
    }
コード例 #26
0
ファイル: _backup-perform.php プロジェクト: arobbins/iab
					<?php 
foreach (pb_backupbuddy::$options['remote_destinations'] as $destination_id => $destination) {
    echo '<li class="bb_destination-item bb_destination-' . $destination['type'] . '"><a href="javascript:void(0)" title="' . $destination['title'] . '" rel="' . $destination_id . '">' . $destination['title'] . '</a></li>';
}
?>
					<br><br>
					<a href="javascript:void(0)" class="btn btn-small btn-white btn-cancel-send" onClick="jQuery('.bb_destinations').hide();">Nevermind</a>
					<a href="javascript:void(0)" class="btn btn-small btn-addnew" onClick="jQuery('.bb_destinations-existing').hide(); jQuery('.bb_destinations-new').show();">Add New Destination +</a>
				</ul>
			</div>
			<div class="bb_destinations-group bb_destinations-new">
				<h3>What kind of destination do you want to add?</h3>
				<ul>
					<?php 
$i = 0;
foreach (pb_backupbuddy_destinations::get_destinations_list() as $destination_name => $destination) {
    $i++;
    echo '<li class="bb_destination-item bb_destination-' . $destination_name . ' bb_destination-new-item"><a href="javascript:void(0)" rel="' . $destination_name . '">' . $destination['name'] . '</a></li>';
    if ($i >= 5) {
        echo '<span class="bb_destination-break"></span>';
        $i = 0;
    }
}
?>
					<br><br>
					<a href="javascript:void(0)" class="btn btn-small btn-white btn-with-icon btn-back btn-back-add"  onClick="jQuery('.bb_destinations-new').hide(); jQuery('.bb_destinations-existing').show();"><span class="btn-icon"></span>Back to existing destinations</a>
				</ul>
			</div>
		</div>
	</div>
</div>
コード例 #27
0
ファイル: ajax.php プロジェクト: brettex/pspark
 public function remote_save()
 {
     pb_backupbuddy::verify_nonce();
     require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
     $settings_form = pb_backupbuddy_destinations::configure(array('type' => pb_backupbuddy::_POST('pb_backupbuddy_type')), 'save');
     $save_result = $settings_form->process();
     $destination_id = trim(pb_backupbuddy::_GET('pb_backupbuddy_destinationid'));
     if (count($save_result['errors']) == 0) {
         if ($destination_id == 'NEW') {
             // ADD NEW.
             // Dropbox Kludge. Sigh.
             $save_result['data']['token'] = pb_backupbuddy::$options['dropboxtemptoken'];
             pb_backupbuddy::$options['remote_destinations'][] = $save_result['data'];
             pb_backupbuddy::save();
             echo 'Destination Added.';
         } elseif (!isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) {
             // EDITING NONEXISTANT.
             echo 'Error #54859. Invalid destination ID.';
         } else {
             // EDITING EXISTING -- Save!
             pb_backupbuddy::$options['remote_destinations'][$destination_id] = $save_result['data'];
             //echo '<pre>' . print_r( pb_backupbuddy::$options['remote_destinations'][$destination_id], true ) . '</pre>';
             pb_backupbuddy::save();
             echo 'Settings saved.';
         }
     } else {
         echo "Error saving settings.\n\n";
         echo implode("\n", $save_result['errors']);
     }
     die;
 }
コード例 #28
0
<?php

backupbuddy_core::verifyAjaxAccess();
// Remote destination saving.
/*	remote_save()
*	
*	Remote destination saving.
*	
*	@return		null
*/
pb_backupbuddy::verify_nonce();
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
$settings_form = pb_backupbuddy_destinations::configure(array('type' => pb_backupbuddy::_POST('pb_backupbuddy_type')), 'save');
$save_result = $settings_form->process();
$destination_id = trim(pb_backupbuddy::_GET('pb_backupbuddy_destinationid'));
if (count($save_result['errors']) == 0) {
    // NO ERRORS SO SAVE.
    if ($destination_id == 'NEW') {
        // ADD NEW.
        // Copy over dropbox token.
        $save_result['data']['token'] = pb_backupbuddy::$options['dropboxtemptoken'];
        pb_backupbuddy::$options['remote_destinations'][] = $save_result['data'];
        $newDestination = array();
        $newDestination['title'] = $save_result['data']['title'];
        $newDestination['type'] = $save_result['data']['type'];
        backupbuddy_core::addNotification('destination_created', 'Remote destination created', 'A new remote destination "' . $newDestination['title'] . '" has been created.', $newDestination);
        pb_backupbuddy::save();
        echo 'Destination Added.';
    } elseif (!isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) {
        // EDITING NONEXISTANT.
        echo 'Error #54859. Invalid destination ID `' . $destination_id . '`.';
コード例 #29
0
ファイル: init.php プロジェクト: adrianjonmiller/animalhealth
 public static function test($settings)
 {
     $remote_path = self::get_remote_path($settings['directory']);
     // Has leading and trailng slashes.
     $manage_data = pb_backupbuddy_destination_stash::get_manage_data($settings);
     if (!is_array($manage_data['credentials'])) {
         // Credentials were somehow faulty. User changed password after prior page? Unlikely but you never know...
         $error_msg = 'Error #8484383c: Your authentication credentials for Stash failed. Verify your login and password to Stash. You may need to update the Stash destination settings. Perhaps you recently changed your password?';
         pb_backupbuddy::status('error', $error_msg);
         return $error_msg;
     }
     // Try sending a file.
     $send_response = pb_backupbuddy_destinations::send($settings, dirname(dirname(__FILE__)) . '/remote-send-test.php', $send_id = 'TEST-' . pb_backupbuddy::random_string(12));
     // 3rd param true forces clearing of any current uploads.
     if (false === $send_response) {
         $send_response = 'Error sending test file to Stash.';
     } else {
         $send_response = 'Success.';
     }
     // S3 object for managing files.
     $credentials = pb_backupbuddy_destination_stash::get_manage_data($settings);
     $s3_manage = new AmazonS3($manage_data['credentials']);
     if ($settings['ssl'] == 0) {
         @$s3_manage->disable_ssl(true);
     }
     // Delete sent file.
     $delete_response = 'Success.';
     $delete_response = $s3_manage->delete_object($manage_data['bucket'], $manage_data['subkey'] . $remote_path . 'remote-send-test.php');
     if (!$delete_response->isOK()) {
         $delete_response = 'Unable to delete test Stash file `remote-send-test.php`. Details: `' . print_r($response, true) . '`.';
         pb_backupbuddy::status('details', $delete_response);
     } else {
         $delete_response = 'Success.';
     }
     // Load destination fileoptions.
     pb_backupbuddy::status('details', 'About to load fileoptions data.');
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
     if (true !== ($result = $fileoptions_obj->is_ok())) {
         pb_backupbuddy::status('error', __('Fatal Error #9034.84838. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
         return false;
     }
     pb_backupbuddy::status('details', 'Fileoptions data loaded.');
     $fileoptions =& $fileoptions_obj->options;
     if ('Success.' != $send_response || 'Success.' != $delete_response) {
         $fileoptions['status'] = 'failure';
         $fileoptions_obj->save();
         unset($fileoptions_obj);
         return 'Send details: `' . $send_response . '`. Delete details: `' . $delete_response . '`.';
     } else {
         $fileoptions['status'] = 'success';
         $fileoptions['finish_time'] = time();
     }
     $fileoptions_obj->save();
     unset($fileoptions_obj);
     return true;
 }
コード例 #30
0
ファイル: init.php プロジェクト: russtx/tac
 public static function test($settings)
 {
     if (class_exists('CFRuntime')) {
         die('CFRuntime already defined. Another plugin may be incorrectly loading its copy of S3 libraries on BackupBuddy pages.');
     }
     require_once dirname(dirname(__FILE__)) . '/_s3lib/aws-sdk/sdk.class.php';
     $remote_path = self::get_remote_path($settings['directory']);
     // Has leading and trailng slashes.
     $settings['bucket'] = strtolower($settings['bucket']);
     // Buckets must be lowercase.
     /*
     if ( FALSE !== strpos( $settings['bucket'], ' ' ) ) {
     	$message = 'Bucket names cannot have spaces in them.';
     	return $message;
     }
     */
     // Try sending a file.
     $send_response = pb_backupbuddy_destinations::send($settings, dirname(dirname(__FILE__)) . '/remote-send-test.php', $send_id = 'TEST-' . pb_backupbuddy::random_string(12));
     // 3rd param true forces clearing of any current uploads.
     if (false === $send_response) {
         $send_response = 'Error sending test file to S3.';
     } else {
         $send_response = 'Success.';
     }
     // S3 object for managing files.
     $credentials = pb_backupbuddy_destination_s3::get_credentials($settings);
     $s3_manage = new AmazonS3($credentials);
     if ($settings['ssl'] == 0) {
         @$s3_manage->disable_ssl(true);
     }
     // Verify bucket exists; create if not. Also set region to the region bucket exists in.
     if (false === self::_prepareBucketAndRegion($s3_manage, $settings)) {
         return false;
     }
     // Delete sent file.
     $delete_response = 'Success.';
     $delete_response = $s3_manage->delete_object($credentials['bucket'], $remote_path . 'remote-send-test.php');
     if (!$delete_response->isOK()) {
         $delete_response = 'Unable to delete test S3 file `remote-send-test.php`.';
         pb_backupbuddy::status('details', $delete_response . ' Details: `' . print_r($delete_response, true) . '`.');
     } else {
         $delete_response = 'Success.';
     }
     // Load destination fileoptions.
     pb_backupbuddy::status('details', 'About to load fileoptions data.');
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     pb_backupbuddy::status('details', 'Fileoptions instance #7.');
     $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
     if (true !== ($result = $fileoptions_obj->is_ok())) {
         pb_backupbuddy::status('error', __('Fatal Error #9034.84838. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
         return false;
     }
     pb_backupbuddy::status('details', 'Fileoptions data loaded.');
     $fileoptions =& $fileoptions_obj->options;
     if ('Success.' != $send_response || 'Success.' != $delete_response) {
         $fileoptions['status'] = 'failure';
         $fileoptions_obj->save();
         unset($fileoptions_obj);
         return 'Send details: `' . $send_response . '`. Delete details: `' . $delete_response . '`.';
     } else {
         $fileoptions['status'] = 'success';
         $fileoptions['finish_time'] = time();
     }
     $fileoptions_obj->save();
     unset($fileoptions_obj);
     return true;
 }