Backup and Restore WordPress – WPBackItUp Backup Plugin - Version 1.32.0

Version Description

Download this release

Release Info

Developer cssimmon
Plugin Icon 128x128 Backup and Restore WordPress – WPBackItUp Backup Plugin
Version 1.32.0
Comparing to
See all releases

Code changes from version 1.31.0 to 1.32.0

lib/includes/class-admin-notices.php CHANGED
@@ -75,11 +75,11 @@ if ( ! class_exists( 'WPBackitup_Admin_Notices' ) ) {
75
  // $notice = $this->get_safe_beta_notice();
76
  // $this->show_notice($promo,$notice);
77
  // break;
78
- case $this->BLACK_FRIDAY_2018_PROMO:
79
- $promo = sprintf("%s-%s",$this->promo,$this->get_black_friday_day_id_2018());
80
- $notice = $this->get_black_friday_notice_2018();
81
- $this->show_notice($promo,$notice);
82
- break;
83
  // case $this->INDEPENDENCE_DAY_PROMO:
84
  // $promo = sprintf("%s-%s",$this->promo,$this->get_indepence_day_promo_id());
85
  // $notice = $this->get_independence_day_notice();
@@ -146,14 +146,14 @@ if ( ! class_exists( 'WPBackitup_Admin_Notices' ) ) {
146
  //
147
  //
148
  // //Is the black friday active
149
- if ( false !== $this->get_black_friday_day_id_2018()) {
150
- $wpbacktiup_license = new WPBackItUp_License();
151
-
152
- //Don't show notice when premium is installed
153
- if (!$wpbacktiup_license->is_premium_license() || ! $wpbacktiup_license->is_license_active() ) {
154
- return $this->BLACK_FRIDAY_2018_PROMO;
155
- }
156
- }
157
 
158
  return false; //no active promos
159
 
75
  // $notice = $this->get_safe_beta_notice();
76
  // $this->show_notice($promo,$notice);
77
  // break;
78
+ // case $this->BLACK_FRIDAY_2018_PROMO:
79
+ // $promo = sprintf("%s-%s",$this->promo,$this->get_black_friday_day_id_2018());
80
+ // $notice = $this->get_black_friday_notice_2018();
81
+ // $this->show_notice($promo,$notice);
82
+ // break;
83
  // case $this->INDEPENDENCE_DAY_PROMO:
84
  // $promo = sprintf("%s-%s",$this->promo,$this->get_indepence_day_promo_id());
85
  // $notice = $this->get_independence_day_notice();
146
  //
147
  //
148
  // //Is the black friday active
149
+ // if ( false !== $this->get_black_friday_day_id_2018()) {
150
+ // $wpbacktiup_license = new WPBackItUp_License();
151
+ //
152
+ // //Don't show notice when premium is installed
153
+ // if (!$wpbacktiup_license->is_premium_license() || ! $wpbacktiup_license->is_license_active() ) {
154
+ // return $this->BLACK_FRIDAY_2018_PROMO;
155
+ // }
156
+ // }
157
 
158
  return false; //no active promos
159
 
lib/includes/class-api.php CHANGED
@@ -58,6 +58,9 @@ class WPBackItUp_API {
58
  // Random status value
59
  // $cloud_status = array('uploading', 'uploaded', 'error', false);
60
 
 
 
 
61
  $available_backups[] = array(
62
  'backup_job_id' => $backup_job->getJobId(),
63
  'backup_job_name' => $backup_job->getJobName(),
58
  // Random status value
59
  // $cloud_status = array('uploading', 'uploaded', 'error', false);
60
 
61
+
62
+
63
+
64
  $available_backups[] = array(
65
  'backup_job_id' => $backup_job->getJobId(),
66
  'backup_job_name' => $backup_job->getJobName(),
lib/includes/class-backup.php CHANGED
@@ -87,6 +87,9 @@ class WPBackItUp_Backup {
87
  $this->backup_retained_number = $WPBackitup->backup_retained_number();
88
  $this->backup_retained_days = WPBACKITUP__BACKUP_RETAINED_DAYS; //Prob need to move this to main propery
89
 
 
 
 
90
  } catch(Exception $e) {
91
  error_log($e);
92
  WPBackItUp_Logger::log_error($this->log_name,__METHOD__,'Constructor Exception: ' .$e);
@@ -180,8 +183,14 @@ class WPBackItUp_Backup {
180
 
181
  //Check for job control record
182
  $folder_name = basename($folder);
183
- $job = WPBackItUp_Job::get_jobs_by_job_name(WPBackItUp_Job::BACKUP,$folder_name);
184
 
 
 
 
 
 
 
 
185
  //If no jobs found then purge
186
  if(false===$job){
187
  if (file_exists($folder)) {
@@ -1307,8 +1316,10 @@ class WPBackItUp_Backup {
1307
  WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Begin');
1308
 
1309
  $backup_project_path = $this->backup_project_path;
 
1310
  //remove the 4 character prefix
1311
- $new_backup_path = str_replace('TMP_','',$backup_project_path);
 
1312
 
1313
  $file_system = new WPBackItUp_FileSystem($this->log_name);
1314
  if (! $file_system->rename_file($backup_project_path,$new_backup_path)){
@@ -1316,7 +1327,7 @@ class WPBackItUp_Backup {
1316
  return false;
1317
  }
1318
 
1319
- $this->set_final_backup_path();
1320
 
1321
  WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'End');
1322
  return true;
@@ -1325,15 +1336,17 @@ class WPBackItUp_Backup {
1325
  /**
1326
  * this is needed because it is set to TMP until finalization then needed a way to know where the current path is
1327
  *
 
1328
  */
1329
- public function set_final_backup_path(){
1330
  WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Begin');
1331
 
1332
- $backup_project_path = $this->backup_project_path;
1333
- $new_backup_path = str_replace('TMP_','',$backup_project_path);
 
 
1334
 
1335
- //set the path to the new path
1336
- $this->backup_project_path=$new_backup_path;
1337
 
1338
  WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'End');
1339
  }
87
  $this->backup_retained_number = $WPBackitup->backup_retained_number();
88
  $this->backup_retained_days = WPBACKITUP__BACKUP_RETAINED_DAYS; //Prob need to move this to main propery
89
 
90
+ //error_log("CONSTRUCTOR:" .var_export($this->backup_project_path,true));
91
+
92
+
93
  } catch(Exception $e) {
94
  error_log($e);
95
  WPBackItUp_Logger::log_error($this->log_name,__METHOD__,'Constructor Exception: ' .$e);
183
 
184
  //Check for job control record
185
  $folder_name = basename($folder);
 
186
 
187
+ //Check for the secure prefix on the folder name - may not always exist
188
+ $delimiter_count = substr_count ($folder_name,"_");
189
+ if ($delimiter_count>=2){
190
+ $folder_name =substr($folder_name,strpos($folder_name,"_")+1);
191
+ }
192
+
193
+ $job = WPBackItUp_Job::get_jobs_by_job_name(WPBackItUp_Job::BACKUP,$folder_name);
194
  //If no jobs found then purge
195
  if(false===$job){
196
  if (file_exists($folder)) {
1316
  WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Begin');
1317
 
1318
  $backup_project_path = $this->backup_project_path;
1319
+
1320
  //remove the 4 character prefix
1321
+ $new_prefix=wp_generate_password(10,false,false)."_";
1322
+ $new_backup_path = str_replace('TMP_',$new_prefix,$backup_project_path);
1323
 
1324
  $file_system = new WPBackItUp_FileSystem($this->log_name);
1325
  if (! $file_system->rename_file($backup_project_path,$new_backup_path)){
1327
  return false;
1328
  }
1329
 
1330
+ $this->backup_project_path=$new_backup_path;
1331
 
1332
  WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'End');
1333
  return true;
1336
  /**
1337
  * this is needed because it is set to TMP until finalization then needed a way to know where the current path is
1338
  *
1339
+ * @param $new_backup_path
1340
  */
1341
+ public function set_final_backup_path($new_backup_path){
1342
  WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Begin');
1343
 
1344
+ //make sure exists before setting - could be false
1345
+ if (file_exists($new_backup_path)){
1346
+ $this->backup_project_path=$new_backup_path;
1347
+ }
1348
 
1349
+ //error_log("SET FINAL:" .var_export($this->backup_project_path,true));
 
1350
 
1351
  WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'End');
1352
  }
lib/includes/class-job.php CHANGED
@@ -460,6 +460,20 @@ class WPBackItUp_Job {
460
  return $this->getJobMetaValue('backup_zip_files',false);
461
  }
462
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
463
 
464
  /**
465
  * Set job start time
460
  return $this->getJobMetaValue('backup_zip_files',false);
461
  }
462
 
463
+ /**
464
+ * Get backup Zip Files
465
+ *
466
+ * @return string/false on not found
467
+ */
468
+ public function getBackupFolderPath() {
469
+ $backupFolderPath=false;
470
+ $backupFiles = $this->getJobMetaValue('backup_zip_files',false);
471
+ if (is_array($backupFiles))
472
+ $backupFolderPath = dirname(key($backupFiles));
473
+
474
+ return $backupFolderPath;
475
+ }
476
+
477
 
478
  /**
479
  * Set job start time
lib/includes/class-license.php CHANGED
@@ -599,6 +599,7 @@ class WPBackItUp_License {
599
  $data['license_type'] = 2;
600
  break;
601
  case 2://premium
 
602
  $data['license_type'] = 3;
603
  break;
604
  }
599
  $data['license_type'] = 2;
600
  break;
601
  case 2://premium
602
+ case 3://Premium-50
603
  $data['license_type'] = 3;
604
  break;
605
  }
lib/includes/class-usage.php CHANGED
@@ -205,7 +205,25 @@ class WPBackItUp_Usage {
205
  $blocking=false;
206
  if (true===WPBACKITUP__DEBUG) $blocking=true;
207
  $this->setup_data($source);
208
- $response = wp_remote_post( 'https://5bx6m4uwn0.execute-api.us-east-1.amazonaws.com/prd/utv2', array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  'method' => 'POST',
210
  'timeout' => 8,
211
  'redirection' => 5,
205
  $blocking=false;
206
  if (true===WPBACKITUP__DEBUG) $blocking=true;
207
  $this->setup_data($source);
208
+
209
+ //$url = 'https://5bx6m4uwn0.execute-api.us-east-1.amazonaws.com/prd/utv2';
210
+ $api_url = 'https://5bx6m4uwn0.execute-api.us-east-1.amazonaws.com';
211
+ $environment = "prd";
212
+ $api_version = "utv2";
213
+
214
+ //add environment for testing
215
+ if (true===WPBACKITUP__DEBUG) {
216
+ //When testing use VPN or request will be rejected because of api gateway blacklist
217
+ $environment = "dev";
218
+ $this->data['ut-id'] = 'dev-testing';
219
+ $this->data['environment'] = 'dev';
220
+ }
221
+
222
+ $url = sprintf("%s/%s/%s",$api_url,$environment,$api_version);
223
+ // error_log(var_export($url,true));
224
+ // error_log(var_export($this->data,true));
225
+ WPBackItUp_Logger::log_info($this->log_name,__METHOD__,'Usage Tracking Request:' . var_export( json_encode( $this->data ), true ));
226
+ $response = wp_remote_post( $url, array(
227
  'method' => 'POST',
228
  'timeout' => 8,
229
  'redirection' => 5,
lib/includes/class-wpbackitup-admin.php CHANGED
@@ -1176,8 +1176,13 @@ class WPBackitup_Admin {
1176
 
1177
  $job = WPBackItUp_Job::get_job_by_id($job_id);
1178
  if (false!==$job){
1179
- $job->setStatus(WPBackItUp_Job::DELETED);
1180
- $backup_folder_name = $job->getJobName();
 
 
 
 
 
1181
 
1182
  $backup_folder_path = WPBACKITUP__BACKUP_PATH .'/' . $backup_folder_name;
1183
  $DLT_backup_folder_path = WPBACKITUP__BACKUP_PATH .'/DLT_' . $backup_folder_name .'_' . current_time( 'timestamp' );
1176
 
1177
  $job = WPBackItUp_Job::get_job_by_id($job_id);
1178
  if (false!==$job){
1179
+
1180
+ //Cleanup will remove folders of orphaned even if folder not prefixed.
1181
+ $job->setStatus(WPBackItUp_Job::DELETED);
1182
+ $backup_folder_name = $job->getBackupFolderPath();
1183
+ if (false!=$backup_folder_name){
1184
+ $backup_folder_name = basename($backup_folder_name);
1185
+ }
1186
 
1187
  $backup_folder_path = WPBACKITUP__BACKUP_PATH .'/' . $backup_folder_name;
1188
  $DLT_backup_folder_path = WPBACKITUP__BACKUP_PATH .'/DLT_' . $backup_folder_name .'_' . current_time( 'timestamp' );
lib/includes/handler_download.php CHANGED
@@ -78,6 +78,22 @@ if ( isset($_REQUEST['_wpnonce']) && !empty($_REQUEST['_wpnonce'])
78
  WPBackItUp_Logger::log_info($download_logname,__METHOD__,'Backup file path:' . $backup_path );
79
  }
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  if ( (!empty($backup_filename) || !empty($log_filename) ) && file_exists( $backup_path ) ) {
82
  $file_name=basename( $backup_path );
83
  $file_size = filesize($backup_path);
78
  WPBackItUp_Logger::log_info($download_logname,__METHOD__,'Backup file path:' . $backup_path );
79
  }
80
 
81
+ //If file doesnt exist look for secure path
82
+ if ( ! file_exists( $backup_path ) ) {
83
+ $file_name = basename($backup_path);
84
+ //error_log(var_export($backup_path,true));
85
+ $job_name = basename(dirname($backup_path));
86
+ $backup_jobs = WPBackItUp_Job::get_jobs_by_job_name( WPBackItUp_Job::BACKUP, $job_name );
87
+
88
+ //If a job was found
89
+ if (is_array($backup_jobs) && count($backup_jobs)>0){
90
+ $backup_job=current($backup_jobs);
91
+ $backup_path = $backup_job->getBackupFolderPath();
92
+ $backup_path = $backup_path."/".$file_name;
93
+ }
94
+ }
95
+
96
+ //error_log(var_export($backup_path,true));
97
  if ( (!empty($backup_filename) || !empty($log_filename) ) && file_exists( $backup_path ) ) {
98
  $file_name=basename( $backup_path );
99
  $file_size = filesize($backup_path);
lib/includes/job_backup.php CHANGED
@@ -525,6 +525,7 @@ if ('task_backup_siteinfo'==$current_task->getTaskName()) {
525
  return false;
526
  }
527
 
 
528
  }
529
 
530
 
@@ -1040,6 +1041,7 @@ if ('task_encrypt_files'==$current_task->getTaskName()) {
1040
  $current_task->setStatus(WPBackItUp_Job_Task::COMPLETE);
1041
  WPBackItUp_Logger::log($backup_logname,'**END ENCRYPT SENSITIVE FILES**');
1042
 
 
1043
  }
1044
 
1045
 
@@ -1216,12 +1218,11 @@ if ('task_finalize_backup'==$current_task->getTaskName()) {
1216
  }
1217
  }
1218
 
1219
- //POST BACKUP TASKS
1220
-
1221
- $wp_backup->set_final_backup_path();
1222
-
1223
  //RUN POST BACKUP TASKS
1224
  //error_log('TASK:'.$current_task->getTaskName());
 
 
 
1225
  //If not complete then we must have some post backup tasks
1226
  $post_backup_task = sprintf("%s_%s",WPBACKITUP__NAMESPACE,$current_task->getTaskName());
1227
  //error_log('Run Task:'.$post_backup_task);
@@ -1270,7 +1271,7 @@ function end_backup($err=null, $success=null){
1270
  WPBackItUp_Admin_Bar::backup_success();
1271
  }
1272
 
1273
- $wp_backup->set_final_backup_path();
1274
 
1275
  WPBackItUp_Logger::log_info($backup_logname,__METHOD__,'Zip up all the logs.');
1276
  //Zip up all the logs in the log folder
525
  return false;
526
  }
527
 
528
+ return;
529
  }
530
 
531
 
1041
  $current_task->setStatus(WPBackItUp_Job_Task::COMPLETE);
1042
  WPBackItUp_Logger::log($backup_logname,'**END ENCRYPT SENSITIVE FILES**');
1043
 
1044
+ return;
1045
  }
1046
 
1047
 
1218
  }
1219
  }
1220
 
 
 
 
 
1221
  //RUN POST BACKUP TASKS
1222
  //error_log('TASK:'.$current_task->getTaskName());
1223
+
1224
+ $wp_backup->set_final_backup_path($current_job->getBackupFolderPath());
1225
+
1226
  //If not complete then we must have some post backup tasks
1227
  $post_backup_task = sprintf("%s_%s",WPBACKITUP__NAMESPACE,$current_task->getTaskName());
1228
  //error_log('Run Task:'.$post_backup_task);
1271
  WPBackItUp_Admin_Bar::backup_success();
1272
  }
1273
 
1274
+ $wp_backup->set_final_backup_path($current_job->getBackupFolderPath());
1275
 
1276
  WPBackItUp_Logger::log_info($backup_logname,__METHOD__,'Zip up all the logs.');
1277
  //Zip up all the logs in the log folder
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: wpbackitup, cssimmon, alaminopu, imranshuvo
3
  Tags: backup, backups, back up, backup plugin, database backup, multisite backup, full backup, database, restore, migrate, clone, malware
4
  Requires at least: 3.8.0
5
  Requires PHP: 5.2.4
6
- Tested up to: 5.0
7
- Stable tag: 1.30.0
8
  Author URI: https://www.wpbackitup.com
9
  Donate link: https://www.wpbackitup.com
10
  License: GPLv2 or later
@@ -217,6 +217,13 @@ Our online documentation and full list of FAQs can be found at [support.wpbackit
217
 
218
 
219
  == Changelog ==
 
 
 
 
 
 
 
220
  = 1.31 =
221
  *Release Date - November 6, 2018
222
 
3
  Tags: backup, backups, back up, backup plugin, database backup, multisite backup, full backup, database, restore, migrate, clone, malware
4
  Requires at least: 3.8.0
5
  Requires PHP: 5.2.4
6
+ Tested up to: 5.1
7
+ Stable tag: 1.31.0
8
  Author URI: https://www.wpbackitup.com
9
  Donate link: https://www.wpbackitup.com
10
  License: GPLv2 or later
217
 
218
 
219
  == Changelog ==
220
+ = 1.32 =
221
+ *Release Date - March 4, 2019
222
+
223
+ * UPDATE : Tested up to WP 5.1
224
+ * UPDATE : Added secure prefix to backup folder name to increase security
225
+ * UPDATE : Minor updates to backup engine
226
+
227
  = 1.31 =
228
  *Release Date - November 6, 2018
229
 
wp-backitup.php CHANGED
@@ -6,7 +6,7 @@
6
  * Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
7
  * Author: WPBackItUp
8
  * Author URI: https://www.wpbackitup.com
9
- * Version: 1.31.0
10
  * Text Domain: wp-backitup
11
  *
12
  * License: GPL3
@@ -32,7 +32,7 @@ define( 'WPBACKITUP__NAMESPACE', 'wp-backitup' );
32
  define( 'WPBACKITUP__CLASSNAMESPACE', 'WPBackItUp' );
33
 
34
  define( 'WPBACKITUP__MAJOR_VERSION', 1);
35
- define( 'WPBACKITUP__MINOR_VERSION', 31);
36
  define( 'WPBACKITUP__MAINTENANCE_VERSION', 0); //Dont forget to update version in header on WP release
37
  define( 'WPBACKITUP__BUILD_VERSION', 0); //Used for hotfix releases
38
 
6
  * Description: Backup your content, settings, themes, plugins and media in just a few simple clicks.
7
  * Author: WPBackItUp
8
  * Author URI: https://www.wpbackitup.com
9
+ * Version: 1.32.0
10
  * Text Domain: wp-backitup
11
  *
12
  * License: GPL3
32
  define( 'WPBACKITUP__CLASSNAMESPACE', 'WPBackItUp' );
33
 
34
  define( 'WPBACKITUP__MAJOR_VERSION', 1);
35
+ define( 'WPBACKITUP__MINOR_VERSION', 32);
36
  define( 'WPBACKITUP__MAINTENANCE_VERSION', 0); //Dont forget to update version in header on WP release
37
  define( 'WPBACKITUP__BUILD_VERSION', 0); //Used for hotfix releases
38