Пример #1
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;
 }
Пример #2
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>
Пример #3
0
 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;
 }
Пример #4
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;
    }
Пример #5
0
<script type="text/javascript">
jQuery(document).ready(function(){
	jQuery( '#pb_backupbuddy_first_run' ).datetimepicker({
		ampm: true
	});
});
</script>

<?php 
pb_backupbuddy::$classes['core']->versions_confirm();
$date_format_example = 'mm/dd/yyyy hh:mm [am/pm]';
// Example date format for displaying to user.
// HANDLE SCHEDULE DELETION.
if (pb_backupbuddy::_POST('bulk_action') == 'delete_schedule') {
    pb_backupbuddy::verify_nonce(pb_backupbuddy::_POST('_wpnonce'));
    // Security check to prevent unauthorized deletions by posting from a remote place.
    $deleted_schedules = array();
    foreach (pb_backupbuddy::_POST('items') as $id) {
        $deleted_schedules[] = htmlentities(pb_backupbuddy::$options['schedules'][$id]['title']);
        $next_scheduled_time = wp_next_scheduled('pb_backupbuddy-cron_scheduled_backup', array((int) $id));
        wp_unschedule_event($next_scheduled_time, 'pb_backupbuddy-cron_scheduled_backup', array((int) $id));
        // Remove old schedule. pb_backupbuddy::$options['schedules'][$id]['first_run']
        unset(pb_backupbuddy::$options['schedules'][$id]);
    }
    pb_backupbuddy::save();
    pb_backupbuddy::alert(__('Deleted schedule(s):', 'it-l10n-backupbuddy') . ' ' . implode(', ', $deleted_schedules));
}
// End if deleting backup(s).
if (pb_backupbuddy::_GET('edit') != '') {
    $mode = 'edit';
Пример #6
0
 public 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(pb_backupbuddy::$options['backup_directory'] . $item)) {
                 if (@unlink(pb_backupbuddy::$options['backup_directory'] . $item) === true) {
                     $deleted_files[] = $item;
                     // Cleanup any related fileoptions files.
                     $serial = pb_backupbuddy::$classes['core']->get_serial_from_file($item);
                     $fileoptions_file = pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '.txt';
                     $fileoptions_filetree_file = pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '-filetree.txt';
                     if (file_exists($fileoptions_file)) {
                         if (false === @unlink($fileoptions_file)) {
                             pb_backupbuddy::status('error', 'Unable to delete fileoptions file `' . $fileoptions_file . '`.');
                         }
                     }
                     if (file_exists($fileoptions_file . '.lock')) {
                         if (false === @unlink($fileoptions_file . '.lock')) {
                             pb_backupbuddy::status('error', 'Unable to delete fileoptions file `' . $fileoptions_file . '.lock`.');
                         }
                     }
                     if (file_exists($fileoptions_filetree_file)) {
                         if (false === @unlink($fileoptions_filetree_file)) {
                             pb_backupbuddy::status('error', 'Unable to delete fileoptions file `' . $fileoptions_filetree_file . '`.');
                         }
                     }
                     $backup_files = glob(pb_backupbuddy::$options['backup_directory'] . '*.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 = $this->get_serial_from_file($item);
                         $fileoptions_file = pb_backupbuddy::$options['log_directory'] . '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(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.
                 }
             }
             $serial = pb_backupbuddy::$classes['core']->get_serial_from_file($file);
             // Populate integrity data structure in options.
             pb_backupbuddy::$classes['core']->backup_integrity_check($file);
             // 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');
             require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
             $backup_options = new pb_backupbuddy_fileoptions(pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '.txt');
             if (true !== ($result = $backup_options->is_ok())) {
                 pb_backupbuddy::status('error', 'Error retrieving fileoptions file `' . pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '.txt' . '`. Err 4332345.');
             }
             // Verify valid fileoptions data exists.
             if (!is_array($backup_options->options)) {
                 // fileoptions data missing. try to regenerate with integrity check
                 pb_backupbuddy::status('details', 'Fileoptions data missing loading backup list. Re-scanning integrity to regenerate on file `' . $file . '`.');
                 pb_backupbuddy::$classes['core']->backup_integrity_check($file);
                 // Re-load fileoptions now.
                 $backup_options = new pb_backupbuddy_fileoptions(pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '.txt');
                 if (true !== ($result = $backup_options->is_ok())) {
                     pb_backupbuddy::status('error', 'Error retrieving fileoptions file `' . pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '.txt' . '`. Err 3278475845.');
                 }
             }
             $step_times = array();
             if (isset($backup_options->options['steps'])) {
                 foreach ($backup_options->options['steps'] as $step) {
                     if (isset($step['finish_time']) && $step['finish_time'] != 0) {
                         // Step time taken.
                         $step_times[] = $step['finish_time'] - $step['start_time'];
                     }
                 }
                 // End foreach.
             } else {
                 // End if serial in array is set.
                 $step_times[] = 'unknown';
             }
             // End if serial in array is NOT set.
             $step_times = implode(', ', $step_times);
             // Defaults...
             $detected_type = '';
             $file_size = '';
             $modified = '';
             $modified_time = 0;
             $integrity = '';
             $statistics = '';
             $write_speed = '';
             if (is_array($backup_options->options)) {
                 // Data intact... put it all together.
                 // Calculate time ago.
                 $time_ago = '';
                 if (isset($backup_options->options['integrity']) && isset($backup_options->options['integrity']['modified'])) {
                     $time_ago = '<span class="description">' . pb_backupbuddy::$format->time_ago($backup_options->options['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($backup_options->options['integrity']['comment']) && $backup_options->options['integrity']['comment'] !== false && $backup_options->options['integrity']['comment'] !== '') {
                     $main_string .= '<br><span class="description">Note: <span class="pb_backupbuddy_notetext">' . htmlentities($backup_options->options['integrity']['comment']) . '</span></span>';
                 }
                 $detected_type = pb_backupbuddy::$format->prettify($backup_options->options['integrity']['detected_type'], $pretty_type);
                 if (isset($backup_options->options['profile'])) {
                     $detected_type = $detected_type . '<br><small class="description">' . htmlentities($backup_options->options['profile']['title']) . '</small>';
                 }
                 $file_size = pb_backupbuddy::$format->file_size($backup_options->options['integrity']['size']);
                 $modified = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($backup_options->options['integrity']['modified'])) . '<br>' . $time_ago;
                 $modified_time = $backup_options->options['integrity']['modified'];
                 if (isset($backup_options->options['integrity']['status'])) {
                     // Pre-v4.0.
                     $status = $backup_options->options['integrity']['status'];
                 } else {
                     // v4.0+
                     $status = $backup_options->options['integrity']['is_ok'];
                 }
                 $integrity = pb_backupbuddy::$format->prettify($status, $pretty_status) . ' <a href="' . pb_backupbuddy::page_url() . '&reset_integrity=' . $serial . '" title="Rescan integrity. Last checked ' . pb_backupbuddy::$format->date($backup_options->options['integrity']['scan_time']) . '."><img src="' . pb_backupbuddy::plugin_url() . '/images/refresh_gray.gif" style="vertical-align: -1px;"></a>' . '<div class="row-actions"><a title="' . __('Backup Details, Status, & Statistics', '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>';
             }
             // end if is_array( $backup_options ).
             $backups[basename($file)] = array(array(basename($file), $main_string), $detected_type, $file_size, $modified, $integrity);
             $backup_sort_dates[basename($file)] = $modified_time;
         }
         // 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;
 }
Пример #7
0
 public function pbframework_troubleshooting()
 {
     pb_backupbuddy::verify_nonce();
     echo 'test';
 }