Plugin Directory

Changeset 778188


Ignore:
Timestamp:
09/25/2013 08:01:37 AM (13 years ago)
Author:
Driskell
Message:

Update dev version

Location:
wponlinebackup/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • wponlinebackup/trunk/include/admin.php

    r774720 r778188  
    14041404        if ( !is_null( $result ) ) {
    14051405
    1406             if ( file_exists( WPONLINEBACKUP_LOCALBACKUPDIR . '/' . $result['filename'] ) ) {
    1407 
    1408                 $ret = @unlink( WPONLINEBACKUP_LOCALBACKUPDIR . '/' . $result['filename'] );
     1406            if ( file_exists( $this->WPOnlineBackup->Get_Setting( 'backup_directory' ) . '/' . $result['filename'] ) ) {
     1407
     1408                $ret = @unlink( $this->WPOnlineBackup->Get_Setting( 'backup_directory' ) . '/' . $result['filename'] );
    14091409
    14101410            } else {
     
    16571657<p><?php _e( 'Below is a list of backup files currently stored on your server. <strong>It is highly recommended that these backups are downloaded and stored away from the server to prevent a total loss if the server fails.</strong>', 'wponlinebackup' ); ?></p>
    16581658<p><?php echo sprintf( __( 'Old files are deleted automatically to keep you below %s storage space whilst still keeping a minimum of %s files (configurable in General Settings.) LOCKED files will never be deleted and will not be counted towards the storage space.', 'wponlinebackup' ), WPOnlineBackup_Formatting::Fix_B( $this->WPOnlineBackup->Get_Setting( 'local_max_storage' ) * 1048576 ), $this->WPOnlineBackup->Get_Setting( 'local_min_gens' ) ); ?></p>
    1659 <p><?php echo sprintf( __( 'Encrypted files, which have a .ENC file extension, can be decrypted from this page; the result of the decryption will be stored next to the original file in this folder. You can also upload files to this folder via FTP for decryption or storage; the location is: %s.', 'wponlinebackup' ), WPONLINEBACKUP_LOCALBACKUPDIR ); ?></p>
     1659<p><?php echo sprintf( __( 'Encrypted files, which have a .ENC file extension, can be decrypted from this page; the result of the decryption will be stored next to the original file in this folder. You can also upload files to this folder via FTP for decryption or storage; the location is: %s.', 'wponlinebackup' ), $this->WPOnlineBackup->Get_Setting( 'backup_directory' ) ); ?></p>
    16601660<table class="widefat" style="clear: left" cellspacing="0">
    16611661<thead>
     
    16891689        );
    16901690
    1691         // Create a map of filenames and index creation dates
     1691        // Create a map of filenames and index creation dates and remove any missing files
     1692        $backup_dir = $this->WPOnlineBackup->Get_Setting( 'backup_directory' );
     1693
    16921694        $filenames = array();
    16931695        $creation_dates = array();
     1696
    16941697        foreach ( $result as $download ) {
     1698
     1699            // Does it actually exist?
     1700            if ( !file_exists( $backup_dir . '/' . $download['filename'] ) ) {
     1701
     1702                $esc_filename = $download['filename'];
     1703                $wpdb->escape_by_ref( $esc_filename );
     1704
     1705                // Remove from database
     1706                $wpdb->query(
     1707                    'DELETE FROM `' . $wpdb->prefix . 'wponlinebackup_local` ' .
     1708                    'WHERE filename = \'' . $esc_filename . '\''
     1709                );
     1710
     1711                continue;
     1712
     1713            }
     1714
    16951715            $filenames[ $download['filename'] ] = & $download;
    16961716            $creation_dates[] = $download['creation_date'];
     1717
    16971718        }
    16981719
    16991720        // Browse the backups directory and populate any missing entries
    1700         if ( false !== ( $d = @opendir( WPONLINEBACKUP_LOCALBACKUPDIR ) ) ) {
     1721        if ( false !== ( $d = @opendir( $backup_dir ) ) ) {
    17011722
    17021723            while ( false !== ( $f = @readdir( $d ) ) ) {
     
    17111732
    17121733                // Missing entry, get some information we need
    1713                 $created = @filemtime( WPONLINEBACKUP_LOCALBACKUPDIR . '/' . $f );
    1714                 $size = @filesize( WPONLINEBACKUP_LOCALBACKUPDIR . '/' . $f );
     1734                $created = @filemtime( $backup_dir . '/' . $f );
     1735                $size = @filesize( $backup_dir . '/' . $f );
    17151736
    17161737                if ( $created === false || $size === false )
     
    37593780            }
    37603781
     3782            if ( !array_key_exists( 'override_backup_directory', $_POST ) || !array_key_exists( 'backup_directory', $_POST ) ) {
     3783                $this->WPOnlineBackup->Set_Setting( 'backup_directory', null );
     3784            } else {
     3785                $value = strval( $_POST['backup_directory'] );
     3786                if ( !file_exists( $value ) || !is_dir( $value ) ) {
     3787                    $errors[] = array(
     3788                        'icon'  => 'error',
     3789                        'text'  => 'backup_directory must be an existing directory',
     3790                    );
     3791                } else {
     3792                    if ( ( $f = @fopen( $value . '/obfwtest', 'w' ) ) === false ) {
     3793                        $errors[] = array(
     3794                            'icon'  => 'error',
     3795                            'text'  => 'backup_directory does not appear to be accessible',
     3796                        );
     3797                    } else {
     3798                        @fclose( $f );
     3799                        @unlink( $value . '/obfwtest' );
     3800                    }
     3801                }
     3802                $this->WPOnlineBackup->Set_Setting( 'backup_directory', $value );
     3803            }
     3804
    37613805            if ( !array_key_exists( 'override_core_tables', $_POST ) || !array_key_exists( 'core_tables', $_POST ) ) {
    37623806                $this->WPOnlineBackup->Set_Setting( 'core_tables', null );
     
    40884132</tr>
    40894133<tr valign="top">
     4134<th scope="row" style="text-align: right; padding: 18px"><label for="backup_directory" style="font-weight: bold"><?php echo 'backup_directory'; ?></label></th>
     4135<td><p><strong>WARNING:</strong> This path is automatically excluded from the filesystem backup. It is therefore recommended that this folder contain absolutely nothing and is dedicated to the plugin.</p>
     4136<p><input type="checkbox" name="override_backup_directory" id="override_backup_directory" value="1"<?php
     4137// Mark as checked if we selected this option
     4138        if ( !is_null( $this->WPOnlineBackup->Get_Setting( 'backup_directory', true ) ) ) {
     4139?> checked="checked"<?php
     4140        }
     4141?>>&nbsp;<input type="text" style="width: 250px" name="backup_directory" id="backup_directory" value="<?php echo $this->WPOnlineBackup->Get_Setting( 'backup_directory' ); ?>"></p></td>
     4142</tr>
     4143<tr valign="top">
    40904144<th scope="row" style="text-align: right; padding: 18px"><label for="core_tables" style="font-weight: bold"><?php echo 'core_tables'; ?></label></th>
    40914145<td><p><input type="checkbox" name="override_core_tables" id="override_core_tables" value="1"<?php
  • wponlinebackup/trunk/include/bootstrap.php

    r768952 r778188  
    384384        // Verify that the backups directory is NOT browsable - we should get back 403, 404 or a blank index.html if it's not
    385385        // First ensure the index.html is there and then check
    386         if ( !@file_exists( WPONLINEBACKUP_LOCALBACKUPDIR . '/index.html' ) )
    387             @copy( WPONLINEBACKUP_PATH . '/index.html', WPONLINEBACKUP_LOCALBACKUPDIR . '/index.html' );
     386        if ( !@file_exists( $this->WPOnlineBackup->Get_Setting( 'backup_directory' ) . '/index.html' ) )
     387            @copy( WPONLINEBACKUP_PATH . '/index.html', $this->WPOnlineBackup->Get_Setting( 'backup_directory' ) . '/index.html' );
    388388
    389389        $config_verify['backups_url'] = content_url() . '/backups/';
     
    477477        $this->activity_id = 0;
    478478
    479         // Start with no cache
    480         $cache = array();
     479        // Populate the settings cache
     480        $cache = array(
     481            'local_tmp_dir'     => $this->WPOnlineBackup->Get_Setting( 'local_tmp_dir' ),
     482            'backup_directory'  => $this->WPOnlineBackup->Get_Setting( 'backup_directory' ),
     483        );
    481484
    482485        if ( $type == WPONLINEBACKUP_ACTIVITY_DECRYPT ) {
     
    514517
    515518        }
    516 
    517         $cache['local_tmp_dir'] = $this->WPOnlineBackup->Get_Setting( 'local_tmp_dir' );
    518519
    519520        // Reset the problem code
     
    21212122        // Create the local backup directory
    21222123        // The web server must be able to serve files from the local backups directory so we can't risk setting 0700; it may cause the web server to lose access if the server config is weird
    2123         if ( !@file_exists( WPONLINEBACKUP_LOCALBACKUPDIR ) && false === @mkdir( WPONLINEBACKUP_LOCALBACKUPDIR ) ) {
     2124        if ( !@file_exists( $this->status['progress']['cache']['backup_directory'] ) && false === @mkdir( $this->status['progress']['cache']['backup_directory'] ) ) {
    21242125
    21252126            // Grab the error
     
    21282129            $this->Log_Event(
    21292130                WPONLINEBACKUP_EVENT_ERROR,
    2130                 sprintf( __( 'The directory (%s) where local backups will be stored could not be created.', 'wponlinebackup' ), WPONLINEBACKUP_LOCALBACKUPDIR ) . PHP_EOL .
     2131                sprintf( __( 'The directory (%s) where local backups will be stored could not be created.', 'wponlinebackup' ), $this->status['progress']['cache']['backup_directory'] ) . PHP_EOL .
    21312132                sprintf( __( 'You may need to login via FTP and create the folder yourself and "CHMOD" it to "0770" or, as a last resort, "0777". You should also create the temporary processing directory (%s) with the same permissions.', 'wponlinebackup' ), $this->status['progress']['cache']['local_tmp_dir'] ) . PHP_EOL .
    21322133                sprintf( __( 'Error: %s', 'wponlinebackup' ), $ret )
     
    21402141
    21412142        // Prevent browsing by dropping in a blank index.html if there isn't one
    2142         if ( !@file_exists( WPONLINEBACKUP_LOCALBACKUPDIR . '/index.html' ) )
    2143             $ret = @copy( WPONLINEBACKUP_PATH . '/index.html', WPONLINEBACKUP_LOCALBACKUPDIR . '/index.html' );
     2143        if ( !@file_exists( $this->status['progress']['cache']['backup_directory'] . '/index.html' ) )
     2144            $ret = @copy( WPONLINEBACKUP_PATH . '/index.html', $this->status['progress']['cache']['backup_directory'] . '/index.html' );
    21442145
    21452146        // If we failed to copy, report a write problem - or if we didn't copy because index.html already existed, try to write to it with touch which only touches modification time
    2146         if ( false === $ret || false === @touch( WPONLINEBACKUP_LOCALBACKUPDIR . '/index.html' ) ) {
     2147        if ( false === $ret || false === @touch( $this->status['progress']['cache']['backup_directory'] . '/index.html' ) ) {
    21472148
    21482149            $ret = OBFW_Tidy_Exception();
     
    21502151            $this->Log_Event(
    21512152                WPONLINEBACKUP_EVENT_ERROR,
    2152                 sprintf( __( 'The directory (%s) where local backups will be stored cannot be written to.', 'wponlinebackup' ), WPONLINEBACKUP_LOCALBACKUPDIR ) . PHP_EOL .
     2153                sprintf( __( 'The directory (%s) where local backups will be stored cannot be written to.', 'wponlinebackup' ), $this->status['progress']['cache']['backup_directory'] ) . PHP_EOL .
    21532154                sprintf( __( 'You may need to login via FTP and "CHMOD" it to "0770" or, as a last resort, "0777". You should also check the temporary processing directory (%s) has the same permissions, also creating the folder if necessary.', 'wponlinebackup' ), $this->status['progress']['cache']['local_tmp_dir'] ) . PHP_EOL .
    21542155                sprintf( __( 'Error: %s', 'wponlinebackup' ), $ret )
     
    21912192
    21922193        // Prevent browsing by dropping in a blank index.html if there isn't one
    2193         if ( !@file_exists( WPONLINEBACKUP_LOCALBACKUPDIR . '/index.html' ) )
    2194             @copy( WPONLINEBACKUP_PATH . '/index.html', WPONLINEBACKUP_LOCALBACKUPDIR . '/index.html' );
     2194        if ( !@file_exists( $this->status['progress']['cache']['backup_directory'] . '/index.html' ) )
     2195            @copy( WPONLINEBACKUP_PATH . '/index.html', $this->status['progress']['cache']['backup_directory'] . '/index.html' );
    21952196
    21962197        // This now gives us three fold security, number 3 being the 100% protection and the others just to deter and out of principle
     
    24162417
    24172418        // Move it into place
    2418         @rename( $this->status['progress']['file_set']['file'], WPONLINEBACKUP_LOCALBACKUPDIR . '/' . $name );
     2419        @rename( $this->status['progress']['file_set']['file'], $this->status['progress']['cache']['backup_directory'] . '/' . $name );
    24192420
    24202421        // Store the file name
     
    24782479
    24792480            // Move it into place
    2480             if ( false === @rename( $this->status['progress']['file_set']['file'], WPONLINEBACKUP_LOCALBACKUPDIR . '/' . $name ) ) {
     2481            if ( false === @rename( $this->status['progress']['file_set']['file'], $this->status['progress']['cache']['backup_directory'] . '/' . $name ) ) {
    24812482
    24822483                // Grab the error
     
    24892490                $this->Log_Event(
    24902491                    WPONLINEBACKUP_EVENT_ERROR,
    2491                     sprintf( __( 'An error occurred trying to save the backup to the local backup folder at %s.', 'wponlinebackup' ), WPONLINEBACKUP_LOCALBACKUPDIR ) . PHP_EOL .
     2492                    sprintf( __( 'An error occurred trying to save the backup to the local backup folder at %s.', 'wponlinebackup' ), $this->status['progress']['cache']['backup_directory'] ) . PHP_EOL .
    24922493                    sprintf( __( 'Error: %s', 'wponlinebackup' ), $ret )
    24932494                );
     
    26052606
    26062607                    // Delete it - if it's not there assume deleted (user may have deleted manually)
    2607                     if ( !file_exists( WPONLINEBACKUP_LOCALBACKUPDIR . '/' . $row['filename'] ) || false !== @unlink( WPONLINEBACKUP_LOCALBACKUPDIR . '/' . $row['filename'] ) ) {
     2608                    if ( !file_exists( $this->status['progress']['cache']['backup_directory'] . '/' . $row['filename'] ) || false !== @unlink( $this->status['progress']['cache']['backup_directory'] . '/' . $row['filename'] ) ) {
    26082609
    26092610                        // Drop from database
  • wponlinebackup/trunk/include/decrypt.php

    r747393 r778188  
    5858
    5959            // Open it
    60             if ( false === ( $this->file = @fopen( WPONLINEBACKUP_LOCALBACKUPDIR . '/' . $progress['config']['file'], 'rb' ) ) ) {
     60            if ( false === ( $this->file = @fopen( $progress['cache']['backup_directory'] . '/' . $progress['config']['file'], 'rb' ) ) ) {
    6161
    6262                $ret = OBFW_Tidy_Exception();
  • wponlinebackup/trunk/include/files.php

    r769618 r778188  
    153153
    154154        // Default excludes - we always exclude the backup data temporary directory, and the global temporary direct (in case we relocated it in advanced settings screen)
    155         $excludes[ WPONLINEBACKUP_FILE_EXCLUDE_LOCALTMPDIR ] = $this->WPOnlineBackup->Get_Setting( 'local_tmp_dir' );
     155        $excludes[ WPONLINEBACKUP_FILE_EXCLUDE_LOCALTMPDIR ] = $progress['cache']['local_tmp_dir'];
    156156        $excludes[ WPONLINEBACKUP_FILE_EXCLUDE_GZIPTMPDIR ] = $this->WPOnlineBackup->Get_Setting( 'gzip_tmp_dir' );
    157         $excludes[ WPONLINEBACKUP_FILE_EXCLUDE_LOCALBACKUPDIR ] = WPONLINEBACKUP_LOCALBACKUPDIR;
     157        $excludes[ WPONLINEBACKUP_FILE_EXCLUDE_LOCALBACKUPDIR ] = $progress['cache']['backup_directory'];
    158158
    159159        // Build additional excludes
  • wponlinebackup/trunk/wponlinebackup.php

    r774874 r778188  
    3131define( 'WPONLINEBACKUP_PATH', preg_replace( '#/$#', '', plugin_dir_path( __FILE__ ) ) ); // BTL code styling requires we do not have forward slash!
    3232define( 'WPONLINEBACKUP_TMP', WPONLINEBACKUP_PATH . '/tmp' );
    33 define( 'WPONLINEBACKUP_LOCALBACKUPDIR', WP_CONTENT_DIR . '/backups' );
    3433// WPONLINEBACKUP_URL requires the use of plugin_dir_url which should only be called during init()
    3534// It is also only used in the administration pages, so it is now defined in WPOnlineBackup_Admin::Init() which is our admin_init action
     
    908907            // Gzip temporary directory - only used for processing large files which forces us to use gzopen() without a Rejection header
    909908            'gzip_tmp_dir'      => null, // on-the-fly in Get_Setting()
     909            // The local backup directory
     910            'backup_directory'  => WP_CONTENT_DIR . '/backups',
    910911            // Tables that always backup and are not optional
    911912            'core_tables'       => array(
Note: See TracChangeset for help on using the changeset viewer.