当前位置: 首页>>代码示例>>PHP>>正文


PHP backupbuddy_core::normalize_comment_data方法代码示例

本文整理汇总了PHP中backupbuddy_core::normalize_comment_data方法的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core::normalize_comment_data方法的具体用法?PHP backupbuddy_core::normalize_comment_data怎么用?PHP backupbuddy_core::normalize_comment_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在backupbuddy_core的用法示例。


在下文中一共展示了backupbuddy_core::normalize_comment_data方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_archives_list

/**
 *	get_archives_list()
 *
 *	Returns an array of backup archive zip filenames found.
 *
 *	@return		array		Array of .zip filenames; path NOT included.
 */
function get_archives_list()
{
    Auth::require_authentication();
    if (!isset(pb_backupbuddy::$classes['zipbuddy'])) {
        require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
        pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(ABSPATH);
    }
    // List backup files in this directory.
    $backup_archives = array();
    $backup_archives_glob = glob(ABSPATH . 'backup*.zip');
    if (!is_array($backup_archives_glob) || empty($backup_archives_glob)) {
        // On failure glob() returns false or an empty array depending on server settings so normalize here.
        $backup_archives_glob = array();
    }
    foreach ($backup_archives_glob as $backup_archive) {
        $comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($backup_archive);
        $comment = backupbuddy_core::normalize_comment_data($comment);
        $this_archive = array('file' => basename($backup_archive), 'comment' => $comment);
        $backup_archives[] = $this_archive;
    }
    unset($backup_archives_glob);
    return $backup_archives;
}
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:30,代码来源:del-1.php

示例2: getZipMeta

 public static function getZipMeta($file)
 {
     if (!isset(pb_backupbuddy::$classes['zipbuddy'])) {
         require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
         pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
     }
     $comment_meta = array();
     if (isset($file)) {
         $comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($file);
         $comment = backupbuddy_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 (false !== ($response = backupbuddy_core::pretty_meta_info($comment_line_name, $comment_line_value))) {
                 $response[0] = '<span title="' . $comment_line_name . '">' . $response[0] . '</span>';
                 $comment_meta[$comment_line_name] = $response;
             }
         }
     }
     if (count($comment_meta) > 0) {
         return $comment_meta;
     } else {
         return false;
     }
 }
开发者ID:bunnywong,项目名称:freshlinker,代码行数:25,代码来源:core.php

示例3: backup_zip_files_alternate

 protected function backup_zip_files_alternate($state = array())
 {
     // Dependent on the zip build strategy chosen we will need to set various operational
     // parameters on the zipbuddy object to be used by the method building the zip. Eventually
     // we can use strategy objects but for now we'll do it the old-fashioned way.
     // Strategies are:
     // Single-Burst/Single-Step: Step Period = Infinite; Min/Max Burst Content Size = Infinite;
     // Multi-Burst/Single-Step: Step Period = Infinite; Min/Max Burst Content Size = Per-Config;
     // Multi-Burst/Multi-Step: Step Period = Per-Config; Min/Max Burst Content Size = Per-Config;
     $zip_build_strategy_name = array(self::ZIP_BUILD_STRATEGY_SBSS => 'Single-Burst/Single-Step', self::ZIP_BUILD_STRATEGY_MBSS => 'Multi-Burst/Single-Step', self::ZIP_BUILD_STRATEGY_MBMS => 'Multi-Burst/Multi-Step');
     // Get the current strategy
     if (isset(pb_backupbuddy::$options['zip_build_strategy'])) {
         $zip_build_strategy = pb_backupbuddy::$options['zip_build_strategy'];
         if (self::ZIP_BUILD_STRATEGY_MIN > $zip_build_strategy || self::ZIP_BUILD_STRATEGY_MAX < $zip_build_strategy) {
             // Hmm, not valid - have to revert to default
             $zip_build_strategy = self::ZIP_BUILD_STRATEGY_MBSS;
             pb_backupbuddy::status('details', 'Zip Build Strategy not recognized - reverting to: ' . $zip_build_strategy_name[$zip_build_strategy]);
         } else {
             pb_backupbuddy::status('details', 'Zip Build Strategy: ' . $zip_build_strategy_name[$zip_build_strategy]);
         }
     } else {
         // Hmm, should be set - have to revert to default
         $zip_build_strategy = self::ZIP_BUILD_STRATEGY_MBSS;
         pb_backupbuddy::status('details', 'Zip Build Strategy not set - reverting to: ' . $zip_build_strategy_name[$zip_build_strategy]);
     }
     // Now we haev to check if running in Classic mode. If yes then we cannot use multi-step without continually
     // resetting the "start" time for the zip monitor. The better approach is to override the zip build strategy
     // if it is a multi-step strategy and at least revert it to multi-burst/single-step. If it is already this
     // or single-burst/single-step we can leave it as it is
     // The backup mode details _should_ be available through this class variable created in pre_backup() function.
     if ($this->_backup['profile']['backup_mode'] == '1') {
         // Running in Classic mode...
         if (self::ZIP_BUILD_STRATEGY_MBSS < $zip_build_strategy) {
             $zip_build_strategy = self::ZIP_BUILD_STRATEGY_MBSS;
             pb_backupbuddy::status('details', 'Zip Build Strategy overridden as incompatible with Classic backup mode - reverting to: ' . $zip_build_strategy_name[$zip_build_strategy]);
         }
     }
     // Now based on the stratgy set build parameters that we will set on the zipbuddy object that
     // define the zip build behaviour
     switch ($zip_build_strategy) {
         case self::ZIP_BUILD_STRATEGY_SBSS:
             $step_period = PHP_INT_MAX;
             // Effectively infinite
             $burst_min_content = 4 == PHP_INT_SIZE ? (double) (pow(2, 63) - 1) : (double) PHP_INT_MAX;
             // Hack to get large value for either 32 or 64 bit PHP
             $burst_max_content = 4 == PHP_INT_SIZE ? (double) (pow(2, 63) - 1) : (double) PHP_INT_MAX;
             break;
         case self::ZIP_BUILD_STRATEGY_MBSS:
             $step_period = PHP_INT_MAX;
             $burst_min_content = null;
             $burst_max_content = null;
             break;
         case self::ZIP_BUILD_STRATEGY_MBMS:
             $step_period = null;
             // Force the option value to be used
             $burst_min_content = null;
             $burst_max_content = null;
             break;
     }
     // We can set the values on the zipbuddy object at this point
     pb_backupbuddy::$classes['zipbuddy']->set_step_period($step_period);
     pb_backupbuddy::$classes['zipbuddy']->set_min_burst_content($burst_min_content);
     pb_backupbuddy::$classes['zipbuddy']->set_max_burst_content($burst_max_content);
     if (empty($state)) {
         // This is our first (and perhaps only) call, so do first time stuff
         pb_backupbuddy::status('milestone', 'start_files');
         pb_backupbuddy::status('details', 'Backup root: `' . $this->_backup['backup_root'] . '`.');
         // Set compression on / off.
         //pb_backupbuddy::$classes['zipbuddy']->set_compression( $this->_backup['compression'] );
         // Currently we'll still allow skipping the addition of the meta data in the comment
         // but eventually this will become mandatory (in al likelihood)
         // Save meta information in comment.
         if ('0' == pb_backupbuddy::$options['save_comment_meta']) {
             pb_backupbuddy::status('details', 'Skipping saving meta data to zip comment based on settings.');
             $comment = '';
         } else {
             pb_backupbuddy::status('details', 'Saving meta data to zip comment.');
             // Calculate some statistics to store in meta later. These need to be calculated before zipping in case the DB goes away later to prevent a possible failure.
             $totalPosts = 0;
             foreach (wp_count_posts('post') as $type => $count) {
                 $totalPosts += $count;
             }
             $totalPages = 0;
             foreach (wp_count_posts('page') as $type => $count) {
                 $totalPages += $count;
             }
             $totalComments = 0;
             foreach (wp_count_comments() as $type => $count) {
                 $totalComments += $count;
             }
             $totalUsers = count_users();
             $totalUsers = $totalUsers['total_users'];
             global $wpdb;
             $db_prefix = $wpdb->prefix;
             global $wp_version;
             $meta = array('serial' => $this->_backup['serial'], 'siteurl' => site_url(), 'type' => $this->_backup['type'], 'profile' => $this->_backup['profile']['title'], 'created' => $this->_backup['start_time'], 'db_prefix' => $db_prefix, 'bb_version' => pb_backupbuddy::settings('version'), 'wp_version' => $wp_version, 'dat_path' => str_replace($this->_backup['backup_root'], '', $this->_backup['temp_directory'] . 'backupbuddy_dat.php'), 'posts' => $totalPosts, 'pages' => $totalPages, 'comments' => $totalComments, 'users' => $totalUsers, 'note' => '');
             $comment = backupbuddy_core::normalize_comment_data($meta);
         }
         // Always create the empty zip archive with the optional meta data comment added at this point.
         // This is method independent so is done just in zipbuddy.
//.........这里部分代码省略.........
开发者ID:jcwproductions,项目名称:jcwproductions-blog,代码行数:101,代码来源:backup.php

示例4: set_backup_note

 public function set_backup_note()
 {
     if (!isset(pb_backupbuddy::$classes['zipbuddy'])) {
         require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
         pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
     }
     $backup_file = backupbuddy_core::getBackupDirectory() . pb_backupbuddy::_POST('backup_file');
     $note = pb_backupbuddy::_POST('note');
     $note = preg_replace("/[[:space:]]+/", ' ', $note);
     $note = preg_replace("/[^[:print:]]/", '', $note);
     $note = substr($note, 0, 200);
     // Returns true on success, else the error message.
     $old_comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($backup_file);
     $comment = backupbuddy_core::normalize_comment_data($old_comment);
     $comment['note'] = $note;
     //$new_comment = base64_encode( serialize( $comment ) );
     $comment_result = pb_backupbuddy::$classes['zipbuddy']->set_comment($backup_file, $comment);
     if ($comment_result !== true) {
         echo $comment_result;
     } else {
         echo '1';
     }
     // Even if we cannot save the note into the archive file, store it in internal settings.
     $serial = backupbuddy_core::get_serial_from_file($backup_file);
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     $backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt');
     if (true === ($result = $backup_options->is_ok())) {
         $backup_options->options['integrity']['comment'] = $note;
         $backup_options->save();
     }
     die;
 }
开发者ID:serker72,项目名称:T3S,代码行数:32,代码来源:ajax.php

示例5: pluginbuddy_zipbuddy

$backup_type = '';
if (!isset(pb_backupbuddy::$classes['zipbuddy'])) {
    require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
    pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
}
$previous_status_serial = pb_backupbuddy::get_status_serial();
// Store current status serial setting to reset back later.
if (true !== $skipLogRedirect) {
    pb_backupbuddy::status('details', 'Redirecting status logging temporarily.');
    pb_backupbuddy::set_status_serial('zipbuddy_test');
    // Redirect logging output to a certain log file.
}
// Look for comment.
pb_backupbuddy::status('details', 'Verifying comment in zip archive.');
$raw_comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($file);
$comment = backupbuddy_core::normalize_comment_data($raw_comment);
$comment = $comment['note'];
$tests = array();
pb_backupbuddy::status('details', 'NOTE: It is normal to see several "File not found" messages in the next several log lines.');
// Check for DAT file.
$pass = false;
pb_backupbuddy::status('details', 'Verifying DAT file in zip archive.');
if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/backupbuddy_dat.php') === true) {
    // Post 2.0 full backup
    $backup_type = 'full';
    $pass = true;
}
if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/temp_' . $serial . '/backupbuddy_dat.php') === true) {
    // Pre 2.0 full backup
    $backup_type = 'full';
    $pass = true;
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:31,代码来源:_integrityCheck.php

示例6: backup_zip_files

 function backup_zip_files()
 {
     pb_backupbuddy::status('action', 'start_files');
     pb_backupbuddy::status('details', 'Backup root: `' . $this->_backup['backup_root'] . '`.');
     // Set compression on / off.
     //pb_backupbuddy::$classes['zipbuddy']->set_compression( $this->_backup['compression'] );
     // Create zip file!
     $zip_response = pb_backupbuddy::$classes['zipbuddy']->add_directory_to_zip($this->_backup['archive_file'], $this->_backup['backup_root'], $this->_backup['directory_exclusions'], $this->_backup['temporary_zip_directory']);
     // Zip results.
     if ($zip_response === true) {
         // Zip success.
         pb_backupbuddy::status('message', __('Backup ZIP file successfully created.', 'it-l10n-backupbuddy'));
         if (chmod($this->_backup['archive_file'], 0644)) {
             pb_backupbuddy::status('details', __('Chmod of ZIP file to 0644 succeeded.', 'it-l10n-backupbuddy'));
         } else {
             pb_backupbuddy::status('details', __('Chmod of ZIP file to 0644 failed.', 'it-l10n-backupbuddy'));
         }
         // Save meta information in comment.
         if ('0' == pb_backupbuddy::$options['save_comment_meta']) {
             pb_backupbuddy::status('details', 'Skipping saving meta data to zip comment based on settings.');
         } else {
             pb_backupbuddy::status('details', 'Saving meta data to zip comment.');
             $totalPosts = 0;
             foreach (wp_count_posts('post') as $type => $count) {
                 $totalPosts += $count;
             }
             $totalPages = 0;
             foreach (wp_count_posts('page') as $type => $count) {
                 $totalPages += $count;
             }
             $totalComments = 0;
             foreach (wp_count_comments() as $type => $count) {
                 $totalComments += $count;
             }
             $totalUsers = count_users();
             $totalUsers = $totalUsers['total_users'];
             global $wp_version;
             global $wpdb;
             $meta = array('serial' => $this->_backup['serial'], 'siteurl' => site_url(), 'type' => $this->_backup['type'], 'profile' => $this->_backup['profile']['title'], 'created' => $this->_backup['start_time'], 'db_prefix' => $wpdb->prefix, 'bb_version' => pb_backupbuddy::settings('version'), 'wp_version' => $wp_version, 'dat_path' => str_replace($this->_backup['backup_root'], '', $this->_backup['temp_directory'] . 'backupbuddy_dat.php'), 'posts' => $totalPosts, 'pages' => $totalPages, 'comments' => $totalComments, 'users' => $totalUsers, 'note' => '');
             $comment = backupbuddy_core::normalize_comment_data($meta);
             $comment_result = pb_backupbuddy::$classes['zipbuddy']->set_comment($this->_backup['archive_file'], $comment);
             if ($comment_result !== true) {
                 pb_backupbuddy::status('warning', 'Unable to save meta data to zip comment. This is not a fatal warning & will not impact the backup itself.');
             } else {
                 pb_backupbuddy::status('details', 'Saved meta data to zip comment.');
             }
         }
     } else {
         // Zip failure.
         // Delete temporary data directory.
         if (file_exists($this->_backup['temp_directory'])) {
             pb_backupbuddy::status('details', __('Removing temp data directory.', 'it-l10n-backupbuddy'));
             pb_backupbuddy::$filesystem->unlink_recursive($this->_backup['temp_directory']);
         }
         // Delete temporary ZIP directory.
         if (file_exists($this->_backup['temporary_zip_directory'])) {
             pb_backupbuddy::status('details', __('Removing temp zip directory.', 'it-l10n-backupbuddy'));
             pb_backupbuddy::$filesystem->unlink_recursive($this->_backup['temporary_zip_directory']);
         }
         pb_backupbuddy::status('error', __('Error #3382: Backup FAILED. Unable to successfully generate ZIP archive.', 'it-l10n-backupbuddy'));
         pb_backupbuddy::status('error', __('Error #3382 help: http://ithemes.com/codex/page/BackupBuddy:_Error_Codes#3382', 'it-l10n-backupbuddy'));
         pb_backupbuddy::status('action', 'halt_script');
         // Halt JS on page.
         return false;
     }
     // end zip failure.
     // Need to make sure the database connection is active. Sometimes it goes away during long bouts doing other things -- sigh.
     // This is not essential so use include and not require (suppress any warning)
     pb_backupbuddy::status('details', 'Loading DB kicker in case database has gone away.');
     @(include_once pb_backupbuddy::plugin_path() . '/lib/wpdbutils/wpdbutils.php');
     if (class_exists('pluginbuddy_wpdbutils')) {
         // This is the database object we want to use
         global $wpdb;
         // Get our helper object and let it use us to output status messages
         $dbhelper = new pluginbuddy_wpdbutils($wpdb);
         // If we cannot kick the database into life then signal the error and return false which will stop the backup
         // Otherwise all is ok and we can just fall through and let the function return true
         if (!$dbhelper->kick()) {
             pb_backupbuddy::status('error', __('Backup FAILED. Backup file produced but Database Server has gone away, unable to schedule next backup step', 'it-l10n-backupbuddy'));
             return false;
         } else {
             pb_backupbuddy::status('details', 'Database seems to still be connected.');
         }
     } else {
         // Utils not available so cannot verify database connection status - just notify
         pb_backupbuddy::status('details', __('Database Server connection status unverified.', 'it-l10n-backupbuddy'));
     }
     return true;
 }
开发者ID:serker72,项目名称:T3S,代码行数:89,代码来源:backup.php

示例7: integrity_status


//.........这里部分代码省略.........
                 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', '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.
     //***** 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(backupbuddy_core::getBackupDirectory());
     }
     $comment_meta = array();
     if (isset($backup_options->options['archive_file'])) {
         $comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($backup_options->options['archive_file']);
         $comment = backupbuddy_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 (false !== ($response = backupbuddy_core::pretty_meta_info($comment_line_name, $comment_line_value))) {
                 $comment_meta[] = $response;
             }
         }
     }
     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($backup_options->options['trigger'])) {
         $trigger = $backup_options->options['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><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;
 }
开发者ID:netfor,项目名称:nextrading,代码行数:101,代码来源:ajax.php

示例8: extract_files

/**
 *	extract()
 *
 *	Extract backup zip file.
 *
 *	@return		array		True if the extraction was a success OR skipping of extraction is set.
 */
function extract_files()
{
    // Zip & Unzip library setup.
    require_once ABSPATH . 'importbuddy/lib/zipbuddy/zipbuddy.php';
    pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(ABSPATH, array(), 'unzip');
    $backup_archive = ABSPATH . pb_backupbuddy::$options['file'];
    if (true === pb_backupbuddy::$options['skip_files']) {
        // Option to skip all file updating / extracting.
        pb_backupbuddy::status('message', 'Skipped extracting files based on debugging options.');
    } else {
        pb_backupbuddy::set_greedy_script_limits();
        pb_backupbuddy::status('message', 'Unzipping into `' . ABSPATH . '`');
        $destination_directory = ABSPATH;
        // Set compatibility mode if defined in advanced options.
        $compatibility_mode = false;
        // Default to no compatibility mode.
        if (pb_backupbuddy::$options['force_compatibility_medium'] != false) {
            $compatibility_mode = 'ziparchive';
        } elseif (pb_backupbuddy::$options['force_compatibility_slow'] != false) {
            $compatibility_mode = 'pclzip';
        }
        // Extract zip file & verify it worked.
        if (true !== ($result = pb_backupbuddy::$classes['zipbuddy']->unzip($backup_archive, $destination_directory, $compatibility_mode))) {
            pb_backupbuddy::status('error', 'Failed unzipping archive.');
            pb_backupbuddy::alert('Failed unzipping archive.', true);
            return false;
        }
        pb_backupbuddy::status('details', 'Success extracting Zip File "' . ABSPATH . pb_backupbuddy::$options['file'] . '" into "' . ABSPATH . '".');
    }
    // End extraction not skipped.
    // Made it here so zip returned true OR skipped unzip step.
    // Handle meta data in comment.
    pb_backupbuddy::status('details', 'Retrieving meta data from ZIP file (if any).');
    $comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($backup_archive);
    $comment = backupbuddy_core::normalize_comment_data($comment);
    $comment_text = print_r($comment, true);
    $comment_text = str_replace(array("\n", "\r"), '; ', $comment_text);
    pb_backupbuddy::status('details', 'Backup meta data: `' . $comment_text . '`.');
    // Use meta to find DAT file (if possible). BB v3.3+.
    $dat_file = '';
    if ('' != $comment['dat_path']) {
        // Specific DAT location is known.
        pb_backupbuddy::status('details', 'Checking for DAT file as reported by meta data as file `' . ABSPATH . $comment['dat_path'] . '`.');
        if (file_exists(ABSPATH . $comment['dat_path'])) {
            $dat_file = ABSPATH . $comment['dat_path'];
            pb_backupbuddy::status('details', 'DAT file found based on meta path.');
        } else {
            pb_backupbuddy::status('warning', 'DAT file was not found as reported by meta data. This is unusual but may not be fatal. Commencing search for file...');
        }
    }
    // Deduce DAT file location based on backup filename. BB < v3.3.
    if ('' == $dat_file) {
        pb_backupbuddy::status('details', 'Scanning for DAT file based on backup file name.');
        $dat_file_locations = array(ABSPATH . 'wp-content/uploads/temp_' . pb_backupbuddy::$options['zip_id'] . '/backupbuddy_dat.php', ABSPATH . 'wp-content/uploads/backupbuddy_temp/' . pb_backupbuddy::$options['zip_id'] . '/backupbuddy_dat.php', ABSPATH . 'backupbuddy_dat.php');
        $dat_file = '';
        foreach ($dat_file_locations as $dat_file_location) {
            if (file_exists($dat_file_location)) {
                $dat_file = $dat_file_location;
                break;
            }
        }
        if ('' == $dat_file) {
            // DAT not found.
            $error_message = 'Error #9004: Key files missing. Backup data file, backupbuddy_dat.php was not found in the extracted files in any expected location. The unzip process either failed to fully complete, you renamed the backup ZIP file (rename it back to correct this), or the zip file is not a proper BackupBuddy backup.';
            pb_backupbuddy::status('error', $error_message);
            pb_backupbuddy::alert($error_message, true, '9004');
            return false;
        }
        pb_backupbuddy::status('details', 'Successfully found DAT file based on backup file name: `' . $dat_file . '`.');
    }
    // Get DAT file contents & save into options..
    pb_backupbuddy::$options['dat_file'] = pb_backupbuddy::$classes['import']->get_dat_file_array($dat_file);
    pb_backupbuddy::$options['temp_serial_directory'] = basename($dat_file);
    pb_backupbuddy::save();
    return true;
}
开发者ID:netfor,项目名称:nextrading,代码行数:83,代码来源:2.php

示例9: backup_integrity_check

 public static function backup_integrity_check($file, $fileoptions = '', $options = array(), $skipLogRedirect = false)
 {
     pb_backupbuddy::status('details', 'Started backup_integrity_check() function.');
     $serial = self::get_serial_from_file($file);
     // User selected to rescan a file.
     if (pb_backupbuddy::_GET('reset_integrity') == $serial) {
         pb_backupbuddy::alert('Rescanning backup integrity for backup file `' . basename($file) . '`');
         pb_backupbuddy::flush();
     }
     $options = array_merge(array('skip_database_dump' => '0'), $options);
     $scan_notes = array();
     // Get backup fileoptions.
     if ($fileoptions != '') {
         $backup_options =& $fileoptions;
     } else {
         require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
         $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.
         if (true !== ($result = $backup_options->is_ok())) {
             pb_backupbuddy::status('error', __('Fatal Error #9034 C. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error on file `' . backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' . '`: ' . $result);
             pb_backupbuddy::status('action', 'halt_script');
             // Halt JS on page.
             return false;
         }
     }
     if (isset($backup_options->options['profile'])) {
         $options = $backup_options->options['profile'];
         $options = array_merge(pb_backupbuddy::settings('profile_defaults'), $options);
     }
     // Return if cached.
     if (isset($backup_options->options['integrity']) && count($backup_options->options['integrity']) > 0 && pb_backupbuddy::_GET('reset_integrity') != $serial) {
         // Already have integrity data and NOT resetting this one.
         pb_backupbuddy::status('details', 'Integrity data for backup `' . $serial . '` is cached; not scanning again.');
         return $backup_options->options['integrity'];
     } elseif (pb_backupbuddy::_GET('reset_integrity') == $serial) {
         // Resetting this one.
         pb_backupbuddy::status('details', 'Resetting backup integrity stats for backup with serial `' . $serial . '`.');
     } else {
         // No integrity data; not resetting. Just keep going...
     }
     // Integrity check disabled. Skip.
     if (($options['integrity_check'] == '0' || pb_backupbuddy::$options['profiles'][0]['integrity_check'] == '0') && pb_backupbuddy::_GET('reset_integrity') == '') {
         // Integrity checking disabled. Allows run if manually rescanning on backups page.
         pb_backupbuddy::status('details', 'Integrity check disabled. Skipping scan.');
         $file_stats = @stat($file);
         if ($file_stats === false) {
             // stat failure.
             pb_backupbuddy::status('error', 'Error #4539774. Unable to get file details ( via stat() ) for file `' . $file . '`. The file may be corrupt or too large for the server.');
             $file_size = 0;
             $file_modified = 0;
         } else {
             // stat success.
             $file_size = $file_stats['size'];
             $file_modified = $file_stats['mtime'];
         }
         unset($file_stats);
         $integrity = array('status' => 'Unknown', 'tests' => array(), 'scan_time' => 0, 'detected_type' => 'unknown', 'size' => $file_size, 'modified' => $file_modified, 'file' => basename($file), 'comment' => false);
         $backup_options->options['integrity'] = array_merge(pb_backupbuddy::settings('backups_integrity_defaults'), $integrity);
         $backup_options->save();
         return $backup_options->options['integrity'];
     }
     //***** BEGIN CALCULATING STATUS DETAILS.
     $backup_type = '';
     if (!isset(pb_backupbuddy::$classes['zipbuddy'])) {
         require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
         pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(backupbuddy_core::getBackupDirectory());
     }
     $previous_status_serial = pb_backupbuddy::get_status_serial();
     // Store current status serial setting to reset back later.
     if (true !== $skipLogRedirect) {
         pb_backupbuddy::status('details', 'Redirecting status logging temporarily.');
         pb_backupbuddy::set_status_serial('zipbuddy_test');
         // Redirect logging output to a certain log file.
     }
     // Look for comment.
     pb_backupbuddy::status('details', 'Verifying comment in zip archive.');
     $raw_comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($file);
     $comment = backupbuddy_core::normalize_comment_data($raw_comment);
     $comment = $comment['note'];
     $tests = array();
     pb_backupbuddy::status('details', 'NOTE: It is normal to see several "File not found" messages in the next several log lines.');
     // Check for DAT file.
     $pass = false;
     pb_backupbuddy::status('details', 'Verifying DAT file in zip archive.');
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/backupbuddy_temp/' . $serial . '/backupbuddy_dat.php') === true) {
         // Post 2.0 full backup
         $backup_type = 'full';
         $pass = true;
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'wp-content/uploads/temp_' . $serial . '/backupbuddy_dat.php') === true) {
         // Pre 2.0 full backup
         $backup_type = 'full';
         $pass = true;
     }
     if (pb_backupbuddy::$classes['zipbuddy']->file_exists($file, 'backupbuddy_dat.php') === true) {
         // DB backup
         $backup_type = 'db';
         $pass = true;
     }
     $tests[] = array('test' => 'BackupBuddy data file', 'pass' => $pass);
//.........这里部分代码省略.........
开发者ID:netfor,项目名称:nextrading,代码行数:101,代码来源:core.php


注:本文中的backupbuddy_core::normalize_comment_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。