public function integrity_status() { $serial = pb_backupbuddy::_GET('serial'); pb_backupbuddy::load(); pb_backupbuddy::$ui->ajax_header(); $integrity = pb_backupbuddy::$options['backups'][$serial]['integrity']; // Backup overall status. /* echo 'Backup status: '; if ( $integrity['status'] == 'pass' ) { // Pass. echo '<span class="pb_label pb_label-success">Good</span>'; } else { // Fail. echo '<span class="pb_label pb_label-important">Bad</span>'; } echo '<br>'; */ //***** BEGIN TESTS AND RESULTS. if (!is_array($integrity['status_details'])) { // $integrity['status_details'] is NOT array (old, pre-3.1.9). echo '<h3>Integrity Technical Details</h3>'; echo '<textarea style="width: 100%; height: 175px;" wrap="off">'; foreach (pb_backupbuddy::$options['backups'][$serial]['integrity'] as $item_name => $item_value) { $item_value = str_replace('<br />', '<br>', $item_value); $item_value = str_replace('<br><br>', '<br>', $item_value); $item_value = str_replace('<br>', "\n ", $item_value); echo $item_name . ' => ' . $item_value . "\n"; } echo '</textarea><br><br><b>Note:</b> It is normal to see several "file not found" entries as BackupBuddy checks for expected files in multiple locations, expecting to only find each file once in one of those locations.'; } else { // $integrity['status_details'] is array. echo '<br>'; function pb_pretty_results($value) { if ($value === true) { return '<span class="pb_label pb_label-success">Pass</span>'; } else { return '<span class="pb_label pb_label-important">Fail</span>'; } } // The tests & their status.. $tests = array(); $tests[] = array('BackupBackup data file exists', pb_pretty_results($integrity['status_details']['found_dat'])); $tests[] = array('Database SQL file exists', pb_pretty_results($integrity['status_details']['found_sql'])); if ($integrity['detected_type'] == 'full') { // Full backup. $tests[] = array('WordPress wp-config.php exists (full backups only)', pb_pretty_results($integrity['status_details']['found_wpconfig'])); } else { // DB only. $tests[] = array('WordPress wp-config.php exists (full backups only)', '<span class="pb_label pb_label-success">N/A</span>'); } $columns = array(__('Integrity Test', 'it-l10n-backupbuddy'), __('Status', 'it-l10n-backupbuddy')); pb_backupbuddy::$ui->list_table($tests, array('columns' => $columns, 'css' => 'width: 100%; min-width: 200px;')); } // end $integrity['status_details'] is an array. //***** END TESTS AND RESULTS. echo '<br><br>'; //***** BEGIN STEPS. $steps = array(); 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 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 taken. $step_time = (string) ($step['finish_time'] - $step['start_time']) . ' seconds'; // Compile details for this step into array. $steps[] = array($step_name, $step_time, $step['attempts']); } } // End foreach. } else { // End if serial in array is set. $step_times[] = 'unknown'; } // End if serial in array is NOT set. $columns = array(__('Backup Step', 'it-l10n-backupbuddy'), __('Time Taken', 'it-l10n-backupbuddy'), __('Attempts', 'it-l10n-backupbuddy')); if (count($steps) == 0) { _e('No step step statistics were found for this backup.', 'it-l10n-backupbuddy'); } else { pb_backupbuddy::$ui->list_table($steps, array('columns' => $columns, 'css' => 'width: 100%; min-width: 200px;')); } //***** END STEPS. if (isset(pb_backupbuddy::$options['backups'][$serial]['trigger'])) { $trigger = pb_backupbuddy::$options['backups'][$serial]['trigger']; } else { $trigger = 'Unknown trigger'; } $scanned = pb_backupbuddy::$format->date($integrity['scan_time']); echo '<br><br>'; echo ucfirst($trigger) . " backup {$integrity['file']} last scanned {$scanned}."; echo '<br><br>'; /* echo '<h3>Integrity Technical Details</h3>'; echo '<textarea style="width: 100%; height: 175px;" wrap="off">'; foreach( pb_backupbuddy::$options['backups'][$serial]['integrity'] as $item_name => $item_value ) { $item_value = str_replace( '<br />', '<br>', $item_value ); $item_value = str_replace( '<br><br>', '<br>', $item_value ); $item_value = str_replace( '<br>', "\n ", $item_value ); echo $item_name . ' => ' . $item_value . "\n"; } echo '</textarea><br><br><b>Note:</b> It is normal to see several "file not found" entries as BackupBuddy checks for expected files in multiple locations, expecting to only find each file once in one of those locations.<br><br>If you are encountering problems providing this information to support may assist in troubleshooting.'; */ pb_backupbuddy::$ui->ajax_footer(); die; }
if ($value === true) { return '<span class="pb_label pb_label-success">Pass</span>'; } else { return '<span class="pb_label pb_label-important">Fail</span>'; } } // The tests & their status.. $tests = array(); $tests[] = array('BackupBackup data file exists', pb_pretty_results($integrity['status_details']['found_dat'])); $tests[] = array('Database SQL file exists', pb_pretty_results($integrity['status_details']['found_sql'])); if ($integrity['detected_type'] == 'full') { // Full backup. $tests[] = array('WordPress wp-config.php exists (full/files backups only)', pb_pretty_results($integrity['status_details']['found_wpconfig'])); } elseif ($integrity['detected_type'] == 'files') { // Files only backup. $tests[] = array('WordPress wp-config.php exists (full/files backups only)', pb_pretty_results($integrity['status_details']['found_wpconfig'])); } else { // DB only. $tests[] = array('WordPress wp-config.php exists (full/files backups only)', '<span class="pb_label pb_label-success">N/A</span>'); } } else { // 4.0+ Tests. $tests = array(); if (isset($integrity['tests'])) { foreach ((array) $integrity['tests'] as $test) { if (true === $test['pass']) { $status_text = '<span class="pb_label pb_label-success">Pass</span>'; } else { $status_text = '<span class="pb_label pb_label-important">Fail</span>'; } $tests[] = array($test['test'], $status_text);
public function integrity_status() { $serial = pb_backupbuddy::_GET('serial'); $serial = str_replace('/\\', '', $serial); pb_backupbuddy::load(); pb_backupbuddy::$ui->ajax_header(); require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php'; $backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = true); if (true !== ($result = $backup_options->is_ok())) { pb_backupbuddy::alert(__('Unable to access fileoptions data file.', 'it-l10n-backupbuddy') . ' Error: ' . $result); die; } $integrity = $backup_options->options['integrity']; //echo '<p><b>' . __( 'Backup File', 'it-l10n-backupbuddy' ) . '</b>: ' . $integrity['file'] . '</p>'; $start_time = 'Unknown'; $finish_time = 'Unknown'; if (isset($backup_options->options['start_time'])) { $start_time = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($backup_options->options['start_time'])) . ' <span class="description">(' . pb_backupbuddy::$format->time_ago($backup_options->options['finish_time']) . ' ago)</span>'; if ($backup_options->options['finish_time'] > 0) { $finish_time = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($backup_options->options['finish_time'])) . ' <span class="description">(' . pb_backupbuddy::$format->time_ago($backup_options->options['finish_time']) . ' ago)</span>'; } else { // unfinished. $finish_time = '<i>Unfinished</i>'; } } //***** BEGIN TESTS AND RESULTS. if (isset($integrity['status_details'])) { // $integrity['status_details'] is NOT array (old, pre-3.1.9). echo '<h3>Integrity Technical Details</h3>'; echo '<textarea style="width: 100%; height: 175px;" wrap="off">'; foreach ($integrity as $item_name => $item_value) { $item_value = str_replace('<br />', '<br>', $item_value); $item_value = str_replace('<br><br>', '<br>', $item_value); $item_value = str_replace('<br>', "\n ", $item_value); echo $item_name . ' => ' . $item_value . "\n"; } echo '</textarea><br><br><b>Note:</b> It is normal to see several "file not found" entries as BackupBuddy checks for expected files in multiple locations, expecting to only find each file once in one of those locations.'; } else { // $integrity['status_details'] is array. echo '<br>'; if (isset($integrity['status_details'])) { // PRE-v4.0 Tests. function pb_pretty_results($value) { if ($value === true) { return '<span class="pb_label pb_label-success">Pass</span>'; } else { return '<span class="pb_label pb_label-important">Fail</span>'; } } // The tests & their status.. $tests = array(); $tests[] = array('BackupBackup data file exists', pb_pretty_results($integrity['status_details']['found_dat'])); $tests[] = array('Database SQL file exists', pb_pretty_results($integrity['status_details']['found_sql'])); if ($integrity['detected_type'] == 'full') { // Full backup. $tests[] = array('WordPress wp-config.php exists (full/files backups only)', pb_pretty_results($integrity['status_details']['found_wpconfig'])); } elseif ($integrity['detected_type'] == 'files') { // Files only backup. $tests[] = array('WordPress wp-config.php exists (full/files backups only)', pb_pretty_results($integrity['status_details']['found_wpconfig'])); } else { // DB only. $tests[] = array('WordPress wp-config.php exists (full/files backups only)', '<span class="pb_label pb_label-success">N/A</span>'); } } else { // 4.0+ Tests. $tests = array(); foreach ((array) $integrity['tests'] as $test) { if (true === $test['pass']) { $status_text = '<span class="pb_label pb_label-success">Pass</span>'; } else { $status_text = '<span class="pb_label pb_label-important">Fail</span>'; } $tests[] = array($test['test'], $status_text); } } $columns = array(__('Integrity Test', 'it-l10n-backupbuddy'), __('Status', 'it-l10n-backupbuddy')); pb_backupbuddy::$ui->list_table($tests, array('columns' => $columns, 'css' => 'width: 100%; min-width: 200px;')); } // end $integrity['status_details'] is an array. echo '<br><br>'; //***** END TESTS AND RESULTS. // Output meta info table (if any). if (false === ($metaInfo = backupbuddy_core::getZipMeta(backupbuddy_core::getBackupDirectory() . $integrity['file']))) { // $backup_options->options['archive_file'] echo '<i>No meta data found in zip comment. Skipping meta information display.</i>'; } else { pb_backupbuddy::$ui->list_table($metaInfo, array('columns' => array('Backup Details', 'Value'), 'css' => 'width: 100%; min-width: 200px;')); } echo '<br><br>'; //***** BEGIN STEPS. $steps = array(); $steps[] = array('Start Time', $start_time, ''); if (isset($backup_options->options['steps'])) { foreach ($backup_options->options['steps'] as $step) { if (isset($step['finish_time']) && $step['finish_time'] != 0) { // Step name. if ($step['function'] == 'backup_create_database_dump') { if (count($step['args'][0]) == 1) { $step_name = 'Database dump (breakout: ' . $step['args'][0][0] . ')'; } else { $step_name = 'Database dump'; } } elseif ($step['function'] == 'backup_zip_files') { if (isset($backup_options->options['steps']['backup_zip_files'])) { $zip_time = $backup_options->options['steps']['backup_zip_files']; } else { $zip_time = 0; } // Calculate write speed in MB/sec for this backup. if ($zip_time == '0') { // Took approx 0 seconds to backup so report this speed. $write_speed = '> ' . pb_backupbuddy::$format->file_size($backup_options->options['integrity']['size']); } else { if ($zip_time == 0) { $write_speed = ''; } else { $write_speed = pb_backupbuddy::$format->file_size($backup_options->options['integrity']['size'] / $zip_time) . '/sec'; } } $step_name = 'Zip archive creation (Write speed: ' . $write_speed . ')'; } elseif ($step['function'] == 'post_backup') { $step_name = 'Post-backup cleanup'; } elseif ($step['function'] == 'integrity_check') { $step_name = 'Integrity Check'; } else { $step_name = $step['function']; } // Step time taken. $step_time = (string) ($step['finish_time'] - $step['start_time']) . ' seconds'; // Compile details for this step into array. $steps[] = array($step_name, $step_time, $step['attempts']); } } // End foreach. } else { // End if serial in array is set. $step_times[] = 'unknown'; } // End if serial in array is NOT set. // Total overall time from initiation to end. if (isset($backup_options->options['finish_time']) && isset($backup_options->options['start_time']) && $backup_options->options['finish_time'] != 0 && $backup_options->options['start_time'] != 0) { $total_time = $backup_options->options['finish_time'] - $backup_options->options['start_time'] . ' seconds'; } else { $total_time = '<i>Unknown</i>'; } $steps[] = array('Finish Time', $finish_time, ''); $steps[] = array('<b>Total Overall Time</b>', $total_time, ''); $columns = array(__('Backup Steps', 'it-l10n-backupbuddy'), __('Time', 'it-l10n-backupbuddy'), __('Attempts', 'it-l10n-backupbuddy')); if (count($steps) == 0) { _e('No step statistics were found for this backup.', 'it-l10n-backupbuddy'); } else { pb_backupbuddy::$ui->list_table($steps, array('columns' => $columns, 'css' => 'width: 100%; min-width: 200px;')); } echo '<br><br>'; //***** END STEPS. if (isset($backup_options->options['trigger'])) { $trigger = $backup_options->options['trigger']; } else { $trigger = 'Unknown trigger'; } $scanned = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($integrity['scan_time'])); echo ucfirst($trigger) . " backup {$integrity['file']} last scanned {$scanned}."; echo '<br><br><br>'; echo '<a class="button secondary-button" onclick="jQuery(\'#pb_backupbuddy_advanced_debug\').slideToggle();">Display Advanced Debugging</a>'; echo '<div id="pb_backupbuddy_advanced_debug" style="display: none;">'; echo '<textarea style="width: 100%; height: 400px;" wrap="on">'; echo print_r($backup_options->options, true); echo '</textarea><br><br>'; echo '</div><br><br>'; pb_backupbuddy::$ui->ajax_footer(); die; }
public function integrity_status() { $serial = pb_backupbuddy::_GET('serial'); pb_backupbuddy::load(); pb_backupbuddy::$ui->ajax_header(); $integrity = pb_backupbuddy::$options['backups'][$serial]['integrity']; // Backup overall status. /* echo 'Backup status: '; if ( $integrity['status'] == 'pass' ) { // Pass. echo '<span class="pb_label pb_label-success">Good</span>'; } else { // Fail. echo '<span class="pb_label pb_label-important">Bad</span>'; } echo '<br>'; */ //***** BEGIN TESTS AND RESULTS. if (!is_array($integrity['status_details'])) { // $integrity['status_details'] is NOT array (old, pre-3.1.9). echo '<h3>Integrity Technical Details</h3>'; echo '<textarea style="width: 100%; height: 175px;" wrap="off">'; foreach (pb_backupbuddy::$options['backups'][$serial]['integrity'] as $item_name => $item_value) { $item_value = str_replace('<br />', '<br>', $item_value); $item_value = str_replace('<br><br>', '<br>', $item_value); $item_value = str_replace('<br>', "\n ", $item_value); echo $item_name . ' => ' . $item_value . "\n"; } echo '</textarea><br><br><b>Note:</b> It is normal to see several "file not found" entries as BackupBuddy checks for expected files in multiple locations, expecting to only find each file once in one of those locations.'; } else { // $integrity['status_details'] is array. echo '<br>'; function pb_pretty_results($value) { if ($value === true) { return '<span class="pb_label pb_label-success">Pass</span>'; } else { return '<span class="pb_label pb_label-important">Fail</span>'; } } // The tests & their status.. $tests = array(); $tests[] = array('BackupBackup data file exists', pb_pretty_results($integrity['status_details']['found_dat'])); $tests[] = array('Database SQL file exists', pb_pretty_results($integrity['status_details']['found_sql'])); if ($integrity['detected_type'] == 'full') { // Full backup. $tests[] = array('WordPress wp-config.php exists (full backups only)', pb_pretty_results($integrity['status_details']['found_wpconfig'])); } else { // DB only. $tests[] = array('WordPress wp-config.php exists (full backups only)', '<span class="pb_label pb_label-success">N/A</span>'); } $columns = array(__('Integrity Test', 'it-l10n-backupbuddy'), __('Status', 'it-l10n-backupbuddy')); pb_backupbuddy::$ui->list_table($tests, array('columns' => $columns, 'css' => 'width: 100%; min-width: 200px;')); } // end $integrity['status_details'] is an array. //***** END TESTS AND RESULTS. echo '<br><br>'; //***** BEGIN STEPS. $steps = array(); 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 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'; } elseif ($step['function'] == 'integrity_check') { $step_name = 'Integrity Check'; } else { $step_name = $step['function']; } // Step time taken. $step_time = (string) ($step['finish_time'] - $step['start_time']) . ' seconds'; // Compile details for this step into array. $steps[] = array($step_name, $step_time, $step['attempts']); } } // End foreach. } else { // End if serial in array is set. $step_times[] = 'unknown'; } // End if serial in array is NOT set. $columns = array(__('Backup Step', 'it-l10n-backupbuddy'), __('Time Taken', 'it-l10n-backupbuddy'), __('Attempts', 'it-l10n-backupbuddy')); if (count($steps) == 0) { _e('No step step statistics were found for this backup.', 'it-l10n-backupbuddy'); } else { pb_backupbuddy::$ui->list_table($steps, array('columns' => $columns, 'css' => 'width: 100%; min-width: 200px;')); } echo '<br><br>'; //***** END STEPS. //***** BEGIN COMMENT META. if (!isset(pb_backupbuddy::$classes['zipbuddy'])) { require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php'; pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(pb_backupbuddy::$options['backup_directory']); } $comment = pb_backupbuddy::$classes['zipbuddy']->get_comment(pb_backupbuddy::$options['backups'][$serial]['archive_file']); $comment = pb_backupbuddy::$classes['core']->normalize_comment_data($comment); $comment_meta = array(); foreach ($comment as $comment_line_name => $comment_line_value) { // Loop through all meta fields in the comment array to display. if ($comment_line_name == 'serial') { $comment_line_name = 'Unique serial identifier (serial)'; } elseif ($comment_line_name == 'siteurl') { $comment_line_name = 'Site URL (siteurl)'; } elseif ($comment_line_name == 'type') { $comment_line_name = 'Backup type (type)'; if ($comment_line_value == 'db') { $comment_line_value = 'Database'; } elseif ($comment_line_value == 'full') { $comment_line_value = 'Full'; } } elseif ($comment_line_name == 'created') { $comment_line_name = 'Backup creation time (created)'; if ($comment_line_value != '') { $comment_line_value = pb_backupbuddy::$format->date($comment_line_value); } } elseif ($comment_line_name == 'bb_version') { $comment_line_name = 'BackupBuddy version at creation (bb_version)'; } elseif ($comment_line_name == 'wp_version') { $comment_line_name = 'WordPress version at creation (wp_version)'; } elseif ($comment_line_name == 'dat_path') { $comment_line_name = 'BackupBuddy data file (relative; dat_path)'; } elseif ($comment_line_name == 'note') { $comment_line_name = 'User-specified note'; if ($comment_line_value != '') { $comment_line_value = '"' . htmlentities($comment_line_value) . '"'; } } else { $step_name = $step['function']; } if ($comment_line_value != '') { $comment_meta[] = array($comment_line_name, $comment_line_value); } } if (count($comment_meta) > 0) { pb_backupbuddy::$ui->list_table($comment_meta, array('columns' => array('Meta Information', 'Value'), 'css' => 'width: 100%; min-width: 200px;')); } else { echo '<i>No meta data found in zip comment. Skipping meta information display.</i>'; } //***** END COMMENT META. if (isset(pb_backupbuddy::$options['backups'][$serial]['trigger'])) { $trigger = pb_backupbuddy::$options['backups'][$serial]['trigger']; } else { $trigger = 'Unknown trigger'; } $scanned = pb_backupbuddy::$format->date($integrity['scan_time']); echo '<br><br>'; echo ucfirst($trigger) . " backup {$integrity['file']} last scanned {$scanned}."; echo '<br><br>'; /* echo '<h3>Integrity Technical Details</h3>'; echo '<textarea style="width: 100%; height: 175px;" wrap="off">'; foreach( pb_backupbuddy::$options['backups'][$serial]['integrity'] as $item_name => $item_value ) { $item_value = str_replace( '<br />', '<br>', $item_value ); $item_value = str_replace( '<br><br>', '<br>', $item_value ); $item_value = str_replace( '<br>', "\n ", $item_value ); echo $item_name . ' => ' . $item_value . "\n"; } echo '</textarea><br><br><b>Note:</b> It is normal to see several "file not found" entries as BackupBuddy checks for expected files in multiple locations, expecting to only find each file once in one of those locations.<br><br>If you are encountering problems providing this information to support may assist in troubleshooting.'; */ pb_backupbuddy::$ui->ajax_footer(); die; }