Plugin Directory

Changeset 6478


Ignore:
Timestamp:
09/26/2006 03:11:54 AM (20 years ago)
Author:
filosofo
Message:

update to 1.8 and to WP 2.0 trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-db-backup/trunk/wp-db-backup.php

    r3079 r6478  
    55Description: On-demand backup of your WordPress database.
    66Author: Scott Merrill
    7 Version: 1.7
     7Version: 1.8
    88Author URI: http://www.skippy.net/
    99
    … …  
    1717// CHANGE THIS IF YOU WANT TO USE A
    1818// DIFFERENT BACKUP LOCATION
    19 define('WP_BACKUP_DIR', 'wp-content/backup');
     19
     20$rand = substr( md5( md5( DB_PASSWORD ) ), -5 );
     21
     22define('WP_BACKUP_DIR', 'wp-content/backup-' . $rand);
    2023
    2124define('ROWS_PER_SEGMENT', 100);
    … …  
    3437
    3538        function wpdbBackup() {
    36                 load_plugin_textdomain('wp-db-backup');
    37                
    3839                add_action('wp_cron_daily', array(&$this, 'wp_cron_daily'));
    3940
    … …  
    4243       
    4344                if (isset($_POST['do_backup'])) {
     45                        if ( !current_user_can('import') ) die(__('You are not allowed to perform backups.'));
    4446                        switch($_POST['do_backup']) {
    4547                        case 'backup':
    … …  
    5153                        }
    5254                } elseif (isset($_GET['fragment'] )) {
     55                        if ( !current_user_can('import') ) die(__('You are not allowed to perform backups.'));
    5356                        add_action('init', array(&$this, 'init'));
    5457                } elseif (isset($_GET['backup'] )) {
     58                        if ( !current_user_can('import') ) die(__('You are not allowed to perform backups.'));
    5559                        add_action('init', array(&$this, 'init'));
    5660                } else {
    5761                        add_action('admin_menu', array(&$this, 'admin_menu'));
    58                 }       
     62                }
    5963        }
    6064       
    6165        function init() {
    62                 global $user_level;
    63                 get_currentuserinfo();
    64 
    65                 if ($user_level < 9) die('Need higher user level.');
     66                if ( !current_user_can('import') ) die(__('You are not allowed to perform backups.'));
    6667
    6768                if (isset($_GET['backup'])) {
    … …  
    6970                       
    7071                        $this->backup_file = $_GET['backup'];
    71                        
     72                        $this->validate_file($this->backup_file);
     73
    7274                        switch($via) {
    7375                        case 'smtp':
    … …  
    8486                                }
    8587                                echo '
    86                                         alert("' . __('Backup Complete!', 'wp-db-backup') . '");
     88                                        alert("' . __('Backup Complete!') . '");
    8789                                        </script>
    8890                                ';
    … …  
    9597                if (isset($_GET['fragment'] )) {
    9698                        list($table, $segment, $filename) = explode(':', $_GET['fragment']);
     99                        $this->validate_file($filename);
    97100                        $this->backup_fragment($table, $segment, $filename);
    98101                }
    … …  
    110113                echo "<div class='wrap'>";
    111114                //echo "<pre>" . print_r($_POST, 1) . "</pre>";
    112                 echo '<h2>' . __('Backup', 'wp-db-backup') . '</h2>
    113                         <fieldset class="options"><legend>' . __('Progress', 'wp-db-backup') . '</legend>
    114                         ' . __('<p><strong>DO NOT DO THE FOLLOWING AS IT WILL CAUSE YOUR BACKUP TO FAIL:</strong></p> <ol><li>Close this browser</li><li>Reload this page</li><li>Click the Stop or Back buttons in your browser</li></ol>', 'wp-db-backup') . '
    115                         <p><strong>' . __('Progress:', 'wp-db-backup') . '</strong></p>
     115                echo '<h2>' . __('Backup') . '</h2>
     116                        <fieldset class="options"><legend>' . __('Progress') . '</legend>
     117                        <p><strong>' .
     118                                __('DO NOT DO THE FOLLOWING AS IT WILL CAUSE YOUR BACKUP TO FAIL:').
     119                        '</strong></p>
     120                        <ol>
     121                                <li>'.__('Close this browser').'</li>
     122                                <li>'.__('Reload this page').'</li>
     123                                <li>'.__('Click the Stop or Back buttons in your browser').'</li>
     124                        </ol>
     125                        <p><strong>' . __('Progress:') . '</strong></p>
    116126                        <div id="meterbox" style="height:11px;width:80%;padding:3px;border:1px solid #659fff;"><div id="meter" style="height:11px;background-color:#659fff;width:0%;text-align:center;font-size:6pt;">&nbsp;</div></div>
    117127                        <div id="progress_message"></div>
    … …  
    133143                                errors.innerHTML = errors.innerHTML + str + "<br />";
    134144                        }
    135                        
     145
    136146                        function backup(table, segment) {
    137147                                var fram = document.getElementById("backuploader");                             
    … …  
    156166                case 'http':
    157167                        echo '
    158                                 setProgress("' . sprintf(__("Backup complete, preparing <a href=\\\"%s\\\">backup</a> for download...", 'wp-db-backup'), $download_uri) . '");
     168                                setProgress("' . sprintf(__("Backup complete, preparing <a href=\\\"%s\\\">backup</a> for download..."), $download_uri) . '");
    159169                                fram.src = "' . $download_uri . '";
    160170                        ';
    … …  
    162172                case 'smtp':
    163173                        echo '
    164                                 setProgress("' . sprintf(__("Backup complete, sending <a href=\\\"%s\\\">backup</a> via email...", 'wp-db-backup'), $download_uri) . '");
     174                                setProgress("' . sprintf(__("Backup complete, sending <a href=\\\"%s\\\">backup</a> via email..."), $download_uri) . '");
    165175                                fram.src = "' . $download_uri . '&via=email&recipient=' . $_POST['backup_recipient'] . '";
    166176                        ';
    … …  
    168178                default:
    169179                        echo '
    170                                 setProgress("' . sprintf(__("Backup complete, download <a href=\\\"%s\\\">here</a>.", 'wp-db-backup'), $download_uri) . '");
     180                                setProgress("' . sprintf(__("Backup complete, download <a href=\\\"%s\\\">here</a>."), $download_uri) . '");
    171181                        ';
    172182                }
    … …  
    207217                                if(step != 0) setMeter(100 * step / ' . $step_count . ');
    208218                        }
    209                        
     219
    210220                        nextStep();
    211221                        //--></script>
     222        </div>
    212223                ';
    213224        }
    … …  
    219230               
    220231                if($table == '') {
    221                         $msg = __("Creating backup file...", 'wp-db-backup');
     232                        $msg = __('Creating backup file...');
    222233                } else {
    223234                        if($segment == -1) {
    224                                 $msg = sprintf(__('Finished backing up table \\"%s\\".', 'wp-db-backup'), $table);
     235                                $msg = sprintf(__('Finished backing up table \\"%s\\".'), $table);
    225236                        } else {
    226                                 $msg = sprintf(__('Backing up table \\"%s\\"...', 'wp-db-backup'), $table);
     237                                $msg = sprintf(__('Backing up table \\"%s\\"...'), $table);
    227238                        }
    228239                }
    … …  
    236247                        $this->fp = $this->open(ABSPATH . $this->backup_dir . $filename, 'a');
    237248                        if(!$this->fp) {
    238                                 $this->backup_error(__('Could not open the backup file for writing!', 'wp-db-backup'));
    239                                 $this->fatal_error = __('The backup file could not be saved.  Please check the permissions for writing to your backup directory and try again.', 'wp-db-backup');
     249                                $this->backup_error(__('Could not open the backup file for writing!'));
     250                                $this->fatal_error = __('The backup file could not be saved.  Please check the permissions for writing to your backup directory and try again.');
    240251                        }
    241252                        else {
    … …  
    262273                        }
    263274                } else {
    264                         $this->backup_error(__('The backup directory is not writeable!', 'wp-db-backup'));
    265                         $this->fatal_error = __('The backup directory is not writeable!  Please check the permissions for writing to your backup directory and try again.', 'wp-db-backup');
     275                        $this->backup_error(__('The backup directory is not writeable!'));
     276                        $this->fatal_error = __('The backup directory is not writeable!  Please check the permissions for writing to your backup directory and try again.');
    266277                }
    267278
    … …  
    298309                $core_tables = $_POST['core_tables'];
    299310                $this->backup_file = $this->db_backup($core_tables, $also_backup);
    300                 if (FALSE !== $backup_file) {
     311                if (FALSE !== $this->backup_file) {
    301312                        if ('smtp' == $_POST['deliver']) {
    302313                                $this->deliver_backup ($this->backup_file, $_POST['deliver'], $_POST['backup_recipient']);
    … …  
    312323        ///////////////////////////////
    313324        function admin_menu() {
    314                 add_management_page('Backup', 'Backup', 9, basename(__FILE__), array(&$this, 'backup_menu'));
     325                add_management_page(__('Backup'), __('Backup'), 'import', basename(__FILE__), array(&$this, 'backup_menu'));
    315326        }
    316327
    317328        function fragment_menu() {
    318                 add_management_page('Backup', 'Backup', 9, basename(__FILE__), array(&$this, 'build_backup_script'));
    319         }
    320        
     329                add_management_page(__('Backup'), __('Backup'), 'import', basename(__FILE__), array(&$this, 'build_backup_script'));
     330        }
     331
    321332        /////////////////////////////////////////////////////////
    322333        function sql_addslashes($a_string = '', $is_like = FALSE)
    … …  
    332343            }
    333344            $a_string = str_replace('\'', '\\\'', $a_string);
    334        
     345
    335346            return $a_string;
    336347        } // function sql_addslashes($a_string = '', $is_like = FALSE)
    337        
     348
    338349        ///////////////////////////////////////////////////////////
    339350        function backquote($a_name)
    … …  
    383394                if ($this->gzip()) {
    384395                        if(@gzwrite($this->fp, $query_line) === FALSE) {
    385                                 backup_error(__('There was an error writing a line to the backup script:', 'wp-db-backup'));
     396                                backup_error(__('There was an error writing a line to the backup script:'));
    386397                                backup_error('&nbsp;&nbsp;' . $query_line);
    387398                        }
    388399                } else {
    389400                        if(@fwrite($this->fp, $query_line) === FALSE) {
    390                                 backup_error(__('There was an error writing a line to the backup script:', 'wp-db-backup'));
     401                                backup_error(__('There was an error writing a line to the backup script:'));
    391402                                backup_error('&nbsp;&nbsp;' . $query_line);
    392403                        }
    … …  
    398409                        $this->backup_errors[] = $err;
    399410                } elseif(count($this->backup_errors) == 20) {
    400                         $this->backup_errors[] = __('Subsequent errors have been omitted from this log.', 'wp-db-backup');
     411                        $this->backup_errors[] = __('Subsequent errors have been omitted from this log.');
    401412                }
    402413        }
    … …  
    417428                $table_structure = $wpdb->get_results("DESCRIBE $table");
    418429                if (! $table_structure) {
    419                         backup_errors(__('Error getting table details', 'wp-db-backup') . ": $table");
     430                        backup_errors(__('Error getting table details') . ": $table");
    420431                        return FALSE;
    421432                }
    … …  
    442453                        $create_table = $wpdb->get_results("SHOW CREATE TABLE $table", ARRAY_N);
    443454                        if (FALSE === $create_table) {
    444                                 $this->backup_error(sprintf(__("Error with SHOW CREATE TABLE for %s.", 'wp-db-backup'), $table));
     455                                $this->backup_error(sprintf(__("Error with SHOW CREATE TABLE for %s."), $table));
    445456                                $this->stow("#\n# Error with SHOW CREATE TABLE for $table!\n#\n");
    446457                        }
    … …  
    448459                       
    449460                        if (FALSE === $table_structure) {
    450                                 $this->backup_error(sprintf(__("Error getting table structure of %s", 'wp-db-backup'), $table));
     461                                $this->backup_error(sprintf(__("Error getting table structure of %s"), $table));
    451462                                $this->stow("#\n# Error getting table structure of $table!\n#\n");
    452463                        }
    … …  
    487498                                if ( !ini_get('safe_mode')) @set_time_limit(15*60);
    488499                                $table_data = $wpdb->get_results("SELECT * FROM $table LIMIT {$row_start}, {$row_inc}", ARRAY_A);
    489                                
     500
    490501                                /*
    491502                                if (FALSE === $table_data) {
    … …  
    557568                        $this->fp = $this->open(ABSPATH . $this->backup_dir . $wp_backup_filename);
    558569                        if(!$this->fp) {
    559                                 $this->backup_error(__('Could not open the backup file for writing!', 'wp-db-backup'));
     570                                $this->backup_error(__('Could not open the backup file for writing!'));
    560571                                return false;
    561572                        }
    562573                } else {
    563                         $this->backup_error(__('The backup directory is not writeable!', 'wp-db-backup'));
     574                        $this->backup_error(__('The backup directory is not writeable!'));
    564575                        return false;
    565576                }
    … …  
    605616                if ('http' == $delivery) {
    606617                        if (! file_exists($diskfile)) {
    607                                 $msg = sprintf(__('File not found:<br /><strong>%1s</strong><br />', 'wp-db-backup'), $filename);
     618                                $msg = sprintf(__('File not found:%s'), "<br /><strong>$filename</strong><br />");
    608619                                $this_basename = preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', __FILE__);
    609                                 $msg .= '<br /><a href="' . get_settings('siteurl') . "/wp-admin/edit.php?page={$this_basename}" . '">' . __('Return to Backup', 'wp-db-backup');
     620                                $msg .= '<br /><a href="' . get_settings('siteurl') . "/wp-admin/edit.php?page={$this_basename}" . '">' . __('Return to Backup');
    610621                        die($msg);
    611622                        }
    … …  
    632643                        $headers .= 'From: ' . get_settings('admin_email') . "\n";
    633644               
    634                         $message = sprintf(__("Attached to this email is\n   %1s\n   Size:%2s kilobytes\n", 'wp-db-backup'), $filename, round(filesize($diskfile)/1024));
     645                        $message = sprintf(__("Attached to this email is\n   %1s\n   Size:%2s kilobytes\n"), $filename, round(filesize($diskfile)/1024));
    635646                        // Add a multipart boundary above the plain message
    636647                        $message = "This is a multi-part message in MIME format.\n\n" .
    637648                                "--{$boundary}\n" .
    638                                 "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
     649                                "Content-Type: text/plain; charset=\"utf-8\"\n" .
    639650                                "Content-Transfer-Encoding: 7bit\n\n" .
    640651                                $message . "\n\n";
    … …  
    651662                       
    652663                        if (function_exists('wp_mail')) {
    653                                 wp_mail ($recipient, get_bloginfo('name') . ' ' . __('Database Backup', 'wp-db-backup'), $message, $headers);
     664                                wp_mail ($recipient, get_bloginfo('name') . ' ' . __('Database Backup'), $message, $headers);
    654665                        } else {
    655                                 mail ($recipient, get_bloginfo('name') . ' ' . __('Database Backup', 'wp-db-backup'), $message, $headers);
     666                                mail ($recipient, get_bloginfo('name') . ' ' . __('Database Backup'), $message, $headers);
    656667                        }
    657668                       
    … …  
    669680                // did we just do a backup?  If so, let's report the status
    670681                if ( $this->backup_complete ) {
    671                         $feedback = '<div class="updated"><p>' . __('Backup Successful', 'wp-db-backup') . '!';
     682                        $feedback = '<div class="updated"><p>' . __('Backup Successful') . '!';
    672683                        $file = $this->backup_file;
    673684                        switch($_POST['deliver']) {
    674685                        case 'http':
    675                                 $feedback .= '<br />' . sprintf(__('Your backup file: <a href="%1s">%2s</a> should begin downloading shortly.', 'wp-db-backup'), get_settings('siteurl') . "/{$this->backup_dir}{$this->backup_file}", $this->backup_file);
     686                                $feedback .= '<br />' . sprintf(__('Your backup file: <a href="%1s">%2s</a> should begin downloading shortly.'), get_settings('siteurl') . "/{$this->backup_dir}{$this->backup_file}", $this->backup_file);
    676687                                break;
    677688                        case 'smtp':
    … …  
    681692                                        $feedback .= $_POST['backup_recipient'];
    682693                                }
    683                                 $feedback = '<br />' . sprintf(__('Your backup has been emailed to %s', 'wp-db-backup'), $feedback);
     694                                $feedback = '<br />' . sprintf(__('Your backup has been emailed to %s'), $feedback);
    684695                                break;
    685696                        case 'none':
    686                                 $feedback .= '<br />' . __('Your backup file has been saved on the server. If you would like to download it now, right click and select "Save As"', 'wp-db-backup');
    687                                 $feedback .= ':<br /> <a href="' . get_settings('siteurl') . "/{$this->backup_dir}$file\">$file</a> : " . filesize(ABSPATH . $this->backup_dir . $file) . __(' bytes', 'wp-db-backup');
     697                                $feedback .= '<br />' . __('Your backup file has been saved on the server. If you would like to download it now, right click and select "Save As"');
     698                                $feedback .= ':<br /> <a href="' . get_settings('siteurl') . "/{$this->backup_dir}$file\">$file</a> : " . sprintf(__('%s bytes'), filesize(ABSPATH . $this->backup_dir . $file));
    688699                        }
    689700                        $feedback .= '</p></div>';
    … …  
    691702               
    692703                if (count($this->backup_errors)) {
    693                         $feedback .= '<div class="updated error">' . __('The following errors were reported', 'wp-db-backup') . ":<pre>";
     704                        $feedback .= '<div class="updated error">' . __('The following errors were reported:') . "<pre>";
    694705                        foreach($this->backup_errors as $error) {
    695706                                $feedback .= "{$error}\n";  //Errors are already localized
    … …  
    705716                                update_option('wp_cron_backup_recipient', $_POST['cron_backup_recipient'], FALSE);
    706717                        }
    707                         $feedback .= '<div class="updated"><p>' . __('Scheduled Backup Options Saved!', 'wp-db-backup') . '</p></div>';
     718                        $feedback .= '<div class="updated"><p>' . __('Scheduled Backup Options Saved!') . '</p></div>';
    708719                }
    709720               
    … …  
    727738                        echo $feedback;
    728739                }
    729                
    730                 if (! is_dir(ABSPATH . $this->backup_dir)) {
    731                         echo '<div class="updated error"><p align="center">' . __('WARNING: Your backup directory does not exist!', 'wp-db-backup') . '<br />' . ABSPATH . $this->backup_dir . "</p></div>";
     740
     741                // Give the new dirs the same perms as wp-content.
     742                $stat = stat( ABSPATH . 'wp-content' );
     743                $dir_perms = $stat['mode'] & 0000777; // Get the permission bits.
     744
     745                if ( !file_exists( ABSPATH . $this->backup_dir) ) {
     746                        if ( @ mkdir( ABSPATH . $this->backup_dir) ) {
     747                                @ chmod( ABSPATH . $this->backup_dir, $dir_perms);
     748                        } else {
     749                                echo '<div class="updated error"><p align="center">' . __('WARNING: Your wp-content directory is <strong>NOT</strong> writable! We can not create the backup directory.') . '<br />' . ABSPATH . $this->backup_dir . "</p></div>";
    732750                        $WHOOPS = TRUE;
    733                 }elseif (! is_writable(ABSPATH . $this->backup_dir)) {
    734                         echo '<div class="updated error"><p align="center">' . __('WARNING: Your backup directory is <strong>NOT</strong> writable!', 'wp-db-backup') . '<br />' . ABSPATH . $this->backup_dir . "</p></div>";
    735                         $WHOOPS = TRUE;
    736                 }
     751                        }
     752                }
     753               
     754                if ( !is_writable( ABSPATH . $this->backup_dir) ) {
     755                        echo '<div class="updated error"><p align="center">' . __('WARNING: Your backup directory is <strong>NOT</strong> writable! We can not create the backup directory.') . '<br />' . ABSPATH . "</p></div>";
     756                }
     757
     758                if ( !file_exists( ABSPATH . $this->backup_dir . 'index.php') ) {
     759                        @ touch( ABSPATH . $this->backup_dir . "index.php");
     760                }
     761
    737762                echo "<div class='wrap'>";
    738                 echo '<h2>' . __('Backup', 'wp-db-backup') . '</h2>';
    739                 echo '<fieldset class="options"><legend>' . __('Tables', 'wp-db-backup') . '</legend>';
     763                echo '<h2>' . __('Backup') . '</h2>';
     764                echo '<fieldset class="options"><legend>' . __('Tables') . '</legend>';
    740765                echo '<form method="post">';
    741766                echo '<table align="center" cellspacing="5" cellpadding="5"><tr><td width="50%" align="left" class="alternate" valign="top">';
    742                 echo __('These core WordPress tables will always be backed up', 'wp-db-backup') . ': <br /><ul>';
     767                echo __('These core WordPress tables will always be backed up:') . '<br /><ul>';
    743768                foreach ($wp_backup_default_tables as $table) {
    744769                        echo "<li><input type='hidden' name='core_tables[]' value='$table' />$table</li>";
    … …  
    746771                echo '</ul></td><td width="50%" align="left" valign="top">';
    747772                if (count($other_tables) > 0) {
    748                         echo __('You may choose to include any of the following tables', 'wp-db-backup') . ': <br />';
     773                        echo __('You may choose to include any of the following tables:') . ' <br />';
    749774                        foreach ($other_tables as $table) {
    750775                                echo "<label style=\"display:block;\"><input type='checkbox' name='other_tables[]' value='{$table}' /> {$table}</label>";
    … …  
    752777                }
    753778                echo '</tr></table></fieldset>';
    754                 echo '<fieldset class="options"><legend>' . __('Backup Options', 'wp-db-backup') . '</legend>';
    755                 echo __('What to do with the backup file', 'wp-db-backup') . ":<br />";
    756                 echo '<label style="display:block;"><input type="radio" name="deliver" value="none" /> ' . __('Save to server', 'wp-db-backup') . " ({$this->backup_dir})</label>";
    757                 echo '<label style="display:block;"><input type="radio" checked="checked" name="deliver" value="http" /> ' . __('Download to your computer', 'wp-db-backup') . '</label>';
     779                echo '<fieldset class="options"><legend>' . __('Backup Options') . '</legend>';
     780                echo __('What to do with the backup file:') . "<br />";
     781                echo '<label style="display:block;"><input type="radio" name="deliver" value="none" /> ' . __('Save to server') . " ({$this->backup_dir})</label>";
     782                echo '<label style="display:block;"><input type="radio" checked="checked" name="deliver" value="http" /> ' . __('Download to your computer') . '</label>';
    758783                echo '<div><input type="radio" name="deliver" id="do_email" value="smtp" /> ';
    759                 echo sprintf(__('<label for="do_email">Email backup to:</label> %s', 'wp-db-backup'), '<input type="text" name="backup_recipient" size="20" value="' . get_settings('admin_email') . '" />');
     784                echo '<label for="do_email">'.__('Email backup to:').'</label><input type="text" name="backup_recipient" size="20" value="' . get_settings('admin_email') . '" />';
    760785               
    761786                // Check DB dize.
    … …  
    775800                if (! $WHOOPS) {
    776801                        echo '<input type="hidden" name="do_backup" id="do_backup" value="backup" /></div>';
    777                         echo '<p class="submit"><input type="submit" name="submit" onclick="document.getElementById(\'do_backup\').value=\'fragments\';" value="' . __('Backup', 'wp-db-backup') . '!" / ></p>';
     802                        echo '<p class="submit"><input type="submit" name="submit" onclick="document.getElementById(\'do_backup\').value=\'fragments\';" value="' . __('Backup') . '!" / ></p>';
    778803                } else {
    779                         echo '<p class="alternate">' . __('WARNING: Your backup directory is <strong>NOT</strong> writable!', 'wp-db-backup') . '</p>';
     804                        echo '<p class="alternate">' . __('WARNING: Your backup directory is <strong>NOT</strong> writable!') . '</p>';
    780805                }
    781806                echo '</fieldset>';
    … …  
    784809                // this stuff only displays if wp_cron is installed
    785810                if (function_exists('wp_cron_init')) {
    786                         echo '<fieldset class="options"><legend>' . __('Scheduled Backup', 'wp-db-backup') . '</legend>';
     811                        echo '<fieldset class="options"><legend>' . __('Scheduled Backup') . '</legend>';
    787812                        $datetime = get_settings('date_format') . ' @ ' . get_settings('time_format');
    788                         echo '<p>' . __('Last WP-Cron Daily Execution', 'wp-db-backup') . ': ' . date($datetime, get_option('wp_cron_daily_lastrun')) . '<br />';
    789                         echo __('Next WP-Cron Daily Execution', 'wp-db-backup') . ': ' . date($datetime, (get_option('wp_cron_daily_lastrun') + 86400)) . '</p>';
     813                        echo '<p>' . __('Last WP-Cron Daily Execution') . ': ' . date($datetime, get_option('wp_cron_daily_lastrun')) . '<br />';
     814                        echo __('Next WP-Cron Daily Execution') . ': ' . date($datetime, (get_option('wp_cron_daily_lastrun') + 86400)) . '</p>';
    790815                        echo '<form method="post">';
    791816                        echo '<table width="100%" callpadding="5" cellspacing="5">';
    792817                        echo '<tr><td align="center">';
    793                         echo __('Schedule: ', 'wp-db-backup');
     818                        echo __('Schedule: ');
    794819                        $wp_cron_backup_schedule = get_option('wp_cron_backup_schedule');
    795                         $schedule = array(0 => __('None', 'wp-db-backup'), 1 => __('Daily', 'wp-db-backup'));
     820                        $schedule = array(0 => __('None'), 1 => __('Daily'));
    796821                        foreach ($schedule as $value => $name) {
    797822                                echo ' <input type="radio" name="cron_schedule"';
    … …  
    799824                                        echo ' checked="checked" ';
    800825                                }
    801                                 echo 'value="' . $value . '" /> ' . __($name, 'wp-db-backup');
     826                                echo 'value="' . $value . '" /> ' . __($name);
    802827                        }
    803828                        echo '</td><td align="center">';
    … …  
    806831                                $cron_recipient = get_settings('admin_email');
    807832                        }
    808                         echo __('Email backup to', 'wp-db-backup') . ': <input type="text" name="cron_backup_recipient" size="20" value="' . $cron_recipient . '" />';
     833                        echo __('Email backup to:') . ' <input type="text" name="cron_backup_recipient" size="20" value="' . $cron_recipient . '" />';
    809834                        echo '</td></tr>';
    810835                        $cron_tables = get_option('wp_cron_backup_tables');
    … …  
    813838                        }
    814839                        if (count($other_tables) > 0) {
    815                                 echo '<tr><td colspan="2" align="left">' . __('Tables to include', 'wp-db-backup') . ':<br />';
     840                                echo '<tr><td colspan="2" align="left">' . __('Tables to include:') . '<br />';
    816841                                foreach ($other_tables as $table) {
    817842                                        echo '<input type="checkbox" ';
    … …  
    823848                                echo '</td></tr>';
    824849                        }
    825                         echo '<tr><td colspan="2" align="center"><input type="hidden" name="wp_cron_backup_options" value="SET" /><input type="submit" name="submit" value="' . __('Submit', 'wp-db-backup') . '" /></td></tr></table></form>';
     850                        echo '<tr><td colspan="2" align="center"><input type="hidden" name="wp_cron_backup_options" value="SET" /><input type="submit" name="submit" value="' . __('Submit') . '" /></td></tr></table></form>';
    826851                        echo '</fieldset>';
    827852                }
    … …  
    859884                return;
    860885        } // wp_cron_db_backup
     886
     887        function validate_file($file) {
     888                if (false !== strpos($file, '..'))
     889                        die(__("Cheatin' uh ?"));
     890
     891                if (false !== strpos($file, './'))
     892                        die(__("Cheatin' uh ?"));
     893
     894                if (':' == substr($file, 1, 1))
     895                        die(__("Cheatin' uh ?"));
     896        }
     897
    861898}
    862899
    863 $mywpdbbackup = new wpdbBackup();
     900function wpdbBackup_init() {
     901        global $mywpdbbackup;
     902
     903        if ( !current_user_can('import') ) return;
     904
     905        $mywpdbbackup = new wpdbBackup();       
     906}
     907
     908add_action('plugins_loaded', 'wpdbBackup_init');
    864909
    865910?>
Note: See TracChangeset for help on using the changeset viewer.