本文整理汇总了PHP中pb_backupbuddy类的典型用法代码示例。如果您正苦于以下问题:PHP pb_backupbuddy类的具体用法?PHP pb_backupbuddy怎么用?PHP pb_backupbuddy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了pb_backupbuddy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: plugin_information
function plugin_information($plugin_slug, $data)
{
$plugin_path = $data['path'];
?>
<textarea readonly="readonly" rows="7" cols="65" wrap="off" style="width: 100%;"><?php
//echo "Version History:\n\n";
readfile($plugin_path . '/history.txt');
?>
</textarea>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#pluginbuddy_<?php
echo $plugin_slug;
?>
_debugtoggle").click(function() {
jQuery("#pluginbuddy_<?php
echo $plugin_slug;
?>
_debugtoggle_div").slideToggle();
});
});
</script>
<?php
if (pb_backupbuddy::_POST('reset_defaults') == $plugin_slug) {
if (call_user_func('pb_' . $plugin_slug . '::reset_options', true) === true) {
pb_backupbuddy::alert('Plugin settings have been reset to defaults for plugin `' . $data['name'] . '`.');
} else {
pb_backupbuddy::alert('Unable to reset plugin settings. Verify you are running the latest version.');
}
}
?>
<?php
}
示例2: api
function api()
{
die('0');
// TODO: Internal security lockout.
if (!isset(pb_backupbuddy::$options['api_key_test']) || pb_backupbuddy::$options['api_key_test'] == '') {
die('0');
}
if (pb_backupbuddy::$options['api_key_test'] != 'dsnfilasbfisybfdjybfjalybsfaklsbfa') {
die('0');
}
$run = pb_backupbuddy::_POST('run');
// TODO: TESTING temp allow GET method:
if ('' == $run) {
$run = pb_backupbuddy::_GET('run');
}
if ('' == $run) {
die(json_encode(array('success' => false, 'error' => 'Error #489384: Missing run command.')));
} else {
if (false === ($return = call_user_func('backupbuddy_api::' . $run))) {
die(json_encode(array('success' => false, 'error' => 'Error #328983: Command failed.')));
} else {
die(json_encode(array('success' => true, 'version' => pb_backupbuddy::settings('version'), 'data' => $return)));
}
}
die;
}
示例3: backupbuddy_register_sync_verbs
function backupbuddy_register_sync_verbs($api)
{
$verbs = array('backupbuddy-run-backup' => 'Ithemes_Sync_Verb_Backupbuddy_Run_Backup', 'backupbuddy-list-profiles' => 'Ithemes_Sync_Verb_Backupbuddy_List_Profiles', 'backupbuddy-list-schedules' => 'Ithemes_Sync_Verb_Backupbuddy_List_Schedules', 'backupbuddy-list-destinations' => 'Ithemes_Sync_Verb_Backupbuddy_List_Destinations', 'backupbuddy-get-overview' => 'Ithemes_Sync_Verb_Backupbuddy_Get_Overview', 'backupbuddy-get-latestBackupProcess' => 'Ithemes_Sync_Verb_Backupbuddy_Get_LatestBackupProcess', 'backupbuddy-get-everything' => 'Ithemes_Sync_Verb_Backupbuddy_Get_Everything', 'backupbuddy-get-importbuddy' => 'Ithemes_Sync_Verb_Backupbuddy_Get_Importbuddy');
foreach ($verbs as $name => $class) {
$api->register($name, $class, pb_backupbuddy::plugin_path() . "/classes/ithemes-sync/{$name}.php");
}
}
示例4: 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() {
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_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 );
if ( $comment === false ) {
$comment = '';
}
$this_archive = array(
'file' => basename( $backup_archive ),
'comment' => $comment,
);
$backup_archives[] = $this_archive;
}
unset( $backup_archives_glob );
return $backup_archives;
}
示例5: remove_file
function remove_file($file, $description, $error_on_missing = false)
{
pb_backupbuddy::status('message', 'Deleting `' . $description . '`...');
@chmod($file, 0755);
// High permissions to delete.
if (is_dir($file)) {
// directory.
pb_backupbuddy::$filesystem->unlink_recursive($file);
if (file_exists($file)) {
pb_backupbuddy::status('error', 'Unable to delete directory: `' . $description . '`. You should manually delete it.');
} else {
pb_backupbuddy::status('message', 'Deleted.', false);
// No logging of this action to prevent recreating log.
}
} else {
// file
if (file_exists($file)) {
if (@unlink($file) != 1) {
pb_backupbuddy::status('error', 'Unable to delete file: `' . $description . '`. You should manually delete it.');
} else {
pb_backupbuddy::status('message', 'Deleted.', false);
// No logging of this action to prevent recreating log.
}
}
}
}
示例6: backupbuddy_dbMediaSince
function backupbuddy_dbMediaSince($includeThumbs = true)
{
global $wpdb;
$wpdb->show_errors();
// Turn on error display.
$mediaFiles = array();
// Select all media attachments.
$sql = "select " . $wpdb->prefix . "postmeta.meta_value as file," . $wpdb->prefix . "posts.post_modified as file_modified," . $wpdb->prefix . "postmeta.meta_key as meta_key from " . $wpdb->prefix . "postmeta," . $wpdb->prefix . "posts WHERE ( meta_key='_wp_attached_file' OR meta_key='_wp_attachment_metadata' ) AND " . $wpdb->prefix . "postmeta.post_id = " . $wpdb->prefix . "posts.id ORDER BY meta_key ASC";
$results = $wpdb->get_results($sql, ARRAY_A);
if (null === $results || false === $results) {
pb_backupbuddy::status('error', 'Error #238933: Unable to calculate media with query `' . $sql . '`. Check database permissions or contact host.');
}
foreach ((array) $results as $result) {
if ($result['meta_key'] == '_wp_attached_file') {
$mediaFiles[$result['file']] = array('modified' => $result['file_modified']);
}
// Include thumbnail image files.
if (true === $includeThumbs) {
if ($result['meta_key'] == '_wp_attachment_metadata') {
$data = unserialize($result['file']);
foreach ($data['sizes'] as $size) {
// Go through each sized thumbnail file.
$mediaFiles[$size['file']] = array('modified' => $mediaFiles[$data['file']]['modified']);
}
}
}
}
// end foreach $results.
unset($results);
return $mediaFiles;
}
示例7: run
public function run($arguments)
{
$arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
$profile = $arguments['profile'];
if ('db' == $profile) {
// db profile is always index 1.
$profile = '1';
} elseif ('full' == $profile) {
// full profile is always index 2.
$profile = '2';
}
if (is_numeric($profile)) {
if (isset(pb_backupbuddy::$options['profiles'][$profile])) {
$profileArray = pb_backupbuddy::$options['profiles'][$profile];
} else {
return array('api' => '0', 'status' => 'error', 'message' => 'Error #2332904: Invalid profile ID `' . htmlentities($profile) . '`. Profile with this number was not found. Try deactivating then reactivating the plugin. If this fails please reset the plugin Settings back to Defaults from the Settings page.');
}
} else {
return array('api' => '0', 'status' => 'error', 'message' => 'Error #85489548955. Invalid profile ID not numeric: `' . htmlentities($profile) . '`.');
}
require_once pb_backupbuddy::plugin_path() . '/classes/backup.php';
pb_backupbuddy::$classes['backup'] = new pb_backupbuddy_backup();
// Set serial ahead of time so can be used by AJAX before backup procedure actually begins.
$serial = pb_backupbuddy::random_string(10);
$profileArray['backup_mode'] = '2';
// Force modern mode when running under sync.
// Run the backup!
if (pb_backupbuddy::$classes['backup']->start_backup_process($profileArray, 'manual', array(), array(), 'it-sync', $serial, array()) !== true) {
return array('api' => '0', 'status' => 'error', 'message' => 'Error #435832: Backup failed. See BackupBuddy log for details.');
}
return array('api' => '0', 'status' => 'ok', 'message' => 'Backup initiated successfully.');
}
示例8: enqueue_dashboard_stylesheet
function enqueue_dashboard_stylesheet($hook)
{
if ('index.php' != $hook) {
return;
}
wp_enqueue_style('bub_dashboard_widget', pb_backupbuddy::plugin_url() . '/css/dashboard_widget.css');
}
示例9: parse_options
function parse_options($restoreData)
{
if ('1' == pb_backupbuddy::_POST('restoreFiles')) {
$restoreData['restoreFiles'] = true;
} else {
$restoreData['restoreFiles'] = false;
}
if ('1' == pb_backupbuddy::_POST('restoreDatabase')) {
$restoreData['restoreDatabase'] = true;
} else {
$restoreData['restoreDatabase'] = false;
}
if ('1' == pb_backupbuddy::_POST('migrateHtaccess')) {
$restoreData['migrateHtaccess'] = true;
} else {
$restoreData['migrateHtaccess'] = false;
}
if ('all' == pb_backupbuddy::_POST('zipMethodStrategy') || 'ziparchive' == pb_backupbuddy::_POST('zipMethodStrategy') || 'pclzip' == pb_backupbuddy::_POST('zipMethodStrategy')) {
$restoreData['zipMethodStrategy'] = pb_backupbuddy::_POST('zipMethodStrategy');
}
/*
if ( ( isset( $_POST['log_level'] ) ) && ( $_POST['log_level'] != '' ) ) {
pb_backupbuddy::$options['log_level'] = $_POST['log_level'];
} else {
pb_backupbuddy::$options['log_level'] = '';
}
*/
return $restoreData;
}
示例10: 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();
return array('api' => '0', 'status' => 'ok', 'message' => 'Destination added.');
}
示例11: execute
public function execute($command)
{
if (stristr(PHP_OS, 'WIN') && !stristr(PHP_OS, 'DARWIN')) {
// Windows; do nothing.
} else {
// Linux/Mac
if (ini_get('exec_dir') !== false && ini_get('exec_dir') != '') {
// exec_dir PHP patch in place: http://www.kyberdigi.cz/projects/execdir/
pb_backupbuddy::status('details', 'exec_dir detected. Skipping path assignment.');
} else {
pb_backupbuddy::status('details', 'exec_dir not detected. Proceeding normally.');
$command = 'PATH=$PATH:/usr/bin/:/usr/local/bin/:usr/local/bin:/usr/local/sbin/:/usr/sbin/:/sbin/:/usr/:/bin/' . '; ' . $command;
}
}
// Output command (strips mysqldump passwords).
if (strstr($command, '--password=')) {
$password_portion_begin = strpos($command, '--password=');
$password_portion_end = strpos($command, ' ', $password_portion_begin);
//pb_backupbuddy::status( 'details', 'pass start: `' . $password_portion_begin . '`. pass end: `' . $password_portion_end . '`' );
$password_portion = substr($command, $password_portion_begin, $password_portion_end - $password_portion_begin);
//pb_backupbuddy::status( 'details', 'pass portion: `' . $password_portion . '`.' );
$unpassworded_command = str_replace($password_portion, '--password=*HIDDEN*', $command);
pb_backupbuddy::status('details', 'exec() command (password hidden) `' . $unpassworded_command . '` (with path definition).');
unset($unpassworded_command);
} else {
pb_backupbuddy::status('details', 'exec() command `' . $command . '` (with path definition).');
}
$exec_output = array();
@exec($command, $exec_output, $exec_exit_code);
pb_backupbuddy::status('details', 'exec() command output: `' . implode(',', $exec_output) . '`; Exit code: `' . $exec_exit_code . '`; Exit code description: `' . pb_backupbuddy::$filesystem->exit_code_lookup($exec_exit_code) . '`');
return array($exec_output, $exec_exit_code);
}
示例12: 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;
}
}
示例13: execute
public function execute($command)
{
if (stristr(PHP_OS, 'WIN') && !stristr(PHP_OS, 'DARWIN')) {
// Windows; do nothing.
} else {
// Linux/Mac
$command = 'PATH=$PATH:/usr/bin/:/usr/local/bin/:usr/local/bin:/usr/local/sbin/:/usr/sbin/:/sbin/:/usr/:/bin/' . '; ' . $command;
}
// Output command (strips mysqldump passwords).
if (strstr($command, '--password=')) {
$password_portion_begin = strpos($command, '--password=');
$password_portion_end = strpos($command, ' ', $password_portion_begin);
//pb_backupbuddy::status( 'details', 'pass start: `' . $password_portion_begin . '`. pass end: `' . $password_portion_end . '`' );
$password_portion = substr($command, $password_portion_begin, $password_portion_end - $password_portion_begin);
//pb_backupbuddy::status( 'details', 'pass portion: `' . $password_portion . '`.' );
$unpassworded_command = str_replace($password_portion, '--password=*HIDDEN*', $command);
pb_backupbuddy::status('details', 'exec() command (password hidden) `' . $unpassworded_command . '` (with path definition).');
unset($unpassworded_command);
} else {
pb_backupbuddy::status('details', 'exec() command `' . $command . '` (with path definition).');
}
@exec($command, $exec_output, $exec_exit_code);
pb_backupbuddy::status('details', 'exec() command output: `' . implode(',', $exec_output) . '`; Exit code: `' . $exec_exit_code . '`; Exit code description: `' . pb_backupbuddy::$filesystem->exit_code_lookup($exec_exit_code) . '`');
return array($exec_output, $exec_exit_code);
}
示例14: 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();
$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);
}
示例15: pb_backupbuddy_stash_pass_form
function pb_backupbuddy_stash_pass_form()
{
echo 'Please enter your iThemes.com Member Password to access your full Stash listing including files stored from other sites:<br><br><br>';
echo '<form method="post"><b>iThemes Member Password</b>: <input type="password" name="stash_password" size="20"> <input type="submit" name="submit" value="Authenticate" class="button button-primary">';
pb_backupbuddy::nonce();
echo '</form>';
echo '<br><br><br><br>';
}