本文整理汇总了PHP中BackWPup_Encryption::decrypt方法的典型用法代码示例。如果您正苦于以下问题:PHP BackWPup_Encryption::decrypt方法的具体用法?PHP BackWPup_Encryption::decrypt怎么用?PHP BackWPup_Encryption::decrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackWPup_Encryption
的用法示例。
在下文中一共展示了BackWPup_Encryption::decrypt方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param string $boxtype
* @throws BackWPup_Destination_Dropbox_API_Exception
*/
public function __construct($boxtype = 'dropbox')
{
if ($boxtype == 'dropbox') {
$this->oauth_app_key = get_site_option('backwpup_cfg_dropboxappkey', base64_decode("dHZkcjk1MnRhZnM1NmZ2"));
$this->oauth_app_secret = BackWPup_Encryption::decrypt(get_site_option('backwpup_cfg_dropboxappsecret', base64_decode("OWV2bDR5MHJvZ2RlYmx1")));
$this->root = 'dropbox';
} else {
$this->oauth_app_key = get_site_option('backwpup_cfg_dropboxsandboxappkey', base64_decode("cHVrZmp1a3JoZHR5OTFk"));
$this->oauth_app_secret = BackWPup_Encryption::decrypt(get_site_option('backwpup_cfg_dropboxsandboxappsecret', base64_decode("eGNoYzhxdTk5eHE0eWdq")));
$this->root = 'sandbox';
}
if (empty($this->oauth_app_key) or empty($this->oauth_app_secret)) {
throw new BackWPup_Destination_Dropbox_API_Exception("No App key or App Secret specified.");
}
}
示例2: edit_ajax
/**
* @param string $args
*/
public function edit_ajax($args = '')
{
$error = '';
if (is_array($args)) {
$ajax = FALSE;
} else {
if (!current_user_can('backwpup_jobs_edit')) {
wp_die(-1);
}
check_ajax_referer('backwpup_ajax_nonce');
$args['msazureaccname'] = $_POST['msazureaccname'];
$args['msazurekey'] = $_POST['msazurekey'];
$args['msazureselected'] = $_POST['msazureselected'];
$ajax = TRUE;
}
echo '<span id="msazurecontainererror" style="color:red;">';
if (!empty($args['msazureaccname']) && !empty($args['msazurekey'])) {
try {
set_include_path(get_include_path() . PATH_SEPARATOR . BackWPup::get_plugin_data('plugindir') . '/vendor/PEAR/');
$blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService('DefaultEndpointsProtocol=https;AccountName=' . $args['msazureaccname'] . ';AccountKey=' . BackWPup_Encryption::decrypt($args['msazurekey']));
$containers = $blobRestProxy->listContainers()->getContainers();
} catch (Exception $e) {
$error = $e->getMessage();
}
}
if (empty($args['msazureaccname'])) {
_e('Missing account name!', 'backwpup');
} elseif (empty($args['msazurekey'])) {
_e('Missing access key!', 'backwpup');
} elseif (!empty($error)) {
echo esc_html($error);
} elseif (empty($containers)) {
_e('No container found!', 'backwpup');
}
echo '</span>';
if (!empty($containers)) {
echo '<select name="msazurecontainer" id="msazurecontainer">';
foreach ($containers as $container) {
echo "<option " . selected(strtolower($args['msazureselected']), strtolower($container->getName()), FALSE) . ">" . $container->getName() . "</option>";
}
echo '</select>';
}
if ($ajax) {
die;
} else {
return;
}
}
示例3: edit_ajax
/**
* @param string $args
*/
public function edit_ajax($args = '')
{
$error = '';
if (is_array($args)) {
$ajax = FALSE;
} else {
if (!current_user_can('backwpup_jobs_edit')) {
wp_die(-1);
}
check_ajax_referer('backwpup_ajax_nonce');
$args['s3accesskey'] = $_POST['s3accesskey'];
$args['s3secretkey'] = $_POST['s3secretkey'];
$args['s3bucketselected'] = $_POST['s3bucketselected'];
$args['s3base_url'] = $_POST['s3base_url'];
$args['s3region'] = $_POST['s3region'];
$ajax = TRUE;
}
echo '<span id="s3bucketerror" style="color:red;">';
if (!empty($args['s3accesskey']) && !empty($args['s3secretkey'])) {
try {
$s3 = new AmazonS3(array('key' => $args['s3accesskey'], 'secret' => BackWPup_Encryption::decrypt($args['s3secretkey']), 'certificate_authority' => TRUE));
$base_url = $this->get_s3_base_url($args['s3region'], $args['s3base_url']);
if (stristr($base_url, 'amazonaws.com')) {
$s3->set_region(str_replace(array('http://', 'https://'), '', $base_url));
} else {
$s3->set_hostname(str_replace(array('http://', 'https://'), '', $base_url));
$s3->allow_hostname_override(FALSE);
if (substr($base_url, -1) == '/') {
$s3->enable_path_style(TRUE);
}
}
if (stristr($base_url, 'http://')) {
$s3->disable_ssl();
}
$buckets = $s3->list_buckets();
} catch (Exception $e) {
$error = $e->getMessage();
}
}
if (empty($args['s3accesskey'])) {
_e('Missing access key!', 'backwpup');
} elseif (empty($args['s3secretkey'])) {
_e('Missing secret access key!', 'backwpup');
} elseif (!empty($error) && $error == 'Access Denied') {
echo '<input type="text" name="s3bucket" id="s3bucket" value="' . esc_attr($args['s3bucketselected']) . '" >';
} elseif (!empty($error)) {
echo esc_html($error);
} elseif (!isset($buckets) || count($buckets->body->Buckets->Bucket) < 1) {
_e('No bucket found!', 'backwpup');
}
echo '</span>';
if (!empty($buckets->body->Buckets->Bucket)) {
echo '<select name="s3bucket" id="s3bucket">';
foreach ($buckets->body->Buckets->Bucket as $bucket) {
echo "<option " . selected($args['s3bucketselected'], esc_attr($bucket->Name), FALSE) . ">" . esc_attr($bucket->Name) . "</option>";
}
echo '</select>';
}
if ($ajax) {
die;
}
}
示例4: create_account
/**
* @param $email
* @param $password
* @throws BackWPup_Destination_SugarSync_API_Exception
*/
public function create_account($email, $password)
{
$auth = '<?xml version="1.0" encoding="UTF-8" ?>';
$auth .= '<user>';
$auth .= '<email>' . mb_convert_encoding($email, 'UTF-8', $this->encoding) . '</email>';
$auth .= '<password>' . mb_convert_encoding($password, 'UTF-8', $this->encoding) . '</password>';
$auth .= '<accessKeyId>' . get_site_option('backwpup_cfg_sugarsynckey', base64_decode("TlRBek1EY3lOakV6TkRrMk1URXhNemM0TWpJ")) . '</accessKeyId>';
$auth .= '<privateAccessKey>' . BackWPup_Encryption::decrypt(get_site_option('backwpup_cfg_sugarsyncsecret', base64_decode("TkRFd01UazRNVEpqTW1Ga05EaG1NR0k1TVRFNFpqa3lPR1V6WlRVMk1tTQ=="))) . '</privateAccessKey>';
$auth .= '</user>';
// init
$curl = curl_init();
//set options
curl_setopt($curl, CURLOPT_URL, 'https://provisioning-api.sugarsync.com/users');
curl_setopt($curl, CURLOPT_USERAGENT, BackWPup::get_plugin_data('User-Agent'));
if (ini_get('open_basedir') == '') {
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
if (BackWPup::get_plugin_data('cacert')) {
curl_setopt($curl, CURLOPT_SSLVERSION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($curl, CURLOPT_CAINFO, BackWPup::get_plugin_data('cacert'));
curl_setopt($curl, CURLOPT_CAPATH, dirname(BackWPup::get_plugin_data('cacert')));
} else {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
}
curl_setopt($curl, CURLOPT_HEADER, TRUE);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/xml; charset=UTF-8', 'Content-Length: ' . strlen($auth)));
curl_setopt($curl, CURLOPT_POSTFIELDS, $auth);
curl_setopt($curl, CURLOPT_POST, TRUE);
// execute
$response = curl_exec($curl);
$curlgetinfo = curl_getinfo($curl);
// fetch curl errors
if (curl_errno($curl) != 0) {
throw new BackWPup_Destination_SugarSync_API_Exception('cUrl Error: ' . curl_error($curl));
}
curl_close($curl);
if ($curlgetinfo['http_code'] == 201) {
throw new BackWPup_Destination_SugarSync_API_Exception('Account created.');
} else {
if ($curlgetinfo['http_code'] == 400) {
throw new BackWPup_Destination_SugarSync_API_Exception('Http Error: ' . $curlgetinfo['http_code'] . ' ' . substr($response, $curlgetinfo['header_size']));
} elseif ($curlgetinfo['http_code'] == 401) {
throw new BackWPup_Destination_SugarSync_API_Exception('Http Error: ' . $curlgetinfo['http_code'] . ' Developer credentials cannot be verified. Either a developer with the specified accessKeyId does not exist or the privateKeyID does not match an assigned accessKeyId.');
} elseif ($curlgetinfo['http_code'] == 403) {
throw new BackWPup_Destination_SugarSync_API_Exception('Http Error: ' . $curlgetinfo['http_code'] . ' ' . substr($response, $curlgetinfo['header_size']));
} elseif ($curlgetinfo['http_code'] == 503) {
throw new BackWPup_Destination_SugarSync_API_Exception('Http Error: ' . $curlgetinfo['http_code'] . ' ' . substr($response, $curlgetinfo['header_size']));
} else {
throw new BackWPup_Destination_SugarSync_API_Exception('Http Error: ' . $curlgetinfo['http_code']);
}
}
}
示例5: get_jobrun_url
/**
*
* Get a url to run a job of BackWPup
*
* @param string $starttype Start types are 'runnow', 'runnowlink', 'cronrun', 'runext', 'restart', 'restartalt', 'test'
* @param int $jobid The id of job to start else 0
*
* @return array|object [url] is the job url [header] for auth header or object form wp_remote_get()
*/
public static function get_jobrun_url($starttype, $jobid = 0)
{
$authentication = get_site_option('backwpup_cfg_authentication', array('method' => '', 'basic_user' => '', 'basic_password' => '', 'user_id' => 0, 'query_arg' => ''));
$url = site_url('wp-cron.php');
$header = array('Cache-Control' => 'no-cache');
$authurl = '';
$query_args = array('_nonce' => substr(wp_hash(wp_nonce_tick() . 'backwpup_job_run-' . $starttype, 'nonce'), -12, 10), 'doing_wp_cron' => sprintf('%.22F', microtime(true)));
if (in_array($starttype, array('restart', 'runnow', 'cronrun', 'runext', 'test'), true)) {
$query_args['backwpup_run'] = $starttype;
}
if (in_array($starttype, array('runnowlink', 'runnow', 'cronrun', 'runext'), true) && !empty($jobid)) {
$query_args['jobid'] = $jobid;
}
if (!empty($authentication['basic_user']) && !empty($authentication['basic_password']) && $authentication['method'] == 'basic') {
$header['Authorization'] = 'Basic ' . base64_encode($authentication['basic_user'] . ':' . BackWPup_Encryption::decrypt($authentication['basic_password']));
$authurl = urlencode($authentication['basic_user']) . ':' . urlencode(BackWPup_Encryption::decrypt($authentication['basic_password'])) . '@';
}
if (!empty($authentication['query_arg']) && $authentication['method'] == 'query_arg') {
$url .= '?' . $authentication['query_arg'];
}
if ($starttype === 'runext') {
$query_args['_nonce'] = get_site_option('backwpup_cfg_jobrunauthkey');
$query_args['doing_wp_cron'] = null;
if (!empty($authurl)) {
$url = str_replace('https://', 'https://' . $authurl, $url);
$url = str_replace('http://', 'http://' . $authurl, $url);
}
}
if ($starttype === 'runnowlink' && (!defined('ALTERNATE_WP_CRON') || !ALTERNATE_WP_CRON)) {
$url = wp_nonce_url(network_admin_url('admin.php'), 'backwpup_job_run-' . $starttype);
$query_args['page'] = 'backwpupjobs';
$query_args['action'] = 'runnow';
$query_args['doing_wp_cron'] = null;
unset($query_args['_nonce']);
}
if ($starttype === 'runnowlink' && defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
$query_args['backwpup_run'] = 'runnowalt';
$query_args['_nonce'] = substr(wp_hash(wp_nonce_tick() . 'backwpup_job_run-runnowalt', 'nonce'), -12, 10);
$query_args['doing_wp_cron'] = null;
}
if ($starttype === 'restartalt' && defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
$query_args['backwpup_run'] = 'restart';
$query_args['_nonce'] = null;
}
if ($starttype === 'restart' || $starttype === 'test') {
$query_args['_nonce'] = null;
}
if (!empty($authentication['user_id']) && $authentication['method'] === 'user') {
//cache cookies for auth some
$cookies = get_site_transient('backwpup_cookies');
if (empty($cookies)) {
$wp_admin_user = get_users(array('role' => 'administrator', 'number' => 1));
if (empty($wp_admin_user)) {
$wp_admin_user = get_users(array('role' => 'backwpup_admin', 'number' => 1));
}
if (!empty($wp_admin_user[0]->ID)) {
$expiration = time() + 356 * DAY_IN_SECONDS;
$manager = WP_Session_Tokens::get_instance($wp_admin_user[0]->ID);
$token = $manager->create($expiration);
$cookies[LOGGED_IN_COOKIE] = wp_generate_auth_cookie($wp_admin_user[0]->ID, $expiration, 'logged_in', $token);
}
set_site_transient('backwpup_cookies', $cookies, HOUR_IN_SECONDS - 30);
}
} else {
$cookies = '';
}
$cron_request = array('url' => add_query_arg($query_args, $url), 'key' => $query_args['doing_wp_cron'], 'args' => array('blocking' => false, 'sslverify' => false, 'timeout' => 0.01, 'headers' => $header, 'user-agent' => BackWPup::get_plugin_data('User-Agent')));
if (!empty($cookies)) {
foreach ($cookies as $name => $value) {
$cron_request['args']['cookies'][] = new WP_Http_Cookie(array('name' => $name, 'value' => $value));
}
}
$cron_request = apply_filters('cron_request', $cron_request);
if ($starttype === 'test') {
$cron_request['args']['timeout'] = 15;
$cron_request['args']['blocking'] = true;
}
if (!in_array($starttype, array('runnowlink', 'runext', 'restartalt'), true)) {
delete_transient('doing_cron');
return wp_remote_post($cron_request['url'], $cron_request['args']);
}
return $cron_request;
}
示例6: edit_ajax
/**
* sends test mail
*/
public function edit_ajax()
{
check_ajax_referer('backwpup_ajax_nonce');
//get mail settings
$emailmethod = 'mail';
$emailsendmail = '';
$emailhost = '';
$emailhostport = '';
$emailsecure = '';
$emailuser = '';
$emailpass = '';
if (empty($_POST['emailmethod'])) {
//do so if i'm the wp_mail to get the settings
global $phpmailer;
// (Re)create it, if it's gone missing
if (!is_object($phpmailer) || !$phpmailer instanceof PHPMailer) {
require_once ABSPATH . WPINC . '/class-phpmailer.php';
require_once ABSPATH . WPINC . '/class-smtp.php';
$phpmailer = new PHPMailer(true);
}
//only if PHPMailer really used
if (is_object($phpmailer)) {
do_action_ref_array('phpmailer_init', array(&$phpmailer));
//get settings from PHPMailer
$emailmethod = $phpmailer->Mailer;
$emailsendmail = $phpmailer->Sendmail;
$emailhost = $phpmailer->Host;
$emailhostport = $phpmailer->Port;
$emailsecure = $phpmailer->SMTPSecure;
$emailuser = $phpmailer->Username;
$emailpass = $phpmailer->Password;
}
} else {
$emailmethod = $_POST['emailmethod'];
$emailsendmail = $_POST['emailsendmail'];
$emailhost = $_POST['emailhost'];
$emailhostport = $_POST['emailhostport'];
$emailsecure = $_POST['emailsecure'];
$emailuser = $_POST['emailuser'];
$emailpass = BackWPup_Encryption::decrypt($_POST['emailpass']);
}
//Generate mail with Swift Mailer
if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
}
try {
// Create the Transport
if ($emailmethod == 'smtp') {
$transport = Swift_SmtpTransport::newInstance($emailhost, $emailhostport);
$transport->setUsername($emailuser);
$transport->setPassword($emailpass);
if ($emailsecure == 'ssl') {
$transport->setEncryption('ssl');
}
if ($emailsecure == 'tls') {
$transport->setEncryption('tls');
}
} elseif ($emailmethod == 'sendmail') {
$transport = Swift_SendmailTransport::newInstance($emailsendmail);
} else {
$transport = Swift_MailTransport::newInstance();
}
// Create the Mailer using your created Transport
$emailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance(__('BackWPup archive sending TEST Message', 'backwpup'));
$message->setFrom(array($_POST['emailsndemail'] => isset($_POST['emailsndemailname']) ? $_POST['emailsndemailname'] : ''));
$message->setTo(array($_POST['emailaddress']));
$message->setBody(__('If this message reaches your inbox, sending backup archives via email should work for you.', 'backwpup'));
// Send the message
$result = $emailer->send($message);
} catch (Exception $e) {
echo '<span id="emailsendtext" style="color:red;">Swift Mailer: ' . $e->getMessage() . '</span>';
}
if (isset($mbEncoding)) {
mb_internal_encoding($mbEncoding);
}
if (!isset($result) || !$result) {
echo '<span id="emailsendtext" style="color:red;">' . __('Error while sending email!', 'backwpup') . '</span>';
} else {
echo '<span id="emailsendtext" style="color:green;">' . __('Email sent.', 'backwpup') . '</span>';
}
die;
}
示例7: job_run_archive
/**
* @param $job_object
* @return bool
*/
public function job_run_archive(BackWPup_Job $job_object)
{
$job_object->substeps_todo = 2 + $job_object->backup_filesize;
if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
$job_object->log(sprintf(__('%d. Try to send backup file to an FTP server …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']), E_USER_NOTICE);
}
if (!empty($job_object->job['ftpssl'])) {
//make SSL FTP connection
if (function_exists('ftp_ssl_connect')) {
$ftp_conn_id = ftp_ssl_connect($job_object->job['ftphost'], $job_object->job['ftphostport'], $job_object->job['ftptimeout']);
if ($ftp_conn_id) {
$job_object->log(sprintf(__('Connected via explicit SSL-FTP to server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_NOTICE);
} else {
$job_object->log(sprintf(__('Cannot connect via explicit SSL-FTP to server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_ERROR);
return FALSE;
}
} else {
$job_object->log(__('PHP function to connect with explicit SSL-FTP to server does not exist!', 'backwpup'), E_USER_ERROR);
return TRUE;
}
} else {
//make normal FTP connection if SSL not work
$ftp_conn_id = ftp_connect($job_object->job['ftphost'], $job_object->job['ftphostport'], $job_object->job['ftptimeout']);
if ($ftp_conn_id) {
$job_object->log(sprintf(__('Connected to FTP server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_NOTICE);
} else {
$job_object->log(sprintf(__('Cannot connect to FTP server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_ERROR);
return FALSE;
}
}
//FTP Login
$job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'USER ' . $job_object->job['ftpuser']), E_USER_NOTICE);
if ($loginok = @ftp_login($ftp_conn_id, $job_object->job['ftpuser'], BackWPup_Encryption::decrypt($job_object->job['ftppass']))) {
$job_object->log(sprintf(__('FTP server response: %s', 'backwpup'), 'User ' . $job_object->job['ftpuser'] . ' logged in.'), E_USER_NOTICE);
} else {
//if PHP ftp login don't work use raw login
$return = ftp_raw($ftp_conn_id, 'USER ' . $job_object->job['ftpuser']);
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $return[0]), E_USER_NOTICE);
if (substr(trim($return[0]), 0, 3) <= 400) {
$job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'PASS *******'), E_USER_NOTICE);
$return = ftp_raw($ftp_conn_id, 'PASS ' . BackWPup_Encryption::decrypt($job_object->job['ftppass']));
if (substr(trim($return[0]), 0, 3) <= 400) {
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $return[0]), E_USER_NOTICE);
$loginok = TRUE;
} else {
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $return[0]), E_USER_ERROR);
}
}
}
if (!$loginok) {
return FALSE;
}
//SYSTYPE
$job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'SYST'), E_USER_NOTICE);
$systype = ftp_systype($ftp_conn_id);
if ($systype) {
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $systype), E_USER_NOTICE);
} else {
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), __('Error getting SYSTYPE', 'backwpup')), E_USER_ERROR);
}
//set actual ftp dir to ftp dir
if (empty($job_object->job['ftpdir'])) {
$job_object->job['ftpdir'] = trailingslashit(ftp_pwd($ftp_conn_id));
}
// prepend actual ftp dir if relative dir
if (substr($job_object->job['ftpdir'], 0, 1) != '/') {
$job_object->job['ftpdir'] = trailingslashit(ftp_pwd($ftp_conn_id)) . $job_object->job['ftpdir'];
}
//test ftp dir and create it if not exists
if ($job_object->job['ftpdir'] != '/') {
@ftp_chdir($ftp_conn_id, '/');
//go to root
$ftpdirs = explode('/', trim($job_object->job['ftpdir'], '/'));
foreach ($ftpdirs as $ftpdir) {
if (empty($ftpdir)) {
continue;
}
if (!@ftp_chdir($ftp_conn_id, $ftpdir)) {
if (@ftp_mkdir($ftp_conn_id, $ftpdir)) {
$job_object->log(sprintf(__('FTP Folder "%s" created!', 'backwpup'), $ftpdir), E_USER_NOTICE);
ftp_chdir($ftp_conn_id, $ftpdir);
} else {
$job_object->log(sprintf(__('FTP Folder "%s" cannot be created!', 'backwpup'), $ftpdir), E_USER_ERROR);
return FALSE;
}
}
}
}
// Get the current working directory
$current_ftp_dir = trailingslashit(ftp_pwd($ftp_conn_id));
if ($job_object->substeps_done == 0) {
$job_object->log(sprintf(__('FTP current folder is: %s', 'backwpup'), $current_ftp_dir), E_USER_NOTICE);
}
//get file size to resume upload
@clearstatcache();
$job_object->substeps_done = @ftp_size($ftp_conn_id, $job_object->job['ftpdir'] . $job_object->backup_file);
//.........这里部分代码省略.........
示例8: page
//.........这里部分代码省略.........
<div class="table ui-tabs-hide" id="backwpup-tab-net">
<h3 class="title"><?php
_e('Authentication', 'backwpup');
?>
</h3>
<p><?php
_e('Is your blog protected with HTTP basic authentication (.htaccess)? If yes, please set the username and password for authentication here.', 'backwpup');
?>
</p>
<table class="form-table">
<tr>
<th scope="row"><label for="httpauthuser"><?php
_e('Username:', 'backwpup');
?>
</label></th>
<td>
<input name="httpauthuser" type="text" id="httpauthuser"
value="<?php
echo get_site_option('backwpup_cfg_httpauthuser');
?>
"
class="regular-text" autocomplete="off" />
</td>
</tr>
<tr>
<th scope="row"><label for="httpauthpassword"><?php
_e('Password:', 'backwpup');
?>
</label></th>
<td>
<input name="httpauthpassword" type="password" id="httpauthpassword"
value="<?php
echo BackWPup_Encryption::decrypt(get_site_option('backwpup_cfg_httpauthpassword'));
?>
"
class="regular-text" autocomplete="off" />
</tr>
</table>
</div>
<div class="table ui-tabs-hide" id="backwpup-tab-apikey">
<?php
do_action('backwpup_page_settings_tab_apikey');
?>
</div>
<div class="table ui-tabs-hide" id="backwpup-tab-information">
<br />
<?php
echo '<table class="wp-list-table widefat fixed" cellspacing="0" style="width: 85%;margin-left:auto;;margin-right:auto;">';
echo '<thead><tr><th width="35%">' . __('Setting', 'backwpup') . '</th><th>' . __('Value', 'backwpup') . '</th></tr></thead>';
echo '<tfoot><tr><th>' . __('Setting', 'backwpup') . '</th><th>' . __('Value', 'backwpup') . '</th></tr></tfoot>';
echo '<tr title=">=3.2"><td>' . __('WordPress version', 'backwpup') . '</td><td>' . BackWPup::get_plugin_data('wp_version') . '</td></tr>';
if (!class_exists('BackWPup_Pro', FALSE)) {
echo '<tr title=""><td>' . __('BackWPup version', 'backwpup') . '</td><td>' . BackWPup::get_plugin_data('Version') . ' <a href="' . translate(BackWPup::get_plugin_data('pluginuri'), 'backwpup') . '">' . __('Get pro.', 'backwpup') . '</a></td></tr>';
} else {
echo '<tr title=""><td>' . __('BackWPup Pro version', 'backwpup') . '</td><td>' . BackWPup::get_plugin_data('Version') . '</td></tr>';
}
echo '<tr title=">=5.3.3"><td>' . __('PHP version', 'backwpup') . '</td><td>' . PHP_VERSION . '</td></tr>';
echo '<tr title=">=5.0.7"><td>' . __('MySQL version', 'backwpup') . '</td><td>' . $wpdb->get_var("SELECT VERSION() AS version") . '</td></tr>';
if (function_exists('curl_version')) {
$curlversion = curl_version();
示例9: edit_ajax
/**
* @param string $args
*/
public function edit_ajax($args = '')
{
$error = '';
if (is_array($args)) {
$ajax = FALSE;
} else {
if (!current_user_can('backwpup_jobs_edit')) {
wp_die(-1);
}
check_ajax_referer('backwpup_ajax_nonce');
$args['rscusername'] = $_POST['rscusername'];
$args['rscapikey'] = $_POST['rscapikey'];
$args['rscselected'] = $_POST['rscselected'];
$args['rscregion'] = $_POST['rscregion'];
$ajax = TRUE;
}
echo '<span id="rsccontainererror" style="color:red;">';
$container_list = array();
if (!empty($args['rscusername']) && !empty($args['rscapikey']) && !empty($args['rscregion'])) {
try {
$conn = new OpenCloud\Rackspace(self::get_auth_url_by_region($args['rscregion']), array('username' => $args['rscusername'], 'apiKey' => BackWPup_Encryption::decrypt($args['rscapikey'])));
$ostore = $conn->objectStoreService('cloudFiles', $args['rscregion'], 'publicURL');
$containerlist = $ostore->listContainers();
while ($container = $containerlist->next()) {
$container_list[] = $container->name;
}
} catch (Exception $e) {
$error = $e->getMessage();
}
}
if (empty($args['rscusername'])) {
_e('Missing username!', 'backwpup');
} elseif (empty($args['rscapikey'])) {
_e('Missing API Key!', 'backwpup');
} elseif (!empty($error)) {
echo esc_html($error);
} elseif (empty($container_list)) {
_e("A container could not be found!", 'backwpup');
}
echo '</span>';
if (!empty($container_list)) {
echo '<select name="rsccontainer" id="rsccontainer">';
foreach ($container_list as $container_name) {
echo "<option " . selected(strtolower($args['rscselected']), strtolower($container_name), FALSE) . ">" . $container_name . "</option>";
}
echo '</select>';
}
if ($ajax) {
die;
} else {
return;
}
}
示例10: edit_ajax
/**
* @param string $args
*/
public function edit_ajax($args = '')
{
$error = '';
$buckets_list = array();
if (is_array($args)) {
$ajax = FALSE;
} else {
if (!current_user_can('backwpup_jobs_edit')) {
wp_die(-1);
}
check_ajax_referer('backwpup_ajax_nonce');
$args['s3accesskey'] = sanitize_text_field($_POST['s3accesskey']);
$args['s3secretkey'] = sanitize_text_field($_POST['s3secretkey']);
$args['s3bucketselected'] = sanitize_text_field($_POST['s3bucketselected']);
$args['s3base_url'] = esc_url_raw($_POST['s3base_url']);
$args['s3region'] = sanitize_text_field($_POST['s3region']);
$ajax = TRUE;
}
echo '<span id="s3bucketerror" style="color:red;">';
if (!empty($args['s3accesskey']) && !empty($args['s3secretkey'])) {
try {
$s3 = Aws\S3\S3Client::factory(array('key' => $args['s3accesskey'], 'secret' => BackWPup_Encryption::decrypt($args['s3secretkey']), 'region' => $args['s3region'], 'base_url' => $this->get_s3_base_url($args['s3region'], $args['s3base_url']), 'scheme' => 'https', 'ssl.certificate_authority' => BackWPup::get_plugin_data('cacert')));
$buckets = $s3->listBuckets();
if (!empty($buckets['Buckets'])) {
$buckets_list = $buckets['Buckets'];
}
while (!empty($vaults['Marker'])) {
$buckets = $s3->listBuckets(array('marker' => $buckets['Marker']));
if (!empty($buckets['Buckets'])) {
$buckets_list = array_merge($buckets_list, $buckets['Buckets']);
}
}
} catch (Exception $e) {
$error = $e->getMessage();
}
}
if (empty($args['s3accesskey'])) {
_e('Missing access key!', 'backwpup');
} elseif (empty($args['s3secretkey'])) {
_e('Missing secret access key!', 'backwpup');
} elseif (!empty($error) && $error == 'Access Denied') {
echo '<input type="text" name="s3bucket" id="s3bucket" value="' . esc_attr($args['s3bucketselected']) . '" >';
} elseif (!empty($error)) {
echo esc_html($error);
} elseif (!isset($buckets) || count($buckets['Buckets']) < 1) {
_e('No bucket found!', 'backwpup');
}
echo '</span>';
if (!empty($buckets_list)) {
echo '<select name="s3bucket" id="s3bucket">';
foreach ($buckets_list as $bucket) {
echo "<option " . selected($args['s3bucketselected'], esc_attr($bucket['Name']), FALSE) . ">" . esc_attr($bucket['Name']) . "</option>";
}
echo '</select>';
}
if ($ajax) {
die;
}
}
示例11: page
//.........这里部分代码省略.........
</label>
</fieldset>
</td>
</tr>
<tr class="authentication_basic" <?php
if ($authentication['method'] !== 'basic') {
echo 'style="display:none"';
}
?>
>
<th scope="row"><label for="authentication_basic_user"><?php
_e('Basic Auth Username:', 'backwpup');
?>
</label></th>
<td>
<input name="authentication_basic_user" type="text" id="authentication_basic_user" value="<?php
echo esc_attr($authentication['basic_user']);
?>
" class="regular-text" autocomplete="off" />
</td>
</tr>
<tr class="authentication_basic" <?php
if ($authentication['method'] !== 'basic') {
echo 'style="display:none"';
}
?>
>
<th scope="row"><label for="authentication_basic_password"><?php
_e('Basic Auth Password:', 'backwpup');
?>
</label></th>
<td>
<input name="authentication_basic_password" type="password" id="authentication_basic_password" value="<?php
echo esc_attr(BackWPup_Encryption::decrypt($authentication['basic_password']));
?>
" class="regular-text" autocomplete="off" />
</tr>
<tr class="authentication_user" <?php
if ($authentication['method'] !== 'user') {
echo 'style="display:none"';
}
?>
>
<th scope="row"><?php
_e('Select WordPress User', 'backwpup');
?>
</th>
<td>
<fieldset>
<legend class="screen-reader-text"><span><?php
_e('Select WordPress User', 'backwpup');
?>
</span>
</legend>
<label for="authentication_user_id">
<select name="authentication_user_id" size="1" >
<?php
$users = get_users(array('who' => 'administrators', 'number' => 99, 'orderby' => 'display_name'));
foreach ($users as $user) {
echo '<option value="' . $user->ID . '" ' . selected($authentication['user_id'], $user->ID, FALSE) . '>' . esc_attr($user->display_name) . '</option>';
}
?>
</select>
</label>
</fieldset>
</td>
示例12: get_jobrun_url
/**
*
* Get a url to run a job of BackWPup
*
* @param string $starttype Start types are 'runnow', 'runnowlink', 'cronrun', 'runext', 'restart', 'test'
* @param int $jobid The id of job to start else 0
* @return array|object [url] is the job url [header] for auth header or object form wp_remote_get()
*/
public static function get_jobrun_url($starttype, $jobid = 0)
{
$wp_admin_user = get_users(array('role' => 'backwpup_admin', 'number' => 1));
//get a user for cookie auth
$url = site_url('wp-cron.php');
$header = array();
$authurl = '';
$query_args = array('_nonce' => substr(wp_hash(wp_nonce_tick() . 'backwpup_job_run-' . $starttype, 'nonce'), -12, 10), 'doing_wp_cron' => sprintf('%.22F', microtime(true)));
if (in_array($starttype, array('restart', 'runnow', 'cronrun', 'runext', 'test'))) {
$query_args['backwpup_run'] = $starttype;
}
if (in_array($starttype, array('runnowlink', 'runnow', 'cronrun', 'runext')) && !empty($jobid)) {
$query_args['jobid'] = $jobid;
}
if (get_site_option('backwpup_cfg_httpauthuser') && get_site_option('backwpup_cfg_httpauthpassword')) {
$header['Authorization'] = 'Basic ' . base64_encode(get_site_option('backwpup_cfg_httpauthuser') . ':' . BackWPup_Encryption::decrypt(get_site_option('backwpup_cfg_httpauthpassword')));
$authurl = get_site_option('backwpup_cfg_httpauthuser') . ':' . BackWPup_Encryption::decrypt(get_site_option('backwpup_cfg_httpauthpassword')) . '@';
}
if ($starttype == 'runext') {
$query_args['_nonce'] = get_site_option('backwpup_cfg_jobrunauthkey');
$query_args['doing_wp_cron'] = NULL;
if (!empty($authurl)) {
$url = str_replace('https://', 'https://' . $authurl, $url);
$url = str_replace('http://', 'http://' . $authurl, $url);
}
}
if ($starttype == 'runnowlink' && (!defined('ALTERNATE_WP_CRON') || !ALTERNATE_WP_CRON)) {
$url = wp_nonce_url(network_admin_url('admin.php'), 'backwpup_job_run-' . $starttype);
$query_args['page'] = 'backwpupjobs';
$query_args['action'] = 'runnow';
$query_args['doing_wp_cron'] = NULL;
unset($query_args['_nonce']);
}
if ($starttype == 'runnowlink' && defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
$query_args['backwpup_run'] = 'runnowalt';
$query_args['_nonce'] = substr(wp_hash(wp_nonce_tick() . 'backwpup_job_run-runnowalt', 'nonce'), -12, 10);
$query_args['doing_wp_cron'] = NULL;
}
//Extra for WP-Cron control
if (class_exists('WP_Cron_Control') && ($starttype == 'runext' || $starttype == 'runnow' || $starttype == 'restart')) {
$wp_cron_control_settings = get_option('wpcroncontrol_settings', array());
if (empty($wp_cron_control_settings['secret_string']) && file_exists(WP_PLUGIN_DIR . '/wp-cron-control/wp-cron-control.php')) {
$wp_cron_control_settings['secret_string'] = md5(realpath(WP_PLUGIN_DIR . '/wp-cron-control/wp-cron-control.php') . get_current_blog_id());
$wp_cron_control_settings['enable'] = 1;
}
if (isset($wp_cron_control_settings['enable']) && $wp_cron_control_settings['enable'] == 1) {
if (defined('WP_CRON_CONTROL_SECRET')) {
$wp_cron_control_settings['secret_string'] = WP_CRON_CONTROL_SECRET;
}
$query_args[$wp_cron_control_settings['secret_string']] = '';
$query_args['doing_wp_cron'] = NULL;
}
}
$cron_request = apply_filters('cron_request', array('url' => add_query_arg($query_args, $url), 'key' => $query_args['doing_wp_cron'], 'args' => array('blocking' => FALSE, 'sslverify' => apply_filters('https_local_ssl_verify', true), 'timeout' => 0.01, 'headers' => $header, 'cookies' => array(new WP_Http_Cookie(array('name' => AUTH_COOKIE, 'value' => wp_generate_auth_cookie($wp_admin_user[0]->ID, time() + 300, 'auth'))), new WP_Http_Cookie(array('name' => LOGGED_IN_COOKIE, 'value' => wp_generate_auth_cookie($wp_admin_user[0]->ID, time() + 300, 'logged_in')))), 'user-agent' => BackWpup::get_plugin_data('User-Agent'))));
if ($starttype == 'test') {
$cron_request['args']['timeout'] = 15;
$cron_request['args']['blocking'] = TRUE;
}
if (!in_array($starttype, array('runnowlink', 'runext'))) {
set_transient('doing_cron', $query_args['doing_wp_cron']);
return wp_remote_post($cron_request['url'], $cron_request['args']);
}
return $cron_request;
}
示例13: __construct
/**
* @param string $boxtype
* @throws BackWPup_Destination_Dropbox_API_Exception
*/
public function __construct($boxtype = 'dropbox')
{
if ($boxtype == 'dropbox') {
$this->oauth_app_key = get_site_option('backwpup_cfg_dropboxappkey');
$this->oauth_app_secret = BackWPup_Encryption::decrypt(get_site_option('backwpup_cfg_dropboxappsecret'));
$this->root = 'dropbox';
} else {
$this->oauth_app_key = get_site_option('backwpup_cfg_dropboxsandboxappkey');
$this->oauth_app_secret = BackWPup_Encryption::decrypt(get_site_option('backwpup_cfg_dropboxsandboxappsecret'));
$this->root = 'sandbox';
}
if (empty($this->oauth_app_key) or empty($this->oauth_app_secret)) {
throw new BackWPup_Destination_Dropbox_API_Exception("No App key or App Secret specified.");
}
}
示例14: job_run_archive
/**
* @param $job_object BAckWPup_Job
* @return bool
*/
public function job_run_archive(BackWPup_Job $job_object)
{
$job_object->substeps_todo = 2 + $job_object->backup_filesize;
if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
$job_object->log(sprintf(__('%d. Trying to send backup file to S3 Service …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']), E_USER_NOTICE);
}
try {
$s3 = Aws\S3\S3Client::factory(array('key' => $job_object->job['s3accesskey'], 'secret' => BackWPup_Encryption::decrypt($job_object->job['s3secretkey']), 'region' => $job_object->job['s3region'], 'base_url' => $this->get_s3_base_url($job_object->job['s3region'], $job_object->job['s3base_url']), 'scheme' => 'https', 'ssl.certificate_authority' => BackWPup::get_plugin_data('cacert')));
if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY'] && $job_object->substeps_done < $job_object->backup_filesize) {
if ($s3->doesBucketExist($job_object->job['s3bucket'])) {
$bucketregion = $s3->getBucketLocation(array('Bucket' => $job_object->job['s3bucket']));
$job_object->log(sprintf(__('Connected to S3 Bucket "%1$s" in %2$s', 'backwpup'), $job_object->job['s3bucket'], $bucketregion->get('Location')), E_USER_NOTICE);
} else {
$job_object->log(sprintf(__('S3 Bucket "%s" does not exist!', 'backwpup'), $job_object->job['s3bucket']), E_USER_ERROR);
return TRUE;
}
if ($job_object->job['s3multipart'] && empty($job_object->steps_data[$job_object->step_working]['UploadId'])) {
//Check for aboded Multipart Uploads
$job_object->log(__('Checking for not aborted multipart Uploads …', 'backwpup'));
$multipart_uploads = $s3->listMultipartUploads(array('Bucket' => $job_object->job['s3bucket'], 'Prefix' => (string) $job_object->job['s3dir']));
$uploads = $multipart_uploads->get('Uploads');
if (!empty($uploads)) {
foreach ($uploads as $upload) {
$s3->abortMultipartUpload(array('Bucket' => $job_object->job['s3bucket'], 'Key' => $upload['Key'], 'UploadId' => $upload['UploadId']));
$job_object->log(sprintf(__('Upload for %s aborted.', 'backwpup'), $upload['Key']));
}
}
}
//transfer file to S3
$job_object->log(__('Starting upload to S3 Service …', 'backwpup'));
}
if (!$job_object->job['s3multipart'] || $job_object->backup_filesize < 1048576 * 6) {
//Prepare Upload
if (!($up_file_handle = fopen($job_object->backup_folder . $job_object->backup_file, 'rb'))) {
$job_object->log(__('Can not open source file for transfer.', 'backwpup'), E_USER_ERROR);
return FALSE;
}
$create_args = array();
$create_args['Bucket'] = $job_object->job['s3bucket'];
$create_args['ACL'] = 'private';
//encrxption
if (!empty($job_object->job['s3ssencrypt'])) {
$create_args['ServerSideEncryption'] = $job_object->job['s3ssencrypt'];
}
//Storage Class
if (!empty($job_object->job['s3storageclass'])) {
$create_args['StorageClass'] = $job_object->job['s3storageclass'];
}
$create_args['Metadata'] = array('BackupTime' => date('Y-m-d H:i:s', $job_object->start_time));
$create_args['Body'] = $up_file_handle;
$create_args['Key'] = $job_object->job['s3dir'] . $job_object->backup_file;
$create_args['ContentType'] = $job_object->get_mime_type($job_object->backup_folder . $job_object->backup_file);
try {
$s3->putObject($create_args);
} catch (Aws\Common\Exception\MultipartUploadException $e) {
$job_object->log(E_USER_ERROR, sprintf(__('S3 Service API: %s', 'backwpup'), $e->getMessage()), $e->getFile(), $e->getLine());
return FALSE;
}
} else {
//Prepare Upload
if ($file_handle = fopen($job_object->backup_folder . $job_object->backup_file, 'rb')) {
fseek($file_handle, $job_object->substeps_done);
try {
if (empty($job_object->steps_data[$job_object->step_working]['UploadId'])) {
$args = array('ACL' => 'private', 'Bucket' => $job_object->job['s3bucket'], 'ContentType' => $job_object->get_mime_type($job_object->backup_folder . $job_object->backup_file), 'Key' => $job_object->job['s3dir'] . $job_object->backup_file);
if (!empty($job_object->job['s3ssencrypt'])) {
$args['ServerSideEncryption'] = $job_object->job['s3ssencrypt'];
}
if (!empty($job_object->job['s3storageclass'])) {
$args['StorageClass'] = empty($job_object->job['s3storageclass']) ? '' : $job_object->job['s3storageclass'];
}
$upload = $s3->createMultipartUpload($args);
$job_object->steps_data[$job_object->step_working]['UploadId'] = $upload->get('UploadId');
$job_object->steps_data[$job_object->step_working]['Parts'] = array();
$job_object->steps_data[$job_object->step_working]['Part'] = 1;
}
while (!feof($file_handle)) {
$chunk_upload_start = microtime(TRUE);
$part_data = fread($file_handle, 1048576 * 5);
//5MB Minimum part size
$part = $s3->uploadPart(array('Bucket' => $job_object->job['s3bucket'], 'UploadId' => $job_object->steps_data[$job_object->step_working]['UploadId'], 'Key' => $job_object->job['s3dir'] . $job_object->backup_file, 'PartNumber' => $job_object->steps_data[$job_object->step_working]['Part'], 'Body' => $part_data));
$chunk_upload_time = microtime(TRUE) - $chunk_upload_start;
$job_object->substeps_done = $job_object->substeps_done + strlen($part_data);
$job_object->steps_data[$job_object->step_working]['Parts'][] = array('ETag' => $part->get('ETag'), 'PartNumber' => $job_object->steps_data[$job_object->step_working]['Part']);
$job_object->steps_data[$job_object->step_working]['Part']++;
$time_remaining = $job_object->do_restart_time();
if ($time_remaining < $chunk_upload_time) {
$job_object->do_restart_time(TRUE);
}
$job_object->update_working_data();
}
$s3->completeMultipartUpload(array('Bucket' => $job_object->job['s3bucket'], 'UploadId' => $job_object->steps_data[$job_object->step_working]['UploadId'], 'Key' => $job_object->job['s3dir'] . $job_object->backup_file, 'Parts' => $job_object->steps_data[$job_object->step_working]['Parts']));
} catch (Exception $e) {
$job_object->log(E_USER_ERROR, sprintf(__('S3 Service API: %s', 'backwpup'), $e->getMessage()), $e->getFile(), $e->getLine());
if (!empty($job_object->steps_data[$job_object->step_working]['uploadId'])) {
$s3->abortMultipartUpload(array('Bucket' => $job_object->job['s3bucket'], 'UploadId' => $job_object->steps_data[$job_object->step_working]['uploadId'], 'Key' => $job_object->job['s3dir'] . $job_object->backup_file));
//.........这里部分代码省略.........