diff -r be944660c56a -r 3d72ae0968f4 wp/wp-content/plugins/wp-db-backup/wp-db-backup.php --- a/wp/wp-content/plugins/wp-db-backup/wp-db-backup.php Wed Sep 21 18:19:35 2022 +0200 +++ b/wp/wp-content/plugins/wp-db-backup/wp-db-backup.php Tue Sep 27 16:37:53 2022 +0200 @@ -1,15 +1,13 @@ Tools → Backup to get started. Author: Delicious Brains Author URI: https://deliciousbrains.com -Version: 2.4 +Version: 2.5.2 Domain Path: /languages -Copyright 2018 Austin Matzko (email : austin at pressedcode.com) - This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -53,7 +51,7 @@ var $basename; var $page_url; var $referer_check_key; - var $version = '2.4'; + var $version = '2.5.2'; function module_check() { $mod_evasive = false; @@ -149,7 +147,7 @@ add_action( 'init', array( &$this, 'perform_backup' ) ); break; case 'fragments': - add_action( 'admin_menu', array( &$this, 'fragment_menu' ) ); + add_action( 'admin_menu', array( &$this, 'admin_menu' ) ); break; } } elseif ( isset( $_GET['fragment'] ) ) { @@ -205,8 +203,22 @@ if ( isset( $_GET['fragment'] ) ) { list($table, $segment, $filename) = explode( ':', sanitize_text_field( $_GET['fragment'] ) ); - $this->validate_file( $filename ); - $this->backup_fragment( $table, $segment, $filename ); + + if ( empty( $table ) || in_array( $table, $this->get_tables() ) ) { + $this->validate_file( $filename ); + $this->backup_fragment( $table, $segment, $filename ); + } else { + $this->error( + array( + 'loc' => 'frame', + 'kind' => 'fatal', + 'msg' => __( + 'There was an error determining the table to backup. Please check the settings used for the backup and try again.', + 'wp-db-backup' + ), + ) + ); + } } die(); @@ -257,31 +269,39 @@ function build_backup_script() { global $table_prefix, $wpdb; - echo "
"; - echo '
' . __( 'Progress', 'wp-db-backup' ) . ' -

' . - __( 'DO NOT DO THE FOLLOWING AS IT WILL CAUSE YOUR BACKUP TO FAIL:', 'wp-db-backup' ) . - '

-
    -
  1. ' . __( 'Close this browser', 'wp-db-backup' ) . '
  2. -
  3. ' . __( 'Reload this page', 'wp-db-backup' ) . '
  4. -
  5. ' . __( 'Click the Stop or Back buttons in your browser', 'wp-db-backup' ) . '
  6. -
-

' . __( 'Progress:', 'wp-db-backup' ) . '

-
 
-
-
+ echo '
' . __( 'Progress', 'wp-db-backup' ) . ' + +
+

Backup In Progress...

+
+ +
+
+
+
+
'?> +
+ +
+ +

+ Whilst the backup is in progress, please do not close the browser, reload or change the page, or click the stop or back browser buttons. This would result in the backup failing. +

+
+ +
+
- -
'; - $this->backup_menu(); } function backup_fragment( $table, $segment, $filename ) { @@ -513,28 +532,29 @@ if ( ul ) { var lis = ul.getElementsByTagName('li'); if ( 2 < lis.length ) { - var text = document.createElement('p'); - text.className = 'instructions'; - text.innerHTML = '[SHIFT] to toggle multiple checkboxes', 'wp-db-backup' ); ?>'; - ul.parentNode.insertBefore(text, ul); + var text = document.querySelector('.instructions-container p'); + text.style.display = 'block'; } } t[k].p = d.getElementsByTagName("input"); for(var i=0; i < t[k].p.length; i++) { if(t[k].name == t[k].p[i].getAttribute('name')) { t[k].p[i].id = k + '-table-' + i; - t[k].p[i].onkeyup = t[k].p[i].onclick = function(e) { + var label = document.getElementById(t[k].p[i].id).parentNode; + t[k].p[i].onkeyup = label.onclick = function(e) { e = e ? e : event; if ( 16 == e.keyCode ) return; - var match = /([\w-]*)-table-(\d*)/.exec(this.id); + var match = /([\w-]*)-table-(\d*)/.exec(this.querySelector('input').id); var listname = match[1]; var that = match[2]; if ( null === t[listname].s ) t[listname].s = that; else if ( e.shiftKey ) { + console.log(this); var start = Math.min(that, t[listname].s) + 1; var end = Math.max(that, t[listname].s); + this.querySelector('input').checked = true; for( var j=start; j < end; j++) t[listname].p[j].checked = t[listname].p[j].checked ? false : true; t[listname].s = null; @@ -553,7 +573,7 @@ var initTimeChange = function() { var timeWrap = document.getElementById('backup-time-wrap'); var backupTime = document.getElementById('next-backup-time'); - if ( !! timeWrap && !! backupTime && ( 1 == + if ( !! timeWrap && !! backupTime && ( 1 == @@ -614,7 +634,8 @@ function admin_load() { add_action( 'admin_head', array( &$this, 'admin_header' ) ); - wp_enqueue_style( 'wp-db-backup-styles', plugin_dir_url( __FILE__ ) . 'assets/css/style.css' ); + wp_enqueue_style( 'wp-db-backup-styles', plugin_dir_url( __FILE__ ) . 'assets/css/style.css', array( 'common', 'forms' ) ); + wp_enqueue_script( 'wp-db-backup-script', plugin_dir_url( __FILE__ ) . 'assets/js/script.js', array( 'jquery' ), $this->version, true ); } function admin_menu() { @@ -637,11 +658,6 @@ } } - function fragment_menu() { - $page_hook = add_management_page( __( 'Backup', 'wp-db-backup' ), __( 'Backup', 'wp-db-backup' ), 'import', $this->basename, array( &$this, 'build_backup_script' ) ); - add_action( 'load-' . $page_hook, array( &$this, 'admin_load' ) ); - } - /** * Add WP-DB-Backup-specific help options to the 2.7 =< WP contextual help menu * @return string The text of the help menu. @@ -1115,7 +1131,7 @@ // did we just do a backup? If so, let's report the status if ( $this->backup_complete ) { - $feedback = '

' . __( 'Backup Successful', 'wp-db-backup' ) . '!'; + $feedback = '

' . __( 'Backup Successful', 'wp-db-backup' ) . '!'; $file = $this->backup_file; switch ( $_POST['deliver'] ) { case 'http': @@ -1139,13 +1155,15 @@ $this->wp_secure(); if ( count( $this->errors ) ) { - $feedback .= '

' . __( 'The following errors were reported:', 'wp-db-backup' ) . '

'; + $feedback .= '

' . __( 'The following errors were reported:', 'wp-db-backup' ) . '

'; $feedback .= '

' . $this->error_display( 'main', false ) . '

'; $feedback .= '

'; } // did we just save options for wp-cron? if ( ( function_exists( 'wp_schedule_event' ) || function_exists( 'wp_cron_init' ) ) && isset( $_POST['wp_cron_backup_options'] ) ) : + check_admin_referer( $this->referer_check_key ); + do_action( 'wp_db_b_update_cron_options' ); if ( function_exists( 'wp_schedule_event' ) ) { @@ -1168,30 +1186,20 @@ update_option( 'wp_cron_backup_recipient', sanitize_text_field( $_POST['cron_backup_recipient'] ), false ); } - $feedback .= '

' . __( 'Scheduled Backup Options Saved!', 'wp-db-backup' ) . '

'; + $feedback .= '

' . __( 'Scheduled Backup Options Saved!', 'wp-db-backup' ) . '

'; endif; $other_tables = array(); $also_backup = array(); // Get complete db table list - $all_tables = $wpdb->get_results( 'SHOW TABLES', ARRAY_N ); - $all_tables = array_map( - function( $a ) { - return $a[0]; - }, - $all_tables - ); + $all_tables = $this->get_tables(); // Get list of WP tables that actually exist in this DB (for 1.6 compat!) $wp_backup_default_tables = array_intersect( $all_tables, $this->core_table_names ); // Get list of non-WP tables $other_tables = array_diff( $all_tables, $wp_backup_default_tables ); - if ( '' != $feedback ) { - echo $feedback; - } - if ( ! $this->wp_secure() ) { return; } @@ -1204,7 +1212,7 @@ // the file doesn't exist and can't create it if ( ! file_exists( $this->backup_dir ) && ! @mkdir( $this->backup_dir ) ) { ?> -
+

NOT exist, and we cannot create it.', 'wp-db-backup' ); ?>

' . $this->backup_dir . '' ); ?>

@@ -1213,7 +1221,7 @@ $whoops = true; } elseif ( ! is_writable( $this->backup_dir ) && ! @chmod( $this->backup_dir, $dir_perms ) ) { ?> -
+

NOT writable! We cannot create the backup files.', 'wp-db-backup' ); ?>

777', 'a+w', '' . $this->backup_dir . '' ); ?>

@@ -1228,7 +1236,7 @@ // the directory is not writable probably due to safe mode } else { ?> -
+

NOT writable! We cannot create the backup files.', 'wp-db-backup' ); ?>

backup_dir . 'index.php' ); } ?> -
-

+
+
+ +

+
+ + + +
+ + build_backup_script(); + } + ?> +
referer_check_key ); } ?> -
+ +
+ + +
+

Tables

+
+ +
+
-

+
+

+
    comments ) { $checked = ( isset( $excs['spam'] ) && is_array( $excs['spam'] ) && in_array( $table, $excs['spam'] ) ) ? ' checked=\'checked\'' : ''; - echo "
  • $table " . __( 'Exclude spam comments', 'wp-db-backup' ) . '
  • '; + echo "
  • $table
  • '; } elseif ( function_exists( 'wp_get_post_revisions' ) && $table == $wpdb->posts ) { $checked = ( isset( $excs['revisions'] ) && is_array( $excs['revisions'] ) && in_array( $table, $excs['revisions'] ) ) ? ' checked=\'checked\'' : ''; - echo "
  • $table " . __( 'Exclude post revisions', 'wp-db-backup' ) . '
  • '; + echo "
  • $table
  • '; } else { echo "
  • $table
  • "; } @@ -1277,11 +1323,16 @@ ?>
+
+ 0 ) { ?> -

+
+

+ +
+ +
-
+ + +
-

+ +
+

Backup Options

+
+ +

- +

-

NOT writable!', 'wp-db-backup' ); ?>

+

NOT writable!', 'wp-db-backup' ); ?>

+ +
@@ -1335,14 +1401,18 @@ $cron_old = ( function_exists( 'wp_cron_init' ) && ! $cron ) ? true : false; // wp-cron plugin by Skippy if ( $cron_old || $cron ) : - echo '
' . __( 'Scheduled Backup', 'wp-db-backup' ) . ''; + echo ''; endif; // end of wp_cron (legacy) section + echo '
'; echo '
'; } // end wp_backup_menu() @@ -1460,11 +1541,11 @@ continue; } $display = ( ! '' == $settings['display'] ) ? $settings['display'] : sprintf( __( '%s seconds', 'wp-db-backup' ), $interval ); - $menu .= "
  • get_results( 'SHOW TABLES', ARRAY_N ); - $all_tables = array_map( - function( $a ) { - return $a[0]; - }, - $all_tables - ); + $all_tables = $this->get_tables(); $core_tables = array_intersect( $all_tables, $this->core_table_names ); $other_tables = get_option( 'wp_cron_backup_tables' ); $recipient = get_option( 'wp_cron_backup_recipient' ); @@ -1723,6 +1798,24 @@ return $this->get_post_data_array( 'wp_cron_backup_tables' ); } + /** + * Get an array of all tables on the current WP install. + * + * @return array + */ + function get_tables() { + global $wpdb; + + $all_tables = $wpdb->get_results( 'SHOW TABLES', ARRAY_N ); + + return array_map( + function( $a ) { + return $a[0]; + }, + $all_tables + ); + } + } function wpdbBackup_init() {