本文整理汇总了PHP中backupbuddy_core::get_directory_exclusions方法的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core::get_directory_exclusions方法的具体用法?PHP backupbuddy_core::get_directory_exclusions怎么用?PHP backupbuddy_core::get_directory_exclusions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backupbuddy_core
的用法示例。
在下文中一共展示了backupbuddy_core::get_directory_exclusions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array_merge
*
* Display site site listing on Server Info page.
*
*/
$profile_id = 0;
if (is_numeric(pb_backupbuddy::_GET('profile'))) {
if (isset(pb_backupbuddy::$options['profiles'][pb_backupbuddy::_GET('profile')])) {
$profile_id = pb_backupbuddy::_GET('profile');
pb_backupbuddy::$options['profiles'][pb_backupbuddy::_GET('profile')] = array_merge(pb_backupbuddy::settings('profile_defaults'), pb_backupbuddy::$options['profiles'][pb_backupbuddy::_GET('profile')]);
// Set defaults if not set.
} else {
pb_backupbuddy::alert('Error #45849458b: Invalid profile ID number `' . htmlentities(pb_backupbuddy::_GET('profile')) . '`. Displaying with default profile.', true);
}
}
echo '<!-- profile: ' . $profile_id . ' -->';
$exclusions = backupbuddy_core::get_directory_exclusions(pb_backupbuddy::$options['profiles'][$profile_id]);
$result = pb_backupbuddy::$filesystem->dir_size_map(ABSPATH, ABSPATH, $exclusions, $dir_array);
if (0 == $result) {
pb_backupbuddy::alert('Error #5656653. Unable to access directory map listing for directory `' . ABSPATH . '`.');
die;
}
$total_size = pb_backupbuddy::$options['stats']['site_size'] = $result[0];
$total_size_excluded = pb_backupbuddy::$options['stats']['site_size_excluded'] = $result[1];
pb_backupbuddy::$options['stats']['site_size_updated'] = time();
pb_backupbuddy::save();
arsort($dir_array);
if (pb_backupbuddy::_GET('text') == 'true') {
pb_backupbuddy::$ui->ajax_header();
echo '<h3>' . __('Site Size Listing & Exclusions', 'it-l10n-backupbuddy') . '</h3>';
echo '<textarea style="width:100%; height: 300px; font-family: monospace;" wrap="off">';
echo __('Size + Children', 'it-l10n-backupbuddy') . "\t";
示例2: get_site_size
public static function get_site_size()
{
$exclusions = backupbuddy_core::get_directory_exclusions(pb_backupbuddy::$options['profiles'][0]);
$dir_array = array();
$result = pb_backupbuddy::$filesystem->dir_size_map(ABSPATH, ABSPATH, $exclusions, $dir_array);
unset($dir_array);
// Free this large chunk of memory.
$total_size = pb_backupbuddy::$options['stats']['site_size'] = $result[0];
$total_size_excluded = pb_backupbuddy::$options['stats']['site_size_excluded'] = $result[1];
$total_objects = pb_backupbuddy::$options['stats']['site_objects'] = $result[2];
$total_objects_excluded = pb_backupbuddy::$options['stats']['site_objects_excluded'] = $result[3];
pb_backupbuddy::$options['stats']['site_size_updated'] = time();
pb_backupbuddy::save();
return array($total_size, $total_size_excluded, $total_objects, $total_objects_excluded);
}
示例3: pre_backup
//.........这里部分代码省略.........
}
// Output active plugins list for debugging...
$activePlugins = get_option('active_plugins');
pb_backupbuddy::status('details', 'Active WordPress plugins: `' . implode('; ', $activePlugins) . '`.');
pb_backupbuddy::status('startSubFunction', json_encode(array('function' => 'wp_plugins_found', 'title' => 'Found ' . count($activePlugins) . ' active WordPress plugins.')));
unset($activePlugins);
// Compression to bool.
/*
if ( $profile['compression'] == '1' ) {
$profile['compression'] = true;
} else {
$profile['compression'] = false;
}
*/
if (pb_backupbuddy::$options['compression'] == '1') {
$compression = true;
} else {
$compression = false;
}
$archiveURL = '';
$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());
if (FALSE !== stristr($backup_dir, $abspath)) {
// Make sure file to download is in a publicly accessible location (beneath WP web root technically).
$sitepath = str_replace($abspath, '', $backup_dir);
$archiveURL = rtrim(site_url(), '/\\') . '/' . trim($sitepath, '/\\') . '/' . basename($archiveFile);
}
$forceSingleDatabaseFile = false;
if ('1' == pb_backupbuddy::$options['force_single_db_file']) {
$forceSingleDatabaseFile = true;
}
// Set up the backup data.
$this->_backup = array('data_version' => 1, 'backupbuddy_version' => pb_backupbuddy::settings('version'), 'serial' => $serial, 'init_complete' => false, 'backup_mode' => $profile['backup_mode'], 'type' => $type, 'profile' => $profile, 'default_profile' => pb_backupbuddy::$options['profiles'][0], 'start_time' => time(), 'finish_time' => 0, 'updated_time' => time(), 'status' => array(), 'max_execution_time' => backupbuddy_core::adjustedMaxExecutionTime(), 'archive_size' => 0, 'schedule_title' => $schedule_title, 'backup_directory' => backupbuddy_core::getBackupDirectory(), 'archive_file' => $archiveFile, 'archive_url' => $archiveURL, 'trigger' => $trigger, 'zip_method_strategy' => pb_backupbuddy::$options['zip_method_strategy'], 'compression' => $compression, 'ignore_zip_warnings' => pb_backupbuddy::$options['ignore_zip_warnings'], 'ignore_zip_symlinks' => pb_backupbuddy::$options['ignore_zip_symlinks'], 'steps' => array(), 'integrity' => array(), 'temp_directory' => '', 'backup_root' => '', 'export_plugins' => array(), 'additional_table_includes' => array(), 'additional_table_excludes' => array(), 'directory_exclusions' => backupbuddy_core::get_directory_exclusions($profile, false, $serial), 'table_sizes' => array(), 'breakout_tables' => array(), 'force_single_db_file' => $forceSingleDatabaseFile, 'deployment_log' => '', 'deployment_direction' => $deployDirection, 'deployment_destination' => $deployDestinationSettings, 'runnerUID' => get_current_user_id());
pb_backupbuddy::status('startSubFunction', json_encode(array('function' => 'file_excludes', 'title' => 'Found ' . count($this->_backup['directory_exclusions']) . ' file or directory exclusions.')));
// Warn if excluding key paths.
$alertFileExcludes = backupbuddy_core::alert_core_file_excludes($this->_backup['directory_exclusions']);
foreach ($alertFileExcludes as $alertFileExcludeId => $alertFileExclude) {
pb_backupbuddy::status('warning', $alertFileExclude);
}
pb_backupbuddy::anti_directory_browsing(backupbuddy_core::getTempDirectory(), $die = false);
// Figure out paths.
if ($this->_backup['type'] == 'full' || $this->_backup['type'] == 'files') {
$this->_backup['temp_directory'] = backupbuddy_core::getTempDirectory() . $serial . '/';
$this->_backup['backup_root'] = ABSPATH;
// ABSPATH contains trailing slash.
} elseif ($this->_backup['type'] == 'db') {
$this->_backup['temp_directory'] = backupbuddy_core::getTempDirectory() . $serial . '/';
$this->_backup['backup_root'] = $this->_backup['temp_directory'];
} elseif ($this->_backup['type'] == 'export') {
// WordPress unzips into wordpress subdirectory by default so must include that in path.
$this->_backup['temp_directory'] = backupbuddy_core::getTempDirectory() . $serial . '/wordpress/wp-content/uploads/backupbuddy_temp/' . $serial . '/';
// We store temp data for export within the temporary WordPress installation within the temp directory. A bit confusing; sorry about that.
$this->_backup['backup_root'] = backupbuddy_core::getTempDirectory() . $serial . '/wordpress/';
} else {
pb_backupbuddy::status('error', __('Backup FAILED. Unknown backup type.', 'it-l10n-backupbuddy'));
pb_backupbuddy::status('haltScript', '');
// Halt JS on page.
}
pb_backupbuddy::status('details', 'Temp directory: `' . $this->_backup['temp_directory'] . '`.');
pb_backupbuddy::status('details', 'Backup root: `' . $this->_backup['backup_root'] . '`.');
// Plugins to export (only for MS exports).
if (count($export_plugins) > 0) {
$this->_backup['export_plugins'] = $export_plugins;
}
// Calculate additional database table inclusion/exclusion.
示例4: site_size_listing
public function site_size_listing()
{
$profile_id = 0;
if (is_numeric(pb_backupbuddy::_GET('profile'))) {
if (isset(pb_backupbuddy::$options['profiles'][pb_backupbuddy::_GET('profile')])) {
$profile_id = pb_backupbuddy::_GET('profile');
pb_backupbuddy::$options['profiles'][pb_backupbuddy::_GET('profile')] = array_merge(pb_backupbuddy::settings('profile_defaults'), pb_backupbuddy::$options['profiles'][pb_backupbuddy::_GET('profile')]);
// Set defaults if not set.
} else {
pb_backupbuddy::alert('Error #45849458b: Invalid profile ID number `' . htmlentities(pb_backupbuddy::_GET('profile')) . '`. Displaying with default profile.', true);
}
}
echo '<!-- profile: ' . $profile_id . ' -->';
$exclusions = backupbuddy_core::get_directory_exclusions(pb_backupbuddy::$options['profiles'][$profile_id]);
$result = pb_backupbuddy::$filesystem->dir_size_map(ABSPATH, ABSPATH, $exclusions, $dir_array);
if (0 == $result) {
pb_backupbuddy::alert('Error #5656653. Unable to access directory map listing for directory `' . ABSPATH . '`.');
die;
}
$total_size = pb_backupbuddy::$options['stats']['site_size'] = $result[0];
$total_size_excluded = pb_backupbuddy::$options['stats']['site_size_excluded'] = $result[1];
pb_backupbuddy::$options['stats']['site_size_updated'] = time();
pb_backupbuddy::save();
arsort($dir_array);
if (pb_backupbuddy::_GET('text') == 'true') {
pb_backupbuddy::$ui->ajax_header();
echo '<h3>' . __('Site Size Listing & Exclusions', 'it-l10n-backupbuddy') . '</h3>';
echo '<textarea style="width:100%; height: 300px; font-family: monospace;" wrap="off">';
echo __('Size + Children', 'it-l10n-backupbuddy') . "\t";
echo __('- Exclusions', 'it-l10n-backupbuddy') . "\t";
echo __('Directory', 'it-l10n-backupbuddy') . "\n";
} else {
?>
<style>
.backupbuddy_sizemap_table th {
white-space: nowrap;
}
.backupbuddy_sizemap_table td {
word-break: break-all;
}
</style>
<table class="widefat backupbuddy_sizemap_table">
<thead>
<tr class="thead">
<?php
echo '<th>', __('Directory', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Children', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Exclusions', 'it-l10n-backupbuddy'), '<br><span class="description">Global defaults profile</span></th>';
?>
</tr>
</thead>
<tfoot>
<tr class="thead">
<?php
echo '<th>', __('Directory', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Children', 'it-l10n-backupbuddy'), '</th>', '<th>', __('Size with Exclusions', 'it-l10n-backupbuddy'), '<br><span class="description">Global defaults profile</span></th>';
?>
</tr>
</tfoot>
<tbody>
<?php
}
if (pb_backupbuddy::_GET('text') == 'true') {
echo str_pad(pb_backupbuddy::$format->file_size($total_size), 10, ' ', STR_PAD_RIGHT) . "\t" . str_pad(pb_backupbuddy::$format->file_size($total_size_excluded), 10, ' ', STR_PAD_RIGHT) . "\t" . __('TOTALS', 'it-l10n-backupbuddy') . "\n";
} else {
echo '<tr><td align="right"><b>' . __('TOTALS', 'it-l10n-backupbuddy') . ':</b></td><td><b>' . pb_backupbuddy::$format->file_size($total_size) . '</b></td><td><b>' . pb_backupbuddy::$format->file_size($total_size_excluded) . '</b></td></tr>';
}
$item_count = 0;
foreach ($dir_array as $id => $item) {
// Each $item is in format array( TOTAL_SIZE, TOTAL_SIZE_TAKING_EXCLUSIONS_INTO_ACCOUNT );
$item_count++;
if ($item_count > 100) {
flush();
$item_count = 0;
}
if ($item[1] === false) {
if (pb_backupbuddy::_GET('text') == 'true') {
$excluded_size = 'EXCLUDED';
echo '**';
} else {
$excluded_size = '<span class="pb_label pb_label-important">Excluded</span>';
echo '<tr style="background: #fcc9c9;">';
}
} else {
$excluded_size = pb_backupbuddy::$format->file_size($item[1]);
if (pb_backupbuddy::_GET('text') != 'true') {
echo '<tr>';
}
}
if (pb_backupbuddy::_GET('text') == 'true') {
echo str_pad(pb_backupbuddy::$format->file_size($item[0]), 10, ' ', STR_PAD_RIGHT) . "\t" . str_pad($excluded_size, 10, ' ', STR_PAD_RIGHT) . "\t" . $id . "\n";
} else {
echo '<td>' . $id . '</td><td>' . pb_backupbuddy::$format->file_size($item[0]) . '</td><td>' . $excluded_size . '</td></tr>';
}
}
if (pb_backupbuddy::_GET('text') == 'true') {
echo str_pad(pb_backupbuddy::$format->file_size($total_size), 10, ' ', STR_PAD_RIGHT) . "\t" . str_pad(pb_backupbuddy::$format->file_size($total_size_excluded), 10, ' ', STR_PAD_RIGHT) . "\t" . __('TOTALS', 'it-l10n-backupbuddy') . "\n";
} else {
echo '<tr><td align="right"><b>' . __('TOTALS', 'it-l10n-backupbuddy') . ':</b></td><td><b>' . pb_backupbuddy::$format->file_size($total_size) . '</b></td><td><b>' . pb_backupbuddy::$format->file_size($total_size_excluded) . '</b></td></tr>';
}
if (pb_backupbuddy::_GET('text') == 'true') {
echo "\n\nEXCLUSIONS (" . count($exclusions) . "):" . "\n" . implode("\n", $exclusions);
echo '</textarea>';
//.........这里部分代码省略.........
示例5: _step_update_files_list
private static function _step_update_files_list($custom_root = '', $startAt = 0, $items = array())
{
$start_time = microtime(true);
pb_backupbuddy::status('details', 'Starting to process files; updating files list.');
if (false === self::_load_catalog()) {
return false;
}
if ('' != $custom_root) {
pb_backupbuddy::status('details', 'Scanning custom directory: `' . $custom_root . '`.');
sleep(3);
// Give WordPress time to make thumbnails, etc.
}
if (0 == $startAt && '' == $custom_root) {
// Reset stats when starting from the beginning of a full file scan (not for custom roots).
self::$_state['stats']['files_pending_delete'] = 0;
self::$_state['stats']['files_pending_send'] = 0;
self::$_state['stats']['files_total_count'] = 0;
self::$_state['stats']['files_total_size'] = 0;
}
// Get Live-specific excludes.
$excludes = backupbuddy_live::getOption('file_excludes', true);
// Add standard BB excludes we always apply.
$excludes = array_unique(array_merge(self::$_default_excludes, backupbuddy_core::get_directory_exclusions(pb_backupbuddy::$options['profiles'][0], $trim_suffix = false, $serial = ''), backupbuddy_core::get_directory_exclusions(array('excludes' => $excludes), $trim_suffix = false, $serial = '')));
pb_backupbuddy::status('details', 'Excluding directories: `' . implode(', ', $excludes) . '`.');
// Generate list of files.
if ('' != $custom_root) {
$root = $custom_root;
} else {
$root = ABSPATH;
}
$root = rtrim($root, '/\\');
// Make sure no trailing slash.
$root_len = strlen($root);
$custom_root_diff = '';
if ('' != $custom_root) {
$custom_root_diff = substr($root, strlen(ABSPATH) - 1);
}
$destination_settings = self::get_destination_settings();
pb_backupbuddy::status('details', 'Starting deep file scan.');
$max_time = $destination_settings['max_time'] - self::TIME_WIGGLE_ROOM;
$files = pb_backupbuddy::$filesystem->deepscandir($root, $excludes, $startAt, $items, $start_time, $max_time - 8);
// Additional 5 seconds so that we can add files into catalog after this completes.
if (!is_array($files)) {
backupbuddy_core::addNotification('live_error', 'BackupBuddy Stash Live Error', $files);
pb_backupbuddy::status('error', 'Error #84393434: Halting Stash Live due to error returned by deepscandir: `' . $files . '`.');
return $files;
}
if (false === $files[0]) {
// Format when chunking: array( $finished = false, array( $startAt, $items ) )
pb_backupbuddy::status('details', 'Deep file scan requires chunking.');
return array('File scanning', array($custom_root, $files[1][0], $files[1][1]));
} else {
pb_backupbuddy::status('details', 'Deep file scan complete.');
}
// Remove root from path AND remote directories..
foreach ($files as $i => &$file) {
if (is_dir($file)) {
// Don't track directories, only actual files.
unset($files[$i]);
continue 1;
}
$file = substr($file, $root_len);
}
// Flip array.
$files = array_flip($files);
// Check if this file is already in the list or not.
$filesAdded = 0;
//$addedSinceOutput = 0;
//$outputEvery = 20; // Log every X number of files added into catalog.
foreach ($files as $file => $ignoreID) {
if ('' == $custom_root) {
// Only increment existing files if scanning from root (because stats were reset for fresh count).
self::$_state['stats']['files_total_count']++;
}
$pathed_file = $custom_root_diff . $file;
// Applies custom root portion if applicable.
if (!isset(self::$_catalog[$pathed_file])) {
// File not already in signature list. Add it in with initial values.
if ('' != $custom_root) {
// Was not added earlier yet.
self::$_state['stats']['files_total_count']++;
}
self::$_catalog[$pathed_file] = self::$_signatureDefaults;
self::$_catalog[$pathed_file]['a'] = microtime(true);
$filesAdded++;
self::$_state['stats']['files_pending_send']++;
//$addedSinceOutput++;
/*
if ( ( pb_backupbuddy::$options['log_level'] == '3' ) || ( $addedSinceOutput > $outputEvery ) ) { // Full logging enabled.
pb_backupbuddy::status( 'details', 'Added `' . $addedSinceOutput . '` more files. Last file: `' . $pathed_file . '`.' );
if ( $addedSinceOutput > $outputEvery ) {
$addedSinceOutput = 0;
}
}
*/
if ($filesAdded % 2000 == 0) {
self::$_state['stats']['files_to_catalog_percentage'] = round(number_format($filesAdded / count($files) * 100, 2));
self::$_stateObj->save();
}
if ('3' == pb_backupbuddy::$options['log_level']) {
//.........这里部分代码省略.........