BackUpWordPress - Version 2.1.2

Version Description

Download this release

Release Info

Developer willmot
Plugin Icon 128x128 BackUpWordPress
Version 2.1.2
Comparing to
See all releases

Code changes from version 2.1.1 to 2.1.2

admin/actions.php CHANGED
@@ -45,9 +45,9 @@ add_action( 'load-tools_page_' . HMBKP_PLUGIN_SLUG, 'hmbkp_request_delete_schedu
45
  function hmbkp_ajax_request_do_backup() {
46
 
47
  if ( empty( $_POST['hmbkp_schedule_id'] ) )
48
- return;
49
 
50
- // We wan't to display any fatal errors in this ajax request so we can catch them on the other side.
51
  error_reporting( E_ERROR );
52
  @ini_set( 'display_errors', 'On' );
53
  @ini_set( 'html_errors', 'Off' );
@@ -149,7 +149,7 @@ add_action( 'admin_init', 'hmbkp_dismiss_error' );
149
  function hmbkp_ajax_is_backup_in_progress() {
150
 
151
  if ( empty( $_POST['hmbkp_schedule_id'] ) )
152
- return;
153
 
154
  $schedule = new HMBKP_Scheduled_Backup( urldecode( $_POST['hmbkp_schedule_id'] ) );
155
 
@@ -170,7 +170,7 @@ add_action( 'wp_ajax_hmbkp_is_in_progress', 'hmbkp_ajax_is_backup_in_progress' )
170
  function hmbkp_ajax_calculate_backup_size() {
171
 
172
  if ( empty( $_POST['hmbkp_schedule_id'] ) )
173
- return;
174
 
175
  $schedule = new HMBKP_Scheduled_Backup( urldecode( $_POST['hmbkp_schedule_id'] ) );
176
 
@@ -209,6 +209,9 @@ add_action( 'wp_ajax_hmbkp_cron_test', 'hmbkp_ajax_cron_test' );
209
  */
210
  function hmbkp_edit_schedule_load() {
211
 
 
 
 
212
  $schedule = new HMBKP_Scheduled_Backup( $_GET['hmbkp_schedule_id'] );
213
 
214
  require( HMBKP_PLUGIN_PATH . '/admin/schedule-form.php' );
@@ -223,6 +226,9 @@ add_action( 'wp_ajax_hmbkp_edit_schedule_load', 'hmbkp_edit_schedule_load' );
223
  */
224
  function hmbkp_edit_schedule_excludes_load() {
225
 
 
 
 
226
  $schedule = new HMBKP_Scheduled_Backup( $_GET['hmbkp_schedule_id'] );
227
 
228
  require( HMBKP_PLUGIN_PATH . '/admin/schedule-form-excludes.php' );
@@ -255,7 +261,7 @@ add_action( 'wp_ajax_hmbkp_add_schedule_load', 'hmbkp_add_schedule_load' );
255
  function hmnkp_edit_schedule_submit() {
256
 
257
  if ( empty( $_GET['hmbkp_schedule_id'] ) )
258
- return;
259
 
260
  $schedule = new HMBKP_Scheduled_Backup( $_GET['hmbkp_schedule_id'] );
261
 
@@ -327,6 +333,9 @@ add_action( 'wp_ajax_hmnkp_edit_schedule_submit', 'hmnkp_edit_schedule_submit' )
327
  */
328
  function hmbkp_add_exclude_rule() {
329
 
 
 
 
330
  $schedule = new HMBKP_Scheduled_Backup( $_POST['hmbkp_schedule_id'] );
331
 
332
  $schedule->set_excludes( $_POST['hmbkp_exclude_rule'], true );
@@ -349,6 +358,9 @@ add_action( 'wp_ajax_hmbkp_add_exclude_rule', 'hmbkp_add_exclude_rule' );
349
  */
350
  function hmbkp_delete_exclude_rule() {
351
 
 
 
 
352
  $schedule = new HMBKP_Scheduled_Backup( $_GET['hmbkp_schedule_id'] );
353
 
354
  $excludes = $schedule->get_excludes();
@@ -373,11 +385,14 @@ add_action( 'wp_ajax_hmbkp_delete_exclude_rule', 'hmbkp_delete_exclude_rule' );
373
  */
374
  function hmbkp_preview_exclude_rule() {
375
 
376
- if ( ! empty( $_POST['hmbkp_schedule_id'] ) )
377
- $schedule = new HMBKP_Scheduled_Backup( $_POST['hmbkp_schedule_id'] );
 
 
378
 
379
- if ( ! empty( $_POST['hmbkp_schedule_excludes'] ) )
380
- $excludes = explode( ',', $_POST['hmbkp_schedule_excludes'] );
 
381
 
382
  hmbkp_file_list( $schedule, $excludes, 'get_excluded_files' );
383
 
@@ -403,7 +418,7 @@ add_action( 'wp_ajax_hmbkp_file_list', 'hmbkp_preview_exclude_rule', 10, 0 );
403
  function hmbkp_display_error_and_offer_to_email_it() {
404
 
405
  if ( empty( $_POST['hmbkp_error'] ) )
406
- return;
407
 
408
  $error = str_replace( HM_Backup::get_home_path(), '', $_POST['hmbkp_error'] ); ?>
409
 
@@ -425,7 +440,7 @@ add_action( 'wp_ajax_hmbkp_backup_error', 'hmbkp_display_error_and_offer_to_emai
425
  function hmbkp_send_error_via_email() {
426
 
427
  if ( empty( $_POST['hmbkp_error'] ) )
428
- return;
429
 
430
  $error = $_POST['hmbkp_error'];
431
 
45
  function hmbkp_ajax_request_do_backup() {
46
 
47
  if ( empty( $_POST['hmbkp_schedule_id'] ) )
48
+ exit;
49
 
50
+ // We want to display any fatal errors in this ajax request so we can catch them on the other side.
51
  error_reporting( E_ERROR );
52
  @ini_set( 'display_errors', 'On' );
53
  @ini_set( 'html_errors', 'Off' );
149
  function hmbkp_ajax_is_backup_in_progress() {
150
 
151
  if ( empty( $_POST['hmbkp_schedule_id'] ) )
152
+ exit;
153
 
154
  $schedule = new HMBKP_Scheduled_Backup( urldecode( $_POST['hmbkp_schedule_id'] ) );
155
 
170
  function hmbkp_ajax_calculate_backup_size() {
171
 
172
  if ( empty( $_POST['hmbkp_schedule_id'] ) )
173
+ exit;
174
 
175
  $schedule = new HMBKP_Scheduled_Backup( urldecode( $_POST['hmbkp_schedule_id'] ) );
176
 
209
  */
210
  function hmbkp_edit_schedule_load() {
211
 
212
+ if ( empty( $_GET['hmbkp_schedule_id'] ) )
213
+ exit;
214
+
215
  $schedule = new HMBKP_Scheduled_Backup( $_GET['hmbkp_schedule_id'] );
216
 
217
  require( HMBKP_PLUGIN_PATH . '/admin/schedule-form.php' );
226
  */
227
  function hmbkp_edit_schedule_excludes_load() {
228
 
229
+ if ( empty( $_GET['hmbkp_schedule_id'] ) )
230
+ exit;
231
+
232
  $schedule = new HMBKP_Scheduled_Backup( $_GET['hmbkp_schedule_id'] );
233
 
234
  require( HMBKP_PLUGIN_PATH . '/admin/schedule-form-excludes.php' );
261
  function hmnkp_edit_schedule_submit() {
262
 
263
  if ( empty( $_GET['hmbkp_schedule_id'] ) )
264
+ exit;
265
 
266
  $schedule = new HMBKP_Scheduled_Backup( $_GET['hmbkp_schedule_id'] );
267
 
333
  */
334
  function hmbkp_add_exclude_rule() {
335
 
336
+ if ( empty( $_GET['hmbkp_schedule_id'] ) )
337
+ exit;
338
+
339
  $schedule = new HMBKP_Scheduled_Backup( $_POST['hmbkp_schedule_id'] );
340
 
341
  $schedule->set_excludes( $_POST['hmbkp_exclude_rule'], true );
358
  */
359
  function hmbkp_delete_exclude_rule() {
360
 
361
+ if ( empty( $_GET['hmbkp_schedule_id'] ) )
362
+ exit;
363
+
364
  $schedule = new HMBKP_Scheduled_Backup( $_GET['hmbkp_schedule_id'] );
365
 
366
  $excludes = $schedule->get_excludes();
385
  */
386
  function hmbkp_preview_exclude_rule() {
387
 
388
+ echo 'test';
389
+
390
+ if ( empty( $_POST['hmbkp_schedule_id'] ) || empty( $_POST['hmbkp_schedule_excludes'] ) )
391
+ exit;
392
 
393
+ $schedule = new HMBKP_Scheduled_Backup( $_POST['hmbkp_schedule_id'] );
394
+
395
+ $excludes = explode( ',', $_POST['hmbkp_schedule_excludes'] );
396
 
397
  hmbkp_file_list( $schedule, $excludes, 'get_excluded_files' );
398
 
418
  function hmbkp_display_error_and_offer_to_email_it() {
419
 
420
  if ( empty( $_POST['hmbkp_error'] ) )
421
+ exit;
422
 
423
  $error = str_replace( HM_Backup::get_home_path(), '', $_POST['hmbkp_error'] ); ?>
424
 
440
  function hmbkp_send_error_via_email() {
441
 
442
  if ( empty( $_POST['hmbkp_error'] ) )
443
+ exit;
444
 
445
  $error = $_POST['hmbkp_error'];
446
 
assets/hmbkp.js CHANGED
@@ -76,6 +76,8 @@ jQuery( document ).ready( function( $ ) {
76
  { 'action' : 'hmbkp_file_list', 'hmbkp_schedule_excludes' : $( '.hmbkp_add_exclude_rule input' ).val(), 'hmbkp_schedule_id' : $( '[name="hmbkp_schedule_id"]' ).val() },
77
  function( data ) {
78
 
 
 
79
  $( '.hmbkp_add_exclude_rule ul' ).remove();
80
  $( '.hmbkp_add_exclude_rule p' ).remove();
81
 
@@ -216,7 +218,7 @@ jQuery( document ).ready( function( $ ) {
216
  function( data ) {
217
 
218
  // Assume success if no data passed back
219
- if ( ! data ) {
220
 
221
  $.fancybox.close();
222
 
@@ -306,7 +308,7 @@ jQuery( document ).ready( function( $ ) {
306
  function( data ) {
307
 
308
  // Backup Succeeded
309
- if ( ! data ) {
310
  location.reload( true );
311
  }
312
 
@@ -320,7 +322,7 @@ jQuery( document ).ready( function( $ ) {
320
  { 'action' : 'hmbkp_backup_error', 'hmbkp_error' : data },
321
  function( data ) {
322
 
323
- if ( ! data )
324
  return;
325
 
326
  $.fancybox( {
@@ -375,8 +377,8 @@ function hmbkpRedirectOnBackupComplete( schedule_id, redirect ) {
375
  { 'action' : 'hmbkp_is_in_progress', 'hmbkp_schedule_id' : jQuery( '[data-hmbkp-schedule-id]' ).attr( 'data-hmbkp-schedule-id' ) },
376
  function( data ) {
377
 
378
- if ( data === 0 && redirect === true ) {
379
- location.reload( true );
380
 
381
  } else {
382
 
76
  { 'action' : 'hmbkp_file_list', 'hmbkp_schedule_excludes' : $( '.hmbkp_add_exclude_rule input' ).val(), 'hmbkp_schedule_id' : $( '[name="hmbkp_schedule_id"]' ).val() },
77
  function( data ) {
78
 
79
+ console.log( data );
80
+
81
  $( '.hmbkp_add_exclude_rule ul' ).remove();
82
  $( '.hmbkp_add_exclude_rule p' ).remove();
83
 
218
  function( data ) {
219
 
220
  // Assume success if no data passed back
221
+ if ( ! data || data == 0 ) {
222
 
223
  $.fancybox.close();
224
 
308
  function( data ) {
309
 
310
  // Backup Succeeded
311
+ if ( ! data || data == 0 ) {
312
  location.reload( true );
313
  }
314
 
322
  { 'action' : 'hmbkp_backup_error', 'hmbkp_error' : data },
323
  function( data ) {
324
 
325
+ if ( ! data || data == 0 )
326
  return;
327
 
328
  $.fancybox( {
377
  { 'action' : 'hmbkp_is_in_progress', 'hmbkp_schedule_id' : jQuery( '[data-hmbkp-schedule-id]' ).attr( 'data-hmbkp-schedule-id' ) },
378
  function( data ) {
379
 
380
+ if ( data == 0 && redirect === true ) {
381
+ location.reload( true );
382
 
383
  } else {
384
 
functions/core.php CHANGED
@@ -287,11 +287,11 @@ function hmbkp_path() {
287
  if ( ! file_exists( $index ) && is_writable( $path ) )
288
  file_put_contents( $index, '' );
289
 
 
 
290
  // Protect the directory with a .htaccess file on Apache servers
291
  if ( $is_apache && function_exists( 'insert_with_markers' ) && ! file_exists( $htaccess ) && is_writable( $path ) ) {
292
 
293
- $htaccess = $path . '/.htaccess';
294
-
295
  $contents[] = '# ' . sprintf( __( 'This %s file ensures that other people cannot download your backup files.', 'hmbkp' ), '.htaccess' );
296
  $contents[] = '';
297
  $contents[] = '<IfModule mod_rewrite.c>';
287
  if ( ! file_exists( $index ) && is_writable( $path ) )
288
  file_put_contents( $index, '' );
289
 
290
+ $htaccess = $path . '/.htaccess';
291
+
292
  // Protect the directory with a .htaccess file on Apache servers
293
  if ( $is_apache && function_exists( 'insert_with_markers' ) && ! file_exists( $htaccess ) && is_writable( $path ) ) {
294
 
 
 
295
  $contents[] = '# ' . sprintf( __( 'This %s file ensures that other people cannot download your backup files.', 'hmbkp' ), '.htaccess' );
296
  $contents[] = '';
297
  $contents[] = '<IfModule mod_rewrite.c>';
hm-backup/hm-backup.php CHANGED
@@ -195,7 +195,8 @@ class HM_Backup {
195
 
196
  $home_path = ABSPATH;
197
 
198
- if ( $home_url !== $site_url )
 
199
  $home_path = trailingslashit( substr( ABSPATH, 0, strrpos( ABSPATH, str_replace( $home_url, '', $site_url ) ) ) );
200
 
201
  return self::conform_dir( $home_path );
@@ -907,7 +908,8 @@ class HM_Backup {
907
  if ( ! empty( $this->mysqldump_verified ) )
908
  return true;
909
 
910
- if ( ! file_exists( $this->get_database_dump_filepath() ) )
 
911
  $this->error( $this->get_mysqldump_method(), __( 'The mysqldump file was not created', 'hmbkp' ) );
912
 
913
  if ( $this->get_errors( $this->get_mysqldump_method() ) )
195
 
196
  $home_path = ABSPATH;
197
 
198
+ // If site_url contains home_url and they differ then assume WordPress is installed in a sub directory
199
+ if ( $home_url !== $site_url && strpos( $site_url, $home_url ) === 0 )
200
  $home_path = trailingslashit( substr( ABSPATH, 0, strrpos( ABSPATH, str_replace( $home_url, '', $site_url ) ) ) );
201
 
202
  return self::conform_dir( $home_path );
908
  if ( ! empty( $this->mysqldump_verified ) )
909
  return true;
910
 
911
+ // mysqldump can create empty dump files on error so we need to check the filesize
912
+ if ( ! file_exists( $this->get_database_dump_filepath() ) || filesize( $this->get_database_dump_filepath() ) === 0 )
913
  $this->error( $this->get_mysqldump_method(), __( 'The mysqldump file was not created', 'hmbkp' ) );
914
 
915
  if ( $this->get_errors( $this->get_mysqldump_method() ) )
plugin.php CHANGED
@@ -5,7 +5,7 @@ Plugin Name: BackUpWordPress
5
  Plugin URI: http://hmn.md/backupwordpress/
6
  Description: Simple automated backups of your WordPress powered website. Once activated you'll find me under <strong>Tools &rarr; Backups</strong>.
7
  Author: Human Made Limited
8
- Version: 2.1.1
9
  Author URI: http://hmn.md/
10
  */
11
 
5
  Plugin URI: http://hmn.md/backupwordpress/
6
  Description: Simple automated backups of your WordPress powered website. Once activated you'll find me under <strong>Tools &rarr; Backups</strong>.
7
  Author: Human Made Limited
8
+ Version: 2.1.2
9
  Author URI: http://hmn.md/
10
  */
11
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: humanmade, joehoyle, mattheu, tcrsavage, willmot, cuvelier
3
  Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade
4
  Requires at least: 3.3.3
5
  Tested up to: 3.5
6
- Stable tag: 2.1.1
7
 
8
  Simple automated back ups of your WordPress powered website.
9
 
@@ -103,6 +103,13 @@ You can also tweet <a href="http://twitter.com/humanmadeltd">@humanmadeltd</a> o
103
 
104
  == Changelog ==
105
 
 
 
 
 
 
 
 
106
  #### 2.1.1
107
 
108
  * Fix a possible fatal error when a backup schedule is instantiated outside of wp-admin.
3
  Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade
4
  Requires at least: 3.3.3
5
  Tested up to: 3.5
6
+ Stable tag: 2.1.2
7
 
8
  Simple automated back ups of your WordPress powered website.
9
 
103
 
104
  == Changelog ==
105
 
106
+ #### 2.1.2
107
+
108
+ * Fix an issue that could stop the settings panel from closing on save on servers which return `'0'` for ajax requests.
109
+ * Fix an issue that could cause the backup root to be set to `/` on sites with `site_url` and `home` set to different domains.
110
+ * The mysqldump fallback function will now be used if `mysqldump` produces an empty file.
111
+ * Fix a possible PHP `NOTICE` on Apache servers.
112
+
113
  #### 2.1.1
114
 
115
  * Fix a possible fatal error when a backup schedule is instantiated outside of wp-admin.