Changeset 876572
- Timestamp:
- 03/17/2014 01:13:32 PM (12 years ago)
- Location:
- backupwordpress/trunk
- Files:
-
- 20 edited
-
admin/actions.php (modified) (8 diffs)
-
admin/backups.php (modified) (1 diff)
-
admin/constants.php (modified) (1 diff)
-
admin/page.php (modified) (3 diffs)
-
admin/schedule-form.php (modified) (1 diff)
-
admin/schedule.php (modified) (1 diff)
-
admin/server-info.php (modified) (1 diff)
-
assets/hmbkp.css (modified) (4 diffs)
-
assets/hmbkp.js (modified) (23 diffs)
-
backupwordpress.php (modified) (2 diffs)
-
classes/class-email.php (modified) (4 diffs)
-
classes/class-requirements.php (modified) (1 diff)
-
classes/class-schedule.php (modified) (17 diffs)
-
classes/class-schedules.php (modified) (1 diff)
-
classes/wp-cli.php (modified) (2 diffs)
-
functions/core.php (modified) (6 diffs)
-
functions/interface.php (modified) (2 diffs)
-
hm-backup/hm-backup.php (modified) (4 diffs)
-
readme.txt (modified) (4 diffs)
-
uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
backupwordpress/trunk/admin/actions.php
r859574 r876572 15 15 16 16 if ( is_wp_error( $deleted ) ) 17 echo $deleted->get_error_message();17 wp_die( $deleted->get_error_message() ); 18 18 19 19 wp_safe_redirect( remove_query_arg( array( 'hmbkp_delete_backup', '_wpnonce' ) ), 303 ); … … 68 68 check_ajax_referer( 'hmbkp_nonce', 'nonce' ); 69 69 70 // Fixes an issue on servers which only allow a single session per client 70 // Fixes an issue on servers which only allow a single session per client 71 71 session_write_close(); 72 72 … … 159 159 unlink( trailingslashit( hmbkp_path() ) . $schedule->get_running_backup_filename() ); 160 160 161 if ( $schedule->get_schedule_running_path() && file_exists( $schedule->get_schedule_running_path() ) ) 162 unlink( $schedule->get_schedule_running_path() ); 163 161 164 hmbkp_cleanup(); 162 165 … … 251 254 if ( is_wp_error( $response ) ) { 252 255 253 echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress has detected a problem.', 'hmbkp' ) . '</strong> ' . sprintf( __( '%1$s is returning a %2$s response which could mean cron jobs aren\'t getting fired properly. BackUpWordPress relies on wp-cron to run scheduled back ups. See the %3$s for more details.', 'hmbkp' ), '<code>wp-cron.php</code>', '<code>' . $response->get_error_message() . '</code>', '<a href="http://wordpress.org/extend/plugins/backupwordpress/faq/">FAQ</a>' ) . '</p></div>';256 echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress has detected a problem.', 'hmbkp' ) . '</strong> ' . sprintf( __( '%1$s is returning a %2$s response which could mean cron jobs aren\'t getting fired properly. BackUpWordPress relies on wp-cron to run scheduled backups. See the %3$s for more details.', 'hmbkp' ), '<code>wp-cron.php</code>', '<code>' . $response->get_error_message() . '</code>', '<a href="http://wordpress.org/extend/plugins/backupwordpress/faq/">FAQ</a>' ) . '</p></div>'; 254 257 255 258 update_option( 'hmbkp_wp_cron_test_failed', true ); … … 257 260 } elseif ( wp_remote_retrieve_response_code( $response ) != 200 ) { 258 261 259 echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress has detected a problem.', 'hmbkp' ) . '</strong> ' . sprintf( __( '%1$s is returning a %2$s response which could mean cron jobs aren\'t getting fired properly. BackUpWordPress relies on wp-cron to run scheduled back ups. See the %3$s for more details.', 'hmbkp' ), '<code>wp-cron.php</code>', '<code>' . esc_html( wp_remote_retrieve_response_code( $response ) ) . ' ' . esc_html( get_status_header_desc( wp_remote_retrieve_response_code( $response ) ) ) . '</code>', '<a href="http://wordpress.org/extend/plugins/backupwordpress/faq/">FAQ</a>' ) . '</p></div>';262 echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress has detected a problem.', 'hmbkp' ) . '</strong> ' . sprintf( __( '%1$s is returning a %2$s response which could mean cron jobs aren\'t getting fired properly. BackUpWordPress relies on wp-cron to run scheduled backups. See the %3$s for more details.', 'hmbkp' ), '<code>wp-cron.php</code>', '<code>' . esc_html( wp_remote_retrieve_response_code( $response ) ) . ' ' . esc_html( get_status_header_desc( wp_remote_retrieve_response_code( $response ) ) ) . '</code>', '<a href="http://wordpress.org/extend/plugins/backupwordpress/faq/">FAQ</a>' ) . '</p></div>'; 260 263 261 264 update_option( 'hmbkp_wp_cron_test_failed', true ); … … 328 331 * Validate and either return errors or update the schedule 329 332 */ 330 function hm nkp_edit_schedule_submit() {333 function hmbkp_edit_schedule_submit() { 331 334 332 335 if ( empty( $_GET['hmbkp_schedule_id'] ) ) … … 337 340 $errors = array(); 338 341 339 340 if ( isset( $_GET[' hmbkp_schedule_type'] ) ) {341 342 $schedule_type = sanitize_text_field( $_GET['hmbkp_schedule_type'] );343 344 if ( ! trim( $schedule_type ) )345 $errors['hmbkp_schedule_type'] = __( 'Backup type cannot be empty', 'hmbkp' ); 346 347 elseif ( ! in_array( $schedule_type, array( 'complete', 'file', 'database' ) ) ) 348 $errors['hmbkp_schedule_type'] = __( 'Invalid backup type', 'hmbkp' );349 342 // called from an extension 343 if ( isset( $_GET['is_destination_form'] ) ) { 344 345 // Save the service options 346 foreach ( HMBKP_Services::get_services( $schedule ) as $service ) 347 $errors = array_merge( $errors, $service->save() ); 348 349 $schedule->save(); 350 351 if ( empty( $errors ) ) 352 wp_send_json_success(); 350 353 else 354 wp_send_json_error( $errors ); 355 356 } else { 357 358 $schedule_settings = array(); 359 360 if ( isset( $_GET['hmbkp_schedule_recurrence'] ) ) { 361 362 $hmbkp_schedule_recurrence = $_GET['hmbkp_schedule_recurrence']; 363 364 if ( isset( $_GET['hmbkp_schedule_type'] ) ) { 365 366 $schedule_type = sanitize_text_field( $_GET['hmbkp_schedule_type'] ); 367 368 if ( ! trim( $schedule_type ) ) 369 $errors['hmbkp_schedule_type'] = __( 'Backup type cannot be empty', 'hmbkp' ); 370 371 elseif ( ! in_array( $schedule_type, array( 'complete', 'file', 'database' ) ) ) 372 $errors['hmbkp_schedule_type'] = __( 'Invalid backup type', 'hmbkp' ); 373 374 else 375 $schedule_settings['schedule_type'] = $schedule_type; 376 377 } 378 379 if ( isset( $_GET['hmbkp_schedule_recurrence']['hmbkp_type'] ) ) { 380 $hmbkp_schedule_recurrence_type = sanitize_text_field( $_GET['hmbkp_schedule_recurrence']['hmbkp_type'] ); 381 382 if ( empty( $hmbkp_schedule_recurrence_type ) ) 383 $errors['hmbkp_schedule_recurrence']['hmbkp_type'] = __( 'Schedule cannot be empty', 'hmbkp' ); 384 385 elseif ( ! in_array( $hmbkp_schedule_recurrence_type, array_keys( hmbkp_get_cron_schedules() ) ) && $hmbkp_schedule_recurrence_type !== 'manually' ) 386 $errors['hmbkp_schedule_recurrence']['hmbkp_type'] = __( 'Invalid schedule', 'hmbkp' ); 387 388 } 389 390 if ( 'manually' !== $hmbkp_schedule_recurrence_type ) { 391 392 if ( isset( $_GET['hmbkp_schedule_recurrence']['hmbkp_schedule_start_day_of_week'] ) ) { 393 394 $hmbkp_schedule_time['day_of_week'] = sanitize_text_field( $_GET['hmbkp_schedule_recurrence']['hmbkp_schedule_start_day_of_week'] ); 395 396 if ( ! in_array( $hmbkp_schedule_time['day_of_week'], array( 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday' ) ) ) 397 $errors['hmbkp_schedule_start_day_of_week'] = __( 'Day of week must be an integer between 1 and 7', 'backupwordpress' ); 398 399 } 400 401 if ( isset( $_GET['hmbkp_schedule_recurrence']['hmbkp_schedule_start_day_of_month'] ) ) { 402 403 $hmbkp_schedule_time['day_of_month'] = absint( $_GET['hmbkp_schedule_recurrence']['hmbkp_schedule_start_day_of_month'] ); 404 405 $options = array( 406 'min_range' => 1, 407 'max_range' => 31 408 ); 409 410 if ( false === filter_var( $hmbkp_schedule_time['day_of_month'], FILTER_VALIDATE_INT, array( 'options' => $options ) ) ) 411 $errors['hmbkp_schedule_start_day_of_month'] = __( 'Day of month must be between 1 and 31', 'backupwordpress' ); 412 413 } 414 415 if ( isset( $_GET['hmbkp_schedule_recurrence']['hmbkp_schedule_start_hours'] ) ) { 416 417 $hmbkp_schedule_time['hours'] = absint( $_GET['hmbkp_schedule_recurrence']['hmbkp_schedule_start_hours'] ); 418 419 $options = array( 420 'min_range' => 1, 421 'max_range' => 23 422 ); 423 424 if ( false === filter_var( $hmbkp_schedule_time['hours'], FILTER_VALIDATE_INT, array( 'options' => $options ) ) ) 425 $errors['hmbkp_schedule_start_hours'] = __( 'Hours must be between 1 and 23', 'backupwordpress' ); 426 427 } 428 429 if ( isset( $_GET['hmbkp_schedule_recurrence']['hmbkp_schedule_start_minutes'] ) ) { 430 431 $hmbkp_schedule_time['minutes'] = absint( $_GET['hmbkp_schedule_recurrence']['hmbkp_schedule_start_minutes'] ); 432 433 $options = array( 434 'min_range' => 0, 435 'max_range' => 59 436 ); 437 438 if ( false === filter_var( $hmbkp_schedule_time['minutes'], FILTER_VALIDATE_INT, array( 'options' => $options ) ) ) 439 $errors['hmbkp_schedule_start_minutes'] = __( 'Minutes must be between 0 and 59', 'backupwordpress' ); 440 441 } 442 443 } 444 } 445 446 if ( isset( $_GET['hmbkp_schedule_max_backups'] ) ) { 447 448 $schedule_max_backups = sanitize_text_field( $_GET['hmbkp_schedule_max_backups'] ); 449 450 if ( empty( $schedule_max_backups ) ) 451 $errors['hmbkp_schedule_max_backups'] = __( 'Max backups can\'t be empty', 'hmbkp' ); 452 453 elseif ( ! is_numeric( $schedule_max_backups ) ) 454 $errors['hmbkp_schedule_max_backups'] = __( 'Max backups must be a number', 'hmbkp' ); 455 456 elseif ( ! ( $schedule_max_backups >= 1 ) ) 457 $errors['hmbkp_schedule_max_backups'] = __( 'Max backups must be greater than 0', 'hmbkp' ); 458 459 else 460 $schedule_settings['schedule_max_backups'] = absint( $schedule_max_backups ); 461 462 } 463 464 // Save the service options 465 foreach ( HMBKP_Services::get_services( $schedule ) as $service ) { 466 $errors = array_merge( $errors, $service->save() ); 467 } 468 469 if ( $errors ) { 470 wp_send_json_error( $errors ); 471 472 } else { 473 474 if ( isset( $hmbkp_schedule_time ) ) 475 $schedule->set_schedule_start_time( hmbkp_determine_start_time( $hmbkp_schedule_recurrence_type, $hmbkp_schedule_time ) ); 476 477 $schedule->set_reoccurrence( $hmbkp_schedule_recurrence_type ); 351 478 $schedule->set_type( $schedule_type ); 479 $schedule->set_max_backups( $schedule_settings['schedule_max_backups'] ); 480 481 $schedule->save(); 482 483 // Remove any old backups in-case max backups was reduced 484 $schedule->delete_old_backups(); 485 486 wp_send_json_success(); 487 488 } 352 489 353 490 } 354 491 355 if ( isset( $_GET['hmbkp_schedule_reoccurrence'] ) ) { 356 357 $schedule_reoccurrence = sanitize_text_field( $_GET['hmbkp_schedule_reoccurrence'] ); 358 359 if ( empty( $schedule_reoccurrence ) ) 360 $errors['hmbkp_schedule_reoccurrence'] = __( 'Schedule cannot be empty', 'hmbkp' ); 361 362 elseif ( ! in_array( $schedule_reoccurrence, array_keys( $schedule->get_cron_schedules() ) ) && $schedule_reoccurrence !== 'manually' ) 363 $errors['hmbkp_schedule_reoccurrence'] = __( 'Invalid schedule', 'hmbkp' ); 364 365 else 366 $schedule->set_reoccurrence( $schedule_reoccurrence ); 367 368 } 369 370 if ( isset( $_GET['hmbkp_schedule_max_backups'] ) ) { 371 372 $schedule_max_backups = sanitize_text_field( $_GET['hmbkp_schedule_max_backups'] ); 373 374 if ( empty( $schedule_max_backups ) ) 375 $errors['hmbkp_schedule_max_backups'] = __( 'Max backups can\'t be empty', 'hmbkp' ); 376 377 elseif ( ! is_numeric( $schedule_max_backups ) ) 378 $errors['hmbkp_schedule_max_backups'] = __( 'Max backups must be a number', 'hmbkp' ); 379 380 elseif ( ! ( $schedule_max_backups >= 1 ) ) 381 $errors['hmbkp_schedule_max_backups'] = __( 'Max backups must be greater than 0', 'hmbkp' ); 382 383 else 384 $schedule->set_max_backups( (int) $schedule_max_backups ); 385 386 // Remove any old backups in-case max backups was reduced 387 $schedule->delete_old_backups(); 388 389 } 390 391 // Save the service options 392 foreach ( HMBKP_Services::get_services( $schedule ) as $service ) 393 $errors = array_merge( $errors, $service->save() ); 394 395 $schedule->save(); 396 397 if ( $errors ) 398 echo json_encode( $errors ); 399 400 die; 401 402 } 403 add_action( 'wp_ajax_hmnkp_edit_schedule_submit', 'hmnkp_edit_schedule_submit' ); 492 die(); 493 494 } 495 add_action( 'wp_ajax_hmbkp_edit_schedule_submit', 'hmbkp_edit_schedule_submit' ); 404 496 405 497 /** … … 553 645 * @return void 554 646 */ 555 function hmbkp_load_enable_support () {647 function hmbkp_load_enable_support() { 556 648 557 649 check_ajax_referer( 'hmbkp_nonce', '_wpnonce' ); -
backupwordpress/trunk/admin/backups.php
r848987 r876572 38 38 <?php endforeach; ?> 39 39 40 <li><a class="colorbox" href="<?php esc_attr_e( esc_url( add_query_arg( array( 'action' => 'hmbkp_add_schedule_load' ), is_multisite() ? admin_url( 'admin-ajax.php' ) : network_admin_url( 'admin-ajax.php' ) ) ) ); ?>"> + <?php _e( 'add schedule', 'hmbkp' ); ?></a></li>40 <li><a class="colorbox" href="<?php esc_attr_e( esc_url( add_query_arg( array( 'action' => 'hmbkp_add_schedule_load' ), is_multisite() ? network_admin_url( 'admin-ajax.php' ) : admin_url( 'admin-ajax.php' ) ) ) ); ?>"> + <?php _e( 'add schedule', 'hmbkp' ); ?></a></li> 41 41 42 42 </ul> -
backupwordpress/trunk/admin/constants.php
r838473 r876572 1 1 <div id="hmbkp-constants"> 2 2 3 <p><?php printf( __( 'You can %1$s any of the following %2$s in your %3$s to control advanced settings. %4$s. Defined %5$s will be highlighted.', 'hmbkp' ), '<code>define</code>', '<code>' . __( 'Constants', 'hmbkp' ) . '</code>', '<code>wp-config.php</code>', '<a href="http://codex.wordpress.org/Editing_wp-config.php">' . __( 'The Codex can help', 'hmbkp' ) . '</a>', '<code>' . __( 'Constants', 'hmbkp' ) . '</code>' ); ?></p>3 <p><?php printf( __( 'You can %1$s any of the following %2$s in your %3$s to control advanced settings. %4$s. Defined %5$s will be highlighted.', 'hmbkp' ), '<code>define</code>', '<code>' . __( 'Constants', 'hmbkp' ) . '</code>', '<code>wp-config.php</code>', '<a href="http://codex.wordpress.org/Editing_wp-config.php">' . __( 'The Codex can help', 'hmbkp' ) . '</a>', '<code>' . __( 'Constants', 'hmbkp' ) . '</code>' ); ?></p> 4 4 5 <dl>5 <table class="widefat"> 6 6 7 <dt<?php if ( defined( 'HMBKP_PATH' ) ) { ?> class="hmbkp_active"<?php } ?>><code>HMBKP_PATH</code></dt> 8 <dd><p><?php printf( __( 'The path to folder you would like to store your backup files in, defaults to %s.', 'hmbkp' ), '<code>' . esc_html( hmbkp_path_default() ) . '</code>' ); ?></p><p class="example"><?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_PATH', '/home/willmot/backups' );</code></p></dd> 7 <tr<?php if ( defined( 'HMBKP_PATH' ) ) { ?> class="hmbkp_active"<?php } ?>> 9 8 10 <dt<?php if ( defined( 'HMBKP_MYSQLDUMP_PATH' ) ) { ?> class="hmbkp_active"<?php } ?>><code>HMBKP_MYSQLDUMP_PATH</code></dt> 11 <dd><p><?php printf( __( 'The path to your %1$s executable. Will be used for the %2$s part of the back up if available.', 'hmbkp' ), '<code>mysqldump</code>', '<code>' . __( 'database', 'hmbkp' ) . '</code>' ); ?></p><p class="example"><?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_MYSQLDUMP_PATH', '/opt/local/bin/mysqldump' );</code></p></dd> 9 <td><code>HMBKP_PATH</code></td> 12 10 13 <dt<?php if ( defined( 'HMBKP_ZIP_PATH' ) ) { ?> class="hmbkp_active"<?php } ?>><code>HMBKP_ZIP_PATH</code></dt> 14 <dd><p><?php printf( __( 'The path to your %1$s executable. Will be used to zip up your %2$s and %3$s if available.', 'hmbkp' ), '<code>zip</code>', '<code>' . __( 'files', 'hmbkp' ) . '</code>', '<code>' . __( 'database', 'hmbkp' ) . '</code>' ); ?><p class="example"><?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_ZIP_PATH', '/opt/local/bin/zip' );</code></p></dd> 11 <td> 15 12 16 <dt<?php if ( defined( 'HMBKP_EXCLUDE' ) ) { ?> class="hmbkp_active"<?php } ?>><code>HMBKP_EXCLUDE</code></dt> 17 <dd><p><?php _e( 'Comma separated list of files or directories to exclude, the backups directory is automatically excluded.', 'hmbkp' ); ?><p class="example"><?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_EXCLUDE', '/wp-content/uploads/, /stats/, .svn/, *.txt' );</code></p></dd> 13 <?php if ( defined( 'HMBKP_PATH' ) ) { ?> 14 <p><?php printf( __( 'You\'ve set it to: %s', 'hmbkp' ), '<code>' . HMBKP_PATH . '</code>' ); ?></p> 15 <?php } ?> 18 16 19 <dt<?php if ( defined( 'HMBKP_CAPABILITY' ) ) { ?> class="hmbkp_active"<?php } ?>><code>HMBKP_CAPABILITY</code></dt> 20 <dd><p><?php printf( __( 'The capability to use when calling %1$s. Defaults to %2$s.', 'hmbkp' ), '<code>add_menu_page</code>', '<code>manage_options</code>' ); ?><p class="example"><?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_CAPABILITY', 'edit_posts' );</code></p></dd> 17 <p><?php printf( __( 'The path to folder you would like to store your backup files in, defaults to %s.', 'hmbkp' ), '<code>' . esc_html( hmbkp_path_default() ) . '</code>' ); ?> <?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_PATH', '/home/willmot/backups' );</code></p> 21 18 22 <dt<?php if ( defined( 'HMBKP_ROOT' ) ) { ?> class="hmbkp_active"<?php } ?>><code>HMBKP_ROOT</code></dt> 23 <dd><p><?php printf( __( 'The root directory that is backed up. Defaults to %s.', 'hmbkp' ), '<code>' . HM_Backup::get_home_path() . '</code>' ); ?><p class="example"><?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_ROOT', ABSPATH . 'wp/' );</code></p></dd> 19 </td> 24 20 25 <dt<?php if ( defined( 'HMBKP_SCHEDULE_TIME' ) && HMBKP_SCHEDULE_TIME !== '11pm' ) { ?> class="hmbkp_active"<?php } ?>><code>HMBKP_SCHEDULE_TIME</code></dt> 26 <dd><p><?php printf( __( 'The time that your schedules should run. Defaults to %s.', 'hmbkp' ), '<code>23:00</code>' ); ?><p class="example"><?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_SCHEDULE_TIME', '07:30' );</code></p></dd> 21 </tr> 27 22 28 <?php 23 <tr<?php if ( defined( 'HMBKP_MYSQLDUMP_PATH' ) ) { ?> class="hmbkp_active"<?php } ?>> 29 24 30 foreach ( HMBKP_Services::get_services() as $file => $service ) 31 echo wp_kses_post( call_user_func( array( $service, 'constant' ) ) ); ?> 25 <td><code>HMBKP_MYSQLDUMP_PATH</code></td> 32 26 33 </dl> 27 <td> 28 29 <?php if ( defined( 'HMBKP_MYSQLDUMP_PATH' ) ) { ?> 30 <p><?php printf( __( 'You\'ve set it to: %s', 'hmbkp' ), '<code>' . HMBKP_MYSQLDUMP_PATH . '</code>' ); ?></p> 31 <?php } ?> 32 33 <p><?php printf( __( 'The path to your %1$s executable. Will be used for the %2$s part of the back up if available.', 'hmbkp' ), '<code>mysqldump</code>', '<code>' . __( 'database', 'hmbkp' ) . '</code>' ); ?> <?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_MYSQLDUMP_PATH', '/opt/local/bin/mysqldump' );</code></p> 34 35 </td> 36 37 </tr> 38 39 <tr<?php if ( defined( 'HMBKP_ZIP_PATH' ) ) { ?> class="hmbkp_active"<?php } ?>> 40 41 <td><code>HMBKP_ZIP_PATH</code></td> 42 43 <td> 44 45 <?php if ( defined( 'HMBKP_ZIP_PATH' ) ) { ?> 46 <p><?php printf( __( 'You\'ve set it to: %s', 'hmbkp' ), '<code>' . HMBKP_ZIP_PATH . '</code>' ); ?></p> 47 <?php } ?> 48 49 <p><?php printf( __( 'The path to your %1$s executable. Will be used to zip up your %2$s and %3$s if available.', 'hmbkp' ), '<code>zip</code>', '<code>' . __( 'files', 'hmbkp' ) . '</code>', '<code>' . __( 'database', 'hmbkp' ) . '</code>' ); ?> <?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_ZIP_PATH', '/opt/local/bin/zip' );</code></p> 50 51 </td> 52 53 </tr> 54 55 <tr<?php if ( defined( 'HMBKP_EXCLUDE' ) ) { ?> class="hmbkp_active"<?php } ?>> 56 57 <td><code>HMBKP_EXCLUDE</code></td> 58 59 <td> 60 61 <?php if ( defined( 'HMBKP_EXCLUDE' ) ) { ?> 62 <p><?php printf( __( 'You\'ve set it to: %s', 'hmbkp' ), '<code>' . HMBKP_EXCLUDE . '</code>' ); ?></p> 63 <?php } ?> 64 65 <p><?php _e( 'Comma separated list of files or directories to exclude, the backups directory is automatically excluded.', 'hmbkp' ); ?> <?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_EXCLUDE', '/wp-content/uploads/, /stats/, .svn/, *.txt' );</code></p> 66 67 </td> 68 69 </tr> 70 71 <tr<?php if ( defined( 'HMBKP_CAPABILITY' ) ) { ?> class="hmbkp_active"<?php } ?>> 72 73 <td><code>HMBKP_CAPABILITY</code></td> 74 75 <td> 76 77 <?php if ( defined( 'HMBKP_CAPABILITY' ) ) { ?> 78 <p><?php printf( __( 'You\'ve set it to: %s', 'hmbkp' ), '<code>' . HMBKP_CAPABILITY . '</code>' ); ?></p> 79 <?php } ?> 80 81 <p><?php printf( __( 'The capability to use when calling %1$s. Defaults to %2$s.', 'hmbkp' ), '<code>add_menu_page</code>', '<code>manage_options</code>' ); ?> <?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_CAPABILITY', 'edit_posts' );</code></p> 82 83 </td> 84 85 </tr> 86 87 <tr<?php if ( defined( 'HMBKP_ROOT' ) ) { ?> class="hmbkp_active"<?php } ?>> 88 89 <td><code>HMBKP_ROOT</code></td> 90 91 <td> 92 93 <?php if ( defined( 'HMBKP_ROOT' ) ) { ?> 94 <p><?php printf( __( 'You\'ve set it to: %s', 'hmbkp' ), '<code>' . HMBKP_ROOT . '</code>' ); ?></p> 95 <?php } ?> 96 97 <p><?php printf( __( 'The root directory that is backed up. Defaults to %s.', 'hmbkp' ), '<code>' . HM_Backup::get_home_path() . '</code>' ); ?> <?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_ROOT', ABSPATH . 'wp/' );</code></p> 98 99 </td> 100 101 </tr> 102 103 <tr<?php if ( defined( 'HMBKP_SCHEDULE_TIME' ) && HMBKP_SCHEDULE_TIME !== '11pm' ) { ?> class="hmbkp_active"<?php } ?>> 104 105 <td><code>HMBKP_SCHEDULE_TIME</code></td> 106 107 <td> 108 109 <?php if ( defined( 'HMBKP_SCHEDULE_TIME' ) && HMBKP_SCHEDULE_TIME !== '11pm' ) { ?> 110 <p><?php printf( __( 'You\'ve set it to: %s', 'hmbkp' ), '<code>' . HMBKP_SCHEDULE_TIME . '</code>' ); ?></p> 111 <?php } ?> 112 113 <p><?php printf( __( 'The time that your schedules should run. Defaults to %s.', 'hmbkp' ), '<code>23:00</code>' ); ?> <?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_SCHEDULE_TIME', '07:30' );</code></p> 114 115 </td> 116 117 </tr> 118 119 <?php foreach ( HMBKP_Services::get_services() as $file => $service ) 120 echo wp_kses_post( call_user_func( array( $service, 'constant' ) ) ); ?> 121 122 </table> 34 123 35 124 </div> -
backupwordpress/trunk/admin/page.php
r859574 r876572 1 1 <div class="wrap"> 2 3 <?php screen_icon( HMBKP_PLUGIN_SLUG ); ?>4 2 5 3 <h2> … … 12 10 <?php } else { ?> 13 11 14 <a id="intercom-info" class="colorbox add-new-h2" href="<?php echo wp_nonce_url( add_query_arg( array( 'action' => 'load_enable_support' ), is_multisite() ? admin_url( 'admin-ajax.php' ) : network_admin_url( 'admin-ajax.php' ) ), 'hmbkp_nonce' ); ?>"> Enable Support</a>12 <a id="intercom-info" class="colorbox add-new-h2" href="<?php echo wp_nonce_url( add_query_arg( array( 'action' => 'load_enable_support' ), is_multisite() ? admin_url( 'admin-ajax.php' ) : network_admin_url( 'admin-ajax.php' ) ), 'hmbkp_nonce' ); ?>"><?php _e( 'Enable Support', 'hmbkp' ); ?></a> 15 13 16 14 <?php } ?> … … 23 21 <?php include_once( HMBKP_PLUGIN_PATH . '/admin/backups.php' ); ?> 24 22 25 <?php else : ?>26 27 <p><strong><?php _e( 'You need to fix the issues detailed above before BackUpWordPress can start.', 'hmbkp' ); ?></strong></p>28 29 <?php endif; ?>30 31 23 <p class="howto"><?php printf( __( 'If you\'re finding BackUpWordPress useful, please %1$s rate it on the plugin directory. %2$s', 'hmbkp' ), '<a href="http://wordpress.org/support/view/plugin-reviews/backupwordpress">', '</a>' ); ?></p> 32 24 33 25 <p class="howto"><?php _e( 'If you need help getting things working then check the FAQ by clicking on help in the top right hand corner of this page.', 'hmbkp' ); ?></p> 34 26 35 <p class="howto"><strong><?php printf( __( 'Wish you could store your backups in a safer place? Our %1$spremium extensions%2$s enable automatic backups to Dropbox, FTP, Google Drive and more.', 'hmbkp' ), '<a href="http://bwp.hmn.md/?utm_source=wordpress-org&utm_medium=wp-admin&utm_campaign=freeplugin">', '</a>' ); ?></strong></p> 27 <p class="howto"><strong><?php printf( __( 'Wish you could store your backups in a safer place? Our %1$spremium extensions%2$s enable automatic backups to Dropbox, FTP, Google Drive and more.', 'hmbkp' ), '<a href="https://bwp.hmn.md/?utm_source=wordpress-org&utm_medium=wp-admin&utm_campaign=freeplugin">', '</a>' ); ?></strong></p> 28 29 <?php endif; ?> 36 30 37 31 </div> -
backupwordpress/trunk/admin/schedule-form.php
r838473 r876572 7 7 <legend><?php _e( 'Schedule Settings', 'hmbkp' ); ?></legend> 8 8 9 <label>9 <div> 10 10 11 <?php _e( 'Backup', 'hmbkp' ); ?>11 <label for="hmbkp_schedule_type"><?php _e( 'Backup', 'hmbkp' ); ?></label> 12 12 13 <select name="hmbkp_schedule_type" id="hmbkp_schedule_type"> 14 <option<?php selected( $schedule->get_type(), 'complete' ); ?> value="complete"><?php _e( 'Both Database & files', 'hmbkp' ); ?></option> 15 <option<?php selected( $schedule->get_type(), 'file' ); ?> value="file"><?php _e( 'Files only', 'hmbkp' ); ?></option> 16 <option<?php selected( $schedule->get_type(), 'database' ); ?> value="database"><?php _e( 'Database only', 'hmbkp' ); ?></option> 17 </select> 13 <select name="hmbkp_schedule_type" id="hmbkp_schedule_type"> 18 14 19 </label>15 <option<?php selected( $schedule->get_type(), 'complete' ); ?> value="complete"><?php _e( 'Both Database & files', 'hmbkp' ); ?></option> 20 16 21 <label>17 <option<?php selected( $schedule->get_type(), 'file' ); ?> value="file"><?php _e( 'Files only', 'hmbkp' ); ?></option> 22 18 23 <?php _e( 'Schedule', 'hmbkp' ); ?>19 <option<?php selected( $schedule->get_type(), 'database' ); ?> value="database"><?php _e( 'Database only', 'hmbkp' ); ?></option> 24 20 25 <select name="hmbkp_schedule_reoccurrence" id="hmbkp_schedule_reoccurrence">21 </select> 26 22 27 <option value="manually"><?php _e( 'Manual Only', 'hmbkp' ); ?></option>23 </div> 28 24 29 <?php foreach ( $schedule->get_cron_schedules() as $cron_schedule => $cron_details ) : ?>25 <div> 30 26 31 <option <?php selected( $schedule->get_reoccurrence(), $cron_schedule ); ?> value="<?php echo esc_attr( $cron_schedule ); ?>">27 <label for="hmbkp_schedule_recurrence_type"><?php _e( 'Schedule', 'hmbkp' ); ?></label> 32 28 33 <?php esc_html_e( $cron_details['display'], 'hmbkp' ); ?>29 <select name="hmbkp_schedule_recurrence[hmbkp_type]" id="hmbkp_schedule_recurrence_type"> 34 30 35 </option>31 <option value="manually"><?php _e( 'Manual Only', 'hmbkp' ); ?></option> 36 32 37 <?php endforeach;?>33 <?php foreach ( $schedule->get_cron_schedules() as $cron_schedule => $cron_details ) : ?> 38 34 39 </select>35 <option <?php selected( $schedule->get_reoccurrence(), $cron_schedule ); ?> value="<?php echo esc_attr( $cron_schedule ); ?>"> 40 36 41 </label>37 <?php esc_html_e( $cron_details['display'], 'hmbkp' ); ?> 42 38 43 <label>39 </option> 44 40 45 <?php _e( 'Number of backups to store on this server', 'hmbkp' ); ?>41 <?php endforeach; ?> 46 42 47 <input type="number" name="hmbkp_schedule_max_backups" min="1" step="1" value="<?php echo esc_attr( $schedule->get_max_backups() ); ?>" />43 </select> 48 44 49 <p class="description"><?php printf( __( 'Past this limit older backups will be deleted automatically. This schedule will store a maximum of %s of backups', 'hmbkp' ), '<code>' . size_format( $schedule->get_filesize() * $schedule->get_max_backups() ) . '</code>' ); ?></p>45 </div> 50 46 51 </label> 47 <?php if ( ! $start_time = $schedule->get_schedule_start_time() ) 48 $start_time = time(); ?> 52 49 53 <?php 50 <div id="start-day" class="recurring-setting"> 54 51 55 foreach ( HMBKP_Services::get_services( $schedule ) as $service ) 56 $service->field(); 52 <label for="hmbkp_schedule_start_day_of_week"><?php _e( 'Start Day', 'hmbkp' ); ?></label> 57 53 58 ?>54 <select id="hmbkp_schedule_start_day_of_week" name="hmbkp_schedule_recurrence[hmbkp_schedule_start_day_of_week]"> 59 55 60 <p class="submit"> 56 <?php $weekdays = array( 57 'monday' => __( 'Monday', 'hmbkp' ), 58 'tuesday' => __( 'Tuesday', 'hmbkp' ), 59 'wednesday' => __( 'Wednesday', 'hmbkp' ), 60 'thursday' => __( 'Thursday', 'hmbkp' ), 61 'friday' => __( 'Friday', 'hmbkp' ), 62 'saturday' => __( 'Saturday', 'hmbkp' ), 63 'sunday' => __( 'Sunday', 'hmbkp' ) 64 ); 61 65 62 <button type="submit" class="button-primary"><?php _e( 'Update', 'hmbkp' ); ?></button> 66 foreach ( $weekdays as $key => $day ) : ?> 67 68 <option value="<?php echo esc_attr( $key ) ?>" <?php selected( strtolower( date( 'l', $start_time ) ), $key ); ?>><?php echo esc_html( $day ); ?></option> 69 70 <?php endforeach; ?> 71 72 </select> 73 74 </div> 75 76 <div id="start-date" class="recurring-setting"> 77 78 <label for="hmbkp_schedule_start_day_of_month"><?php _e( 'Start Day of Month', 'hmbkp' ); ?></label> 79 80 <input type="number" min="0" max="31" step="1" id="hmbkp_schedule_start_day_of_month" name="hmbkp_schedule_recurrence[hmbkp_schedule_start_day_of_month]" value="<?php echo esc_attr( date( 'j', $start_time ) ); ?>"> 81 82 </div> 83 84 <div id="schedule-start" class="recurring-setting"> 85 86 <label for="hmbkp_schedule_start_hours"><?php _e( 'Start time', 'hmbkp' ); ?></label> 87 88 <span class="field-group"> 89 90 <label for="hmbkp_schedule_start_hours"><input type="number" min="0" max="23" step="1" name="hmbkp_schedule_recurrence[hmbkp_schedule_start_hours]" id="hmbkp_schedule_start_hours" value="<?php echo esc_attr( date( 'G', $start_time ) ); ?>"> 91 92 <?php _e( 'Hours', 'hmbkp' ); ?></label> 93 94 <label for="hmbkp_schedule_start_minutes"><input type="number" min="0" max="59" step="1" name="hmbkp_schedule_recurrence[hmbkp_schedule_start_minutes]" id="hmbkp_schedule_start_minutes" value="<?php echo esc_attr( (float) date( 'i', $start_time ) ); ?>"> 95 96 <?php _e( 'Minutes', 'hmbkp' ); ?></label> 97 98 </span> 99 100 <p class="twice-js description"><?php _e( 'The second backup will run 12 hours after the first', 'hmbkp' ); ?></p> 101 102 </div> 103 104 <div> 105 106 <label for="hmbkp_schedule_max_backups"><?php _e( 'Number of backups to store on this server', 'hmbkp' ); ?></label> 107 108 <input type="number" id="hmbkp_schedule_max_backups" name="hmbkp_schedule_max_backups" min="1" step="1" value="<?php echo esc_attr( $schedule->get_max_backups() ); ?>" /> 109 110 <p class="description"> 111 112 <?php printf( __( 'Past this limit older backups will be deleted automatically.', 'hmbkp' ) ); ?> 113 114 <?php if ( $schedule->is_filesize_cached() ) { 115 printf( __( 'This schedule will store a maximum of %s of backups', 'hmbkp' ), '<code>' . size_format( $schedule->get_filesize() * $schedule->get_max_backups() ) . '</code>' ); 116 } ?> 117 118 </p> 119 120 </div> 121 122 <?php foreach ( HMBKP_Services::get_services( $schedule ) as $service ) 123 $service->field(); ?> 124 125 <p class="submit"> 126 127 <button type="submit" class="button-primary"><?php _e( 'Update', 'hmbkp' ); ?></button> 63 128 64 129 </p> -
backupwordpress/trunk/admin/schedule.php
r838473 r876572 16 16 17 17 case 'hmbkp_hourly' : 18 19 $reoccurrence = date_i18n( 'i', $schedule->get_next_occurrence( false ) ) === '00' ? '<span ' . $next_backup . '>' . __( 'hourly on the hour', 'hmbkp' ) . '</span>' : sprintf( __( 'hourly at %s minutes past the hour', 'hmbkp' ), '<span ' . $next_backup . '>' . str_replace( '0', '', date_i18n( 'i', $schedule->get_next_occurrence( false ) ) ) ) . '</span>'; 18 $reoccurrence = date_i18n( 'i', $schedule->get_next_occurrence( false ) ) === '00' ? '<span ' . $next_backup . '>' . __( 'hourly on the hour', 'hmbkp' ) . '</span>' : sprintf( __( 'hourly at %s minutes past the hour', 'hmbkp' ), '<span ' . $next_backup . '>' . intval( date_i18n( 'i', $schedule->get_next_occurrence( false ) ) ) ) . '</span>'; 20 19 21 20 break; -
backupwordpress/trunk/admin/server-info.php
r859574 r876572 9 9 <?php foreach ( HMBKP_Requirements::get_requirements( $group ) as $requirement ) : ?> 10 10 11 <?php if ( ( is_string( $requirement->raw_result() ) && strlen( $requirement->result() ) < 20 ) || is_bool( $requirement->raw_result() ) ) { ?> 12 11 13 <tr> 12 <td><?php echo $requirement->name(); ?></td> 13 <td><pre><?php echo $requirement->result(); ?></pre></td> 14 15 <td><?php echo esc_html( $requirement->name() ); ?></td> 16 17 <td> 18 <code><?php echo esc_html( $requirement->result() ); ?></code> 19 </td> 20 14 21 </tr> 22 23 <?php } else { ?> 24 25 <tr> 26 27 <td colspan="2"> 28 <?php echo esc_html( $requirement->name() ); ?> 29 <pre><?php echo esc_html( $requirement->result() ); ?></pre> 30 </td> 31 32 </tr> 33 34 <?php } ?> 15 35 16 36 <?php endforeach; ?> -
backupwordpress/trunk/assets/hmbkp.css
r859574 r876572 1 1 #icon-backupwordpress.icon32 { background: url(icon_backupwordpress_32x32.png); } 2 2 3 tfoot p { margin: 0; font-weight: normal; } 4 #hmbkp-constants dl { overflow: hidden; margin: 20px 0; } 5 #hmbkp-constants dt { float: left; min-width: 250px; clear: both; padding: 6px; margin: 1px 0; cursor: pointer; } 6 #hmbkp-constants dd { color: #666; padding: 7px 0 7px 250px; border-top: 1px solid #DFDFDF; margin: 0; cursor: pointer; min-height: 40px; } 7 #hmbkp-constants dd:last-child { border-bottom: 1px solid #DFDFDF; } 8 #hmbkp-constants dt:not(.hmbkp_active) + dd { background: #F9F9F9; } 9 #hmbkp-constants dd .example { white-space: nowrap; display: none; } 10 #hmbkp-constants dd p { margin: 0; } 11 #hmbkp-constants dt:not(.hmbkp_active):hover + dd, #hmbkp-constants dt:not(.hmbkp_active) + dd:hover { background-color: #FFF; } 12 #hmbkp-constants dd:hover p, #hmbkp-constants dt:hover + dd p { display: none; } 13 #hmbkp-constants dd:hover .example, #hmbkp-constants dt:hover + dd .example { display: inline; } 3 tfoot p { margin: 0; font-weight: normal; }#hmbkp-constants dl { overflow: hidden; margin: 20px 0; } 14 4 15 5 .completed th, .completed td { background-color: #FFFFE0; } 16 .hmbkp_active :before { content: "\00a0 \2713"; font-size: 11px; }17 .hmbkp_active , .hmbkp_active code, #hmbkp-constants .hmbkp_active + dd{ background: #E5F7E8; }6 .hmbkp_active td:first-child > code:before { content: "\00a0 \2713 "; font-size: 11px; } 7 .hmbkp_active { background: #E5F7E8; } 18 8 .contextual-help-tabs-wrap .updated { margin: 15px 0 0; } 19 9 … … 25 15 .hmbkp_schedule { clear: both; overflow: hidden; } 26 16 27 28 17 #cboxLoadedContent { margin-bottom: 0; } 29 18 19 .hmbkp-form { overflow: hidden; } 30 20 .hmbkp-form fieldset { float: left; } 31 21 .js .hmbkp-form fieldset + fieldset { display: none; margin-right: -100%; } 22 form.hmbkp-form div.recurring-setting { display: none; } 32 23 33 .hmbkp-form label{ display: block; line-height: 25px; padding-bottom: 20px; border-bottom: 1px dotted #CCC; margin-bottom: 20px; width: 320px; position: relative; }24 form.hmbkp-form div { display: block; line-height: 25px; padding-bottom: 20px; border-bottom: 1px dotted #CCC; margin-bottom: 20px; width: 320px; position: relative; } 34 25 35 26 .hmbkp-form legend { padding: 0 0 20px; font-size: 1.17em; font-weight: bold; } 36 .hmbkp-form label > *{ float: right; }27 .hmbkp-form div > select, .hmbkp-form div > input, .hmbkp-form div > span.field-group, .button-right { float: right; } 37 28 .hmbkp-form label.hidden { display: none; } 38 .hmbkp-form label > input[type="text"], .hmbkp-form label > select, .hmbkp-form label> input[type="password"] { min-width: 200px; }39 .hmbkp-form label> input[type="checkbox"] { margin-top: 6px; }40 .hmbkp-form label.description { line-height: 16px; margin-top: 10px; float: none; }41 .hmbkp-form p.submit { margin: 0; padding:0; }29 .hmbkp-form div > input[type="text"], .hmbkp-form div > select, .hmbkp-form div > input[type="password"] { min-width: 200px; } 30 .hmbkp-form div > input[type="checkbox"] { margin-top: 6px; } 31 .hmbkp-form div .description { line-height: 16px; margin-top: 10px; float: none; } 32 .hmbkp-form p.submit { margin: 20px 0 0; padding: 0; } 42 33 .hmbkp-form .button-primary { float: right; } 43 34 .hmbkp-form [type="number"] { min-width: 50px; width: 50px; } 44 .hmbkp-error span { position: absolute; top: -14px; right: 1px; color: #FFF; background-color: red; white-space: nowrap; line-height: 16px; font-size: 11px; padding: 0 3px; border-radius: 3px 3px 0 0; }35 .hmbkp-error span, span.hmbkp-error { position: absolute; top: -14px; right: 1px; color: #FFF; background-color: red; white-space: nowrap; line-height: 16px; font-size: 11px; padding: 0 3px; border-radius: 3px 3px 0 0; } 45 36 .hmbkp-error input[type], .hmbkp-error select { border-color: red; border-top-right-radius: 0; } 46 .hmbkp-edit-schedule-excludes-form .code{word-break: break-word;}47 37 48 38 .hmbkp-form ul { width: 320px; overflow: hidden; } 49 .hmbkp-form ul.hmbkp_file_list { background-color: #FFF; display: block; border-radius: 4px; box-sizing: border-box; clear: both; box-shadow: inset 0px 0px 2px #CCC; font-size: 11px; }39 .hmbkp-form ul.hmbkp_file_list { background-color: #FFF; max-height: 200px; overflow-y: scroll; display: block; border-radius: 4px; box-sizing: border-box; clear: both; box-shadow: inset 0px 0px 2px #CCC; font-size: 11px; } 50 40 .hmbkp_file_list li { margin: 0; padding: 5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 16px; } 51 41 .hmbkp_file_list li + li { border-top: 1px dotted #CCC; } … … 66 56 .hmbkp-schedule-actions { font-size: 12px; font-weight: normal; margin: 0 0 0 26px; } 67 57 68 .hmbkp-ajax-loading, button.hmbkp-ajax-loading { padding-left: 20px; }69 .hmbkp-ajax-loading: before {width: 16px;height: 16px; margin-right: 10px; content: ""; background: transparent url('spinner-2x.gif') no-repeat 0 0; background-size: 16px 16px; vertical-align: middle; display: inline-block; }58 .hmbkp-ajax-loading, button.hmbkp-ajax-loading { padding-left: 20px; position: relative; } 59 .hmbkp-ajax-loading::before { content: ""; width: 16px; height: 16px; background-image: url('spinner-2x.gif'); background-size: 16px 16px; background-repeat: no-repeat; background-position: 0 0; position: absolute; left: -30px; top: 5px; } 70 60 71 61 button { height: 14px; } … … 83 73 .hmbkp-exclude-preview-open table, .hmbkp-exclude-preview-open .hmbkp-tabs, .hmbkp-exclude-preview-open p.submit { display: none; } 84 74 .hmbkp-exclude-preview-open .hmbkp_add_exclude_rule { margin: 0; } 85 .ui-tabs-panel { clear: both;} 75 .hmbkp-tabs > div { display: none; } 76 .ui-tabs-panel { clear: both; } 86 77 .ui-tabs-panel form { padding-top: 10px; } 87 78 88 table.widefat tbody t d { padding: 8px 7px;}79 table.widefat tbody tr:nth-child(odd) { background-color: #f9f9f9 } 89 80 .hmbkp-edit-schedule-excludes-form td a, .hmbkp-edit-schedule-excludes-form td span.reason { float: right; } 81 .hmbkp-edit-schedule-excludes-form td span.code { float: left; width: 255px; } 90 82 .hmbkp-edit-schedule-excludes-form td span.reason { color: #CCC; } 91 83 input[type="datetime-local"] { border-radius: 3px; border-width: 1px; border-style: solid; box-sizing: border-box; border-color: #DFDFDF; background-color: white; } -
backupwordpress/trunk/assets/hmbkp.js
r852089 r876572 6 6 // Remove the loading class when ajax requests complete 7 7 $( document ).ajaxComplete( function() { 8 $( '.hmbkp-ajax-loading' ).removeClass( 'hmbkp-ajax-loading' ) ;8 $( '.hmbkp-ajax-loading' ).removeClass( 'hmbkp-ajax-loading' ).removeAttr( 'disabled' ); 9 9 } ); 10 10 … … 19 19 if ( ! $( '.subsubsub a.current' ).size() ) 20 20 $( '.subsubsub li:first a').addClass( 'current' ); 21 22 // Carries the same resize options we want23 // to use to all other .resize()24 var resize_options = {25 height: '85%'26 };27 21 28 22 // Initialize colorbox … … 31 25 'initialHeight' : '100px', 32 26 'transition' : 'elastic', 33 'scrolling' : true,34 'innerWidth' : "320px",35 'maxHeight' : resize_options.height, //85% Takes into account the WP Admin bar.27 'scrolling' : false, 28 'innerWidth' : '320px', 29 'maxHeight' : '85%', // 85% Takes into account the WP Admin bar. 36 30 'escKey' : false, 37 31 'overlayClose' : false, … … 43 37 $( '.hmbkp-tabs' ).tabs(); 44 38 45 if ( $( ".hmbkp-form p.submit:contains('" + hmbkp.update + "')" ).size() ) 39 if ( $( ".hmbkp-form p.submit:contains('" + hmbkp.update + "')" ).size() ) { 46 40 $( '<button type="button" class="button-secondary hmbkp-colorbox-close">' + hmbkp.cancel + '</button>' ).appendTo( '.hmbkp-form p.submit' ); 41 } 42 43 44 $( '.recurring-setting' ).hide(); 45 46 hmbkpToggleScheduleFields( $('select#hmbkp_schedule_recurrence_type').val() ); 47 48 $( document ).on( 'change', 'select#hmbkp_schedule_recurrence_type', function() { 49 hmbkpToggleScheduleFields( $( this ).val() ); 50 } ); 51 52 $.colorbox.resize(); 53 47 54 } 48 55 … … 51 58 // Resize the colorbox when switching tabs 52 59 $( document).on( 'click', '.ui-tabs-anchor', function( e ) { 53 $.colorbox.resize( resize_options);60 $.colorbox.resize(); 54 61 } ); 55 62 … … 87 94 } 88 95 89 $( this ).addClass( 'hmbkp-ajax-loading' ) ;96 $( this ).addClass( 'hmbkp-ajax-loading' ).attr( 'disabled', 'disabled' ); 90 97 91 98 $.post( … … 105 112 $( '.hmbkp-edit-schedule-excludes-form' ).addClass( 'hmbkp-exclude-preview-open' ); 106 113 107 $.colorbox.resize( resize_options);114 $.colorbox.resize(); 108 115 109 116 } … … 137 144 $( '.hmbkp-edit-schedule-excludes-form' ).removeClass( 'hmbkp-exclude-preview-open' ); 138 145 146 $.colorbox.resize(); 147 139 148 } ); 140 149 … … 142 151 $( document ).on( 'click', '.hmbkp_save_exclude_rule', function() { 143 152 144 $( this ).addClass( 'hmbkp-ajax-loading' ) ;153 $( this ).addClass( 'hmbkp-ajax-loading' ).attr( 'disabled', 'disabled' ); 145 154 146 155 $.post( … … 151 160 $( '.hmbkp-edit-schedule-excludes-form' ).show(); 152 161 $( '.hmbkp-tabs' ).tabs(); 153 $.colorbox.resize( resize_options);162 $.colorbox.resize(); 154 163 } 155 164 ); … … 160 169 $( document ).on( 'click', '.hmbkp-edit-schedule-excludes-form td a', function( e ) { 161 170 162 $( this ).addClass( 'hmbkp-ajax-loading' ).text( '' ) ;163 164 $.colorbox.resize( resize_options);171 $( this ).addClass( 'hmbkp-ajax-loading' ).text( '' ).attr( 'disabled', 'disabled' ); 172 173 $.colorbox.resize( resize_options ); 165 174 166 175 e.preventDefault(); … … 173 182 $( '.hmbkp-edit-schedule-excludes-form' ).show(); 174 183 $( '.hmbkp-tabs' ).tabs(); 175 $.colorbox.resize( resize_options);184 $.colorbox.resize(); 176 185 } 177 186 ); … … 184 193 var $isDestinationSettingsForm = $( this ).find( 'button[type="submit"]' ).hasClass( "dest-settings-save" ); 185 194 186 isNewSchedule = $( this ).closest( 'form' ).attr( 'data-schedule-action' ) == 'add' ? true : false;187 scheduleId = $( this ).closest( 'form' ).find( '[name="hmbkp_schedule_id"]' ).val();195 var isNewSchedule = $( this ).closest( 'form' ).attr( 'data-schedule-action' ) == 'add' ? true : false; 196 var scheduleId = $( this ).closest( 'form' ).find( '[name="hmbkp_schedule_id"]' ).val(); 188 197 189 198 // Only continue if we have a schedule id … … 195 204 return false; 196 205 197 $( this ).find( 'button[type="submit"]' ).addClass( 'hmbkp-ajax-loading' ) ;206 $( this ).find( 'button[type="submit"]' ).addClass( 'hmbkp-ajax-loading' ).attr( 'disabled', 'disabled' ); 198 207 199 208 $( '.hmbkp-error span' ).remove(); … … 204 213 $.get( 205 214 ajaxurl + '?' + $( this ).serialize(), 206 { 'action' : 'hmnkp_edit_schedule_submit' }, 207 function( data ) { 208 209 // Assume success if no data passed back 210 if ( ( ! data || data == 0 ) && ( $isDestinationSettingsForm === false ) ) { 215 { 'action' : 'hmbkp_edit_schedule_submit' }, 216 function( data ) { 217 218 if ( ( data.success === true ) && ( $isDestinationSettingsForm === false ) ) { 211 219 212 220 $.colorbox.close(); … … 219 227 location.reload(); 220 228 221 } else if( ! data || data == 0) {229 } else if( data.success === true ) { 222 230 // nothing for now 223 231 } else { 224 232 225 233 // Get the errors json string 226 var errors = JSON.parse( data );234 var errors = data.data; 227 235 228 236 // Loop through the errors 229 237 $.each( errors, function( key, value ) { 230 238 239 var selector = key.replace(/(:|\.|\[|\])/g,'\\$1'); 240 231 241 // Focus the first field that errored 232 242 if ( typeof( hmbkp_focused ) == 'undefined' ) { 233 243 234 $( ' [name="' + key + '"]').focus();244 $( '#' + selector ).focus(); 235 245 236 246 hmbkp_focused = true; … … 239 249 240 250 // Add an error class to all fields with errors 241 $( '[name="' + key + '"]' ).closest( 'label' ).addClass( 'hmbkp-error' ); 251 $( 'label[for=' + selector + ']' ).addClass( 'hmbkp-error' ); 252 253 $( '#' + selector ).next( 'span' ).remove(); 242 254 243 255 // Add the error message 244 $( '[name="' + key + '"]' ).after( '<span>' + value + '</span>' ); 256 $( '#' + selector ).after( '<span class="hmbkp-error">' + value + '</span>' ); 257 245 258 246 259 } ); … … 286 299 hmbkpRedirectOnBackupComplete( $( '[data-hmbkp-schedule-id]' ).attr( 'data-hmbkp-schedule-id' ), true ); 287 300 301 // Run a backup 288 302 $( document ).on( 'click', '.hmbkp-run', function( e ) { 289 303 … … 299 313 ).done( function( data ) { 300 314 301 catchResponseAndOfferToEmail( data );315 hmbkpCatchResponseAndOfferToEmail( data ); 302 316 303 317 // Redirect back on error 304 318 } ).fail( function( jqXHR, textStatus ) { 305 319 306 catchResponseAndOfferToEmail( jqXHR.responseText );320 hmbkpCatchResponseAndOfferToEmail( jqXHR.responseText ); 307 321 308 322 } ); … … 318 332 } ); 319 333 320 function catchResponseAndOfferToEmail( data ) { 321 322 // Carries the same resize options we want 323 // to use to all other .resize() 324 var resize_options = { 325 height: '85%' 326 }; 334 function hmbkpToggleScheduleFields( recurrence ){ 335 336 recurrence = typeof recurrence !== 'undefined' ? recurrence : 'manually'; 337 338 var settingFields = jQuery( '.recurring-setting'); 339 var scheduleSettingFields = jQuery( '#schedule-start'); 340 var twiceDailyNote = jQuery( 'p.twice-js' ); 341 342 switch( recurrence ) { 343 344 case 'manually': 345 settingFields.hide(); 346 break; 347 348 case 'hmbkp_hourly' : // fall through 349 case 'hmbkp_daily' : 350 settingFields.hide(); 351 scheduleSettingFields.show(); 352 twiceDailyNote.hide(); 353 break; 354 355 case 'hmbkp_twicedaily' : 356 settingFields.hide(); 357 scheduleSettingFields.show(); 358 twiceDailyNote.show(); 359 break; 360 361 case 'hmbkp_weekly' : // fall through 362 case 'hmbkp_fortnightly' : 363 settingFields.hide(); 364 jQuery( '#start-day' ).show(); 365 scheduleSettingFields.show(); 366 twiceDailyNote.hide(); 367 break; 368 369 case 'hmbkp_monthly' : 370 settingFields.hide(); 371 scheduleSettingFields.show(); 372 jQuery( '#start-date' ).show(); 373 twiceDailyNote.hide(); 374 break; 375 376 } 377 378 jQuery.colorbox.resize(); 379 380 } 381 382 function hmbkpCatchResponseAndOfferToEmail( data ) { 327 383 328 384 // Backup Succeeded … … 345 401 jQuery.colorbox( { 346 402 'innerWidth' : "320px", 347 'maxHeight' : " 85%",403 'maxHeight' : "100%", 348 404 'html' : data, 349 405 'overlayClose' : false, … … 351 407 'onLoad' : function() { 352 408 jQuery( '#cboxClose' ).remove(); 353 jQuery.colorbox.resize( resize_options);409 jQuery.colorbox.resize(); 354 410 } 355 411 } ); … … 364 420 e.preventDefault(); 365 421 366 jQuery( this ).addClass( 'hmbkp-ajax-loading' ) ;422 jQuery( this ).addClass( 'hmbkp-ajax-loading' ).attr( 'disabled', 'disabled' ); 367 423 368 424 jQuery.post( -
backupwordpress/trunk/backupwordpress.php
r859574 r876572 6 6 Description: Simple automated backups of your WordPress powered website. Once activated you'll find me under <strong>Tools → Backups</strong>. 7 7 Author: Human Made Limited 8 Version: 2. 58 Version: 2.6 9 9 Author URI: http://hmn.md/ 10 10 */ … … 62 62 if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) 63 63 define( 'WP_MAX_MEMORY_LIMIT', '256M' ); 64 65 if ( ! defined( 'HMBKP_SCHEDULE_TIME' ) )66 define( 'HMBKP_SCHEDULE_TIME', '11pm' );67 64 68 65 if ( ! defined( 'HMBKP_ADMIN_PAGE' ) ) { -
backupwordpress/trunk/classes/class-email.php
r859574 r876572 27 27 public function field() { ?> 28 28 29 <label>30 31 <?php _e( 'Email notification', 'hmbkp' ); ?>32 33 <input type="email" name="<?php echo esc_attr( $this->get_field_name( 'email' ) ); ?>" value="<?php echo esc_attr( $this->get_field_value( 'email' ) ); ?>" />34 35 <p class="description"><?php printf( __( 'Receive a notification email when a backup completes, if the backup is small enough (< %s) then it will be attached to the email. Separate multiple email address\'s with a comma.', 'hmbkp' ), '<code>' . size_format( hmbkp_get_max_attachment_size() ) . '</code>' ); ?></p>36 37 </label>29 <div> 30 31 <label for="<?php echo esc_attr( $this->get_field_name( 'email' ) ); ?>"><?php _e( 'Email notification', 'hmbkp' ); ?></label> 32 33 <input type="email" id="<?php echo esc_attr( $this->get_field_name( 'email' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'email' ) ); ?>" value="<?php echo esc_attr( $this->get_field_value( 'email' ) ); ?>" /> 34 35 <p class="description"><?php printf( __( 'Receive a notification email when a backup completes, if the backup is small enough (< %s) then it will be attached to the email. Separate multiple email address\'s with a comma.', 'hmbkp' ), '<code>' . size_format( hmbkp_get_max_attachment_size() ) . '</code>' ); ?></p> 36 37 </div> 38 38 39 39 <?php } … … 51 51 public static function constant() { ?> 52 52 53 <dt<?php if ( defined( 'HMBKP_ATTACHMENT_MAX_FILESIZE' ) ) { ?> class="hmbkp_active"<?php } ?>><code>HMBKP_ATTACHMENT_MAX_FILESIZE</code></dt> 54 <dd><p><?php printf( __( 'The maximum filesize of your backup that will be attached to your notification emails . Defaults to %s.', 'hmbkp' ), '<code>10MB</code>' ); ?><p class="example"><?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_ATTACHMENT_MAX_FILESIZE', '25MB' );</code></p></dd> 53 <tr<?php if ( defined( 'HMBKP_ATTACHMENT_MAX_FILESIZE' ) ) { ?> class="hmbkp_active"<?php } ?>> 54 55 <td><code>HMBKP_ATTACHMENT_MAX_FILESIZE</code></td> 56 57 <td> 58 59 <?php if ( defined( 'HMBKP_ATTACHMENT_MAX_FILESIZE' ) ) { ?> 60 <p><?php printf( __( 'You\'ve set it to: %s', 'hmbkp' ), '<code>' . HMBKP_ATTACHMENT_MAX_FILESIZE . '</code>' ); ?></p> 61 <?php } ?> 62 63 <p><?php printf( __( 'The maximum filesize of your backup that will be attached to your notification emails . Defaults to %s.', 'hmbkp' ), '<code>10MB</code>' ); ?> <?php _e( 'e.g.', 'hmbkp' ); ?> <code>define( 'HMBKP_ATTACHMENT_MAX_FILESIZE', '25MB' );</code></p> 64 65 </td> 66 67 </tr> 55 68 56 69 <?php } … … 74 87 75 88 } 76 89 77 90 /** 78 91 * Used to determine if the service is in use or not … … 95 108 if ( isset( $new_data['email'] ) ) { 96 109 97 if ( ! empty( $new_data['email'] ) ) 98 foreach ( explode( ',', $new_data['email'] ) as $email ) 99 if ( ! is_email( $email ) ) 110 if ( ! empty( $new_data['email'] ) ) { 111 112 foreach ( explode( ',', $new_data['email'] ) as $email ) { 113 114 $email = trim( $email ); 115 116 if ( ! is_email( $email ) ) { 100 117 $errors['email'] = sprintf( __( '%s isn\'t a valid email', 'hmbkp' ), $email ); 101 102 if ( ! empty( $errors['email'] ) ) 103 $new_data['email'] = ''; 118 } 119 120 if ( ! empty( $errors['email'] ) ) { 121 $new_data['email'] = ''; 122 } 123 124 } 125 126 } 127 128 return $errors; 104 129 105 130 } 106 107 return $errors;108 131 109 132 } -
backupwordpress/trunk/classes/class-requirements.php
r859574 r876572 564 564 protected function test() { 565 565 566 $backup_sizes = array(); 567 566 568 $schedules = HMBKP_Schedules::get_instance(); 567 569 -
backupwordpress/trunk/classes/class-schedule.php
r848987 r876572 33 33 34 34 /** 35 * The schedule start time36 *37 * (default value: current_time( 'timestamp' ))38 *39 * @var mixed40 * @access private41 */42 private $schedule_start_time = 0;43 44 /**45 35 * Setup the schedule object 46 36 * Loads the options from the database and populates properties … … 86 76 $this->set_zip_command_path( false ); 87 77 78 if ( defined( 'HMBKP_SCHEDULE_START_TIME' ) && strtotime( 'HMBKP_SCHEDULE_START_TIME' ) ) 79 $this->set_schedule_start_time( strtotime( 'HMBKP_SCHEDULE_START_TIME' ) ); 80 88 81 // Set the path - TODO remove external function dependancy 89 82 $this->set_path( hmbkp_path() ); 90 91 $hmbkp_schedules = $this->get_cron_schedules();92 83 93 84 // Set the archive filename to site name + schedule slug + date … … 96 87 97 88 // Setup the schedule if it isn't set 98 if ( ( ! $this-> get_next_occurrence() && in_array( $this->get_reoccurrence(), array_keys( $hmbkp_schedules ) ) ) || ( date( get_option( 'time_format' ), strtotime( HMBKP_SCHEDULE_TIME ) - ( get_option( 'gmt_offset' ) * 3600 ) ) !== date( get_option( 'time_format' ), $this->get_next_occurrence() ) ) )89 if ( ( ! $this->is_cron_scheduled() && $this->get_reoccurrence() !== 'manually' ) ) { 99 90 $this->schedule(); 91 } 100 92 101 93 } … … 133 125 public function get_name() { 134 126 135 $re occurence = ( 'manually' === $this->get_reoccurrence() ) ? $this->get_reoccurrence() : substr( $this->get_reoccurrence(), 6 );136 137 return ucwords( $this->get_type() ) . ' ' . $re occurence;127 $recurrence = ( 'manually' === $this->get_reoccurrence() ) ? $this->get_reoccurrence() : substr( $this->get_reoccurrence(), 6 ); 128 129 return ucwords( $this->get_type() ) . ' ' . $recurrence; 138 130 139 131 } … … 235 227 236 228 if ( empty( $max ) || ! is_int( $max ) ) 237 return new WP_Error( 'hmbkp_invalid_type_error', sprintf( __( 'Argument 1 for %s must be a valid integer', 'hmbkp' ) ), __METHOD__);229 return new WP_Error( 'hmbkp_invalid_type_error', sprintf( __( 'Argument 1 for %s must be a valid integer', 'hmbkp' ), __METHOD__ ) ); 238 230 239 231 $this->options['max_backups'] = $max; … … 427 419 return 0; 428 420 429 if ( empty( $this->schedule_start_time ) ) { 430 431 if ( defined( 'HMBKP_SCHEDULE_TIME' ) && HMBKP_SCHEDULE_TIME ) 432 $date = strtotime( HMBKP_SCHEDULE_TIME ); 433 434 else 435 $date = strtotime( '11pm' ); 436 437 // Convert to UTC 438 $date -= get_option( 'gmt_offset' ) * 3600; 439 440 // if the scheduled time already passed today then start at the next interval instead 441 if ( $date <= strtotime( 'now' ) ) 442 $date += $this->get_interval(); 443 444 $this->set_schedule_start_time( $date ); 445 } 446 447 return $this->schedule_start_time; 421 if ( ! empty( $this->options['schedule_start_time'] ) ) 422 return $this->options['schedule_start_time']; 423 424 $this->set_schedule_start_time( time() ); 425 426 return time(); 448 427 449 428 } … … 452 431 * Set the schedule start time. 453 432 * 454 * @access public 455 * @param int $timestamp in UTC 456 * @return void 457 */ 458 public function set_schedule_start_time( $timestamp ) { 459 $this->schedule_start_time = $timestamp; 433 * @param array $args 434 */ 435 public function set_schedule_start_time( $time ) { 436 437 // Don't allow setting the start time in the past 438 if ( (int) $time <= time() ) { 439 return new WP_Error( 'hmbkp_invalid_argument_error', sprintf( __( 'Argument 1 for %s must be a valid future timestamp', 'hmbkp' ), __METHOD__ ) ); 440 } 441 442 $this->options['schedule_start_time'] = $time; 443 444 $this->schedule(); 445 460 446 } 461 447 … … 468 454 469 455 // Default to no reoccurrence 470 if ( empty( $this->options['reoccurrence'] ) ) 456 if ( empty( $this->options['reoccurrence'] ) ) { 471 457 $this->set_reoccurrence( 'manually' ); 458 } 472 459 473 460 return $this->options['reoccurrence']; … … 487 474 // Check it's valid 488 475 if ( ! is_string( $reoccurrence ) || ! trim( $reoccurrence ) || ( ! in_array( $reoccurrence, array_keys( $hmbkp_schedules ) ) ) && $reoccurrence !== 'manually' ) 489 return new WP_Error( 'hmbkp_invalid_argument_error', sprintf( __( 'Argument 1 for %s must be a valid cron reoccurrence or "manually"', 'hmbkp' ) ), __METHOD__ ); 490 491 if ( isset( $this->options['reoccurrence'] ) && $this->options['reoccurrence'] === $reoccurrence ) 476 return new WP_Error( 'hmbkp_invalid_argument_error', sprintf( __( 'Argument 1 for %s must be a valid cron reoccurrence or "manually"', 'hmbkp' ), __METHOD__ ) ); 477 478 // If the recurrence is already set to the same thing then there's no need to continue 479 if ( isset( $this->options['reoccurrence'] ) && $this->options['reoccurrence'] === $reoccurrence && $this->is_cron_scheduled() ) 492 480 return; 493 481 494 482 $this->options['reoccurrence'] = $reoccurrence; 495 483 496 if ( $reoccurrence === 'manually' ) 484 if ( $reoccurrence === 'manually' ) { 497 485 $this->unschedule(); 498 499 else 486 } 487 488 else { 500 489 $this->schedule(); 490 } 501 491 502 492 return true; 493 503 494 } 504 495 … … 525 516 * @return array 526 517 */ 527 public function get_cron_schedules() {518 public static function get_cron_schedules() { 528 519 529 520 $schedules = wp_get_schedules(); … … 557 548 } 558 549 550 public function is_cron_scheduled() { 551 return (bool) $this->get_next_occurrence(); 552 } 553 559 554 560 555 /** 561 556 * Get the path to the backup running file that stores the running backup status 562 557 * 563 * @access p rivate558 * @access public 564 559 * @return string 565 560 */ 566 p rivatefunction get_schedule_running_path() {561 public function get_schedule_running_path() { 567 562 return $this->get_path() . '/.schedule-' . $this->get_id() . '-running'; 568 563 } … … 578 573 $this->unschedule(); 579 574 580 wp_schedule_event( $this->get_schedule_start_time(), $this->get_reoccurrence(), 'hmbkp_schedule_hook', array( 'id' => $this->get_id() ) ); 575 $schedule_timestamp = $this->get_schedule_start_time(); 576 577 wp_schedule_event( $schedule_timestamp, $this->get_reoccurrence(), 'hmbkp_schedule_hook', array( 'id' => $this->get_id() ) ); 581 578 582 579 } … … 622 619 623 620 /** 624 * Get the status of the running backup.621 * Get the filename that the running status is stored in. 625 622 * 626 623 * @access public 627 624 * @return string 628 625 */ 629 public function get_ status() {626 public function get_running_backup_filename() { 630 627 631 628 if ( ! file_exists( $this->get_schedule_running_path() ) ) 632 629 return ''; 633 630 634 $status = explode( '::', file_get_contents( $this->get_schedule_running_path() ) ); 635 636 return end( $status ); 637 638 } 639 640 /** 641 * Get the filename that the running status is stored in. 631 $status = json_decode( file_get_contents( $this->get_schedule_running_path() ) ); 632 633 if ( ! empty( $status->filename ) ) 634 return $status->filename; 635 636 return ''; 637 638 } 639 640 /** 641 * Get the status of the running backup. 642 642 * 643 643 * @access public 644 644 * @return string 645 645 */ 646 public function get_ running_backup_filename() {646 public function get_status() { 647 647 648 648 if ( ! file_exists( $this->get_schedule_running_path() ) ) 649 649 return ''; 650 650 651 $backup_running_file = explode( '::', file_get_contents( $this->get_schedule_running_path() ) ); 652 653 return reset( $backup_running_file ); 651 $status = json_decode( file_get_contents( $this->get_schedule_running_path() ) ); 652 653 if ( ! empty( $status->status ) ) 654 return $status->status; 655 656 return ''; 657 654 658 } 655 659 … … 666 670 return; 667 671 668 fwrite( $handle, $this->get_archive_filename() . '::' . $message ); 672 $status = json_encode( (object) array( 673 'filename' => $this->get_archive_filename(), 674 'started' => $this->get_schedule_running_start_time(), 675 'status' => $message 676 ) ); 677 678 fwrite( $handle, $status ); 669 679 670 680 fclose( $handle ); 681 682 } 683 684 /** 685 * Set the time that the current running backup was started 686 * 687 * @access public 688 * @return int $timestamp 689 */ 690 public function get_schedule_running_start_time() { 691 692 if ( ! file_exists( $this->get_schedule_running_path() ) ) 693 return 0; 694 695 $status = json_decode( file_get_contents( $this->get_schedule_running_path() ) ); 696 697 if ( ! empty( $status->started ) && (int) (string) $status->started === $status->started ) 698 return $status->started; 699 700 return time(); 671 701 672 702 } … … 677 707 */ 678 708 protected function do_action( $action ) { 679 680 switch ( $action ) :681 682 case 'hmbkp_mysqldump_started' :683 684 $this->set_status( sprintf( __( 'Dumping Database %s', 'hmbkp' ), '(<code>' . $this->get_mysqldump_method() . '</code>)' ) );685 break;686 687 case 'hmbkp_mysqldump_verify_started' :688 689 $this->set_status( sprintf( __( 'Verifying Database Dump %s', 'hmbkp' ), '(<code>' . $this->get_mysqldump_method() . '</code>)' ) );690 break;691 692 case 'hmbkp_archive_started' :693 694 $this->set_status( sprintf( __( 'Creating zip archive %s', 'hmbkp' ), '(<code>' . $this->get_archive_method() . '</code>)' ) );695 break;696 697 case 'hmbkp_archive_verify_started' :698 699 $this->set_status( sprintf( __( 'Verifying Zip Archive %s', 'hmbkp' ), '(<code>' . $this->get_archive_method() . '</code>)' ) );700 break;701 702 case 'hmbkp_backup_complete' :703 704 $this->set_status( __( 'Finishing Backup', 'hmbkp' ) );705 break;706 707 case 'hmbkp_error' :708 709 if ( $this->get_errors() ) {710 711 $file = $this->get_path() . '/.backup_errors';712 713 if ( file_exists( $file ) )714 @unlink( $file );715 716 if ( ! $handle = @fopen( $file, 'w' ) )717 return;718 719 fwrite( $handle, json_encode( $this->get_errors() ) );720 721 fclose( $handle );722 723 }724 725 break;726 727 case 'hmbkp_warning' :728 729 if ( $this->get_warnings() ) {730 731 $file = $this->get_path() . '/.backup_warnings';732 733 if ( file_exists( $file ) )734 @unlink( $file );735 736 if ( ! $handle = @fopen( $file, 'w' ) )737 return;738 739 fwrite( $handle, json_encode( $this->get_warnings() ) );740 741 fclose( $handle );742 743 }744 745 break;746 747 endswitch;748 709 749 710 // Pass the actions to all the services … … 755 716 parent::do_action( $action ); 756 717 718 switch ( $action ) : 719 720 case 'hmbkp_mysqldump_started' : 721 722 $this->set_status( sprintf( __( 'Dumping Database %s', 'hmbkp' ), '(<code>' . $this->get_mysqldump_method() . '</code>)' ) ); 723 break; 724 725 case 'hmbkp_mysqldump_verify_started' : 726 727 $this->set_status( sprintf( __( 'Verifying Database Dump %s', 'hmbkp' ), '(<code>' . $this->get_mysqldump_method() . '</code>)' ) ); 728 break; 729 730 case 'hmbkp_archive_started' : 731 732 $this->set_status( sprintf( __( 'Creating zip archive %s', 'hmbkp' ), '(<code>' . $this->get_archive_method() . '</code>)' ) ); 733 break; 734 735 case 'hmbkp_archive_verify_started' : 736 737 $this->set_status( sprintf( __( 'Verifying Zip Archive %s', 'hmbkp' ), '(<code>' . $this->get_archive_method() . '</code>)' ) ); 738 break; 739 740 case 'hmbkp_backup_complete' : 741 742 $this->set_status( __( 'Finishing Backup', 'hmbkp' ) ); 743 break; 744 745 case 'hmbkp_error' : 746 747 if ( $this->get_errors() ) { 748 749 $file = $this->get_path() . '/.backup_errors'; 750 751 if ( file_exists( $file ) ) 752 @unlink( $file ); 753 754 if ( ! $handle = @fopen( $file, 'w' ) ) 755 return; 756 757 fwrite( $handle, json_encode( $this->get_errors() ) ); 758 759 fclose( $handle ); 760 761 } 762 763 break; 764 765 case 'hmbkp_warning' : 766 767 if ( $this->get_warnings() ) { 768 769 $file = $this->get_path() . '/.backup_warnings'; 770 771 if ( file_exists( $file ) ) 772 @unlink( $file ); 773 774 if ( ! $handle = @fopen( $file, 'w' ) ) 775 return; 776 777 fwrite( $handle, json_encode( $this->get_warnings() ) ); 778 779 fclose( $handle ); 780 781 } 782 783 break; 784 785 endswitch; 786 757 787 } 758 788 … … 807 837 // Check that it's a valid filepath 808 838 if ( empty( $filepath ) || ! is_string( $filepath ) ) 809 return new WP_Error( 'hmbkp_empty_string_error', sprintf( __( 'Argument 1 for %s must be a non empty string', 'hmbkp' ) ), __METHOD__);839 return new WP_Error( 'hmbkp_empty_string_error', sprintf( __( 'Argument 1 for %s must be a non empty string', 'hmbkp' ), __METHOD__ ) ); 810 840 811 841 // Make sure it exists 812 842 if ( ! file_exists( $filepath ) ) 813 return new WP_Error( 'hmbkp_file_error', sprintf( __( '%s d pesn\'t exist', 'hmbkp' ) ), $filepath);843 return new WP_Error( 'hmbkp_file_error', sprintf( __( '%s doesn\'t exist', 'hmbkp' ), $filepath ) ); 814 844 815 845 // Make sure it was created by this schedule 816 846 if ( strpos( $filepath, $this->get_id() ) === false ) 817 return new WP_Error( 'hmbkp_backup_error', sprintf( __( 'That backup wasn\'t created by this schedule', 'hmbkp' )) );847 return new WP_Error( 'hmbkp_backup_error', __( 'That backup wasn\'t created by this schedule', 'hmbkp' ) ); 818 848 819 849 unlink( $filepath ); 820 850 821 851 return true; 852 822 853 } 823 854 -
backupwordpress/trunk/classes/class-schedules.php
r838473 r876572 30 30 */ 31 31 private function __construct() { 32 $this->refresh_schedules(); 33 } 34 35 public function refresh_schedules() { 32 36 33 37 global $wpdb; -
backupwordpress/trunk/classes/wp-cli.php
r838473 r876572 10 10 class BackUpCommand extends WP_CLI_Command { 11 11 12 public function __construct( $args, $assoc_args ) { 12 /** 13 * Generate some posts. 14 * 15 * ## OPTIONS 16 * 17 * [--files_only] 18 * : Backup files only, default to off 19 * 20 * [--database_only] 21 * : Backup database only, defaults to off 22 * 23 * [--path] 24 * : dir that the backup should be save in, defaults to wp-content/backups/ 25 * 26 * [--root] 27 * : dir that should be backed up, defaults to site root. 28 * 29 * [--zip_command_path] 30 * : path to your zip binary, standard locations are automatically used 31 * 32 * [--mysqldump_command_path] 33 * : path to your mysqldump binary, standard locations are automatically used 34 * 35 * ## Usage 36 * 37 * wp backupwordpress backup [--files_only] [--database_only] [--path<dir>] [--root<dir>] [--zip_command_path=<path>] [--mysqldump_command_path=<path>] 38 */ 39 public function backup( $args, $assoc_args ) { 13 40 14 41 // Make sure it's possible to do a backup … … 73 100 } 74 101 75 static function help() {76 77 WP_CLI::line( <<<EOB78 usage: wp backup [--files_only] [--database_only] [--path<dir>] [--root<dir>] [--zip_command_path=<path>] [--mysqldump_command_path=<path>]79 80 --files_only Backup files only, default to off81 --database_only Backup database only, defaults to off82 --path dir that the backup should be save in, defaults to wp-content/backups/83 --root dir that should be backed up, defaults to site root.84 --zip_command_path path to your zip binary, standard locations are automatically used85 --mysqldump_command_path path to your mysqldump binary, standard locations are automatically used86 87 EOB88 );89 90 }91 92 102 } 93 WP_CLI::add_command( 'backup ', 'BackUpCommand' );103 WP_CLI::add_command( 'backupwordpress', 'BackUpCommand' ); -
backupwordpress/trunk/functions/core.php
r859574 r876572 212 212 $database_daily = new HMBKP_Scheduled_Backup( 'default-1' ); 213 213 $database_daily->set_type( 'database' ); 214 $database_daily->set_schedule_start_time( hmbkp_determine_start_time( 'hmbkp_daily', array( 'hours' => '23', 'minutes' => '0' ) ) ); 214 215 $database_daily->set_reoccurrence( 'hmbkp_daily' ); 215 216 $database_daily->set_max_backups( 14 ); … … 222 223 $complete_weekly = new HMBKP_Scheduled_Backup( 'default-2' ); 223 224 $complete_weekly->set_type( 'complete' ); 225 $complete_weekly->set_schedule_start_time( hmbkp_determine_start_time( 'hmbkp_weekly', array( 'day_of_week' => 'sunday', 'hours' => '3', 'minutes' => '0' ) ) ); 224 226 $complete_weekly->set_reoccurrence( 'hmbkp_weekly' ); 225 227 $complete_weekly->set_max_backups( 12 ); 226 228 $complete_weekly->save(); 229 230 $schedules->refresh_schedules(); 227 231 228 232 function hmbkp_default_schedules_setup_warning() { … … 272 276 @unlink( $dir ); 273 277 274 if ( ! is_dir( $dir ) )278 if ( ! is_dir( $dir ) || ! is_readable( $dir ) ) 275 279 return false; 276 280 … … 446 450 return false; 447 451 452 $test_backup = new HMBKP_Scheduled_Backup( 'test_backup' ); 453 454 if ( ! is_readable( $test_backup->get_root() ) ) 455 return false; 456 448 457 return true; 449 458 } … … 467 476 468 477 while ( false !== ( $file = readdir( $handle ) ) ) { 469 if ( ! in_array( $file, array( '.', '..', 'index.html' ) ) && pathinfo( $file, PATHINFO_EXTENSION ) !== 'zip' )478 if ( ! in_array( $file, array( '.', '..', 'index.html' ) ) && pathinfo( $file, PATHINFO_EXTENSION ) !== 'zip' && strpos( $file, '-running' ) === false ) 470 479 hmbkp_rmdirtree( trailingslashit( $hmbkp_path ) . $file ); 471 480 } … … 525 534 return true; 526 535 } 536 537 /** 538 * List of schedules 539 * 540 * @return array 541 */ 542 function hmbkp_get_cron_schedules() { 543 544 $schedules = wp_get_schedules(); 545 546 // remove any schedule whose key is not prefixed with 'hmbkp_' 547 foreach ( $schedules as $key => $arr ) { 548 if ( ! preg_match( '/^hmbkp_/', $key ) ) 549 unset( $schedules[$key] ); 550 } 551 552 return $schedules; 553 } 554 555 /** 556 * @param string $type the type of the schedule 557 * @param array $times { 558 * An array of time arguments. Optional. 559 * 560 * @type int $minutes The minute to start the schedule on. Defaults to current time + 10 minutes. Accepts 561 * any valid `date( 'i' )` output. 562 * @type int $hours The hour to start the schedule on. Defaults to current time + 10 minutes. Accepts 563 * any valid `date( 'G' )` output. 564 * @type string $day_of_week The day of the week to start the schedule on. Defaults to current time + 10 minutes. Accepts 565 * any valid `date( 'l' )` output. 566 * @type int $day_of_month The day of the month to start the schedule on. Defaults to current time + 10 minutes. Accepts 567 * any valid `date( 'j' )` output. 568 * @type int $now The current time. Defaults to `time()`. Accepts any valid timestamp. 569 * 570 * } 571 * @return int $timestamp Returns the resulting timestamp on success and Int 0 on failure 572 */ 573 function hmbkp_determine_start_time( $type, $times = array() ) { 574 575 // Default to in 10 minutes 576 if ( ! empty( $times['now'] ) ) { 577 $default_timestamp = $times['now'] + 600; 578 579 } else { 580 $default_timestamp = time() + 600; 581 } 582 583 $default_times = array( 584 'minutes' => date( 'i', $default_timestamp ), 585 'hours' => date( 'G', $default_timestamp ), 586 'day_of_week' => date( 'l', $default_timestamp ), 587 'day_of_month' => date( 'j', $default_timestamp ), 588 'now' => time() 589 ); 590 591 $args = wp_parse_args( $times, $default_times ); 592 593 $schedule_start = ''; 594 595 $intervals = HMBKP_Scheduled_Backup::get_cron_schedules(); 596 597 // Allow the hours and minutes to be overwritten by a constant 598 if ( defined( 'HMBKP_SCHEDULE_TIME' ) && HMBKP_SCHEDULE_TIME ) { 599 $hm = HMBKP_SCHEDULE_TIME; 600 } 601 602 // The hour and minute that the schedule should start on 603 else { 604 $hm = $args['hours'] . ':' . $args['minutes'] . ':00'; 605 } 606 607 switch ( $type ) { 608 609 case 'hmbkp_hourly' : 610 case 'hmbkp_daily' : 611 case 'hmbkp_twicedaily': 612 613 // The next occurance of the specified time 614 $schedule_start = $hm; 615 break; 616 617 case 'hmbkp_weekly' : 618 case 'hmbkp_fortnightly' : 619 620 // The next day of the week at the specified time 621 $schedule_start = $args['day_of_week'] . ' ' . $hm; 622 break; 623 624 case 'hmbkp_monthly' : 625 626 // The occurance of the time on the specified day of the month 627 $schedule_start = date( 'F', $args['now'] ) . ' ' . $args['day_of_month'] . ' ' . $hm; 628 629 // If we've already gone past that day this month then we'll need to start next month 630 if ( strtotime( $schedule_start, $args['now'] ) <= $args['now'] ) 631 $schedule_start = date( 'F', strtotime( '+ 1 month', $args['now'] ) ) . ' ' . $args['day_of_month'] . ' ' . $hm; 632 633 // If that's still in the past then we'll need to jump to next year 634 if ( strtotime( $schedule_start, $args['now'] ) <= $args['now'] ) 635 $schedule_start = date( 'F', strtotime( '+ 1 month', $args['now'] ) ) . ' ' . $args['day_of_month'] . ' ' . date( 'Y', strtotime( '+ 1 year', $args['now'] ) ) . ' ' . $hm; 636 637 break; 638 default : 639 640 return 0; 641 642 break; 643 644 } 645 646 $timestamp = strtotime( $schedule_start, $args['now'] ); 647 648 // Convert to UTC 649 $timestamp -= get_option( 'gmt_offset' ) * 3600; 650 651 // If the scheduled time already passed then keep adding the interval until we get to a future date 652 while ( $timestamp <= $args['now'] ) { 653 $timestamp += $intervals[ $type ]['interval']; 654 } 655 656 return $timestamp; 657 658 } -
backupwordpress/trunk/functions/interface.php
r859574 r876572 125 125 endif; 126 126 127 $test_backup = new HMBKP_Scheduled_Backup( 'test_backup' ); 128 129 if ( ! is_readable( $test_backup->get_root() ) ) : 130 131 function hmbkp_backup_root_unreadable_notice() { 132 $test_backup = new HMBKP_Scheduled_Backup( 'test_backup' ); 133 echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress has detected a problem.', 'hmbkp' ) . '</strong>' . sprintf( __( 'Your backup root path %s isn\'t readable.', 'hmbkp' ), '<code>' . $test_backup->get_root() . '</code>' ) . '</p></div>'; 134 } 135 136 add_action( 'admin_notices', 'hmbkp_backup_root_unreadable_notice' ); 137 138 endif; 139 127 140 } 128 141 … … 278 291 ob_start(); ?> 279 292 280 <span class="hmbkp-status"><?php echo $schedule->get_status() ? wp_kses_data( $schedule->get_status() ) : __( 'Starting Backup', 'hmbkp' ); ?> <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'hmbkp_cancel', 'hmbkp_schedule_id' => $schedule->get_id() ), $settings_url ) ); ?>"><?php _e( 'cancel', 'hmbkp' ); ?></a></span> 293 <span class="hmbkp-status"<?php if ( $schedule->get_status() ) { ?> title="<?php printf( __( 'Started %s ago', 'hmbkp' ), human_time_diff( $schedule->get_schedule_running_start_time() ) ); ?>"<?php } ?>> 294 <?php echo $schedule->get_status() ? wp_kses_data( $schedule->get_status() ) : __( 'Starting Backup', 'hmbkp' ); ?> 295 <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'hmbkp_cancel', 'hmbkp_schedule_id' => $schedule->get_id() ), $settings_url ) ); ?>"><?php _e( 'cancel', 'hmbkp' ); ?></a> 296 </span> 281 297 282 298 <div class="hmbkp-schedule-actions row-actions"> -
backupwordpress/trunk/hm-backup/hm-backup.php
r838473 r876572 182 182 if ( array_intersect( array( 'shell_exec', 'escapeshellarg', 'escapeshellcmd' ), array_map( 'trim', explode( ',', @ini_get( 'disable_functions' ) ) ) ) ) 183 183 return false; 184 184 185 185 // Functions can also be disabled via suhosin 186 186 if ( array_intersect( array( 'shell_exec', 'escapeshellarg', 'escapeshellcmd' ), array_map( 'trim', explode( ',', @ini_get( 'suhosin.executor.func.blacklist' ) ) ) ) ) … … 208 208 209 209 $home_path = ABSPATH; 210 211 // Attempt to guess the home path based on the location of wp-config.php 212 if ( ! file_exists( ABSPATH . 'wp-config.php' ) ) { 213 $home_path = trailingslashit( dirname( ABSPATH ) ); 214 } 210 215 211 216 // If site_url contains home_url and they differ then assume WordPress is installed in a sub directory … … 510 515 ); 511 516 512 // Find the one which works517 // Find the first one which works 513 518 foreach ( $mysqldump_locations as $location ) { 514 if ( @is_executable( self::conform_dir( $location ) ) ) 519 if ( @is_executable( self::conform_dir( $location ) ) ) { 515 520 $this->set_mysqldump_command_path( $location ); 521 break; // Found one 522 } 516 523 } 517 524 … … 571 578 ); 572 579 573 // Find the one which works580 // Find the first one which works 574 581 foreach ( $zip_locations as $location ) { 575 if ( @is_executable( self::conform_dir( $location ) ) ) 582 if ( @is_executable( self::conform_dir( $location ) ) ) { 576 583 $this->set_zip_command_path( $location ); 584 break; // Found one 585 } 577 586 } 578 587 -
backupwordpress/trunk/readme.txt
r859576 r876572 3 3 Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade 4 4 Requires at least: 3.7.1 5 Tested up to: 3. 8.16 Stable tag: 2. 57 8 Simple automated back ups of your WordPress powered website.5 Tested up to: 3.9 6 Stable tag: 2.6 7 8 Simple automated backups of your WordPress powered website. 9 9 10 10 == Description == 11 11 12 [BackUpWordPress](http ://bwp.hmn.md/?utm_source=wordpress-org&utm_medium=plugin-page&utm_campaign=freeplugin) will back up your entire site including your database and all your files on a schedule that suits you. Try it now to see how easy it is!12 [BackUpWordPress](https://bwp.hmn.md/?utm_source=wordpress-org&utm_medium=plugin-page&utm_campaign=freeplugin) will back up your entire site including your database and all your files on a schedule that suits you. Try it now to see how easy it is! 13 13 14 14 = Features = … … 18 18 * Manage multiple schedules. 19 19 * Option to have each backup file emailed to you. 20 * Uses `zip` and `mysqldump` for faster back ups if they are available.20 * Uses `zip` and `mysqldump` for faster backups if they are available. 21 21 * Works on Linux & Windows Server. 22 * Exclude files and folders from your back ups.22 * Exclude files and folders from your backups. 23 23 * Good support should you need help. 24 24 * Translations for Spanish, German, Chinese, Romanian, Russian, Serbian, Lithuanian, Italian, Czech, Dutch, French, Basque. … … 50 50 **What if I want I want to back up my site to another destination?** 51 51 52 BackUpWordPress Pro supports Dropbox, Google Drive, Amazon S3, Rackspace, Azure, DreamObjects and FTP/SFTP. Check it out here: [http ://bwp.hmn.md](http://bwp.hmn.md/?utm_source=wordpress-org&utm_medium=plugin-page&utm_campaign=freeplugin)52 BackUpWordPress Pro supports Dropbox, Google Drive, Amazon S3, Rackspace, Azure, DreamObjects and FTP/SFTP. Check it out here: [https://bwp.hmn.md](http://bwp.hmn.md/?utm_source=wordpress-org&utm_medium=plugin-page&utm_campaign=freeplugin) 53 53 54 54 **How do I restore my site from a backup?** … … 107 107 108 108 == Changelog == 109 110 #### 2.6 111 112 * It's now possible to choose the time and day that your schedule will run on. 113 * Introduces several new unit tests around schedule timings. 114 * Fixes a bug that could cause the hourly schedule to run constantly. 115 * Improved the layout of the Constants help panel. 116 * If the backup root directory is unreadable then the plugin will no longer function. 117 * Update the backups table match the standard WordPress table styles. 118 * Improved styling for the settings dialogue. 119 * Improved styling for the Server Info help tab. 120 * /s/back ups/backups. 121 * Remove Deprecated call to `screen_icon`. 122 * Updated French translation. 123 * Update the `WP CLI` command to use the new method for registering command. 124 * Reload the schedules when re-setting up the default schedules so they show up straight away. 125 * s/dpesnt't/doesn't. 126 * Only show the estimated total schedule size when editing an existing schedule. 127 * Stop stripping 0 from the minutes on hourly backups so that backups at 10 (& 20, etc.) past the hour correctly show. 128 * Disable buttons whilst ajax requests are running. 129 * Move spinners outside the buttons as they didn't look very good inside. 130 * Improve the detection of the home path on multisite installs which have WordPress in a subdirectory. 131 * Track the time that the running backup is started and display how long a backup has been running for. 132 * Fix an issue that meant it wasn't possible to run multiple manual backups at the same time. 133 * Many other minor improvements. 109 134 110 135 #### 2.5 -
backupwordpress/trunk/uninstall.php
r838473 r876572 3 3 if ( ! defined( 'HMBKP_PLUGIN_PATH' ) ) 4 4 define( 'HMBKP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); 5 6 if ( ! defined( 'HMBKP_SCHEDULE_TIME' ) )7 define( 'HMBKP_SCHEDULE_TIME', '11pm' );8 5 9 6 // Load the schedules
Note: See TracChangeset
for help on using the changeset viewer.