Changeset 778188
- Timestamp:
- 09/25/2013 08:01:37 AM (13 years ago)
- Location:
- wponlinebackup/trunk
- Files:
-
- 5 edited
-
include/admin.php (modified) (6 diffs)
-
include/bootstrap.php (modified) (12 diffs)
-
include/decrypt.php (modified) (1 diff)
-
include/files.php (modified) (1 diff)
-
wponlinebackup.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wponlinebackup/trunk/include/admin.php
r774720 r778188 1404 1404 if ( !is_null( $result ) ) { 1405 1405 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'] ); 1409 1409 1410 1410 } else { … … 1657 1657 <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> 1658 1658 <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> 1660 1660 <table class="widefat" style="clear: left" cellspacing="0"> 1661 1661 <thead> … … 1689 1689 ); 1690 1690 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 1692 1694 $filenames = array(); 1693 1695 $creation_dates = array(); 1696 1694 1697 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 1695 1715 $filenames[ $download['filename'] ] = & $download; 1696 1716 $creation_dates[] = $download['creation_date']; 1717 1697 1718 } 1698 1719 1699 1720 // Browse the backups directory and populate any missing entries 1700 if ( false !== ( $d = @opendir( WPONLINEBACKUP_LOCALBACKUPDIR) ) ) {1721 if ( false !== ( $d = @opendir( $backup_dir ) ) ) { 1701 1722 1702 1723 while ( false !== ( $f = @readdir( $d ) ) ) { … … 1711 1732 1712 1733 // 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 ); 1715 1736 1716 1737 if ( $created === false || $size === false ) … … 3759 3780 } 3760 3781 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 3761 3805 if ( !array_key_exists( 'override_core_tables', $_POST ) || !array_key_exists( 'core_tables', $_POST ) ) { 3762 3806 $this->WPOnlineBackup->Set_Setting( 'core_tables', null ); … … 4088 4132 </tr> 4089 4133 <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 ?>> <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"> 4090 4144 <th scope="row" style="text-align: right; padding: 18px"><label for="core_tables" style="font-weight: bold"><?php echo 'core_tables'; ?></label></th> 4091 4145 <td><p><input type="checkbox" name="override_core_tables" id="override_core_tables" value="1"<?php -
wponlinebackup/trunk/include/bootstrap.php
r768952 r778188 384 384 // Verify that the backups directory is NOT browsable - we should get back 403, 404 or a blank index.html if it's not 385 385 // 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' ); 388 388 389 389 $config_verify['backups_url'] = content_url() . '/backups/'; … … 477 477 $this->activity_id = 0; 478 478 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 ); 481 484 482 485 if ( $type == WPONLINEBACKUP_ACTIVITY_DECRYPT ) { … … 514 517 515 518 } 516 517 $cache['local_tmp_dir'] = $this->WPOnlineBackup->Get_Setting( 'local_tmp_dir' );518 519 519 520 // Reset the problem code … … 2121 2122 // Create the local backup directory 2122 2123 // 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'] ) ) { 2124 2125 2125 2126 // Grab the error … … 2128 2129 $this->Log_Event( 2129 2130 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 . 2131 2132 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 . 2132 2133 sprintf( __( 'Error: %s', 'wponlinebackup' ), $ret ) … … 2140 2141 2141 2142 // 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' ); 2144 2145 2145 2146 // 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' ) ) { 2147 2148 2148 2149 $ret = OBFW_Tidy_Exception(); … … 2150 2151 $this->Log_Event( 2151 2152 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 . 2153 2154 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 . 2154 2155 sprintf( __( 'Error: %s', 'wponlinebackup' ), $ret ) … … 2191 2192 2192 2193 // 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' ); 2195 2196 2196 2197 // This now gives us three fold security, number 3 being the 100% protection and the others just to deter and out of principle … … 2416 2417 2417 2418 // 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 ); 2419 2420 2420 2421 // Store the file name … … 2478 2479 2479 2480 // 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 ) ) { 2481 2482 2482 2483 // Grab the error … … 2489 2490 $this->Log_Event( 2490 2491 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 . 2492 2493 sprintf( __( 'Error: %s', 'wponlinebackup' ), $ret ) 2493 2494 ); … … 2605 2606 2606 2607 // 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'] ) ) { 2608 2609 2609 2610 // Drop from database -
wponlinebackup/trunk/include/decrypt.php
r747393 r778188 58 58 59 59 // 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' ) ) ) { 61 61 62 62 $ret = OBFW_Tidy_Exception(); -
wponlinebackup/trunk/include/files.php
r769618 r778188 153 153 154 154 // 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']; 156 156 $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']; 158 158 159 159 // Build additional excludes -
wponlinebackup/trunk/wponlinebackup.php
r774874 r778188 31 31 define( 'WPONLINEBACKUP_PATH', preg_replace( '#/$#', '', plugin_dir_path( __FILE__ ) ) ); // BTL code styling requires we do not have forward slash! 32 32 define( 'WPONLINEBACKUP_TMP', WPONLINEBACKUP_PATH . '/tmp' ); 33 define( 'WPONLINEBACKUP_LOCALBACKUPDIR', WP_CONTENT_DIR . '/backups' );34 33 // WPONLINEBACKUP_URL requires the use of plugin_dir_url which should only be called during init() 35 34 // It is also only used in the administration pages, so it is now defined in WPOnlineBackup_Admin::Init() which is our admin_init action … … 908 907 // Gzip temporary directory - only used for processing large files which forces us to use gzopen() without a Rejection header 909 908 'gzip_tmp_dir' => null, // on-the-fly in Get_Setting() 909 // The local backup directory 910 'backup_directory' => WP_CONTENT_DIR . '/backups', 910 911 // Tables that always backup and are not optional 911 912 'core_tables' => array(
Note: See TracChangeset
for help on using the changeset viewer.