BackWPup – WordPress Backup Plugin - Version 2.1.9

Version Description

  • bypass Google Analytics by Yoast oauth
  • improved working displaying
Download this release

Release Info

Developer danielhuesken
Plugin Icon 128x128 BackWPup – WordPress Backup Plugin
Version 2.1.9
Comparing to
See all releases

Code changes from version 2.1.8 to 2.1.9

backwpup-functions.php CHANGED
@@ -115,12 +115,9 @@ function backwpup_plugin_activate() {
115
  $jobs=get_option('backwpup_jobs');
116
  if (isset($jobs[0]))
117
  unset($jobs[0]); //Delete old false job
118
- $activejobs=false;
119
  if (!empty($jobs)) {
120
  foreach ($jobs as $jobid => $jobvalue) {
121
  $checktjobs[$jobid]=backwpup_get_job_vars($jobid); //check jobvaules
122
- if (!empty($checktjobs[$jobid]['activated']))
123
- $activejobs=true;
124
  }
125
  //save job values
126
  update_option('backwpup_jobs',$checktjobs);
@@ -128,8 +125,7 @@ function backwpup_plugin_activate() {
128
  //remove old cron jobs
129
  wp_clear_scheduled_hook('backwpup_cron');
130
  //make new schedule round
131
- if ($activejobs)
132
- wp_schedule_event(time(), 'backwpup_int', 'backwpup_cron');
133
  //Set settings defaults
134
  if (empty($cfg['mailsndemail'])) $cfg['mailsndemail']=sanitize_email(get_bloginfo( 'admin_email' ));
135
  if (empty($cfg['mailsndname'])) $cfg['mailsndname']='BackWPup '.get_bloginfo( 'name' );
115
  $jobs=get_option('backwpup_jobs');
116
  if (isset($jobs[0]))
117
  unset($jobs[0]); //Delete old false job
 
118
  if (!empty($jobs)) {
119
  foreach ($jobs as $jobid => $jobvalue) {
120
  $checktjobs[$jobid]=backwpup_get_job_vars($jobid); //check jobvaules
 
 
121
  }
122
  //save job values
123
  update_option('backwpup_jobs',$checktjobs);
125
  //remove old cron jobs
126
  wp_clear_scheduled_hook('backwpup_cron');
127
  //make new schedule round
128
+ wp_schedule_event(time(), 'backwpup_int', 'backwpup_cron');
 
129
  //Set settings defaults
130
  if (empty($cfg['mailsndemail'])) $cfg['mailsndemail']=sanitize_email(get_bloginfo( 'admin_email' ));
131
  if (empty($cfg['mailsndname'])) $cfg['mailsndname']='BackWPup '.get_bloginfo( 'name' );
backwpup.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: BackWPup
4
  Plugin URI: http://backwpup.com
5
  Description: WordPress Backup and more...
6
  Author: Daniel Hüsken
7
- Version: 2.1.8
8
  Author URI: http://danielhuesken.de
9
  Text Domain: backwpup
10
  Domain Path: /lang/
@@ -32,7 +32,7 @@ Domain Path: /lang/
32
  define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
33
  define('BACKWPUP_PLUGIN_BASEURL',plugins_url('',__FILE__));
34
  //Set Plugin Version
35
- define('BACKWPUP_VERSION', '2.1.8');
36
  //Set Min Wordpress Version
37
  define('BACKWPUP_MIN_WORDPRESS_VERSION', '3.1');
38
  //Set User Capability
@@ -97,5 +97,11 @@ if (backwpup_env_checks()) {
97
  $cfg=get_option('backwpup');
98
  if (!empty($cfg['disablewpcron']))
99
  define('DISABLE_WP_CRON',true);
 
 
 
 
 
 
100
  }
101
  ?>
4
  Plugin URI: http://backwpup.com
5
  Description: WordPress Backup and more...
6
  Author: Daniel Hüsken
7
+ Version: 2.1.9
8
  Author URI: http://danielhuesken.de
9
  Text Domain: backwpup
10
  Domain Path: /lang/
32
  define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
33
  define('BACKWPUP_PLUGIN_BASEURL',plugins_url('',__FILE__));
34
  //Set Plugin Version
35
+ define('BACKWPUP_VERSION', '2.1.9');
36
  //Set Min Wordpress Version
37
  define('BACKWPUP_MIN_WORDPRESS_VERSION', '3.1');
38
  //Set User Capability
97
  $cfg=get_option('backwpup');
98
  if (!empty($cfg['disablewpcron']))
99
  define('DISABLE_WP_CRON',true);
100
+ //bypass Google Analytics by Yoast oauth
101
+ if ( isset($_GET['oauth_token']) && $_GET['page'] == 'backwpupeditjob' ) {
102
+ $_GET['oauth_token_backwpup'] = $_GET['oauth_token'];
103
+ unset($_GET['oauth_token']);
104
+ unset($_REQUEST['oauth_token']);
105
+ }
106
  }
107
  ?>
job/backup_create.php CHANGED
@@ -49,7 +49,11 @@ function backup_create() {
49
  }
50
  } else { //use PclZip
51
  define('PCLZIP_TEMPORARY_DIR', $STATIC['TEMPDIR']);
52
- require_once($STATIC['WP']['ABSPATH'].'wp-admin/includes/class-pclzip.php');
 
 
 
 
53
  //Create Zip File
54
  if (is_array($filelist[0])) {
55
  trigger_error(sprintf(__('%d. try to create backup zip (PclZip) archive...','backwpup'),$WORKING['BACKUP_CREATE']['STEP_TRY']),E_USER_NOTICE);
@@ -58,9 +62,9 @@ function backup_create() {
58
  $files[$i][79003]=$filelist[$i]['OUTFILE'];
59
  $files[$i][79004]=$filelist[$i]['MTIME'];
60
  }
61
- need_free_memory('40M'); //40MB free memory for zip
62
  $zipbackupfile = new PclZip($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
63
- if (0==$zipbackupfile->create($files,PCLZIP_CB_POST_ADD,'_pclzipPostAddCallBack')) {
64
  trigger_error(sprintf(__('Zip archive create error: %s','backwpup'),$zipbackupfile->errorInfo(true)),E_USER_ERROR);
65
  } else {
66
  $WORKING['STEPDONE']=count($filelist);
@@ -68,6 +72,8 @@ function backup_create() {
68
  trigger_error(__('Backup zip archive create done','backwpup'),E_USER_NOTICE);
69
  }
70
  }
 
 
71
  }
72
  } elseif (strtolower($STATIC['JOB']['fileformart'])==".tar.gz" or strtolower($STATIC['JOB']['fileformart'])==".tar.bz2" or strtolower($STATIC['JOB']['fileformart'])==".tar") { //tar files
73
 
49
  }
50
  } else { //use PclZip
51
  define('PCLZIP_TEMPORARY_DIR', $STATIC['TEMPDIR']);
52
+ require_once($STATIC['WP']['ABSPATH'].'wp-admin/includes/class-pclzip.php');
53
+ if ( ini_get( 'mbstring.func_overload' ) && function_exists( 'mb_internal_encoding' ) ) {
54
+ $previous_encoding = mb_internal_encoding();
55
+ mb_internal_encoding( 'ISO-8859-1' );
56
+ }
57
  //Create Zip File
58
  if (is_array($filelist[0])) {
59
  trigger_error(sprintf(__('%d. try to create backup zip (PclZip) archive...','backwpup'),$WORKING['BACKUP_CREATE']['STEP_TRY']),E_USER_NOTICE);
62
  $files[$i][79003]=$filelist[$i]['OUTFILE'];
63
  $files[$i][79004]=$filelist[$i]['MTIME'];
64
  }
65
+ need_free_memory('20M'); //20MB free memory for zip
66
  $zipbackupfile = new PclZip($STATIC['JOB']['backupdir'].$STATIC['backupfile']);
67
+ if (0==$zipbackupfile->create($files,PCLZIP_CB_POST_ADD,'_pclzipPostAddCallBack',PCLZIP_OPT_TEMP_FILE_THRESHOLD, 5)) {
68
  trigger_error(sprintf(__('Zip archive create error: %s','backwpup'),$zipbackupfile->errorInfo(true)),E_USER_ERROR);
69
  } else {
70
  $WORKING['STEPDONE']=count($filelist);
72
  trigger_error(__('Backup zip archive create done','backwpup'),E_USER_NOTICE);
73
  }
74
  }
75
+ if ( isset($previous_encoding) )
76
+ mb_internal_encoding( $previous_encoding );
77
  }
78
  } elseif (strtolower($STATIC['JOB']['fileformart'])==".tar.gz" or strtolower($STATIC['JOB']['fileformart'])==".tar.bz2" or strtolower($STATIC['JOB']['fileformart'])==".tar") { //tar files
79
 
job/file_list.php CHANGED
@@ -6,7 +6,7 @@ function file_list() {
6
  $WORKING['STEPTODO']=2;
7
 
8
  //Check free memory for file list
9
- need_free_memory(4194304); //4MB free memory for filelist
10
  //empty filelist
11
  $tempfilelist=array();
12
  //exlude of job
6
  $WORKING['STEPTODO']=2;
7
 
8
  //Check free memory for file list
9
+ need_free_memory('10MB'); //10MB free memory for filelist
10
  //empty filelist
11
  $tempfilelist=array();
12
  //exlude of job
job/job_functions.php CHANGED
@@ -64,7 +64,7 @@ function add_file($files) {
64
  // get file list
65
  function get_filelist() {
66
  global $STATIC;
67
- if (file_exists($STATIC['TEMPDIR'].'.filelist') and $filelistfile=file_get_contents($STATIC['TEMPDIR'].'.filelist'))
68
  return unserialize(trim($filelistfile));
69
  else
70
  return array();
@@ -178,7 +178,7 @@ function delete_working_file() {
178
 
179
  function update_working_file($mustwrite=false) {
180
  global $WORKING,$STATIC,$runmicrotime;
181
- if (!file_exists($STATIC['TEMPDIR'].'.running')) {
182
  job_end();
183
  return false;
184
  }
@@ -469,6 +469,7 @@ function job_end() {
469
  update_working_file(true);
470
  unlink($STATIC['TEMPDIR'].'.running');
471
  rmdir($STATIC['TEMPDIR']);
 
472
  }
473
  mysql_close($mysqlconlink);
474
  die();
@@ -501,7 +502,7 @@ function job_shutdown($signal='') {
501
  }
502
  //no more restarts
503
  $WORKING['RESTART']++;
504
- if ((!empty($STATIC['WP']['ALTERNATE_CRON']) or $WORKING['RESTART']>=$STATIC['CFG']['jobscriptretry']) and file_exists($STATIC['TEMPDIR'].'.running') and is_writable($STATIC['LOGFILE'])) { //only x restarts allowed
505
  if (!empty($STATIC['WP']['ALTERNATE_CRON']))
506
  file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."\"|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]>".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span class=\"error\">[ERROR]".__('Can not restart on alternate cron....','backwpup')."</span><br />\n", FILE_APPEND);
507
  else
@@ -523,7 +524,7 @@ function job_shutdown($signal='') {
523
  //set PID to 0
524
  $WORKING['PID']=0;
525
  //Excute jobrun again
526
- if (!file_exists($STATIC['TEMPDIR'].'.running'))
527
  exit;
528
  if (is_writable($STATIC['LOGFILE']))
529
  file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]\">".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span>".$WORKING['RESTART'].'. '.__('Script stop! Will started again now!','backwpup')."</span><br />\n", FILE_APPEND);
64
  // get file list
65
  function get_filelist() {
66
  global $STATIC;
67
+ if (is_file($STATIC['TEMPDIR'].'.filelist') and $filelistfile=file_get_contents($STATIC['TEMPDIR'].'.filelist'))
68
  return unserialize(trim($filelistfile));
69
  else
70
  return array();
178
 
179
  function update_working_file($mustwrite=false) {
180
  global $WORKING,$STATIC,$runmicrotime;
181
+ if (!is_file($STATIC['TEMPDIR'].'.running')) {
182
  job_end();
183
  return false;
184
  }
469
  update_working_file(true);
470
  unlink($STATIC['TEMPDIR'].'.running');
471
  rmdir($STATIC['TEMPDIR']);
472
+ clearstatcache();
473
  }
474
  mysql_close($mysqlconlink);
475
  die();
502
  }
503
  //no more restarts
504
  $WORKING['RESTART']++;
505
+ if ((!empty($STATIC['WP']['ALTERNATE_CRON']) or $WORKING['RESTART']>=$STATIC['CFG']['jobscriptretry']) and is_file($STATIC['TEMPDIR'].'.running') and is_writable($STATIC['LOGFILE'])) { //only x restarts allowed
506
  if (!empty($STATIC['WP']['ALTERNATE_CRON']))
507
  file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."\"|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]>".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span class=\"error\">[ERROR]".__('Can not restart on alternate cron....','backwpup')."</span><br />\n", FILE_APPEND);
508
  else
524
  //set PID to 0
525
  $WORKING['PID']=0;
526
  //Excute jobrun again
527
+ if (!is_file($STATIC['TEMPDIR'].'.running'))
528
  exit;
529
  if (is_writable($STATIC['LOGFILE']))
530
  file_put_contents($STATIC['LOGFILE'], "<span class=\"timestamp\" title=\"[Line: ".__LINE__."|File: ".basename(__FILE__)."|Mem: ".formatbytes(@memory_get_usage(true))."|Mem Max: ".formatbytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."|PID: ".getmypid()."]\">".date('Y/m/d H:i.s',time()+$STATIC['WP']['TIMEDIFF']).":</span> <span>".$WORKING['RESTART'].'. '.__('Script stop! Will started again now!','backwpup')."</span><br />\n", FILE_APPEND);
job/job_run.php CHANGED
@@ -3,16 +3,11 @@
3
  define('BACKWPUP_JOBRUN_FOLDER', dirname(__FILE__).'/');
4
  // get needed functions for the jobrun
5
  require_once(BACKWPUP_JOBRUN_FOLDER.'job_functions.php');
6
- //check referer
7
- if ($_SERVER["HTTP_USER_AGENT"]!='BackWPup' and $_POST['type']!='javastart') {
8
- header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found",true,404);
9
- die();
10
- }
11
  //get temp dir
12
- $STATIC['TEMPDIR']=trim(urldecode($_POST['BackWPupJobTemp']));
13
- if (!is_writable($STATIC['TEMPDIR'])) {
 
14
  die('Temp dir not writable!!! Job aborted!');
15
- }
16
  //read runningfile and config
17
  $runningfile=get_working_file();
18
  if ($runningfile['JOBID']>0 and $runningfile['WORKING']['NONCE']==$_POST['nonce']) {
@@ -43,12 +38,12 @@ flush();
43
  if (function_exists('memory_get_usage') && (inbytes(@ini_get('memory_limit')) < inbytes($STATIC['WP']['MEMORY_LIMIT'])))
44
  @ini_set('memory_limit',$STATIC['WP']['MEMORY_LIMIT']);
45
  //check existing Logfile
46
- if (empty($STATIC) or !file_exists($STATIC['LOGFILE'])) {
47
  delete_working_file();
48
  die('No logfile found!');
49
  }
50
  //load translation
51
- if (file_exists(dirname(__FILE__).'/../lang/backwpup-'.$STATIC['WP']['WPLANG'].'.mo')) {
52
  require($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/pomo/mo.php');
53
  $TRANSLATE = new MO();
54
  $TRANSLATE->import_from_file(dirname(__FILE__).'/../lang/backwpup-'.$STATIC['WP']['WPLANG'].'.mo');
@@ -99,7 +94,7 @@ mysql_update();
99
  foreach($WORKING['STEPS'] as $step) {
100
  $stepfile=strtolower($step).'.php';
101
  if ($step!='JOB_END') {
102
- if (file_exists(BACKWPUP_JOBRUN_FOLDER.$stepfile)) {
103
  require_once(BACKWPUP_JOBRUN_FOLDER.$stepfile);
104
  } else {
105
  trigger_error(sprintf(__('Can not find job step file: %s','backwpup'),$stepfile),E_USER_ERROR);
3
  define('BACKWPUP_JOBRUN_FOLDER', dirname(__FILE__).'/');
4
  // get needed functions for the jobrun
5
  require_once(BACKWPUP_JOBRUN_FOLDER.'job_functions.php');
 
 
 
 
 
6
  //get temp dir
7
+ $STATIC['TEMPDIR']=filter_input( INPUT_POST, 'BackWPupJobTemp', FILTER_SANITIZE_URL );
8
+ $STATIC['TEMPDIR']=rtrim(realpath($STATIC['TEMPDIR']),'/\\').'/';
9
+ if (empty($STATIC['TEMPDIR']) || !is_dir($STATIC['TEMPDIR']) || !is_writable($STATIC['TEMPDIR']))
10
  die('Temp dir not writable!!! Job aborted!');
 
11
  //read runningfile and config
12
  $runningfile=get_working_file();
13
  if ($runningfile['JOBID']>0 and $runningfile['WORKING']['NONCE']==$_POST['nonce']) {
38
  if (function_exists('memory_get_usage') && (inbytes(@ini_get('memory_limit')) < inbytes($STATIC['WP']['MEMORY_LIMIT'])))
39
  @ini_set('memory_limit',$STATIC['WP']['MEMORY_LIMIT']);
40
  //check existing Logfile
41
+ if (empty($STATIC) or !is_file($STATIC['LOGFILE'])) {
42
  delete_working_file();
43
  die('No logfile found!');
44
  }
45
  //load translation
46
+ if (is_file(dirname(__FILE__).'/../lang/backwpup-'.$STATIC['WP']['WPLANG'].'.mo')) {
47
  require($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/pomo/mo.php');
48
  $TRANSLATE = new MO();
49
  $TRANSLATE->import_from_file(dirname(__FILE__).'/../lang/backwpup-'.$STATIC['WP']['WPLANG'].'.mo');
94
  foreach($WORKING['STEPS'] as $step) {
95
  $stepfile=strtolower($step).'.php';
96
  if ($step!='JOB_END') {
97
+ if (is_file(BACKWPUP_JOBRUN_FOLDER.$stepfile)) {
98
  require_once(BACKWPUP_JOBRUN_FOLDER.$stepfile);
99
  } else {
100
  trigger_error(sprintf(__('Can not find job step file: %s','backwpup'),$stepfile),E_USER_ERROR);
job/show_working.php CHANGED
@@ -1,13 +1,13 @@
1
  <?PHP
2
  function backwpup_read_logfile($logfile) {
3
- if (is_file($logfile) and strtolower(substr($logfile,-3))=='.gz')
4
  $logfiledata=gzfile($logfile);
5
  elseif (is_file($logfile.'.gz'))
6
  $logfiledata=gzfile($logfile.'.gz');
7
  elseif (is_file($logfile))
8
  $logfiledata=file($logfile);
9
  else
10
- return false;
11
  $lines=array();
12
  $start=false;
13
  foreach ($logfiledata as $line){
@@ -22,24 +22,13 @@ function backwpup_read_logfile($logfile) {
22
  return $lines;
23
  }
24
 
25
- function backwpup_get_working_file() {
26
- if (is_file(trim($_POST['BackWPupJobTemp']).'.running')) {
27
- if ($runningfile=file_get_contents(trim($_POST['BackWPupJobTemp']).'.running'))
28
- return unserialize(trim($runningfile));
29
- else
30
- return false;
31
- } else {
32
- return false;
33
- }
34
- }
35
-
36
  //read log file header
37
  function backwpup_read_logheader($logfile) {
38
  $headers=array("backwpup_version" => "version","backwpup_logtime" => "logtime","backwpup_errors" => "errors","backwpup_warnings" => "warnings","backwpup_jobid" => "jobid","backwpup_jobname" => "name","backwpup_jobtype" => "type","backwpup_jobruntime" => "runtime","backwpup_backupfilesize" => "backupfilesize");
39
  if (!is_readable($logfile))
40
  return false;
41
  //Read file
42
- if (strtolower(substr($logfile,-3))==".gz") {
43
  $fp = gzopen( $logfile, 'r' );
44
  $file_data = gzread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
45
  gzclose( $fp );
@@ -61,37 +50,41 @@ function backwpup_read_logheader($logfile) {
61
  return $joddata;
62
  }
63
 
64
- $_POST['logfile']=trim(str_replace(array(':','@','../','//','\\'),'',$_POST['logfile']));
65
- $_POST['BackWPupJobTemp']=trim(str_replace(array(':','@','../','//','\\'),'',$_POST['BackWPupJobTemp']));
66
- if (file_exists($_POST['logfile'].'.gz'))
67
- $_POST['logfile']=$_POST['logfile'].'.gz';
68
-
69
- // check given file is a backwpup logfile
70
- if (substr(trim($_POST['logfile']),-3)!='.gz' and substr($_POST['logfile'],-8)!='.html.gz' and substr($_POST['logfile'],0,13)!='backwpup_log_' and strlen($_POST['logfile'])>40 and strlen($_POST['logfile'])<37)
71
  die();
 
 
72
 
 
 
 
73
  $log='';
74
- if (file_exists($_POST['logfile'])) {
75
- if (file_exists($_POST['BackWPupJobTemp'].'.running')) {
76
- if ($infile=backwpup_get_working_file()) {
77
- $warnings=$infile['WORKING']['WARNING'];
78
- $errors=$infile['WORKING']['ERROR'];
79
- $stepspersent=$infile['STEPSPERSENT'];
80
- $steppersent=$infile['STEPPERSENT'];
81
- }
 
 
 
 
 
 
 
82
  } else {
83
- $logheader=backwpup_read_logheader(trim($_POST['logfile']));
84
  $warnings=$logheader['warnings'];
85
  $errors=$logheader['errors'];
86
  $stepspersent=100;
87
  $steppersent=100;
88
  $log.='<span id="stopworking"></span>';
89
  }
90
- $logfilarray=backwpup_read_logfile(trim($_POST['logfile']));
91
- //for ($i=0;$i<count($logfilarray);$i++)
92
- for ($i=$_POST['logpos'];$i<count($logfilarray);$i++)
93
- $log.=$logfilarray[$i];
94
- echo json_encode(array('logpos'=>count($logfilarray),'LOG'=>$log,'WARNING'=>$warnings,'ERROR'=>$errors,'STEPSPERSENT'=>$stepspersent,'STEPPERSENT'=>$steppersent));
95
  }
96
  die();
97
  ?>
1
  <?PHP
2
  function backwpup_read_logfile($logfile) {
3
+ if (is_file($logfile) and substr($logfile,-3)=='.gz')
4
  $logfiledata=gzfile($logfile);
5
  elseif (is_file($logfile.'.gz'))
6
  $logfiledata=gzfile($logfile.'.gz');
7
  elseif (is_file($logfile))
8
  $logfiledata=file($logfile);
9
  else
10
+ return array();
11
  $lines=array();
12
  $start=false;
13
  foreach ($logfiledata as $line){
22
  return $lines;
23
  }
24
 
 
 
 
 
 
 
 
 
 
 
 
25
  //read log file header
26
  function backwpup_read_logheader($logfile) {
27
  $headers=array("backwpup_version" => "version","backwpup_logtime" => "logtime","backwpup_errors" => "errors","backwpup_warnings" => "warnings","backwpup_jobid" => "jobid","backwpup_jobname" => "name","backwpup_jobtype" => "type","backwpup_jobruntime" => "runtime","backwpup_backupfilesize" => "backupfilesize");
28
  if (!is_readable($logfile))
29
  return false;
30
  //Read file
31
+ if (substr($logfile,-3)==".gz") {
32
  $fp = gzopen( $logfile, 'r' );
33
  $file_data = gzread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
34
  gzclose( $fp );
50
  return $joddata;
51
  }
52
 
53
+ $logfile=filter_input( INPUT_POST, 'logfile', FILTER_SANITIZE_URL );
54
+ $logfile=realpath($logfile);
55
+ if (substr($logfile,-5)!='.html' && substr(basename($logfile),0,13)!='backwpup_log_')
 
 
 
 
56
  die();
57
+ if (is_file($logfile.'.gz'))
58
+ $logfile.='.gz';
59
 
60
+ $backwpupjobtemp=filter_input( INPUT_POST, 'BackWPupJobTemp', FILTER_SANITIZE_URL );
61
+ $backwpupjobtemp=rtrim(realpath($backwpupjobtemp),'/\\');
62
+
63
  $log='';
64
+ if (is_file($logfile)) {
65
+ $logpos=filter_input( INPUT_POST, 'logpos', FILTER_SANITIZE_NUMBER_INT );
66
+ $logfilarray=backwpup_read_logfile($logfile);
67
+ $newpos=count($logfilarray);
68
+ for ($i=$logpos;$i<count($logfilarray);$i++)
69
+ $log.=$logfilarray[$i];
70
+ if (!empty($newpos) && $newpos>0)
71
+ $logpos=$newpos;
72
+
73
+ if (is_file($backwpupjobtemp.'/.running') && $runningfile=file_get_contents($backwpupjobtemp.'/.running')) {
74
+ $infile=unserialize($runningfile);
75
+ $warnings=$infile['WORKING']['WARNING'];
76
+ $errors=$infile['WORKING']['ERROR'];
77
+ $stepspersent=$infile['STEPSPERSENT'];
78
+ $steppersent=$infile['STEPPERSENT'];
79
  } else {
80
+ $logheader=backwpup_read_logheader($logfile);
81
  $warnings=$logheader['warnings'];
82
  $errors=$logheader['errors'];
83
  $stepspersent=100;
84
  $steppersent=100;
85
  $log.='<span id="stopworking"></span>';
86
  }
87
+ echo json_encode(array('logpos'=>$logpos,'LOG'=>$log,'WARNING'=>$warnings,'ERROR'=>$errors,'STEPSPERSENT'=>$stepspersent,'STEPPERSENT'=>$steppersent));
 
 
 
 
88
  }
89
  die();
90
  ?>
job/wp_export_generate.php CHANGED
@@ -6,13 +6,14 @@ define('DONOTCDN', true);
6
  define('DONOTCACHCEOBJECT', true);
7
  define('W3TC_IN_MINIFY',false); //W3TC will not loaded
8
 
9
- $_POST['BackWPupJobTemp']=str_replace(array(':','@','../','//','\\'),'',$_POST['BackWPupJobTemp']);
10
- if (file_exists(trim($_POST['BackWPupJobTemp']).'.running'))
11
- $runningfile=file_get_contents(trim($_POST['BackWPupJobTemp']).'.running');
 
12
  $infile=array();
13
  if (!empty($runningfile))
14
  $infile=unserialize(trim($runningfile));
15
- if (file_exists(trim($infile['ABSPATH']).'wp-load.php') and $_POST['nonce']==$infile['WORKING']['NONCE'] and $_POST['type']=='getxmlexport') {
16
  require_once(trim($infile['ABSPATH']).'wp-load.php'); /** Setup WordPress environment */
17
  require_once(trim($infile['ABSPATH']).'wp-admin/includes/export.php');
18
  export_wp();
6
  define('DONOTCACHCEOBJECT', true);
7
  define('W3TC_IN_MINIFY',false); //W3TC will not loaded
8
 
9
+ $backwpupjobtemp=filter_input( INPUT_POST, 'BackWPupJobTemp', FILTER_SANITIZE_URL );
10
+ $backwpupjobtemp=rtrim(realpath($backwpupjobtemp),'/\\');
11
+ if (!empty($backwpupjobtemp) && is_dir($backwpupjobtemp) && is_file($backwpupjobtemp).'/.running')
12
+ $runningfile=file_get_contents($backwpupjobtemp.'/.running');
13
  $infile=array();
14
  if (!empty($runningfile))
15
  $infile=unserialize(trim($runningfile));
16
+ if (is_file(trim($infile['ABSPATH']).'wp-load.php') and $_POST['nonce']==$infile['WORKING']['NONCE'] and $_POST['type']=='getxmlexport') {
17
  require_once(trim($infile['ABSPATH']).'wp-load.php'); /** Setup WordPress environment */
18
  require_once(trim($infile['ABSPATH']).'wp-admin/includes/export.php');
19
  export_wp();
js/backwpupworking.js CHANGED
@@ -1,7 +1,6 @@
1
  jQuery(document).ready( function($) {
2
  if ($('#alternate_wp_cron').val()=='1') {
3
  $.ajax({
4
- headers: {'User-Agent': 'BackWPup'},
5
  type: 'POST',
6
  url: $('#backwpuprunurl').val(),
7
  cache: false,
@@ -17,7 +16,6 @@ jQuery(document).ready( function($) {
17
  if ($('#logfile').length>0) {
18
  var refreshId = setInterval(function() {
19
  $.ajax({
20
- headers: {'User-Agent': 'BackWPup'},
21
  type: 'POST',
22
  url: $('#backwpupworkingajaxurl').val(),
23
  cache: false,
@@ -28,12 +26,9 @@ jQuery(document).ready( function($) {
28
  },
29
  dataType: 'json',
30
  success: function(rundata) {
31
- if ( 0 < rundata.logpos ) {
32
- $('#logpos').val(rundata.logpos);
33
- }
34
  if ( '' != rundata.LOG ) {
35
  $('#showworking').append(rundata.LOG);
36
- //$('#showworking').replaceWith('<div id=\"showworking\">'+rundata.LOG+'</div>');
37
  $('#showworking').scrollTop(rundata.logpos*12);
38
  }
39
  if ( 0 < rundata.ERROR ) {
1
  jQuery(document).ready( function($) {
2
  if ($('#alternate_wp_cron').val()=='1') {
3
  $.ajax({
 
4
  type: 'POST',
5
  url: $('#backwpuprunurl').val(),
6
  cache: false,
16
  if ($('#logfile').length>0) {
17
  var refreshId = setInterval(function() {
18
  $.ajax({
 
19
  type: 'POST',
20
  url: $('#backwpupworkingajaxurl').val(),
21
  cache: false,
26
  },
27
  dataType: 'json',
28
  success: function(rundata) {
29
+ $('#logpos').val(rundata.logpos);
 
 
30
  if ( '' != rundata.LOG ) {
31
  $('#showworking').append(rundata.LOG);
 
32
  $('#showworking').scrollTop(rundata.logpos*12);
33
  }
34
  if ( 0 < rundata.ERROR ) {
pages/header_backwpup.php CHANGED
@@ -95,6 +95,7 @@ if (!empty($doaction)) {
95
  closedir($dir);
96
  }
97
  }
 
98
  if (!empty($runningfile['LOGFILE'])) {
99
  file_put_contents($runningfile['LOGFILE'], "<span class=\"timestamp\">".backwpup_date_i18n('Y/m/d H:i.s').":</span> <span class=\"error\">[ERROR]".__('Aborted by user!!!','backwpup')."</span><br />\n", FILE_APPEND);
100
  //write new log header
95
  closedir($dir);
96
  }
97
  }
98
+ clearstatcache();
99
  if (!empty($runningfile['LOGFILE'])) {
100
  file_put_contents($runningfile['LOGFILE'], "<span class=\"timestamp\">".backwpup_date_i18n('Y/m/d H:i.s').":</span> <span class=\"error\">[ERROR]".__('Aborted by user!!!','backwpup')."</span><br />\n", FILE_APPEND);
101
  //write new log header
pages/header_backwpupeditjob.php CHANGED
@@ -7,9 +7,9 @@ if (isset($_GET['dropboxauth']) and $_GET['dropboxauth']=='AccessToken') {
7
  $jobid = (int) $_GET['jobid'];
8
  check_admin_referer('edit-job');
9
  $backwpup_message='';
10
- if ((int)$_GET['uid']>0 and !empty($_GET['oauth_token'])) {
11
  $reqtoken=get_transient('backwpup_dropboxrequest');
12
- if ($reqtoken['oAuthRequestToken']==$_GET['oauth_token']) {
13
  //Get Access Tokens
14
  require_once (dirname(__FILE__).'/../libs/dropbox.php');
15
  $jobs=get_option('backwpup_jobs');
7
  $jobid = (int) $_GET['jobid'];
8
  check_admin_referer('edit-job');
9
  $backwpup_message='';
10
+ if ((int)$_GET['uid']>0 and !empty($_GET['oauth_token_backwpup'])) {
11
  $reqtoken=get_transient('backwpup_dropboxrequest');
12
+ if ($reqtoken['oAuthRequestToken']==$_GET['oauth_token_backwpup']) {
13
  //Get Access Tokens
14
  require_once (dirname(__FILE__).'/../libs/dropbox.php');
15
  $jobs=get_option('backwpup_jobs');
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: backup, admin, file, Database, mysql, Cron, ftp, S3, export, xml, multisite, Rackspace, Cloud, Azure, DropBox, SugarSync, Google, Storage
5
  Requires at least: 3.1
6
  Tested up to: 3.3
7
- Stable tag: 2.1.8
8
 
9
  WordPress Backup and more...
10
 
@@ -52,6 +52,10 @@ Do backups and more for your WordPress Blog.
52
  4. Backups Manage Page
53
 
54
  == Changelog ==
 
 
 
 
55
  = 2.1.8 =
56
  * Updated AWS lib to 1.5.2
57
  * Security improvements
4
  Tags: backup, admin, file, Database, mysql, Cron, ftp, S3, export, xml, multisite, Rackspace, Cloud, Azure, DropBox, SugarSync, Google, Storage
5
  Requires at least: 3.1
6
  Tested up to: 3.3
7
+ Stable tag: 2.1.9
8
 
9
  WordPress Backup and more...
10
 
52
  4. Backups Manage Page
53
 
54
  == Changelog ==
55
+ = 2.1.9 =
56
+ * bypass Google Analytics by Yoast oauth
57
+ * improved working displaying
58
+
59
  = 2.1.8 =
60
  * Updated AWS lib to 1.5.2
61
  * Security improvements