本文整理汇总了PHP中pb_backupbuddy::verify_nonce方法的典型用法代码示例。如果您正苦于以下问题:PHP pb_backupbuddy::verify_nonce方法的具体用法?PHP pb_backupbuddy::verify_nonce怎么用?PHP pb_backupbuddy::verify_nonce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pb_backupbuddy
的用法示例。
在下文中一共展示了pb_backupbuddy::verify_nonce方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: backups_list
public function backups_list($type = 'default', $subsite_mode = false)
{
if (pb_backupbuddy::_POST('bulk_action') == 'delete_backup') {
$needs_save = false;
pb_backupbuddy::verify_nonce(pb_backupbuddy::_POST('_wpnonce'));
// Security check to prevent unauthorized deletions by posting from a remote place.
$deleted_files = array();
foreach (pb_backupbuddy::_POST('items') as $item) {
if (file_exists(pb_backupbuddy::$options['backup_directory'] . $item)) {
if (@unlink(pb_backupbuddy::$options['backup_directory'] . $item) === true) {
$deleted_files[] = $item;
if (count(pb_backupbuddy::$options['backups']) > 3) {
// Keep a minimum number of backups in array for stats.
$this_serial = $this->get_serial_from_file($item);
unset(pb_backupbuddy::$options['backups'][$this_serial]);
$needs_save = true;
}
} else {
pb_backupbuddy::alert('Error: Unable to delete backup file `' . $item . '`. Please verify permissions.', true);
}
}
// End if file exists.
}
// End foreach.
if ($needs_save === true) {
pb_backupbuddy::save();
}
pb_backupbuddy::alert(__('Deleted backup(s):', 'it-l10n-backupbuddy') . ' ' . implode(', ', $deleted_files));
}
// End if deleting backup(s).
$backups = array();
$backup_sort_dates = array();
$files = glob(pb_backupbuddy::$options['backup_directory'] . 'backup*.zip');
if (is_array($files) && !empty($files)) {
// For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match.
$backup_prefix = $this->backup_prefix();
// Backup prefix for this site. Used for MS checking that this user can see this backup.
foreach ($files as $file_id => $file) {
if ($subsite_mode === true && is_multisite()) {
// If a Network and NOT the superadmin must make sure they can only see the specific subsite backups for security purposes.
// Only allow viewing of their own backups.
if (!strstr($file, $backup_prefix)) {
unset($files[$file_id]);
// Remove this backup from the list. This user does not have access to it.
continue;
// Skip processing to next file.
echo 'bob';
}
}
$serial = pb_backupbuddy::$classes['core']->get_serial_from_file($file);
// Populate integrity data structure in options.
pb_backupbuddy::$classes['core']->backup_integrity_check($file);
$pretty_status = array('pass' => 'Good', 'fail' => '<font color="red">Bad</font>');
$pretty_type = array('full' => 'Full', 'db' => 'Database');
//echo '<pre>' . print_r( pb_backupbuddy::$options['backups'][$serial], true ) . '</pre>';
// Calculate time for each step.
$step_times = array();
$step_time_details = array();
$zip_time = 0;
if (isset(pb_backupbuddy::$options['backups'][$serial]['steps'])) {
foreach (pb_backupbuddy::$options['backups'][$serial]['steps'] as $step) {
if (!isset($step['finish_time']) || $step['finish_time'] == 0) {
$step_times[] = '<span class="description">Unknown</span>';
} else {
$step_time = $step['finish_time'] - $step['start_time'];
$step_times[] = $step_time;
// Pretty step name:
if ($step['function'] == 'backup_create_database_dump') {
$step_name = 'Database dump';
} elseif ($step['function'] == 'backup_zip_files') {
$step_name = 'Zip archive creation';
} elseif ($step['function'] == 'post_backup') {
$step_name = 'Post-backup cleanup';
} else {
$step_name = $step['function'];
}
$step_time_details[] = '<b>' . $step_name . '</b><br> ' . $step_time . ' seconds in ' . $step['attempts'] . ' attempts.';
if ($step['function'] == 'backup_zip_files') {
$zip_time = $step_time;
}
}
}
// End foreach.
} else {
// End if serial in array is set.
$step_times[] = '<span class="description">Unknown</span>';
}
// End if serial in array is NOT set.
$step_times = implode(', ', $step_times);
//echo '<pre>' . print_r( pb_backupbuddy::$options['backups'][$serial], true ) . '</pre>';
// Calculate start and finish.
if (isset(pb_backupbuddy::$options['backups'][$serial]['start_time']) && isset(pb_backupbuddy::$options['backups'][$serial]['finish_time']) && pb_backupbuddy::$options['backups'][$serial]['start_time'] > 0 && pb_backupbuddy::$options['backups'][$serial]['finish_time'] > 0) {
$start_time = pb_backupbuddy::$options['backups'][$serial]['start_time'];
$finish_time = pb_backupbuddy::$options['backups'][$serial]['finish_time'];
$total_time = $finish_time - $start_time;
} else {
$total_time = '<span class="description">Unknown</span>';
}
// Calculate write speed in MB/sec for this backup.
if ($zip_time == '0') {
//.........这里部分代码省略.........
示例2:
<?php
pb_backupbuddy::$ui->title(__('Deploy Database', 'it-l10n-backupbuddy') . ' <a style="font-size: 0.6em;" href="#" onClick="jQuery(\'#pb_backupbuddy_status_wrap\').toggle();">Display Status Log</a>');
if (!defined('BACKUPBUDDY_API_ENABLE') || TRUE != BACKUPBUDDY_API_ENABLE) {
pb_backupbuddy::alert("Make sure the following is in your wp-config.php file on this server:<br><textarea style='width: 100%;' disabled='disabled'>define( 'BACKUPBUDDY_API_ENABLE', true ); // Requires API key to access.</textarea>");
return false;
}
/*
if ( ! defined( 'BACKUPBUDDY_API_SALT' ) || ( 'CHANGEME' == BACKUPBUDDY_API_SALT ) || ( strlen( BACKUPBUDDY_API_SALT ) < 5 ) ) {
pb_backupbuddy::alert( "Make sure the following is in your wp-config.php file on this server:<br><textarea style='width: 100%;' disabled='disabled'>define( 'BACKUPBUDDY_API_SALT', 'CHANGEME' ); // !!! IMPORTANT !!! Change CHANGEME to the left to a unique password/phrase for generating API keys. 5+ characters.</textarea>" );
return false;
}
*/
if ('1' == pb_backupbuddy::_POST('regenerate_api_key')) {
pb_backupbuddy::verify_nonce();
// Security check.
pb_backupbuddy::$options['api_key'] = backupbuddy_core::generate_api_key();
pb_backupbuddy::save();
}
?>
<b>Note:</b> wp-config.php files as well as BackupBuddy settings will NOT be transferred in either direction. Your current BackupBuddy settings, destinations, API keys etc. will remain as they are on both sites.<br><br>
<form method="post">
<?php
pb_backupbuddy::nonce();
?>
<input type="hidden" name="regenerate_api_key" value="1">
<button class="button secondary-button" onClick="jQuery('.backupbuddy_api_key-hide').toggle(); return false;">Show API Key</button><span class="backupbuddy_api_key-hide" style="display: none;"> <input type="submit" name="submit" value="Generate New API Key" class="button button-primary"></span>
<br>
<br>
示例3: remote_save
public function remote_save()
{
pb_backupbuddy::verify_nonce();
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
$settings_form = pb_backupbuddy_destinations::configure(array('type' => pb_backupbuddy::_POST('pb_backupbuddy_type')), 'save');
$save_result = $settings_form->process();
$destination_id = trim(pb_backupbuddy::_GET('pb_backupbuddy_destinationid'));
if (count($save_result['errors']) == 0) {
if ($destination_id == 'NEW') {
// ADD NEW.
// Dropbox Kludge. Sigh.
$save_result['data']['token'] = pb_backupbuddy::$options['dropboxtemptoken'];
pb_backupbuddy::$options['remote_destinations'][] = $save_result['data'];
pb_backupbuddy::save();
echo 'Destination Added.';
} elseif (!isset(pb_backupbuddy::$options['remote_destinations'][$destination_id])) {
// EDITING NONEXISTANT.
echo 'Error #54859. Invalid destination ID.';
} else {
// EDITING EXISTING -- Save!
pb_backupbuddy::$options['remote_destinations'][$destination_id] = $save_result['data'];
//echo '<pre>' . print_r( pb_backupbuddy::$options['remote_destinations'][$destination_id], true ) . '</pre>';
pb_backupbuddy::save();
echo 'Settings saved.';
}
} else {
echo "Error saving settings.\n\n";
echo implode("\n", $save_result['errors']);
}
die;
}
示例4: backups_list
public static function backups_list($type = 'default', $subsite_mode = false)
{
if (pb_backupbuddy::_POST('bulk_action') == 'delete_backup' && is_array(pb_backupbuddy::_POST('items'))) {
$needs_save = false;
pb_backupbuddy::verify_nonce(pb_backupbuddy::_POST('_wpnonce'));
// Security check to prevent unauthorized deletions by posting from a remote place.
$deleted_files = array();
foreach (pb_backupbuddy::_POST('items') as $item) {
if (file_exists(backupbuddy_core::getBackupDirectory() . $item)) {
if (@unlink(backupbuddy_core::getBackupDirectory() . $item) === true) {
$deleted_files[] = $item;
// Cleanup any related fileoptions files.
$serial = backupbuddy_core::get_serial_from_file($item);
$backup_files = glob(backupbuddy_core::getBackupDirectory() . '*.zip');
if (!is_array($backup_files)) {
$backup_files = array();
}
if (count($backup_files) > 5) {
// Keep a minimum number of backups in array for stats.
$this_serial = self::get_serial_from_file($item);
$fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $this_serial . '.txt';
if (file_exists($fileoptions_file)) {
@unlink($fileoptions_file);
}
if (file_exists($fileoptions_file . '.lock')) {
@unlink($fileoptions_file . '.lock');
}
$needs_save = true;
}
} else {
pb_backupbuddy::alert('Error: Unable to delete backup file `' . $item . '`. Please verify permissions.', true);
}
}
// End if file exists.
}
// End foreach.
if ($needs_save === true) {
pb_backupbuddy::save();
}
pb_backupbuddy::alert(__('Deleted:', 'it-l10n-backupbuddy') . ' ' . implode(', ', $deleted_files));
}
// End if deleting backup(s).
$backups = array();
$backup_sort_dates = array();
$files = glob(backupbuddy_core::getBackupDirectory() . 'backup*.zip');
if (is_array($files) && !empty($files)) {
// For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match.
$backup_prefix = self::backup_prefix();
// Backup prefix for this site. Used for MS checking that this user can see this backup.
foreach ($files as $file_id => $file) {
if ($subsite_mode === true && is_multisite()) {
// If a Network and NOT the superadmin must make sure they can only see the specific subsite backups for security purposes.
// Only allow viewing of their own backups.
if (!strstr($file, $backup_prefix)) {
unset($files[$file_id]);
// Remove this backup from the list. This user does not have access to it.
continue;
// Skip processing to next file.
}
}
$serial = backupbuddy_core::get_serial_from_file($file);
$options = array();
if (file_exists(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt')) {
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
pb_backupbuddy::status('details', 'Fileoptions instance #33.');
$backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = false, $ignore_lock = false, $create_file = true);
// Will create file to hold integrity data if nothing exists.
} else {
$backup_options = '';
}
$backup_integrity = backupbuddy_core::backup_integrity_check($file, $backup_options, $options);
// Backup status.
$pretty_status = array(true => '<span class="pb_label pb_label-success">Good</span>', 'pass' => '<span class="pb_label pb_label-success">Good</span>', false => '<span class="pb_label pb_label-important">Bad</span>', 'fail' => '<span class="pb_label pb_label-important">Bad</span>');
// Backup type.
$pretty_type = array('full' => 'Full', 'db' => 'Database', 'files' => 'Files');
// Defaults...
$detected_type = '';
$file_size = '';
$modified = '';
$modified_time = 0;
$integrity = '';
$main_string = 'Warn#284.';
if (is_array($backup_integrity)) {
// Data intact... put it all together.
// Calculate time ago.
$time_ago = '';
if (isset($backup_integrity['modified'])) {
$time_ago = pb_backupbuddy::$format->time_ago($backup_integrity['modified']) . ' ago';
}
$detected_type = pb_backupbuddy::$format->prettify($backup_integrity['detected_type'], $pretty_type);
if ($detected_type == '') {
$detected_type = 'Unknown';
} else {
if (isset($backup_options->options['profile'])) {
$detected_type = '
<div>
<span style="color: #AAA; float: left;">' . $detected_type . '</span>
<span style="display: inline-block; float: left; height: 15px; border-right: 1px solid #EBEBEB; margin-left: 6px; margin-right: 6px;"></span>
' . htmlentities($backup_options->options['profile']['title']) . '
</div>
//.........这里部分代码省略.........
示例5: jQuery
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery( '#pb_backupbuddy_first_run' ).datetimepicker({
ampm: true
});
});
</script>
<?php
pb_backupbuddy::$classes['core']->versions_confirm();
$date_format_example = 'mm/dd/yyyy hh:mm [am/pm]';
// Example date format for displaying to user.
// HANDLE SCHEDULE DELETION.
if (pb_backupbuddy::_POST('bulk_action') == 'delete_schedule') {
pb_backupbuddy::verify_nonce(pb_backupbuddy::_POST('_wpnonce'));
// Security check to prevent unauthorized deletions by posting from a remote place.
$deleted_schedules = array();
foreach (pb_backupbuddy::_POST('items') as $id) {
$deleted_schedules[] = htmlentities(pb_backupbuddy::$options['schedules'][$id]['title']);
$next_scheduled_time = wp_next_scheduled('pb_backupbuddy-cron_scheduled_backup', array((int) $id));
wp_unschedule_event($next_scheduled_time, 'pb_backupbuddy-cron_scheduled_backup', array((int) $id));
// Remove old schedule. pb_backupbuddy::$options['schedules'][$id]['first_run']
unset(pb_backupbuddy::$options['schedules'][$id]);
}
pb_backupbuddy::save();
pb_backupbuddy::alert(__('Deleted schedule(s):', 'it-l10n-backupbuddy') . ' ' . implode(', ', $deleted_schedules));
}
// End if deleting backup(s).
if (pb_backupbuddy::_GET('edit') != '') {
$mode = 'edit';
示例6: backups_list
public function backups_list($type = 'default', $subsite_mode = false)
{
if (pb_backupbuddy::_POST('bulk_action') == 'delete_backup' && is_array(pb_backupbuddy::_POST('items'))) {
$needs_save = false;
pb_backupbuddy::verify_nonce(pb_backupbuddy::_POST('_wpnonce'));
// Security check to prevent unauthorized deletions by posting from a remote place.
$deleted_files = array();
foreach (pb_backupbuddy::_POST('items') as $item) {
if (file_exists(pb_backupbuddy::$options['backup_directory'] . $item)) {
if (@unlink(pb_backupbuddy::$options['backup_directory'] . $item) === true) {
$deleted_files[] = $item;
// Cleanup any related fileoptions files.
$serial = pb_backupbuddy::$classes['core']->get_serial_from_file($item);
$fileoptions_file = pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '.txt';
$fileoptions_filetree_file = pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '-filetree.txt';
if (file_exists($fileoptions_file)) {
if (false === @unlink($fileoptions_file)) {
pb_backupbuddy::status('error', 'Unable to delete fileoptions file `' . $fileoptions_file . '`.');
}
}
if (file_exists($fileoptions_file . '.lock')) {
if (false === @unlink($fileoptions_file . '.lock')) {
pb_backupbuddy::status('error', 'Unable to delete fileoptions file `' . $fileoptions_file . '.lock`.');
}
}
if (file_exists($fileoptions_filetree_file)) {
if (false === @unlink($fileoptions_filetree_file)) {
pb_backupbuddy::status('error', 'Unable to delete fileoptions file `' . $fileoptions_filetree_file . '`.');
}
}
$backup_files = glob(pb_backupbuddy::$options['backup_directory'] . '*.zip');
if (!is_array($backup_files)) {
$backup_files = array();
}
if (count($backup_files) > 5) {
// Keep a minimum number of backups in array for stats.
$this_serial = $this->get_serial_from_file($item);
$fileoptions_file = pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $this_serial . '.txt';
if (file_exists($fileoptions_file)) {
@unlink($fileoptions_file);
}
if (file_exists($fileoptions_file . '.lock')) {
@unlink($fileoptions_file . '.lock');
}
$needs_save = true;
}
} else {
pb_backupbuddy::alert('Error: Unable to delete backup file `' . $item . '`. Please verify permissions.', true);
}
}
// End if file exists.
}
// End foreach.
if ($needs_save === true) {
pb_backupbuddy::save();
}
pb_backupbuddy::alert(__('Deleted:', 'it-l10n-backupbuddy') . ' ' . implode(', ', $deleted_files));
}
// End if deleting backup(s).
$backups = array();
$backup_sort_dates = array();
$files = glob(pb_backupbuddy::$options['backup_directory'] . 'backup*.zip');
if (is_array($files) && !empty($files)) {
// For robustness. Without open_basedir the glob() function returns an empty array for no match. With open_basedir in effect the glob() function returns a boolean false for no match.
$backup_prefix = $this->backup_prefix();
// Backup prefix for this site. Used for MS checking that this user can see this backup.
foreach ($files as $file_id => $file) {
if ($subsite_mode === true && is_multisite()) {
// If a Network and NOT the superadmin must make sure they can only see the specific subsite backups for security purposes.
// Only allow viewing of their own backups.
if (!strstr($file, $backup_prefix)) {
unset($files[$file_id]);
// Remove this backup from the list. This user does not have access to it.
continue;
// Skip processing to next file.
}
}
$serial = pb_backupbuddy::$classes['core']->get_serial_from_file($file);
// Populate integrity data structure in options.
pb_backupbuddy::$classes['core']->backup_integrity_check($file);
// Backup status.
$pretty_status = array(true => '<span class="pb_label pb_label-success">Good</span>', 'pass' => '<span class="pb_label pb_label-success">Good</span>', false => '<span class="pb_label pb_label-important">Bad</span>', 'fail' => '<span class="pb_label pb_label-important">Bad</span>');
// Backup type.
$pretty_type = array('full' => 'Full', 'db' => 'Database');
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
$backup_options = new pb_backupbuddy_fileoptions(pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '.txt');
if (true !== ($result = $backup_options->is_ok())) {
pb_backupbuddy::status('error', 'Error retrieving fileoptions file `' . pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '.txt' . '`. Err 4332345.');
}
// Verify valid fileoptions data exists.
if (!is_array($backup_options->options)) {
// fileoptions data missing. try to regenerate with integrity check
pb_backupbuddy::status('details', 'Fileoptions data missing loading backup list. Re-scanning integrity to regenerate on file `' . $file . '`.');
pb_backupbuddy::$classes['core']->backup_integrity_check($file);
// Re-load fileoptions now.
$backup_options = new pb_backupbuddy_fileoptions(pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '.txt');
if (true !== ($result = $backup_options->is_ok())) {
pb_backupbuddy::status('error', 'Error retrieving fileoptions file `' . pb_backupbuddy::$options['log_directory'] . 'fileoptions/' . $serial . '.txt' . '`. Err 3278475845.');
}
}
//.........这里部分代码省略.........
示例7: pbframework_troubleshooting
public function pbframework_troubleshooting()
{
pb_backupbuddy::verify_nonce();
echo 'test';
}