本文整理汇总了PHP中backupbuddy_core::backup_prefix方法的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core::backup_prefix方法的具体用法?PHP backupbuddy_core::backup_prefix怎么用?PHP backupbuddy_core::backup_prefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backupbuddy_core
的用法示例。
在下文中一共展示了backupbuddy_core::backup_prefix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculateArchiveFilename
public function calculateArchiveFilename($serial, $type)
{
// Prepare some values for setting up the backup data.
$siteurl_stripped = backupbuddy_core::backup_prefix();
// Calculate customizable section of archive filename (date vs date+time).
if (pb_backupbuddy::$options['archive_name_format'] == 'datetime') {
// "datetime" = Date + time.
$backupfile_datetime = date(self::ARCHIVE_NAME_FORMAT_DATETIME, pb_backupbuddy::$format->localize_time(time()));
} else {
// "date" = date only (the default).
$backupfile_datetime = date(self::ARCHIVE_NAME_FORMAT_DATE, pb_backupbuddy::$format->localize_time(time()));
}
$archiveFile = backupbuddy_core::getBackupDirectory() . 'backup-' . $siteurl_stripped . '-' . $backupfile_datetime . '-' . $type . '-' . $serial . '.zip';
pb_backupbuddy::status('details', 'Calculated archive file: `' . $archiveFile . '`.');
return $archiveFile;
}
示例2: array
pb_backupbuddy::alert('The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.');
echo '<br>';
pb_backupbuddy::status('details', 'Scheduling Cron for creating S3 copy.');
backupbuddy_core::schedule_single_event(time(), 'process_remote_copy', array('s3', pb_backupbuddy::_GET('cpy_file'), $settings));
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.
}
// Handle download link
if (pb_backupbuddy::_GET('downloadlink_file') != '') {
$link = $s3->get_object($manage_data['bucket'], $remote_path . pb_backupbuddy::_GET('downloadlink_file'), array('preauth' => time() + 3600));
pb_backupbuddy::alert('You may download this backup (' . pb_backupbuddy::_GET('downloadlink_file') . ') with <a href="' . $link . '">this link</a>. The link is valid for one hour.');
echo '<br>';
}
$prefix = backupbuddy_core::backup_prefix();
// Get file listing.
$response = $s3->list_objects($manage_data['bucket'], array('prefix' => $remote_path));
// list all the files in the subscriber account
// Get list of files.
$backup_list_temp = array();
foreach ($response->body->Contents as $object) {
$file = str_ireplace($remote_path, '', $object->Key);
if (FALSE !== stristr($file, '/')) {
// Do NOT display any files within a deeper subdirectory.
continue;
}
if (!preg_match(pb_backupbuddy_destination_s3::BACKUP_FILENAME_PATTERN, $file) && 'importbuddy.php' !== $file) {
// Do not display any files that do not appear to be a BackupBuddy backup file (except importbuddy.php).
continue;
}
示例3: send
public static function send($settings = array(), $files = array(), $send_id = '')
{
$rs_username = $settings['username'];
$rs_api_key = $settings['api_key'];
$rs_container = $settings['container'];
$limit = $settings['archive_limit'];
$rs_server = $settings['server'];
require_once dirname(__FILE__) . '/lib/rackspace/cloudfiles.php';
$auth = new CF_Authentication($rs_username, $rs_api_key, NULL, $rs_server);
$auth->authenticate();
$conn = new CF_Connection($auth);
// Set container
@$conn->create_container($rs_container);
// Create container if it does not exist.
$container = $conn->get_container($rs_container);
// Get container.
foreach ($files as $rs_file) {
pb_backupbuddy::status('details', 'About to create object on Rackspace...');
// Put file to Rackspace.
$sendbackup = $container->create_object(basename($rs_file));
pb_backupbuddy::status('details', 'Object created. About to stream actual file `' . $rs_file . '`...');
if ($sendbackup->load_from_filename($rs_file)) {
pb_backupbuddy::status('details', 'Send succeeded.');
// Start remote backup limit
if ($limit > 0) {
pb_backupbuddy::status('details', 'Archive limit of `' . $limit . '` in settings.');
$bkupprefix = backupbuddy_core::backup_prefix();
$results = $container->get_objects(0, NULL, 'backup-' . $bkupprefix . '-');
// Create array of backups and organize by date
$backups = array();
foreach ($results as $backup) {
$backups[$backup->name] = $backup->last_modified;
}
arsort($backups);
if (count($backups) > $limit) {
pb_backupbuddy::status('details', 'More archives (' . count($backups) . ') than limit (' . $limit . ') allows. Trimming...');
$i = 0;
$delete_fail_count = 0;
foreach ($backups as $buname => $butime) {
$i++;
if ($i > $limit) {
pb_backupbuddy::status('details', 'Trimming excess file `' . $buname . '`...');
if (!$container->delete_object($buname)) {
pb_backupbuddy::status('details', 'Unable to delete excess Rackspace file `' . $buname . '`');
$delete_fail_count++;
}
}
}
if ($delete_fail_count !== 0) {
$error_message = 'Rackspace 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 Rackspace file limit to enforce.');
}
// End remote backup limit
return true;
// Success.
} else {
// Failed.
$error_message = 'ERROR #9025: Connected to Rackspace but unable to put file. Verify Rackspace settings included Rackspace permissions.' . "\n\n" . 'http://ithemes.com/codex/page/BackupBuddy:_Error_Codes#9025';
pb_backupbuddy::status('details', $error_message, 'error');
backupbuddy_core::mail_error(__($error_message, 'it-l10n-backupbuddy'));
return false;
// Failed.
}
}
// end foreach.
}
示例4: send
//.........这里部分代码省略.........
// Schedule next chunk to send.
pb_backupbuddy::status('details', 'Dropbox (PHP 5.3+) scheduling send of next part(s).');
$cronTime = time();
$cronArgs = array($chunked_destination_settings, $files, $send_id, $delete_after);
$cronHashID = md5($cronTime . serialize($cronArgs));
$cronArgs[] = $cronHashID;
if (false === backupbuddy_core::schedule_single_event($cronTime, pb_backupbuddy::cron_tag('destination_send'), $cronArgs)) {
pb_backupbuddy::status('error', 'Error #948844: Unable to schedule next Dropbox2 cron chunk.');
return false;
} else {
pb_backupbuddy::status('details', 'Success scheduling next cron chunk.');
}
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.
pb_backupbuddy::status('details', 'Dropbox (PHP 5.3+) scheduled send of next part(s). Done for this cycle.');
return array($chunked_destination_settings['_chunk_upload_id'], 'Sent 1 of ' . $chunked_destination_settings['_chunk_total_count'] . ' parts.');
} else {
// normal (non-chunked) send.
pb_backupbuddy::status('details', 'Dropbox send not set to be chunked.');
pb_backupbuddy::status('details', 'About to put file `' . basename($file) . '` (' . pb_backupbuddy::$format->file_size($file_size) . ') to Dropbox (PHP 5.3+).');
$send_time = -microtime(true);
try {
$result = self::$_dbxClient->uploadFile($settings['directory'] . '/' . basename($file), dbx\WriteMode::add(), $f);
} catch (\Exception $e) {
pb_backupbuddy::status('error', 'Dropbox Error: ' . $e->getMessage());
return false;
}
$send_time += microtime(true);
@fclose($f);
pb_backupbuddy::status('details', 'About to load fileoptions data.');
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
pb_backupbuddy::status('details', 'Fileoptions instance #14.');
$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;
// Calculate some stats to log.
$data_length = $file_size;
$transfer_speed = $data_length / $send_time;
pb_backupbuddy::status('details', 'Dropbox (non-chunked) transfer stats - Sent: `' . pb_backupbuddy::$format->file_size($data_length) . '`, Transfer duration: `' . $send_time . '`, Speed: `' . pb_backupbuddy::$format->file_size($transfer_speed) . '/sec`.');
$fileoptions['write_speed'] = $transfer_speed;
$fileoptions_obj->save();
unset($fileoptions_obj);
}
// end normal (non-chunked) send.
pb_backupbuddy::status('message', 'Success sending `' . basename($file) . '` to Dropbox!');
// Start remote backup limit
if ($settings['archive_limit'] > 0) {
pb_backupbuddy::status('details', 'Dropbox file limit in place. Proceeding with enforcement.');
$meta_data = self::$_dbxClient->getMetadataWithChildren($settings['directory']);
// Create array of backups and organize by date
$bkupprefix = backupbuddy_core::backup_prefix();
$backups = array();
foreach ((array) $meta_data['contents'] as $looping_file) {
if ($looping_file['is_dir'] == '1') {
// JUST IN CASE. IGNORE anything that is a directory.
continue;
}
// check if file is backup
if (strpos($looping_file['path'], 'backup-' . $bkupprefix . '-') !== false) {
// Appears to be a backup file.
$backups[$looping_file['path']] = strtotime($looping_file['modified']);
}
}
arsort($backups);
if (count($backups) > $settings['archive_limit']) {
pb_backupbuddy::status('details', 'Dropbox backup file count of `' . count($backups) . '` exceeds limit of `' . $settings['archive_limit'] . '`.');
$i = 0;
$delete_fail_count = 0;
foreach ($backups as $buname => $butime) {
$i++;
if ($i > $settings['archive_limit']) {
if (!self::$_dbxClient->delete($buname)) {
// Try to delete backup on Dropbox. Increment failure count if unable to.
pb_backupbuddy::status('details', 'Unable to delete excess Dropbox file: `' . $buname . '`');
$delete_fail_count++;
} else {
pb_backupbuddy::status('details', 'Deleted excess Dropbox file: `' . $buname . '`');
}
}
}
if ($delete_fail_count !== 0) {
backupbuddy_core::mail_error(sprintf(__('Dropbox remote limit could not delete %s backups.', 'it-l10n-backupbuddy'), $delete_fail_count));
}
}
} else {
pb_backupbuddy::status('details', 'No Dropbox file limit to enforce.');
}
// End remote backup limit
}
// end foreach.
pb_backupbuddy::status('details', 'All files sent.');
return true;
// Success if made it this far.
}
示例5: calculateArchiveFilename
public static function calculateArchiveFilename($serial, $type, $profile)
{
// Prepare some values for setting up the backup data.
$siteurl_stripped = backupbuddy_core::backup_prefix();
// Add profile to filename if set in options and exists
if (empty(pb_backupbuddy::$options['archive_name_profile']) || empty($profile['title'])) {
$backupfile_profile = '';
} else {
$backupfile_profile = sanitize_file_name(strtolower($profile['title'])) . '-';
$backupfile_profile = str_replace('/', '_', $backupfile_profile);
$backupfile_profile = str_replace('\\', '_', $backupfile_profile);
$backupfile_profile = str_replace('.', '_', $backupfile_profile);
$backupfile_profile = str_replace(' ', '_', $backupfile_profile);
$backupfile_profile = str_replace('-', '_', $backupfile_profile);
}
// Calculate customizable section of archive filename (date vs date+time).
if (pb_backupbuddy::$options['archive_name_format'] == 'datetime') {
// "datetime" = Date + time.
$backupfile_datetime = date(backupbuddy_constants::ARCHIVE_NAME_FORMAT_DATETIME, pb_backupbuddy::$format->localize_time(time()));
} elseif (pb_backupbuddy::$options['archive_name_format'] == 'datetime24') {
// "datetime" = Date + time in 24hr format.
$backupfile_datetime = date(backupbuddy_constants::ARCHIVE_NAME_FORMAT_DATETIME24, pb_backupbuddy::$format->localize_time(time()));
} elseif (pb_backupbuddy::$options['archive_name_format'] == 'timestamp') {
// "datetime" = Date + time in 24hr format.
$backupfile_datetime = pb_backupbuddy::$format->localize_time(time());
} else {
// "date" = date only (the default).
$backupfile_datetime = date(backupbuddy_constants::ARCHIVE_NAME_FORMAT_DATE, pb_backupbuddy::$format->localize_time(time()));
}
$archiveFile = backupbuddy_core::getBackupDirectory() . 'backup-' . $siteurl_stripped . '-' . $backupfile_datetime . '-' . $backupfile_profile . $type . '-' . $serial . '.zip';
pb_backupbuddy::status('details', 'Calculated archive file: `' . $archiveFile . '`.');
return $archiveFile;
}
示例6: die
<?php
backupbuddy_core::verifyAjaxAccess();
// Directory exclusions picker for settings page.
/* download_archive()
*
* Handle allowing download of archive.
*
* @param
* @return
*/
if (is_multisite() && !current_user_can('manage_network')) {
// If a Network and NOT the superadmin must make sure they can only download the specific subsite backups for security purposes.
// Only allow downloads of their own backups.
if (!strstr(pb_backupbuddy::_GET('backupbuddy_backup'), backupbuddy_core::backup_prefix())) {
die('Access Denied. You may only download backups specific to your Multisite Subsite. Only Network Admins may download backups for another subsite in the network.');
}
}
// Make sure file exists we are trying to get.
if (!file_exists(backupbuddy_core::getBackupDirectory() . pb_backupbuddy::_GET('backupbuddy_backup'))) {
// Does not exist.
die('Error #548957857584784332. The requested backup file does not exist. It may have already been deleted.');
}
$abspath = str_replace('\\', '/', ABSPATH);
// Change slashes to handle Windows as we store backup_directory with Linux-style slashes even on Windows.
$backup_dir = str_replace('\\', '/', backupbuddy_core::getBackupDirectory());
// Make sure file to download is in a publicly accessible location (beneath WP web root technically).
if (FALSE === stristr($backup_dir, $abspath)) {
die('Error #5432532. You cannot download backups stored outside of the WordPress web root. Please use FTP or other means.');
}
// Made it this far so download dir is within this WP install.
示例7: send
public static function send($settings = array(), $files = array(), $send_id = '')
{
global $pb_backupbuddy_destination_errors;
if ('1' == $settings['disabled']) {
$pb_backupbuddy_destination_errors[] = __('Error #48933: This destination is currently disabled. Enable it under this destination\'s Advanced Settings.', 'it-l10n-backupbuddy');
return false;
}
if (!is_array($files)) {
$files = array($files);
}
$token =& $settings['token'];
$directory = '/' . ltrim($settings['directory'], '/\\');
$limit = $settings['archive_limit'];
// Normalize picky dropbox directory.
$directory = trim($directory, '\\/');
pb_backupbuddy::status('details', 'About to load Dropbuddy library...');
require_once pb_backupbuddy::plugin_path() . '/destinations/dropbox/lib/dropbuddy/dropbuddy.php';
pb_backupbuddy::status('details', 'Dropbuddy loaded.');
//pb_backupbuddy::status( 'details', 'Authenticating to dropbox with token: `' . implode( ';', $token ) . '`.' );
$dropbuddy = new pb_backupbuddy_dropbuddy($token);
pb_backupbuddy::status('details', 'Dropbuddy object created.');
if ($dropbuddy->authenticate() !== true) {
pb_backupbuddy::status('details', 'Dropbox authentication failed in send().');
return false;
} else {
pb_backupbuddy::status('details', 'Authenticated to Dropbox.');
}
$memory = pb_backupbuddy_destination_dropbox::memory_guesstimate();
pb_backupbuddy::status('details', 'Dropbox limitation estimated to be max transfer size of ' . round($memory['hypothesis'], 0) . 'MB based on PHP memory limit of ' . $memory['limit'] . 'MB & current loaded WordPress plugins.');
pb_backupbuddy::status('details', 'Looping through files to send to Dropbox.');
foreach ($files as $file) {
pb_backupbuddy::status('details', 'About to put file `' . basename($file) . '` (' . pb_backupbuddy::$format->file_size(filesize($file)) . ') to Dropbox (v1).');
try {
$status = $dropbuddy->put_file($directory . '/' . basename($file), $file);
} catch (Dropbox_Exception $e) {
pb_backupbuddy::status('error', 'Dropbox exception caught. Error #8954785: ' . $e->getMessage());
return false;
}
if ($status === true) {
pb_backupbuddy::status('details', 'SUCCESS sending to Dropbox!');
} else {
pb_backupbuddy::status('details', 'Dropbox file send FAILURE. HTTP Status: ' . $status['httpStatus'] . '; Body: ' . $status['body'], 'error');
return false;
}
// Start remote backup limit
if ($limit > 0) {
pb_backupbuddy::status('details', 'Dropbox file limit in place. Proceeding with enforcement.');
$meta_data = $dropbuddy->get_meta_data($directory);
// Create array of backups and organize by date
$bkupprefix = backupbuddy_core::backup_prefix();
$backups = array();
foreach ((array) $meta_data['contents'] as $looping_file) {
if ('1' == $looping_file['is_dir']) {
// Additional safety layer to ignore subdirectory.
continue;
}
// check if file is backup
if (strpos($looping_file['path'], 'backup-' . $bkupprefix . '-') !== false) {
$backups[$looping_file['path']] = strtotime($looping_file['modified']);
}
}
arsort($backups);
if (count($backups) > $limit) {
pb_backupbuddy::status('details', 'Dropbox backup file count of `' . count($backups) . '` exceeds limit of `' . $limit . '`.');
$i = 0;
$delete_fail_count = 0;
foreach ($backups as $buname => $butime) {
$i++;
if ($i > $limit) {
if (!$dropbuddy->delete($buname)) {
// Try to delete backup on Dropbox. Increment failure count if unable to.
pb_backupbuddy::status('details', 'Unable to delete excess Dropbox file: `' . $buname . '`');
$delete_fail_count++;
}
}
}
if ($delete_fail_count !== 0) {
backupbuddy_core::mail_error(sprintf(__('Dropbox remote limit could not delete %s backups.', 'it-l10n-backupbuddy'), $delete_fail_count));
}
}
} else {
pb_backupbuddy::status('details', 'No Dropbox file limit to enforce.');
}
// End remote backup limit
}
// end foreach.
pb_backupbuddy::status('details', 'All files sent.');
return true;
// Success if made it this far.
}
示例8: send
//.........这里部分代码省略.........
$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.397237. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
return false;
}
pb_backupbuddy::status('details', 'Fileoptions data loaded.');
$fileoptions =& $fileoptions_obj->options;
$fileoptions['_multipart_status'] = 'Sent part ' . $settings['_chunks_sent'] . ' of ~' . $settings['_chunks_total'] . ' parts.';
$fileoptions['finish_time'] = microtime(true);
$fileoptions['status'] = 'success';
$fileoptions_obj->save();
unset($fileoptions_obj);
}
}
}
fclose($fs);
self::$_client->setDefer(false);
if (false == $uploadStatus) {
global $pb_backupbuddy_destination_errors;
$pb_backupbuddy_destination_errors[] = 'Error #84347474 sending. Details: ' . $uploadStatus;
return false;
} else {
// Success.
if (true === $delete_remote_after) {
self::deleteFile($settings, $uploadStatus->id);
}
}
}
// end foreach.
$db_archive_limit = $settings['db_archive_limit'];
$full_archive_limit = $settings['full_archive_limit'];
$files_archive_limit = $settings['files_archive_limit'];
// BEGIN FILE LIMIT PROCESSING. Enforce archive limits if applicable.
if ($backup_type == 'full') {
$limit = $full_archive_limit;
} elseif ($backup_type == 'db') {
$limit = $db_archive_limit;
} elseif ($backup_type == 'files') {
$limit = $files_archive_limit;
} else {
$limit = 0;
pb_backupbuddy::status('warning', 'Warning #34352453244. Google Drive was unable to determine backup type (reported: `' . $backup_type . '`) so archive limits NOT enforced for this backup.');
}
pb_backupbuddy::status('details', 'Google Drive database backup archive limit of `' . $limit . '` of type `' . $backup_type . '` based on destination settings.');
if ($limit > 0) {
pb_backupbuddy::status('details', 'Google Drive archive limit enforcement beginning.');
// Get file listing.
$searchCount = 1;
$remoteFiles = array();
while (count($remoteFiles) == 0 && $searchCount < 5) {
pb_backupbuddy::status('details', 'Checking archive limits. Attempt ' . $searchCount . '.');
$remoteFiles = pb_backupbuddy_destination_gdrive::listFiles($settings, "title contains 'backup-' AND title contains '-" . $backup_type . "-' AND '" . $folderID . "' IN parents AND trashed=false");
//"title contains 'backup' and trashed=false" );
sleep(1);
$searchCount++;
}
// List backups associated with this site by date.
$backups = array();
$prefix = backupbuddy_core::backup_prefix();
foreach ($remoteFiles as $remoteFile) {
if ('application/vnd.google-apps.folder' == $remoteFile->mimeType) {
// Ignore folders.
continue;
}
if (strpos($remoteFile->originalFilename, 'backup-' . $prefix . '-') !== false) {
// Appears to be a backup file for this site.
$backups[$remoteFile->id] = strtotime($remoteFile->modifiedDate);
}
}
arsort($backups);
pb_backupbuddy::status('details', 'Google Drive found `' . count($backups) . '` backups of this type when checking archive limits.');
if (count($backups) > $limit) {
pb_backupbuddy::status('details', 'More archives (' . count($backups) . ') than limit (' . $limit . ') allows. Trimming...');
$i = 0;
$delete_fail_count = 0;
foreach ($backups as $buname => $butime) {
$i++;
if ($i > $limit) {
pb_backupbuddy::status('details', 'Trimming excess file `' . $buname . '`...');
if (true !== self::deleteFile($settings, $buname)) {
pb_backupbuddy::status('details', 'Unable to delete excess Google Drive file `' . $buname . '`. Details: `' . print_r($pb_backupbuddy_destination_errors, true) . '`.');
$delete_fail_count++;
}
}
}
pb_backupbuddy::status('details', 'Finished trimming excess backups.');
if ($delete_fail_count !== 0) {
$error_message = 'Google Drive remote limit could not delete ' . $delete_fail_count . ' backups.';
pb_backupbuddy::status('error', $error_message);
backupbuddy_core::mail_error($error_message);
}
}
pb_backupbuddy::status('details', 'Google Drive completed archive limiting.');
} else {
pb_backupbuddy::status('details', 'No Google Drive archive file limit to enforce.');
}
// End remote backup limit
// Made it this far then success.
return true;
}
示例9: spawn_cron
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.
}
// end copying to local.
// Handle download link
if (pb_backupbuddy::_GET('downloadlink_file') != '') {
$link = pb_backupbuddy_destination_s32::getFileURL($settings, pb_backupbuddy::_GET('downloadlink_file'));
pb_backupbuddy::alert('You may download this backup (' . pb_backupbuddy::_GET('downloadlink_file') . ') with <a href="' . $link . '">this link</a>. The link is valid for one hour.');
echo '<br>';
}
// end download link.
// Get list of files for this site.
if ('true' != pb_backupbuddy::_GET('listAll')) {
$remotePath = $settings['directory'] . 'backup-' . backupbuddy_core::backup_prefix();
} else {
$remotePath = $settings['directory'];
}
$files = pb_backupbuddy_destination_s32::listFiles($settings, $remotePath);
if (!is_array($files)) {
die('Error listing files: `' . $files . '`.');
}
$backup_list_temp = array();
foreach ($files as $object) {
$file = str_ireplace($settings['directory'], '', $object['Key']);
if (FALSE !== stristr($file, '/')) {
// Do NOT display any files within a deeper subdirectory.
continue;
}
if (!preg_match(pb_backupbuddy_destination_s32::BACKUP_FILENAME_PATTERN, $file) && 'importbuddy.php' !== $file) {
示例10: array
if ('0' == $destination['disable_file_management']) {
$stashDestination = $destination_id;
break;
} else {
pb_backupbuddy::alert('A Stash destination was found but deployment functionality has been disabled for it. It is not available for deployment features.');
}
}
}
$deployments = array(array('siteurl' => 'http://destsite.com/', 'destination' => 0, 'importSettings' => array()));
if ('' != pb_backupbuddy::_GET('deploy')) {
if (!wp_verify_nonce(pb_backupbuddy::_GET('_wpnonce'), 'backupbuddy_deploy_toggle')) {
die('Access Denied. Invalid NONCE.');
}
if ('enable' == pb_backupbuddy::_GET('deploy')) {
$identifier = pb_backupbuddy::random_string(12);
$deployFile = backupbuddy_core::getTempDirectory() . 'deploy-' . backupbuddy_core::backup_prefix() . '.dat';
// . '-' . $identifier .
$meta = array('siteurl' => site_url(), 'deployEnabled' => time());
$deployFileContents = json_encode($meta);
pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
if (false === file_put_contents($deployFile, $deployFileContents)) {
pb_backupbuddy::alert('Error #848383: Unable to write temporary deployment file `' . $deployFile . '`. Verify permissions on the directory.');
} else {
$destinationSettings = pb_backupbuddy::$options['remote_destinations'][$stashDestination];
$destinationSettings['meta'] = $meta;
$destinationSettings['forceRootUpload'] = true;
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
$send_result = pb_backupbuddy_destinations::send($destinationSettings, array($deployFile), $identifier, $delete_after = true);
if (true === $send_result) {
pb_backupbuddy::$options['deployment_allowed'] = '1';
pb_backupbuddy::save();
示例11: array
backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('process_remote_copy'), array('stash2', $file, $settings));
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.
}
// end copying to local.
// Handle download link
if (pb_backupbuddy::_GET('downloadlink_file') != '') {
pb_backupbuddy::alert('Download the selected backup file with <a href="' . esc_url(base64_decode(pb_backupbuddy::_GET('downloadlink_file'))) . '">this link</a>. The link is valid for one hour.');
echo '<br>';
}
// end download link.
// Get list of files for this site.
if ('true' != pb_backupbuddy::_GET('listAll')) {
$remotePath = 'backup-' . backupbuddy_core::backup_prefix();
} else {
$remotePath = '';
}
$files = pb_backupbuddy_destination_stash2::listFiles($settings, $remotePath);
if (!is_array($files)) {
pb_backupbuddy::alert('Error: ' . $files);
die;
}
$backup_list_temp = array();
foreach ((array) $files as $file) {
/*
echo '<br><pre>';
print_r( $file );
echo '</pre>';
*/
示例12: print_r
<?php
backupbuddy_core::verifyAjaxAccess();
require pb_backupbuddy::plugin_path() . '/destinations/live/_troubleshooting.php';
backupbuddy_live_troubleshooting::run();
$output = "**File best viewed with wordwrap OFF**\n\n" . print_r(backupbuddy_live_troubleshooting::get_raw_results(), true);
header('Content-Description: File Transfer');
header('Content-Type: text/plain; name=backupbuddy-live_troubleshooting-' . backupbuddy_core::backup_prefix() . '.txt');
header('Content-Disposition: attachment; filename=backupbuddy-live_troubleshooting-' . backupbuddy_core::backup_prefix() . '.txt');
header('Expires: 0');
header('Content-Length: ' . strlen($output));
pb_backupbuddy::flush();
echo $output;
pb_backupbuddy::flush();
die;
示例13: archiveLimit
public static function archiveLimit($settings, $backup_type)
{
$settings = self::_init($settings);
pb_backupbuddy::status('error', 'Error #8339832893: TODO archiveLimit().');
if ($backup_type == 'full') {
$limit = $settings['full_archive_limit'];
pb_backupbuddy::status('details', 'Full backup archive limit of `' . $limit . '` of type `full` based on destination settings.');
} elseif ($backup_type == 'db') {
$limit = $settings['db_archive_limit'];
pb_backupbuddy::status('details', 'Database backup archive limit of `' . $limit . '` of type `db` based on destination settings.');
} elseif ($backup_type == 'files') {
$limit = $settings['files_archive_limit'];
pb_backupbuddy::status('details', 'Database backup archive limit of `' . $limit . '` of type `files` based on destination settings.');
} else {
$limit = 0;
pb_backupbuddy::status('warning', 'Warning #237332. Unable to determine backup type (reported: `' . $backup_type . '`) so archive limits NOT enforced for this backup.');
}
if ($limit > 0) {
pb_backupbuddy::status('details', 'Archive limit enforcement beginning.');
// Get file listing.
$files = self::listFiles($settings, $prefix = '');
if (!is_array($files)) {
pb_backupbuddy::status('Error #3892383: Unable to list files. Skipping archive limiting.');
return false;
}
$remotePath = 'backup-' . backupbuddy_core::backup_prefix();
$prefixLen = strlen(backupbuddy_core::backup_prefix());
// List backups associated with this site by date.
$backups = array();
foreach ($files as $file) {
if ($file['backup_type'] != $backup_type) {
continue;
}
if (!backupbuddy_core::startsWith(basename($file['filename']), $remotePath)) {
// Only show backups for this site unless set to show all.
continue;
}
$backups[$file['filename']] = $file['uploaded_timestamp'];
}
unset($files);
arsort($backups);
pb_backupbuddy::status('details', 'Found `' . count($backups) . '` backups of this type when checking archive limits.');
if (count($backups) > $limit) {
pb_backupbuddy::status('details', 'More archives (' . count($backups) . ') than limit (' . $limit . ') allows. Trimming...');
$i = 0;
$delete_fail_count = 0;
foreach ($backups as $buname => $butime) {
$i++;
if ($i > $limit) {
pb_backupbuddy::status('details', 'Trimming excess file `' . $buname . '`...');
$delete_response = self::deleteFile($settings, substr($buname, $prefixLen + 1));
if (true !== $delete_response) {
self::_error('Unable to delete excess Stash file `' . $buname . '`. Details: `' . $delete_response . '`.');
$delete_fail_count++;
}
}
}
// end foreach.
pb_backupbuddy::status('details', 'Finished trimming excess backups.');
if ($delete_fail_count !== 0) {
$error_message = 'Stash remote limit could not delete ' . $delete_fail_count . ' backups.';
pb_backupbuddy::status('error', $error_message);
backupbuddy_core::mail_error($error_message);
}
}
pb_backupbuddy::status('details', 'Stash completed archive limiting.');
} else {
pb_backupbuddy::status('details', 'No Stash archive file limit to enforce.');
}
// End remote backup limit
return true;
}
示例14: download_archive
public function download_archive()
{
if (is_multisite() && !current_user_can('manage_network')) {
// If a Network and NOT the superadmin must make sure they can only download the specific subsite backups for security purposes.
// Only allow downloads of their own backups.
if (!strstr(pb_backupbuddy::_GET('backupbuddy_backup'), backupbuddy_core::backup_prefix())) {
die('Access Denied. You may only download backups specific to your Multisite Subsite. Only Network Admins may download backups for another subsite in the network.');
}
}
// Make sure file exists we are trying to get.
if (!file_exists(backupbuddy_core::getBackupDirectory() . pb_backupbuddy::_GET('backupbuddy_backup'))) {
// Does not exist.
die('Error #548957857584784332. The requested backup file does not exist. It may have already been deleted.');
}
$abspath = str_replace('\\', '/', ABSPATH);
// Change slashes to handle Windows as we store backup_directory with Linux-style slashes even on Windows.
$backup_dir = str_replace('\\', '/', backupbuddy_core::getBackupDirectory());
// Make sure file to download is in a publicly accessible location (beneath WP web root technically).
if (FALSE === stristr($backup_dir, $abspath)) {
die('Error #5432532. You cannot download backups stored outside of the WordPress web root. Please use FTP or other means.');
}
// Made it this far so download dir is within this WP install.
$sitepath = str_replace($abspath, '', $backup_dir);
$download_url = rtrim(site_url(), '/\\') . '/' . trim($sitepath, '/\\') . '/' . pb_backupbuddy::_GET('backupbuddy_backup');
if (pb_backupbuddy::$options['lock_archives_directory'] == '1') {
// High security mode.
if (file_exists(backupbuddy_core::getBackupDirectory() . '.htaccess')) {
$unlink_status = @unlink(backupbuddy_core::getBackupDirectory() . '.htaccess');
if ($unlink_status === false) {
die('Error #844594. Unable to temporarily remove .htaccess security protection on archives directory to allow downloading. Please verify permissions of the BackupBuddy archives directory or manually download via FTP.');
}
}
header('Location: ' . $download_url);
ob_clean();
flush();
sleep(8);
// Wait 8 seconds before creating security file.
$htaccess_creation_status = @file_put_contents(backupbuddy_core::getBackupDirectory() . '.htaccess', 'deny from all');
if ($htaccess_creation_status === false) {
die('Error #344894545. Security Warning! Unable to create security file (.htaccess) in backups archive directory. This file prevents unauthorized downloading of backups should someone be able to guess the backup location and filenames. This is unlikely but for best security should be in place. Please verify permissions on the backups directory.');
}
} else {
// Normal mode.
header('Location: ' . $download_url);
}
die;
}
示例15: pre_backup
function pre_backup($serial, $profile, $trigger, $pre_backup = array(), $post_backup = array(), $schedule_title = '', $export_plugins = array())
{
pb_backupbuddy::status('action', 'start_function^pre_backup^Getting ready to backup');
$type = $profile['type'];
// Log some status information.
pb_backupbuddy::status('details', __('Performing pre-backup procedures.', 'it-l10n-backupbuddy'));
if ($type == 'full') {
pb_backupbuddy::status('message', __('Full backup mode.', 'it-l10n-backupbuddy'));
} elseif ($type == 'db') {
pb_backupbuddy::status('message', __('Database only backup mode.', 'it-l10n-backupbuddy'));
} elseif ($type == 'files') {
pb_backupbuddy::status('message', __('Files only backup mode.', 'it-l10n-backupbuddy'));
//$profile['skip_database_dump'] = '1';
} elseif ($type == 'export') {
pb_backupbuddy::status('message', __('Multisite Site Export mode.', 'it-l10n-backupbuddy'));
} else {
pb_backupbuddy::status('error', __('Error #8587383: Unknown backup mode.', 'it-l10n-backupbuddy')) . 'Supplied backup type: `' . htmlentities($type) . '`.';
}
if ('1' == pb_backupbuddy::$options['prevent_flush']) {
pb_backupbuddy::status('details', 'Flushing will be skipped based on advanced settings.');
} else {
pb_backupbuddy::status('details', 'Flushing will not be skipped (default).');
}
// Schedule daily housekeeping.
if (false === wp_next_scheduled(pb_backupbuddy::cron_tag('housekeeping'))) {
// if schedule does not exist...
backupbuddy_core::schedule_event(time() + 60 * 60 * 2, 'daily', pb_backupbuddy::cron_tag('housekeeping'), array());
// Add schedule.
}
// Verify directories.
pb_backupbuddy::status('details', 'Verifying directories ...');
if (false === backupbuddy_core::verify_directories()) {
pb_backupbuddy::status('error', 'Error #18573. Error verifying directories. See details above. Backup halted.');
pb_backupbuddy::status('action', 'halt_script');
// Halt JS on page.
die;
} else {
pb_backupbuddy::status('details', 'Directories verified.');
}
// Delete all backup archives if this troubleshooting option is enabled.
if (pb_backupbuddy::$options['delete_archives_pre_backup'] == '1') {
pb_backupbuddy::status('message', 'Deleting all existing backups prior to backup as configured on the settings page.');
$file_list = glob(backupbuddy_core::getBackupDirectory() . 'backup*.zip');
if (is_array($file_list) && !empty($file_list)) {
foreach ($file_list as $file) {
if (@unlink($file) === true) {
pb_backupbuddy::status('details', 'Deleted backup archive `' . basename($file) . '` based on settings to delete all backups.');
} else {
pb_backupbuddy::status('details', 'Unable to delete backup archive `' . basename($file) . '` based on settings to delete all backups. Verify permissions.');
}
}
}
}
// Generate unique serial ID.
pb_backupbuddy::status('details', 'Backup serial generated: `' . $serial . '`.');
pb_backupbuddy::status('details', 'About to load fileoptions data in create mode.');
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
$this->_backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = false, $ignore_lock = false, $create_file = true);
if (true !== ($result = $this->_backup_options->is_ok())) {
pb_backupbuddy::status('error', __('Fatal Error #9034 A. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
pb_backupbuddy::status('action', 'halt_script');
// Halt JS on page.
return false;
}
pb_backupbuddy::status('details', 'Fileoptions data loaded.');
$this->_backup =& $this->_backup_options->options;
// Set reference.
// Cleanup internal stats.
pb_backupbuddy::status('details', 'Resetting statistics for last backup time and number of edits since last backup.');
pb_backupbuddy::$options['last_backup_start'] = time();
// Reset time since last backup.
pb_backupbuddy::$options['edits_since_last'] = 0;
// Reset edit stats for notifying user of how many posts/pages edited since last backup happened.
pb_backupbuddy::$options['last_backup_serial'] = $serial;
pb_backupbuddy::save();
// Output active plugins list for debugging...
$activePlugins = get_option('active_plugins');
pb_backupbuddy::status('details', 'Active WordPress plugins: `' . implode('; ', $activePlugins) . '`.');
pb_backupbuddy::status('action', 'start_subfunction^wp_plugins_found^Found ' . count($activePlugins) . ' active WordPress plugins.');
unset($activePlugins);
// Prepare some values for setting up the backup data.
$siteurl_stripped = backupbuddy_core::backup_prefix();
// Calculate customizable section of archive filename (date vs date+time).
if (pb_backupbuddy::$options['archive_name_format'] == 'datetime') {
// "datetime" = Date + time.
$backupfile_datetime = date(self::ARCHIVE_NAME_FORMAT_DATETIME, pb_backupbuddy::$format->localize_time(time()));
} else {
// "date" = date only (the default).
$backupfile_datetime = date(self::ARCHIVE_NAME_FORMAT_DATE, pb_backupbuddy::$format->localize_time(time()));
}
// Compression to bool.
/*
if ( $profile['compression'] == '1' ) {
$profile['compression'] = true;
} else {
$profile['compression'] = false;
}
*/
if (pb_backupbuddy::$options['compression'] == '1') {
$compression = true;
//.........这里部分代码省略.........