Plugin Directory

Changeset 3124649


Ignore:
Timestamp:
07/24/2024 02:00:48 PM (20 months ago)
Author:
databasebackup
Message:

added credits

Location:
wp-database-backup/tags/6.12
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • wp-database-backup/tags/6.12/includes/admin/class-wpdb-admin.php

    r3124584 r3124649  
    147147        if ( 1 === $wp_db_remove_local_backup ) {
    148148            if ( file_exists( $args[1] ) ) {
    149                 unlink( $args[1] );// File path.
     149                wp_delete_file( $args[1] );// File path.
    150150            }
    151151        }
     
    234234                            $path_info = wp_upload_dir();
    235235                            if ( file_exists( $path_info['basedir'] . '/db-backup/.htaccess' ) ) {
    236                                 unlink( $path_info['basedir'] . '/db-backup/.htaccess' );
     236                                wp_delete_file( $path_info['basedir'] . '/db-backup/.htaccess' );
    237237                            }
    238238                        }
     
    311311                        // If $file is NOT a directory remove it.
    312312                        if ( ! is_dir( $file ) ) {
    313                             unlink( $dir . $file );
     313                            wp_delete_file( $dir . $file );
    314314                        }
    315315                    }
     
    349349                                    chdir($file_directory);
    350350                                    if ( isset($options[ $index ]['filename']) && file_exists( $options[ $index ]['filename'] ) ) {
    351                                         unlink( $options[ $index ]['filename'] );
     351                                        wp_delete_file( $options[ $index ]['filename'] );
    352352                                    }
    353353                                    if(isset($options[ $index ]['filename'])){
    354354                                        $file_sql = explode( '.', $options[ $index ]['filename'] );
    355355                                        if ( isset($file_sql[0]) && file_exists( $file_sql[0] . '.sql' ) ) {
    356                                             unlink( $file_sql[0] . '.sql' );
     356                                            wp_delete_file( $file_sql[0] . '.sql' );
    357357                                        }
    358358                                    }
    359359                                   
    360360                                    chdir($actual_working_directory);
     361                                    $newoptions = wpdbbkp_filter_unique_filenames( $newoptions );
    361362                                    update_option( 'wp_db_backup_backups', $newoptions , false);
    362363                                    $nonce = wp_create_nonce( 'wp-database-backup' );
     
    382383                                            foreach($files as $file) {
    383384                                                if(is_file($file)){
    384                                                     unlink($file);
     385                                                    wp_delete_file($file);
    385386                                                } 
    386387                                            }
     
    417418                                            if ( ! ( in_array( $file, $backup_check_list, true ) ) ) {
    418419                                                if ( file_exists( $wp_db_backup_path . '/' . $file ) ) {
    419                                                     unlink( $wp_db_backup_path . '/' . $file );
     420                                                    wp_delete_file( $wp_db_backup_path . '/' . $file );
    420421                                                }
    421422                                                $delete_message .= ' ' . $file;
     
    553554                                if ( isset( $options[ $index ]['sqlfile'] ) && file_exists( $options[ $index ]['sqlfile'] ) ) { // Added for extract zip file V.3.3.0.
    554555                                    if ( file_exists( $options[ $index ]['sqlfile'] ) ) {
    555                                         unlink( $options[ $index ]['sqlfile'] );
     556                                        wp_delete_file( $options[ $index ]['sqlfile'] );
    556557                                    }
    557558                                } else {
     
    562563                                            $database_file = ( $file_sql[0] . '.sql' );
    563564                                                if ( file_exists( $database_file ) ) {
    564                                                     unlink( $database_file );
     565                                                    wp_delete_file( $database_file );
    565566                                                }
    566567
     
    631632
    632633        $options  = get_option( 'wp_db_backup_backups' );
    633         $options = $this->wpdbbkp_filter_unique_filenames( $options );
     634        $options = wpdbbkp_filter_unique_filenames( $options );
    634635        $settings = get_option( 'wp_db_backup_options' );
    635636        $wp_db_log = get_option( 'wp_db_log' ); ?>
     
    19031904        $wpdb->flush();
    19041905        /* BEGIN : Prevent saving backup plugin settings in the database dump */
     1906        $options_backup = wpdbbkp_filter_unique_filenames( $options_backup );
    19051907        add_option( 'wp_db_backup_backups', $options_backup );
    19061908        add_option( 'wp_db_backup_options', $settings_backup );
     
    19251927   
    19261928        // Initialize the file with table creation statement if it doesn't exist
    1927         $row2 = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N ); // phpcs:ignore
     1929
     1930        $table = esc_sql( $table );
     1931        $row2 = $wpdb->get_row( "SHOW CREATE TABLE `{$table}`", ARRAY_N ); // phpcs:ignore
    19281932        $initial_output = "\n\n" . $row2[1] . ";\n\n";
    19291933   
     
    19771981   
    19781982        $sub_limit = 500;
    1979         $check_count = $wpdb->get_var( "SELECT COUNT(*) FROM {$table}" ); // phpcs:ignore
     1983        // phpcs:ignore
     1984        $check_count = $wpdb->get_var( "SELECT COUNT(*) FROM `{$table}`" );
    19801985        $check_count = intval( $check_count );
    19811986   
     
    19851990            for ( $sub_i = 0; $sub_i < $t_sub_queries; $sub_i++ ) {
    19861991                $sub_offset = $sub_i * $sub_limit;
    1987                 $sub_result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `$table` LIMIT %d OFFSET %d", array( $sub_limit, $sub_offset ) ), ARRAY_A ); // phpcs:ignore
     1992                $sub_result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `{$table}` LIMIT %d OFFSET %d", array( $sub_limit, $sub_offset ) ), ARRAY_A ); // phpcs:ignore
    19881993   
    19891994                if ( $sub_result ) {
     
    20112016            }
    20122017        } else {
    2013             $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `$table`" ), ARRAY_A ); // phpcs:ignore
     2018            $result = $wpdb->get_results( "SELECT * FROM `{$table}`", ARRAY_A ); // phpcs:ignore
    20142019   
    20152020            $output = '';
     
    22782283        if ( $this->get_errors( $this->get_mysqldump_method() ) && file_exists( $sql_filename ) ) {
    22792284            if ( file_exists( $sql_filename ) ) {
    2280                 unlink( $sql_filename );
     2285                wp_delete_file( $sql_filename );
    22812286            }
    22822287        }
     
    22852290        if ( 0 === filesize( $sql_filename ) ) {
    22862291            if ( file_exists( $sql_filename ) ) {
    2287                 unlink( $sql_filename );
     2292                wp_delete_file( $sql_filename );
    22882293            }
    22892294        }
     
    23992404            foreach($tables as $table){
    24002405                if ( empty( $wp_db_exclude_table ) || ( ! ( in_array( $table, $wp_db_exclude_table, true ) ) ) ) {
    2401                     $this->wp_db_backup_create_mysql_backup_new($table,$path_info['basedir'] . '/db-backup/' . $sql_filename );
     2406                    $this->wp_db_backup_create_mysql_backup_new($table, $path_info['basedir'] . '/db-backup/' . $sql_filename );
    24022407                }
    24032408            }
     
    24052410         }
    24062411            /* BEGIN : Prevent saving backup plugin settings in the database dump */
     2412            $options_backup = wpdbbkp_filter_unique_filenames( $options_backup );
    24072413            add_option( 'wp_db_backup_backups', $options_backup );
    24082414            add_option( 'wp_db_backup_options', $settings_backup );
     
    24842490                    $index = $i;
    24852491                    if ( isset($options[ $index ]['dir']) && file_exists( $options[ $index ]['dir'] ) ) {
    2486                         unlink( $options[ $index ]['dir'] );
     2492                        wp_delete_file( $options[ $index ]['dir'] );
    24872493                    }
    24882494                    $file_sql = explode( '.', $options[ $index ]['dir'] );
    24892495                    if ( isset($file_sql[0]) && file_exists( $file_sql[0] . '.sql' ) ) {
    2490                         unlink( $file_sql[0] . '.sql' );
     2496                        wp_delete_file( $file_sql[0] . '.sql' );
    24912497                    }
    24922498                }
     
    24962502                    $newoptions[] = $options[ $index ];
    24972503                }
     2504                $newoptions = wpdbbkp_filter_unique_filenames( $newoptions );
    24982505
    24992506                update_option( 'wp_db_backup_backups', $newoptions , false);
     
    25022509
    25032510        if ( file_exists( $path_info['basedir'] . '/db-backup/' . $sql_filename ) ) {
    2504             unlink( $path_info['basedir'] . '/db-backup/' . $sql_filename );
     2511            wp_delete_file( $path_info['basedir'] . '/db-backup/' . $sql_filename );
    25052512        }
    25062513        return $upload_path;
     
    25852592        );
    25862593        if ( 1 !== (int) $wp_db_remove_local_backup ) {
     2594            $options = wpdbbkp_filter_unique_filenames( $options );
    25872595            update_option( 'wp_db_backup_backups', $options , false);
    25882596        }
     
    29142922            $filename = $FileName . '.sql';
    29152923            $WPDBFileName = $FileName . '.zip';
    2916             @unlink($this->wp_db_backup_wp_config_path() . '/' . $filename);
    2917             @unlink($this->wp_db_backup_wp_config_path() . '/wp_installer.php');
     2924            wp_delete_file($this->wp_db_backup_wp_config_path() . '/' . $filename);
     2925            wp_delete_file($this->wp_db_backup_wp_config_path() . '/wp_installer.php');
    29182926            @$filesize = filesize($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/' . $WPDBFileName);
    29192927
     
    31523160            // If there are errors delete the backup file.
    31533161            if ($this->get_errors($this->get_archive_method()) && file_exists($WPDBFileName))
    3154                 unlink($WPDBFileName);
     3162                wp_delete_file($WPDBFileName);
    31553163
    31563164            // If the archive file still exists assume it's good
     
    32493257        }
    32503258
    3251         private function wpdbbkp_filter_unique_filenames($backups) {
    3252            $unique_filenames = [];
    3253            $filtered_backups = [];
    3254             if(!empty($backups)){
    3255                 foreach ($backups as $backup) {
    3256                     if (isset($backup['filename']) && !in_array($backup['filename'], $unique_filenames)) {
    3257                         $unique_filenames[] = $backup['filename'];
    3258                         $filtered_backups[] = $backup;
    3259                     }
    3260                 }
    3261             }
    3262            return $filtered_backups;
    3263        }
    3264 
    32653259    }
    32663260
  • wp-database-backup/tags/6.12/includes/admin/class-wpdbbkp-restore.php

    r3124584 r3124649  
    165165                }
    166166           
    167                 @unlink($file_path);
     167                wp_delete_file($file_path);
    168168            }
    169169           
  • wp-database-backup/tags/6.12/includes/admin/cron-create-full-backup.php

    r3124590 r3124649  
    233233       
    234234   
    235 
     235        $options_backup = wpdbbkp_filter_unique_filenames($options_backup);
    236236        update_option('wp_db_backup_backups',$options_backup, false);
    237237        update_option('wp_db_backup_options',$settings_backup, false);
     
    372372            $filename = $FileName . '.sql';
    373373            $path_info = wp_upload_dir();
     374            $filepath  = $path_info['basedir'] . '/db-backup/' . $filename;
    374375            global $wpdb;
    375376   
     
    395396                $output = '';
    396397                $sub_limit = 500;
     398                $table = esc_sql($table);
    397399                //phpcs:ignore  -- need to get all tables
    398                 $check_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `{$table}`"));
     400                $check_count = $wpdb->get_var("SELECT COUNT(*) FROM `{$table}`");
    399401                $check_count = intval($check_count);
    400402   
     
    412414                } else {
    413415                    // phpcs:ignore  -- need to get all data for selected table
    414                     $result = $wpdb->get_results($wpdb->prepare("SELECT * FROM `{$table}`"), ARRAY_A);
     416                    $result = $wpdb->get_results("SELECT * FROM `{$table}`", ARRAY_A);
    415417                    $output .= wpdbbkp_create_sql_insert_statements($table, $result);
    416418                }
     
    418420
    419421                // phpcs:ignore  -- Get table structure for backup
    420                 $row2 = $wpdb->get_row($wpdb->prepare("SHOW CREATE TABLE `{$table}`"), ARRAY_N);
     422                $row2 = $wpdb->get_row("SHOW CREATE TABLE `{$table}`", ARRAY_N);
    421423                $output = "\n\n" . $row2[1] . ";\n\n" . $output;
    422424   
     
    427429                $use_php_methods = $total_size > 10 * $chunk_size; // Use PHP methods for large files
    428430   
    429                 $append_content = function($new_content) use ($filename, $wp_filesystem, $use_php_methods) {
     431                $append_content = function($new_content) use ($filepath, $wp_filesystem, $use_php_methods) {
    430432                    if ($use_php_methods) {
    431433                        //phpcs:ignore  -- Use PHP methods for large files
    432                         file_put_contents($filename, $new_content, FILE_APPEND);
     434                        file_put_contents($filepath, $new_content, FILE_APPEND);
    433435                    } else {
    434                         if (!$wp_filesystem->exists($filename)) {
    435                             $wp_filesystem->put_contents($filename, $new_content, FS_CHMOD_FILE);
     436                        if (!$wp_filesystem->exists($filepath)) {
     437                            $wp_filesystem->put_contents($filepath, $new_content, FS_CHMOD_FILE);
    436438                        } else {
    437                             $current_contents = $wp_filesystem->get_contents($filename);
     439                            $current_contents = $wp_filesystem->get_contents($filepath);
    438440                            if ($current_contents === false) {
    439441                                return false;
    440442                            }
    441443                            $updated_contents = $current_contents . $new_content;
    442                             $wp_filesystem->put_contents($filename, $updated_contents, FS_CHMOD_FILE);
     444                            $wp_filesystem->put_contents($filepath, $updated_contents, FS_CHMOD_FILE);
    443445                        }
    444446                    }
     
    574576                if (get_option('wp_db_backup_backup_type') == 'Database' || get_option('wp_db_backup_backup_type') == 'complete') {
    575577                    $filename = $FileName . '.sql';
    576                     $zip->addFile($path_info['basedir'] . '/db-backup/' . $filename, $filename);
     578                    //phpcs:ignore  -- check if file exists
     579                    if(file_exists( $path_info['basedir'] . '/db-backup/' . $filename )){
     580                        $zip->addFile($path_info['basedir'] . '/db-backup/' . $filename, $filename);
     581                    }
    577582                }
    578583                $zip->close();
     
    814819                        $index = $i;
    815820                        if ( isset($options[ $index ]['dir']) && file_exists( $options[ $index ]['dir'] ) ) {
    816                             unlink( $options[ $index ]['dir'] );
     821                            wp_delete_file( $options[ $index ]['dir'] );
    817822                        }
    818823                        $file_sql = explode( '.', $options[ $index ]['dir'] );
    819824                        if ( isset($file_sql[0]) && file_exists( $file_sql[0] . '.sql' ) ) {
    820                             unlink( $file_sql[0] . '.sql' );
     825                            wp_delete_file( $file_sql[0] . '.sql' );
    821826                        }
    822827                    }
     
    924929    }
    925930
     931    $new_options = wpdbbkp_filter_unique_filenames( $new_options );
     932
     933
    926934    update_option( 'wp_db_backup_backups', $new_options, false );
    927935
  • wp-database-backup/tags/6.12/includes/admin/mb-helper-functions.php

    r3124584 r3124649  
    268268    return $wp_filesystem->exists( $file );
    269269}
     270
     271/**
     272 * Filters an array of backup files to ensure only unique filenames are included.
     273 *
     274 * @param array $backups Array of backup files.
     275 * @return array Filtered array of backup files with unique filenames.
     276 */
     277function wpdbbkp_filter_unique_filenames( $backups ) {
     278    $unique_filenames = [];
     279    $filtered_backups = [];
     280
     281    if ( ! empty( $backups ) ) {
     282        foreach ( $backups as $backup ) {
     283            if ( isset( $backup['filename'] ) && ! in_array( $backup['filename'], $unique_filenames ) ) {
     284                $unique_filenames[] = $backup['filename'];
     285                $filtered_backups[] = $backup;
     286            }
     287        }
     288    }
     289
     290    return $filtered_backups;
     291}
     292
  • wp-database-backup/tags/6.12/includes/class-wpdbfullbackuplog.php

    r3124584 r3124649  
    3939        }
    4040
     41        $new_options = wpdbbkp_filter_unique_filenames( $new_options );
     42
    4143        // Update the options
    4244        update_option( 'wp_db_backup_backups', $new_options, false );
  • wp-database-backup/tags/6.12/readme.txt

    r3124584 r3124649  
    203203== Upgrade Notice ==
    204204* Sanitised multiple inputs and escape output to remove further risk of cross site script security.
     205
     206== Credits ==
     207
     208=== This plugin uses the following third-party libraries: ===
     209
     2101. === Google APIs Client Library for PHP ===
     211   - Author: Google
     212   - URL: https://github.com/googleapis/google-api-php-client
     213   - License: Apache License, Version 2.0 (the "License")
     214   - License URL: http://www.apache.org/licenses/LICENSE-2.0
     215
     2162. === PHP Secure Communications Library ===
     217   - Author: phpseclib
     218   - URL:https://github.com/phpseclib/phpseclib
     219   - License: MIT License (or any other applicable license)
     220   - License URL: http://opensource.org/licenses/MIT
     221
     2223. === PhpConcept Library - Zip Module ===
     223   - Author: Vincent Blavet
     224   - URL:http://www.phpconcept.net
     225   - License: License GNU/LGPL
     226
     2274. === phpFileTree ===
     228   - Author: Cory S.N. LaViska's
     229   - URL: https://www.abeautifulsite.net/blog/2007/06/php-file-tree/
Note: See TracChangeset for help on using the changeset viewer.