本文整理汇总了PHP中BackWPup_Encryption::encrypt方法的典型用法代码示例。如果您正苦于以下问题:PHP BackWPup_Encryption::encrypt方法的具体用法?PHP BackWPup_Encryption::encrypt怎么用?PHP BackWPup_Encryption::encrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackWPup_Encryption
的用法示例。
在下文中一共展示了BackWPup_Encryption::encrypt方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_post_form
/**
* Save settings form data
*/
public static function save_post_form()
{
if (!current_user_can('backwpup_settings')) {
return;
}
//set default options if button clicked
if (isset($_POST['default_settings']) && $_POST['default_settings']) {
delete_site_option('backwpup_cfg_showadminbar');
delete_site_option('backwpup_cfg_showfoldersize');
delete_site_option('backwpup_cfg_jobsteprestart');
delete_site_option('backwpup_cfg_jobstepretry');
delete_site_option('backwpup_cfg_jobmaxexecutiontime');
delete_site_option('backwpup_cfg_jobziparchivemethod');
delete_site_option('backwpup_cfg_jobnotranslate');
delete_site_option('backwpup_cfg_jobwaittimems');
delete_site_option('backwpup_cfg_maxlogs');
delete_site_option('backwpup_cfg_gzlogs');
delete_site_option('backwpup_cfg_protectfolders');
delete_site_option('backwpup_cfg_httpauthuser');
delete_site_option('backwpup_cfg_httpauthpassword');
delete_site_option('backwpup_cfg_logfolder');
BackWPup_Admin::message(__('Settings reset to default', 'backwpup'));
return;
}
update_site_option('backwpup_cfg_showadminbar', isset($_POST['showadminbar']) ? 1 : 0);
update_site_option('backwpup_cfg_showfoldersize', isset($_POST['showfoldersize']) ? 1 : 0);
update_site_option('backwpup_cfg_jobsteprestart', isset($_POST['jobsteprestart']) ? 1 : 0);
if (100 > $_POST['jobstepretry'] && 0 < $_POST['jobstepretry']) {
$_POST['jobstepretry'] = abs((int) $_POST['jobstepretry']);
}
if (empty($_POST['jobstepretry']) or !is_int($_POST['jobstepretry'])) {
$_POST['jobstepretry'] = 3;
}
update_site_option('backwpup_cfg_jobstepretry', $_POST['jobstepretry']);
update_site_option('backwpup_cfg_jobmaxexecutiontime', abs((int) $_POST['jobmaxexecutiontime']));
update_site_option('backwpup_cfg_jobziparchivemethod', $_POST['jobziparchivemethod'] == '' || $_POST['jobziparchivemethod'] == 'PclZip' || $_POST['jobziparchivemethod'] == 'ZipArchive' ? $_POST['jobziparchivemethod'] : '');
update_site_option('backwpup_cfg_jobnotranslate', isset($_POST['jobnotranslate']) ? 1 : 0);
update_site_option('backwpup_cfg_jobwaittimems', $_POST['jobwaittimems']);
update_site_option('backwpup_cfg_maxlogs', abs((int) $_POST['maxlogs']));
update_site_option('backwpup_cfg_gzlogs', isset($_POST['gzlogs']) ? 1 : 0);
update_site_option('backwpup_cfg_protectfolders', isset($_POST['protectfolders']) ? 1 : 0);
update_site_option('backwpup_cfg_httpauthuser', $_POST['httpauthuser']);
update_site_option('backwpup_cfg_httpauthpassword', BackWPup_Encryption::encrypt($_POST['httpauthpassword']));
$_POST['jobrunauthkey'] = preg_replace('/[^a-zA-Z0-9]/', '', trim($_POST['jobrunauthkey']));
update_site_option('backwpup_cfg_jobrunauthkey', $_POST['jobrunauthkey']);
$_POST['logfolder'] = trailingslashit(str_replace('\\', '/', trim(stripslashes($_POST['logfolder']))));
if ($_POST['logfolder'][0] == '.' || $_POST['logfolder'][0] != '/' && !preg_match('#^[a-zA-Z]:/#', $_POST['logfolder'])) {
$_POST['logfolder'] = trailingslashit(str_replace('\\', '/', ABSPATH)) . $_POST['logfolder'];
}
//set def. folders
if (empty($_POST['logfolder']) || $_POST['logfolder'] == '/') {
delete_site_option('backwpup_cfg_logfolder');
} else {
update_site_option('backwpup_cfg_logfolder', $_POST['logfolder']);
}
do_action('backwpup_page_settings_save');
BackWPup_Admin::message(__('Settings saved', 'backwpup'));
}
示例2: edit_tab
/**
* @param $jobid
*/
public function edit_tab($jobid)
{
//Dropbox auth keys from Dropbox
// if cancelled auth
if (!empty($_GET['not_approved'])) {
echo '<div id="message" class="error"><p>' . __('Dropbox authentication not approved', 'backwpup') . '</p></div>';
delete_site_transient('backwpup_dropbox_auth_' . $jobid);
}
// if Auth data exists
$auth_data = get_site_transient('backwpup_dropbox_auth_' . $jobid);
if ($auth_data) {
$oAuthStuff = array();
try {
$dropbox = new BackWPup_Destination_Dropbox_API($auth_data['type']);
$oAuthStuff = $dropbox->oAuthAccessToken($auth_data['oauth_token'], $auth_data['oauth_token_secret']);
if (!empty($oAuthStuff)) {
echo '<div id="message" class="updated below-h2"><p>' . __('Dropbox authentication complete!', 'backwpup') . '</p></div>';
BackWPup_Option::update($jobid, 'dropboxtoken', $oAuthStuff['oauth_token']);
BackWPup_Option::update($jobid, 'dropboxsecret', BackWPup_Encryption::encrypt($oAuthStuff['oauth_token_secret']));
BackWPup_Option::update($jobid, 'dropboxroot', $auth_data['type']);
delete_site_transient('backwpup_dropbox_auth_' . $jobid);
}
} catch (Exception $e) {
echo '<div id="message" class="error"><p>' . sprintf(__('Dropbox API: %s', 'backwpup'), $e->getMessage()) . '</p></div>';
delete_site_transient('backwpup_dropbox_auth_' . $jobid);
}
}
?>
<h3 class="title"><?php
_e('Login', 'backwpup');
?>
</h3>
<p></p>
<table class="form-table">
<tr>
<th scope="row"><?php
_e('Authenticate', 'backwpup');
?>
</th>
<td><?php
if (!BackWPup_Option::get($jobid, 'dropboxtoken') && !BackWPup_Option::get($jobid, 'dropboxsecret') && !isset($oAuthStuff['oauth_token'])) {
?>
<span style="color:red;"><?php
_e('Not authenticated!', 'backwpup');
?>
</span> <a href="http://db.tt/8irM1vQ0"><?php
_e('Create Account', 'backwpup');
?>
</a><br />
<?php
} else {
?>
<span style="color:green;"><?php
_e('Authenticated!', 'backwpup');
?>
</span><br />
<?php
}
?>
<a class="button secondary" href="<?php
echo admin_url('admin-ajax.php', 'relative');
?>
?action=backwpup_dest_dropbox&type=sandbox&jobid=<?php
echo $jobid;
?>
"><?php
_e('Reauthenticate (Sandbox)', 'backwpup');
?>
</a>
<a class="button secondary" href="<?php
echo admin_url('admin-ajax.php', 'relative');
?>
?action=backwpup_dest_dropbox&type=dropbox&jobid=<?php
echo $jobid;
?>
"><?php
_e('Reauthenticate (full Dropbox)', 'backwpup');
?>
</a>
</td>
</tr>
</table>
<h3 class="title"><?php
_e('Backup settings', 'backwpup');
?>
</h3>
<p></p>
<table class="form-table">
<tr>
<th scope="row"><label for="iddropboxdir"><?php
_e('Folder in Dropbox', 'backwpup');
?>
</label></th>
<td>
//.........这里部分代码省略.........
示例3: edit_form_post_save
/**
* @param $jobid
* @return string
*/
public function edit_form_post_save($jobid)
{
BackWPup_Option::update($jobid, 's3accesskey', isset($_POST['s3accesskey']) ? $_POST['s3accesskey'] : '');
BackWPup_Option::update($jobid, 's3secretkey', isset($_POST['s3secretkey']) ? BackWPup_Encryption::encrypt($_POST['s3secretkey']) : '');
BackWPup_Option::update($jobid, 's3base_url', isset($_POST['s3base_url']) ? esc_url_raw($_POST['s3base_url']) : '');
BackWPup_Option::update($jobid, 's3region', isset($_POST['s3region']) ? $_POST['s3region'] : '');
BackWPup_Option::update($jobid, 's3storageclass', isset($_POST['s3storageclass']) ? $_POST['s3storageclass'] : '');
BackWPup_Option::update($jobid, 's3ssencrypt', isset($_POST['s3ssencrypt']) && $_POST['s3ssencrypt'] == 'AES256' ? 'AES256' : '');
BackWPup_Option::update($jobid, 's3bucket', isset($_POST['s3bucket']) ? $_POST['s3bucket'] : '');
$_POST['s3dir'] = trailingslashit(str_replace('//', '/', str_replace('\\', '/', trim(stripslashes($_POST['s3dir'])))));
if (substr($_POST['s3dir'], 0, 1) == '/') {
$_POST['s3dir'] = substr($_POST['s3dir'], 1);
}
if ($_POST['s3dir'] == '/') {
$_POST['s3dir'] = '';
}
BackWPup_Option::update($jobid, 's3dir', $_POST['s3dir']);
BackWPup_Option::update($jobid, 's3maxbackups', isset($_POST['s3maxbackups']) ? (int) $_POST['s3maxbackups'] : 0);
BackWPup_Option::update($jobid, 's3syncnodelete', isset($_POST['s3syncnodelete']) && $_POST['s3syncnodelete'] == 1 ? TRUE : FALSE);
BackWPup_Option::update($jobid, 's3multipart', isset($_POST['s3multipart']) && $_POST['s3multipart'] == 1 ? TRUE : FALSE);
//create new bucket
if (!empty($_POST['s3newbucket'])) {
try {
$s3 = new AmazonS3(array('key' => $_POST['s3accesskey'], 'secret' => BackWPup_Encryption::decrypt($_POST['s3secretkey']), 'certificate_authority' => TRUE));
$base_url = $this->get_s3_base_url($_POST['s3region'], $_POST['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();
}
// set bucket creation region
if ($_POST['s3region'] == 'google-storage' || $_POST['s3region'] == 'hosteurope') {
$region = 'EU';
} else {
$region = str_replace(array('http://', 'https://'), '', $base_url);
}
$bucket = $s3->create_bucket($_POST['s3newbucket'], $region, 'private');
if ($bucket->status == 200) {
BackWPup_Admin::message(sprintf(__('Bucket %1$s created in %2$s.', 'backwpup'), $_POST['s3newbucket'], $bucket['Location']));
} else {
BackWPup_Admin::message(sprintf(__('Bucket %s could not be created.', 'backwpup'), $_POST['s3newbucket']), TRUE);
}
} catch (Exception $e) {
BackWPup_Admin::message($e->getMessage(), TRUE);
}
BackWPup_Option::update($jobid, 's3bucket', $_POST['s3newbucket']);
}
}
示例4: edit_form_post_save
/**
* @param $jobid
* @return string
*/
public function edit_form_post_save($jobid)
{
BackWPup_Option::update($jobid, 'msazureaccname', isset($_POST['msazureaccname']) ? $_POST['msazureaccname'] : '');
BackWPup_Option::update($jobid, 'msazurekey', isset($_POST['msazurekey']) ? BackWPup_Encryption::encrypt($_POST['msazurekey']) : '');
BackWPup_Option::update($jobid, 'msazurecontainer', isset($_POST['msazurecontainer']) ? $_POST['msazurecontainer'] : '');
$_POST['msazuredir'] = trailingslashit(str_replace('//', '/', str_replace('\\', '/', trim(stripslashes($_POST['msazuredir'])))));
if (substr($_POST['msazuredir'], 0, 1) == '/') {
$_POST['msazuredir'] = substr($_POST['msazuredir'], 1);
}
if ($_POST['msazuredir'] == '/') {
$_POST['msazuredir'] = '';
}
BackWPup_Option::update($jobid, 'msazuredir', $_POST['msazuredir']);
BackWPup_Option::update($jobid, 'msazuremaxbackups', isset($_POST['msazuremaxbackups']) ? (int) $_POST['msazuremaxbackups'] : 0);
BackWPup_Option::update($jobid, 'msazuresyncnodelete', isset($_POST['msazuresyncnodelete']) && $_POST['msazuresyncnodelete'] == 1 ? TRUE : FALSE);
//create a new container
if (!empty($_POST['newmsazurecontainer']) && !empty($_POST['msazureaccname']) && !empty($_POST['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=' . $_POST['msazureaccname'] . ';AccountKey=' . $_POST['msazurekey']);
$container_options = new WindowsAzure\Blob\Models\CreateContainerOptions();
$container_options->setPublicAccess(WindowsAzure\Blob\Models\PublicAccessType::NONE);
$blobRestProxy->createContainer($_POST['newmsazurecontainer'], $container_options);
BackWPup_Option::update($jobid, 'msazurecontainer', $_POST['newmsazurecontainer']);
BackWPup_Admin::message(sprintf(__('MS Azure container "%s" created.', 'backwpup'), $_POST['newmsazurecontainer']));
} catch (Exception $e) {
BackWPup_Admin::message(sprintf(__('MS Azure container create: %s', 'backwpup'), $e->getMessage()), TRUE);
}
}
}
示例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'];
//.........这里部分代码省略.........
示例6: edit_form_post_save
/**
* @param $id
*/
public function edit_form_post_save($id)
{
$_POST['ftphost'] = str_replace(array('http://', 'ftp://'), '', sanitize_text_field($_POST['ftphost']));
BackWPup_Option::update($id, 'ftphost', isset($_POST['ftphost']) ? $_POST['ftphost'] : '');
BackWPup_Option::update($id, 'ftphostport', !empty($_POST['ftphostport']) ? absint($_POST['ftphostport']) : 21);
BackWPup_Option::update($id, 'ftptimeout', !empty($_POST['ftptimeout']) ? absint($_POST['ftptimeout']) : 90);
BackWPup_Option::update($id, 'ftpuser', sanitize_text_field($_POST['ftpuser']));
BackWPup_Option::update($id, 'ftppass', BackWPup_Encryption::encrypt($_POST['ftppass']));
if (!empty($_POST['ftpdir'])) {
$_POST['ftpdir'] = trailingslashit(str_replace('//', '/', str_replace('\\', '/', trim(sanitize_text_field($_POST['ftpdir'])))));
}
BackWPup_Option::update($id, 'ftpdir', $_POST['ftpdir']);
BackWPup_Option::update($id, 'ftpmaxbackups', !empty($_POST['ftpmaxbackups']) ? absint($_POST['ftpmaxbackups']) : 0);
if (function_exists('ftp_ssl_connect')) {
BackWPup_Option::update($id, 'ftpssl', !empty($_POST['ftpssl']));
} else {
BackWPup_Option::update($id, 'ftpssl', false);
}
BackWPup_Option::update($id, 'ftppasv', !empty($_POST['ftppasv']));
}
示例7: edit_form_post_save
/**
* @param $jobid
*/
public function edit_form_post_save($jobid)
{
BackWPup_Option::update($jobid, 'emailaddress', isset($_POST['emailaddress']) ? sanitize_email($_POST['emailaddress']) : '');
BackWPup_Option::update($jobid, 'emailefilesize', isset($_POST['emailefilesize']) ? (int) $_POST['emailefilesize'] : 0);
BackWPup_Option::update($jobid, 'emailsndemail', sanitize_email($_POST['emailsndemail']));
BackWPup_Option::update($jobid, 'emailmethod', $_POST['emailmethod'] == '' || $_POST['emailmethod'] == 'mail' || $_POST['emailmethod'] == 'sendmail' || $_POST['emailmethod'] == 'smtp' ? $_POST['emailmethod'] : '');
BackWPup_Option::update($jobid, 'emailsendmail', $_POST['emailsendmail']);
BackWPup_Option::update($jobid, 'emailsndemailname', $_POST['emailsndemailname']);
BackWPup_Option::update($jobid, 'emailhost', $_POST['emailhost']);
BackWPup_Option::update($jobid, 'emailhostport', (int) $_POST['emailhostport']);
BackWPup_Option::update($jobid, 'emailsecure', $_POST['emailsecure'] == 'ssl' || $_POST['emailsecure'] == 'tls' ? $_POST['emailsecure'] : '');
BackWPup_Option::update($jobid, 'emailuser', $_POST['emailuser']);
BackWPup_Option::update($jobid, 'emailpass', BackWPup_Encryption::encrypt($_POST['emailpass']));
}
示例8: edit_form_post_save
/**
* @param $id
*/
public function edit_form_post_save($id)
{
BackWPup_Option::update($id, 'rscusername', isset($_POST['rscusername']) ? $_POST['rscusername'] : '');
BackWPup_Option::update($id, 'rscapikey', isset($_POST['rscapikey']) ? BackWPup_Encryption::encrypt($_POST['rscapikey']) : '');
BackWPup_Option::update($id, 'rsccontainer', isset($_POST['rsccontainer']) ? $_POST['rsccontainer'] : '');
BackWPup_Option::update($id, 'rscregion', !empty($_POST['rscregion']) ? $_POST['rscregion'] : 'DFW');
$_POST['rscdir'] = trailingslashit(str_replace('//', '/', str_replace('\\', '/', trim(stripslashes($_POST['rscdir'])))));
if (substr($_POST['rscdir'], 0, 1) == '/') {
$_POST['rscdir'] = substr($_POST['rscdir'], 1);
}
if ($_POST['rscdir'] == '/') {
$_POST['rscdir'] = '';
}
BackWPup_Option::update($id, 'rscdir', $_POST['rscdir']);
BackWPup_Option::update($id, 'rscmaxbackups', isset($_POST['rscmaxbackups']) ? (int) $_POST['rscmaxbackups'] : 0);
BackWPup_Option::update($id, 'rscsyncnodelete', isset($_POST['rscsyncnodelete']) && $_POST['rscsyncnodelete'] == 1 ? TRUE : FALSE);
if (!empty($_POST['rscusername']) && !empty($_POST['rscapikey']) && !empty($_POST['newrsccontainer'])) {
try {
$conn = new OpenCloud\Rackspace(self::get_auth_url_by_region($_POST['rscregion']), array('username' => $_POST['rscusername'], 'apiKey' => $_POST['rscapikey']));
$ostore = $conn->objectStoreService('cloudFiles', $_POST['rscregion'], 'publicURL');
$ostore->createContainer($_POST['newrsccontainer']);
BackWPup_Option::update($id, 'rsccontainer', $_POST['newrsccontainer']);
BackWPup_Admin::message(sprintf(__('Rackspace Cloud container "%s" created.', 'backwpup'), $_POST['newrsccontainer']));
} catch (Exception $e) {
BackWPup_Admin::message(sprintf(__('Rackspace Cloud API: %s', 'backwpup'), $e->getMessage()), TRUE);
}
}
}
示例9: edit_form_post_save
/**
* @param $jobid
* @return string
*/
public function edit_form_post_save($jobid)
{
BackWPup_Option::update($jobid, 's3accesskey', sanitize_text_field($_POST['s3accesskey']));
BackWPup_Option::update($jobid, 's3secretkey', isset($_POST['s3secretkey']) ? BackWPup_Encryption::encrypt($_POST['s3secretkey']) : '');
BackWPup_Option::update($jobid, 's3base_url', isset($_POST['s3base_url']) ? esc_url_raw($_POST['s3base_url']) : '');
BackWPup_Option::update($jobid, 's3region', sanitize_text_field($_POST['s3region']));
BackWPup_Option::update($jobid, 's3storageclass', sanitize_text_field($_POST['s3storageclass']));
BackWPup_Option::update($jobid, 's3ssencrypt', isset($_POST['s3ssencrypt']) && $_POST['s3ssencrypt'] === 'AES256' ? 'AES256' : '');
BackWPup_Option::update($jobid, 's3bucket', isset($_POST['s3bucket']) ? sanitize_text_field($_POST['s3bucket']) : '');
$_POST['s3dir'] = trailingslashit(str_replace('//', '/', str_replace('\\', '/', trim(sanitize_text_field($_POST['s3dir'])))));
if (substr($_POST['s3dir'], 0, 1) == '/') {
$_POST['s3dir'] = substr($_POST['s3dir'], 1);
}
if ($_POST['s3dir'] == '/') {
$_POST['s3dir'] = '';
}
BackWPup_Option::update($jobid, 's3dir', $_POST['s3dir']);
BackWPup_Option::update($jobid, 's3maxbackups', !empty($_POST['s3maxbackups']) ? absint($_POST['s3maxbackups']) : 0);
BackWPup_Option::update($jobid, 's3syncnodelete', !empty($_POST['s3syncnodelete']));
BackWPup_Option::update($jobid, 's3multipart', !empty($_POST['s3multipart']));
//create new bucket
if (!empty($_POST['s3newbucket'])) {
try {
$s3 = Aws\S3\S3Client::factory(array('key' => sanitize_text_field($_POST['s3accesskey']), 'secret' => sanitize_text_field($_POST['s3secretkey']), 'region' => sanitize_text_field($_POST['s3region']), 'base_url' => $this->get_s3_base_url(sanitize_text_field($_POST['s3region']), esc_url_raw($_POST['s3base_url'])), 'scheme' => 'https', 'ssl.certificate_authority' => BackWPup::get_plugin_data('cacert')));
// set bucket creation region
if ($_POST['s3region'] === 'google-storage') {
$region = 'EU';
} elseif ($_POST['s3region'] === 'google-storage-us') {
$region = 'US';
} elseif ($_POST['s3region'] === 'google-storage-asia') {
$region = 'ASIA';
} else {
$region = sanitize_text_field($_POST['s3region']);
}
if ($s3->isValidBucketName($_POST['s3newbucket'])) {
$s3->createBucket(array('Bucket' => sanitize_text_field($_POST['s3newbucket']), 'LocationConstraint' => $region));
$s3->waitUntil('bucket_exists', array('Bucket' => $_POST['s3newbucket']));
BackWPup_Admin::message(sprintf(__('Bucket %1$s created.', 'backwpup'), sanitize_text_field($_POST['s3newbucket'])));
} else {
BackWPup_Admin::message(sprintf(__(' %s is not a valid bucket name.', 'backwpup'), sanitize_text_field($_POST['s3newbucket'])), TRUE);
}
} catch (Aws\S3\Exception\S3Exception $e) {
BackWPup_Admin::message($e->getMessage(), TRUE);
}
BackWPup_Option::update($jobid, 's3bucket', sanitize_text_field($_POST['s3newbucket']));
}
}
示例10: save_post_form
/**
* Save settings form data
*/
public static function save_post_form()
{
if (!current_user_can('backwpup_settings')) {
return;
}
//set default options if button clicked
if (isset($_POST['default_settings']) && $_POST['default_settings']) {
delete_site_option('backwpup_cfg_showadminbar');
delete_site_option('backwpup_cfg_showfoldersize');
delete_site_option('backwpup_cfg_jobstepretry');
delete_site_option('backwpup_cfg_jobmaxexecutiontime');
delete_site_option('backwpup_cfg_jobziparchivemethod');
delete_site_option('backwpup_cfg_loglevel');
delete_site_option('backwpup_cfg_jobwaittimems');
delete_site_option('backwpup_cfg_jobrunauthkey');
delete_site_option('backwpup_cfg_jobdooutput');
delete_site_option('backwpup_cfg_maxlogs');
delete_site_option('backwpup_cfg_gzlogs');
delete_site_option('backwpup_cfg_protectfolders');
delete_site_option('backwpup_cfg_authentication');
delete_site_option('backwpup_cfg_logfolder');
delete_site_option('backwpup_cfg_dropboxappkey');
delete_site_option('backwpup_cfg_dropboxappsecret');
delete_site_option('backwpup_cfg_dropboxsandboxappkey');
delete_site_option('backwpup_cfg_dropboxsandboxappsecret');
delete_site_option('backwpup_cfg_sugarsynckey');
delete_site_option('backwpup_cfg_sugarsyncsecret');
delete_site_option('backwpup_cfg_sugarsyncappid');
BackWPup_Option::default_site_options();
BackWPup_Admin::message(__('Settings reset to default', 'backwpup'));
return;
}
update_site_option('backwpup_cfg_showadminbar', isset($_POST['showadminbar']) ? 1 : 0);
update_site_option('backwpup_cfg_showfoldersize', isset($_POST['showfoldersize']) ? 1 : 0);
if (100 > $_POST['jobstepretry'] && 0 < $_POST['jobstepretry']) {
$_POST['jobstepretry'] = abs((int) $_POST['jobstepretry']);
}
if (empty($_POST['jobstepretry']) or !is_int($_POST['jobstepretry'])) {
$_POST['jobstepretry'] = 3;
}
update_site_option('backwpup_cfg_jobstepretry', $_POST['jobstepretry']);
$max_exe_time = abs((int) $_POST['jobmaxexecutiontime']);
if (!is_int($max_exe_time) || $max_exe_time < 0) {
$max_exe_time = 0;
} elseif ($max_exe_time > 300) {
$max_exe_time = 300;
}
update_site_option('backwpup_cfg_jobmaxexecutiontime', $max_exe_time);
update_site_option('backwpup_cfg_jobziparchivemethod', $_POST['jobziparchivemethod'] == '' || $_POST['jobziparchivemethod'] == 'PclZip' || $_POST['jobziparchivemethod'] == 'ZipArchive' ? $_POST['jobziparchivemethod'] : '');
update_site_option('backwpup_cfg_loglevel', in_array($_POST['loglevel'], array('normal_translated', 'normal', 'debug_translated', 'debug')) ? $_POST['loglevel'] : 'normal_translated');
update_site_option('backwpup_cfg_jobwaittimems', $_POST['jobwaittimems']);
update_site_option('backwpup_cfg_jobdooutput', isset($_POST['jobdooutput']) ? 1 : 0);
update_site_option('backwpup_cfg_maxlogs', abs((int) $_POST['maxlogs']));
update_site_option('backwpup_cfg_gzlogs', isset($_POST['gzlogs']) ? 1 : 0);
update_site_option('backwpup_cfg_protectfolders', isset($_POST['protectfolders']) ? 1 : 0);
$_POST['jobrunauthkey'] = preg_replace('/[^a-zA-Z0-9]/', '', trim($_POST['jobrunauthkey']));
update_site_option('backwpup_cfg_jobrunauthkey', $_POST['jobrunauthkey']);
$_POST['logfolder'] = trailingslashit(str_replace('\\', '/', trim(stripslashes($_POST['logfolder']))));
//set def. folders
if (empty($_POST['logfolder']) || $_POST['logfolder'] === '/') {
delete_site_option('backwpup_cfg_logfolder');
BackWPup_Option::default_site_options();
} else {
update_site_option('backwpup_cfg_logfolder', $_POST['logfolder']);
}
$authentication = get_site_option('backwpup_cfg_authentication', array('method' => '', 'basic_user' => '', 'basic_password' => '', 'user_id' => 0, 'query_arg' => ''));
$authentication['method'] = in_array($_POST['authentication_method'], array('user', 'basic', 'query_arg')) ? $_POST['authentication_method'] : '';
$authentication['basic_user'] = $_POST['authentication_basic_user'];
$authentication['basic_password'] = BackWPup_Encryption::encrypt($_POST['authentication_basic_password']);
$authentication['query_arg'] = $_POST['authentication_query_arg'];
$authentication['user_id'] = (int) $_POST['authentication_user_id'];
update_site_option('backwpup_cfg_authentication', $authentication);
delete_site_transient('backwpup_cookies');
do_action('backwpup_page_settings_save');
BackWPup_Admin::message(__('Settings saved', 'backwpup'));
}
示例11: edit_form_post_save
/**
* @param $id
*/
public function edit_form_post_save($id)
{
$_POST['ftphost'] = str_replace(array('http://', 'ftp://'), '', $_POST['ftphost']);
BackWPup_Option::update($id, 'ftphost', isset($_POST['ftphost']) ? $_POST['ftphost'] : '');
BackWPup_Option::update($id, 'ftphostport', !empty($_POST['ftphostport']) ? (int) $_POST['ftphostport'] : 21);
BackWPup_Option::update($id, 'ftptimeout', !empty($_POST['ftptimeout']) ? (int) $_POST['ftptimeout'] : 90);
BackWPup_Option::update($id, 'ftpuser', isset($_POST['ftpuser']) ? $_POST['ftpuser'] : '');
BackWPup_Option::update($id, 'ftppass', isset($_POST['ftppass']) ? BackWPup_Encryption::encrypt($_POST['ftppass']) : '');
if (!empty($_POST['ftpdir'])) {
$_POST['ftpdir'] = trailingslashit(str_replace('//', '/', str_replace('\\', '/', trim(stripslashes($_POST['ftpdir'])))));
}
BackWPup_Option::update($id, 'ftpdir', $_POST['ftpdir']);
BackWPup_Option::update($id, 'ftpmaxbackups', isset($_POST['ftpmaxbackups']) ? (int) $_POST['ftpmaxbackups'] : 0);
if (function_exists('ftp_ssl_connect')) {
BackWPup_Option::update($id, 'ftpssl', isset($_POST['ftpssl']) && $_POST['ftpssl'] == 1 ? TRUE : FALSE);
} else {
BackWPup_Option::update($id, 'ftpssl', FALSE);
}
BackWPup_Option::update($id, 'ftppasv', isset($_POST['ftppasv']) && $_POST['ftppasv'] == 1 ? TRUE : FALSE);
}
示例12: edit_form_post_save
/**
* @param $jobid
* @return string
*/
public function edit_form_post_save($jobid)
{
BackWPup_Option::update($jobid, 's3accesskey', isset($_POST['s3accesskey']) ? $_POST['s3accesskey'] : '');
BackWPup_Option::update($jobid, 's3secretkey', isset($_POST['s3secretkey']) ? BackWPup_Encryption::encrypt($_POST['s3secretkey']) : '');
BackWPup_Option::update($jobid, 's3base_url', isset($_POST['s3base_url']) ? esc_url_raw($_POST['s3base_url']) : '');
BackWPup_Option::update($jobid, 's3region', isset($_POST['s3region']) ? $_POST['s3region'] : '');
BackWPup_Option::update($jobid, 's3storageclass', isset($_POST['s3storageclass']) ? $_POST['s3storageclass'] : '');
BackWPup_Option::update($jobid, 's3ssencrypt', isset($_POST['s3ssencrypt']) && $_POST['s3ssencrypt'] == 'AES256' ? 'AES256' : '');
BackWPup_Option::update($jobid, 's3bucket', isset($_POST['s3bucket']) ? $_POST['s3bucket'] : '');
$_POST['s3dir'] = trailingslashit(str_replace('//', '/', str_replace('\\', '/', trim(stripslashes($_POST['s3dir'])))));
if (substr($_POST['s3dir'], 0, 1) == '/') {
$_POST['s3dir'] = substr($_POST['s3dir'], 1);
}
if ($_POST['s3dir'] == '/') {
$_POST['s3dir'] = '';
}
BackWPup_Option::update($jobid, 's3dir', $_POST['s3dir']);
BackWPup_Option::update($jobid, 's3maxbackups', isset($_POST['s3maxbackups']) ? (int) $_POST['s3maxbackups'] : 0);
BackWPup_Option::update($jobid, 's3syncnodelete', isset($_POST['s3syncnodelete']) && $_POST['s3syncnodelete'] == 1 ? TRUE : FALSE);
BackWPup_Option::update($jobid, 's3multipart', isset($_POST['s3multipart']) && $_POST['s3multipart'] == 1 ? TRUE : FALSE);
//create new bucket
if (!empty($_POST['s3newbucket'])) {
try {
$s3 = Aws\S3\S3Client::factory(array('key' => $_POST['s3accesskey'], 'secret' => $_POST['s3secretkey'], 'region' => $_POST['s3region'], 'base_url' => $this->get_s3_base_url($_POST['s3region'], $_POST['s3base_url']), 'scheme' => 'https', 'ssl.certificate_authority' => BackWPup::get_plugin_data('plugindir') . '/vendor/cacert.pem'));
// set bucket creation region
if ($_POST['s3region'] == 'google-storage' || $_POST['s3region'] == 'hosteurope') {
$region = 'EU';
} else {
$region = $_POST['s3region'];
}
if ($s3->isValidBucketName($_POST['s3newbucket'])) {
$bucket = $s3->createBucket(array('Bucket' => $_POST['s3newbucket'], 'LocationConstraint' => $region));
$s3->waitUntil('bucket_exists', $_POST['s3newbucket']);
if ($bucket->get('Location')) {
BackWPup_Admin::message(sprintf(__('Bucket %1$s created in %2$s.', 'backwpup'), $_POST['s3newbucket'], $bucket->get('Location')));
} else {
BackWPup_Admin::message(sprintf(__('Bucket %s could not be created.', 'backwpup'), $_POST['s3newbucket']), TRUE);
}
} else {
BackWPup_Admin::message(sprintf(__(' %s is not a valid bucket name.', 'backwpup'), $_POST['s3newbucket']), TRUE);
}
} catch (Aws\S3\Exception\S3Exception $e) {
BackWPup_Admin::message($e->getMessage(), TRUE);
}
BackWPup_Option::update($jobid, 's3bucket', $_POST['s3newbucket']);
}
}