Пример #1
0
function parse_options($restoreData)
{
    if ('1' == pb_backupbuddy::_POST('restoreFiles')) {
        $restoreData['restoreFiles'] = true;
    } else {
        $restoreData['restoreFiles'] = false;
    }
    if ('1' == pb_backupbuddy::_POST('restoreDatabase')) {
        $restoreData['restoreDatabase'] = true;
    } else {
        $restoreData['restoreDatabase'] = false;
    }
    if ('1' == pb_backupbuddy::_POST('migrateHtaccess')) {
        $restoreData['migrateHtaccess'] = true;
    } else {
        $restoreData['migrateHtaccess'] = false;
    }
    if ('all' == pb_backupbuddy::_POST('zipMethodStrategy') || 'ziparchive' == pb_backupbuddy::_POST('zipMethodStrategy') || 'pclzip' == pb_backupbuddy::_POST('zipMethodStrategy')) {
        $restoreData['zipMethodStrategy'] = pb_backupbuddy::_POST('zipMethodStrategy');
    }
    /*
    if ( ( isset( $_POST['log_level'] ) ) && ( $_POST['log_level'] != '' ) ) {
    	pb_backupbuddy::$options['log_level'] = $_POST['log_level'];
    } else {
    	pb_backupbuddy::$options['log_level'] = '';
    }
    */
    return $restoreData;
}
Пример #2
0
 function api()
 {
     die('0');
     // TODO: Internal security lockout.
     if (!isset(pb_backupbuddy::$options['api_key_test']) || pb_backupbuddy::$options['api_key_test'] == '') {
         die('0');
     }
     if (pb_backupbuddy::$options['api_key_test'] != 'dsnfilasbfisybfdjybfjalybsfaklsbfa') {
         die('0');
     }
     $run = pb_backupbuddy::_POST('run');
     // TODO: TESTING temp allow GET method:
     if ('' == $run) {
         $run = pb_backupbuddy::_GET('run');
     }
     if ('' == $run) {
         die(json_encode(array('success' => false, 'error' => 'Error #489384: Missing run command.')));
     } else {
         if (false === ($return = call_user_func('backupbuddy_api::' . $run))) {
             die(json_encode(array('success' => false, 'error' => 'Error #328983: Command failed.')));
         } else {
             die(json_encode(array('success' => true, 'version' => pb_backupbuddy::settings('version'), 'data' => $return)));
         }
     }
     die;
 }
Пример #3
0
function plugin_information($plugin_slug, $data)
{
    $plugin_path = $data['path'];
    ?>
	
	<textarea readonly="readonly" rows="7" cols="65" wrap="off" style="width: 100%;"><?php 
    //echo "Version History:\n\n";
    readfile($plugin_path . '/history.txt');
    ?>
</textarea>
	<script type="text/javascript">
		jQuery(document).ready(function() {
			jQuery("#pluginbuddy_<?php 
    echo $plugin_slug;
    ?>
_debugtoggle").click(function() {
				jQuery("#pluginbuddy_<?php 
    echo $plugin_slug;
    ?>
_debugtoggle_div").slideToggle();
			});
		});
	</script>
	<?php 
    if (pb_backupbuddy::_POST('reset_defaults') == $plugin_slug) {
        if (call_user_func('pb_' . $plugin_slug . '::reset_options', true) === true) {
            pb_backupbuddy::alert('Plugin settings have been reset to defaults for plugin `' . $data['name'] . '`.');
        } else {
            pb_backupbuddy::alert('Unable to reset plugin settings. Verify you are running the latest version.');
        }
    }
    ?>
	
	<?php 
}
Пример #4
0
function fatal_test_die()
{
    echo '<div style="padding: 10px;"><b>Fatal errors encountered during testing. Please resolve them to continue tests.</b></div>';
    if (pb_backupbuddy::_POST('skip_database_import') == '1') {
        echo '<br><span class="pb_label pb_label-info">Important</span> Database import set to be skipped based on advanced options. Any failures ignored.<br><br>';
        echo '<!-- Success. -->';
    }
    die;
}
Пример #5
0
 public static function check($force_check = false)
 {
     if (true === self::$_checked && $force_check === false) {
         // Skip checking if already skipped unless forcing.
         return self::$_authenticated;
     }
     $login_attempt_file = ABSPATH . 'importbuddy/_login_attempts.php';
     $login_attempts = 1;
     if (file_exists($login_attempt_file)) {
         $login_attempts = @file_get_contents($login_attempt_file);
     }
     if (false !== $login_attempts) {
         $login_attempts = trim(str_replace('<?php die(); ?>', '', $login_attempts));
         if ($login_attempts > self::MAX_LOGIN_ATTEMPTS_ALLOWED) {
             die('Access Denied. Maximum login attempts exceeded. You must delete "_login_attempts.php" in the importbuddy directory to unloack this script to allow it to continue.');
         }
     }
     $actual_pass_hash = PB_PASSWORD;
     if ('#PASSWORD#' == $actual_pass_hash || '' == $actual_pass_hash) {
         die('Error #84578459745. A password must be set.');
     }
     if (pb_backupbuddy::_POST('password') != '') {
         $supplied_pass_hash = md5(pb_backupbuddy::_POST('password'));
     } else {
         if (pb_backupbuddy::_GET('v') != '') {
             // Hash submitted by magic migration.
             $supplied_pass_hash = pb_backupbuddy::_GET('v');
         } else {
             // Normal form submitted hash.
             if (pb_backupbuddy::_POST('pass_hash') != '') {
                 $supplied_pass_hash = pb_backupbuddy::_POST('pass_hash');
             } elseif (pb_backupbuddy::_POST('pb_backupbuddy_pass_hash') != '') {
                 $supplied_pass_hash = pb_backupbuddy::_POST('pb_backupbuddy_pass_hash');
             } else {
                 $supplied_pass_hash = '';
             }
         }
     }
     if ($supplied_pass_hash == $actual_pass_hash) {
         self::$_authenticated = true;
     } else {
         // Incorrect hash. Reset settings & track attempts.
         if ('' != $supplied_pass_hash) {
             // Dont count blank hash as an attempt.
             if (true === self::RESET_DEFAULTS_ON_INVALID_LOGIN) {
                 pb_backupbuddy::reset_defaults();
             }
             if (false !== $login_attempts) {
                 global $pb_login_attempts;
                 $pb_login_attempts = $login_attempts;
                 @file_put_contents($login_attempt_file, '<?php die(); ?>' . ($login_attempts + 1));
             }
         }
     }
     self::$_checked = true;
     return self::$_authenticated;
 }
Пример #6
0
/**
 *	upload()
 *
 *	Processes uploaded backup file.
 *
 *	@return		array		True on upload success; false otherwise.
 */
function upload()
{
    if (isset($_POST['upload']) && $_POST['upload'] == 'local') {
        if (pb_backupbuddy::$options['password'] != '#PASSWORD#') {
            $path_parts = pathinfo($_FILES['file']['name']);
            if (strtolower(substr($_FILES['file']['name'], 0, 6)) == 'backup' && strtolower($path_parts['extension']) == 'zip') {
                if (move_uploaded_file($_FILES['file']['tmp_name'], basename($_FILES['file']['name']))) {
                    pb_backupbuddy::alert('File Uploaded. Your backup was successfully uploaded.');
                    return true;
                } else {
                    pb_backupbuddy::alert('Sorry, there was a problem uploading your file.', true);
                    return false;
                }
            } else {
                pb_backupbuddy::alert('Only properly named BackupBuddy zip archives with a zip extension may be uploaded.', true);
                return false;
            }
        } else {
            pb_backupbuddy::alert('Upload Access Denied. To prevent unauthorized file uploads an importbuddy password must be configured and properly entered to use this feature.');
            return false;
        }
    }
    // DOWNLOAD FILE FROM STASH TO LOCAL.
    if (pb_backupbuddy::_POST('upload') == 'stash') {
        pb_backupbuddy::set_greedy_script_limits(true);
        /*
        echo '<pre>';
        print_r( $_POST );
        echo '</pre>';
        */
        $requestcore_file = dirname(dirname(dirname(__FILE__))) . '/lib/requestcore/requestcore.class.php';
        require_once $requestcore_file;
        $link = pb_backupbuddy::_POST('link');
        $destination_file = dirname(dirname(dirname(dirname(__FILE__)))) . '/' . basename(pb_backupbuddy::_POST('link'));
        $destination_file = substr($destination_file, 0, stripos($destination_file, '.zip') + 4);
        $_GET['file'] = basename($destination_file);
        $request = new RequestCore($link);
        $request->set_write_file($destination_file);
        echo '<div id="pb_importbuddy_working" style="padding: 20px;">Downloading backup from Stash to `' . $destination_file . '`...<br><br><img src="' . pb_backupbuddy::plugin_url() . '/images/loading_large.gif" title="Working... Please wait as this may take a moment..."><br><br></div>';
        flush();
        $response = $request->send_request(false);
        if ($response !== true) {
            pb_backupbuddy::alert('Error #8548459598. Unable to download file from Stash. You may manually download it and upload to the server via FTP.');
        } else {
            // No error.
            if (!file_exists($destination_file)) {
                pb_backupbuddy::alert('Error #34845745878. Stash returned a success but the backup file was not found locally. Check this server\'s directory write permissions. You may manually download it and upload to the server via FTP.');
            }
        }
        echo '<script type="text/javascript">jQuery("#pb_importbuddy_working").hide();</script>';
    }
}
Пример #7
0
 /**
  * Class constructor sets up the environment
  *
  * @since 6.4.0.13
  *
  * @return void
  */
 function __construct()
 {
     // Register the tests
     $this->register_tests();
     // Grab the DB credentials from POST
     $creds = array();
     $creds['server'] = pb_backupbuddy::_POST('server');
     $creds['username'] = pb_backupbuddy::_POST('username');
     $creds['password'] = pb_backupbuddy::_POST('password');
     $creds['database'] = pb_backupbuddy::_POST('database');
     $creds['prefix'] = pb_backupbuddy::_POST('prefix');
     // If we don't have all the fields, die with error
     if ('' == $creds['server'] || '' == $creds['username'] || '' == $creds['database'] || '' == $creds['prefix']) {
         $this->tests['overall_error'] = 'One or more database settings was left blank. All fields except optional password are required.';
         die(json_encode($this->tests));
     }
     $this->creds = $creds;
     // Run the tests, one at a time
     $this->run_tests();
 }
Пример #8
0
function parse_options($restoreData)
{
    if ('1' == pb_backupbuddy::_POST('migrateDatabase')) {
        $restoreData['databaseSettings']['migrateDatabase'] = true;
    } else {
        $restoreData['databaseSettings']['migrateDatabase'] = false;
    }
    if ('1' == pb_backupbuddy::_POST('migrateDatabaseBruteForce')) {
        $restoreData['databaseSettings']['migrateDatabaseBruteForce'] = true;
    } else {
        $restoreData['databaseSettings']['migrateDatabaseBruteForce'] = false;
    }
    $restoreData['siteurl'] = preg_replace('|/*$|', '', pb_backupbuddy::_POST('siteurl'));
    // Strip trailing slashes.
    $restoreData['homeurl'] = preg_replace('|/*$|', '', pb_backupbuddy::_POST('homeurl'));
    // Strip trailing slashes.
    if ('' == $restoreData['homeurl']) {
        $restoreData['homeurl'] = $restoreData['siteurl'];
    }
    $restoreData['maxExecutionTime'] = pb_backupbuddy::_POST('max_execution_time');
    return $restoreData;
}
Пример #9
0
function parse_options($restoreData)
{
    if ('1' == pb_backupbuddy::_POST('delete_backup')) {
        $restoreData['cleanup']['deleteArchive'] = true;
    } else {
        $restoreData['cleanup']['deleteArchive'] = false;
    }
    if ('1' == pb_backupbuddy::_POST('delete_temp')) {
        $restoreData['cleanup']['deleteTempFiles'] = true;
    } else {
        $restoreData['cleanup']['deleteTempFiles'] = false;
    }
    if ('1' == pb_backupbuddy::_POST('delete_importbuddy')) {
        $restoreData['cleanup']['deleteImportBuddy'] = true;
    } else {
        $restoreData['cleanup']['deleteImportBuddy'] = false;
    }
    if ('1' == pb_backupbuddy::_POST('delete_importbuddylog')) {
        $restoreData['cleanup']['deleteImportLog'] = true;
    } else {
        $restoreData['cleanup']['deleteImportLog'] = false;
    }
    return $restoreData;
}
Пример #10
0
<?php

pb_backupbuddy::$ui->title(__('Deploy Database', 'it-l10n-backupbuddy') . ' &nbsp;&nbsp; <a style="font-size: 0.6em;" href="#" onClick="jQuery(\'#pb_backupbuddy_status_wrap\').toggle();">Display Status Log</a>');
if (!defined('BACKUPBUDDY_API_ENABLE') || TRUE != BACKUPBUDDY_API_ENABLE) {
    pb_backupbuddy::alert("Make sure the following is in your wp-config.php file on this server:<br><textarea style='width: 100%;' disabled='disabled'>define( 'BACKUPBUDDY_API_ENABLE', true ); // Requires API key to access.</textarea>");
    return false;
}
/*
if ( ! defined( 'BACKUPBUDDY_API_SALT' ) || ( 'CHANGEME' == BACKUPBUDDY_API_SALT ) || ( strlen( BACKUPBUDDY_API_SALT ) < 5 ) ) {
	pb_backupbuddy::alert( "Make sure the following is in your wp-config.php file on this server:<br><textarea style='width: 100%;' disabled='disabled'>define( 'BACKUPBUDDY_API_SALT', 'CHANGEME' ); // !!! IMPORTANT !!! Change CHANGEME to the left to a unique password/phrase for generating API keys. 5+ characters.</textarea>" );
	return false;
}
*/
if ('1' == pb_backupbuddy::_POST('regenerate_api_key')) {
    pb_backupbuddy::verify_nonce();
    // Security check.
    pb_backupbuddy::$options['api_key'] = backupbuddy_core::generate_api_key();
    pb_backupbuddy::save();
}
?>

<b>Note:</b> wp-config.php files as well as BackupBuddy settings will NOT be transferred in either direction. Your current BackupBuddy settings, destinations, API keys etc. will remain as they are on both sites.<br><br>

<form method="post">
	<?php 
pb_backupbuddy::nonce();
?>
	<input type="hidden" name="regenerate_api_key" value="1">
	<button class="button secondary-button" onClick="jQuery('.backupbuddy_api_key-hide').toggle(); return false;">Show API Key</button><span class="backupbuddy_api_key-hide" style="display: none;">&nbsp;&nbsp;<input type="submit" name="submit" value="Generate New API Key" class="button button-primary"></span>
	<br>
	<br>
     $authCode = trim(pb_backupbuddy::_POST('dropbox_authorization_code'));
     try {
         list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
     } catch (\Exception $e) {
         pb_backupbuddy::alert('<b>Verify you authorized BackupBuddy access in Dropbox and copied the Dropbox authorization code exactly in the BackupBuddy field.</b><br><br>Error details: ' . $e->getMessage(), true);
         // '<br><br>' . pb_backupbuddy::$ui->button( pb_backupbuddy::page_url(), '&larr; go back & retry' )
         $bad_auth_code = true;
         $pb_hide_save = true;
     }
     if (false === $bad_auth_code) {
         $dropboxClient = new \Dropbox\Client($accessToken, 'BackupBuddy v' . pb_backupbuddy::settings('version'));
         $accountInfo = $dropboxClient->getAccountInfo();
         $show_config_form = true;
     }
 }
 if ('' == pb_backupbuddy::_POST('dropbox_authorization_code') || true === $bad_auth_code) {
     // No authorization code entered yet so user needs to authorize.
     try {
         $authorizeUrl = $webAuth->start();
     } catch (Exception $e) {
         pb_backupbuddy::alert('Error #8778656: Dropbox error. Details: `' . $e->getMessage() . '`.', true);
         return false;
     }
     echo '<form method="post" action="' . pb_backupbuddy::ajax_url('destination_picker') . '&add=dropbox2&callback_data=' . pb_backupbuddy::_GET('callback_data') . '">';
     echo '<br><b>Adding a Dropbox destination</b><ol>';
     echo '<li> <a href="' . $authorizeUrl . '" class="button-primary pb_dropbox_authorize" target="_new">' . __('Connect to Dropbox.com & Authorize (opens new window)', 'it-l10n-backupbuddy') . '</a></li>';
     echo '<li>Click <b>Allow</b> in the new window (you may need to login to Dropbox.com first).</li>';
     echo '<li>Enter the provided <b>Authorization Code</b>: <input type="text" name="dropbox_authorization_code" size="45"></li>';
     echo '<li><input type="submit" class="button-primary" value="' . __("Yes, I've Authorized BackupBuddy with Dropbox & Entered the Code above", 'it-l10n-backupbuddy') . '"></li>';
     echo '</ol>';
     echo '</form>';
Пример #12
0
		</table>
	</form>
	
	<?php 
    die;
}
$s3 = new AmazonS3($manage_data['credentials']);
// the key, secret, token
if ($settings['ssl'] == '0') {
    @$s3->disable_ssl(true);
}
// Handle deletion.
if (pb_backupbuddy::_POST('bulk_action') == 'delete_backup') {
    pb_backupbuddy::verify_nonce();
    $deleted_files = array();
    foreach ((array) pb_backupbuddy::_POST('items') as $item) {
        $response = $s3->delete_object($manage_data['bucket'], $manage_data['subkey'] . $remote_path . $item);
        if ($response->isOK()) {
            $deleted_files[] = $item;
        } else {
            pb_backupbuddy::alert('Error: Unable to delete `' . $item . '`. Verify permissions.');
        }
    }
    if (count($deleted_files) > 0) {
        pb_backupbuddy::alert('Deleted ' . implode(', ', $deleted_files) . '.');
        delete_transient('pb_backupbuddy_stashquota_' . $itxapi_username);
        // Delete quota transient since it probably has changed now.
    }
    echo '<br>';
}
// Handle copying files to local
Пример #13
0
<?php

// Incoming vars: $backupFile, $step
if (!current_user_can(pb_backupbuddy::$options['role_access'])) {
    die('Error #473623. Access Denied.');
}
//pb_backupbuddy::verify_nonce();
$restoreData = unserialize(base64_decode(pb_backupbuddy::_POST('restoreData')));
require_once pb_backupbuddy::plugin_path() . '/classes/restore.php';
$rollback = new backupbuddy_restore('rollback', $restoreData);
$status = $rollback->swapDatabases();
if (false === $status) {
    $errors = $rollback->getErrors();
    if (count($errors) > 0) {
        pb_backupbuddy::alert('Errors were encountered: ' . implode(', ', $errors) . ' If seeking support please click to Show Advanced Details above and provide a copy of the log.');
    }
    return;
}
$restoreData = $rollback->getState();
?>


<h3>Test your site then select <i>Accept</i> to lock in changes or <i>Cancel</i> to undo.</h3>
<a href="<?php 
echo site_url();
?>
" target="_new"><b>Click here to test your site</b></a> before proceeding.
<br><br>
If your site functions as expected you may proceed to making these changes permanent by selecting the button below to
accept the changes. If anything appears wrong or you have not made a backup of your original site you should select to cancel
the rollback to revert your site to its prior condition.
Пример #14
0
	</div>
	
	<?php 
$requested_profile = pb_backupbuddy::_GET('backupbuddy_backup');
if ('db' == $requested_profile) {
    // db profile is always index 1.
    $requested_profile = '1';
} elseif ('full' == $requested_profile) {
    // full profile is always index 2.
    $requested_profile = '2';
}
$export_plugins = array();
// Default of no exported plugins. Used by MS export.
if (pb_backupbuddy::_GET('backupbuddy_backup') == 'export') {
    // EXPORT.
    $export_plugins = pb_backupbuddy::_POST('items');
    $profile_array = pb_backupbuddy::$options['0'];
    // Run exports on default profile.
    $profile_array['type'] = 'export';
    // Pass array with export type set.
} else {
    // NOT MULTISITE EXPORT.
    if (is_numeric($requested_profile)) {
        if (isset(pb_backupbuddy::$options['profiles'][$requested_profile])) {
            $profile_array = pb_backupbuddy::$options['profiles'][$requested_profile];
        } else {
            die('Error #84537483: Invalid profile ID `' . htmlentities($requested_profile) . '`. Profile with this number was not found. Try deactivating then reactivating the plugin. If this fails please reset the plugin Settings back to Defaults from the Settings page.');
        }
    } else {
        die('Error #85489548955. Invalid profile ID not numeric: `' . htmlentities($requested_profile) . '`.');
    }
Пример #15
0
				<?php 
            }
            // end if type not blank.
            //echo implode( ' - ', $meta );
            echo '</div>';
            echo '</li>';
        }
        echo '</ul>';
    }
    ?>
	
<?php 
}
// End file not given in querystring.
// If one or more backup files was found then provide a button to continue.
if (!empty($backup_archives) || 'stash' == pb_backupbuddy::_POST('upload')) {
    echo '</div><!-- /wrap -->';
    ?>
	
	
	<div class="main_box_foot">
		<center>
			
			<div style="margin-top: 20px; margin-bottom: 30px;">
				<b>What would you like to restore from the backup?</b>
				&nbsp;&nbsp;
				<label style="float: inherit;">
					<input type="checkbox" name="restoreFiles" value="1" CHECKED> Files
				</label>
				&nbsp;&nbsp;
				<label style="float: inherit;">
Пример #16
0
    public static function backups_list($type = 'default', $subsite_mode = false)
    {
        if (pb_backupbuddy::_POST('bulk_action') == 'delete_backup' && is_array(pb_backupbuddy::_POST('items'))) {
            $needs_save = false;
            pb_backupbuddy::verify_nonce(pb_backupbuddy::_POST('_wpnonce'));
            // Security check to prevent unauthorized deletions by posting from a remote place.
            $deleted_files = array();
            foreach (pb_backupbuddy::_POST('items') as $item) {
                if (file_exists(backupbuddy_core::getBackupDirectory() . $item)) {
                    if (@unlink(backupbuddy_core::getBackupDirectory() . $item) === true) {
                        $deleted_files[] = $item;
                        // Cleanup any related fileoptions files.
                        $serial = backupbuddy_core::get_serial_from_file($item);
                        $backup_files = glob(backupbuddy_core::getBackupDirectory() . '*.zip');
                        if (!is_array($backup_files)) {
                            $backup_files = array();
                        }
                        if (count($backup_files) > 5) {
                            // Keep a minimum number of backups in array for stats.
                            $this_serial = self::get_serial_from_file($item);
                            $fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $this_serial . '.txt';
                            if (file_exists($fileoptions_file)) {
                                @unlink($fileoptions_file);
                            }
                            if (file_exists($fileoptions_file . '.lock')) {
                                @unlink($fileoptions_file . '.lock');
                            }
                            $needs_save = true;
                        }
                    } else {
                        pb_backupbuddy::alert('Error: Unable to delete backup file `' . $item . '`. Please verify permissions.', true);
                    }
                }
                // End if file exists.
            }
            // End foreach.
            if ($needs_save === true) {
                pb_backupbuddy::save();
            }
            pb_backupbuddy::alert(__('Deleted:', 'it-l10n-backupbuddy') . ' ' . implode(', ', $deleted_files));
        }
        // End if deleting backup(s).
        $backups = array();
        $backup_sort_dates = array();
        $files = glob(backupbuddy_core::getBackupDirectory() . 'backup*.zip');
        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.
            $backup_prefix = self::backup_prefix();
            // Backup prefix for this site. Used for MS checking that this user can see this backup.
            foreach ($files as $file_id => $file) {
                if ($subsite_mode === true && is_multisite()) {
                    // If a Network and NOT the superadmin must make sure they can only see the specific subsite backups for security purposes.
                    // Only allow viewing of their own backups.
                    if (!strstr($file, $backup_prefix)) {
                        unset($files[$file_id]);
                        // Remove this backup from the list. This user does not have access to it.
                        continue;
                        // Skip processing to next file.
                    }
                }
                $serial = backupbuddy_core::get_serial_from_file($file);
                $options = array();
                if (file_exists(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt')) {
                    require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
                    pb_backupbuddy::status('details', 'Fileoptions instance #33.');
                    $backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = false, $ignore_lock = false, $create_file = true);
                    // Will create file to hold integrity data if nothing exists.
                } else {
                    $backup_options = '';
                }
                $backup_integrity = backupbuddy_core::backup_integrity_check($file, $backup_options, $options);
                // Backup status.
                $pretty_status = array(true => '<span class="pb_label pb_label-success">Good</span>', 'pass' => '<span class="pb_label pb_label-success">Good</span>', false => '<span class="pb_label pb_label-important">Bad</span>', 'fail' => '<span class="pb_label pb_label-important">Bad</span>');
                // Backup type.
                $pretty_type = array('full' => 'Full', 'db' => 'Database', 'files' => 'Files');
                // Defaults...
                $detected_type = '';
                $file_size = '';
                $modified = '';
                $modified_time = 0;
                $integrity = '';
                $main_string = 'Warn#284.';
                if (is_array($backup_integrity)) {
                    // Data intact... put it all together.
                    // Calculate time ago.
                    $time_ago = '';
                    if (isset($backup_integrity['modified'])) {
                        $time_ago = pb_backupbuddy::$format->time_ago($backup_integrity['modified']) . ' ago';
                    }
                    $detected_type = pb_backupbuddy::$format->prettify($backup_integrity['detected_type'], $pretty_type);
                    if ($detected_type == '') {
                        $detected_type = 'Unknown';
                    } else {
                        if (isset($backup_options->options['profile'])) {
                            $detected_type = '
							<div>
								<span style="color: #AAA; float: left;">' . $detected_type . '</span>
								<span style="display: inline-block; float: left; height: 15px; border-right: 1px solid #EBEBEB; margin-left: 6px; margin-right: 6px;"></span>
								' . htmlentities($backup_options->options['profile']['title']) . '
							</div>
							';
                        }
                    }
                    $file_size = pb_backupbuddy::$format->file_size($backup_integrity['size']);
                    $modified = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($backup_integrity['modified']), 'l, F j, Y - g:i:s a');
                    $modified_time = $backup_integrity['modified'];
                    if (isset($backup_integrity['status'])) {
                        // Pre-v4.0.
                        $status = $backup_integrity['status'];
                    } else {
                        // v4.0+
                        $status = $backup_integrity['is_ok'];
                    }
                    // Calculate main row string.
                    if ($type == 'default') {
                        // Default backup listing.
                        $main_string = '<a href="' . pb_backupbuddy::ajax_url('download_archive') . '&backupbuddy_backup=' . basename($file) . '" class="backupbuddyFileTitle" title="' . basename($file) . '">' . $modified . ' (' . $time_ago . ')</a>';
                    } elseif ($type == 'migrate') {
                        // Migration backup listing.
                        $main_string = '<a class="pb_backupbuddy_hoveraction_migrate backupbuddyFileTitle" rel="' . basename($file) . '" href="' . pb_backupbuddy::page_url() . '&migrate=' . basename($file) . '&value=' . basename($file) . '" title="' . basename($file) . '">' . $modified . ' (' . $time_ago . ')</a>';
                    } else {
                        $main_string = '{Unknown type.}';
                    }
                    // Add comment to main row string if applicable.
                    if (isset($backup_integrity['comment']) && $backup_integrity['comment'] !== false && $backup_integrity['comment'] !== '') {
                        $main_string .= '<br><span class="description">Note: <span class="pb_backupbuddy_notetext">' . htmlentities($backup_integrity['comment']) . '</span></span>';
                    }
                    $integrity = pb_backupbuddy::$format->prettify($status, $pretty_status) . ' ';
                    if (isset($backup_integrity['scan_notes']) && count((array) $backup_integrity['scan_notes']) > 0) {
                        foreach ((array) $backup_integrity['scan_notes'] as $scan_note) {
                            $integrity .= $scan_note . ' ';
                        }
                    }
                    $integrity .= '<a href="' . pb_backupbuddy::page_url() . '&reset_integrity=' . $serial . '" title="Rescan integrity. Last checked ' . pb_backupbuddy::$format->date($backup_integrity['scan_time']) . '."><img src="' . pb_backupbuddy::plugin_url() . '/images/refresh_gray.gif" style="vertical-align: -1px;"></a>';
                    $integrity .= '<div class="row-actions"><a title="' . __('Backup Status', 'it-l10n-backupbuddy') . '" href="' . pb_backupbuddy::ajax_url('integrity_status') . '&serial=' . $serial . '&#038;TB_iframe=1&#038;width=640&#038;height=600" class="thickbox">' . __('View Details', 'it-l10n-backupbuddy') . '</a></div>';
                    $sumLogFile = backupbuddy_core::getLogDirectory() . 'status-' . $serial . '_sum_' . pb_backupbuddy::$options['log_serial'] . '.txt';
                    if (file_exists($sumLogFile)) {
                        $integrity .= '<div class="row-actions"><a title="' . __('View Backup Log', 'it-l10n-backupbuddy') . '" href="' . pb_backupbuddy::ajax_url('view_log') . '&serial=' . $serial . '&#038;TB_iframe=1&#038;width=640&#038;height=600" class="thickbox">' . __('View Log', 'it-l10n-backupbuddy') . '</a></div>';
                    }
                }
                // end if is_array( $backup_options ).
                $backups[basename($file)] = array(array(basename($file), $main_string . '<br><span class="description" style="color: #AAA; display: inline-block; margin-top: 5px;">' . basename($file) . '</span>'), $detected_type, $file_size, $integrity);
                $backup_sort_dates[basename($file)] = $modified_time;
            }
            // End foreach().
        }
        // End if.
        // Sort backup by date.
        arsort($backup_sort_dates);
        // Re-arrange backups based on sort dates.
        $sorted_backups = array();
        foreach ($backup_sort_dates as $backup_file => $backup_sort_date) {
            $sorted_backups[$backup_file] = $backups[$backup_file];
            unset($backups[$backup_file]);
        }
        unset($backups);
        return $sorted_backups;
    }
Пример #17
0
if ('' != pb_backupbuddy::_GET('cpy')) {
    // Copy dropbox backups to the local backup files
    pb_backupbuddy::alert('The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.');
    echo '<br>';
    pb_backupbuddy::status('details', 'Scheduling Cron for creating Dropbox copy.');
    backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('process_destination_copy'), array($destination, pb_backupbuddy::_GET('cpy')));
    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.
}
// 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;
    }
Пример #18
0
 function destination_ftp_pathpicker()
 {
     function pb_backupbuddy_ftp_listDetailed($resource, $directory = '.')
     {
         if (is_array($children = @ftp_rawlist($resource, $directory))) {
             $items = array();
             foreach ($children as $child) {
                 $chunks = preg_split("/\\s+/", $child);
                 list($item['rights'], $item['number'], $item['user'], $item['group'], $item['size'], $item['month'], $item['day'], $item['time']) = $chunks;
                 $item['type'] = $chunks[0][0] === 'd' ? 'directory' : 'file';
                 array_splice($chunks, 0, 8);
                 $items[implode(" ", $chunks)] = $item;
             }
             return $items;
         }
         return false;
     }
     // end listDetailed subfunction.
     $settings = array('address' => pb_backupbuddy::_GET('pb_backupbuddy_address'), 'username' => pb_backupbuddy::_GET('pb_backupbuddy_username'), 'password' => pb_backupbuddy::_GET('pb_backupbuddy_password'), 'ftps' => pb_backupbuddy::_GET('pb_backupbuddy_ftps'), 'active_mode' => pb_backupbuddy::_GET('pb_backupbuddy_active_mode'));
     if ($settings['address'] == '' || $settings['username'] == '' || $settings['password'] == '') {
         die(__('Missing required FTP server inputs.', 'it-l10n-backupbuddy'));
     }
     // Settings
     if ($settings['active_mode'] == '0') {
         $active_mode = false;
     } else {
         $active_mode = true;
     }
     $server = $settings['address'];
     $port = '21';
     if (strstr($server, ':')) {
         $server_params = explode(':', $server);
         $server = $server_params[0];
         $port = $server_params[1];
     }
     // Connect.
     if ($settings['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');
             die($error);
         }
     } else {
         if (function_exists('ftp_ssl_connect')) {
             $conn_id = @ftp_ssl_connect($server, $port);
             if ($conn_id === false) {
                 die(__('Destination server does not support FTPS?', 'it-l10n-backupbuddy'));
             }
         } else {
             die(__('Your web server doesnt support FTPS.', 'it-l10n-backupbuddy'));
         }
     }
     // Authenticate.
     $login_result = @ftp_login($conn_id, $settings['username'], $settings['password']);
     if (!$conn_id || !$login_result) {
         pb_backupbuddy::status('details', 'FTP test: Invalid user/pass.');
         $response = __('Unable to login to FTP server. Bad user/pass.', 'it-l10n-backupbuddy');
         if ($settings['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.";
         }
         die($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 . '`.');
     }
     // Calculate root.
     $ftpRoot = urldecode(pb_backupbuddy::_POST('dir'));
     if ('' == $ftpRoot) {
         // No root passed so figure out root from FTP server itself.
         $ftpRoot = ftp_pwd($conn_id);
     }
     $ftpList = pb_backupbuddy_ftp_listDetailed($conn_id, $ftpRoot);
     echo '<ul class="jqueryFileTree pb_backupbuddy_ftpdestination_pathpickerboxtree">';
     if (count($ftpList) > 2) {
         foreach ($ftpList as $fileName => $file) {
             if ('.' == $fileName || '..' == $fileName) {
                 continue;
             }
             if ('directory' == $file['type']) {
                 // Directory.
                 echo '<li class="directory collapsed">';
                 $return = '';
                 $return .= '<div class="pb_backupbuddy_treeselect_control">';
                 $return .= '<img src="' . pb_backupbuddy::plugin_url() . '/images/greenplus.png" style="vertical-align: -3px;" title="Select this path..." class="pb_backupbuddy_filetree_select">';
                 $return .= '</div>';
                 echo '<a href="#" rel="' . htmlentities($ftpRoot . $fileName) . '/" title="Toggle expand...">' . htmlentities($fileName) . $return . '</a>';
                 echo '</li>';
             } else {
                 // File.
                 echo '<li class="file collapsed">';
                 echo '<a href="#" rel="' . htmlentities($ftpRoot . $fileName) . '">' . htmlentities($fileName) . '</a>';
                 echo '</li>';
             }
         }
     } else {
         echo '<ul class="jqueryFileTree">';
         echo '<li><a href="#" rel="' . htmlentities(pb_backupbuddy::_POST('dir') . 'NONE') . '"><i>Empty Directory ...</i></a></li>';
         echo '</ul>';
     }
     echo '</ul>';
     die;
 }
Пример #19
0
    foreach ((array) $e as $e_line_title => $e_line) {
        $e_string .= $e_line_title . ' => ' . $e_line . "; ";
    }
    $e_string = rtrim($e_string, '; ') . '.';
    // Write to log.
    @file_put_contents($main_file, $e_string, FILE_APPEND);
    // IMPORTBUDDY
    $status = pb_backupbuddy::$format->date(time()) . "\t" . sprintf("%01.2f", round(microtime(true) - pb_backupbuddy::$start_time, 2)) . "\t" . sprintf("%01.2f", round(memory_get_peak_usage() / 1048576, 2)) . "\t" . 'error' . "\t\t" . str_replace(chr(9), '   ', $e_string);
    $status = str_replace('\\', '/', $status);
    echo '<script type="text/javascript">pb_status_append("' . str_replace('"', '&quot;', $status) . '");</script>';
}
// End shutdown_function.
/********** AJAX **********/
$ajax = '';
if (pb_backupbuddy::_POST('ajax') != '') {
    $ajax = pb_backupbuddy::_POST('ajax');
} elseif (pb_backupbuddy::_GET('ajax') != '') {
    $ajax = pb_backupbuddy::_GET('ajax');
}
if ($ajax != '') {
    Auth::require_authentication();
    // Die if not logged in.
    $page = ABSPATH . 'importbuddy/controllers/ajax/' . $ajax . '.php';
    if (file_exists($page)) {
        require_once $page;
    } else {
        echo '{Error: Invalid AJAX action `' . htmlentities($ajax) . '`.}';
    }
    /********** PAGES **********/
} elseif (pb_backupbuddy::_GET('step') != '' && is_numeric(pb_backupbuddy::_GET('step'))) {
    $step = pb_backupbuddy::_GET('step');
Пример #20
0
function plugin_information( $plugin_slug, $data ) {
	$plugin_path = $data['path'];
	?>
	
	<?php pb_backupbuddy::$ui->start_metabox( 'Plugin Information', true, 'width: 70%;' ); ?>
		<textarea readonly="readonly" rows="7" cols="65" wrap="off" style="width: 100%;"><?php echo "Version History:\n\n" ; readfile( $plugin_path . '/history.txt' ); ?></textarea>
		<br /><br />
		<script type="text/javascript">
			jQuery(document).ready(function() {
				jQuery("#pluginbuddy_<?php echo $plugin_slug; ?>_debugtoggle").click(function() {
					jQuery("#pluginbuddy_<?php echo $plugin_slug; ?>_debugtoggle_div").slideToggle();
				});
			});
		</script>
		<?php
		if ( pb_backupbuddy::_POST( 'reset_defaults' ) == $plugin_slug ) {
			if ( call_user_func(  'pb_' . $plugin_slug . '::reset_options', true ) === true ) {
				pb_backupbuddy::alert( 'Plugin settings have been reset to defaults for plugin `' . $data['name'] . '`.' );
			} else {
				pb_backupbuddy::alert( 'Unable to reset plugin settings. Verify you are running the latest version.' );
			}
		}
		?>
		<form method="post" action="<?php echo pb_backupbuddy::page_url(); ?>">
			<input type="hidden" name="reset_defaults" value="<?php echo $plugin_slug; ?>" />
			<input type="submit" name="submit" value="Reset Plugin Settings to Defaults" id="reset_defaults" class="button secondary-button" onclick="if ( !confirm('WARNING: This will reset all settings associated with this plugin to their defaults. Are you sure you want to do this?') ) { return false; }" />
		</form><br>
	<?php pb_backupbuddy::$ui->end_metabox(); ?>
	
	<?php
}
Пример #21
0
 public function importexport_settings()
 {
     pb_backupbuddy::load();
     pb_backupbuddy::$ui->ajax_header();
     if (pb_backupbuddy::_POST('import_settings') != '') {
         $import = trim(stripslashes(pb_backupbuddy::_POST('import_data')));
         $import = base64_decode($import);
         if ($import === false) {
             // decode failed.
             pb_backupbuddy::alert('Unable to decode settings data. Import aborted. Insure that you fully copied the settings and did not change any of the text.');
         } else {
             // decode success.
             if (($import = maybe_unserialize($import)) === false) {
                 // unserialize fail.
                 pb_backupbuddy::alert('Unable to unserialize settings data. Import aborted. Insure that you fully copied the settings and did not change any of the text.');
             } else {
                 // unserialize success.
                 if (!isset($import['data_version'])) {
                     // missing expected content.
                     pb_backupbuddy::alert('Unserialized settings data but it did not contain expected data. Import aborted. Insure that you fully copied the settings and did not change any of the text.');
                 } else {
                     // contains expected content.
                     pb_backupbuddy::$options = $import;
                     require_once pb_backupbuddy::plugin_path() . '/controllers/activation.php';
                     // Run data migration to upgrade if needed.
                     pb_backupbuddy::save();
                     pb_backupbuddy::alert('Provided settings successfully imported. Prior settings overwritten.');
                 }
             }
         }
     }
     echo '<h2>Export BackupBuddy Settings</h2>';
     echo 'Copy the encoded plugin settings below and paste it into the destination BackupBuddy Settings Import page.<br><br>';
     echo '<textarea style="width: 100%; height: 100px;" wrap="on">';
     echo base64_encode(serialize(pb_backupbuddy::$options));
     echo '</textarea>';
     echo '<br><br><br>';
     echo '<h2>Import BackupBuddy Settings</h2>';
     echo 'Paste encoded plugin settings below to import & replace current settings.  If importing settings from an older version and errors are encountered please deactivate and reactivate the plugin.<br><br>';
     echo '<form method="post" action="' . pb_backupbuddy::ajax_url('importexport_settings') . '">';
     echo '<textarea style="width: 100%; height: 100px;" wrap="on" name="import_data"></textarea>';
     echo '<br><br><input type="submit" name="import_settings" value="Import Settings" class="button button-primary">';
     echo '</form>';
     pb_backupbuddy::$ui->ajax_footer();
     die;
 }
}
// Remote destination testing.
/*	remote_test()
 *	
 *	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";
Пример #23
0
<?php

//print_r( pb_backupbuddy::_POST() );
$cpanel_user = pb_backupbuddy::_POST('cpanel_user');
$cpanel_password = pb_backupbuddy::_POST('cpanel_pass');
$cpanel_host = pb_backupbuddy::_POST('cpanel_url');
$cpanel_port = pb_backupbuddy::_POST('cpanel_port');
$db_name = pb_backupbuddy::_POST('cpanel_dbname');
$db_user = pb_backupbuddy::_POST('cpanel_dbuser');
$db_pass = pb_backupbuddy::_POST('cpanel_dbpass');
// Needed for HTTP requests.
$requestcore_file = pb_backupbuddy::plugin_path() . '/lib/requestcore/requestcore.class.php';
require_once $requestcore_file;
require_once pb_backupbuddy::plugin_path() . '/lib/cpanel/cpanel.php';
$create_db_result = pb_backupbuddy_cpanel::create_db($cpanel_user, $cpanel_password, $cpanel_host, $db_name, $db_user, $db_pass, $cpanel_port);
if ($create_db_result === true) {
    echo 'Success! Created database, user, and assigned user to database.';
} else {
    echo "Unable to automatically create database with the provided settings. Check settings or manually create the database from your host's control panel. See tutorial at: ";
    echo "http://pluginbuddy.com/tutorial-create-database-in-cpanel/\n\n";
    echo "Error details:\n" . implode("\n", $create_db_result);
}
die;
Пример #24
0
    $_POST['pb_backupbuddy_importbuddy_pass_hash_confirm'] = '';
    $importbuddy_pass_match_fail = true;
}
/* END VERIFYING PASSWORD CONFIRMATIONS MATCH */
/* BEGIN REPLACING IMPORTBUDDY/REPAIRBUDDY_PASS_HASH WITH VALUE OF ACTUAL HASH */
// ImportBuddy hash replace.
if (str_replace(')', '', pb_backupbuddy::_POST('pb_backupbuddy_importbuddy_pass_hash')) != '' && md5(pb_backupbuddy::_POST('pb_backupbuddy_importbuddy_pass_hash')) != pb_backupbuddy::$options['importbuddy_pass_hash']) {
    //echo 'posted value: ' . pb_backupbuddy::_POST( 'pb_backupbuddy_importbuddy_pass_hash' ) . '<br>';
    //echo 'hash: ' . md5( pb_backupbuddy::_POST( 'pb_backupbuddy_importbuddy_pass_hash' ) ) . '<br>';
    pb_backupbuddy::$options['importbuddy_pass_length'] = strlen(pb_backupbuddy::_POST('pb_backupbuddy_importbuddy_pass_hash'));
    $_POST['pb_backupbuddy_importbuddy_pass_hash'] = md5(pb_backupbuddy::_POST('pb_backupbuddy_importbuddy_pass_hash'));
} else {
    // Keep the same.
    if ($importbuddy_pass_match_fail !== true) {
        // keep the same
        $_POST['pb_backupbuddy_importbuddy_pass_hash'] = pb_backupbuddy::$options['importbuddy_pass_hash'];
    }
}
// Set importbuddy dummy text to display in form box. Equal length to the provided password.
$data['importbuddy_pass_dummy_text'] = str_pad('', pb_backupbuddy::$options['importbuddy_pass_length'], ')');
/* BEGIN SAVE MULTISITE SPECIFIC SETTINGS IN SET OPTIONS SO THEY ARE AVAILABLE GLOBALLY */
if (is_multisite()) {
    // Save multisite export option to the global site/network options for global retrieval.
    $options = get_site_option('pb_' . pb_backupbuddy::settings('slug'));
    $options['multisite_export'] = pb_backupbuddy::_POST('pb_backupbuddy_multisite_export');
    update_site_option('pb_' . pb_backupbuddy::settings('slug'), $options);
    unset($options);
}
/* END SAVE MULTISITE SPECIFIC SETTINGS IN SET OPTIONS SO THEY ARE AVAILABLE GLOBALLY */
// Load settings view.
pb_backupbuddy::load_view('settings', $data);
Пример #25
0
 public function backups_list($type = 'default', $subsite_mode = false)
 {
     if (pb_backupbuddy::_POST('bulk_action') == 'delete_backup') {
         $needs_save = false;
         pb_backupbuddy::verify_nonce(pb_backupbuddy::_POST('_wpnonce'));
         // Security check to prevent unauthorized deletions by posting from a remote place.
         $deleted_files = array();
         foreach (pb_backupbuddy::_POST('items') as $item) {
             if (file_exists(pb_backupbuddy::$options['backup_directory'] . $item)) {
                 if (@unlink(pb_backupbuddy::$options['backup_directory'] . $item) === true) {
                     $deleted_files[] = $item;
                     if (count(pb_backupbuddy::$options['backups']) > 3) {
                         // Keep a minimum number of backups in array for stats.
                         $this_serial = $this->get_serial_from_file($item);
                         unset(pb_backupbuddy::$options['backups'][$this_serial]);
                         $needs_save = true;
                     }
                 } else {
                     pb_backupbuddy::alert('Error: Unable to delete backup file `' . $item . '`. Please verify permissions.', true);
                 }
             }
             // End if file exists.
         }
         // End foreach.
         if ($needs_save === true) {
             pb_backupbuddy::save();
         }
         pb_backupbuddy::alert(__('Deleted backup(s):', 'it-l10n-backupbuddy') . ' ' . implode(', ', $deleted_files));
     }
     // End if deleting backup(s).
     $backups = array();
     $backup_sort_dates = array();
     $files = glob(pb_backupbuddy::$options['backup_directory'] . 'backup*.zip');
     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.
         $backup_prefix = $this->backup_prefix();
         // Backup prefix for this site. Used for MS checking that this user can see this backup.
         foreach ($files as $file_id => $file) {
             if ($subsite_mode === true && is_multisite()) {
                 // If a Network and NOT the superadmin must make sure they can only see the specific subsite backups for security purposes.
                 // Only allow viewing of their own backups.
                 if (!strstr($file, $backup_prefix)) {
                     unset($files[$file_id]);
                     // Remove this backup from the list. This user does not have access to it.
                     continue;
                     // Skip processing to next file.
                     echo 'bob';
                 }
             }
             $serial = pb_backupbuddy::$classes['core']->get_serial_from_file($file);
             // Populate integrity data structure in options.
             pb_backupbuddy::$classes['core']->backup_integrity_check($file);
             $pretty_status = array('pass' => 'Good', 'fail' => '<font color="red">Bad</font>');
             $pretty_type = array('full' => 'Full', 'db' => 'Database');
             //echo '<pre>' . print_r( pb_backupbuddy::$options['backups'][$serial], true ) . '</pre>';
             // Calculate time for each step.
             $step_times = array();
             $step_time_details = array();
             $zip_time = 0;
             if (isset(pb_backupbuddy::$options['backups'][$serial]['steps'])) {
                 foreach (pb_backupbuddy::$options['backups'][$serial]['steps'] as $step) {
                     if (!isset($step['finish_time']) || $step['finish_time'] == 0) {
                         $step_times[] = '<span class="description">Unknown</span>';
                     } else {
                         $step_time = $step['finish_time'] - $step['start_time'];
                         $step_times[] = $step_time;
                         // Pretty step name:
                         if ($step['function'] == 'backup_create_database_dump') {
                             $step_name = 'Database dump';
                         } elseif ($step['function'] == 'backup_zip_files') {
                             $step_name = 'Zip archive creation';
                         } elseif ($step['function'] == 'post_backup') {
                             $step_name = 'Post-backup cleanup';
                         } else {
                             $step_name = $step['function'];
                         }
                         $step_time_details[] = '<b>' . $step_name . '</b><br>&nbsp;&nbsp;&nbsp;' . $step_time . ' seconds in ' . $step['attempts'] . ' attempts.';
                         if ($step['function'] == 'backup_zip_files') {
                             $zip_time = $step_time;
                         }
                     }
                 }
                 // End foreach.
             } else {
                 // End if serial in array is set.
                 $step_times[] = '<span class="description">Unknown</span>';
             }
             // End if serial in array is NOT set.
             $step_times = implode(', ', $step_times);
             //echo '<pre>' . print_r( pb_backupbuddy::$options['backups'][$serial], true ) . '</pre>';
             // Calculate start and finish.
             if (isset(pb_backupbuddy::$options['backups'][$serial]['start_time']) && isset(pb_backupbuddy::$options['backups'][$serial]['finish_time']) && pb_backupbuddy::$options['backups'][$serial]['start_time'] > 0 && pb_backupbuddy::$options['backups'][$serial]['finish_time'] > 0) {
                 $start_time = pb_backupbuddy::$options['backups'][$serial]['start_time'];
                 $finish_time = pb_backupbuddy::$options['backups'][$serial]['finish_time'];
                 $total_time = $finish_time - $start_time;
             } else {
                 $total_time = '<span class="description">Unknown</span>';
             }
             // Calculate write speed in MB/sec for this backup.
             if ($zip_time == '0') {
                 // Took approx 0 seconds to backup so report this speed.
                 if (!isset($finish_time) || $finish_time == '0') {
                     $write_speed = '<span class="description">Unknown</span>';
                 } else {
                     $write_speed = '> ' . pb_backupbuddy::$format->file_size(pb_backupbuddy::$options['backups'][$serial]['integrity']['size']);
                 }
             } else {
                 $write_speed = pb_backupbuddy::$format->file_size(pb_backupbuddy::$options['backups'][$serial]['integrity']['size'] / $zip_time);
             }
             // Figure out trigger.
             if (isset(pb_backupbuddy::$options['backups'][$serial]['trigger'])) {
                 $trigger = pb_backupbuddy::$options['backups'][$serial]['trigger'];
             } else {
                 $trigger = __('Unknown', 'it-l10n-backupbuddy');
             }
             // HTML output for stats.
             $statistics = "\n\t\t\t\t\t<span style='width: 80px; display: inline-block;'>Total time:</span>{$total_time} secs<br>\n\t\t\t\t\t<span style='width: 80px; display: inline-block;'>Step times:</span>{$step_times}<br>\n\t\t\t\t\t<span style='width: 80px; display: inline-block;'>Write speed:</span>{$write_speed}/sec\n\t\t\t\t";
             // HTML output for stats details (for tooltip).
             $statistic_details = '<br><br>' . implode('<br>', $step_time_details) . '<br><br><i>Trigger: ' . $trigger . '</i>';
             // Calculate time ago.
             $time_ago = '<span class="description">' . pb_backupbuddy::$format->time_ago(pb_backupbuddy::$options['backups'][$serial]['integrity']['modified']) . ' ago</span>';
             // Calculate main row string.
             if ($type == 'default') {
                 // Default backup listing.
                 $main_string = '<a href="' . pb_backupbuddy::ajax_url('download_archive') . '&backupbuddy_backup=' . basename($file) . '">' . basename($file) . '</a>';
             } elseif ($type == 'migrate') {
                 // Migration backup listing.
                 $main_string = '<a class="pb_backupbuddy_hoveraction_migrate" rel="' . basename($file) . '" href="' . pb_backupbuddy::page_url() . '&migrate=' . basename($file) . '&value=' . basename($file) . '">' . basename($file) . '</a>';
             } else {
                 $main_string = '{Unknown type.}';
             }
             // Add comment to main row string if applicable.
             if (isset(pb_backupbuddy::$options['backups'][$serial]['integrity']['comment']) && pb_backupbuddy::$options['backups'][$serial]['integrity']['comment'] !== false && pb_backupbuddy::$options['backups'][$serial]['integrity']['comment'] !== '') {
                 $main_string .= '<br><span class="description">Note: <span class="pb_backupbuddy_notetext">' . pb_backupbuddy::$options['backups'][$serial]['integrity']['comment'] . '</span></span>';
             }
             $backups[basename($file)] = array(array(basename($file), $main_string), pb_backupbuddy::$format->date(pb_backupbuddy::$options['backups'][$serial]['integrity']['modified']) . '<br>' . $time_ago, pb_backupbuddy::$format->file_size(pb_backupbuddy::$options['backups'][$serial]['integrity']['size']), pb_backupbuddy::$format->prettify(pb_backupbuddy::$options['backups'][$serial]['integrity']['status'], $pretty_status) . ' ' . pb_backupbuddy::tip(pb_backupbuddy::$options['backups'][$serial]['integrity']['status_details'] . '<br><br>Checked ' . pb_backupbuddy::$format->date(pb_backupbuddy::$options['backups'][$serial]['integrity']['scan_time']) . $statistic_details, '', false) . ' <a href="' . pb_backupbuddy::page_url() . '&reset_integrity=' . $serial . '" title="' . __('Refresh backup integrity status for this file', 'it-l10n-backupbuddy') . '"><img src="' . pb_backupbuddy::plugin_url() . '/images/refresh_gray.gif" style="vertical-align: -1px;"></a>', pb_backupbuddy::$format->prettify(pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'], $pretty_type), $statistics);
             $backup_sort_dates[basename($file)] = pb_backupbuddy::$options['backups'][$serial]['integrity']['modified'];
         }
         // End foreach().
     }
     // End if.
     // Sort backup sizes.
     arsort($backup_sort_dates);
     // Re-arrange backups based on sort dates.
     $sorted_backups = array();
     foreach ($backup_sort_dates as $backup_file => $backup_sort_date) {
         $sorted_backups[$backup_file] = $backups[$backup_file];
         unset($backups[$backup_file]);
     }
     unset($backups);
     return $sorted_backups;
 }
Пример #26
0
                // File is in directory we are not sending. Unset.
                unset($deployData['pullPluginFiles'][$i]);
            }
        }
    }
    if ('true' == pb_backupbuddy::_POST('sendPlugins')) {
        $deployData['sendPlugins'] = true;
    } else {
        $deployData['sendPlugins'] = false;
    }
    if ('true' == pb_backupbuddy::_POST('sendMedia')) {
        $deployData['sendMedia'] = true;
    } else {
        $deployData['sendMedia'] = false;
    }
    $deployData['destination_id'] = pb_backupbuddy::_POST('destination_id');
    if ('push' == pb_backupbuddy::_GET('direction')) {
        $post_backup_steps = array(array('function' => 'deploy_push_start', 'args' => array($deployData), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0));
        pb_backupbuddy::status('details', 'Deployment PUSH set to send to remote destination `' . $deployData['destination_id'] . '`. Added to post backup function steps.');
    }
    // end if PUSH type deployment.
    if ('pull' == pb_backupbuddy::_GET('direction')) {
        $post_backup_steps = array(array('function' => 'deploy_pull_start', 'args' => array($deployData), 'start_time' => 0, 'finish_time' => 0, 'attempts' => 0));
        pb_backupbuddy::status('details', 'Deployment PULL set to send to remote destination `' . $deployData['destination_id'] . '`. Added to post backup function steps.');
    }
    // end if PULL type deployment.
}
// end if deployment.
$deployDestination = null;
if (isset($deployData['destination'])) {
    $deployDestination = $deployData['destination'];
Пример #27
0
<?php

backupbuddy_core::verifyAjaxAccess();
// Note: importbuddy, backup files, etc should have already been cleaned up by importbuddy itself at this point.
$serial = pb_backupbuddy::_POST('serial');
$direction = pb_backupbuddy::_POST('direction');
pb_backupbuddy::load();
if ('pull' == $direction) {
    // Local so clean up here.
    backupbuddy_core::cleanup_temp_tables($serial);
    die('1');
} elseif ('push' == $direction) {
    // Remote so call API to clean up.
    require_once pb_backupbuddy::plugin_path() . '/classes/remote_api.php';
    $destinationID = pb_backupbuddy::_POST('destinationID');
    if (!isset(pb_backupbuddy::$options['remote_destinations'][$destinationID])) {
        die('Error #8383983: Invalid destination ID `' . htmlentities($destinationID) . '`.');
    }
    $destinationArray = pb_backupbuddy::$options['remote_destinations'][$destinationID];
    if ('site' != $destinationArray['type']) {
        die('Error #8378332: Destination with ID `' . htmlentities($destinationID) . '` not of "site" type.');
    }
    $apiKey = $destinationArray['api_key'];
    $apiSettings = backupbuddy_remote_api::key_to_array($apiKey);
    if (false === ($response = backupbuddy_remote_api::remoteCall($apiSettings, 'confirmDeployment', array('serial' => $serial), 10, null, null, null, null, null, null, null, $returnRaw = true))) {
        $message = 'Error #2378378324. Unable to confirm remote deployment with serial `' . $serial . '` via remote API.';
        pb_backupbuddy::status('error', $message);
        die($message);
    } else {
        if (false === ($response = json_decode($response, true))) {
            $message = 'Error #239872373. Unable to decode remote deployment response with serial `' . $serial . '` via remote API. Remote server response: `' . print_r($response) . '`.';
Пример #28
0
    }
} elseif (!empty($_POST['edit_destination'])) {
    if ($_POST['#title'] == '') {
        $_POST['#title'] = '[no name]';
    }
    if ($_POST['#type'] == 'ftp') {
        if ($_POST['#path'] != '' && substr($_POST['#path'], 0, 1) != '/') {
            // Require leading slash for FTP path.
            $_POST['#path'] = '/' . $_POST['#path'];
        }
    }
    if (!defined('PB_DEMO_MODE')) {
        $missing_field = false;
        $required_fields = explode(',', pb_backupbuddy::_POST('required_fields'));
        foreach ($required_fields as $required_field) {
            if (pb_backupbuddy::_POST('#' . $required_field) == '') {
                $missing_field = true;
            }
        }
        if ($missing_field !== false) {
            pb_backupbuddy::alert('One or more required fields were missing. Destination settings not saved.');
        } else {
            savesettings($_POST['savepoint']);
            pb_backupbuddy::alert(__('Destination settings saved.', 'it-l10n-backupbuddy'));
        }
    } else {
        pb_backupbuddy::alert('Access denied in demo mode.', true);
    }
}
pb_backupbuddy::$ui->start_tab('ftp');
require_once '_destination_ftp.php';
Пример #29
0
All scheduled WordPress tasks (CRON jobs) are listed below. Use caution when manually running or deleting scheduled CRON
jobs as plugins, themes, or WordPress itself may expect these to remain in place. WordPress will recreate any mandatory
internal CRON jobs automatically if they are removed.<br><br>
<?php 
$cron = get_option('cron');
// Handle CRON deletions.
if (pb_backupbuddy::_POST('bulk_action') == 'delete_cron') {
    if (defined('PB_DEMO_MODE')) {
        pb_backupbuddy::alert('Access denied in demo mode.', true);
    } else {
        $delete_items = pb_backupbuddy::_POST('items');
        $deleted_crons = array();
        // For listing in alert.
        foreach ($delete_items as $delete_item) {
            $cron_parts = explode('|', $delete_item);
            $timestamp = $cron_parts[0];
            $cron_hook = $cron_parts[1];
            $cron_key = $cron_parts[2];
            if (isset($cron[$timestamp][$cron_hook][$cron_key])) {
                // Run cron.
                $cron_array = $cron[$timestamp][$cron_hook][$cron_key];
                // Get cron array based on passed values.
                $result = backupbuddy_core::unschedule_event($timestamp, $cron_hook, $cron_array['args']);
                // Delete the scheduled cron.
                if ($result === FALSE) {
                    pb_backupbuddy::alert('Error #5657667675. Unable to delete CRON job. Please see your BackupBuddy error log for details.');
                }
                $deleted_crons[] = $cron_hook . ' / ' . $cron_key;
                // Add deleted cron to list of deletions for display.
            } else {
                // Cron not found, error.
 public static function is_call_valid()
 {
     $key_public = pb_backupbuddy::_POST('backupbuddy_api_key');
     $verb = pb_backupbuddy::_POST('verb');
     $time = pb_backupbuddy::_POST('now');
     $filecrc = pb_backupbuddy::_POST('filecrc');
     $signature = pb_backupbuddy::_POST('signature');
     $maxAge = 60 * 60;
     // Time in seconds after which a signed request is deemed too old. Help prevent replays. 1hr.
     foreach (pb_backupbuddy::$options['remote_api']['keys'] as $key) {
         $keyArr = self::key_to_array($key);
         if ($key_public == $keyArr['key_public']) {
             // Incoming public key matches a stored public key.
             // Has call expired?
             if (!is_numeric($time) || time() - $time > $maxAge) {
                 $message = 'Error #4845985: API call timestamp is too old. Verify the realtime clock on each server is relatively in sync.';
                 pb_backupbuddy::status('error', $message);
                 die(json_encode(array('success' => false, 'error' => $message)));
             }
             // Verify signature.
             $calculatedSignature = md5($time . $verb . $key_public . $keyArr['key_secret'] . $filecrc);
             if ($calculatedSignature != $signature) {
                 // Key matched but signature failed. Data has been tempered with or damaged in transit.
                 return false;
             } else {
                 return true;
             }
         }
     }
     return false;
 }