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


PHP pb_backupbuddy_fileoptions::save方法代码示例

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


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

示例1: foreach

    pb_backupbuddy::$options['data_version'] = '4';
    // Update data structure version to 4.
    pb_backupbuddy::$options['role_access'] = 'activate_plugins';
    // Change default role from `administrator` to `activate_plugins` capability.
    pb_backupbuddy::save();
}
// ********** END 3.1.8.2 -> 3.1.8.3 DATA MIGRATION **********
// ********** BEGIN 3.3.0 -> 3.3.0.1 BACKUP DATASTRUCTURE OPTIONS to FILEOPTIONS MIGRATION **********
if (pb_backupbuddy::$options['data_version'] < 5) {
    if (isset(pb_backupbuddy::$options['backups']) && count(pb_backupbuddy::$options['backups']) > 0) {
        pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getLogDirectory() . 'fileoptions/');
        require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
        foreach (pb_backupbuddy::$options['backups'] as $serial => $backup) {
            $backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = false, $ignore_lock = false, $create_file = true);
            $backup_options->options = $backup;
            if (true === $backup_options->save()) {
                unset(pb_backupbuddy::$options['backups'][$serial]);
            }
            unset($backup_options);
        }
    }
    pb_backupbuddy::$options['data_version'] = '5';
    pb_backupbuddy::save();
}
// ********** END 3.3.0 -> 3.3.0.1 BACKUP DATASTRUCTURE OPTIONS to FILEOPTIONS MIGRATION **********
// ********** BEGIN 4.0 UPGRADE **********
if (pb_backupbuddy::$options['data_version'] < 6) {
    // Migrate profile-specific settings into 'Defaults' key profile.
    pb_backupbuddy::$options['profiles'][0]['skip_database_dump'] = pb_backupbuddy::$options['skip_database_dump'];
    unset(pb_backupbuddy::$options['skip_database_dump']);
    pb_backupbuddy::$options['profiles'][0]['backup_nonwp_tables'] = pb_backupbuddy::$options['backup_nonwp_tables'];
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:31,代码来源:activation.php

示例2: test

 public static function test($settings)
 {
     $settings = self::_init($settings);
     $sendOK = false;
     $deleteOK = false;
     $send_id = 'TEST-' . pb_backupbuddy::random_string(12);
     // Try sending a file.
     if ('1' == $settings['stash_mode']) {
         // Stash mode.
         $settings['type'] = 'stash2';
     }
     $send_response = pb_backupbuddy_destinations::send($settings, dirname(dirname(__FILE__)) . '/remote-send-test.php', $send_id);
     // 3rd param true forces clearing of any current uploads.
     if (true === $send_response) {
         $send_response = __('Success.', 'it-l10n-backupbuddy');
         $sendOK = true;
     } else {
         global $pb_backupbuddy_destination_errors;
         $send_response = 'Error sending test file to S3 (v2). Details: `' . implode(', ', $pb_backupbuddy_destination_errors) . '`.';
     }
     pb_backupbuddy::add_status_serial('remote_send-' . $send_id);
     // Delete sent file if it was sent.
     $delete_response = 'n/a';
     if (true === $sendOK) {
         pb_backupbuddy::status('details', 'Preparing to delete sent test file.');
         if ('1' == $settings['stash_mode']) {
             // Stash mode.
             if (true === ($delete_response = pb_backupbuddy_destination_stash2::deleteFile($settings, 'remote-send-test.php'))) {
                 // success
                 $delete_response = __('Success.', 'it-l10n-backupbuddy');
                 $deleteOK = true;
             } else {
                 // error
                 $error = 'Unable to delete Stash test file `remote-send-test.php`. Details: `' . $delete_response . '`.';
                 $delete_response = $error;
                 $deleteOK = false;
             }
         } else {
             // S3 mode.
             if (true === ($delete_response = self::deleteFile($settings, 'remote-send-test.php'))) {
                 $delete_response = __('Success.', 'it-l10n-backupbuddy');
                 $deleteOK = true;
             } else {
                 $error = 'Unable to delete test file `remote-send-test.php`. Details: `' . $delete_response . '`.';
                 pb_backupbuddy::status('details', $error);
                 $delete_response = $error;
                 $deleteOK = false;
             }
         }
     } else {
         // end if $sendOK.
         pb_backupbuddy::status('details', 'Skipping test delete due to failed send.');
     }
     // Load destination fileoptions.
     pb_backupbuddy::status('details', 'About to load fileoptions data.');
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     pb_backupbuddy::status('details', 'Fileoptions instance #7.');
     $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
     if (true !== ($result = $fileoptions_obj->is_ok())) {
         return self::_error(__('Fatal Error #9034.84838. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
     }
     pb_backupbuddy::status('details', 'Fileoptions data loaded.');
     $fileoptions =& $fileoptions_obj->options;
     if (true !== $sendOK || true !== $deleteOK) {
         $fileoptions['status'] = 'failure';
         $fileoptions_obj->save();
         unset($fileoptions_obj);
         return 'Send details: `' . $send_response . '`. Delete details: `' . $delete_response . '`.';
     } else {
         $fileoptions['status'] = 'success';
         $fileoptions['finish_time'] = time();
     }
     $fileoptions_obj->save();
     unset($fileoptions_obj);
     pb_backupbuddy::status('details', 'Finished test function.');
     return true;
 }
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:77,代码来源:init.php

示例3: send


//.........这里部分代码省略.........
         // First chunk was sent initiationg multipart send.
         $chunked_destination_settings['_chunk_transfer_speeds'][] = $chunk_transfer_speed;
         // Load destination fileoptions.
         pb_backupbuddy::status('details', 'About to load fileoptions data.');
         require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
         pb_backupbuddy::status('details', 'Fileoptions instance #15.');
         $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
         if (true !== ($result = $fileoptions_obj->is_ok())) {
             pb_backupbuddy::status('error', __('Fatal Error #9034.84838. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
             return false;
         }
         pb_backupbuddy::status('details', 'Fileoptions data loaded.');
         $fileoptions =& $fileoptions_obj->options;
         // Multipart send completed. Send finished signal to Dropbox to seal the deal.
         if (true === feof($f)) {
             pb_backupbuddy::status('details', 'At end of file. Finishing transfer and notifying Dropbox of file transfer completion.');
             $chunked_destination_settings['_chunk_upload_id'] = '';
             // Unset since chunking finished.
             try {
                 $result = self::$_dbxClient->chunkedUploadFinish($settings['_chunk_upload_id'], $settings['directory'] . '/' . basename($file), dbx\WriteMode::add());
             } catch (\Exception $e) {
                 pb_backupbuddy::status('error', 'Dropbox Error #549838979: ' . $e->getMessage());
                 return false;
             }
             pb_backupbuddy::status('details', 'Chunked upload finish results: `' . print_r($result, true) . '`.');
             if (filesize($settings['_chunk_file']) != $result['bytes']) {
                 pb_backupbuddy::status('error', 'Error #8958944. Dropbox reported file size differs from local size. The file upload may have been corrupted.');
                 return false;
             }
             $fileoptions['write_speed'] = array_sum($chunked_destination_settings['_chunk_transfer_speeds']) / $chunked_destination_settings['_chunk_sent_count'];
             $fileoptions['_multipart_status'] = 'Sent part ' . $chunked_destination_settings['_chunk_sent_count'] . ' of ' . $chunked_destination_settings['_chunk_total_count'] . '.';
             $fileoptions['finish_time'] = time();
             $fileoptions['status'] = 'success';
             $fileoptions_obj->save();
             unset($fileoptions_obj);
         }
         fclose($f);
         pb_backupbuddy::status('details', 'Sent chunk number `' . $chunked_destination_settings['_chunk_sent_count'] . '` to Dropbox with upload ID: `' . $chunked_destination_settings['_chunk_upload_id'] . '`. Next offset: `' . $chunked_destination_settings['_chunk_next_offset'] . '`.');
         // Schedule to continue if anything is left to upload for this multipart of any individual files.
         if ($chunked_destination_settings['_chunk_upload_id'] != '' || count($files) > 0) {
             pb_backupbuddy::status('details', 'Dropbox multipart upload has more parts left. Scheduling next part send.');
             $cronTime = time();
             $cronArgs = array($chunked_destination_settings, $files, $send_id, $delete_after);
             $cronHashID = md5($cronTime . serialize($cronArgs));
             $cronArgs[] = $cronHashID;
             $schedule_result = backupbuddy_core::schedule_single_event($cronTime, pb_backupbuddy::cron_tag('destination_send'), $cronArgs);
             if (true === $schedule_result) {
                 pb_backupbuddy::status('details', 'Next Dropbox chunk step cron event scheduled.');
             } else {
                 pb_backupbuddy::status('error', 'Next Dropbox chunk step cron even FAILED to be scheduled.');
             }
             spawn_cron(time() + 150);
             // Adds > 60 seconds to get around once per minute cron running limit.
             update_option('_transient_doing_cron', 0);
             // Prevent cron-blocking for next item.
             return array($chunked_destination_settings['_chunk_upload_id'], 'Sent ' . $chunked_destination_settings['_chunk_sent_count'] . ' of ' . $chunked_destination_settings['_chunk_total_count'] . ' parts.');
         }
     }
     // end continue multipart chunked upload.
     /***** END MULTIPART CHUNKED CONTINUE *****/
     pb_backupbuddy::status('details', 'Looping through files to send to Dropbox.');
     foreach ($files as $file_id => $file) {
         $file_size = filesize($file);
         pb_backupbuddy::status('details', 'Opening file `' . basename($file) . '` to send.');
         $f = @fopen($file, 'rb');
         if (false === $f) {
开发者ID:russtx,项目名称:tac,代码行数:67,代码来源:init.php

示例4: filemtime

                     $timeoutMessage = 'The remote transfer step appears to have timed out. Try turning on chunking in the destination settings to break up the file transfer into multiple steps. ' . $sendCheckSpot;
                 } else {
                     $timeoutMessage = 'The step function `' . $timeoutStep . '` appears to have timed out. ' . $backupCheckSpot;
                 }
             }
             $error_message = 'Scheduled BackupBuddy backup `' . $backup_options->options['archive_file'] . '` started `' . pb_backupbuddy::$format->time_ago($backup_options->options['start_time']) . '` ago likely timed out. ' . $timeoutMessage;
             pb_backupbuddy::status('error', $error_message);
             if ($secondsAgo < backupbuddy_constants::CLEANUP_MAX_AGE_TO_NOTIFY_TIMEOUT) {
                 // Prevents very old timed out backups from triggering email send.
                 backupbuddy_core::mail_error($error_message);
             }
         }
         // end scheduled.
         $backup_options->options['finish_time'] = FALSE;
         // Consider officially timed out.  If scheduled backup then an error notification will have been sent.
         $backup_options->save();
     }
 }
 // Remove fileoptions files which do not have a corresponding local backup. NOTE: This only handles fileoptions files containing the 'archive_file' key in their array. Handle those without this elsewhere.
 // Cached integrity scans performed when there was not an existing fileoptions file will be missing the archive_file key.
 $backupDir = backupbuddy_core::getBackupDirectory();
 if (!file_exists($backup_options->options['archive_file']) && !file_exists($backupDir . basename($backup_options->options['archive_file']))) {
     // No corresponding backup ZIP file.
     $modified = filemtime($file);
     if (time() - $modified > backupbuddy_constants::MAX_SECONDS_TO_KEEP_ORPHANED_FILEOPTIONS_FILES) {
         // Too many days old so delete.
         if (false === unlink($file)) {
             pb_backupbuddy::status('error', 'Unable to delete orphaned fileoptions file `' . $file . '`.');
         }
         if (file_exists($file . '.lock')) {
             @unlink($file . '.lock');
开发者ID:Offirmo,项目名称:base-wordpress,代码行数:31,代码来源:_periodicCleanup.php

示例5: send

 public static function send($destination_settings, $files, $send_id = '')
 {
     if ('' != $send_id) {
         pb_backupbuddy::add_status_serial('remote_send-' . $send_id);
         pb_backupbuddy::status('details', '----- Initiating master send function.');
         require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
         $fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt';
         if (!file_exists($fileoptions_file)) {
             pb_backupbuddy::status('details', 'Fileoptions file `' . $fileoptions_file . '` does not exist yet; creating.');
             $fileoptions_obj = new pb_backupbuddy_fileoptions($fileoptions_file, $read_only = false, $ignore_lock = true, $create_file = true);
         } else {
             pb_backupbuddy::status('details', 'Fileoptions file exists; loading.');
             $fileoptions_obj = new pb_backupbuddy_fileoptions($fileoptions_file, $read_only = false, $ignore_lock = false, $create_file = false);
         }
         if (true !== ($result = $fileoptions_obj->is_ok())) {
             pb_backupbuddy::status('error', __('Fatal Error #9034.2344848. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
             return false;
         }
         pb_backupbuddy::status('details', 'Fileoptions data loaded.');
         $fileoptions =& $fileoptions_obj->options;
         if ('' == $fileoptions) {
             $fileoptions = backupbuddy_core::get_remote_send_defaults();
             $fileoptions['type'] = $destination_settings['type'];
             if (!is_array($files)) {
                 $fileoptions['file'] = $files;
             } else {
                 $fileoptions['file'] = $files[0];
             }
             $fileoptions_obj->save();
         }
         if (isset($fileoptions['status']) && 'aborted' == $fileoptions['status']) {
             pb_backupbuddy::status('warning', 'Destination send triggered on an ABORTED transfer. Ending send function.');
             return false;
         }
         unset($fileoptions_obj);
     }
     if (false === ($destination = self::_init_destination($destination_settings))) {
         echo '{Error #546893498a. Destination configuration file missing.}';
         if ('' != $send_id) {
             pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
         }
         return false;
     }
     $destination_settings = $destination['settings'];
     // Settings with defaults applied, normalized, etc.
     //$destination_info = $destination['info'];
     if (!is_array($files)) {
         $files = array($files);
     }
     $files_with_sizes = '';
     foreach ($files as $index => $file) {
         if ('' == $file) {
             unset($files[$index]);
             continue;
             // Not actually a file to send.
         }
         if (!file_exists($file)) {
             pb_backupbuddy::status('error', 'Error #58459458743. The file that was attempted to be sent to a remote destination, `' . $file . '`, was not found. It either does not exist or permissions prevent accessing it.');
             if ('' != $send_id) {
                 pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
             }
             return false;
         }
         $files_with_sizes .= $file . ' (' . pb_backupbuddy::$format->file_size(filesize($file)) . '); ';
     }
     pb_backupbuddy::status('details', 'Sending files `' . $files_with_sizes . '` to destination type `' . $destination_settings['type'] . '` titled `' . $destination_settings['title'] . '`.');
     unset($files_with_sizes);
     if (!method_exists($destination['class'], 'send')) {
         pb_backupbuddy::status('error', 'Destination class `' . $destination['class'] . '` does not support send operation -- missing function.');
         if ('' != $send_id) {
             pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
         }
         return false;
     }
     pb_backupbuddy::status('details', 'Calling send function.');
     //$result = $destination_class::send( $destination_settings, $files );
     global $pb_backupbuddy_destination_errors;
     $pb_backupbuddy_destination_errors = array();
     $result = call_user_func_array("{$destination['class']}::send", array($destination_settings, $files, $send_id));
     if ($result === false) {
         $error_details = implode('; ', $pb_backupbuddy_destination_errors);
         backupbuddy_core::mail_error('There was an error sending to the remote destination. One or more files may have not been fully transferred. Please see error details for additional information. If the error persists, enable full error logging and try again for full details and troubleshooting. Details: ' . "\n\n" . $error_details);
     }
     if (is_array($result)) {
         // Send is multipart.
         pb_backupbuddy::status('details', 'Completed send function. Multipart chunk mode. Result: `' . print_r($result, true) . '`.');
         if ('' != $send_id) {
             pb_backupbuddy::status('details', 'About to load fileoptions data.');
             require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
             $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
             if (true !== ($fileoptions_result = $fileoptions_obj->is_ok())) {
                 pb_backupbuddy::status('error', __('Fatal Error #9034.387462. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $fileoptions_result);
                 return false;
             }
             pb_backupbuddy::status('details', 'Fileoptions data loaded.');
             $fileoptions =& $fileoptions_obj->options;
             $fileoptions['_multipart_status'] = $result[1];
             pb_backupbuddy::status('details', 'Destination debugging details: `' . print_r($fileoptions, true) . '`.');
             $fileoptions_obj->save();
             unset($fileoptions_obj);
//.........这里部分代码省略.........
开发者ID:FelixNong1990,项目名称:andy,代码行数:101,代码来源:bootstrap.php

示例6:

<?php

backupbuddy_core::verifyAjaxAccess();
// Abort an in-process remote destination send.
/* remotesend_abort()
 *
 * Abort an in-progress demote destination file transfer. Dies with outputting "1" on success.
 *
 */
$send_id = pb_backupbuddy::_GET('send_id');
$send_id = str_replace('/\\', '', $send_id);
pb_backupbuddy::status('details', 'About to load fileoptions data.');
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
pb_backupbuddy::status('details', 'Fileoptions instance #25.');
$fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = true, $create_file = false);
if (true !== ($result = $fileoptions_obj->is_ok())) {
    pb_backupbuddy::status('error', __('Fatal Error #9034.324544. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
    return false;
}
pb_backupbuddy::status('details', 'Fileoptions data loaded.');
$fileoptions =& $fileoptions_obj->options;
$fileoptions['status'] = 'aborted';
$fileoptions_obj->save();
die('1');
开发者ID:Coop920,项目名称:Sterling-Wellness,代码行数:24,代码来源:remotesend_abort.php

示例7: send


//.........这里部分代码省略.........
         pb_backupbuddy::status('details', 'sFTP log (if available & enabled via full logging mode): `' . $sftp->getSFTPLog() . '`.');
         return false;
     }
     // Upload files.
     $total_transfer_size = 0;
     $total_transfer_time = 0;
     foreach ($files as $file) {
         if (!file_exists($file)) {
             pb_backupbuddy::status('error', 'Error #859485495. Could not upload local file `' . $file . '` to send to sFTP as it does not exist. Verify the file exists, permissions of file, parent directory, and that ownership is correct. You may need suphp installed on the server.');
         }
         if (!is_readable($file)) {
             pb_backupbuddy::status('error', 'Error #8594846548. Could not read local file `' . $file . '` to send to sFTP as it is not readable. Verify permissions of file, parent directory, and that ownership is correct. You may need suphp installed on the server.');
         }
         $filesize = filesize($file);
         $total_transfer_size += $filesize;
         $destination_file = basename($file);
         pb_backupbuddy::status('details', 'About to put to sFTP local file `' . $file . '` of size `' . pb_backupbuddy::$format->file_size($filesize) . '` to remote file `' . $destination_file . '`.');
         $send_time = -microtime(true);
         $upload = $sftp->put($destination_file, $file, NET_SFTP_LOCAL_FILE);
         $send_time += microtime(true);
         $total_transfer_time += $send_time;
         if ($upload === false) {
             // Failed sending.
             $error_message = 'ERROR #9012b ( http://ithemes.com/codex/page/BackupBuddy:_Error_Codes#9012 ).  sFTP file upload failed. Check file permissions & disk quota.';
             pb_backupbuddy::status('error', $error_message);
             backupbuddy_core::mail_error($error_message);
             pb_backupbuddy::status('details', 'sFTP log (if available & enabled via full logging mode): `' . $sftp->getSFTPLog() . '`.');
             return false;
         } else {
             // Success sending.
             pb_backupbuddy::status('details', 'Success completely sending `' . basename($file) . '` to destination.');
             // Start remote backup limit
             if ($settings['archive_limit'] > 0) {
                 pb_backupbuddy::status('details', 'Archive limit enabled. Getting contents of backup directory.');
                 $contents = $sftp->rawlist($settings['path']);
                 // already in destination directory/path.
                 // Create array of backups
                 $bkupprefix = backupbuddy_core::backup_prefix();
                 $backups = array();
                 foreach ($contents as $filename => $backup) {
                     // check if file is backup
                     $pos = strpos($filename, 'backup-' . $bkupprefix . '-');
                     if ($pos !== FALSE) {
                         $backups[] = array('file' => $filename, 'modified' => $backup['mtime']);
                     }
                 }
                 function backupbuddy_number_sort($a, $b)
                 {
                     return $a['modified'] < $b['modified'];
                 }
                 // Sort by modified using custom sort function above.
                 usort($backups, 'backupbuddy_number_sort');
                 if (count($backups) > $settings['archive_limit']) {
                     pb_backupbuddy::status('details', 'More backups found (' . count($backups) . ') than limit permits (' . $settings['archive_limit'] . ').' . print_r($backups, true));
                     $delete_fail_count = 0;
                     $i = 0;
                     foreach ($backups as $backup) {
                         $i++;
                         if ($i > $settings['archive_limit']) {
                             if (false === $sftp->delete($settings['path'] . '/' . $backup['file'])) {
                                 pb_backupbuddy::status('details', 'Unable to delete excess sFTP file `' . $backup['file'] . '` in path `' . $settings['path'] . '`.');
                                 $delete_fail_count++;
                             } else {
                                 pb_backupbuddy::status('details', 'Deleted excess sFTP file `' . $backup['file'] . '` in path `' . $settings['path'] . '`.');
                             }
                         }
                     }
                     if ($delete_fail_count != 0) {
                         backupbuddy_core::mail_error(sprintf(__('sFTP remote limit could not delete %s backups. Please check and verify file permissions.', 'it-l10n-backupbuddy'), $delete_fail_count));
                         pb_backupbuddy::status('error', 'Unable to delete one or more excess backup archives. File storage limit may be exceeded. Manually clean up backups and check permissions.');
                     } else {
                         pb_backupbuddy::status('details', 'No problems encountered deleting excess backups.');
                     }
                 } else {
                     pb_backupbuddy::status('details', 'Not enough backups found to exceed limit. Skipping limit enforcement.');
                 }
             } else {
                 pb_backupbuddy::status('details', 'No sFTP archive file limit to enforce.');
             }
             // End remote backup limit
         }
     }
     // end $files loop.
     // Load destination fileoptions.
     pb_backupbuddy::status('details', 'About to load fileoptions data.');
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     pb_backupbuddy::status('details', 'Fileoptions instance #6.');
     $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
     if (true !== ($result = $fileoptions_obj->is_ok())) {
         pb_backupbuddy::status('error', __('Fatal Error #9034.843498. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
         return false;
     }
     pb_backupbuddy::status('details', 'Fileoptions data loaded.');
     $fileoptions =& $fileoptions_obj->options;
     // Save stats.
     $fileoptions['write_speed'] = $total_transfer_size / $total_transfer_time;
     $fileoptions_obj->save();
     unset($fileoptions_obj);
     return true;
 }
开发者ID:elephantcode,项目名称:elephantcode,代码行数:101,代码来源:init.php

示例8: 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(pb_backupbuddy::$options['backup_directory']);
     }
     $backup_file = pb_backupbuddy::$options['backup_directory'] . pb_backupbuddy::_POST('backup_file');
     $note = pb_backupbuddy::_POST('note');
     $note = ereg_replace("[[:space:]]+", ' ', $note);
     $note = ereg_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 = pb_backupbuddy::$classes['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 = pb_backupbuddy::$classes['core']->get_serial_from_file($backup_file);
     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())) {
         $backup_options->options['integrity']['comment'] = $note;
         $backup_options->save();
     }
     die;
 }
开发者ID:mariakhair,项目名称:bootstrap,代码行数:32,代码来源:ajax.php

示例9: send

 public static function send($destination_settings, $files, $send_id = '', $delete_after = false)
 {
     if ('' != $send_id) {
         pb_backupbuddy::add_status_serial('remote_send-' . $send_id);
         pb_backupbuddy::status('details', '----- Initiating master send function. Post-send deletion: ' . $delete_after);
         require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
         $fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt';
         if (!file_exists($fileoptions_file)) {
             //pb_backupbuddy::status( 'details', 'Fileoptions file `' . $fileoptions_file . '` does not exist yet; creating.' );
             //pb_backupbuddy::status( 'details', 'Fileoptions instance #19.' );
             $fileoptions_obj = new pb_backupbuddy_fileoptions($fileoptions_file, $read_only = false, $ignore_lock = true, $create_file = true);
         } else {
             //pb_backupbuddy::status( 'details', 'Fileoptions file exists; loading.' );
             //pb_backupbuddy::status( 'details', 'Fileoptions instance #18.' );
             $fileoptions_obj = new pb_backupbuddy_fileoptions($fileoptions_file, $read_only = false, $ignore_lock = false, $create_file = false);
         }
         if (true !== ($result = $fileoptions_obj->is_ok())) {
             pb_backupbuddy::status('error', __('Fatal Error #9034.2344848. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
             return false;
         }
         //pb_backupbuddy::status( 'details', 'Fileoptions data loaded.' );
         $fileoptions =& $fileoptions_obj->options;
         if ('' == $fileoptions) {
             $fileoptions = backupbuddy_core::get_remote_send_defaults();
             $fileoptions['type'] = $destination_settings['type'];
             if (!is_array($files)) {
                 $fileoptions['file'] = $files;
             } else {
                 $fileoptions['file'] = $files[0];
             }
             $fileoptions_obj->save();
         }
         if (isset($fileoptions['status']) && 'aborted' == $fileoptions['status']) {
             pb_backupbuddy::status('warning', 'Destination send triggered on an ABORTED transfer. Ending send function.');
             return false;
         }
         unset($fileoptions_obj);
     }
     if (false === ($destination = self::_init_destination($destination_settings))) {
         echo '{Error #546893498a. Destination configuration file missing.}';
         if ('' != $send_id) {
             pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
         }
         return false;
     }
     $destination_settings = $destination['settings'];
     // Settings with defaults applied, normalized, etc.
     //$destination_info = $destination['info'];
     if (!is_array($files)) {
         $files = array($files);
     }
     $originalFiles = $files;
     $files_with_sizes = '';
     foreach ($files as $index => $file) {
         if ('' == $file) {
             unset($files[$index]);
             continue;
             // Not actually a file to send.
         }
         if (!file_exists($file)) {
             pb_backupbuddy::status('error', 'Error #58459458743. The file that was attempted to be sent to a remote destination, `' . $file . '`, was not found. It either does not exist or permissions prevent accessing it.');
             if ('' != $send_id) {
                 pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
             }
             return false;
         }
         $files_with_sizes .= $file . ' (' . pb_backupbuddy::$format->file_size(filesize($file)) . '); ';
     }
     //pb_backupbuddy::status( 'details', 'Sending files `' . $files_with_sizes . '` to destination type `' . $destination_settings['type'] . '` titled `' . $destination_settings['title'] . '`.' );
     unset($files_with_sizes);
     if (!method_exists($destination['class'], 'send')) {
         pb_backupbuddy::status('error', 'Destination class `' . $destination['class'] . '` does not support send operation -- missing function.');
         if ('' != $send_id) {
             pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
         }
         return false;
     }
     //pb_backupbuddy::status( 'details', 'Calling send function.' );
     //$result = $destination_class::send( $destination_settings, $files );
     global $pb_backupbuddy_destination_errors;
     $pb_backupbuddy_destination_errors = array();
     $result = call_user_func_array("{$destination['class']}::send", array($destination_settings, $files, $send_id, $delete_after));
     if ($result === false) {
         $error_details = implode('; ', $pb_backupbuddy_destination_errors);
         if ('' != $error_details) {
             $error_details = ' Details: ' . $error_details;
         }
         $log_directory = backupbuddy_core::getLogDirectory();
         $preError = 'There was an error sending to the remote destination. One or more files may have not been fully transferred. Please see error details for additional information. If the error persists, enable full error logging and try again for full details and troubleshooting. Details: ' . "\n\n";
         $logFile = $log_directory . 'status-remote_send-' . $send_id . '_' . backupbuddy_core::get_serial_from_file($file) . '.txt';
         pb_backupbuddy::status('details', 'Looking for remote send log file `' . $logFile . '`.');
         if (!file_exists($logFile)) {
             pb_backupbuddy::status('details', 'Remote send log file not found.');
             backupbuddy_core::mail_error($preError . $error_details);
         } else {
             // Log exists. Attach.
             pb_backupbuddy::status('details', 'Remote send log file found. Attaching to error email.');
             backupbuddy_core::mail_error($preError . $error_details . "\n\nSee the attached log for details.", '', array($logFile));
         }
         // Save error details into fileoptions for this send.
//.........这里部分代码省略.........
开发者ID:jcwproductions,项目名称:jcwproductions-blog,代码行数:101,代码来源:bootstrap.php

示例10: send

 public static function send($destination_settings, $file, $send_id = '', $delete_after = false)
 {
     if (is_array($file)) {
         // As of v6.1.0.1 no longer accepting multiple files to send.
         $file = $file[0];
     }
     if ('' != $send_id) {
         pb_backupbuddy::add_status_serial('remote_send-' . $send_id);
         pb_backupbuddy::status('details', '----- Initiating master send function for BackupBuddy v' . pb_backupbuddy::settings('version') . '. Post-send deletion: ' . $delete_after);
         require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
         $fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt';
         if (!file_exists($fileoptions_file)) {
             //pb_backupbuddy::status( 'details', 'Fileoptions file `' . $fileoptions_file . '` does not exist yet; creating.' );
             //pb_backupbuddy::status( 'details', 'Fileoptions instance #19.' );
             $fileoptions_obj = new pb_backupbuddy_fileoptions($fileoptions_file, $read_only = false, $ignore_lock = true, $create_file = true);
         } else {
             //pb_backupbuddy::status( 'details', 'Fileoptions file exists; loading.' );
             //pb_backupbuddy::status( 'details', 'Fileoptions instance #18.' );
             $fileoptions_obj = new pb_backupbuddy_fileoptions($fileoptions_file, $read_only = false, $ignore_lock = false, $create_file = false);
         }
         if (true !== ($result = $fileoptions_obj->is_ok())) {
             pb_backupbuddy::status('error', __('Fatal Error #9034.2344848. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
             return false;
         }
         //pb_backupbuddy::status( 'details', 'Fileoptions data loaded.' );
         $fileoptions =& $fileoptions_obj->options;
         if ('' == $fileoptions) {
             // Set defaults.
             $fileoptions = backupbuddy_core::get_remote_send_defaults();
             $fileoptions['type'] = $destination_settings['type'];
             $fileoptions['file'] = $file;
             $fileoptions['retries'] = 0;
         }
         $fileoptions['sendID'] = $send_id;
         $fileoptions['destinationSettings'] = $destination_settings;
         // always store the LATEST settings for resume info and retry function.
         $fileoptions['update_time'] = time();
         $fileoptions['deleteAfter'] = $delete_after;
         $fileoptions_obj->save();
         if (isset($fileoptions['status']) && 'aborted' == $fileoptions['status']) {
             pb_backupbuddy::status('warning', 'Destination send triggered on an ABORTED transfer. Ending send function.');
             return false;
         }
         unset($fileoptions_obj);
     }
     if (false === ($destination = self::_init_destination($destination_settings))) {
         echo '{Error #546893498a. Destination configuration file missing.}';
         if ('' != $send_id) {
             pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
         }
         return false;
     }
     $destination_settings = $destination['settings'];
     // Settings with defaults applied, normalized, etc.
     if (!file_exists($file)) {
         pb_backupbuddy::status('error', 'Error #58459458743. The file that was attempted to be sent to a remote destination, `' . $file . '`, was not found. It either does not exist or permissions prevent accessing it. Check that local backup limits are not causing it to be deleted.');
         if ('' != $send_id) {
             pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
         }
         return false;
     }
     if (!method_exists($destination['class'], 'send')) {
         pb_backupbuddy::status('error', 'Destination class `' . $destination['class'] . '` does not support send operation -- missing function.');
         if ('' != $send_id) {
             pb_backupbuddy::remove_status_serial('remote_send-' . $send_id);
         }
         return false;
     }
     global $pb_backupbuddy_destination_errors;
     $pb_backupbuddy_destination_errors = array();
     $result = call_user_func_array("{$destination['class']}::send", array($destination_settings, $file, $send_id, $delete_after));
     /* $result values:
      *		false		Transfer FAILED.
      *		true		Non-chunked transfer succeeded.
      *		array()		array(
      *						multipart_id,				// Unique string ID for multipart send. Empty string if last chunk finished sending successfully.
      *						multipart_status_message
      *					)
      */
     if ($result === false) {
         $error_details = implode('; ', $pb_backupbuddy_destination_errors);
         if ('' != $error_details) {
             $error_details = ' Details: ' . $error_details;
         }
         $log_directory = backupbuddy_core::getLogDirectory();
         $preError = 'There was an error sending to the remote destination titled `' . $destination_settings['title'] . '` of type `' . backupbuddy_core::pretty_destination_type($destination_settings['type']) . '`. One or more files may have not been fully transferred. Please see error details for additional information. If the error persists, enable full error logging and try again for full details and troubleshooting. Details: ' . "\n\n";
         $logFile = $log_directory . 'status-remote_send-' . $send_id . '_' . pb_backupbuddy::$options['log_serial'] . '.txt';
         pb_backupbuddy::status('details', 'Looking for remote send log file to send in error email: `' . $logFile . '`.');
         if (!file_exists($logFile)) {
             pb_backupbuddy::status('details', 'Remote send log file not found.');
             backupbuddy_core::mail_error($preError . $error_details);
         } else {
             // Log exists. Attach.
             pb_backupbuddy::status('details', 'Remote send log file found. Attaching to error email.');
             backupbuddy_core::mail_error($preError . $error_details . "\n\nSee the attached log for details.", '', array($logFile));
         }
         // Save error details into fileoptions for this send.
         //pb_backupbuddy::status( 'details', 'About to load fileoptions data.' );
         require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
         pb_backupbuddy::status('details', 'Fileoptions instance #45.');
//.........这里部分代码省略.........
开发者ID:Offirmo,项目名称:base-wordpress,代码行数:101,代码来源:bootstrap.php

示例11: test

 public static function test($settings)
 {
     $settings = self::_init($settings);
     // Try sending a file.
     $send_response = pb_backupbuddy_destinations::send($settings, dirname(dirname(__FILE__)) . '/remote-send-test.php', $send_id = 'TEST-' . pb_backupbuddy::random_string(12));
     // 3rd param true forces clearing of any current uploads.
     if (false === $send_response) {
         $send_response = 'Error sending test file to S3.';
     } else {
         $send_response = 'Success.';
     }
     // Delete sent file.
     $delete_response = 'Success.';
     try {
         $delete_response = self::$_client->delete_object(array('Bucket' => $settings['bucket'], 'Key' => $settings['directory'] . 'remote-send-test.php'));
         $delete_response = 'Success.';
     } catch (Exception $e) {
         pb_backupbuddy::status('details', 'Unable to delete test S3 file `remote-send-test.php`. Details: `' . $e->getMessage() . '`.');
     }
     // Load destination fileoptions.
     pb_backupbuddy::status('details', 'About to load fileoptions data.');
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     pb_backupbuddy::status('details', 'Fileoptions instance #7.');
     $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
     if (true !== ($result = $fileoptions_obj->is_ok())) {
         return self::_error(__('Fatal Error #9034.84838. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
     }
     pb_backupbuddy::status('details', 'Fileoptions data loaded.');
     $fileoptions =& $fileoptions_obj->options;
     if ('Success.' != $send_response || 'Success.' != $delete_response) {
         $fileoptions['status'] = 'failure';
         $fileoptions_obj->save();
         unset($fileoptions_obj);
         return 'Send details: `' . $send_response . '`. Delete details: `' . $delete_response . '`.';
     } else {
         $fileoptions['status'] = 'success';
         $fileoptions['finish_time'] = time();
     }
     $fileoptions_obj->save();
     unset($fileoptions_obj);
     return true;
 }
开发者ID:shelbyneilsmith,项目名称:wptools,代码行数:42,代码来源:init.php

示例12: _processSignatures

 private static function _processSignatures($type, $newFileSignatures)
 {
     pb_backupbuddy::status('details', 'About to load fileoptions data in create mode.');
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     pb_backupbuddy::status('details', 'Fileoptions instance #88.');
     $existingSignaturesObj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'live/' . $type . '-' . pb_backupbuddy::$options['log_serial'] . '.txt', $read_only = false, $ignore_lock = false, $create_file = true);
     if (true !== ($result = $existingSignaturesObj->is_ok())) {
         pb_backupbuddy::status('error', 'Error #382983. Unable to create or access fileoptions file for media. Details: `' . $result . '`.');
         return false;
     }
     pb_backupbuddy::status('details', 'Fileoptions data loaded.');
     if (!isset($existingSignaturesObj->options['signatures'])) {
         $existingSignaturesObj->options = array('signatures' => array(), 'stats' => array('totalFiles' => 0, 'needsSent' => 0, 'needsDelete' => 0));
     }
     $existingSignatures =& $existingSignaturesObj->options['signatures'];
     // Loop through local files to see if they differ from previous scan.
     pb_backupbuddy::status('details', 'Comparing new signatures with existing ones.');
     $addOrUpdateCount = 0;
     foreach ($newFileSignatures as $file => $signature) {
         $addOrUpdateFile = false;
         if (!isset($existingSignatures[$file])) {
             // This is a new file. Append to list.
             $addOrUpdateFile = true;
             $existingSignaturesObj->options['stats']['totalFiles']++;
         } else {
             // File exists on remote. See if content is the same.
             if (isset($signature['sha1']) && $signature['sha1'] != $existingSignatures[$file]['sha1']) {
                 // Hash mismatch. Needs updating.
                 $addOrUpdateFile = true;
             } elseif (!isset($signature['sha1']) || '' == $signature['sha1']) {
                 // sha1 not calculated. size may be too large. compare size to see if changed.
                 if ($signature['size'] != $existingSignatures[$file]['size']) {
                     // size mismatch
                     $addOrUpdateFile = true;
                 }
             }
         }
         // File is new and needs added to list to be sent to remote.
         if (true === $addOrUpdateFile) {
             $existingSignatures[$file] = $signature;
             $signature['added'] = time();
             // When did we first notice file?
             $signature['sent'] = false;
             // Has file been sent to Stash?
             $existingSignaturesObj->options['stats']['needsSent']++;
             pb_backupbuddy::status('details', 'New or modified file found `' . $file . '`.');
             $addOrUpdateCount++;
         }
     }
     // Loop through remote files to see if any no longer exist locally and therefore need deleted.
     $deleteCount = 0;
     foreach ($existingSignatures as $file => $signature) {
         if (!isset($newFileSignatures[$file])) {
             $existingSignatures[$file]['delete'] = true;
             $existingSignaturesObj->options['stats']['needsDelete']++;
             $existingSignaturesObj->options['stats']['totalFiles']--;
             pb_backupbuddy::status('details', 'Remote file that no longer exists locally found. Flagging `' . $file . '` for deletion.');
         }
     }
     // Save.
     pb_backupbuddy::status('details', 'Saving updated `' . $type . '` signatures... Added `' . $addOrUpdateCount . '`. Deleted `' . $deleteCount . '`. Total files: `' . $existingSignaturesObj->options['stats']['totalFiles'] . '`. Needs sent: `' . $existingSignaturesObj->options['stats']['needsSent'] . '`. Needs delete: `' . $existingSignaturesObj->options['stats']['needsDelete'] . '`.');
     $existingSignaturesObj->save();
     pb_backupbuddy::status('details', 'Signatures saved.');
     return true;
 }
开发者ID:Offirmo,项目名称:base-wordpress,代码行数:65,代码来源:live.php

示例13: process_timed_out_backups

 public static function process_timed_out_backups()
 {
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     // Mark any backups noted as in progress to timed out if taking too long. Send error email is scheduled and failed or timed out.
     // Also, Purge fileoptions files without matching backup file in existance that are older than 30 days.
     pb_backupbuddy::status('details', 'Cleaning up old backup fileoptions option files.');
     $fileoptions_directory = backupbuddy_core::getLogDirectory() . 'fileoptions/';
     $files = glob($fileoptions_directory . '*.txt');
     if (!is_array($files)) {
         $files = array();
     }
     foreach ($files as $file) {
         pb_backupbuddy::status('details', 'Fileoptions instance #43.');
         $backup_options = new pb_backupbuddy_fileoptions($file, $read_only = false);
         if (true !== ($result = $backup_options->is_ok())) {
             pb_backupbuddy::status('error', 'Error retrieving fileoptions file `' . $file . '`. Err 335353266.');
         } else {
             if (isset($backup_options->options['archive_file'])) {
                 //error_log( print_r( $backup_options->options, true ) );
                 if (FALSE === $backup_options->options['finish_time']) {
                     // Failed & already handled sending notification.
                 } elseif ($backup_options->options['finish_time'] == -1) {
                     // Cancelled manually
                 } elseif ($backup_options->options['finish_time'] >= $backup_options->options['start_time'] && 0 != $backup_options->options['start_time']) {
                     // Completed
                 } else {
                     // Timed out or in progress.
                     $secondsAgo = time() - $backup_options->options['updated_time'];
                     if ($secondsAgo > backupbuddy_constants::TIME_BEFORE_CONSIDERED_TIMEOUT) {
                         // If 24hrs passed since last update to backup then mark this timeout as failed.
                         if ('scheduled' == $backup_options->options['trigger']) {
                             // SCHEDULED BACKUP TIMED OUT.
                             // Determine the first step to not finish.
                             $timeoutStep = '';
                             foreach ($backup_options->options['steps'] as $step) {
                                 if (0 == $step['finish_time']) {
                                     $timeoutStep = $step['function'];
                                     break;
                                 }
                             }
                             $backupCheckSpot = __('Select "View recently made backups" from the BackupBuddy Backups page to find this backup and view its log details and/or manually create a backup to test for problems.', 'it-l10n-backupbuddy');
                             $sendCheckSpot = __('Select "View recently sent files" on the Remote Destinations page to find this backup and view its log details and/or manually create a backup to test for problems.', 'it-l10n-backupbuddy');
                             $timeoutMessage = '';
                             if ('' != $timeoutStep) {
                                 if ('backup_create_database_dump' == $timeoutStep) {
                                     $timeoutMessage = 'The database dump step appears to have timed out. Make sure your database is not full of unwanted logs or clutter. ' . $backupCheckSpot;
                                 } elseif ('backup_zip_files' == $timeoutStep) {
                                     $timeoutMessage = 'The zip archive creation step appears to have timed out. Try turning off zip compression to significantly speed up the process or exclude large files. ' . $backupCheckSpot;
                                 } elseif ('send_remote_destination' == $timeoutStep) {
                                     $timeoutMessage = 'The remote transfer step appears to have timed out. Try turning on chunking in the destination settings to break up the file transfer into multiple steps. ' . $sendCheckSpot;
                                 } else {
                                     $timeoutMessage = 'The step function `' . $timeoutStep . '` appears to have timed out. ' . $backupCheckSpot;
                                 }
                             }
                             $error_message = 'Scheduled BackupBuddy backup `' . $backup_options->options['archive_file'] . '` started `' . pb_backupbuddy::$format->time_ago($backup_options->options['start_time']) . '` ago likely timed out. ' . $timeoutMessage;
                             pb_backupbuddy::status('error', $error_message);
                             if ($secondsAgo < backupbuddy_constants::CLEANUP_MAX_AGE_TO_NOTIFY_TIMEOUT) {
                                 // Prevents very old timed out backups from triggering email send.
                                 backupbuddy_core::mail_error($error_message);
                             }
                         }
                         // end scheduled.
                         $backup_options->options['finish_time'] = FALSE;
                         // Consider officially timed out.  If scheduled backup then an error notification will have been sent.
                         $backup_options->save();
                     }
                 }
                 // Remove fileoptions files which do not have a corresponding local backup. NOTE: This only handles fileoptions files containing the 'archive_file' key in their array. Handle those without this elsewhere.
                 // Cached integrity scans performed when there was not an existing fileoptions file will be missing the archive_file key.
                 $backupDir = backupbuddy_core::getBackupDirectory();
                 if (!file_exists($backup_options->options['archive_file']) && !file_exists($backupDir . basename($backup_options->options['archive_file']))) {
                     // No corresponding backup ZIP file.
                     $modified = filemtime($file);
                     if (time() - $modified > backupbuddy_constants::MAX_SECONDS_TO_KEEP_ORPHANED_FILEOPTIONS_FILES) {
                         // Too many days old so delete.
                         if (false === unlink($file)) {
                             pb_backupbuddy::status('error', 'Unable to delete orphaned fileoptions file `' . $file . '`.');
                         }
                         if (file_exists($file . '.lock')) {
                             @unlink($file . '.lock');
                         }
                     } else {
                         // Do not delete orphaned fileoptions because it is not old enough. Recent backups page needs these to list the backup.
                     }
                 } else {
                     // Backup ZIP file exists.
                 }
             } else {
                 // No archive_file key in fileoptions array.
                 // Trim any fileoptions files that are orphaned (no matching backup zip file). Note that above we trim these files that have the archive_file key in them.
                 $backupDir = backupbuddy_core::getBackupDirectory();
                 $serial = backupbuddy_core::get_serial_from_file('-' . basename($file));
                 // Dash needed to trick get_serial_from_file() into thinking this is a valid backup filename.
                 $backupFiles = glob($backupDir . '*' . $serial . '*.zip');
                 // Try to find a matching backup zip with this serial in its filename.
                 if (!is_array($backupFiles)) {
                     $backupFiles = array();
                 }
                 if (0 == count($backupFiles)) {
                     // No corresponding backup. Delete file.
//.........这里部分代码省略.........
开发者ID:arobbins,项目名称:spellestate,代码行数:101,代码来源:housekeeping.php

示例14: _step_process_file_deletions

 private static function _step_process_file_deletions($startAt = 0)
 {
     if ($startAt < 0) {
         $startAt = 0;
     }
     $start_time = microtime(true);
     if (false === self::_load_catalog()) {
         return false;
     }
     // Build Stash2 destination settings based on Live settings.
     $destination_settings = self::get_destination_settings();
     pb_backupbuddy::status('details', 'Starting deletions at point: `' . $startAt . '`.');
     // Loop through files in the catalog.
     $loopCount = 0;
     $checkCount = 0;
     $filesDeleted = 0;
     $deleteQueue = array();
     // Files queued to delete.
     $last_save = microtime(true);
     foreach (self::$_catalog as $signatureFile => &$signatureDetails) {
         if (0 != $startAt) {
             // Resuming...
             if ($loopCount < $startAt) {
                 $loopCount++;
                 continue;
             }
         } else {
             $loopCount++;
         }
         $checkCount++;
         // Skip non-deleted files.
         if (true !== $signatureDetails['d']) {
             continue;
         }
         // Made it here then we will be deleting a file.
         // Cancel any in-process remote sends of deleted files.
         $sendFileoptions = glob(backupbuddy_core::getLogDirectory() . 'fileoptions/send-live_' . md5($signatureFile) . '-*.txt');
         if (!is_array($sendFileoptions)) {
             $sendFileoptions = array();
         }
         foreach ($sendFileoptions as $sendFileoption) {
             $fileoptions_obj = new pb_backupbuddy_fileoptions($sendFileoption, $read_only = false, $ignore_lock = true, $create_file = false);
             if (true !== ($result = $fileoptions_obj->is_ok())) {
                 pb_backupbuddy::status('error', __('Error #9034.32393. Unable to access fileoptions data related to file `' . $signatureFile . '`. Skipping cleanup of file send.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
                 continue;
             }
             // Something wrong with fileoptions. Let cleanup handle it later.
             if (!isset($fileoptions_obj->options['status'])) {
                 continue;
             }
             // Don't do anything for success, failure, or already-marked as -1 finish time.
             if ('success' == $fileoptions_obj->options['status'] || 'failure' == $fileoptions_obj->options['status'] || -1 == $fileoptions_obj->options['finish_time']) {
                 continue;
             }
             // Cancel this send.
             $fileoptions_obj->options['finish_time'] = -1;
             $fileoptions_obj->save();
             pb_backupbuddy::status('details', 'Cancelled in-progress send of deleted file `' . $signatureFile . '`.');
             unset($fileoptions_obj);
         }
         // If file has been backed up to server then we need to QUEUE the file for deletion.
         if (0 != $signatureDetails['b']) {
             $deleteQueue[] = $signatureFile;
         }
         // Is the queue full to the delete burst limit? Process queue.
         if (count($deleteQueue) >= $destination_settings['max_delete_burst']) {
             pb_backupbuddy::status('details', 'File deletion queue full to burst limit. Triggering deletions call.');
             self::_process_internal_delete_queue($destination_settings, $deleteQueue, $filesDeleted);
             // Process any items in the deletion queue. $deleteQueue and $filesDeleted are references.
         }
         // See if it's time to save our progress so far.
         if (time() - $last_save > self::SAVE_SIGNATURES_EVERY_X_SECONDS) {
             pb_backupbuddy::status('details', 'Time to save progress so far. Triggering deletions call then saving.');
             self::_process_internal_delete_queue($destination_settings, $deleteQueue, $filesDeleted);
             // Process any items in the deletion queue. $deleteQueue and $filesDeleted are references.
             self::$_stateObj->save();
             self::$_catalogObj->save();
             $last_save = microtime(true);
         }
         // Do we have enough time to continue or do we need to chunk?
         if (microtime(true) - $start_time + self::TIME_WIGGLE_ROOM > $destination_settings['max_time']) {
             // Running out of time! Chunk.
             pb_backupbuddy::status('details', 'Running out of time processing deletions. Took `' . (microtime(true) - $start_time) . '` seconds. Triggering deletions call then saving.');
             //self::_process_internal_delete_queue( $destination_settings, $deleteQueue, $filesDeleted ); // Process any items in the deletion queue. $deleteQueue and $filesDeleted are references.
             // Do not process queue here. Anything in the queuecan be handled during the next chunk.
             self::$_stateObj->save();
             self::$_catalogObj->save();
             return array('Processing deletions', array());
             //array( $startAt+$loopCount-$filesDeleted ) );
         }
     }
     // end foreach.
     // Wrap up any lingering deletions.
     pb_backupbuddy::status('details', 'Processing any lingering deletions in queue at finish then saving.');
     self::_process_internal_delete_queue($destination_settings, $deleteQueue, $filesDeleted);
     // Process any items in the deletion queue. $deleteQueue and $filesDeleted are references.
     // Save and finish.
     self::$_stateObj->save();
     self::$_catalogObj->save();
     pb_backupbuddy::status('details', 'Deletions processed. Checked `' . $checkCount . '` files. Deleted `' . $filesDeleted . '` files. Took `' . (microtime(true) - $start_time) . '` seconds.');
//.........这里部分代码省略.........
开发者ID:arobbins,项目名称:spellestate,代码行数:101,代码来源:live_periodic.php

示例15: array

$fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '-filetree.txt';
// Purge cache if too old.
if (file_exists($fileoptions_file) && time() - filemtime($fileoptions_file) > $max_cache_time) {
    if (false === unlink($fileoptions_file)) {
        pb_backupbuddy::alert('Error #456765545. Unable to wipe cached fileoptions file `' . $fileoptions_file . '`.');
    }
}
$fileoptions = new pb_backupbuddy_fileoptions($fileoptions_file);
// Either we are getting cached file tree information or we need to create afresh
if (true !== ($result = $fileoptions->is_ok())) {
    // Get file listing.
    require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
    pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(ABSPATH, array(), 'unzip');
    $files = pb_backupbuddy::$classes['zipbuddy']->get_file_list(backupbuddy_core::getBackupDirectory() . str_replace('\\/', '', pb_backupbuddy::_GET('zip_viewer')));
    $fileoptions->options = $files;
    $fileoptions->save();
} else {
    $files =& $fileoptions->options;
}
// Just make sure we have a sensible files listing
if (!is_array($files)) {
    die('Error #548484.  Unable to retrieve file listing from backup file `' . htmlentities(pb_backupbuddy::_GET('zip_viewer')) . '`.');
}
// To record subdirs of this root
$subdirs = array();
// Strip out any files/subdirs that are not actually directly under the given root
foreach ($files as $key => $file) {
    // If shorter than root length then certainly is not within this (root) directory.
    // It's a quick test that is more effective the longer the root (the deeper you go
    // into the tree)
    if (strlen($file[0]) < $root_len) {
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:31,代码来源:file_tree.php


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