本文整理汇总了PHP中pb_backupbuddy_fileoptions::unlock方法的典型用法代码示例。如果您正苦于以下问题:PHP pb_backupbuddy_fileoptions::unlock方法的具体用法?PHP pb_backupbuddy_fileoptions::unlock怎么用?PHP pb_backupbuddy_fileoptions::unlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pb_backupbuddy_fileoptions
的用法示例。
在下文中一共展示了pb_backupbuddy_fileoptions::unlock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send_remote_destination
public static function send_remote_destination($destination_id, $file, $trigger = '', $send_importbuddy = false, $delete_after = false, $identifier = '', $destination_settings = '')
{
if (defined('PB_DEMO_MODE')) {
return false;
}
if (!file_exists($file)) {
pb_backupbuddy::status('error', 'Error #8583489734: Unable to send file `' . $file . '` to remote destination as it no longer exists. It may have been deleted or permissions are invalid.');
return false;
}
$migrationkey_transient_time = 60 * 60 * 24;
if ('' == $file) {
$backup_file_size = 50000;
// not sure why anything current would be sending importbuddy but NOT sending a backup but just in case...
} else {
$backup_file_size = filesize($file);
}
// Generate remote send ID for reference and add it as a new logging serial for better recording details.
if ('' == $identifier) {
$identifier = pb_backupbuddy::random_string(12);
}
// Set migration key for later determining last initiated migration.
if ('migration' == $trigger) {
set_transient('pb_backupbuddy_migrationkey', $identifier, $migrationkey_transient_time);
}
pb_backupbuddy::status('details', 'Sending file `' . $file . '` to remote destination `' . $destination_id . '` with ID `' . $identifier . '` triggered by `' . $trigger . '`.');
//pb_backupbuddy::status( 'details', 'About to create initial fileoptions data.' );
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
pb_backupbuddy::status('details', 'Fileoptions instance #35.');
$fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $identifier . '.txt', $read_only = false, $ignore_lock = true, $create_file = true);
if (true !== ($result = $fileoptions_obj->is_ok())) {
pb_backupbuddy::status('error', __('Fatal Error #9034 A. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
return false;
}
//pb_backupbuddy::status( 'details', 'Fileoptions data loaded.' );
$fileoptions =& $fileoptions_obj->options;
// Set reference.
// Record some statistics.
$fileoptions = array_merge(self::get_remote_send_defaults(), array('destination' => $destination_id, 'file' => $file, 'file_size' => $backup_file_size, 'trigger' => $trigger, 'send_importbuddy' => $send_importbuddy, 'start_time' => time(), 'finish_time' => 0, 'status' => 'running', 'write_speed' => 0));
pb_backupbuddy::save();
// Destination settings were not passed so get them based on the destination ID provided.
if (!is_array($destination_settings)) {
$destination_settings =& pb_backupbuddy::$options['remote_destinations'][$destination_id];
}
// For Stash we will check the quota prior to initiating send.
if (pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash') {
// Pass off to destination handler.
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
$send_result = pb_backupbuddy_destinations::get_info('stash');
// Used to kick the Stash destination into life.
$stash_quota = pb_backupbuddy_destination_stash::get_quota(pb_backupbuddy::$options['remote_destinations'][$destination_id], true);
if ($file != '') {
$backup_file_size = filesize($file);
} else {
$backup_file_size = 50000;
}
if ($backup_file_size + $stash_quota['quota_used'] > $stash_quota['quota_total']) {
$message = '';
$message .= "You do not have enough Stash storage space to send this file. Please upgrade your Stash storage at http://ithemes.com/member/panel/stash.php or delete files to make space.\n\n";
$message .= 'Attempting to send file of size ' . pb_backupbuddy::$format->file_size($backup_file_size) . ' but you only have ' . $stash_quota['quota_available_nice'] . ' available. ';
$message .= 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).';
pb_backupbuddy::status('error', $message);
backupbuddy_core::mail_error($message);
$fileoptions['status'] = 'Failure. Insufficient destination space.';
$fileoptions_obj->save();
return false;
} else {
if (isset($stash_quota['quota_warning']) && $stash_quota['quota_warning'] != '') {
// We log warning of usage but dont send error email.
$message = '';
$message .= 'WARNING: ' . $stash_quota['quota_warning'] . "\n\nPlease upgrade your Stash storage at http://ithemes.com/member/panel/stash.php or delete files to make space.\n\n";
$message .= 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).';
pb_backupbuddy::status('details', $message);
//backupbuddy_core::mail_error( $message );
}
}
}
// end if stash.
/*
if ( $send_importbuddy === true ) {
pb_backupbuddy::status( 'details', 'Generating temporary importbuddy.php file for remote send.' );
pb_backupbuddy::anti_directory_browsing( backupbuddy_core::getTempDirectory(), $die = false );
$importbuddy_temp = backupbuddy_core::getTempDirectory() . 'importbuddy.php'; // Full path & filename to temporary importbuddy
self::importbuddy( $importbuddy_temp ); // Create temporary importbuddy.
pb_backupbuddy::status( 'details', 'Generated temporary importbuddy.' );
$files[] = $importbuddy_temp; // Add importbuddy file to the list of files to send.
$send_importbuddy = true; // Track to delete after finished.
} else {
pb_backupbuddy::status( 'details', 'Not sending importbuddy.' );
}
*/
// Clear fileoptions so other stuff can access it if needed.
$fileoptions_obj->save();
$fileoptions_obj->unlock();
unset($fileoptions_obj);
// Pass off to destination handler.
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
pb_backupbuddy::status('details', 'Calling destination send() function.');
$send_result = pb_backupbuddy_destinations::send($destination_settings, $file, $identifier, $delete_after);
pb_backupbuddy::status('details', 'Finished destination send() function.');
self::kick_db();
//.........这里部分代码省略.........