Plugin Directory

Changeset 1810499

Timestamp:
01/27/2018 04:34:00 PM (6 years ago)
Author:
filosofo
Message:

Update wp-db-backup to version 2.3.3

Location:
wp-db-backup
Files:
38 added
3 edited

Legend:

Unmodified
Added
Removed
  • wp-db-backup/trunk/README.markdown

    r1366331 r1810499 ��
    66Tags: mysql, database, backup, cron
    77Requires at least: 3.6.0
    8 Tested up to: 4.4.2
    9 Stable tag: 2.3.1
     8Tested up to: 4..2
     9Stable tag: 2.3.
    1010
    1111On-demand backup of your WordPress database.
    1212
    13 Description 
     13Description
    1414-----------
    1515
     
    2121              NO WARRANTY.
    2222
    23     Copyright (c) 2015 Austin Matzko
     23    Copyright (c) 201 Austin Matzko
    2424
    2525[Source Code on GitHub](https://github.com/matzko/wp-db-backup)
    2626
    27 Installation 
     27Installation
    2828------------
    2929
     
    105105When having the database backup emailed or sent to your browser for immediate download, the backup file will be _deleted_ from the server when the transfer is finished.
    106106
    107 Changelog 
     107Changelog
    108108---------
    109109
     
    117117* Do not attempt to delete non-existent files
    118118
    119 2.2.3 
     1192.2.3
    120120-----
    121121* Nonce check fix for localized WP users from Sergey Biryukov
     
    124124* Fix for JS multiple checkbox selection.
    125125
    126 Upgrade Notice
     1262.3.3
     127-----
     128* Sanitize user-supplied data
     129
     130Upgrade Notice
    127131--------------
    128132
    129 2.2.3 
     1332.2.3
    130134-----
    131135* Fixes problems users had when using localized WordPress installations.
    132136* Fixes a bug that caused the size of gzipped backup files to be reported incorrectly.
    133137
    134 Advanced 
     138Advanced
    135139--------
    136140If you are using WordPress version 2.1 or newer, you can schedule automated backups to be sent to the email address
    137141of your choice.
    138142
    139 Translators 
     143Translators
    140144-----------
    141145Thanks to following people for providing translation files for WP-DB-Backup:
     
    174178* 吴曦
    175179
    176 Past Contributors 
     180Past Contributors
    177181-----------------
    178182skippy, Firas, LaughingLizard, MtDewVirus, Podz, Ringmaster
  • wp-db-backup/trunk/readme.txt

    r1366331 r1810499  
    44Tags: mysql, database, backup, cron
    55Requires at least: 3.6.0
    6 Tested up to: 4.4.2
    7 Stable tag: 2.3.1
     6Tested up to: 4..2
     7Stable tag: 2.3.
    88
    99On-demand backup of your WordPress database.
     
    1818              NO WARRANTY.
    1919
    20     Copyright (c) 2016 Austin Matzko
     20    Copyright (c) 201 Austin Matzko
    2121
    2222[Source Code on GitHub](https://github.com/matzko/wp-db-backup)
     
    26261. Activate the plugin at your blog's Admin -> Plugins screen
    27271. The plugin will attempt to create a directory /wp-content/backup-*/ inside your WordPress directory.
    28 1. You may need to make /wp-content writable (at least temporarily) for it to create this directory. 
     281. You may need to make /wp-content writable (at least temporarily) for it to create this directory.
    2929   For example:
    3030   `$ cd /wordpress/`
     
    8888prefix = the table prefix for this WordPress blog, as defined in wp-config.php
    8989date = CCYYmmdd_B format:  20050711_039
    90        the "B" is the internet "Swatch" time. 
     90       the "B" is the internet "Swatch" time.
    9191       See the PHP date() function for details.
    9292
     
    102102* Do not attempt to delete non-existent files
    103103
    104 = 2.2.3 = 
     104= 2.2.3 =
    105105* Nonce check fix for localized WP users from Sergey Biryukov
    106106* Fix for gzipped files' incorrect size.
     
    114114* Fixes a bug that caused the size of gzipped backup files to be reported incorrectly.
    115115
     116
     117
     118
    116119== Advanced ==
    117 If you are using WordPress version 2.1 or newer, you can schedule automated backups to be sent to the email address 
     120If you are using WordPress version 2.1 or newer, you can schedule automated backups to be sent to the email address
    118121of your choice.
    119122
  • wp-db-backup/trunk/wp-db-backup.php

    r1366331 r1810499  
    44Plugin URI: https://github.com/matzko/wp-db-backup
    55Description: On-demand backup of your WordPress database. Navigate to <a href="edit.php?page=wp-db-backup">Tools &rarr; Backup</a> to get started.
    6 Author: Austin Matzko 
     6Author: Austin Matzko
    77Author URI: http://austinmatzko.com/
    8 Version: 2.3.1
    9 
    10 Copyright 2016  Austin Matzko  (email : austin at pressedcode.com)
     8Version: 2.3.
     9
     10Copyright 201  Austin Matzko  (email : austin at pressedcode.com)
    1111
    1212    This program is free software; you can redistribute it and/or modify
     
    3838}
    3939
    40 /** 
    41  * Set MOD_EVASIVE_OVERRIDE to true 
    42  * and increase MOD_EVASIVE_DELAY 
     40/**
     41 * Set MOD_EVASIVE_OVERRIDE to true
     42 * and increase MOD_EVASIVE_DELAY
    4343 * if the backup stops prematurely.
    4444 */
     
    5858    var $page_url;
    5959    var $referer_check_key;
    60     var $version = '2.1.5-alpha';
     60    var $version = '2.';
    6161
    6262    function module_check() {
     
    6464        if ( defined( 'MOD_EVASIVE_OVERRIDE' ) && true === MOD_EVASIVE_OVERRIDE ) return true;
    6565        if ( ! defined( 'MOD_EVASIVE_OVERRIDE' ) || false === MOD_EVASIVE_OVERRIDE ) return false;
    66         if ( function_exists('apache_get_modules') ) 
    67             foreach( (array) apache_get_modules() as $mod ) 
     66        if ( function_exists('apache_get_modules') )
     67            foreach( (array) apache_get_modules() as $mod )
    6868                if ( false !== strpos($mod,'mod_evasive') || false !== strpos($mod,'mod_dosevasive') )
    6969                    return true;
     
    7171    }
    7272
    73     function wpdbBackup() {
     73    function () {
    7474        global $table_prefix, $wpdb;
    7575        add_action('wp_ajax_save_backup_time', array(&$this, 'save_backup_time'));
     
    8181        add_filter('cron_schedules', array(&$this, 'add_sched_options'));
    8282        add_filter('wp_db_b_schedule_choices', array(&$this, 'schedule_choices'));
    83        
     83
    8484        $table_prefix = ( isset( $table_prefix ) ) ? $table_prefix : $wpdb->prefix;
    8585        $datum = date("Ymd_B");
     
    109109            }
    110110        }
    111    
    112         $this->backup_dir = trailingslashit(apply_filters('wp_db_b_backup_dir', (isset($_GET['wp_db_temp_dir']) && is_writable($_GET['wp_db_temp_dir'])) ? $_GET['wp_db_temp_dir'] : get_temp_dir()));
     111
     112        $requested_temp_dir = sanitize_text_field($_GET['wp_db_temp_dir']);
     113        $this->backup_dir = trailingslashit(apply_filters('wp_db_b_backup_dir', (isset($requested_temp_dir) && is_writable($requested_temp_dir)) ? $requested_temp_dir : get_temp_dir()));
    113114        $this->basename = 'wp-db-backup';
    114    
     115
    115116        $this->referer_check_key = $this->basename . '-download_' . DB_NAME;
    116117        if (isset($_POST['do_backup'])) {
     
    118119            check_admin_referer($this->referer_check_key);
    119120            $this->can_user_backup('main');
     121
    120122            // save exclude prefs
    121 
    122             $exc_revisions = isset( $_POST['exclude-revisions'] ) ? (array) $_POST['exclude-revisions'] : array();
    123             $exc_spam = isset( $_POST['exclude-spam'] ) ? (array) $_POST['exclude-spam'] : array();
    124             update_option('wp_db_backup_excs', array('revisions' => $exc_revisions, 'spam' => $exc_spam));
     123            update_option('wp_db_backup_excs', array(
     124           
     125           
     126            ));
    125127            switch($_POST['do_backup']) {
    126128            case 'backup':
     
    129131            case 'fragments':
    130132                add_action('admin_menu', array(&$this, 'fragment_menu'));
    131                 break;             
     133                break;
    132134            }
    133135        } elseif (isset($_GET['fragment'] )) {
     
    141143        }
    142144    }
    143    
     145
    144146    function init() {
    145147        $this->can_user_backup();
    146148        if (isset($_GET['backup'])) {
    147             $via = isset($_GET['via']) ? $_GET['via'] : 'http';
    148            
    149             $this->backup_file = $_GET['backup'];
     149            $via = isset($_GET['via']) ? : 'http';
     150
     151            $this->backup_file = ;
    150152            $this->validate_file($this->backup_file);
    151153
     
    153155            case 'smtp':
    154156            case 'email':
    155                 $success = $this->deliver_backup($this->backup_file, 'smtp', $_GET['recipient'], 'frame');
     157                $success = $this->deliver_backup($this->backup_file, 'smtp', , 'frame');
    156158                $this->error_display( 'frame' );
    157159                if ( $success ) {
     
    162164                    echo '
    163165                        alert("' . __('Backup Complete!','wp-db-backup') . '");
    164                         window.onbeforeunload = null; 
     166                        window.onbeforeunload = null;
    165167                        </script>
    166168                    ';
     
    170172                $success = $this->deliver_backup($this->backup_file, $via);
    171173                echo $this->error_display( 'frame', false );
    172                
     174
    173175                if ( $success ) {
    174176                    echo '
     
    182184        }
    183185        if (isset($_GET['fragment'] )) {
    184             list($table, $segment, $filename) = explode(':', $_GET['fragment']);
     186            list($table, $segment, $filename) = explode(':', );
    185187            $this->validate_file($filename);
    186188            $this->backup_fragment($table, $segment, $filename);
     
    207209    function update_notice_action() {
    208210        global $pagenow;
    209         if ( 
     211        if (
    210212            (
    211213                isset($_REQUEST['action'])
     
    220222        endif;
    221223    }
    222    
     224
    223225    function update_notice($text = '') {
    224226        $pattern = '#(<a href\="' . __('http://codex.wordpress.org/WordPress_Backups') . '">.*?</p>)#';
    225         $replace = '$1' . "\n<p>" . sprintf(__('Click <a href="%s" target="_blank">here</a> to back up your database using the WordPress Database Backup plugin. <strong>Note:</strong> WordPress Database Backup does <em>not</em> back up your files, just your database.', 'wp-db-backup'), 'tools.php?page=wp-db-backup') . "</p>\n"; 
     227        $replace = '$1' . "\n<p>" . sprintf(__('Click <a href="%s" target="_blank">here</a> to back up your database using the WordPress Database Backup plugin. <strong>Note:</strong> WordPress Database Backup does <em>not</em> back up your files, just your database.', 'wp-db-backup'), 'tools.php?page=wp-db-backup') . "</p>\n";
    226228        $text = preg_replace($pattern, $replace, $text);
    227229        return $text;
     
    230232    function build_backup_script() {
    231233        global $table_prefix, $wpdb;
    232    
     234
    233235        echo "<div class='wrap'>";
    234         echo    '<fieldset class="options"><legend>' . __('Progress','wp-db-backup') . '</legend>
     236        echo '<fieldset class="options"><legend>' . __('Progress','wp-db-backup') . '</legend>
    235237            <p><strong>' .
    236238                __('DO NOT DO THE FOLLOWING AS IT WILL CAUSE YOUR BACKUP TO FAIL:','wp-db-backup').
     
    270272                fram.src = "' . $this->page_url . '&fragment=" + table + ":" + segment + ":' . $this->backup_filename . ':&wp_db_temp_dir=' . $this->backup_dir . '";
    271273            }
    272            
     274
    273275            var curStep = 0;
    274            
     276
    275277            function nextStep() {
    276278                backupStep(curStep);
    277279                curStep++;
    278280            }
    279            
     281
    280282            function finishBackup() {
    281                 var fram = document.getElementById("backuploader");             
     283                var fram = document.getElementById("backuploader");
    282284                setMeter(100);
    283285        ';
     
    288290            echo '
    289291                setProgress("' . __('Preparing download.','wp-db-backup') . '");
    290                 window.onbeforeunload = null; 
     292                window.onbeforeunload = null;
    291293                fram.src = "' . $download_uri . '";
    292                
     294
    293295                setTimeout( function() {
    294                     var secondFrame = document.createElement("iframe");             
     296                    var secondFrame = document.createElement("iframe");
    295297                    fram.parentNode.insertBefore(secondFrame, fram);
    296298                    secondFrame.src = "' . $download_uri . '&download-retry=1";
     
    305307            echo '
    306308                setProgress("' . sprintf(__('Your backup has been emailed to %s','wp-db-backup'), $email) . '");
    307                 window.onbeforeunload = null; 
     309                window.onbeforeunload = null;
    308310                fram.src = "' . $download_uri . '&via=email&recipient=' . $email . '";
    309311            ';
     
    312314            echo '
    313315                setProgress("' . __('Backup Complete!','wp-db-backup') . '");
    314                 window.onbeforeunload = null; 
     316                window.onbeforeunload = null;
    315317            ';
    316318        }
    317        
     319
    318320        echo '
    319321            }
    320            
     322
    321323            function backupStep(step) {
    322324                switch(step) {
    323325                case 0: backup("", 0); break;
    324326        ';
    325        
    326         $also_backup = array();
    327         if (isset($_POST['other_tables'])) {
    328             $also_backup = $_POST['other_tables'];
    329         } else {
    330             $also_backup = array();
    331         }
    332         $core_tables = $_POST['core_tables'];
     327
     328        $also_backup = $this->get_post_data_array('other_tables');
     329        $core_tables = $this->get_post_data_array('core_tables');
    333330        $tables = array_merge($core_tables, $also_backup);
    334331        $step_count = 1;
     
    351348        }
    352349        echo "case {$step_count}: finishBackup(); break;";
    353        
     350
    354351        echo '
    355352                }
     
    367364    function backup_fragment($table, $segment, $filename) {
    368365        global $table_prefix, $wpdb;
    369            
     366
    370367        echo "$table:$segment:$filename";
    371        
     368
    372369        if($table == '') {
    373370            $msg = __('Creating backup file...','wp-db-backup');
     
    379376            }
    380377        }
    381        
     378
    382379        if (is_writable($this->backup_dir)) {
    383380            $this->fp = $this->open($this->backup_dir . $filename, 'a');
     
    387384            }
    388385            else {
    389                 if($table == '') {     
     386                if($table == '') {
    390387                    //Begin new backup of MySql
    391388                    $this->stow("# " . __('WordPress MySQL database backup','wp-db-backup') . "\n");
     
    403400                        $this->stow("# " . sprintf(__('Table: %s','wp-db-backup'),$this->backquote($table)) . "\n");
    404401                        $this->stow("# --------------------------------------------------------\n");
    405                     }           
     402                    }
    406403                    $this->backup_table($table, $segment);
    407404                }
     
    412409
    413410        if($this->fp) $this->close($this->fp);
    414        
     411
    415412        $this->error_display('frame');
    416413
     
    428425        $also_backup = array();
    429426        if (isset($_POST['other_tables']))
    430             $also_backup = $_POST['other_tables'];
    431         $core_tables = $_POST['core_tables'];
     427            $also_backup = ;
     428        $core_tables = ;
    432429        $this->backup_file = $this->db_backup($core_tables, $also_backup);
    433430        if (false !== $this->backup_file) {
    434431            if ('smtp' == $_POST['deliver']) {
    435432                $email = sanitize_text_field(wp_unslash($_POST['backup_recipient']));
    436                 $this->deliver_backup($this->backup_file, $_POST['deliver'], $email, 'main');
     433                $this->deliver_backup($this->backup_file, , $email, 'main');
    437434                if ( get_option('wpdb_backup_recip') != $email ) {
    438435                    update_option('wpdb_backup_recip', $email );
     
    441438            } elseif ('http' == $_POST['deliver']) {
    442439                $download_uri = add_query_arg('backup',$this->backup_file,$this->page_url);
    443                 wp_redirect($download_uri); 
     440                wp_redirect($download_uri);
    444441                exit;
    445442            }
     
    478475                            t[k].p[i].onkeyup = t[k].p[i].onclick = function(e) {
    479476                                e = e ? e : event;
    480                                 if ( 16  == e.keyCode ) 
     477                                if ( 16  == e.keyCode )
    481478                                    return;
    482479                                var match = /([\w-]*)-table-(\d*)/.exec(this.id);
     
    498495
    499496                <?php if ( function_exists('wp_schedule_event') ) : // needs to be at least WP 2.1 for ajax ?>
    500                 if ( 'undefined' == typeof XMLHttpRequest ) 
     497                if ( 'undefined' == typeof XMLHttpRequest )
    501498                    var xml = new ActiveXObject( navigator.userAgent.indexOf('MSIE 5') >= 0 ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP' );
    502499                else
     
    507504                    var backupTime = document.getElementById('next-backup-time');
    508505                    if ( !! timeWrap && !! backupTime && ( 1 == <?php
    509                         echo (int) ( 'en' == strtolower( substr( get_locale(), 0, 2 ) ) ); 
     506                        echo (int) ( 'en' == strtolower( substr( get_locale(), 0, 2 ) ) );
    510507                    ?> ) ) {
    511508                        var span = document.createElement('span');
     
    529526                        saveTButton.onclick = function(e) { saveTime(backupTime, mainText); return false; };
    530527                    if ( !! mainText )
    531                         mainText.onkeydown = function(e) { 
     528                        mainText.onkeydown = function(e) {
    532529                            e = e || window.event;
    533530                            if ( 13 == e.keyCode ) {
     
    591588                    padding: 1em;
    592589                }
    593        
     590
    594591                fieldset.options .instructions {
    595592                    font-size: smaller;
     
    607604                }
    608605        </style>
    609         <?php 
     606        <?php
    610607    }
    611608
     
    637634    }
    638635
    639     /** 
     636    /**
    640637     * Add WP-DB-Backup-specific help options to the 2.7 =< WP contextual help menu
    641638     * @return string The text of the help menu.
     
    673670        else $a_string = str_replace('\\', '\\\\', $a_string);
    674671        return str_replace('\'', '\\\'', $a_string);
    675     } 
     672    }
    676673
    677674    /**
     
    684681                $result = array();
    685682                reset($a_name);
    686                 while(list($key, $val) = each($a_name)) 
     683                while(list($key, $val) = each($a_name))
    687684                    $result[$key] = '`' . $val . '`';
    688685                return $result;
     
    693690            return $a_name;
    694691        }
    695     } 
     692    }
    696693
    697694    function open($filename = '', $mode = 'w') {
     
    714711            $this->error(__('There was an error writing a line to the backup script:','wp-db-backup') . '  ' . $query_line . '  ' . $php_errormsg);
    715712    }
    716    
     713
    717714    /**
    718715     * Logs any error messages
     
    721718     */
    722719    function error($args = array()) {
    723         if ( is_string( $args ) ) 
     720        if ( is_string( $args ) )
    724721            $args = array('msg' => $args);
    725722        $args = array_merge( array('loc' => 'main', 'kind' => 'warn', 'msg' => ''), $args);
     
    731728
    732729    /**
    733      * Displays error messages 
     730     * Displays error messages
    734731     * @param array $errs
    735732     * @param string $loc
     
    747744            $err_list[9] = __('Subsequent errors have been omitted from this log.','wp-db-backup');
    748745        $wrap = ( 'frame' == $loc ) ? "<script type=\"text/javascript\">\n var msgList = ''; \n %1\$s \n if ( msgList ) alert(msgList); \n </script>" : '%1$s';
    749         $line = ( 'frame' == $loc ) ? 
     746        $line = ( 'frame' == $loc ) ?
    750747            "try{ window.parent.addError('%1\$s'); } catch(e) { msgList += ' %1\$s';}\n" :
    751748            "%1\$s<br />\n";
     
    767764     * Alain Wolf, Zurich - Switzerland
    768765     * Website: http://restkultur.ch/personal/wolf/scripts/db_backup/
    769    
    770      * Modified by Scott Merrill (http://www.skippy.net/) 
     766
     767     * Modified by Scott Merrill (http://www.skippy.net/)
    771768     * to use the WordPress $wpdb object
    772769     * @param string $table
     
    782779            return false;
    783780        }
    784    
     781
    785782        if(($segment == 'none') || ($segment == 0)) {
    786783            // Add SQL statement to drop existing table
     
    791788            $this->stow("\n");
    792789            $this->stow("DROP TABLE IF EXISTS " . $this->backquote($table) . ";\n");
    793            
     790
    794791            // Table structure
    795792            // Comment in SQL-file
     
    799796            $this->stow("#\n");
    800797            $this->stow("\n");
    801            
     798
    802799            $create_table = $wpdb->get_results("SHOW CREATE TABLE $table", ARRAY_N);
    803800            if (false === $create_table) {
     
    807804            }
    808805            $this->stow($create_table[0][1] . ' ;');
    809            
     806
    810807            if (false === $table_structure) {
    811808                $err_msg = sprintf(__('Error getting table structure of %s','wp-db-backup'), $table);
     
    813810                $this->stow("#\n# $err_msg\n#\n");
    814811            }
    815        
     812
    816813            // Comment in SQL-file
    817814            $this->stow("\n\n");
     
    820817            $this->stow("#\n");
    821818        }
    822        
     819
    823820        if(($segment == 'none') || ($segment >= 0)) {
    824821            $defs = array();
     
    834831                }
    835832            }
    836            
    837            
     833
     834
    838835            // Batch by $row_inc
    839            
     836
    840837            if($segment == 'none') {
    841838                $row_start = 0;
     
    845842                $row_inc = ROWS_PER_SEGMENT;
    846843            }
    847            
    848             do {   
     844
     845            do {
    849846                // don't include extra stuff, if so requested
    850847                $excs = (array) get_option('wp_db_backup_excs');
     
    855852                    $where = ' WHERE post_type != "revision"';
    856853                }
    857                
     854
    858855                if ( !ini_get('safe_mode')) @set_time_limit(15*60);
    859856                $table_data = $wpdb->get_results("SELECT * FROM $table $where LIMIT {$row_start}, {$row_inc}", ARRAY_A);
    860857
    861                 $entries = 'INSERT INTO ' . $this->backquote($table) . ' VALUES ('; 
     858                $entries = 'INSERT INTO ' . $this->backquote($table) . ' VALUES (';
    862859                //    \x08\\x09, not required
    863860                $search = array("\x00", "\x0a", "\x0d", "\x1a");
     
    882879            } while((count($table_data) > 0) and ($segment=='none'));
    883880        }
    884        
     881
    885882        if(($segment == 'none') || ($segment < 0)) {
    886883            // Create footer/closing comment in SQL-file
     
    892889        }
    893890    } // end backup_table()
    894    
     891
    895892    function db_backup($core_tables, $other_tables) {
    896893        global $table_prefix, $wpdb;
    897        
     894
    898895        if (is_writable($this->backup_dir)) {
    899896            $this->fp = $this->open($this->backup_dir . $this->backup_filename);
     
    906903            return false;
    907904        }
    908        
     905
    909906        //Begin new backup of MySql
    910907        $this->stow("# " . __('WordPress MySQL database backup','wp-db-backup') . "\n");
     
    914911        $this->stow("# " . sprintf(__('Database: %s','wp-db-backup'),$this->backquote(DB_NAME)) . "\n");
    915912        $this->stow("# --------------------------------------------------------\n");
    916        
     913
    917914            if ( (is_array($other_tables)) && (count($other_tables) > 0) )
    918915            $tables = array_merge($core_tables, $other_tables);
    919916        else
    920917            $tables = $core_tables;
    921        
     918
    922919        foreach ($tables as $table) {
    923920            // Increase script execution time-limit to 15 min for every table.
     
    929926            $this->backup_table($table);
    930927        }
    931                
     928
    932929        $this->close($this->fp);
    933        
     930
    934931        if (count($this->errors)) {
    935932            return false;
     
    937934            return $this->backup_filename;
    938935        }
    939        
     936
    940937    } //wp_db_backup
    941938
     
    965962        // try to use phpmailer directly (WP 2.2+)
    966963        if ( is_object( $phpmailer ) && ( strtolower(get_class( $phpmailer )) == 'phpmailer' ) ) {
    967            
     964
    968965            // Get the site domain and get rid of www.
    969             $sitename = strtolower( $_SERVER['SERVER_NAME'] );
    970             if ( substr( $sitename, 0, 4 ) == 'www.' ) {
    971                 $sitename = substr( $sitename, 4 );
    972             }
     966            $sitename = $this->get_sitename();
    973967            $from_email = 'wordpress@' . $sitename;
    974968            $from_name = 'WordPress';
     
    993987
    994988            do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
    995            
     989
    996990            $result = @$phpmailer->Send();
    997991
     
    1001995            $boundary = "==WPBACKUP-$randomish";
    1002996            $fp = fopen($diskfile,"rb");
    1003             $file = fread($fp,filesize($diskfile)); 
     997            $file = fread($fp,filesize($diskfile));
    1004998            $this->close($fp);
    1005            
     999
    10061000            $data = chunk_split(base64_encode($file));
    1007            
     1001
    10081002            $headers .= "MIME-Version: 1.0\n";
    1009             $headers = 'From: wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])) . "\n";
     1003            $headers = 'From: wordpress@' . preg_replace('#^www\.#', '', s)) . "\n";
    10101004            $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\n";
    1011        
     1005
    10121006            // Add a multipart boundary above the plain message
    10131007            $message = "This is a multi-part message in MIME format.\n\n" .
    1014                     "--{$boundary}\n" .
     1008            "--{$boundary}\n" .
    10151009                "Content-Type: text/plain; charset=\"" . get_bloginfo('charset') . "\"\n" .
    10161010                "Content-Transfer-Encoding: 7bit\n\n" .
     
    10261020                $data . "\n\n" .
    10271021                "--{$boundary}--\n";
    1028            
     1022
    10291023            $result = @wp_mail($to, $subject, $message, $headers);
    10301024        }
     
    10351029    function deliver_backup($filename = '', $delivery = 'http', $recipient = '', $location = 'main') {
    10361030        if ('' == $filename) { return false; }
    1037        
     1031
    10381032        $diskfile = $this->backup_dir . $filename;
    10391033        $gz_diskfile = "{$diskfile}.gz";
     
    10601054                $diskfile = $gz_diskfile;
    10611055                $filename = "{$filename}.gz";
    1062            
     1056
    10631057            /**
    1064              * Try to compress to gzip, if available 
     1058             * Try to compress to gzip, if available
    10651059             */
    10661060            } else {
     
    10821076            }
    10831077            /*
    1084              * 
     1078             *
    10851079             */
    10861080        } elseif ( file_exists( $gz_diskfile ) && empty( $_GET['download-retry'] ) ) {
     
    10911085        if ('http' == $delivery) {
    10921086            if ( ! file_exists( $diskfile ) ) {
    1093                 if ( empty( $_GET['download-retry'] ) ) { 
     1087                if ( empty( $_GET['download-retry'] ) ) {
    10941088                    $this->error(array('kind' => 'fatal', 'msg' => sprintf(__('File not found:%s','wp-db-backup'), "&nbsp;<strong>$filename</strong><br />") . '<br /><a href="' . $this->page_url . '">' . __('Return to Backup','wp-db-backup') . '</a>'));
    10951089                } else {
     
    11241118                    $msg .= $err['message'];
    11251119                } else {
    1126                     $msg .= __('ERROR: The mail application has failed to deliver the backup.','wp-db-backup'); 
     1120                    $msg .= __('ERROR: The mail application has failed to deliver the backup.','wp-db-backup');
    11271121                }
    11281122                $this->error(array('kind' => 'fatal', 'loc' => $location, 'msg' => $msg));
     
    11351129        return $success;
    11361130    }
    1137    
     1131
    11381132    function backup_menu() {
    11391133        global $table_prefix, $wpdb;
    11401134        $feedback = '';
    11411135        $whoops = false;
    1142        
     1136
    11431137        // did we just do a backup?  If so, let's report the status
    11441138        if ( $this->backup_complete ) {
     
    11611155            $feedback .= '</p></div>';
    11621156        }
    1163    
     1157
    11641158        // security check
    1165         $this->wp_secure(); 
     1159        $this->wp_secure();
    11661160
    11671161        if (count($this->errors)) {
     
    11721166
    11731167        // did we just save options for wp-cron?
    1174         if ( (function_exists('wp_schedule_event') || function_exists('wp_cron_init')) 
     1168        if ( (function_exists('wp_schedule_event') || function_exists('wp_cron_init'))
    11751169            && isset($_POST['wp_cron_backup_options']) ) :
    11761170            do_action('wp_db_b_update_cron_options');
     
    11781172                wp_clear_scheduled_hook( 'wp_db_backup_cron' ); // unschedule previous
    11791173                $scheds = (array) wp_get_schedules();
    1180                 $name = strval($_POST['wp_cron_schedule']);
    1181                 $interval = ( isset($scheds[$name]['interval']) ) ? 
     1174                $name = s);
     1175                $interval = ( isset($scheds[$name]['interval']) ) ?
    11821176                    (int) $scheds[$name]['interval'] : 0;
    11831177                update_option('wp_cron_backup_schedule', $name, false);
     
    11891183                update_option('wp_cron_backup_schedule', intval($_POST['cron_schedule']), false);
    11901184            }
    1191             update_option('wp_cron_backup_tables', isset( $_POST['wp_cron_backup_tables'] ) ? $_POST['wp_cron_backup_tables'] : array() );
     1185            update_option('wp_cron_backup_tables', );
    11921186            if (is_email($_POST['cron_backup_recipient'])) {
    1193                 update_option('wp_cron_backup_recipient', $_POST['cron_backup_recipient'], false);
     1187                update_option('wp_cron_backup_recipient', , false);
    11941188            }
    11951189            $feedback .= '<div class="updated wp-db-backup-updated"><p>' . __('Scheduled Backup Options Saved!','wp-db-backup') . '</p></div>';
    11961190        endif;
    1197        
     1191
    11981192        $other_tables = array();
    11991193        $also_backup = array();
    1200    
    1201         // Get complete db table list   
     1194
     1195        // Get complete db table list
    12021196        $all_tables = $wpdb->get_results("SHOW TABLES", ARRAY_N);
    12031197        $all_tables = array_map(create_function('$a', 'return $a[0];'), $all_tables);
     
    12061200        // Get list of non-WP tables
    12071201        $other_tables = array_diff($all_tables, $wp_backup_default_tables);
    1208        
     1202
    12091203        if ('' != $feedback)
    12101204            echo $feedback;
    12111205
    1212         if ( ! $this->wp_secure() )     
     1206        if ( ! $this->wp_secure() )
    12131207            return;
    12141208
     
    12271221            ?><div class="updated wp-db-backup-updated error"><p><?php _e('WARNING: Your backup directory is <strong>NOT</strong> writable! We cannot create the backup files.','wp-db-backup'); ?></p>
    12281222            <p><?php printf(__('Using your FTP client, try to set the backup directory&rsquo;s write permission to %1$s or %2$s: %3$s', 'wp-db-backup'), '<code>777</code>', '<code>a+w</code>', '<code>' . $this->backup_dir . '</code>'); ?>
    1229             </p></div><?php 
     1223            </p></div><?php
    12301224            $whoops = true;
    12311225        } else {
    12321226            $this->fp = $this->open($this->backup_dir . 'test' );
    1233             if( $this->fp ) { 
     1227            if( $this->fp ) {
    12341228                $this->close($this->fp);
    12351229                @unlink($this->backup_dir . 'test' );
    12361230            // the directory is not writable probably due to safe mode
    12371231            } else {
    1238                 ?><div class="updated wp-db-backup-updated error"><p><?php _e('WARNING: Your backup directory is <strong>NOT</strong> writable! We cannot create the backup files.','wp-db-backup'); ?></p><?php 
     1232                ?><div class="updated wp-db-backup-updated error"><p><?php _e('WARNING: Your backup directory is <strong>NOT</strong> writable! We cannot create the backup files.','wp-db-backup'); ?></p><?php
    12391233                if( ini_get('safe_mode') ){
    1240                     ?><p><?php _e('This problem seems to be caused by your server&rsquo;s <code>safe_mode</code> file ownership restrictions, which limit what files web applications like WordPress can create.', 'wp-db-backup'); ?></p><?php 
     1234                    ?><p><?php _e('This problem seems to be caused by your server&rsquo;s <code>safe_mode</code> file ownership restrictions, which limit what files web applications like WordPress can create.', 'wp-db-backup'); ?></p><?php
    12411235                }
    12421236                ?><?php printf(__('You can try to correct this problem by using your FTP client to delete and then re-create the backup directory: %s', 'wp-db-backup'), '<code>' . $this->backup_dir . '</code>');
    1243                 ?></div><?php 
     1237                ?></div><?php
    12441238                $whoops = true;
    12451239            }
    12461240        }
    12471241
    1248        
     1242
    12491243
    12501244        if ( !file_exists($this->backup_dir . 'index.php') )
     
    12721266        </div>
    12731267        <div class="tables-list extra-tables" id="extra-tables-list">
    1274         <?php 
    1275         if (count($other_tables) > 0) { 
     1268        <?php
     1269        if (count($other_tables) > 0) {
    12761270            ?>
    12771271            <h4><?php _e('You may choose to include any of the following tables:','wp-db-backup'); ?></h4>
     
    12811275                ?>
    12821276                <li><label><input type="checkbox" name="other_tables[]" value="<?php echo $table; ?>" /> <code><?php echo $table; ?></code></label>
    1283                 <?php 
    1284             }
    1285             ?></ul><?php 
     1277                <?php
     1278            }
     1279            ?></ul><?php
    12861280        }
    12871281        ?></div>
    12881282        </fieldset>
    1289        
     1283
    12901284        <fieldset class="options">
    12911285            <legend><?php _e('Backup Options','wp-db-backup'); ?></legend>
     
    12991293                <input type="radio" name="deliver" id="do_email" value="smtp" style="border:none;" />
    13001294                <?php _e('Email backup to:','wp-db-backup'); ?>
    1301                 <input type="text" name="backup_recipient" size="20" value="<?php 
     1295                <input type="text" name="backup_recipient" size="20" value="<?php
    13021296                    $backup_recip = get_option('wpdb_backup_recip');
    13031297                    if ( empty( $backup_recip ) ) {
     
    13091303            </ul>
    13101304            <?php if ( ! $whoops ) : ?>
    1311             <input type="hidden" name="do_backup" id="do_backup" value="backup" /> 
     1305            <input type="hidden" name="do_backup" id="do_backup" value="backup" />
    13121306            <p class="submit">
    13131307                <input type="submit" name="submit" onclick="document.getElementById('do_backup').value='fragments';" value="<?php _e('Backup now!','wp-db-backup'); ?>" />
     
    13191313        <?php do_action('wp_db_b_backup_opts'); ?>
    13201314        </form>
    1321        
     1315
    13221316        <?php
    1323         // this stuff only displays if some sort of wp-cron is available 
     1317        // this stuff only displays if some sort of wp-cron is available
    13241318        $cron = ( function_exists('wp_schedule_event') ) ? true : false; // wp-cron in WP 2.1+
    13251319        $cron_old = ( function_exists('wp_cron_init') && ! $cron ) ? true : false; // wp-cron plugin by Skippy
     
    13341328                    <?php printf(__('Next Backup: %s','wp-db-backup'), '<span id="next-backup-time">' . gmdate($datetime, $next_cron + (get_option('gmt_offset') * 3600)) . '</span>'); ?>
    13351329                    </p>
    1336                     <?php 
     1330                    <?php
    13371331                endif;
    13381332            elseif ( $cron_old ) :
    1339                 ?><p><?php printf(__('Last WP-Cron Daily Execution: %s','wp-db-backup'), gmdate($datetime, get_option('wp_cron_daily_lastrun') + (get_option('gmt_offset') * 3600))); ?><br /><?php 
    1340                 printf(__('Next WP-Cron Daily Execution: %s','wp-db-backup'), gmdate($datetime, (get_option('wp_cron_daily_lastrun') + (get_option('gmt_offset') * 3600) + 86400))); ?></p><?php 
     1333                ?><p><?php printf(__('Last WP-Cron Daily Execution: %s','wp-db-backup'), gmdate($datetime, get_option('wp_cron_daily_lastrun') + (get_option('gmt_offset') * 3600))); ?><br /><?php
     1334                printf(__('Next WP-Cron Daily Execution: %s','wp-db-backup'), gmdate($datetime, (get_option('wp_cron_daily_lastrun') + (get_option('gmt_offset') * 3600) + 86400))); ?></p><?php
    13411335            endif;
    13421336            ?><form method="post" action="">
     
    13441338            <div class="tables-list">
    13451339            <h4><?php _e('Schedule: ','wp-db-backup'); ?></h4>
    1346             <?php 
     1340            <?php
    13471341            if ( $cron_old ) :
    13481342                $wp_cron_backup_schedule = get_option('wp_cron_backup_schedule');
     
    13851379            echo '</fieldset>';
    13861380        endif; // end of wp_cron (legacy) section
    1387        
     1381
    13881382        echo '</div><!-- .wrap -->';
    1389        
     1383
    13901384    } // end wp_backup_menu()
    13911385
    13921386    function get_sched() {
    13931387        $options = array_keys( (array) wp_get_schedules() );
    1394         $freq = get_option('wp_cron_backup_schedule'); 
     1388        $freq = get_option('wp_cron_backup_schedule');
    13951389        $freq = ( in_array( $freq , $options ) ) ? $freq : 'never';
    13961390        return $freq;
     
    14221416        return $menu;
    14231417    } // end schedule_choices()
    1424    
     1418
    14251419    function wp_cron_daily() { // for legacy cron plugin
    14261420        $schedule = intval(get_option('wp_cron_backup_schedule'));
     
    14291423                return;
    14301424        else return $this->cron_backup();
    1431     } 
     1425    }
    14321426
    14331427    function cron_backup() {
     
    14391433        $recipient = get_option('wp_cron_backup_recipient');
    14401434        $backup_file = $this->db_backup($core_tables, $other_tables);
    1441         if (false !== $backup_file) 
     1435        if (false !== $backup_file)
    14421436            return $this->deliver_backup($backup_file, 'smtp', $recipient, 'main');
    14431437        else return false;
     
    14501444
    14511445    /**
    1452      * Checks that WordPress has sufficient security measures 
     1446     * Checks that WordPress has sufficient security measures
    14531447     * @param string $kind
    14541448     * @return bool
     
    14751469        if ( ( $this->wp_secure('fatal', $loc) ) && current_user_can('import') )
    14761470            $can = $this->verify_nonce($_REQUEST['_wpnonce'], $this->referer_check_key, $loc);
    1477         if ( false == $can ) 
     1471        if ( false == $can )
    14781472            $this->error(array('loc' => $loc, 'kind' => 'fatal', 'msg' => __('You are not allowed to perform backups.','wp-db-backup')));
    14791473        return $can;
     
    14901484        if ( wp_verify_nonce($rec, $nonce) )
    14911485            return true;
    1492         else 
     1486        else
    14931487            $this->error(array('loc' => $loc, 'kind' => 'fatal', 'msg' => sprintf(__('There appears to be an unauthorized attempt from this site to access your database located at %1s.  The attempt has been halted.','wp-db-backup'),get_option('home'))));
    14941488    }
    14951489
    14961490    /**
    1497      * Check whether a file to be downloaded is 
     1491     * Check whether a file to be downloaded is
    14981492     * surreptitiously trying to download a non-backup file
    14991493     * @param string $file
    15001494     * @return null
    1501      */ 
     1495     */
    15021496    function validate_file($file) {
    15031497        if ( (false !== strpos($file, '..')) || (false !== strpos($file, './')) || (':' == substr($file, 1, 1)) )
     
    15051499    }
    15061500
     1501
     1502
     1503
     1504
     1505
     1506
     1507
     1508
     1509
     1510
     1511
     1512
     1513
     1514
     1515
     1516
     1517
     1518
     1519
     1520
     1521
     1522
     1523
     1524
     1525
     1526
     1527
     1528
     1529
     1530
     1531
     1532
     1533
     1534
     1535
     1536
     1537
     1538
     1539
     1540
     1541
     1542
     1543
     1544
     1545
     1546
     1547
     1548
     1549
     1550
     1551
     1552
     1553
     1554
     1555
     1556
     1557
     1558
     1559
     1560
     1561
     1562
     1563
     1564
     1565
     1566
     1567
     1568
     1569
     1570
     1571
     1572
     1573
     1574
     1575
     1576
     1577
     1578
     1579
     1580
     1581
     1582
     1583
     1584
     1585
     1586
     1587
     1588
     1589
    15071590}
    15081591
    15091592function wpdbBackup_init() {
    15101593    global $mywpdbbackup;
    1511     $mywpdbbackup = new wpdbBackup();   
     1594    $mywpdbbackup = new wpdbBackup();
    15121595}
    15131596
Note: See TracChangeset for help on using the changeset viewer.