Version Description
Download this release
Release Info
| Developer | willmot |
| Plugin | |
| Version | 1.6.2 |
| Comparing to | |
| See all releases | |
Code changes from version 1.6.1 to 1.6.2
- admin.actions.php +33 -12
- assets/hmbkp.js +5 -3
- functions/backup.functions.php +3 -0
- functions/core.functions.php +2 -24
- functions/interface.functions.php +17 -7
- hm-backup/hm-backup.php +38 -36
- plugin.php +2 -3
- readme.txt +15 -4
admin.actions.php
CHANGED
|
@@ -106,11 +106,12 @@ add_action( 'load-tools_page_' . HMBKP_PLUGIN_SLUG, 'hmbkp_option_save' );
|
|
| 106 |
function hmbkp_request_delete_backup() {
|
| 107 |
|
| 108 |
if ( ! isset( $_GET['hmbkp_delete'] ) || empty( $_GET['hmbkp_delete'] ) )
|
| 109 |
-
return
|
| 110 |
|
| 111 |
hmbkp_delete_backup( $_GET['hmbkp_delete'] );
|
| 112 |
|
| 113 |
wp_redirect( remove_query_arg( 'hmbkp_delete' ), 303 );
|
|
|
|
| 114 |
exit;
|
| 115 |
|
| 116 |
}
|
|
@@ -122,14 +123,13 @@ add_action( 'load-tools_page_' . HMBKP_PLUGIN_SLUG, 'hmbkp_request_delete_backup
|
|
| 122 |
*/
|
| 123 |
function hmbkp_request_do_backup() {
|
| 124 |
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
return false;
|
| 128 |
|
| 129 |
hmbkp_do_backup();
|
| 130 |
|
| 131 |
-
// Redirect back
|
| 132 |
wp_redirect( remove_query_arg( 'action' ), 303 );
|
|
|
|
| 133 |
exit;
|
| 134 |
|
| 135 |
}
|
|
@@ -142,12 +142,10 @@ function hmbkp_ajax_request_do_backup() {
|
|
| 142 |
|
| 143 |
ignore_user_abort( true );
|
| 144 |
|
| 145 |
-
// Are we sure
|
| 146 |
-
if ( hmbkp_is_in_progress() || ! hmbkp_possible() )
|
| 147 |
-
return false;
|
| 148 |
-
|
| 149 |
hmbkp_do_backup();
|
| 150 |
|
|
|
|
|
|
|
| 151 |
}
|
| 152 |
add_action( 'wp_ajax_hmbkp_backup', 'hmbkp_ajax_request_do_backup' );
|
| 153 |
|
|
@@ -158,7 +156,7 @@ add_action( 'wp_ajax_hmbkp_backup', 'hmbkp_ajax_request_do_backup' );
|
|
| 158 |
function hmbkp_request_download_backup() {
|
| 159 |
|
| 160 |
if ( empty( $_GET['hmbkp_download'] ) )
|
| 161 |
-
return
|
| 162 |
|
| 163 |
if ( file_exists( hmbkp_path() . '/.htaccess' ) )
|
| 164 |
unlink( hmbkp_path() . '/.htaccess' );
|
|
@@ -166,6 +164,7 @@ function hmbkp_request_download_backup() {
|
|
| 166 |
hmbkp_path();
|
| 167 |
|
| 168 |
wp_redirect( add_query_arg( 'key', md5( SECURE_AUTH_KEY ), str_replace( ABSPATH, site_url( '/' ), base64_decode( $_GET['hmbkp_download'] ) ) ), 303 );
|
|
|
|
| 169 |
exit;
|
| 170 |
|
| 171 |
}
|
|
@@ -174,15 +173,31 @@ add_action( 'load-tools_page_' . HMBKP_PLUGIN_SLUG, 'hmbkp_request_download_back
|
|
| 174 |
function hmbkp_request_cancel_backup() {
|
| 175 |
|
| 176 |
if ( ! isset( $_GET['action'] ) || $_GET['action'] !== 'hmbkp_cancel' )
|
| 177 |
-
return
|
| 178 |
-
|
| 179 |
hmbkp_cleanup();
|
| 180 |
|
| 181 |
wp_redirect( remove_query_arg( 'action' ), 303 );
|
| 182 |
|
|
|
|
|
|
|
| 183 |
}
|
| 184 |
add_action( 'load-tools_page_' . HMBKP_PLUGIN_SLUG, 'hmbkp_request_cancel_backup' );
|
| 185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
/**
|
| 187 |
* Display the running status via ajax
|
| 188 |
*
|
|
@@ -197,6 +212,7 @@ function hmbkp_ajax_is_backup_in_progress() {
|
|
| 197 |
include( HMBKP_PLUGIN_PATH . '/admin.backup-button.php' );
|
| 198 |
|
| 199 |
exit;
|
|
|
|
| 200 |
}
|
| 201 |
add_action( 'wp_ajax_hmbkp_is_in_progress', 'hmbkp_ajax_is_backup_in_progress' );
|
| 202 |
|
|
@@ -206,8 +222,11 @@ add_action( 'wp_ajax_hmbkp_is_in_progress', 'hmbkp_ajax_is_backup_in_progress' )
|
|
| 206 |
* @return void
|
| 207 |
*/
|
| 208 |
function hmbkp_ajax_calculate_backup_size() {
|
|
|
|
| 209 |
echo hmbkp_calculate();
|
|
|
|
| 210 |
exit;
|
|
|
|
| 211 |
}
|
| 212 |
add_action( 'wp_ajax_hmbkp_calculate', 'hmbkp_ajax_calculate_backup_size' );
|
| 213 |
|
|
@@ -222,10 +241,12 @@ function hmbkp_ajax_cron_test() {
|
|
| 222 |
|
| 223 |
if ( ! is_wp_error( $response ) && $response['response']['code'] != '200' )
|
| 224 |
echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress has detected a problem.', 'hmbkp' ) . '</strong> ' . sprintf( __( '%s is returning a %s response which could mean cron jobs aren\'t getting fired properly. BackUpWordPress relies on wp-cron to run scheduled back ups. See the %s for more details.', 'hmbkp' ), '<code>wp-cron.php</code>', '<code>' . $response['response']['code'] . '</code>', '<a href="http://wordpress.org/extend/plugins/backupwordpress/faq/">FAQ</a>' ) . '</p></div>';
|
|
|
|
| 225 |
else
|
| 226 |
echo 1;
|
| 227 |
|
| 228 |
exit;
|
|
|
|
| 229 |
}
|
| 230 |
add_action( 'wp_ajax_hmbkp_cron_test', 'hmbkp_ajax_cron_test' );
|
| 231 |
|
| 106 |
function hmbkp_request_delete_backup() {
|
| 107 |
|
| 108 |
if ( ! isset( $_GET['hmbkp_delete'] ) || empty( $_GET['hmbkp_delete'] ) )
|
| 109 |
+
return;
|
| 110 |
|
| 111 |
hmbkp_delete_backup( $_GET['hmbkp_delete'] );
|
| 112 |
|
| 113 |
wp_redirect( remove_query_arg( 'hmbkp_delete' ), 303 );
|
| 114 |
+
|
| 115 |
exit;
|
| 116 |
|
| 117 |
}
|
| 123 |
*/
|
| 124 |
function hmbkp_request_do_backup() {
|
| 125 |
|
| 126 |
+
if ( ! isset( $_GET['action'] ) || $_GET['action'] !== 'hmbkp_backup_now' )
|
| 127 |
+
return;
|
|
|
|
| 128 |
|
| 129 |
hmbkp_do_backup();
|
| 130 |
|
|
|
|
| 131 |
wp_redirect( remove_query_arg( 'action' ), 303 );
|
| 132 |
+
|
| 133 |
exit;
|
| 134 |
|
| 135 |
}
|
| 142 |
|
| 143 |
ignore_user_abort( true );
|
| 144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
hmbkp_do_backup();
|
| 146 |
|
| 147 |
+
exit;
|
| 148 |
+
|
| 149 |
}
|
| 150 |
add_action( 'wp_ajax_hmbkp_backup', 'hmbkp_ajax_request_do_backup' );
|
| 151 |
|
| 156 |
function hmbkp_request_download_backup() {
|
| 157 |
|
| 158 |
if ( empty( $_GET['hmbkp_download'] ) )
|
| 159 |
+
return;
|
| 160 |
|
| 161 |
if ( file_exists( hmbkp_path() . '/.htaccess' ) )
|
| 162 |
unlink( hmbkp_path() . '/.htaccess' );
|
| 164 |
hmbkp_path();
|
| 165 |
|
| 166 |
wp_redirect( add_query_arg( 'key', md5( SECURE_AUTH_KEY ), str_replace( ABSPATH, site_url( '/' ), base64_decode( $_GET['hmbkp_download'] ) ) ), 303 );
|
| 167 |
+
|
| 168 |
exit;
|
| 169 |
|
| 170 |
}
|
| 173 |
function hmbkp_request_cancel_backup() {
|
| 174 |
|
| 175 |
if ( ! isset( $_GET['action'] ) || $_GET['action'] !== 'hmbkp_cancel' )
|
| 176 |
+
return;
|
| 177 |
+
|
| 178 |
hmbkp_cleanup();
|
| 179 |
|
| 180 |
wp_redirect( remove_query_arg( 'action' ), 303 );
|
| 181 |
|
| 182 |
+
exit;
|
| 183 |
+
|
| 184 |
}
|
| 185 |
add_action( 'load-tools_page_' . HMBKP_PLUGIN_SLUG, 'hmbkp_request_cancel_backup' );
|
| 186 |
|
| 187 |
+
function hmbkp_dismiss_error() {
|
| 188 |
+
|
| 189 |
+
if ( empty( $_GET['action'] ) || $_GET['action'] !== 'hmbkp_dismiss_error' )
|
| 190 |
+
return;
|
| 191 |
+
|
| 192 |
+
hmbkp_cleanup();
|
| 193 |
+
|
| 194 |
+
wp_redirect( remove_query_arg( 'action' ), 303 );
|
| 195 |
+
|
| 196 |
+
exit;
|
| 197 |
+
|
| 198 |
+
}
|
| 199 |
+
add_action( 'admin_init', 'hmbkp_dismiss_error' );
|
| 200 |
+
|
| 201 |
/**
|
| 202 |
* Display the running status via ajax
|
| 203 |
*
|
| 212 |
include( HMBKP_PLUGIN_PATH . '/admin.backup-button.php' );
|
| 213 |
|
| 214 |
exit;
|
| 215 |
+
|
| 216 |
}
|
| 217 |
add_action( 'wp_ajax_hmbkp_is_in_progress', 'hmbkp_ajax_is_backup_in_progress' );
|
| 218 |
|
| 222 |
* @return void
|
| 223 |
*/
|
| 224 |
function hmbkp_ajax_calculate_backup_size() {
|
| 225 |
+
|
| 226 |
echo hmbkp_calculate();
|
| 227 |
+
|
| 228 |
exit;
|
| 229 |
+
|
| 230 |
}
|
| 231 |
add_action( 'wp_ajax_hmbkp_calculate', 'hmbkp_ajax_calculate_backup_size' );
|
| 232 |
|
| 241 |
|
| 242 |
if ( ! is_wp_error( $response ) && $response['response']['code'] != '200' )
|
| 243 |
echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress has detected a problem.', 'hmbkp' ) . '</strong> ' . sprintf( __( '%s is returning a %s response which could mean cron jobs aren\'t getting fired properly. BackUpWordPress relies on wp-cron to run scheduled back ups. See the %s for more details.', 'hmbkp' ), '<code>wp-cron.php</code>', '<code>' . $response['response']['code'] . '</code>', '<a href="http://wordpress.org/extend/plugins/backupwordpress/faq/">FAQ</a>' ) . '</p></div>';
|
| 244 |
+
|
| 245 |
else
|
| 246 |
echo 1;
|
| 247 |
|
| 248 |
exit;
|
| 249 |
+
|
| 250 |
}
|
| 251 |
add_action( 'wp_ajax_hmbkp_cron_test', 'hmbkp_ajax_cron_test' );
|
| 252 |
|
assets/hmbkp.js
CHANGED
|
@@ -26,13 +26,15 @@ jQuery( document ).ready( function( $ ) {
|
|
| 26 |
|
| 27 |
ajaxRequest = $.get( ajaxurl, { 'action' : 'hmbkp_backup' } );
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
|
| 31 |
ajaxRequest.abort();
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
e.preventDefault();
|
| 38 |
|
| 26 |
|
| 27 |
ajaxRequest = $.get( ajaxurl, { 'action' : 'hmbkp_backup' } );
|
| 28 |
|
| 29 |
+
$( this ).text( 'Starting Backup' ).addClass( 'hmbkp_running' );
|
| 30 |
+
|
| 31 |
+
setTimeout( function() {
|
| 32 |
|
| 33 |
ajaxRequest.abort();
|
| 34 |
|
| 35 |
+
hmbkpRedirectOnBackupComplete();
|
| 36 |
|
| 37 |
+
}, 500 );
|
| 38 |
|
| 39 |
e.preventDefault();
|
| 40 |
|
functions/backup.functions.php
CHANGED
|
@@ -129,6 +129,9 @@ function hmbkp_email_backup() {
|
|
| 129 |
return false;
|
| 130 |
|
| 131 |
$file = HM_Backup::get_instance()->archive_filepath();
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
// Raise the memory and time limit
|
| 134 |
@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
|
| 129 |
return false;
|
| 130 |
|
| 131 |
$file = HM_Backup::get_instance()->archive_filepath();
|
| 132 |
+
|
| 133 |
+
if ( ! file_exists( $file ) )
|
| 134 |
+
return;
|
| 135 |
|
| 136 |
// Raise the memory and time limit
|
| 137 |
@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
|
functions/core.functions.php
CHANGED
|
@@ -25,7 +25,6 @@ function hmbkp_deactivate() {
|
|
| 25 |
'hmbkp_zip_path',
|
| 26 |
'hmbkp_mysqldump_path',
|
| 27 |
'hmbkp_path',
|
| 28 |
-
'hmbkp_max_backups',
|
| 29 |
'hmbkp_running',
|
| 30 |
'hmbkp_status',
|
| 31 |
'hmbkp_complete',
|
|
@@ -35,12 +34,6 @@ function hmbkp_deactivate() {
|
|
| 35 |
foreach ( $options as $option )
|
| 36 |
delete_option( $option );
|
| 37 |
|
| 38 |
-
// If there is a backup running file we should delete it on activate.
|
| 39 |
-
$file = hmbkp_path() . '/.backup_running';
|
| 40 |
-
|
| 41 |
-
if ( file_exists( $file ) )
|
| 42 |
-
unlink( $file );
|
| 43 |
-
|
| 44 |
delete_transient( 'hmbkp_running' );
|
| 45 |
delete_transient( 'hmbkp_estimated_filesize' );
|
| 46 |
|
|
@@ -59,25 +52,10 @@ function hmbkp_deactivate() {
|
|
| 59 |
function hmbkp_update() {
|
| 60 |
|
| 61 |
// Every update
|
| 62 |
-
if ( version_compare( HMBKP_VERSION, get_option( 'hmbkp_plugin_version' ), '>' ) )
|
| 63 |
-
|
| 64 |
hmbkp_deactivate();
|
| 65 |
|
| 66 |
-
|
| 67 |
-
if ( is_dir( hmbkp_path() . '/logs' ) )
|
| 68 |
-
hmbkp_rmdirtree( hmbkp_path() . '/logs' );
|
| 69 |
-
|
| 70 |
-
endif;
|
| 71 |
-
|
| 72 |
-
// Pre 1.1
|
| 73 |
-
if ( ! get_option( 'hmbkp_plugin_version' ) ) :
|
| 74 |
-
|
| 75 |
-
// Delete the obsolete max backups option
|
| 76 |
-
delete_option( 'hmbkp_max_backups' );
|
| 77 |
-
|
| 78 |
-
endif;
|
| 79 |
-
|
| 80 |
-
// Update from backUpWordPress
|
| 81 |
if ( get_option( 'bkpwp_max_backups' ) ) :
|
| 82 |
|
| 83 |
// Carry over the custom path
|
| 25 |
'hmbkp_zip_path',
|
| 26 |
'hmbkp_mysqldump_path',
|
| 27 |
'hmbkp_path',
|
|
|
|
| 28 |
'hmbkp_running',
|
| 29 |
'hmbkp_status',
|
| 30 |
'hmbkp_complete',
|
| 34 |
foreach ( $options as $option )
|
| 35 |
delete_option( $option );
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
delete_transient( 'hmbkp_running' );
|
| 38 |
delete_transient( 'hmbkp_estimated_filesize' );
|
| 39 |
|
| 52 |
function hmbkp_update() {
|
| 53 |
|
| 54 |
// Every update
|
| 55 |
+
if ( version_compare( HMBKP_VERSION, get_option( 'hmbkp_plugin_version' ), '>' ) )
|
|
|
|
| 56 |
hmbkp_deactivate();
|
| 57 |
|
| 58 |
+
// Update from backUpWordPress 0.4.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
if ( get_option( 'bkpwp_max_backups' ) ) :
|
| 60 |
|
| 61 |
// Carry over the custom path
|
functions/interface.functions.php
CHANGED
|
@@ -153,20 +153,20 @@ function hmbkp_admin_notices() {
|
|
| 153 |
endif;
|
| 154 |
|
| 155 |
// If there are any errors reported in the backup
|
| 156 |
-
if (
|
| 157 |
|
| 158 |
function hmbkp_backup_errors_notice() {
|
| 159 |
-
echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress detected that your last backup failed.', 'hmbkp' ) . '</strong></p>' . hmbkp_backup_errors_message() . '</div>';
|
| 160 |
}
|
| 161 |
add_action( 'admin_notices', 'hmbkp_backup_errors_notice' );
|
| 162 |
|
| 163 |
endif;
|
| 164 |
|
| 165 |
// If there are any warnings reported in the backup
|
| 166 |
-
if (
|
| 167 |
|
| 168 |
function hmbkp_backup_warnings_notice() {
|
| 169 |
-
echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress detected an issue with your last backup.', 'hmbkp' ) . '</strong></p>' . hmbkp_backup_warnings_message() . '</div>';
|
| 170 |
}
|
| 171 |
add_action( 'admin_notices', 'hmbkp_backup_warnings_notice' );
|
| 172 |
|
|
@@ -196,7 +196,7 @@ function hmbkp_backup_errors_message() {
|
|
| 196 |
|
| 197 |
$message = '';
|
| 198 |
|
| 199 |
-
foreach ( json_decode( hmbkp_backup_errors() ) as $key => $errors )
|
| 200 |
foreach ( $errors as $error )
|
| 201 |
$message .= '<p><strong>' . $key . '</strong>: <code>' . implode( ':', (array) $error ) . '</code></p>';
|
| 202 |
|
|
@@ -208,9 +208,19 @@ function hmbkp_backup_warnings_message() {
|
|
| 208 |
|
| 209 |
$message = '';
|
| 210 |
|
| 211 |
-
foreach ( json_decode( hmbkp_backup_warnings() ) as $key => $errors )
|
| 212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
$message .= '<p><strong>' . $key . '</strong>: <code>' . implode( ':', (array) $error ) . '</code></p>';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
return $message;
|
| 216 |
|
| 153 |
endif;
|
| 154 |
|
| 155 |
// If there are any errors reported in the backup
|
| 156 |
+
if ( hmbkp_backup_errors_message() ) :
|
| 157 |
|
| 158 |
function hmbkp_backup_errors_notice() {
|
| 159 |
+
echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress detected that your last backup failed.', 'hmbkp' ) . '</strong><a href="' . add_query_arg( 'action', 'hmbkp_dismiss_error' ) . '" style="float: right;" class="button">Dismiss</a></p>' . hmbkp_backup_errors_message() . '</div>';
|
| 160 |
}
|
| 161 |
add_action( 'admin_notices', 'hmbkp_backup_errors_notice' );
|
| 162 |
|
| 163 |
endif;
|
| 164 |
|
| 165 |
// If there are any warnings reported in the backup
|
| 166 |
+
if ( hmbkp_backup_warnings_message() ) :
|
| 167 |
|
| 168 |
function hmbkp_backup_warnings_notice() {
|
| 169 |
+
echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress detected an issue with your last backup.', 'hmbkp' ) . '</strong><a href="' . add_query_arg( 'action', 'hmbkp_dismiss_error' ) . '" style="float: right;" class="button">Dismiss</a></p>' . hmbkp_backup_warnings_message() . '</div>';
|
| 170 |
}
|
| 171 |
add_action( 'admin_notices', 'hmbkp_backup_warnings_notice' );
|
| 172 |
|
| 196 |
|
| 197 |
$message = '';
|
| 198 |
|
| 199 |
+
foreach ( (array) json_decode( hmbkp_backup_errors() ) as $key => $errors )
|
| 200 |
foreach ( $errors as $error )
|
| 201 |
$message .= '<p><strong>' . $key . '</strong>: <code>' . implode( ':', (array) $error ) . '</code></p>';
|
| 202 |
|
| 208 |
|
| 209 |
$message = '';
|
| 210 |
|
| 211 |
+
foreach ( (array) json_decode( hmbkp_backup_warnings() ) as $key => $errors ) {
|
| 212 |
+
|
| 213 |
+
foreach ( $errors as $error ) {
|
| 214 |
+
|
| 215 |
+
// Don't show a warning message for php errors in files outside the backupwordpress plugin
|
| 216 |
+
if ( $key == 'php' && strpos( implode( ':', (array) $error ), HMBKP_PLUGIN_PATH ) === false )
|
| 217 |
+
continue;
|
| 218 |
+
|
| 219 |
$message .= '<p><strong>' . $key . '</strong>: <code>' . implode( ':', (array) $error ) . '</code></p>';
|
| 220 |
+
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
}
|
| 224 |
|
| 225 |
return $message;
|
| 226 |
|
hm-backup/hm-backup.php
CHANGED
|
@@ -195,7 +195,7 @@ class HM_Backup {
|
|
| 195 |
public function archive_filepath() {
|
| 196 |
return trailingslashit( $this->path() ) . $this->archive_filename();
|
| 197 |
}
|
| 198 |
-
|
| 199 |
/**
|
| 200 |
* The full filepath to the archive file.
|
| 201 |
*
|
|
@@ -203,7 +203,7 @@ class HM_Backup {
|
|
| 203 |
* @return string
|
| 204 |
*/
|
| 205 |
public function archive_filename() {
|
| 206 |
-
return sanitize_file_name( $this->archive_filename );
|
| 207 |
}
|
| 208 |
|
| 209 |
/**
|
|
@@ -215,9 +215,9 @@ class HM_Backup {
|
|
| 215 |
public function database_dump_filepath() {
|
| 216 |
return trailingslashit( $this->path() ) . $this->database_dump_filename();
|
| 217 |
}
|
| 218 |
-
|
| 219 |
public function database_dump_filename() {
|
| 220 |
-
return sanitize_file_name( $this->database_dump_filename );
|
| 221 |
}
|
| 222 |
|
| 223 |
public function root() {
|
|
@@ -402,15 +402,15 @@ class HM_Backup {
|
|
| 402 |
// Zip up $this->root with excludes
|
| 403 |
if ( ! $this->database_only && $this->exclude_string( 'zip' ) )
|
| 404 |
$this->error( 'zip', shell_exec( 'cd ' . escapeshellarg( $this->root() ) . ' && ' . escapeshellarg( $this->zip_command_path ) . ' -rq ' . escapeshellarg( $this->archive_filepath() ) . ' ./' . ' -x ' . $this->exclude_string( 'zip' ) . ' 2>&1' ) );
|
| 405 |
-
|
| 406 |
// Zip up $this->root without excludes
|
| 407 |
elseif ( ! $this->database_only )
|
| 408 |
$this->error( 'zip', shell_exec( 'cd ' . escapeshellarg( $this->root() ) . ' && ' . escapeshellarg( $this->zip_command_path ) . ' -rq ' . escapeshellarg( $this->archive_filepath() ) . ' ./' . ' 2>&1' ) );
|
| 409 |
-
|
| 410 |
// Add the database dump to the archive
|
| 411 |
if ( ! $this->files_only )
|
| 412 |
$this->error( 'zip', shell_exec( 'cd ' . escapeshellarg( $this->path() ) . ' && ' . escapeshellarg( $this->zip_command_path ) . ' -uq ' . escapeshellarg( $this->archive_filepath() ) . ' ' . escapeshellarg( $this->database_dump_filename() ) . ' 2>&1' ) );
|
| 413 |
-
|
| 414 |
$this->check_archive();
|
| 415 |
|
| 416 |
}
|
|
@@ -528,30 +528,32 @@ class HM_Backup {
|
|
| 528 |
$this->error( $this->archive_method(), $verify );
|
| 529 |
|
| 530 |
}
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
|
|
|
|
|
|
| 555 |
|
| 556 |
// If there are errors delete the backup file.
|
| 557 |
if ( $this->errors() && file_exists( $this->archive_filepath() ) )
|
|
@@ -772,7 +774,7 @@ class HM_Backup {
|
|
| 772 |
// Sanitize the excludes
|
| 773 |
$excludes = array_filter( array_unique( array_map( 'trim', (array) $this->excludes ) ) );
|
| 774 |
|
| 775 |
-
// If path is inside root, exclude it
|
| 776 |
if ( strpos( $this->path(), $this->root() ) !== false )
|
| 777 |
$excludes[] = trailingslashit( $this->path() );
|
| 778 |
|
|
@@ -827,7 +829,7 @@ class HM_Backup {
|
|
| 827 |
|
| 828 |
// Escape shell args for zip command
|
| 829 |
if ( $context == 'zip' )
|
| 830 |
-
$excludes = array_map( 'escapeshellarg', $excludes );
|
| 831 |
|
| 832 |
return implode( $separator, $excludes );
|
| 833 |
|
|
@@ -1195,10 +1197,10 @@ class HM_Backup {
|
|
| 1195 |
|
| 1196 |
if ( in_array( $type, array( E_STRICT, E_DEPRECATED ) ) || error_reporting() === 0 )
|
| 1197 |
return false;
|
| 1198 |
-
|
| 1199 |
$args = func_get_args();
|
| 1200 |
-
|
| 1201 |
-
$this->
|
| 1202 |
|
| 1203 |
return false;
|
| 1204 |
|
| 195 |
public function archive_filepath() {
|
| 196 |
return trailingslashit( $this->path() ) . $this->archive_filename();
|
| 197 |
}
|
| 198 |
+
|
| 199 |
/**
|
| 200 |
* The full filepath to the archive file.
|
| 201 |
*
|
| 203 |
* @return string
|
| 204 |
*/
|
| 205 |
public function archive_filename() {
|
| 206 |
+
return strtolower( sanitize_file_name( remove_accents( $this->archive_filename ) ) );
|
| 207 |
}
|
| 208 |
|
| 209 |
/**
|
| 215 |
public function database_dump_filepath() {
|
| 216 |
return trailingslashit( $this->path() ) . $this->database_dump_filename();
|
| 217 |
}
|
| 218 |
+
|
| 219 |
public function database_dump_filename() {
|
| 220 |
+
return strtolower( sanitize_file_name( remove_accents( $this->database_dump_filename ) ) );
|
| 221 |
}
|
| 222 |
|
| 223 |
public function root() {
|
| 402 |
// Zip up $this->root with excludes
|
| 403 |
if ( ! $this->database_only && $this->exclude_string( 'zip' ) )
|
| 404 |
$this->error( 'zip', shell_exec( 'cd ' . escapeshellarg( $this->root() ) . ' && ' . escapeshellarg( $this->zip_command_path ) . ' -rq ' . escapeshellarg( $this->archive_filepath() ) . ' ./' . ' -x ' . $this->exclude_string( 'zip' ) . ' 2>&1' ) );
|
| 405 |
+
|
| 406 |
// Zip up $this->root without excludes
|
| 407 |
elseif ( ! $this->database_only )
|
| 408 |
$this->error( 'zip', shell_exec( 'cd ' . escapeshellarg( $this->root() ) . ' && ' . escapeshellarg( $this->zip_command_path ) . ' -rq ' . escapeshellarg( $this->archive_filepath() ) . ' ./' . ' 2>&1' ) );
|
| 409 |
+
|
| 410 |
// Add the database dump to the archive
|
| 411 |
if ( ! $this->files_only )
|
| 412 |
$this->error( 'zip', shell_exec( 'cd ' . escapeshellarg( $this->path() ) . ' && ' . escapeshellarg( $this->zip_command_path ) . ' -uq ' . escapeshellarg( $this->archive_filepath() ) . ' ' . escapeshellarg( $this->database_dump_filename() ) . ' 2>&1' ) );
|
| 413 |
+
|
| 414 |
$this->check_archive();
|
| 415 |
|
| 416 |
}
|
| 528 |
$this->error( $this->archive_method(), $verify );
|
| 529 |
|
| 530 |
}
|
| 531 |
+
|
| 532 |
+
/* Comment out for now as causes memory issues on large sites */
|
| 533 |
+
|
| 534 |
+
//if ( ! $this->errors() ) {
|
| 535 |
+
//
|
| 536 |
+
// // If it's a file backup, get an array of all the files that should have been backed up
|
| 537 |
+
// if ( ! $this->database_only )
|
| 538 |
+
// $files = $this->files();
|
| 539 |
+
//
|
| 540 |
+
// // Check that the database was backed up
|
| 541 |
+
// if ( ! $this->files_only )
|
| 542 |
+
// $files[] = $this->database_dump_filename();
|
| 543 |
+
//
|
| 544 |
+
// $this->load_pclzip();
|
| 545 |
+
//
|
| 546 |
+
// $archive = new PclZip( $this->archive_filepath() );
|
| 547 |
+
// $filesystem = $archive->extract( PCLZIP_OPT_EXTRACT_AS_STRING );
|
| 548 |
+
//
|
| 549 |
+
// foreach( $filesystem as $file )
|
| 550 |
+
// $archive_files[] = untrailingslashit( $file['filename'] );
|
| 551 |
+
//
|
| 552 |
+
// // Check that the array of files that should have been backed up matches the array of files in the zip
|
| 553 |
+
// if ( $files !== $archive_files )
|
| 554 |
+
// $this->error( $this->archive_method(), __( 'Backup file doesn\'t contain the the following files: ', 'hmbkp' ) . implode( ', ', array_diff( $files, $archive_files ) ) );
|
| 555 |
+
//
|
| 556 |
+
//}
|
| 557 |
|
| 558 |
// If there are errors delete the backup file.
|
| 559 |
if ( $this->errors() && file_exists( $this->archive_filepath() ) )
|
| 774 |
// Sanitize the excludes
|
| 775 |
$excludes = array_filter( array_unique( array_map( 'trim', (array) $this->excludes ) ) );
|
| 776 |
|
| 777 |
+
// If path() is inside root(), exclude it
|
| 778 |
if ( strpos( $this->path(), $this->root() ) !== false )
|
| 779 |
$excludes[] = trailingslashit( $this->path() );
|
| 780 |
|
| 829 |
|
| 830 |
// Escape shell args for zip command
|
| 831 |
if ( $context == 'zip' )
|
| 832 |
+
$excludes = array_map( 'escapeshellarg', array_unique( $excludes ) );
|
| 833 |
|
| 834 |
return implode( $separator, $excludes );
|
| 835 |
|
| 1197 |
|
| 1198 |
if ( in_array( $type, array( E_STRICT, E_DEPRECATED ) ) || error_reporting() === 0 )
|
| 1199 |
return false;
|
| 1200 |
+
|
| 1201 |
$args = func_get_args();
|
| 1202 |
+
|
| 1203 |
+
$this->warning( 'php', array_splice( $args, 0, 4 ) );
|
| 1204 |
|
| 1205 |
return false;
|
| 1206 |
|
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 → Backups</strong>.
|
| 7 |
Author: Human Made Limited
|
| 8 |
-
Version: 1.6.
|
| 9 |
Author URI: http://hmn.md/
|
| 10 |
*/
|
| 11 |
|
|
@@ -73,8 +73,6 @@ function hmbkp_actions() {
|
|
| 73 |
if ( HMBKP_VERSION > get_option( 'hmbkp_plugin_version' ) )
|
| 74 |
hmbkp_update();
|
| 75 |
|
| 76 |
-
require_once( HMBKP_PLUGIN_PATH . '/admin.actions.php' );
|
| 77 |
-
|
| 78 |
// Load admin css and js
|
| 79 |
if ( isset( $_GET['page'] ) && $_GET['page'] == HMBKP_PLUGIN_SLUG ) {
|
| 80 |
wp_enqueue_script( 'hmbkp', HMBKP_PLUGIN_URL . '/assets/hmbkp.js' );
|
|
@@ -117,6 +115,7 @@ add_action( 'init', 'hmbkp_setup_hm_backup' );
|
|
| 117 |
|
| 118 |
// Load the admin menu
|
| 119 |
require_once( HMBKP_PLUGIN_PATH . '/admin.menus.php' );
|
|
|
|
| 120 |
|
| 121 |
// Load hm-backup
|
| 122 |
require_once( HMBKP_PLUGIN_PATH . '/hm-backup/hm-backup.php' );
|
| 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 → Backups</strong>.
|
| 7 |
Author: Human Made Limited
|
| 8 |
+
Version: 1.6.2
|
| 9 |
Author URI: http://hmn.md/
|
| 10 |
*/
|
| 11 |
|
| 73 |
if ( HMBKP_VERSION > get_option( 'hmbkp_plugin_version' ) )
|
| 74 |
hmbkp_update();
|
| 75 |
|
|
|
|
|
|
|
| 76 |
// Load admin css and js
|
| 77 |
if ( isset( $_GET['page'] ) && $_GET['page'] == HMBKP_PLUGIN_SLUG ) {
|
| 78 |
wp_enqueue_script( 'hmbkp', HMBKP_PLUGIN_URL . '/assets/hmbkp.js' );
|
| 115 |
|
| 116 |
// Load the admin menu
|
| 117 |
require_once( HMBKP_PLUGIN_PATH . '/admin.menus.php' );
|
| 118 |
+
require_once( HMBKP_PLUGIN_PATH . '/admin.actions.php' );
|
| 119 |
|
| 120 |
// Load hm-backup
|
| 121 |
require_once( HMBKP_PLUGIN_PATH . '/hm-backup/hm-backup.php' );
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: humanmade, joehoyle, mattheu, tcrsavage, willmot
|
|
| 3 |
Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade
|
| 4 |
Requires at least: 3.1
|
| 5 |
Tested up to: 3.3
|
| 6 |
-
Stable tag: 1.6.
|
| 7 |
|
| 8 |
Simple automated back ups of your WordPress powered website.
|
| 9 |
|
|
@@ -74,8 +74,7 @@ Some things you can test are.
|
|
| 74 |
* Are scheduled posts working? (They use wp-cron too).
|
| 75 |
* Are you hosted on Heart Internet? (wp-cron is known not to work with them).
|
| 76 |
* If you click manual backup does it work?
|
| 77 |
-
* Try adding `define( '
|
| 78 |
-
* Try adding `define( 'ALTERNATE_WP_CRON', true ); to your `wp-config.php`, do backups (manual and automatic) work?
|
| 79 |
* Is your site private (I.E. is it behind some kind of authentication, maintenance plugin, .htaccess) if so wp-cron won't work until you remove it, if you are and you temporarily remove the authentication, do backups start working?
|
| 80 |
|
| 81 |
If you have tried all these then feel free to contact support.
|
|
@@ -94,6 +93,18 @@ You can also tweet <a href="http://twitter.com/humanmadeltd">@humanmadeltd</a> o
|
|
| 94 |
|
| 95 |
== Changelog ==
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
#### 1.6.1
|
| 98 |
|
| 99 |
* Fix fatal error on PHP =< 5.3
|
|
@@ -162,7 +173,7 @@ You can also tweet <a href="http://twitter.com/humanmadeltd">@humanmadeltd</a> o
|
|
| 162 |
|
| 163 |
#### 1.3.1
|
| 164 |
|
| 165 |
-
* Check for PHP version. Deactivate plugin if running on PHP version 4.
|
| 166 |
|
| 167 |
#### 1.3
|
| 168 |
|
| 3 |
Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade
|
| 4 |
Requires at least: 3.1
|
| 5 |
Tested up to: 3.3
|
| 6 |
+
Stable tag: 1.6.2
|
| 7 |
|
| 8 |
Simple automated back ups of your WordPress powered website.
|
| 9 |
|
| 74 |
* Are scheduled posts working? (They use wp-cron too).
|
| 75 |
* Are you hosted on Heart Internet? (wp-cron is known not to work with them).
|
| 76 |
* If you click manual backup does it work?
|
| 77 |
+
* Try adding `define( 'ALTERNATE_WP_CRON', true ); to your `wp-config.php`, do automatic backups work?
|
|
|
|
| 78 |
* Is your site private (I.E. is it behind some kind of authentication, maintenance plugin, .htaccess) if so wp-cron won't work until you remove it, if you are and you temporarily remove the authentication, do backups start working?
|
| 79 |
|
| 80 |
If you have tried all these then feel free to contact support.
|
| 93 |
|
| 94 |
== Changelog ==
|
| 95 |
|
| 96 |
+
#### 1.6.2
|
| 97 |
+
|
| 98 |
+
* Track PHP errors as backup warnings not errors.
|
| 99 |
+
* Only show warning message for PHP errors in BackUpWordPress files.
|
| 100 |
+
* Ability to dismiss the error / warning messages.
|
| 101 |
+
* Disable use of PclZip for full archive checking for now as it causes memory issues on some large sites.
|
| 102 |
+
* Don't delete "number of backups" setting on update.
|
| 103 |
+
* Better handling of multibite characters in archive and database dump filenames.
|
| 104 |
+
* Mark backup as running and increase callback timeout to 500 when firing backup via ajax.
|
| 105 |
+
* Don't send backup email if backup failed.
|
| 106 |
+
* Filter out duplicate exclude rules.
|
| 107 |
+
|
| 108 |
#### 1.6.1
|
| 109 |
|
| 110 |
* Fix fatal error on PHP =< 5.3
|
| 173 |
|
| 174 |
#### 1.3.1
|
| 175 |
|
| 176 |
+
* Check for PHP version. Deactivate plugin if running on PHP version 4.
|
| 177 |
|
| 178 |
#### 1.3
|
| 179 |
|
