本文整理汇总了PHP中UpdraftPlus_Options类的典型用法代码示例。如果您正苦于以下问题:PHP UpdraftPlus_Options类的具体用法?PHP UpdraftPlus_Options怎么用?PHP UpdraftPlus_Options使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UpdraftPlus_Options类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: change_path
public static function change_path($file)
{
$opts = UpdraftPlus_Options::get_updraft_option('updraft_dropbox');
$folder = empty($opts['folder']) ? '' : $opts['folder'];
$dropbox_folder = trailingslashit($folder);
return $dropbox_folder == '/' || $dropbox_folder == './' ? $file : $dropbox_folder . $file;
}
示例2: get_login_url
public function get_login_url($redirect_to, $extra_info)
{
if (is_array($extra_info) && !empty($extra_info['user_id']) && is_numeric($extra_info['user_id'])) {
$user_id = $extra_info['user_id'];
if (false == ($login_key = $this->_get_autologin_key($user_id))) {
return $this->_generic_error_response('user_key_failure');
}
// Default value
$redirect_url = network_admin_url();
if (is_array($redirect_to) && !empty($redirect_to['module'])) {
switch ($redirect_to['module']) {
case 'updraftplus':
if ('initiate_restore' == $redirect_to['action'] && class_exists('UpdraftPlus_Options')) {
$redirect_url = UpdraftPlus_Options::admin_page_url() . '?page=updraftplus&udaction=initiate_restore&entities=' . urlencode($redirect_to['data']['entities']) . '&showdata=' . urlencode($redirect_to['data']['showdata']) . '&backup_timestamp=' . (int) $redirect_to['data']['backup_timestamp'];
} elseif ('download_file' == $redirect_to['action']) {
$findex = empty($redirect_to['data']['findex']) ? 0 : (int) $redirect_to['data']['findex'];
// e.g. ?udcentral_action=dl&action=updraftplus_spool_file&backup_timestamp=1455101696&findex=0&what=plugins
$redirect_url = site_url() . '?udcentral_action=spool_file&action=updraftplus_spool_file&findex=' . $findex . '&what=' . urlencode($redirect_to['data']['what']) . '&backup_timestamp=' . (int) $redirect_to['data']['backup_timestamp'];
}
break;
case 'direct_url':
$redirect_url = $redirect_to['url'];
break;
}
}
$login_key = apply_filters('updraftplus_remotecontrol_login_key', array('key' => $login_key, 'created' => time(), 'redirect_url' => $redirect_url), $redirect_to, $extra_info);
// Over-write any previous value - only one can be valid at a time)
update_user_meta($user_id, 'updraftcentral_login_key', $login_key);
return $this->_response(array('login_url' => network_site_url('?udcentral_action=login&login_id=' . $user_id . '&login_key=' . $login_key['key'])));
} else {
return $this->_generic_error_response('user_unknown');
}
}
示例3: get_service
public function get_service($opts, $useservercerts = false, $disablesslverify = null)
{
$user = $opts['user'];
$apikey = $opts['apikey'];
$authurl = $opts['authurl'];
$region = !empty($opts['region']) ? $opts['region'] : null;
require_once UPDRAFTPLUS_DIR . '/vendor/autoload.php';
global $updraftplus;
# The new authentication APIs don't match the values we were storing before
$new_authurl = 'https://lon.auth.api.rackspacecloud.com' == $authurl || 'uk' == $authurl ? Rackspace::UK_IDENTITY_ENDPOINT : Rackspace::US_IDENTITY_ENDPOINT;
if (null === $disablesslverify) {
$disablesslverify = UpdraftPlus_Options::get_updraft_option('updraft_ssl_disableverify');
}
if (empty($user) || empty($apikey)) {
throw new Exception(__('Authorisation failed (check your credentials)', 'updraftplus'));
}
$updraftplus->log("Cloud Files authentication URL: " . $new_authurl);
$client = new Rackspace($new_authurl, array('username' => $user, 'apiKey' => $apikey));
$this->client = $client;
if ($disablesslverify) {
$client->setSslVerification(false);
} else {
if ($useservercerts) {
$client->setConfig(array($client::SSL_CERT_AUTHORITY, 'system'));
} else {
$client->setSslVerification(UPDRAFTPLUS_DIR . '/includes/cacert.pem', true, 2);
}
}
return $client->objectStoreService('cloudFiles', $region);
}
示例4: get_service
public function get_service($opts, $useservercerts = false, $disablesslverify = null)
{
# 'tenant', 'user', 'password', 'authurl', 'path', (optional) 'region'
extract($opts);
if (null === $disablesslverify) {
$disablesslverify = UpdraftPlus_Options::get_updraft_option('updraft_ssl_disableverify');
}
if (empty($user) || empty($password) || empty($authurl)) {
throw new Exception(__('Authorisation failed (check your credentials)', 'updraftplus'));
}
require_once UPDRAFTPLUS_DIR . '/oc/autoload.php';
global $updraftplus;
$updraftplus->log("OpenStack authentication URL: " . $authurl);
$client = new OpenStack($authurl, array('username' => $user, 'password' => $password, 'tenantName' => $tenant));
$this->client = $client;
if ($disablesslverify) {
$client->setSslVerification(false);
} else {
if ($useservercerts) {
$client->setConfig(array($client::SSL_CERT_AUTHORITY => false));
} else {
$client->setSslVerification(UPDRAFTPLUS_DIR . '/includes/cacert.pem', true, 2);
}
}
$client->authenticate();
if (empty($region)) {
$catalog = $client->getCatalog();
if (!empty($catalog)) {
$items = $catalog->getItems();
if (is_array($items)) {
foreach ($items as $item) {
$name = $item->getName();
$type = $item->getType();
if ('swift' != $name || 'object-store' != $type) {
continue;
}
$eps = $item->getEndpoints();
if (!is_array($eps)) {
continue;
}
foreach ($eps as $ep) {
if (is_object($ep) && !empty($ep->region)) {
$region = $ep->region;
}
}
}
}
}
}
$this->region = $region;
return $client->objectStoreService('swift', $region);
}
示例5: backup
function backup($backup_array)
{
global $updraftplus;
$updraft_dir = $updraftplus->backups_dir_location() . '/';
foreach ($backup_array as $type => $file) {
$fullpath = $updraft_dir . $file;
foreach (explode(',', UpdraftPlus_Options::get_updraft_option('updraft_email')) as $sendmail_addr) {
wp_mail(trim($sendmail_addr), __("WordPress Backup", 'updraftplus') . " " . date('Y-m-d H:i', $updraftplus->backup_time), __("Backup is of:", 'updraftplus') . " " . $type . ". " . __('Be wary; email backups may fail because of file size limitations on mail servers.', 'updraftplus'), null, array($fullpath));
}
$updraftplus->uploaded_file($file);
}
$updraftplus->prune_retained_backups("email", null, null);
}
示例6: authorise
/**
* Obtain user authorisation
* The user will be redirected to Dropbox' web endpoint
* @link http://tools.ietf.org/html/rfc5849#section-2.2
* @return void
*/
private function authorise()
{
// Only redirect if using CLI
if (PHP_SAPI !== 'cli' && (!defined('DOING_CRON') || !DOING_CRON)) {
$url = $this->getAuthoriseUrl();
header('Location: ' . $url);
exit;
}
global $updraftplus;
$updraftplus->log('Dropbox reauthorisation needed; but we are running from cron or the CLI, so this is not possible');
UpdraftPlus_Options::update_updraft_option("updraft_dropboxtk_request_token", '');
$updraftplus->log(sprintf(__('You need to re-authenticate with %s, as your existing credentials are not working.', 'updraftplus'), 'Dropbox'), 'error');
exit;
}
示例7: backup
public function backup($backup_array)
{
global $updraftplus, $updraftplus_backup;
$updraft_dir = trailingslashit($updraftplus->backups_dir_location());
$email = $updraftplus->just_one_email(UpdraftPlus_Options::get_updraft_option('updraft_email'), true);
if (!is_array($email)) {
$email = array($email);
}
foreach ($backup_array as $type => $file) {
$descrip_type = preg_match('/^(.*)\\d+$/', $type, $matches) ? $matches[1] : $type;
$fullpath = $updraft_dir . $file;
if (file_exists($fullpath) && filesize($fullpath) > UPDRAFTPLUS_WARN_EMAIL_SIZE) {
$size_in_mb_of_big_file = round(filesize($fullpath) / 1048576, 1);
$toobig_hash = md5($file);
$updraftplus->log($file . ': ' . sprintf(__('This backup archive is %s Mb in size - the attempt to send this via email is likely to fail (few email servers allow attachments of this size). If so, you should switch to using a different remote storage method.', 'updraftplus'), $size_in_mb_of_big_file), 'warning', 'toobigforemail_' . $toobig_hash);
}
$any_attempted = false;
$any_sent = false;
foreach ($email as $ind => $addr) {
if (!apply_filters('updraftplus_email_wholebackup', true, $addr, $ind, $type)) {
continue;
}
foreach (explode(',', $addr) as $sendmail_addr) {
$send_short = strlen($sendmail_addr) > 5 ? substr($sendmail_addr, 0, 5) . '...' : $sendmail_addr;
$updraftplus->log("{$file}: email to: {$send_short}");
$any_attempted = true;
$subject = __("WordPress Backup", 'updraftplus') . ': ' . get_bloginfo('name') . ' (UpdraftPlus ' . $updraftplus->version . ') ' . get_date_from_gmt(gmdate('Y-m-d H:i:s', $updraftplus->backup_time), 'Y-m-d H:i');
$sent = wp_mail(trim($sendmail_addr), $subject, sprintf(__("Backup is of: %s.", 'updraftplus'), site_url() . ' (' . $descrip_type . ')'), null, array($fullpath));
if ($sent) {
$any_sent = true;
}
}
}
if ($any_sent) {
if (isset($toobig_hash)) {
$updraftplus->log_removewarning('toobigforemail_' . $toobig_hash);
// Don't leave it still set for the next archive
unset($toobig_hash);
}
$updraftplus->uploaded_file($file);
} elseif ($any_attempted) {
$updraftplus->log('Mails were not sent successfully');
$updraftplus->log(__('The attempt to send the backup via email failed (probably the backup was too large for this method)', 'updraftplus'), 'error');
} else {
$updraftplus->log('No email addresses were configured to send to');
}
}
return null;
}
示例8: getBackupsData
public function getBackupsData()
{
$backup_list = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
if (empty($backup_list)) {
return;
}
$backups = array();
foreach ($backup_list as $timestamp => $backups_info) {
$time_mm = strtotime("-{$this->last_months} month");
// If date more than 1 month - skip it
if (date('Y-m-d', $timestamp) < date('Y-m-d', $time_mm)) {
continue;
}
$this->backups_size = 0;
$this->backup_files = array();
$destinations = array();
if (is_array($backups_info)) {
if ($this->viewTypes && is_array($this->viewTypes)) {
foreach ($this->viewTypes as $type) {
$this->_addBackupElement($backups_info, $type);
}
}
if (isset($backups_info['service']) && !empty($backups_info['service'])) {
if (is_array($backups_info['service'])) {
foreach ($backups_info['service'] as $service) {
if ($service == 'none') {
$service = 'local';
}
$destinations[] = $service;
}
} else {
if ($backups_info['service'] == 'none') {
$backups_info['service'] = 'local';
}
$destinations[] = $backups_info['service'];
}
}
if (isset($this->backup_files) && is_array($this->backup_files) && !empty($this->backup_files)) {
$backups[date('Y-m-d', $timestamp)][] = array('timestamp' => $timestamp, 'file' => $this->backup_files, 'dest' => $destinations, 'source' => null, 'size' => $this->backups_size, 'links' => array());
}
}
}
return $backups;
}
示例9: backup
public function backup($backup_array)
{
global $updraftplus, $updraftplus_backup;
$updraft_dir = trailingslashit($updraftplus->backups_dir_location());
$email = $updraftplus->just_one_email(UpdraftPlus_Options::get_updraft_option('updraft_email'), true);
if (!is_array($email)) {
$email = array($email);
}
foreach ($backup_array as $type => $file) {
$descrip_type = preg_match('/^(.*)\\d+$/', $type, $matches) ? $matches[1] : $type;
$fullpath = $updraft_dir . $file;
#if (file_exists($fullpath) && filesize($fullpath) > ...
$any_attempted = false;
$any_sent = false;
foreach ($email as $ind => $addr) {
if (!apply_filters('updraftplus_email_wholebackup', true, $addr, $ind, $type)) {
continue;
}
foreach (explode(',', $addr) as $sendmail_addr) {
$send_short = strlen($sendmail_addr) > 5 ? substr($sendmail_addr, 0, 5) . '...' : $sendmail_addr;
$updraftplus->log("{$file}: email to: {$send_short}");
$any_attempted = true;
$subject = __("WordPress Backup", 'updraftplus') . ': ' . get_bloginfo('name') . ' (UpdraftPlus ' . $updraftplus->version . ') ' . get_date_from_gmt(gmdate('Y-m-d H:i:s', $updraftplus->backup_time), 'Y-m-d H:i');
$sent = wp_mail(trim($sendmail_addr), $subject, sprintf(__("Backup is of: %s.", 'updraftplus'), site_url() . ' (' . $descrip_type . ')'), null, array($fullpath));
if ($sent) {
$any_sent = true;
}
}
}
if ($any_sent) {
$updraftplus->uploaded_file($file);
} elseif ($any_attempted) {
$updraftplus->log('Mails were not sent successfully');
$updraftplus->log(__('The attempt to send the backup via email failed (probably the backup was too large for this method)', 'updraftplus'), 'error');
} else {
$updraftplus->log('No email addresses were configured to send to');
}
}
return null;
}
示例10: unpack_package
function unpack_package($package, $delete_package = true)
{
global $wp_filesystem, $updraftplus;
$updraft_dir = $updraftplus->backups_dir_location();
// If not database, then it is a zip - unpack in the usual way
#if (!preg_match('/db\.gz(\.crypt)?$/i', $package)) return parent::unpack_package($updraft_dir.'/'.$package, $delete_package);
if (!preg_match('/db\\.gz(\\.crypt)?$/i', $package)) {
return $this->unpack_package_zip($updraft_dir . '/' . $package, $delete_package);
}
$backup_dir = $wp_filesystem->find_folder($updraft_dir);
// Unpack a database. The general shape of the following is copied from class-wp-upgrader.php
@set_time_limit(1800);
$this->skin->feedback('unpack_package');
$upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
@$wp_filesystem->mkdir($upgrade_folder, octdec($this->calculate_additive_chmod_oct(FS_CHMOD_DIR, 0775)));
//Clean up contents of upgrade directory beforehand.
$upgrade_files = $wp_filesystem->dirlist($upgrade_folder);
if (!empty($upgrade_files)) {
foreach ($upgrade_files as $file) {
$wp_filesystem->delete($upgrade_folder . $file['name'], true);
}
}
//We need a working directory
$working_dir = $upgrade_folder . basename($package, '.crypt');
# $working_dir_localpath = WP_CONTENT_DIR.'/upgrade/'. basename($package, '.crypt');
// Clean up working directory
if ($wp_filesystem->is_dir($working_dir)) {
$wp_filesystem->delete($working_dir, true);
}
if (!$wp_filesystem->mkdir($working_dir, octdec($this->calculate_additive_chmod_oct(FS_CHMOD_DIR, 0775)))) {
return new WP_Error('mkdir_failed', __('Failed to create a temporary directory', 'updraftplus') . ' (' . $working_dir . ')');
}
// Unpack package to working directory
if ($updraftplus->is_db_encrypted($package)) {
$this->skin->feedback('decrypt_database');
$encryption = UpdraftPlus_Options::get_updraft_option('updraft_encryptionphrase');
if (!$encryption) {
return new WP_Error('no_encryption_key', __('Decryption failed. The database file is encrypted, but you have no encryption key entered.', 'updraftplus'));
}
$plaintext = $updraftplus->decrypt(false, $encryption, $wp_filesystem->get_contents($backup_dir . $package));
if ($plaintext) {
$this->skin->feedback('decrypted_database');
if (!$wp_filesystem->put_contents($working_dir . '/backup.db.gz', $plaintext)) {
return new WP_Error('write_failed', __('Failed to write out the decrypted database to the filesystem', 'updraftplus'));
}
} else {
return new WP_Error('decryption_failed', __('Decryption failed. The most likely cause is that you used the wrong key.', 'updraftplus'));
}
} else {
if (!$wp_filesystem->copy($backup_dir . $package, $working_dir . '/backup.db.gz')) {
if ($wp_filesystem->errors->get_error_code()) {
foreach ($wp_filesystem->errors->get_error_messages() as $message) {
show_message($message);
}
}
return new WP_Error('copy_failed', $this->strings['copy_failed']);
}
}
// Once extracted, delete the package if required (non-recursive, is a file)
if ($delete_package) {
$wp_filesystem->delete($backup_dir . $package, false, true);
}
return $working_dir;
}
示例11: options_printpage
public function options_printpage()
{
if (!UpdraftPlus_Options::user_can_manage()) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
$options = $this->options->get_option(UDADDONS2_SLUG . '_options');
$user_and_pass_at_top = empty($options['email']) ? true : false;
$title = htmlspecialchars($this->title);
$mother = $this->mother;
echo <<<ENDHERE
\t<div class="wrap">
\t\t
ENDHERE;
$enter_credentials_begin = UpdraftPlus_Options::options_form_begin('', false);
if (is_multisite()) {
$enter_credentials_begin .= '<input type="hidden" name="action" value="update">';
}
$interested = htmlspecialchars(__('Interested in knowing about your UpdraftPlus.Com password security? Read about it here.', 'updraftplus'));
$connect = htmlspecialchars(__('Connect', 'updraftplus'));
$enter_credentials_end = <<<ENDHERE
\t\t\t<p style="margin-left: 258px;">
\t\t\t\t<input id="ud_connectsubmit" type="submit" class="button-primary" value="{$connect}" />
\t\t\t</p>
\t\t\t<p style="margin-left: 258px; font-size: 70%"><em><a href="http://updraftplus.com/faqs/tell-me-about-my-updraftplus-com-account/">{$interested}</a></em></p>
\t\t</form>
ENDHERE;
global $updraftplus_addons2;
// $this->connected = (!empty($options['email']) && !empty($options['password'])) ? $updraftplus_addons2->connection_status() : false;
$this->connected = !empty($options['email']) ? $updraftplus_addons2->connection_status() : false;
if (true !== $this->connected) {
if (is_wp_error($this->connected)) {
$connection_errors = array();
foreach ($this->connected->get_error_messages() as $key => $msg) {
$connection_errors[] = $msg;
}
} else {
if (!empty($options['email']) && !empty($options['password'])) {
$connection_errors = array(__('An unknown error occurred when trying to connect to UpdraftPlus.Com', 'updraftplus'));
}
}
$this->connected = false;
}
if ($this->connected) {
echo '<p style="clear: both; float: left;">' . __('You are presently <strong>connected</strong> to an UpdraftPlus.Com account.', 'updraftplus');
echo ' <a href="#" onclick="jQuery(\'#ud_connectsubmit\').click();">' . __('If you bought new add-ons, then follow this link to refresh your connection', 'updraftplus') . '</a>.';
if (!empty($options['password'])) {
echo ' ' . __("Note that after you have claimed your add-ons, you can remove your password (but not the email address) from the settings below, without affecting this site's access to updates.", 'updraftplus');
}
} else {
// $oval = is_object($this->plug_updatechecker) ? get_site_option($this->plug_updatechecker->optionName, null) : null;
// // Detect the case where the password has been removed
// if (is_object($oval) && !empty($oval->lastCheck) && time()-$oval->lastCheck < 86400*8) {
// } else {
echo "<p>" . __('You are presently <strong>not connected</strong> to an UpdraftPlus.Com account.', 'updraftplus');
// }
}
echo '</p>';
if (isset($connection_errors)) {
echo '<div class="error"><p><strong>' . __('Errors occurred when trying to connect to UpdraftPlus.Com:', 'updraftplus') . '</strong></p><ul>';
foreach ($connection_errors as $err) {
echo '<li style="list-style:disc inside;">' . $err . '</li>';
}
echo '</ul></div>';
}
global $updraftplus_addons2;
$sid = $updraftplus_addons2->siteid();
$home_url = home_url();
// Enumerate possible unclaimed/re-claimable purchases, and what should be active on this site
$unclaimed_available = array();
$assigned = array();
$have_all = false;
if ($this->connected && isset($updraftplus_addons2->user_addons) && is_array($updraftplus_addons2->user_addons)) {
foreach ($updraftplus_addons2->user_addons as $akey => $addon) {
// Keys: site, sitedescription, key, status
if (isset($addon['status']) && 'active' == $addon['status'] && isset($addon['site']) && ('unclaimed' == $addon['site'] || 'unlimited' == $addon['site'])) {
$key = $addon['key'];
$unclaimed_available[$key] = array('eid' => $akey, 'status' => 'available');
} elseif (isset($addon['status']) && 'active' == $addon['status'] && isset($addon['site']) && $addon['site'] == $sid) {
$key = $addon['key'];
$assigned[$key] = $akey;
if ('all' == $key) {
$have_all = true;
}
} elseif (isset($addon['sitedescription']) && ($home_url === $addon['sitedescription'] || 0 === strpos($addon['sitedescription'], $home_url . ' - '))) {
# Is assigned to a site with the same URL as this one - allow a reclaim
$key = $addon['key'];
$unclaimed_available[$key] = array('eid' => $akey, 'status' => 'reclaimable');
}
}
}
if (!$this->connected) {
$this->show_credentials_form($enter_credentials_begin, $enter_credentials_end);
}
$email = isset($options['email']) ? $options['email'] : '';
$pass = isset($options['password']) ? base64_encode($options['password']) : '';
$sn = base64_encode(get_bloginfo('name'));
$su = base64_encode($home_url);
$ourpageslug = UDADDONS2_PAGESLUG;
$mother = $this->mother;
//$href = (is_multisite()) ? 'settings.php' : 'options-general.php';
//.........这里部分代码省略.........
示例12: save_settings
public function save_settings($settings)
{
global $updraftplus;
// Make sure that settings filters are registered
UpdraftPlus_Options::admin_init();
$return_array = array('saved' => true, 'changed' => array());
$add_to_post_keys = array('updraft_interval', 'updraft_interval_database', 'updraft_starttime_files', 'updraft_starttime_db', 'updraft_startday_files', 'updraft_startday_db');
//If database and files are on same schedule, override the db day/time settings
if (isset($settings['updraft_interval_database']) && isset($settings['updraft_interval_database']) && $settings['updraft_interval_database'] == $settings['updraft_interval'] && isset($settings['updraft_starttime_files'])) {
$settings['updraft_starttime_db'] = $settings['updraft_starttime_files'];
$settings['updraft_startday_db'] = $settings['updraft_startday_files'];
}
foreach ($add_to_post_keys as $key) {
// For add-ons that look at $_POST to find saved settings, add the relevant keys to $_POST so that they find them there
if (isset($settings[$key])) {
$_POST[$key] = $settings[$key];
}
}
// Wipe the extra retention rules, as they are not saved correctly if the last one is deleted
UpdraftPlus_Options::update_updraft_option('updraft_retain_extrarules', array());
UpdraftPlus_Options::update_updraft_option('updraft_email', array());
UpdraftPlus_Options::update_updraft_option('updraft_report_warningsonly', array());
UpdraftPlus_Options::update_updraft_option('updraft_report_wholebackup', array());
UpdraftPlus_Options::update_updraft_option('updraft_extradbs', array());
UpdraftPlus_Options::update_updraft_option('updraft_include_more_path', array());
$relevant_keys = $updraftplus->get_settings_keys();
if (method_exists('UpdraftPlus_Options', 'mass_options_update')) {
$settings = UpdraftPlus_Options::mass_options_update($settings);
$mass_updated = true;
}
foreach ($settings as $key => $value) {
// $exclude_keys = array('option_page', 'action', '_wpnonce', '_wp_http_referer');
// if (!in_array($key, $exclude_keys)) {
if (in_array($key, $relevant_keys)) {
if ($key == "updraft_service" && is_array($value)) {
foreach ($value as $subkey => $subvalue) {
if ($subvalue == '0') {
unset($value[$subkey]);
}
}
}
$updated = empty($mass_updated) ? UpdraftPlus_Options::update_updraft_option($key, $value) : true;
// Add information on what has changed to array to loop through to update links etc.
if ($updated) {
$return_array['changed'][$key] = $value;
} elseif (empty($mass_updated) && $key == 'updraft_interval') {
//To schedule a database when the interval is not changed.
$updraftplus->schedule_backup($value);
} elseif (empty($mass_updated) && $key == 'updraft_interval_database') {
$updraftplus->schedule_backup_database($value);
}
} else {
// When last active, it was catching: option_page, action, _wpnonce, _wp_http_referer, updraft_s3_endpoint, updraft_dreamobjects_endpoint. The latter two are empty; probably don't need to be in the page at all.
//error_log("Non-UD key when saving from POSTed data: ".$key);
}
}
// Checking for various possible messages
$updraft_dir = $updraftplus->backups_dir_location(false);
$really_is_writable = $updraftplus->really_is_writable($updraft_dir);
$dir_info = $this->really_writable_message($really_is_writable, $updraft_dir);
$button_title = esc_attr(__('This button is disabled because your backup directory is not writable (see the settings).', 'updraftplus'));
$return_array['backup_now_message'] = $this->backup_now_remote_message();
$return_array['backup_dir'] = array('writable' => $really_is_writable, 'message' => $dir_info, 'button_title' => $button_title);
//Because of the single AJAX call, we need to remove the existing UD messages from the 'all_admin_notices' action
remove_all_actions('all_admin_notices');
//Moving from 2 to 1 ajax call
ob_start();
$service = UpdraftPlus_Options::get_updraft_option('updraft_service');
$this->setup_all_admin_notices_global($service);
$this->setup_all_admin_notices_udonly($service);
do_action('all_admin_notices');
if (!$really_is_writable) {
//Check if writable
$this->show_admin_warning_unwritable();
}
if ($return_array['saved'] == true) {
//
$this->show_admin_warning(__('Your settings have been saved.', 'updraftplus'), 'updated fade');
}
$messages_output = ob_get_contents();
ob_clean();
// Backup schedule output
$this->next_scheduled_backups_output();
$scheduled_output = ob_get_clean();
$return_array['messages'] = $messages_output;
$return_array['scheduled'] = $scheduled_output;
return $return_array;
}
示例13: backup_wpcore_dirlist
public function backup_wpcore_dirlist($whichdir, $logit = false)
{
// Need to properly analyse the plugins, themes, uploads, content paths in order to strip them out (they may have various non-default manual values)
global $updraftplus;
if (false !== ($wpcore_dirlist = apply_filters('updraftplus_dirlist_wpcore_override', false, $whichdir))) {
return $wpcore_dirlist;
}
$possible_backups = $updraftplus->get_backupable_file_entities(false);
# We don't want to exclude the very thing we are backing up
unset($possible_backups['wpcore']);
# We do want to exclude everything in wp-content
$possible_backups['wp-content'] = WP_CONTENT_DIR;
foreach ($possible_backups as $key => $dir) {
if (is_array($dir)) {
foreach ($dir as $ind => $rdir) {
if (!empty($rdir)) {
$possible_backups_dirs[$rdir] = $key . $ind;
}
}
} else {
if (!empty($dir)) {
$possible_backups_dirs[$dir] = $key;
}
}
}
# Create an array of directories to be skipped
$exclude = UpdraftPlus_Options::get_updraft_option('updraft_include_wpcore_exclude', '');
if ($logit) {
$updraftplus->log("Exclusion option setting (wpcore): " . $exclude);
}
# Make the values into the keys
$wpcore_skip = array_flip(preg_split("/,/", $exclude));
$wpcore_skip['wp_content'] = 0;
// Removing the slash is important (though ought to be redundant by here); otherwise path matching does not work
$wpcore_dirlist = $updraftplus->compile_folder_list_for_backup(untrailingslashit($whichdir), $possible_backups_dirs, $wpcore_skip);
// This is not required to be a perfect test. The point is to make sure we do get WP core.
// Not using this approach for now.
// if (true == apply_filters('updraftplus_backup_wpcore_dirlist_strict', false)) {
// $wpcore_valid = array('wp-admin', 'wp-includes', 'index.php', 'xmlrpc.php');
// foreach ($wpcore_dirlist as $dir) {
//
// }
// }
return $wpcore_dirlist;
}
示例14: vault_connect
private function vault_connect($email, $password)
{
// Username and password set up?
if (empty($email) || empty($password)) {
return new WP_Error('blank_details', __('You need to supply both an email address and a password', 'updraftplus'));
}
global $updraftplus;
// Use SSL to prevent snooping
$result = wp_remote_post($this->vault_mothership . '/?udm_action=vault_connect', array('timeout' => 20, 'body' => array('e' => $email, 'p' => base64_encode($password), 'sid' => $updraftplus->siteid(), 'su' => base64_encode(home_url()))));
if (is_wp_error($result) || false === $result) {
return $result;
}
$response = json_decode($result['body'], true);
if (!is_array($response) || !isset($response['mothership']) || !isset($response['loggedin'])) {
if (preg_match('/has banned your IP address \\(([\\.:0-9a-f]+)\\)/', $result['body'], $matches)) {
return new WP_Error('banned_ip', sprintf(__("UpdraftPlus.com has responded with 'Access Denied'.", 'updraftplus') . '<br>' . __("It appears that your web server's IP Address (%s) is blocked.", 'updraftplus') . ' ' . __('This most likely means that you share a webserver with a hacked website that has been used in previous attacks.', 'updraftplus') . '<br> <a href="https://updraftplus.com/unblock-ip-address/" target="_blank">' . __('To remove the block, please go here.', 'updraftplus') . '</a> ', $matches[1]));
} else {
return new WP_Error('unknown_response', sprintf(__('UpdraftPlus.Com returned a response which we could not understand (data: %s)', 'updraftplus'), $result['body']));
}
}
switch ($response['loggedin']) {
case 'connected':
if (!empty($response['token'])) {
// Store it
$vault_settings = UpdraftPlus_Options::get_updraft_option('updraft_updraftvault');
if (!is_array($vault_settings)) {
$vault_settings = array();
}
$vault_settings['email'] = $email;
$vault_settings['token'] = (string) $response['token'];
$vault_settings['quota'] = -1;
unset($vault_settings['last_config']);
if (isset($response['quota'])) {
$vault_settings['quota'] = $response['quota'];
}
UpdraftPlus_Options::update_updraft_option('updraft_updraftvault', $vault_settings);
if (!empty($response['config']) && is_array($response['config']) && !empty($response['config']['accesskey'])) {
$this->vault_set_config($response['config']);
}
} elseif (isset($response['quota']) && !$response['quota']) {
return new WP_Error('no_quota', __('You do not currently have any UpdraftPlus Vault quota', 'updraftplus'));
} else {
return new WP_Error('unknown_response', __('UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus'));
}
break;
case 'authfailed':
if (!empty($response['authproblem'])) {
if ('invalidpassword' == $response['authproblem']) {
$authfail_error = new WP_Error('authfailed', __('Your email address was valid, but your password was not recognised by UpdraftPlus.Com.', 'updraftplus') . ' <a href="https://updraftplus.com/my-account/lost-password/">' . __('If you have forgotten your password, then go here to change your password on updraftplus.com.', 'updraftplus') . '</a>');
return $authfail_error;
} elseif ('invaliduser' == $response['authproblem']) {
return new WP_Error('authfailed', __('You entered an email address that was not recognised by UpdraftPlus.Com', 'updraftplus'));
}
}
return new WP_Error('authfailed', __('Your email address and password were not recognised by UpdraftPlus.Com', 'updraftplus'));
break;
default:
return new WP_Error('unknown_response', __('UpdraftPlus.Com returned a response, but we could not understand it', 'updraftplus'));
break;
}
return true;
}
示例15: restore_backup
private function restore_backup($timestamp)
{
@set_time_limit(900);
global $wp_filesystem, $updraftplus;
$backup_history = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
if (!is_array($backup_history[$timestamp])) {
echo '<p>' . __('This backup does not exist in the backup history - restoration aborted. Timestamp:', 'updraftplus') . " {$timestamp}</p><br/>";
return new WP_Error('does_not_exist', __('Backup does not exist in the backup history', 'updraftplus'));
}
// request_filesystem_credentials passes on fields just via hidden name/value pairs.
// Build array of parameters to be passed via this
$extra_fields = array();
if (isset($_POST['updraft_restore']) && is_array($_POST['updraft_restore'])) {
foreach ($_POST['updraft_restore'] as $entity) {
$_POST['updraft_restore_' . $entity] = 1;
$extra_fields[] = 'updraft_restore_' . $entity;
}
}
// Now make sure that updraft_restorer_ option fields get passed along to request_filesystem_credentials
foreach ($_POST as $key => $value) {
if (0 === strpos($key, 'updraft_restorer_')) {
$extra_fields[] = $key;
}
}
$credentials = request_filesystem_credentials(UpdraftPlus_Options::admin_page() . "?page=updraftplus&action=updraft_restore&backup_timestamp={$timestamp}", '', false, false, $extra_fields);
WP_Filesystem($credentials);
if ($wp_filesystem->errors->get_error_code()) {
echo '<p><em><a href="http://updraftplus.com/faqs/asked-ftp-details-upon-restorationmigration-updates/">' . __('Why am I seeing this?', 'updraftplus') . '</a></em></p>';
foreach ($wp_filesystem->errors->get_error_messages() as $message) {
show_message($message);
}
exit;
}
# Set up logging
$updraftplus->backup_time_nonce();
$updraftplus->jobdata_set('job_type', 'restore');
$updraftplus->jobdata_set('job_time_ms', $updraftplus->job_time_ms);
$updraftplus->logfile_open($updraftplus->nonce);
# Provide download link for the log file
#echo '<p><a target="_new" href="?action=downloadlog&page=updraftplus&updraftplus_backup_nonce='.htmlspecialchars($updraftplus->nonce).'">'.__('Follow this link to download the log file for this restoration.', 'updraftplus').'</a></p>';
# TODO: Automatic purging of old log files
# TODO: Provide option to auto-email the log file
//if we make it this far then WP_Filesystem has been instantiated and is functional (tested with ftpext, what about suPHP and other situations where direct may work?)
echo '<h1>' . __('UpdraftPlus Restoration: Progress', 'updraftplus') . '</h1><div id="updraft-restore-progress">';
$this->show_admin_warning('<a target="_new" href="?action=downloadlog&page=updraftplus&updraftplus_backup_nonce=' . htmlspecialchars($updraftplus->nonce) . '">' . __('Follow this link to download the log file for this restoration (needed for any support requests).', 'updraftplus') . '</a>');
$updraft_dir = trailingslashit($updraftplus->backups_dir_location());
$foreign_known = apply_filters('updraftplus_accept_archivename', array());
$service = isset($backup_history[$timestamp]['service']) ? $backup_history[$timestamp]['service'] : false;
if (!is_array($service)) {
$service = array($service);
}
// Now, need to turn any updraft_restore_<entity> fields (that came from a potential WP_Filesystem form) back into parts of the _POST array (which we want to use)
if (empty($_POST['updraft_restore']) || !is_array($_POST['updraft_restore'])) {
$_POST['updraft_restore'] = array();
}
$backup_set = $backup_history[$timestamp];
$entities_to_restore = array();
foreach ($_POST['updraft_restore'] as $entity) {
if (empty($backup_set['meta_foreign'])) {
$entities_to_restore[$entity] = $entity;
} else {
if ('db' == $entity && !empty($foreign_known[$backup_set['meta_foreign']]) && !empty($foreign_known[$backup_set['meta_foreign']]['separatedb'])) {
$entities_to_restore[$entity] = 'db';
} else {
$entities_to_restore[$entity] = 'wpcore';
}
}
}
foreach ($_POST as $key => $value) {
if (0 === strpos($key, 'updraft_restore_')) {
$nkey = substr($key, 16);
if (!isset($entities_to_restore[$nkey])) {
$_POST['updraft_restore'][] = $nkey;
if (empty($backup_set['meta_foreign'])) {
$entities_to_restore[$nkey] = $nkey;
} else {
if ('db' == $entity && !empty($foreign_known[$backup_set['meta_foreign']]['separatedb'])) {
$entities_to_restore[$nkey] = 'db';
} else {
$entities_to_restore[$nkey] = 'wpcore';
}
}
}
}
}
if (0 == count($_POST['updraft_restore'])) {
echo '<p>' . __('ABORT: Could not find the information on which entities to restore.', 'updraftplus') . '</p>';
echo '<p>' . __('If making a request for support, please include this information:', 'updraftplus') . ' ' . count($_POST) . ' : ' . htmlspecialchars(serialize($_POST)) . '</p>';
return new WP_Error('missing_info', 'Backup information not found');
}
$updraftplus->log("Restore job started. Entities to restore: " . implode(', ', array_flip($entities_to_restore)));
$this->entities_to_restore = $entities_to_restore;
set_error_handler(array($updraftplus, 'php_error'), E_ALL & ~E_STRICT);
/*
$_POST['updraft_restore'] is typically something like: array( 0=>'db', 1=>'plugins', 2=>'themes'), etc.
i.e. array ( 'db', 'plugins', themes')
*/
$backupable_entities = $updraftplus->get_backupable_file_entities(true, true);
uksort($backup_set, array($this, 'sort_restoration_entities'));
// We use a single object for each entity, because we want to store information about the backup set
//.........这里部分代码省略.........