本文整理汇总了PHP中backupbuddy_core类的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core类的具体用法?PHP backupbuddy_core怎么用?PHP backupbuddy_core使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了backupbuddy_core类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stats
function stats()
{
echo '<style type="text/css">';
echo ' .pb_fancy {';
echo ' font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;';
echo ' font-size: 18px;';
echo ' color: #21759B;';
echo ' }';
echo '</style>';
echo '<div>';
$backup_url = 'admin.php?page=pb_backupbuddy_backup';
$files = glob(backupbuddy_core::getBackupDirectory() . 'backup*.zip');
if (!is_array($files) || empty($files)) {
$files = array();
}
echo sprintf(__('You currently have %s stored backups.', 'it-l10n-backupbuddy'), '<span class="pb_fancy"><a href="' . $backup_url . '">' . count($files) . '</a></span>');
if (pb_backupbuddy::$options['last_backup_finish'] == 0) {
echo ' ', __('You have not successfully created any backups.', 'it-l10n-backupbuddy');
} else {
echo ' ', sprintf(__(' Your most recent successful backup was %s ago.', 'it-l10n-backupbuddy'), '<span class="pb_fancy"><a href="' . $backup_url . '">' . pb_backupbuddy::$format->time_ago(pb_backupbuddy::$options['last_backup_finish']) . '</a></span>');
}
echo ' ', sprintf(__('There have been %s post/page modifications since your last backup.', 'it-l10n-backupbuddy'), '<span class="pb_fancy"><a href="' . $backup_url . '">' . pb_backupbuddy::$options['edits_since_last'] . '</a></span>');
echo ' <span class="pb_fancy"><a href="' . $backup_url . '">', __('Go create a backup!', 'it-l10n-backupbuddy'), '</a></span>';
echo '</div>';
}
示例2: test
public static function test($settings)
{
$email = $settings['address'];
pb_backupbuddy::status('details', 'Testing email destination. Sending ImportBuddy.php.');
$importbuddy_temp = backupbuddy_core::getTempDirectory() . 'importbuddy_' . pb_backupbuddy::random_string(10) . '.php.tmp';
// Full path & filename to temporary importbuddy
backupbuddy_core::importbuddy($importbuddy_temp);
// Create temporary importbuddy.
$files = array($importbuddy_temp);
if (pb_backupbuddy::$options['email_return'] != '') {
$email_return = pb_backupbuddy::$options['email_return'];
} else {
$email_return = get_option('admin_email');
}
$headers = 'From: BackupBuddy <' . $email_return . '>' . "\r\n";
$wp_mail_result = wp_mail($email, 'BackupBuddy Test', 'BackupBuddy destination test for ' . site_url(), $headers, $files);
pb_backupbuddy::status('details', 'Sent test email.');
@unlink($importbuddy_temp);
if ($wp_mail_result === true) {
// WP sent. Hopefully it makes it!
return true;
} else {
// WP couldn't try to send.
echo 'WordPress was unable to attempt to send email. Check your WordPress & server settings.';
return false;
}
}
示例3: generate_queue
public function generate_queue($root = '', $generate_sha1 = true)
{
if ($root == '') {
$root = backupbuddy_core::getLogDirectory();
}
echo 'mem:' . memory_get_usage(true) . '<br>';
$files = (array) pb_backupbuddy::$filesystem->deepglob($root);
echo 'mem:' . memory_get_usage(true) . '<br>';
$root_len = strlen($root);
$new_files = array();
foreach ($files as $file_id => &$file) {
$stat = stat($file);
if (FALSE === $stat) {
pb_backupbuddy::status('error', 'Unable to read file `' . $file . '` stat.');
}
$new_file = substr($file, $root_len);
$sha1 = '';
if (true === $generate_sha1 && $stat['size'] < 1073741824) {
// < 100mb
$sha1 = sha1_file($file);
}
$new_files[$new_file] = array('scanned' => time(), 'size' => $stat['size'], 'modified' => $stat['mtime'], 'sha1' => $sha1);
unset($files[$file_id]);
// Better to free memory or leave out for performance?
}
unset($files);
echo 'mem:' . memory_get_usage(true) . '<br>';
function pb_queuearray_size_compare($a, $b)
{
return $a['size'] > $b['size'];
}
uasort($new_files, 'pb_queuearray_size_compare');
echo '<pre>';
print_r($new_files);
echo '</pre>';
// fileoptions file live_signatures.txt
//backupbuddy_core::st_stable_options( 'xxx', 'test', 5 );
// get file listing of site: glob and store in an array
// open previously generated master list (master file listing since last queue generation).
// loop through and compare file specs to specs in master list. ( anything changed AND not yet in queue AND not maxed out send attempts ) gets added into $queue_files[];
// add master file to end of list so it will be backed up as soon files are finished sending. to keep it up to date.
// sort list smallest to largest
// store in $queue_files[] in format:
/*
array(
'size' => 434344,
'attempts' => 0,
);
*/
// open current queue file (if exists)
// combine new files into queue
// serialize $queue_files
// base64 encode
// write to queue file
pb_backupbuddy::status('details', '12 new or modified files added into Stash queue.');
// Schedule process_queue() to run in 30 seconds from now _IF_ not already scheduled to run.
}
示例4: run
public function run($arguments)
{
$arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
pb_backupbuddy::$options['remote_destinations'][] = $arguments['settings'];
pb_backupbuddy::save();
$newDestination = array();
$newDestination['title'] = $arguments['settings']['title'];
$newDestination['type'] = $arguments['settings']['type'];
backupbuddy_core::addNotification('destination_created', 'Remote destination created', 'A new remote destination "' . $newDestination['title'] . '" has been created.', $newDestination);
$highest_destination_index = end(array_keys(pb_backupbuddy::$options['remote_destinations']));
return array('api' => '1', 'status' => 'ok', 'message' => 'Destination added.', 'destination_id' => $highest_destination_index);
}
示例5: bb_build_remote_destinations
function bb_build_remote_destinations($destinations_list)
{
$remote_destinations = explode('|', $destinations_list);
$remote_destinations_html = '';
foreach ($remote_destinations as $destination) {
if (isset($destination) && $destination != '') {
$remote_destinations_html .= '<li id="pb_remotedestination_' . $destination . '">';
if (!isset(pb_backupbuddy::$options['remote_destinations'][$destination])) {
$remote_destinations_html .= '{destination no longer exists}';
} else {
$remote_destinations_html .= pb_backupbuddy::$options['remote_destinations'][$destination]['title'];
$remote_destinations_html .= ' (' . backupbuddy_core::pretty_destination_type(pb_backupbuddy::$options['remote_destinations'][$destination]['type']) . ') ';
}
$remote_destinations_html .= '<img class="pb_remotedestionation_delete" src="' . pb_backupbuddy::plugin_url() . '/images/redminus.png" style="vertical-align: -3px; cursor: pointer;" title="' . __('Remove remote destination from this schedule.', 'it-l10n-backupbuddy') . '" />';
$remote_destinations_html .= '</li>';
}
}
$remote_destinations = '<ul id="pb_backupbuddy_remotedestinations_list">' . $remote_destinations_html . '</ul>';
return $remote_destinations;
}
示例6: shutdown_function
function shutdown_function()
{
// Get error message.
// Error types: http://php.net/manual/en/errorfunc.constants.php
$e = error_get_last();
if ($e === NULL) {
// No error of any kind.
return;
} else {
// Some type of error.
if (!is_array($e) || $e['type'] != E_ERROR && $e['type'] != E_USER_ERROR) {
// Return if not a fatal error.
//echo '<!-- ' . print_r( $e, true ) . ' -->' . "\n";
return;
}
}
// Calculate log directory.
$log_directory = backupbuddy_core::getLogDirectory();
// Also handle when in importbuddy.
$main_file = $log_directory . 'log-' . pb_backupbuddy::$options['log_serial'] . '.txt';
// Determine if writing to a serial log.
if (pb_backupbuddy::$_status_serial != '') {
$serial = pb_backupbuddy::$_status_serial;
$serial_file = $log_directory . 'status-' . $serial . '_' . pb_backupbuddy::$options['log_serial'] . '.txt';
$write_serial = true;
} else {
$write_serial = false;
}
// Format error message.
$e_string = '----- FATAL ERROR ----- A fatal PHP error was encountered: ';
foreach ((array) $e as $e_line_title => $e_line) {
$e_string .= $e_line_title . ' => ' . $e_line . "; ";
}
$e_string = rtrim($e_string, '; ') . '.';
// Write to log.
@file_put_contents($main_file, $e_string, FILE_APPEND);
// IMPORTBUDDY
$status = pb_backupbuddy::$format->date(time()) . "\t" . sprintf("%01.2f", round(microtime(true) - pb_backupbuddy::$start_time, 2)) . "\t" . sprintf("%01.2f", round(memory_get_peak_usage() / 1048576, 2)) . "\t" . 'error' . "\t\t" . str_replace(chr(9), ' ', $e_string);
$status = str_replace('\\', '/', $status);
echo '<script type="text/javascript">pb_status_append("' . str_replace('"', '"', $status) . '");</script>';
}
示例7: run
public function run($arguments)
{
$arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
if ('' == $arguments['password']) {
// no password send in arguments.
if (!isset(pb_backupbuddy::$options)) {
pb_backupbuddy::load();
}
if ('' == pb_backupbuddy::$options['importbuddy_pass_hash']) {
// no default password is set on Settings page.
return array('api' => '0', 'status' => 'error', 'message' => 'No ImportBuddy password was entered and no default has been set on the Settings page.');
} else {
// Use default.
$importbuddy_pass_hash = pb_backupbuddy::$options['importbuddy_pass_hash'];
}
} else {
// Password passed in arguments.
$importbuddy_pass_hash = md5($arguments['password']);
}
require_once pb_backupbuddy::plugin_path() . '/classes/core.php';
return array('api' => '4', 'status' => 'ok', 'message' => 'ImportBuddy retrieved.', 'importbuddy' => base64_encode(backupbuddy_core::importbuddy('', $importbuddy_pass_hash, $returnNotEcho = true)));
}
示例8: get_archives_list
/**
* get_archives_list()
*
* Returns an array of backup archive zip filenames found.
*
* @return array Array of .zip filenames; path NOT included.
*/
function get_archives_list()
{
Auth::require_authentication();
if (!isset(pb_backupbuddy::$classes['zipbuddy'])) {
require_once pb_backupbuddy::plugin_path() . '/lib/zipbuddy/zipbuddy.php';
pb_backupbuddy::$classes['zipbuddy'] = new pluginbuddy_zipbuddy(ABSPATH);
}
// List backup files in this directory.
$backup_archives = array();
$backup_archives_glob = glob(ABSPATH . 'backup*.zip');
if (!is_array($backup_archives_glob) || empty($backup_archives_glob)) {
// On failure glob() returns false or an empty array depending on server settings so normalize here.
$backup_archives_glob = array();
}
foreach ($backup_archives_glob as $backup_archive) {
$comment = pb_backupbuddy::$classes['zipbuddy']->get_comment($backup_archive);
$comment = backupbuddy_core::normalize_comment_data($comment);
$this_archive = array('file' => basename($backup_archive), 'comment' => $comment);
$backup_archives[] = $this_archive;
}
unset($backup_archives_glob);
return $backup_archives;
}
示例9: wipePrefix
/**
* wipePrefix()
*
* Clear out tables matching supplied prefix.
*
* @return boolean Currently always true.
*/
function wipePrefix($prefix, $confirm = false)
{
if ($confirm !== true) {
die('Error #5466566b: Parameter 2 to wipePrefix() must be boolean true to proceed.');
}
if ($prefix == '') {
pb_backupbuddy::status('warning', 'No database prefix specified to wipe.');
return false;
}
pb_backupbuddy::status('message', 'Beginning wipe of database tables matching prefix `' . $prefix . '`...');
// Connect to database.
//$this->connect_database();
global $wpdb;
$rows = $wpdb->get_results("SELECT table_name FROM information_schema.tables WHERE table_name LIKE '" . backupbuddy_core::dbEscape(str_replace('_', '\\_', $prefix)) . "%' AND table_schema = DATABASE()", ARRAY_A);
$table_wipe_count = count($rows);
foreach ($rows as $row) {
pb_backupbuddy::status('details', 'Dropping table `' . $row['table_name'] . '`.');
$wpdb->query('DROP TABLE `' . $row['table_name'] . '`');
}
unset($rows);
pb_backupbuddy::status('message', 'Wiped database of ' . $table_wipe_count . ' tables.');
return true;
}
示例10: _priorRollbackCleanup
private function _priorRollbackCleanup()
{
$this->_before(__FUNCTION__);
pb_backupbuddy::status('details', 'Checking for any prior failed rollback data to clean up.');
global $wpdb;
$shortSerial = substr($this->_state['serial'], 0, 4);
// NEW prefix
$sql = "SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'BBnew-" . $shortSerial . "\\_%' AND table_schema = DATABASE()";
$results = $wpdb->get_results($sql, ARRAY_A);
pb_backupbuddy::status('details', 'Found ' . count($results) . ' tables to drop with the prefix `BBnew-' . $shortSerial . '_`.');
$dropCount = 0;
foreach ($results as $result) {
if (false === $wpdb->query("DROP TABLE `" . backupbuddy_core::dbEscape($result['table_name']) . "`")) {
$this->_error('Unable to delete table `' . $result['table_name'] . '`.');
} else {
$dropCount++;
}
}
pb_backupbuddy::status('details', 'Dropped `' . $dropCount . '` new tables.');
// OLD prefix
$sql = "SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'BBold-" . $shortSerial . "\\_%' AND table_schema = DATABASE()";
$results = $wpdb->get_results($sql, ARRAY_A);
pb_backupbuddy::status('details', 'Found ' . count($results) . ' tables to drop with the prefix `BBold-' . $shortSerial . '_`.');
$dropCount = 0;
foreach ($results as $result) {
if (false === $wpdb->query("DROP TABLE `" . backupbuddy_core::dbEscape($result['table_name']) . "`")) {
$this->_error('Unable to delete table `' . $result['table_name'] . '`.');
} else {
$dropCount++;
}
}
pb_backupbuddy::status('details', 'Dropped `' . $dropCount . '` old tables.');
pb_backupbuddy::status('details', 'Finished prior rollback cleanup.');
}
示例11: add_action
// Register BackupBuddy API. As of BackupBuddy v5.0. Access credentials will be checked within callback.
add_action('wp_ajax_backupbuddy_api', array(pb_backupbuddy::$_ajax, 'api'));
add_action('wp_ajax_nopriv_backupbuddy_api', array(pb_backupbuddy::$_ajax, 'api'));
/********** DASHBOARD (admin) **********/
// Display stats in Dashboard.
//if ( pb_backupbuddy::$options['dashboard_stats'] == '1' ) {
if (!is_multisite() || is_multisite() && is_network_admin()) {
// Only show if standalon OR in main network admin.
pb_backupbuddy::add_dashboard_widget('stats', 'BackupBuddy v' . pb_backupbuddy::settings('version'), 'godmode');
}
//}
/********** FILTERS (admin) **********/
pb_backupbuddy::add_filter('plugin_row_meta', 10, 2);
/********** PAGES (admin) **********/
$icon = '';
if (is_multisite() && backupbuddy_core::is_network_activated() && !defined('PB_DEMO_MODE')) {
// Multisite installation.
if (defined('PB_BACKUPBUDDY_MULTISITE_EXPERIMENT') && PB_BACKUPBUDDY_MULTISITE_EXPERIMENT == TRUE) {
// comparing with bool but loose so string is acceptable.
if (is_network_admin()) {
// Network Admin pages
pb_backupbuddy::add_page('', 'backup', array(pb_backupbuddy::settings('name'), __('Backup', 'it-l10n-backupbuddy')), 'manage_network', $icon);
pb_backupbuddy::add_page('backup', 'migrate_restore', __('Migrate, Restore', 'it-l10n-backupbuddy'), 'manage_network');
pb_backupbuddy::add_page('backup', 'destinations', __('Remote Destinations', 'it-l10n-backupbuddy'), pb_backupbuddy::$options['role_access']);
pb_backupbuddy::add_page('backup', 'multisite_import', __('MS Import (beta)', 'it-l10n-backupbuddy'), 'manage_network');
pb_backupbuddy::add_page('backup', 'server_tools', __('Server Tools', 'it-l10n-backupbuddy'), 'manage_network');
pb_backupbuddy::add_page('backup', 'malware_scan', __('Malware Scan', 'it-l10n-backupbuddy'), 'manage_network');
pb_backupbuddy::add_page('backup', 'scheduling', __('Schedules', 'it-l10n-backupbuddy'), 'manage_network');
pb_backupbuddy::add_page('backup', 'settings', __('Settings', 'it-l10n-backupbuddy'), 'manage_network');
} else {
// Subsite pages.
示例12: die
<?php
backupbuddy_core::verifyAjaxAccess();
// Note: importbuddy, backup files, etc should have already been cleaned up by importbuddy itself at this point.
$serial = pb_backupbuddy::_POST('serial');
$direction = pb_backupbuddy::_POST('direction');
pb_backupbuddy::load();
if ('pull' == $direction) {
// Local so clean up here.
backupbuddy_core::cleanup_temp_tables($serial);
die('1');
} elseif ('push' == $direction) {
// Remote so call API to clean up.
require_once pb_backupbuddy::plugin_path() . '/classes/remote_api.php';
$destinationID = pb_backupbuddy::_POST('destinationID');
if (!isset(pb_backupbuddy::$options['remote_destinations'][$destinationID])) {
die('Error #8383983: Invalid destination ID `' . htmlentities($destinationID) . '`.');
}
$destinationArray = pb_backupbuddy::$options['remote_destinations'][$destinationID];
if ('site' != $destinationArray['type']) {
die('Error #8378332: Destination with ID `' . htmlentities($destinationID) . '` not of "site" type.');
}
$apiKey = $destinationArray['api_key'];
$apiSettings = backupbuddy_remote_api::key_to_array($apiKey);
if (false === ($response = backupbuddy_remote_api::remoteCall($apiSettings, 'confirmDeployment', array('serial' => $serial), 10, null, null, null, null, null, null, null, $returnRaw = true))) {
$message = 'Error #2378378324. Unable to confirm remote deployment with serial `' . $serial . '` via remote API.';
pb_backupbuddy::status('error', $message);
die($message);
} else {
if (false === ($response = json_decode($response, true))) {
$message = 'Error #239872373. Unable to decode remote deployment response with serial `' . $serial . '` via remote API. Remote server response: `' . print_r($response) . '`.';
示例13: unset
// End foreach.
unset($item);
unset($item_name);
}
// End foreach.
unset($event);
unset($hook_name);
}
// End if is_numeric.
}
// End foreach.
unset($cron_item);
unset($time);
// Cleanup any old notifications.
$notifications = backupbuddy_core::getNotifications();
// Load notifications.
$updateNotifications = false;
$maxTimeDiff = pb_backupbuddy::$options['max_notifications_age_days'] * 24 * 60 * 60;
foreach ($notifications as $i => $notification) {
if (time() - $notification['time'] > $maxTimeDiff) {
unset($notifications[$i]);
$updateNotifications = true;
}
}
if (true === $updateNotifications) {
pb_backupbuddy::status('details', 'Periodic cleanup: Replacing notifications.');
backupbuddy_core::replaceNotifications($notifications);
}
@clearstatcache();
// Clears file info stat cache.
pb_backupbuddy::status('message', 'Finished cleanup procedure.');
示例14: backupbuddy_hourpad
if( jQuery( '#' + target_id ).length == 0 ) { // No status box yet so suppress.
return;
}
jQuery( '#' + target_id ).append( "\n" + message );
textareaelem = document.getElementById( target_id );
textareaelem.scrollTop = textareaelem.scrollHeight;
}
function backupbuddy_hourpad(n) { return ("0" + n).slice(-2); }
</script>
<?php
$success = false;
global $pb_backupbuddy_js_status;
$pb_backupbuddy_js_status = true;
echo pb_backupbuddy::status_box('Restoring . . .');
echo '<div id="pb_backupbuddy_working" style="width: 100px;"><br><center><img src="' . pb_backupbuddy::plugin_url() . '/images/working.gif" title="Working... Please wait as this may take a moment..."></center></div>';
pb_backupbuddy::set_status_serial('restore');
global $wp_version;
pb_backupbuddy::status('details', 'BackupBuddy v' . pb_backupbuddy::settings('version') . ' using WordPress v' . $wp_version . ' on ' . PHP_OS . '.');
$archive_file = pb_backupbuddy::_GET('archive');
// archive to extract from.
require pb_backupbuddy::plugin_path() . '/classes/_restoreFiles.php';
$result = backupbuddy_restore_files::restore(backupbuddy_core::getBackupDirectory() . $archive_file, $files, $finalPath = ABSPATH);
echo '<script type="text/javascript">jQuery("#pb_backupbuddy_working").hide();</script>';
pb_backupbuddy::flush();
if (false === $result) {
} else {
}
pb_backupbuddy::$ui->ajax_footer();
pb_backupbuddy::$ui->ajax_footer();
die;
示例15: 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;
}