';
}
function backuply_promotion_tmpl() {
global $backuply;
?>
- '.__('Never lose your data with Backuply Cloud.', 'backuply').'
- '.__('Easy to integrate with Backuply.', 'backuply').'
- '.__('10 GB of free storage for All Pro users', 'backuply').'
';
}
?>
The Best WordPress Site Builder :
- Gutenberg Blocks
- Drag & Drop Editor
- Widgets
- In-line Editing
- Styling Options
- Animations
- Easily customizable
- Real Time Design
- And many more ...
Visit Pagelayer
Protect your WordPress website from unauthorized access and malware :
- BruteForce Protection
- reCaptcha
- Two Factor Authentication
- Black/Whitelist IP
- Detailed Logs
- Extended Lockouts
- 2FA via Email
- And many more ...
Visit Loginizer
$tv){
if(substr_count(trim($tv), './') > 0){
$error[] = __('There were some invalid files/folders selected', 'backuply'). ' - '.esc_attr($tv);
}
}
$fetch_fileindex = get_option('backuply_additional_fileindex');
if(empty($fetch_fileindex)){
add_option('backuply_additional_fileindex', $tmp_add_to_fileindex, false);
$saved = true;
}else{
update_option('backuply_additional_fileindex', $tmp_add_to_fileindex, false);
$saved = true;
}
}else{
delete_option('backuply_additional_fileindex');
}
// Save Email setting
$notify_email_address = sanitize_email(backuply_optpost('notify_email_address'));
if(isset($notify_email_address)){
update_option('backuply_notify_email_address', is_email($notify_email_address) ? $notify_email_address : '');
$saved = true;
}
if(!empty($error)){
return false;
}
if(isset($_POST['backuply_cron_schedule'])){
if(empty(backuply_optpost('backuply_cron_schedule'))){
delete_option('backuply_cron_settings');
$timestamp = wp_next_scheduled( 'backuply_auto_backup_cron' );
wp_unschedule_event( $timestamp, 'backuply_auto_backup_cron' );
}
if(!empty(backuply_optpost('backuply_cron_schedule')) && (!empty(backuply_optpost('auto_backup_dir')) || !empty(backuply_optpost('auto_backup_db')))){
$cron_settings = [];
$cron_settings['backup_dir'] = isset($_POST['auto_backup_dir']) ? 1 : 0;
$cron_settings['backup_db'] = isset($_POST['auto_backup_db']) ? 1 : 0;
$cron_settings['backup_rotation'] = backuply_optpost('backup_rotation');
$cron_settings['backup_location'] = backuply_optpost('backup_location');
if($_POST['backuply_cron_schedule'] == 'custom') {
$cron_settings['backuply_cron_schedule'] = backuply_optpost('backuply_cron_schedule');
$cron_settings['backuply_custom_cron'][] = backuply_optpost('cron_minute');
$cron_settings['backuply_custom_cron'][] = backuply_optpost('cron_hour');
$cron_settings['backuply_custom_cron'][] = backuply_optpost('cron_day');
$cron_settings['backuply_custom_cron'][] = backuply_optpost('cron_month');
$cron_settings['backuply_custom_cron'][] = backuply_optpost('cron_weekday');
} else {
$cron_settings['backuply_cron_schedule'] = backuply_optpost('backuply_cron_schedule');
}
update_option('backuply_cron_settings', $cron_settings);
if($timestamp = wp_next_scheduled( 'backuply_auto_backup_cron' )) {
wp_unschedule_event( $timestamp, 'backuply_auto_backup_cron' );
}
if(function_exists('backuply_add_auto_backup_schedule')){
backuply_add_auto_backup_schedule();
}
}
$backuply['settings']['backup_dir'] = !empty($_POST['backup_dir']) ? 1 : 0;
$backuply['settings']['backup_db'] = !empty($_POST['backup_db']) ? 1 : 0;
$backuply['settings']['backup_location'] = !empty($_POST['backup_location']) ? backuply_optpost('backup_location') : '';
update_option('backuply_settings', $backuply['settings']);
if(!empty($error)){
return false;
}
update_option('backuply_debug', backuply_is_checked('debug_mode'));
}
// Saving db excludes
if(!empty($_POST['exclude_db_table'])) {
$backuply['excludes']['db'] = map_deep($_POST['exclude_db_table'], 'sanitize_text_field');
update_option('backuply_excludes', $backuply['excludes']);
} else {
unset($backuply['excludes']['db']);
update_option('backuply_excludes', $backuply['excludes']);
}
$success = __('The Backup settings were saved successfully', 'backuply');
return true;
}
$del_loc_id = backuply_optreq('del_loc_id');
$edit_loc_id = backuply_optreq('edit_loc_id');
$backuply_remote_backup_locs = get_option('backuply_remote_backup_locs');
// Handle backup location delete request
if(isset($_REQUEST['backuply_delete_location']) && array_key_exists($del_loc_id, $backuply_remote_backup_locs)){
// Verify Nonce
if(!wp_verify_nonce(backuply_optreq('security'), 'backuply_nonce')){
$error[] = __('Security check Failed!', 'backuply');
return false;
}
unset($backuply_remote_backup_locs[$del_loc_id]);
if(empty($backuply_remote_backup_locs)){
delete_option('backuply_remote_backup_locs');
}else{
update_option('backuply_remote_backup_locs', $backuply_remote_backup_locs);
}
$success = __('Backup location was deleted successfully', 'backuply');
return true;
}
// Handle edit backup location request
if(isset($_REQUEST['backuply_edit_location']) && array_key_exists($edit_loc_id, (array)$backuply_remote_backup_locs)){
// Verify Nonce
if(!wp_verify_nonce(backuply_optreq('security'), 'backuply_nonce')){
$error[] = __('Security check Failed!', 'backuply');
return false;
}
$backuply_remote_backup_locs = get_option('backuply_remote_backup_locs');
$edit_loc_id = backuply_optreq('edit_loc_id');
$edit_loc_name = backuply_optreq('location_name');
$edit_backup_loc = backuply_optreq('backup_loc');
$protocol = $backuply_remote_backup_locs[$edit_loc_id]['protocol'];
if(empty($protocol)){
$protocol = 'ftp';
}
// Let it be any protocol, we welcome all. But class is must. - Jelastic
if(!backuply_include_lib($protocol)) {
$error[] = __('Invalid Protocol', 'backuply');
}
$proto_arr = array('dropbox', 'gdrive', 'aws', 'caws', 'bcloud', 'onedrive');
if(in_array($protocol, $proto_arr)){
// The Backup PATH
$edit_backup_loc = @trim($edit_backup_loc, '/');
if(!empty($edit_backup_loc)){
$edit_backup_loc = '/'.$edit_backup_loc;
}
if($protocol == 'dropbox'){
$dropbox_access_token = $backuply_remote_backup_locs[$edit_loc_id]['dropbox_token'];
$dropbox_refresh_token = $backuply_remote_backup_locs[$edit_loc_id]['refresh_token'];
$full_backup_loc = $protocol.'://'.$dropbox_refresh_token.$edit_backup_loc;
}elseif($protocol == 'bcloud'){
$bcloud = backuply_load_remote_backup('bcloud');
}elseif($protocol == 'gdrive'){
$gdrive = backuply_load_remote_backup('gdrive');
$gdrive_refresh_token = $backuply_remote_backup_locs[$edit_loc_id]['gdrive_refresh_token'];
$gdrive_old_folder = $backuply_remote_backup_locs[$edit_loc_id]['backup_loc'];
$app_dir_loc = $protocol.'://'.rawurlencode($gdrive_refresh_token).'/'.$gdrive->app_dir;
$full_backup_loc = $protocol.'://'.rawurlencode($gdrive_refresh_token).'/'.$gdrive->app_dir.$edit_backup_loc;
$backup_old_loc = $protocol.'://'.rawurlencode($gdrive_refresh_token).'/'.$gdrive->app_dir.$gdrive_old_folder;
// Updating the target Folder
if(!empty($edit_backup_loc)) {
backuply_stream_wrapper_register($protocol, $protocol);
if(file_exists($backup_old_loc) && $backup_old_loc != $app_dir_loc){
if(!@rename($backup_old_loc, $full_backup_loc)) {
$error[] = __('Unable to rename the folder', 'backuply');
}
} else {
if(!@mkdir($full_backup_loc)){
$error[] = __('Failed to create a folder', 'backuply');
}
}
}
}elseif($protocol == 'aws' || $protocol == 'caws'){
$endpoint = $backuply_remote_backup_locs[$edit_loc_id]['aws_endpoint'];
$region = $backuply_remote_backup_locs[$edit_loc_id]['aws_region'];
$bucketName = $backuply_remote_backup_locs[$edit_loc_id]['aws_bucketname'];
$accessKey = $backuply_remote_backup_locs[$edit_loc_id]['aws_accessKey'];
$secretKey = !empty($_REQUEST['aws_secretKey']) ? backuply_optreq('aws_secretKey') : $backuply_remote_backup_locs[$edit_loc_id]['aws_secretKey'];
$defaultdir = '/'. $aws->app_dir;
backuply_stream_wrapper_register($protocol, $protocol);
$full_backup_loc = $protocol.'://'.rawurlencode($accessKey).':'.rawurlencode($secretKey).'@'.$bucketName.'/'.$endpoint.'/'.$region.$defaultdir.$edit_backup_loc;
if(!@opendir($full_backup_loc)){
if(!@mkdir($full_backup_loc)){
$error[] = __('Failed to create bucket', 'backuply');
}
}
}elseif($protocol == 'onedrive'){
$onedrive = backuply_load_remote_backup('onedrive');
$onedrive_refresh_token = $backuply_remote_backup_locs[$edit_loc_id]['onedrive_refresh_token'];
$full_backup_loc = $protocol.'://'.rawurlencode($onedrive_refresh_token).'/'.$onedrive->app_dir.$edit_backup_loc;
$onedrive->create_onedrive_app_dir($onedrive_refresh_token);
}
}else{
// Server Host
$server_host = $backuply_remote_backup_locs[$edit_loc_id]['server_host'];
$server_host = @rtrim($server_host, '/');
$port = (int) $backuply_remote_backup_locs[$edit_loc_id]['port'];
if(empty($port)){
$port = ($protocol == 'softsftp' ? 22 : 21);
}
// The FTP user
$ftp_user = $backuply_remote_backup_locs[$edit_loc_id]['ftp_user'];
// FTP Pass
$ftp_pass = !empty($_REQUEST['ftp_pass']) ? backuply_optreq('ftp_pass') : $backuply_remote_backup_locs[$edit_loc_id]['ftp_pass'];
// The Private Key
// $private_key = str_replace("\r", '', rawGPC(optPOST('private_key')));
// $private_key = trim($private_key);
// SFTP using keys
// if(!empty($private_key)){
// // Passphrase
// if(isset($_POST['passphrase']) && !empty($_POST['passphrase'])){
// $passphrase = rawGPC($_POST['passphrase']);
// }
// }
if(empty($ftp_pass)){
$error[] = __('Please provide either a password or private key', 'backuply');
}
// The Backup PATH
$edit_backup_loc = '/'.@trim($edit_backup_loc, '/');
//'@' in username was causing issue in fopen while creating backup
$full_backup_loc = $protocol.'://'.rawurlencode(($protocol == 'softsftp' && empty($ftp_pass) ? $edit_loc_id : $ftp_user)).':'.rawurlencode($ftp_pass).'@'.$server_host.(!empty($port) ? ':'.$port : '').$edit_backup_loc;
// Test the connection
if($protocol == 'webdav'){
backuply_stream_wrapper_register($protocol, $protocol);
if(!empty($edit_backup_loc)){
mkdir($full_backup_loc);
}
$webdav_connect = stat($full_backup_loc);
if(empty($webdav_connect['mtime']) && empty($webdav_connect['ctime'])){
$error[] = 'Failed to connect to the WebDAV server';
}
}
}
//Check for Duplicate Backup Location
$existing_backup_locs = get_option('backuply_remote_backup_locs');
foreach($existing_backup_locs as $k => $v){
if($edit_loc_id != $k && $full_backup_loc == $v['full_backup_loc']){
$error[] = __('Backup Location with the same path already exists', 'backuply');
break;
}
}
if($protocol != 'dropbox' && $protocol != 'gdrive' && $protocol != 'webdav' && $protocol != 'aws' && $protocol != 'caws' && $protocol != 'onedrive'){
//Connection established or not?
$ftp = backuply_sftp_connect($server_host, $ftp_user, $ftp_pass, $protocol, $port, false);
if(!is_object($ftp) && $ftp == '-2'){
$error[] = __('Could not login with specified details', 'backuply');
}
if(!is_object($ftp) && $ftp == '-1'){
$error[] = __('Could not Resolve Domain Name', 'backuply');
}
if(!is_object($ftp) && $ftp == '-3'){
$error[] = sprintf( esc_html__( 'Specified %1$s Path does not exist', 'backuply'), $protocols[$protocol]);
}
if($ftp == '-4'){
$error[] = __('Could not connect to the server', 'backuply');
}
if($ftp == '-5'){
$error[] = __('Could not connect to the server', 'backuply');
}
//backuply_log('isobject ftp : '.var_export($ftp, 1));
if(!is_object($ftp)){
$error[] = __('Could not connect to the server', 'backuply');
}
if(!empty($error)){
return false;
}
if($protocol == 'softsftp'){
$ftp->chdir('~');
$pwd = $ftp->pwd();
// Some servers pwd is empty and some / in that case we cannot check if it is absolute dir
if(!empty($pwd) && $pwd != '/'){
$homedir = $pwd.'/';
if(!preg_match('/^'.preg_quote($homedir, '/').'/is', $edit_backup_loc)){
$error[] = __('The backup path is not an absolute path. Please provide an absolute path', 'backuply');
}
}
}
//backuply_log('ftp connection is successful');
// Create backup locaion dir for ftp/sftp
backuply_stream_wrapper_register($protocol, $protocol);
if(!empty($edit_backup_loc)){
mkdir($full_backup_loc);
}
}
$backuply_remote_backup_locs[$edit_loc_id]['name'] = $edit_loc_name;
$backuply_remote_backup_locs[$edit_loc_id]['backup_loc'] = $edit_backup_loc;
$backuply_remote_backup_locs[$edit_loc_id]['full_backup_loc'] = $full_backup_loc;
if('aws' == $protocol){
$backuply_remote_backup_locs[$edit_loc_id]['aws_sse'] = isset($_POST['aws_sse']) ? true : false;
}
if(!empty($error)){
return false;
}
update_option('backuply_remote_backup_locs', $backuply_remote_backup_locs);
if(!empty($_POST['backup_sync_infos'])){
backuply_sync_remote_backup_infos($edit_loc_id);
}
$saved = true;
if(!empty($saved)){
$success = __('Backup location details saved successfully', 'backuply');
return true;
}
}
// Handles Adding New Backup Location
if(isset($_REQUEST['addbackuploc'])){
// Verify Nonce
if(!wp_verify_nonce(backuply_optreq('security'), 'backuply_nonce')){
$error[] = __('Security check Failed!', 'backuply');
return false;
}
$protocol = backuply_optreq('protocol');
if(empty($protocol)){
$protocol = 'ftp';
}
// We dont ask the user location_name so we are fixing it here when Backuply Cloud is selected.
if($protocol == 'bcloud'){
$_REQUEST['location_name'] = 'Backuply Cloud';
}
$loc_name = backuply_REQUEST('location_name', __('No backup location name was specified', 'backuply'));
$existing_backup_locs = get_option('backuply_remote_backup_locs');
$remote_backup_locs = (!empty($existing_backup_locs) ? $existing_backup_locs: array());
$location_id = (empty($remote_backup_locs) ? 1 : max(array_keys($remote_backup_locs)) + 1);
$dropbox = backuply_load_remote_backup('dropbox');
$proto_arr = ['dropbox', 'gdrive', 'aws', 'caws', 'onedrive', 'bcloud'];
if(in_array($protocol, $proto_arr)){
$backup_loc = backuply_optreq('backup_loc');
$backup_loc = @trim($backup_loc, '/');
if(!empty($backup_loc)){
$backup_loc = '/'.$backup_loc;
}
if($protocol == 'onedrive'){
$onedrive = backuply_load_remote_backup('onedrive');
$callback_uri = menu_page_url('backuply', false) . '&security='.wp_create_nonce('backuply_nonce');
$onedrive_error = backuply_optget('error');
$onedrive_auth_code = backuply_optget('onedrive_auth_code');
if(!empty($onedrive_error)){
$error[] = __('It seems you cancelled the authorization process', 'backuply');
}
if(empty($onedrive_auth_code)){
$auth_url = 'https://api.backuply.com/onedrive/token.php?action=add_location&loc_name='.rawurlencode($loc_name).'&backup_loc='.rawurlencode($backup_loc).'&url='.rawurlencode($callback_uri).'&softtoken='.rawurlencode(backuply_csrf_get_token()).'&scope='.rawurlencode($onedrive->scopes);
backuply_redirect(filter_var($auth_url, FILTER_SANITIZE_URL), false);
exit;
}else{
$gen_token_resp = $onedrive->generate_onedrive_token($onedrive_auth_code);
$onedrive_access_token = $gen_token_resp['access_token'];
$onedrive_refresh_token = $gen_token_resp['refresh_token'];
if(empty($onedrive_access_token)){
$error[] = __('Failed to generate OneDrive Access Token', 'backuply');
}
}
$full_backup_loc = $protocol.'://'.rawurlencode($onedrive_refresh_token).'/'.$onedrive->app_dir.$backup_loc;
$onedrive->create_onedrive_app_dir($onedrive_refresh_token);
}elseif($protocol == 'bcloud'){
$bcloud = backuply_load_remote_backup('bcloud');
backuply_stream_wrapper_register($protocol, $protocol);
$license = get_option('backuply_license');
$bcloud_key = backuply_optreq('bcloud_key');
if(!empty($bcloud) && !empty($bcloud->bcloud_key)){
$error[] = __('Backuply Cloud is already added as a Location');
} else if(empty($license) || empty($license['license']) || empty($license['active'])){
$error[] = __('Your License is not linked yet', 'backuply');
} else {
$full_backup_loc = $protocol . '://'. rawurlencode(site_url()).'/'. $license['license'] . '?bcloud_key='.$bcloud_key;
if(!$oepn_dir = @opendir($full_backup_loc)){
$error[] = __('Failed to create a folder', 'backuply');
}
}
}elseif($protocol == 'gdrive'){
$gdrive = backuply_load_remote_backup('gdrive');
$callback_uri = menu_page_url('backuply', false) . '&security='.wp_create_nonce('backuply_nonce');
$gdrive_error = backuply_optget('error');
$gdrive_auth_code = backuply_optget('gdrive_auth_code');
if(!empty($gdrive_error)){
$error[] = __('It seems you cancelled the authorization process', 'backuply');
}
if(empty($gdrive_auth_code)){
$auth_url = 'https://api.backuply.com/gdrive/token.php?action=add_location&loc_name='.rawurlencode($loc_name).'&backup_loc='.rawurlencode($backup_loc).'&url='.rawurlencode($callback_uri).'&softtoken='.rawurlencode(backuply_csrf_get_token());
backuply_redirect(filter_var($auth_url, FILTER_SANITIZE_URL), false, true);
exit;
}else{
$gen_token_resp = $gdrive->generate_gdrive_token($gdrive_auth_code);
$gdrive_access_token = $gen_token_resp['access_token'];
$gdrive_refresh_token = $gen_token_resp['refresh_token'];
if(empty($gdrive_access_token)){
$error[] = __('Failed to generate Google Drive Access Token', 'backuply');
}
}
$full_backup_loc = $protocol.'://'.rawurlencode($gdrive_refresh_token).'/'.$gdrive->app_dir.$backup_loc;
$gdrive->create_gdrive_app_dir($gdrive_refresh_token);
backuply_stream_wrapper_register($protocol, $protocol);
if(!@opendir($full_backup_loc)){
if(!@mkdir($full_backup_loc)){
$error[] = __('Failed to create a folder', 'backuply');
}
}
}elseif($protocol == 'aws' || $protocol == 'caws'){
$aws = backuply_load_remote_backup($protocol);
$endpoint = backuply_POST('aws_endpoint',
__('Please provide the AWS S3 endpoint', 'backuply'));
$region = backuply_POST('aws_region',
__('Please provide the AWS S3 region', 'backuply'));
$bucketName = backuply_POST('aws_bucketname',
__('Please provide the AWS S3 bucket name', 'backuply'));
$accessKey = backuply_POST('aws_accessKey',
__('Please provide the AWS S3 access key', 'backuply'));
$secretKey = backuply_POST('aws_secretKey',
__('Please provide the AWS S3 secret key', 'backuply'));
if('aws' == $protocol){
$aws_sse = isset($_POST['aws_sse']) ? true : false;
}
if('caws' == $protocol){
$s3_compat = backuply_optpost('s3_compatible');
}
$defaultdir = '/'. $aws->app_dir;
backuply_stream_wrapper_register($protocol, $protocol);
$full_backup_loc = $protocol.'://'.rawurlencode($accessKey).':'.rawurlencode($secretKey).'@'.$bucketName.'/'.$endpoint.'/'.$region.$defaultdir.$backup_loc;
if(!@opendir($full_backup_loc)){
if(!@mkdir($full_backup_loc)){
$error[] = __('Failed to create bucket', 'backuply');
}
}
}elseif($protocol == 'dropbox'){
$access_code = backuply_optget('access_code');
if(empty($access_code)){
$callback_uri = menu_page_url('backuply', false) . '&security='.wp_create_nonce('backuply_nonce');
$url = 'https://api.backuply.com/dropbox/token.php?action=add_location&loc_name='.rawurlencode($loc_name).'&backup_loc='.rawurlencode($backup_loc).'&url='.rawurlencode($callback_uri).'&softtoken='.rawurlencode(backuply_csrf_get_token());
backuply_redirect($url, false);
exit;
}else {
$dropbox_tokens = $dropbox->generate_dropbox_token($access_code);
$dropbox_access_token = $dropbox_tokens['access_token'];
$dropbox_refresh_token = $dropbox_tokens['refresh_token'];
if(empty($dropbox_access_token) && !empty($access_code)){
$error[] = __('Failed to generate Dropbox Access Token', 'backuply');
}
$full_backup_loc = $protocol.'://'.$dropbox_refresh_token.$backup_loc;
}
}
}else{
// Server Host
$server_host = backuply_optreq('server_host');
$server_host = @rtrim($server_host, '/');
// The Port
$port = (int) backuply_optreq('port');
if(empty($port)){
$port = ($protocol == 'softsftp' ? 22 : 21);
}
// The FTP user
$ftp_user = backuply_POST('ftp_user', __('No FTP user was specified', 'backuply'));
// FTP Pass
if(backuply_optpost('ftp_pass') && !empty(backuply_optpost('ftp_pass'))){
$ftp_pass = backuply_optpost('ftp_pass');
}
// The Backup PATH
$backup_loc = backuply_POST('backup_loc', __('No Backup Location was specified', 'backuply'));
$backup_loc = '/'.@trim($backup_loc, '/');
//'@' in username was causing issue in fopen while creating backup
$full_backup_loc = $protocol.'://'.rawurlencode(($protocol == 'softsftp' && empty($ftp_pass) ? $location_id : $ftp_user)).':'.rawurlencode($ftp_pass).'@'.$server_host.(!empty($port) ? ':'.$port : '').$backup_loc;
// Test the connection
if($protocol == 'webdav'){
backuply_stream_wrapper_register($protocol, $protocol);
if(!empty($backup_loc)){
mkdir($full_backup_loc);
}
$webdav_connect = stat($full_backup_loc);
if(empty($webdav_connect['mtime']) && empty($webdav_connect['ctime'])){
$error[] = __('Failed to connect to the WebDAV server', 'backuply');
}
}
}
//Check for Duplicate Backup Location
if(!empty($existing_backup_locs)){
// We do not want to go in the loop if there are no existing backup locations
foreach($existing_backup_locs as $k => $v){
if($full_backup_loc == $v['full_backup_loc']){
$error[] = __('Backup Location with the same path already exists', 'backuply');
break;
}
}
}
if($protocol != 'dropbox' && $protocol != 'gdrive' && $protocol != 'webdav' && $protocol != 'aws' && $protocol != 'caws' && $protocol != 'onedrive' && $protocol != 'bcloud'){
//Connection established or not?
$ftp = backuply_sftp_connect($server_host, $ftp_user, $ftp_pass, $protocol, $port, false);
if(!is_object($ftp) && $ftp == '-2'){
$error[] = __('Could not login with specified details', 'backuply');
}
if(!is_object($ftp) && $ftp == '-1'){
$error[] = __('Could not Resolve Domain Name', 'backuply');
}
if(!is_object($ftp) && $ftp == '-3'){
$error[] = sprintf(esc_html__('Specified %1$s Path does not exist', 'backuply'), $protocols[$protocol]);
}
if($ftp == '-4'){
$error[] = __('Could not connect to the server', 'backuply');
}
if($ftp == '-5'){
$error[] = __('Could not connect to the server', 'backuply');
}
//backuply_log('isobject ftp : '.var_export($ftp, 1));
if(!is_object($ftp)){
$error[] = __('Could not connect to the server', 'backuply');
}
if(!empty($error)){
return false;
}
if($protocol == 'softsftp'){
$ftp->chdir('~');
$pwd = $ftp->pwd();
// Some servers pwd is empty and some / in that case we cannot check if it is absolute dir
if(!empty($pwd) && $pwd != '/'){
$homedir = $pwd.'/';
if(!preg_match('/^'.preg_quote($homedir, '/').'/is', backuply_cleanpath($backup_loc).'/')){
$error[] = sprintf(esc_html__('The backup path is not an absolute path (%1$s). Please provide an absolute path within your home dir (%2$s)', 'backuply'), $backup_loc, $homedir);
}
}
}
//backuply_log('ftp connection is successful');
// Create backup locaion dir for ftp/sftp
backuply_stream_wrapper_register($protocol, $protocol);
if(!empty($backup_loc)){
mkdir($full_backup_loc);
}
}
$remote_backup_locs[$location_id]['id'] = $location_id;
$remote_backup_locs[$location_id]['name'] = $loc_name;
$remote_backup_locs[$location_id]['protocol'] = $protocol;
$remote_backup_locs[$location_id]['backup_loc'] = $backup_loc;
$remote_backup_locs[$location_id]['full_backup_loc'] = !empty($full_backup_loc) ? $full_backup_loc : '';
if($protocol == 'dropbox'){
$remote_backup_locs[$location_id]['dropbox_token'] = $dropbox_access_token;
$remote_backup_locs[$location_id]['refresh_token'] = $dropbox_refresh_token;
}elseif($protocol == 'gdrive'){
$remote_backup_locs[$location_id]['gdrive_token'] = $gdrive_access_token;
$remote_backup_locs[$location_id]['gdrive_refresh_token'] = $gdrive_refresh_token;
}elseif($protocol == 'onedrive'){
$remote_backup_locs[$location_id]['onedrive_token'] = $onedrive_access_token;
$remote_backup_locs[$location_id]['onedrive_refresh_token'] = $onedrive_refresh_token;
}elseif($protocol == 'aws' || $protocol == 'caws'){
$remote_backup_locs[$location_id]['aws_accessKey'] = $accessKey;
$remote_backup_locs[$location_id]['aws_secretKey'] = $secretKey;
$remote_backup_locs[$location_id]['aws_endpoint'] = $endpoint;
$remote_backup_locs[$location_id]['aws_region'] = $region;
$remote_backup_locs[$location_id]['aws_bucketname'] = $bucketName;
if(!empty($s3_compat)){
$remote_backup_locs[$location_id]['s3_compatible'] = $s3_compat;
}
if(!empty($aws_sse)){
$remote_backup_locs[$location_id]['aws_sse'] = $aws_sse;
}
}elseif($protocol == 'bcloud'){
$remote_backup_locs[$location_id]['bcloud_key'] = !empty($bcloud_keys['bcloud_key']) ? sanitize_key($bcloud_keys['bcloud_key']) : '';
$remote_backup_locs[$location_id]['full_backup_loc'] = !empty($bcloud_keys) ? 'bcloud://'.$bcloud_keys['access_key'].':'.$bcloud_keys['secret_key'].'@'.$license['license'].'/'.$bcloud_keys['region'].'/us-east-1/'.$bcloud_keys['bcloud_key'] : '';
if(!empty($bcloud_keys['bcloud_key'])){
update_option('bcloud_key', $bcloud_keys['bcloud_key']);
}
}else{
$remote_backup_locs[$location_id]['server_host'] = $server_host;
$remote_backup_locs[$location_id]['port'] = $port;
$remote_backup_locs[$location_id]['ftp_user'] = $ftp_user;
$remote_backup_locs[$location_id]['ftp_pass'] = $ftp_pass;
}
if(!empty($error)){
return false;
}
update_option('backuply_remote_backup_locs', $remote_backup_locs);
if(!empty($_POST['backup_sync_infos'])){
backuply_sync_remote_backup_infos($location_id);
}
$saved = true;
$success = __('Backup Location added successfully', 'backuply');
return true;
}
}
function backuply_page_theme(){
global $backuply, $error, $success, $protocols, $wpdb;
//Load the theme's header
backuply_page_header('Backup');
$backups_dir = backuply_glob('backups');
$backups_info_dir = backuply_glob('backups_info');
if(empty($backups_dir) || empty($backups_info_dir)){
$backup_folder_suffix = wp_generate_password(6, false);
$error['folder_issue'] = __('Backuply was unable to create a directory where it creates backups, please create the following folders in wp-content/backuply directory', 'backuply') . 'backups_info-' . $backup_folder_suffix .' and backups-' . $backup_folder_suffix . ' Read More for detailed guide';
}
if(!empty($error)){
backuply_report_error($error);
}
if(!empty($success)){
backuply_report_success($success);
}
//Load Backuply's cron task, if any.
$cron_task = get_option('backuply_cron_settings');
//Get the main part of the backup file location
$backup_file_loc = preg_replace("/wp-admin\/admin.php/", '', wp_kses_post($_SERVER['PHP_SELF']));
$backup_file_loc = preg_replace("/\/$/", "", $backup_file_loc);
//Get the home path and remove the "/" at the end.
$dir_path = backuply_cleanpath(get_home_path());
// Cron schedules
$cron_schedules = backuply_add_cron_interval([]);
$backuply_nonce = wp_create_nonce('backuply_nonce');
?>
'. esc_html__('Pro Version', 'backuply'). '' : ''; ?>
(Last log)' : '';
$restore_last_log = (file_exists(BACKUPLY_BACKUP_DIR . 'backuply_restore_log.php')) ? ' (Last log)' : '';
$last_backup = get_option('backuply_last_backup') ? date('jS \of F Y h:i A', get_option('backuply_last_backup')) . $backup_last_log : 'None';
$last_restore = get_option('backuply_last_restore') ? date('jS \of F Y h:i A', get_option('backuply_last_restore')) . $restore_last_log : 'None';
$auto_backup_schedule = wp_next_scheduled('backuply_auto_backup_cron') ? date('Y-m-d h:i A', wp_next_scheduled('backuply_auto_backup_cron')) : '';
if(!empty($auto_backup_schedule)) {
$now = new DateTime();
$date = new DateTime($auto_backup_schedule);
$diff = $date->diff($now);
if($diff->d == 0 && $diff->h == 0 && $diff->i == 0)
$auto_backup_schedule = 'Now';
elseif($diff->d == 0 && $diff->h == 0)
$auto_backup_schedule = $diff->format("%i minutes");
elseif($diff->d == 0)
$auto_backup_schedule = $diff->format("%h hours and %i minutes");
else
$auto_backup_schedule = $diff->format("%d days, %h hours and %i minutes");
}
?>
Last Backup:
Last Restore:
Auto Backup Next Schedule: '.esc_html($auto_sche).'';
}
?>
To unlock more backup locations
Drag and Drop a file
OR
Supported file format .tar.gz
Backup Upload Alert
';
?>
Features |
Backuply Free |
Backuply Pro |
'.esc_html($feature[0]). ' |
|
|
';
} ?>
|
Active Now |
Get Pro |
data-process="">
Backing Up To:
Restoring From:
Select the file/folder you want to exclude
List of Excluded Files/Folders';
if(!empty($backuply['excludes']['exact'])){
foreach($backuply['excludes']['exact'] as $key => $pattern) {
echo '
'.esc_html($pattern).'
';
}
}
?>
|
|