本文整理汇总了PHP中pb_backupbuddy_fileoptions类的典型用法代码示例。如果您正苦于以下问题:PHP pb_backupbuddy_fileoptions类的具体用法?PHP pb_backupbuddy_fileoptions怎么用?PHP pb_backupbuddy_fileoptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了pb_backupbuddy_fileoptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _load_tables
private static function _load_tables($force_reload = false, $get_contents_only = false)
{
if (is_object(self::$_tablesObj) && true !== $force_reload) {
return self::$_tablesObj;
}
if (true === $force_reload) {
unset(self::$_tablesObj);
}
$read_only = false;
$ignore_lock = self::_fileoptions_lock_ignore_timeout_value();
if (true === $get_contents_only) {
$read_only = true;
$ignore_lock = false;
}
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
$tablesObj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'live/tables-' . pb_backupbuddy::$options['log_serial'] . '.txt', $read_only, $ignore_lock, $create_file = true, $live_mode = true);
if (true !== ($result = $tablesObj->is_ok())) {
pb_backupbuddy::status('error', 'Error #435554390. Unable to create or access fileoptions file. Details: `' . $result . '`. Waiting a moment before ending.');
sleep(3);
// Wait a moment to give time for temporary issues to resolve.
return false;
}
// Set defaults.
if (!is_array($tablesObj->options)) {
$tablesObj->options = array();
}
// Getting contents only.
if (true === $get_contents_only) {
return $tablesObj->options;
}
// Set class variables with references to object and options within.
self::$_tablesObj =& $tablesObj;
self::$_tables =& $tablesObj->options;
return true;
}
开发者ID:arobbins,项目名称:spellestate,代码行数:35,代码来源:live_periodic.php
示例2: 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
示例3: glob
pb_backupbuddy::status('details', 'Cleaning up remote send stats.');
backupbuddy_core::trim_remote_send_stats();
// Verify directory existance and anti-directory browsing is in place everywhere.
backupbuddy_core::verify_directories($skipTempGeneration = true);
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) {
开发者ID:Offirmo,项目名称:base-wordpress,代码行数:31,代码来源:_periodicCleanup.php
示例4: remotesend_abort
function remotesend_abort()
{
$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';
$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:serker72,项目名称:T3S,代码行数:17,代码来源:ajax.php
示例5: str_replace
<?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
示例6: 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
示例7: foreach
// ********** BEGIN 3.1.8.2 -> 3.1.8.3 DATA MIGRATION **********
if (pb_backupbuddy::$options['data_version'] < 4) {
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'];
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:31,代码来源:activation.php
示例8: process_files
public static function process_files($state = array())
{
$start_time = microtime(true);
$state = array_merge(array('current_step' => 'update_files_list', 'step_start' => microtime(true), 'sha1' => false), $state);
$steps = array('update_files_list', 'update_files_details');
/* STEPS
* 1. Generate list of files, leaving stats blank.
* 2. Loop through list. Skip anything set to delete. If scantime is too old, calculate filesize, mtime, and optional sha1. Compare with existing values & update them. If they changed then mark sent to false.
*
* array[filename] => {
* size
* mtime
* sha1
* scantime
* [sent]
* [delete]
* }
*
*/
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.');
$signaturesObj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'live/files-' . pb_backupbuddy::$options['log_serial'] . '.txt', $read_only = false, $ignore_lock = false, $create_file = true);
if (true !== ($result = $signaturesObj->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($signaturesObj->options['signatures'])) {
$signaturesObj->options = array('signatures' => array(), 'stats' => array('totalFiles' => 0, 'pendingSend' => 0, 'pendingDelete' => 0));
}
$signatures =& $signaturesObj->options['signatures'];
if ('update_files_list' == $state['current_step']) {
self::_process_files_update_files_list($signaturesObj, self::_getOption('file_excludes', true));
} elseif ('update_files_details' == $state['current_step']) {
} else {
}
echo 'Total time: ' . (microtime(true) - $start_time);
}
开发者ID:elephantcode,项目名称:elephantcode,代码行数:39,代码来源:live.php
示例9: send
public static function send($settings = array(), $files = array(), $send_id = '')
{
$limit = $settings['archive_limit'];
$path = $settings['path'];
if (!file_exists($settings['path'])) {
pb_backupbuddy::$filesystem->mkdir($settings['path']);
}
$total_transfer_time = 0;
$total_transfer_size = 0;
foreach ($files as $file) {
pb_backupbuddy::status('details', 'Starting send to `' . $path . '`.');
$filesize = filesize($file);
$total_transfer_size += $filesize;
$send_time = -microtime(true);
if (true !== @copy($file, $path . '/' . basename($file))) {
pb_backupbuddy::status('error', 'Unable to copy file `' . $file . '` of size `' . pb_backupbuddy::$format->file_size($filesize) . '` to local path `' . $path . '`. Please verify the directory exists and permissions permit writing.');
backupbuddy_core::mail_error($error_message);
return false;
} else {
pb_backupbuddy::status('details', 'Send success.');
}
$send_time += microtime(true);
$total_transfer_time += $send_time;
// Start remote backup limit
if ($limit > 0) {
pb_backupbuddy::status('details', 'Archive limit of `' . $limit . '` in settings.');
pb_backupbuddy::status('details', 'path: ' . $path . '*.zip');
$remote_files = glob($path . '/*.zip');
if (!is_array($remote_files)) {
$remote_files = array();
}
usort($remote_files, create_function('$a,$b', 'return filemtime($a) - filemtime($b);'));
pb_backupbuddy::status('details', 'Found `' . count($remote_files) . '` backups.');
// Create array of backups and organize by date
$bkupprefix = backupbuddy_core::backup_prefix();
foreach ($remote_files as $file_key => $remote_file) {
if (false === stripos($remote_file, 'backup-' . $bkupprefix . '-')) {
pb_backupbuddy::status('details', 'backup-' . $bkupprefix . '-' . 'not in file: ' . $remote_file);
unset($backups[$file_key]);
}
}
arsort($remote_files);
pb_backupbuddy::status('details', 'Found `' . count($remote_files) . '` backups.');
if (count($remote_files) > $limit) {
pb_backupbuddy::status('details', 'More archives (' . count($remote_files) . ') than limit (' . $limit . ') allows. Trimming...');
$i = 0;
$delete_fail_count = 0;
foreach ($remote_files as $remote_file) {
$i++;
if ($i > $limit) {
pb_backupbuddy::status('details', 'Trimming excess file `' . $remote_file . '`...');
if (!unlink($remote_file)) {
pb_backupbuddy::status('details', 'Unable to delete excess local file `' . $remote_file . '`.');
$delete_fail_count++;
}
}
}
pb_backupbuddy::status('details', 'Finished trimming excess backups.');
if ($delete_fail_count !== 0) {
$error_message = 'Local remote limit could not delete ' . $delete_fail_count . ' backups.';
pb_backupbuddy::status('error', $error_message);
backupbuddy_core::mail_error($error_message);
}
}
} else {
pb_backupbuddy::status('details', 'No local destination file limit to enforce.');
}
// End remote backup limit
}
// end foreach.
// Load fileoptions to the 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 #11.');
$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.2344848. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
return false;
}
pb_backupbuddy::status('details', 'Fileoptions data loaded.');
$fileoptions =& $fileoptions_obj->options;
$fileoptions['write_speed'] = $total_transfer_time / $total_transfer_size;
return true;
}
开发者ID:ryankrieg,项目名称:wordpress-base,代码行数:84,代码来源:init.php
示例10: str_replace
backupbuddy_core::verifyAjaxAccess();
// Display backup integrity status.
/* integrity_status()
*
* description
*
*/
$send_id = pb_backupbuddy::_GET('send_id');
$send_di = str_replace('/\\', '', $send_id);
pb_backupbuddy::load();
pb_backupbuddy::$ui->ajax_header();
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
pb_backupbuddy::status('details', 'Fileoptions instance #27.');
$optionsFile = backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt';
$send_options = new pb_backupbuddy_fileoptions($optionsFile, $read_only = true);
if (true !== ($result = $send_options->is_ok())) {
pb_backupbuddy::alert(__('Unable to access fileoptions data file.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
die;
}
$start_time = 'Unknown';
$finish_time = 'Unknown';
if (isset($send_options->options['start_time'])) {
$start_time = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($send_options->options['start_time'])) . ' <span class="description">(' . pb_backupbuddy::$format->time_ago($send_options->options['start_time']) . ' ago)</span>';
if ($send_options->options['finish_time'] > 0) {
$finish_time = pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($send_options->options['finish_time'])) . ' <span class="description">(' . pb_backupbuddy::$format->time_ago($send_options->options['finish_time']) . ' ago)</span>';
} else {
// unfinished.
$finish_time = '<i>Unfinished</i>';
}
}
开发者ID:elephantcode,项目名称:elephantcode,代码行数:30,代码来源:send_status.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: 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
示例13: _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
示例14: process_timed_out_sends
public static function process_timed_out_sends()
{
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
// Mark any timed out remote sends as timed out. Attempt resend once.
$remote_sends = array();
$send_fileoptions = pb_backupbuddy::$filesystem->glob_by_date(backupbuddy_core::getLogDirectory() . 'fileoptions/send-*.txt');
if (!is_array($send_fileoptions)) {
$send_fileoptions = array();
}
foreach ($send_fileoptions as $send_fileoption) {
$send_id = str_replace('.txt', '', str_replace('send-', '', basename($send_fileoption)));
pb_backupbuddy::status('details', 'About to load fileoptions data.');
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
pb_backupbuddy::status('details', 'Fileoptions instance #23.');
$fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt';
$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.3224442393. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
return false;
}
// Corrupt fileoptions file. Remove.
if (!isset($fileoptions_obj->options['start_time'])) {
unset($fileoptions_obj);
@unlink($fileoptions_file);
continue;
}
// Finish time not set. Shouldn't happen buuuuut.... skip.
if (!isset($fileoptions_obj->options['finish_time'])) {
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;
}
// Older format did not include updated_time.
if (!isset($fileoptions_obj->options['update_time'])) {
continue;
}
$secondsAgo = time() - $fileoptions_obj->options['update_time'];
if ($secondsAgo > backupbuddy_constants::TIME_BEFORE_CONSIDERED_TIMEOUT) {
// If 24hrs passed since last update to backup then mark this timeout as failed.
// Potentially try to resend if not a live_periodic transfer.
if ('live_periodic' != $fileoptions_obj->options['trigger']) {
$isResending = backupbuddy_core::remoteSendRetry($fileoptions_obj, $send_id, pb_backupbuddy::$options['remote_send_timeout_retries']);
if (true === $isResending) {
// If resending then skip sending any error email just yet...
continue;
}
if ('timeout' != $fileoptions_obj->options['status']) {
// Do not send email if status is 'timeout' since either already sent or old-style status marking (pre-v6.0).
// Calculate destination title and type for error email.
$destination_title = '';
$destination_type = '';
if (isset(pb_backupbuddy::$options['remote_destinations'][$fileoptions_obj->options['destination']])) {
$destination_title = pb_backupbuddy::$options['remote_destinations'][$fileoptions_obj->options['destination']]['title'];
$destination_type = backupbuddy_core::pretty_destination_type(pb_backupbuddy::$options['remote_destinations'][$fileoptions_obj->options['destination']]['type']);
}
$error_message = 'A remote destination send of file `' . basename($fileoptions_obj->options['file']) . '` started `' . pb_backupbuddy::$format->time_ago($fileoptions_obj->options['start_time']) . '` ago sending to the destination titled `' . $destination_title . '` of type `' . $destination_type . '` likely timed out. BackupBuddy will attempt to retry this failed transfer ONCE. If the second atempt succeeds the failed attempt will be replaced in the recent sends list. Check the error log for further details and/or manually send a backup to test for problems.';
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);
}
}
}
// Save as timed out.
$fileoptions_obj->options['status'] = 'timeout';
$fileoptions_obj->options['finish_time'] = -1;
$fileoptions_obj->save();
// If live_periofic then just try to delete the file at this point.
if ('live_periodic' == $fileoptions_obj->options['trigger']) {
unset($fileoptions_obj);
@unlink($fileoptions_file);
continue;
}
}
unset($fileoptions_obj);
}
}
开发者ID:arobbins,项目名称:spellestate,代码行数:79,代码来源:housekeeping.php
|
请发表评论