本文整理汇总了PHP中BackWPup_Encryption类的典型用法代码示例。如果您正苦于以下问题:PHP BackWPup_Encryption类的具体用法?PHP BackWPup_Encryption怎么用?PHP BackWPup_Encryption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BackWPup_Encryption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
开发者ID:agileontheweb,项目名称:xvp,代码行数:65,代码来源:class-destination-s3-v1.php
示例2: __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.");
}
}
开发者ID:isrealconsulting,项目名称:site,代码行数:19,代码来源:class-destination-dropbox.php
示例3: 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;
}
开发者ID:skinnard,项目名称:FTL-2,代码行数:92,代码来源:class-job.php
示例4: 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;
}
}
开发者ID:wangshijun101,项目名称:morketing.cn,代码行数:51,代码来源:class-destination-msazure.php
示例5: upgrade_from_version_two
private static function upgrade_from_version_two()
{
//load options
$cfg = get_option('backwpup');
//only exists in Version 2
$jobs = get_option('backwpup_jobs');
//delete old options
delete_option('backwpup');
delete_option('backwpup_jobs');
//add new option default structure and without auto load cache
if (!is_multisite()) {
add_option('backwpup_jobs', array(), NULL, 'no');
}
//upgrade cfg
//if old value switch it to new
if (!empty($cfg['dirlogs'])) {
$cfg['logfolder'] = $cfg['dirlogs'];
}
if (!empty($cfg['httpauthpassword'])) {
if (preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $cfg['httpauthpassword'])) {
$cfg['httpauthpassword'] = base64_decode($cfg['httpauthpassword']);
}
$cfg['httpauthpassword'] = BackWPup_Encryption::encrypt($cfg['httpauthpassword']);
}
// delete old not needed vars
unset($cfg['dirtemp'], $cfg['dirlogs'], $cfg['logfilelist'], $cfg['jobscriptruntime'], $cfg['jobscriptruntimelong'], $cfg['last_activate'], $cfg['disablewpcron'], $cfg['phpzip'], $cfg['apicronservice'], $cfg['mailsndemail'], $cfg['mailsndname'], $cfg['mailmethod'], $cfg['mailsendmail'], $cfg['mailhost'], $cfg['mailpass'], $cfg['mailhostport'], $cfg['mailsecure'], $cfg['mailuser']);
//save in options
foreach ($cfg as $cfgname => $cfgvalue) {
update_site_option('backwpup_cfg_' . $cfgname, $cfgvalue);
}
//Put old jobs to new if exists
foreach ($jobs as $jobid => $jobvalue) {
//convert general settings
if (empty($jobvalue['jobid'])) {
$jobvalue['jobid'] = $jobid;
}
if (empty($jobvalue['activated'])) {
$jobvalue['activetype'] = '';
} else {
$jobvalue['activetype'] = 'wpcron';
}
if (!isset($jobvalue['cronselect']) && !isset($jobvalue['cron'])) {
$jobvalue['cronselect'] = 'basic';
} elseif (!isset($jobvalue['cronselect']) && isset($jobvalue['cron'])) {
$jobvalue['cronselect'] = 'advanced';
}
$jobvalue['backuptype'] = 'archive';
$jobvalue['type'] = explode('+', $jobvalue['type']);
//save as array
foreach ($jobvalue['type'] as $key => $type) {
if ($type == 'DB') {
$jobvalue['type'][$key] = 'DBDUMP';
}
if ($type == 'OPTIMIZE') {
unset($jobvalue['type'][$key]);
}
if ($type == 'CHECK') {
$jobvalue['type'][$key] = 'DBCHECK';
}
if ($type == 'MAIL') {
$jobvalue['type'][$key] = 'EMAIL';
}
}
$jobvalue['archivename'] = $jobvalue['fileprefix'] . '%Y-%m-%d_%H-%i-%s';
$jobvalue['archiveformat'] = $jobvalue['fileformart'];
//convert active destinations
$jobvalue['destinations'] = array();
if (!empty($jobvalue['backupdir']) && $jobvalue['backupdir'] != '/') {
$jobvalue['destinations'][] = 'FOLDER';
}
if (!empty($jobvalue['mailaddress'])) {
$jobvalue['destinations'][] = 'MAIL';
}
if (!empty($jobvalue['ftphost']) && !empty($jobvalue['ftpuser']) && !empty($jobvalue['ftppass'])) {
$jobvalue['destinations'][] = 'FTP';
}
if (!empty($jobvalue['dropetoken']) && !empty($jobvalue['dropesecret'])) {
$jobvalue['destinations'][] = 'DROPBOX';
}
if (!empty($jobvalue['sugarrefreshtoken']) && !empty($jobvalue['sugarroot'])) {
$jobvalue['destinations'][] = 'SUGARSYNC';
}
if (!empty($jobvalue['awsAccessKey']) && !empty($jobvalue['awsSecretKey']) && !empty($jobvalue['awsBucket'])) {
$jobvalue['destinations'][] = 'S3';
}
if (!empty($jobvalue['GStorageAccessKey']) and !empty($jobvalue['GStorageSecret']) && !empty($jobvalue['GStorageBucket']) && !in_array('S3', $jobvalue['destinations'])) {
$jobvalue['destinations'][] = 'S3';
}
if (!empty($jobvalue['rscUsername']) && !empty($jobvalue['rscAPIKey']) && !empty($jobvalue['rscContainer'])) {
$jobvalue['destinations'][] = 'RSC';
}
if (!empty($jobvalue['msazureHost']) && !empty($jobvalue['msazureAccName']) && !empty($jobvalue['msazureKey']) && !empty($jobvalue['msazureContainer'])) {
$jobvalue['destinations'][] = 'MSAZURE';
}
//convert dropbox
$jobvalue['dropboxtoken'] = '';
//new app key are set must reauth
$jobvalue['dropboxsecret'] = '';
$jobvalue['dropboxroot'] = 'dropbox';
$jobvalue['dropboxmaxbackups'] = $jobvalue['dropemaxbackups'];
//.........这里部分代码省略.........
开发者ID:leotaillard,项目名称:btws2016,代码行数:101,代码来源:class-install.php
示例6: 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']);
}
}
}
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:59,代码来源:class-destination-sugarsync.php
示例7: 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;
}
开发者ID:mahassan,项目名称:shellneverknow,代码行数:88,代码来源:class-destination-email.php
示例8: 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);
//.........这里部分代码省略.........
开发者ID:skinnard,项目名称:FTL-2,代码行数:101,代码来源:class-destination-ftp.php
示例9: 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();
开发者ID:onyxagency,项目名称:wordpress,代码行数:67,代码来源:class-page-settings.php
示例10: 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;
}
}
开发者ID:leotaillard,项目名称:btws2016,代码行数:56,代码来源:class-destination-rsc.php
示例11: 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;
}
}
开发者ID:skinnard,项目名称:FTL-2,代码行数:62,代码来源:class-destination-s3.php
示例12: 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>
开发者ID:pedro-mendonca,项目名称:backwpup,代码行数:67,代码来源:class-page-settings.php
示例13: 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, 'co
|
请发表评论