本文整理汇总了PHP中backupbuddy_core::startsWith方法的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core::startsWith方法的具体用法?PHP backupbuddy_core::startsWith怎么用?PHP backupbuddy_core::startsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backupbuddy_core
的用法示例。
在下文中一共展示了backupbuddy_core::startsWith方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deepglob
/**
* pluginbuddy_filesystem->deepglob()
*
* Like the glob() function except walks down into paths to create a full listing of all results in the directory and all subdirectories.
* This is essentially a recursive glob() although it does not use recursion to perform this.
*
* @param string $dir Path to pass to glob and walk through.
* @param array $excludes Array of directories to exclude, relative to the $dir. Include beginning slash.
* @return array Returns array of all matches found.
*/
function deepglob($dir, $excludes = array())
{
$dir = rtrim($dir, '/\\');
// Make sure no trailing slash.
$excludes = str_replace($dir, '', $excludes);
$dir_len = strlen($dir);
$items = glob($dir . '/*');
if (false === $items) {
$items = array();
}
for ($i = 0; $i < count($items); $i++) {
// If this file/directory begins with an exclusion then jump to next file/directory.
foreach ($excludes as $exclude) {
if (backupbuddy_core::startsWith(substr($items[$i], $dir_len), $exclude)) {
unset($items[$i]);
continue 2;
}
}
if (is_dir($items[$i])) {
$add = glob($items[$i] . '/*');
if (false === $add) {
$add = array();
}
$items = array_merge($items, $add);
}
}
return $items;
}
示例2: 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;
}
示例3: hashGlob
public static function hashGlob($root, $generate_sha1 = false, $excludes = array(), $utf8_encode = false)
{
$root = rtrim($root, '/\\');
// Make sure no trailing slash.
$excludes = str_replace($root, '', $excludes);
$files = (array) pb_backupbuddy::$filesystem->deepglob($root);
$root_len = strlen($root);
$hashedFiles = array();
foreach ($files as $file_id => &$file) {
$new_file = substr($file, $root_len);
// If this file/directory begins with an exclusion then jump to next file/directory.
foreach ($excludes as $exclude) {
if (backupbuddy_core::startsWith($new_file, $exclude)) {
continue 2;
}
}
// Omit directories themselves.
if (is_dir($file)) {
continue;
}
$stat = stat($file);
if (FALSE === $stat) {
pb_backupbuddy::status('error', 'Unable to read file `' . $file . '` stat. Skipping file.');
continue;
}
// If the filename is in UTF-8 and the flag is set, encode before using as an array key
if ($utf8_encode && 'UTF-8' == mb_detect_encoding($new_file)) {
$new_file = utf8_encode($new_file);
}
// If the filename is in UTF-8 and the flag is set, encode before using as an array key
if ($utf8_encode && 'UTF-8' == mb_detect_encoding($new_file)) {
$new_file = utf8_encode($new_file);
}
$hashedFiles[$new_file] = array('size' => $stat['size'], 'modified' => $stat['mtime']);
if (defined('BACKUPBUDDY_DEV') && true === BACKUPBUDDY_DEV) {
$hashedFiles[$new_file]['debug_filename'] = base64_encode($file);
$hashedFiles[$new_file]['debug_filelength'] = strlen($file);
}
if (true === $generate_sha1 && $stat['size'] < 1073741824) {
// < 100mb
$hashedFiles[$new_file]['sha1'] = sha1_file($file);
}
unset($files[$file_id]);
// Better to free memory or leave out for performance?
}
unset($files);
return $hashedFiles;
}
示例4: array
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>';
*/
if (!preg_match(pb_backupbuddy_destination_s32::BACKUP_FILENAME_PATTERN, $file['basename']) && 'importbuddy.php' !== $file) {
// Do not display any files that do not appear to be a BackupBuddy backup file (except importbuddy.php).
continue;
}
if ('' != $remotePath && !backupbuddy_core::startsWith(basename($file['filename']), $remotePath)) {
// Only show backups for this site unless set to show all.
continue;
}
$last_modified = $file['uploaded_timestamp'];
$size = (double) $file['size'];
$backup_type = backupbuddy_core::getBackupTypeFromFile($file['filename']);
// Generate array of table rows.
while (isset($backup_list_temp[$last_modified])) {
// Avoid collisions.
$last_modified += 0.1;
}
$backup_list_temp[$last_modified] = array(array(base64_encode($file['url']), $file['filename']), pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($last_modified)) . '<br /><span class="description">(' . pb_backupbuddy::$format->time_ago($last_modified) . ' ago)</span>', pb_backupbuddy::$format->file_size($size), backupbuddy_core::pretty_backup_type($backup_type));
}
krsort($backup_list_temp);
$backup_list = array();