Changeset 650319
- Timestamp:
- 01/09/2013 04:53:57 PM (13 years ago)
- Location:
- wponlinebackup/trunk
- Files:
-
- 10 edited
-
include/admin.php (modified) (6 diffs)
-
include/bootstrap.php (modified) (5 diffs)
-
include/files.php (modified) (21 diffs)
-
include/httprange.php (modified) (2 diffs)
-
include/stream_delta.php (modified) (5 diffs)
-
include/stream_full.php (modified) (5 diffs)
-
include/transmission.php (modified) (1 diff)
-
js/progress.js (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
wponlinebackup.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wponlinebackup/trunk/include/admin.php
r640384 r650319 831 831 'jquery', 832 832 ), 833 '201 2082801'833 '2013010201' 834 834 ); 835 835 wp_localize_script( … … 840 840 'Plugin_URL' => WPONLINEBACKUP_URL, 841 841 'Plugin_File' => WPONLINEBACKUP_FILE, 842 'Events_URL' => 'tools.php?page=' . urlencode( WPONLINEBACKUP_FILE ) . '§ion=events&activity=',842 'Events_URL' => 'tools.php?page=' . urlencode( WPONLINEBACKUP_FILE ), 843 843 'String_Backup' => _x( 'Backup', 'Plugin section', 'wponlinebackup' ), 844 844 'Refresh_Interval' => 2, … … 1261 1261 /*private*/ function Prepare_Decrypt() 1262 1262 { 1263 // Enable our error handling functions 1264 $this->WPOnlineBackup->Enable_Error_Handling(); 1265 1263 1266 // Just try and create the upload folder - ignore error - it just means it is there when they upload via FTP if at all possible 1264 1267 // The form tells them to create it if it is not there, so we don't need to worry about errors here, and when decrypting from uploaded file we stream so only need read access … … 2904 2907 $errors[] = array( 2905 2908 'icon' => 'error', 2906 'text' => __( 'IMPORTANT! Last chance to configure encryption! Once you have connected the plugin to the online vault , you will not be able to change your encryption settings. This is done to ensure that all data sent to the online vault uses the same encryption details. If you wish to change your encryption settings after connecting the plugin, you can disconnect, change them, and then reconnect, but this will ONLY work if you have not yet run an online backup. After the first online backup, the encryption settings becomes permanent, and the only way to reconnect the plugin with new settings is to delete all of the existing backup data related to this blog from the online vault before you reconnect.', 'wponlinebackup' ),2909 'text' => __( 'IMPORTANT! Last chance to configure encryption! Once you have connected the plugin to the online vault you will NOT be able to change your encryption settings without disconnecting the plugin and deleting all backed up data.', 'wponlinebackup' ), 2907 2910 ); 2908 2911 … … 3506 3509 } 3507 3510 3508 if ( !array_key_exists( 'override_remote_api_ attempts', $_POST ) || !array_key_exists( 'remote_api_attempts', $_POST ) ) {3509 $this->WPOnlineBackup->Set_Setting( 'remote_api_ attempts', null );3511 if ( !array_key_exists( 'override_remote_api_retries', $_POST ) || !array_key_exists( 'remote_api_retries', $_POST ) ) { 3512 $this->WPOnlineBackup->Set_Setting( 'remote_api_retries', null ); 3510 3513 } else { 3511 $value = intval( $_POST['remote_api_attempts'] ); 3512 if ( strval( $value ) != strval( $_POST['remote_api_attempts'] ) ) { 3513 $errors[] = array( 3514 'icon' => 'error', 3515 'text' => 'remote_api_attempts must be a number', 3516 ); 3517 } else if ( $value < 1 || $value > 10 ) { 3518 $errors[] = array( 3519 'icon' => 'error', 3520 'text' => 'remote_api_attempts must be between 1 and 10', 3521 ); 3522 } 3523 $this->WPOnlineBackup->Set_Setting( 'remote_api_attempts', $value ); 3524 } 3525 3526 if ( !array_key_exists( 'override_remote_api_wait', $_POST ) || !array_key_exists( 'remote_api_wait', $_POST ) ) { 3527 $this->WPOnlineBackup->Set_Setting( 'remote_api_wait', null ); 3528 } else { 3529 $value = intval( $_POST['remote_api_wait'] ); 3530 if ( strval( $value ) != strval( $_POST['remote_api_wait'] ) ) { 3531 $errors[] = array( 3532 'icon' => 'error', 3533 'text' => 'remote_api_wait must be a number', 3534 ); 3535 } else if ( $value < 1 || $value > 30 ) { 3536 $errors[] = array( 3537 'icon' => 'error', 3538 'text' => 'remote_api_wait must be between 1 and 30', 3539 ); 3540 } 3541 $this->WPOnlineBackup->Set_Setting( 'remote_api_wait', $value ); 3514 $value = intval( $_POST['remote_api_retries'] ); 3515 if ( strval( $value ) != strval( $_POST['remote_api_retries'] ) ) { 3516 $errors[] = array( 3517 'icon' => 'error', 3518 'text' => 'remote_api_retries must be a number', 3519 ); 3520 } else if ( $value < 1 || $value > 50 ) { 3521 $errors[] = array( 3522 'icon' => 'error', 3523 'text' => 'remote_api_retries must be between 1 and 50', 3524 ); 3525 } 3526 $this->WPOnlineBackup->Set_Setting( 'remote_api_retries', $value ); 3542 3527 } 3543 3528 … … 3756 3741 </tr> 3757 3742 <tr valign="top"> 3758 <th scope="row" style="text-align: right; padding: 18px"><label for="remote_api_ attempts" style="font-weight: bold"><?php echo 'remote_api_attempts'; ?></label></th>3759 <td><p><input type="checkbox" name="override_remote_api_ attempts" id="override_remote_api_attempts" value="1"<?php3743 <th scope="row" style="text-align: right; padding: 18px"><label for="remote_api_retries" style="font-weight: bold"><?php echo 'remote_api_retries'; ?></label></th> 3744 <td><p><input type="checkbox" name="override_remote_api_retries" id="override_remote_api_retries" value="1"<?php 3760 3745 // Mark as checked if we selected this option 3761 if ( !is_null( $this->WPOnlineBackup->Get_Setting( 'remote_api_ attempts', true ) ) ) {3746 if ( !is_null( $this->WPOnlineBackup->Get_Setting( 'remote_api_retries', true ) ) ) { 3762 3747 ?> checked="checked"<?php 3763 3748 } 3764 ?>> <input type="text" style="width: 250px" name="remote_api_attempts" id="remote_api_attempts" value="<?php echo $this->WPOnlineBackup->Get_Setting( 'remote_api_attempts' ); ?>"></p></td> 3765 </tr> 3766 <tr valign="top"> 3767 <th scope="row" style="text-align: right; padding: 18px"><label for="remote_api_wait" style="font-weight: bold"><?php echo 'remote_api_wait'; ?></label></th> 3768 <td><p><input type="checkbox" name="override_remote_api_wait" id="override_remote_api_wait" value="1"<?php 3769 // Mark as checked if we selected this option 3770 if ( !is_null( $this->WPOnlineBackup->Get_Setting( 'remote_api_wait', true ) ) ) { 3771 ?> checked="checked"<?php 3772 } 3773 ?>> <input type="text" style="width: 250px" name="remote_api_wait" id="remote_api_wait" value="<?php echo $this->WPOnlineBackup->Get_Setting( 'remote_api_wait' ); ?>"></p></td> 3749 ?>> <input type="text" style="width: 250px" name="remote_api_retries" id="remote_api_retries" value="<?php echo $this->WPOnlineBackup->Get_Setting( 'remote_api_retries' ); ?>"></p></td> 3774 3750 </tr> 3775 3751 <tr valign="top"> -
wponlinebackup/trunk/include/bootstrap.php
r640384 r650319 57 57 // (in the same PHP process) Perform(). So we use this global to ensure we run once per process! 58 58 // We also use this to detect how long we've been running and adjust max_execution_time as necessary 59 global $WPOnlineBackup_Init, $WPOnlineBackup_Perform_Once, $WPOnlineBackup_Perform_Check_Once; 59 60 $WPOnlineBackup_Init = time(); 60 61 $WPOnlineBackup_Perform_Once = false; … … 93 94 // Need formatting functions - used during initialisation of email backup and also during files backup and transmission 94 95 require_once WPONLINEBACKUP_PATH . '/include/formatting.php'; 96 97 // Enable our error handling functions 98 $WPOnlineBackup->Enable_Error_Handling(); 95 99 } 96 100 … … 650 654 if ( $this->status['status'] == WPONLINEBACKUP_STATUS_RUNNING ) { 651 655 652 // Clean up stream but don't wipe it - this will ensure fclose is called on all file handles653 // This should ensure when the next run starts (which will most likely be during this script run since we trigger it directly) that all data has been written to disk654 if ( is_object( $this->stream ) )655 $this->stream->CleanUp( false );656 657 656 // Copy last tick status to current status 658 657 $this->status = $this->last_tick_status; … … 677 676 678 677 } 678 679 // Clean up stream but don't wipe it - this will ensure fclose is called on all file handles 680 // This should ensure when the next run starts (which will most likely be during this script run since we trigger it directly) that all data has been written to disk 681 if ( is_object( $this->stream ) ) 682 $this->stream->CleanUp( false ); 679 683 680 684 // Just in case the below fails, schedule next event … … 1004 1008 // Ignore user aborts 1005 1009 @ignore_user_abort( true ); 1010 1011 // Turn off HTML errors and remove docref_root to normalise error messages 1012 ini_set( 'html_errors', 0 ); 1013 ini_set( 'docref_root', '' ); 1006 1014 1007 1015 // Test safe mode -
wponlinebackup/trunk/include/files.php
r640384 r650319 63 63 WPONLINEBACKUP_FILE_EXCLUDE_PLUGINS_MU => __( 'Multisite plugins directory', 'wponlinebackup' ), 64 64 WPONLINEBACKUP_FILE_EXCLUDE_UPLOADS => __( 'Uploads directory', 'wponlinebackup' ), 65 WPONLINEBACKUP_FILE_EXCLUDE_CUSTOM => __( 'Custom exclude', 'wponlinebackup' ), 65 66 ); 66 67 } … … 78 79 $counter = 0; 79 80 80 // Resolve the root path 81 // Resolve the root path - no need to Normalise_Path orig_root since it is only used in the Log_Event below when we fail to resolve it and we Normalise it there 81 82 $orig_root = preg_replace( '#(?:\\\\|/)$#', '', ABSPATH ); 82 83 … … 84 85 if ( ( $root = @realpath( $orig_root ) ) === false ) { 85 86 86 $ret = OBFW_ Exception();87 $ret = OBFW_Tidy_Exception(); 87 88 88 89 $bootstrap->Log_Event( 89 90 WPONLINEBACKUP_EVENT_ERROR, 90 sprintf( __( 'Failed to resolve the WordPress parent folder path, %s: %s.' , 'wponlinebackup' ), $this->_UTF8_Validate( $orig_root ), $ret ) 91 // For consistency, normalise the root before placing it in the error message 92 sprintf( __( 'Failed to resolve the WordPress parent folder path, %s: %s.' , 'wponlinebackup' ), $this->_UTF8_Validate( $this->Normalise_Path( $orig_root ) ), $ret ) 91 93 ); 92 94 … … 95 97 96 98 } 99 100 // Normalise the root path - along with excludes these are the only inputs that will have directory separators in them - everywhere else we build the path ourselves with a single forward slash so will never need to normalise anywhere else 101 $root = $this->Normalise_Path( $root ); 97 102 98 103 // Always have the root as the folder just above WordPress - we'll just change the stack to only do the WordPress folder if needed … … 135 140 136 141 // Normalise the built-in excludes 137 foreach ( $excludes as $key => $exclude_item ) $excludes[$key] = $this->Normalise_Path($exclude_item); 142 foreach ( $excludes as $key => $exclude_item ) 143 $excludes[ $key ] = $this->Normalise_Path( $exclude_item ); 138 144 139 145 // Grab custom excludes and add them to the list … … 146 152 147 153 // Normalise 148 $exclude_item = $this->Normalise_Path( $exclude_item);154 $exclude_item = $this->Normalise_Path( $exclude_item ); 149 155 150 156 // If prefixed with ../ then take relative to the parent folder if we have one - ignoring the exclude if we don't … … 434 440 435 441 // OK, can't access parent folder, report an error and try with filesystem_upone disabled 436 $report_fallback = OBFW_ Exception();442 $report_fallback = OBFW_Tidy_Exception(); 437 443 438 444 $upone = false; … … 674 680 $tick_progress = $prefix . ':' . $item_path; 675 681 676 // On first timeout we start taking our time, on second timeout we log where we were each time, so on third we can skip the file682 // On first timeout we start taking our time, on second timeout we log where we were each time, so on third we can skip the file 677 683 if ( $this->progress['tick_progress'][0] === $tick_progress ) { 678 684 … … 685 691 if ( is_array( $size = $this->Fetch_Stat( $item_path ) ) ) { 686 692 687 $size = sprintf( __( 'The file size is: %s .' , 'wponlinebackup' ), WPOnlineBackup_Formatting::Fix_B( $size['file_size'], true ) );693 $size = sprintf( __( 'The file size is: %s' , 'wponlinebackup' ), WPOnlineBackup_Formatting::Fix_B( $size['file_size'], true ) ); 688 694 689 695 } else { … … 703 709 } 704 710 705 // Log where we are711 // Log where we are 706 712 $this->progress['tick_progress'] = array( 707 713 0 => $tick_progress, … … 720 726 // Get the next folder to process from the top of the stack 721 727 $this->folder_id = key( $this->job['stack'] ); 722 list ( $parent_id, $parent_folder, $this_folder, $folder_saved ) = current( $this->job['stack'] );728 list ( $parent_id, $parent_folder, $this_folder, $folder_saved ) = current( $this->job['stack'] ); 723 729 724 730 $current_folder = $parent_folder . $this_folder . '/'; … … 772 778 if ( ( $folder = @opendir( $this->job['root'] . $current_folder ) ) === false ) { 773 779 774 $ret = OBFW_ Exception();780 $ret = OBFW_Tidy_Exception(); 775 781 776 782 $this->bootstrap->Log_Event( … … 812 818 813 819 // Have we already visited? 814 if ( true !== ( $ret = $this->Already_Visited( $item, WPONLINEBACKUP_ITEM_FILE, $this->folder_id ) ) ) { 815 816 if ( $ret !== false ) 817 return $ret; 818 819 // Skip symbolic links - we might support them in future, but not now 820 $this->bootstrap->Log_Event( 821 WPONLINEBACKUP_EVENT_INFORMATION, 822 sprintf( __( 'Symbolic link %s was skipped. (Symbolic links are not currently supported.)' , 'wponlinebackup' ), $this->_UTF8_Validate( $current_folder . $item ) ) 823 ); 824 825 // This marking as visited will prevent duplicated log messages 826 if ( true !== ( $ret = $this->Mark_Visited( $item, WPONLINEBACKUP_ITEM_FILE, $this->folder_id ) ) ) 827 return $ret; 828 829 } 820 if ( true === ( $ret = $this->Already_Visited( $item, WPONLINEBACKUP_ITEM_FILE, $this->folder_id ) ) ) 821 continue; 822 823 if ( $ret !== false ) 824 return $ret; 825 826 // Skip symbolic links - we might support them in future, but not now 827 $this->bootstrap->Log_Event( 828 WPONLINEBACKUP_EVENT_INFORMATION, 829 sprintf( __( 'Link %s was skipped: Links are not currently supported' , 'wponlinebackup' ), $this->_UTF8_Validate( $current_folder . $item ) ) 830 ); 831 832 // This marking as visited will prevent duplicated log messages 833 if ( true !== ( $ret = $this->Mark_Visited( $item, WPONLINEBACKUP_ITEM_FILE, $this->folder_id ) ) ) 834 return $ret; 830 835 831 836 } else if ( is_dir( $item_path ) ) { … … 838 843 return $ret; 839 844 840 if ( false !== ( $key = array_search( $ this->Normalise_Path( $item_path ), $this->job['excludes'] ) ) ) {845 if ( false !== ( $key = array_search( $item_path, $this->job['excludes'] ) ) ) { 841 846 842 847 if ( $key > WPONLINEBACKUP_FILE_EXCLUDE_CUSTOM ) … … 846 851 $this->bootstrap->Log_Event( 847 852 WPONLINEBACKUP_EVENT_INFORMATION, 848 sprintf( __( 'Folder %s was excluded . (%s)' , 'wponlinebackup' ), $this->_UTF8_Validate( $current_folder . $item ), $this->exclude_reasons[$key] )853 sprintf( __( 'Folder %s was excluded: %s' , 'wponlinebackup' ), $this->_UTF8_Validate( $current_folder . $item ), $this->exclude_reasons[$key] ) 849 854 ); 850 855 … … 858 863 $this->bootstrap->Log_Event( 859 864 WPONLINEBACKUP_EVENT_WARNING, 860 sprintf( __( 'Folder %s was skipped due to a conflict caused by use of non-UTF8 names. Rename the folder and remove all special characters to resolve.' , 'wponlinebackup' ), $this->_UTF8_Validate( $current_folder . $item ) )865 sprintf( __( 'Folder %s was skipped: Unknown special characters in the folder name; please remove them to allow backup' , 'wponlinebackup' ), $this->_UTF8_Validate( $current_folder . $item ) ) 861 866 ); 862 867 … … 889 894 } 890 895 891 } else if ( false !== ( $key = array_search( $ this->Normalise_Path( $item_path ), $this->job['excludes'] ) ) ) {896 } else if ( false !== ( $key = array_search( $item_path, $this->job['excludes'] ) ) ) { 892 897 893 898 // Have we already visited? 894 if ( true !== ( $ret = $this->Already_Visited( $item, WPONLINEBACKUP_ITEM_FILE, $this->folder_id ) ) ) { 895 896 if ( $ret !== false ) 897 return $ret; 898 899 if ( $key > WPONLINEBACKUP_FILE_EXCLUDE_CUSTOM ) 900 $key = WPONLINEBACKUP_FILE_EXCLUDE_CUSTOM; 901 902 $this->bootstrap->Log_Event( 903 WPONLINEBACKUP_EVENT_INFORMATION, 904 sprintf( __( 'File %s was excluded. (%s)' , 'wponlinebackup' ), $this->_UTF8_Validate( $current_folder . $item ), $this->exclude_reasons[$key] ) 905 ); 906 907 // This marking as visited will prevent duplicated log messages 908 if ( true !== ( $ret = $this->Mark_Visited( $item, WPONLINEBACKUP_ITEM_FILE, $this->folder_id ) ) ) 909 return $ret; 910 911 } 899 if ( true === ( $ret = $this->Already_Visited( $item, WPONLINEBACKUP_ITEM_FILE, $this->folder_id ) ) ) 900 continue; 901 902 if ( $ret !== false ) 903 return $ret; 904 905 if ( $key > WPONLINEBACKUP_FILE_EXCLUDE_CUSTOM ) 906 $key = WPONLINEBACKUP_FILE_EXCLUDE_CUSTOM; 907 908 $this->bootstrap->Log_Event( 909 WPONLINEBACKUP_EVENT_INFORMATION, 910 sprintf( __( 'File %s was excluded: %s' , 'wponlinebackup' ), $this->_UTF8_Validate( $current_folder . $item ), $this->exclude_reasons[$key] ) 911 ); 912 913 // This marking as visited will prevent duplicated log messages 914 if ( true !== ( $ret = $this->Mark_Visited( $item, WPONLINEBACKUP_ITEM_FILE, $this->folder_id ) ) ) 915 return $ret; 912 916 913 917 // Add the item … … 915 919 916 920 // Have we already visited? 917 if ( true !== ( $ret = $this->Already_Visited( $item, WPONLINEBACKUP_ITEM_FILE, $this->folder_id ) ) ) { 918 919 if ( $ret !== false ) 920 return $ret; 921 922 // Special case when returning false is that we encountered another file that conflicts with one we already have, possibly due to UTF-8 conversion 923 $this->bootstrap->Log_Event( 924 WPONLINEBACKUP_EVENT_WARNING, 925 sprintf( __( 'File %s was skipped due to a conflict caused by use of non-UTF8 names. Rename the file and remove all special characters to resolve.' , 'wponlinebackup' ), $this->_UTF8_Validate( $current_folder . $item ) ) 926 ); 927 928 // This marking as visited will prevent duplicated log messages 929 if ( true !== ( $ret = $this->Mark_Visited( $item, WPONLINEBACKUP_ITEM_FOLDER, $this->folder_id ) ) ) 930 return $ret; 931 932 } 921 if ( true === ( $ret = $this->Already_Visited( $item, WPONLINEBACKUP_ITEM_FILE, $this->folder_id ) ) ) 922 continue; 923 924 if ( $ret !== false ) 925 return $ret; 926 927 // Special case when returning false is that we encountered another file that conflicts with one we already have, possibly due to UTF-8 conversion 928 $this->bootstrap->Log_Event( 929 WPONLINEBACKUP_EVENT_WARNING, 930 sprintf( __( 'File %s was skipped: Unknown special characters in the file name; please remove them to allow backup' , 'wponlinebackup' ), $this->_UTF8_Validate( $current_folder . $item ) ) 931 ); 932 933 // This marking as visited will prevent duplicated log messages 934 if ( true !== ( $ret = $this->Mark_Visited( $item, WPONLINEBACKUP_ITEM_FOLDER, $this->folder_id ) ) ) 935 return $ret; 933 936 934 937 } else { … … 1539 1542 $this->job['progress'] = 5; 1540 1543 1541 $this->bootstrap->Tick(); 1544 // Force an update so we update to the deleted files message immediately 1545 $this->bootstrap->Tick( false, true ); 1542 1546 1543 1547 } … … 1622 1626 $this->job['progress'] = 5; 1623 1627 1624 $this->bootstrap->Tick(); 1628 // Force update to set the above message immediately 1629 $this->bootstrap->Tick( false, true ); 1625 1630 1626 1631 } … … 1760 1765 /*private*/ function Fetch_Stat( $file ) 1761 1766 { 1762 if ( ( $file_size = @filesize( $file ) ) === false ) return OBFW_Exception(); 1763 if ( ( $mod_time = @filemtime( $file ) ) === false ) return OBFW_Exception(); 1767 if ( ( $file_size = @filesize( $file ) ) === false ) { 1768 $ret = OBFW_Tidy_Exception(); 1769 return OBFW_FOpen_Exception( $file, $ret ); 1770 } 1771 if ( ( $mod_time = @filemtime( $file ) ) === false ) { 1772 $ret = OBFW_Tidy_Exception(); 1773 return OBFW_FOpen_Exception( $file, $ret ); 1774 } 1764 1775 1765 1776 return compact( 'file_size', 'mod_time' ); -
wponlinebackup/trunk/include/httprange.php
r613977 r650319 98 98 } 99 99 100 // Force buffers to empty 100 // Remove time limit, do NOT ignore user abort, and turn on implicit flush 101 @set_time_limit( 0 ); 102 @ignore_user_abort( false ); 103 @ini_set( 'implicit_flush', 1 ); 104 105 // Don't display errors and remove all error reporting 106 @error_reporting( 0 ); 107 @ini_set( 'display_errors', 0 ); 108 109 // Disable ZLIB output compression and attempt to disable apache gzip compression if we're a module 110 @ini_set( 'zlib.output_compression', 0 ); 111 if ( function_exists( 'apache_setenv' ) ) { 112 @apache_setenv( 'no-gzip', 1 ); 113 @apache_setenv( 'dont-vary', 1 ); 114 } 115 116 // Force buffers to empty and ensure output buffering is off 117 @ini_set( 'output_buffering', 0 ); 101 118 $buffers = ob_get_level(); 102 119 while ( $buffers-- ) … … 110 127 else 111 128 $type = 'application/octet-stream'; 112 113 @set_time_limit( 0 );114 @ignore_user_abort( false );115 @ini_set( 'implicit_flush', 1 );116 129 117 130 header( 'Content-Type: ' . $type ); -
wponlinebackup/trunk/include/stream_delta.php
r640384 r650319 442 442 if ( is_null( $size ) && ( $size = @filesize( $path ) ) === false ) { 443 443 444 $size = OBFW_Exception(); 444 $size = OBFW_Tidy_Exception(); 445 $size = OBFW_FOpen_Exception( $path, $size ); 445 446 return true; 446 447 … … 452 453 if ( ( $status['mod_time'] = @filemtime( $path ) ) === false ) { 453 454 454 $size = OBFW_Exception(); 455 $size = OBFW_Tidy_Exception(); 456 $size = OBFW_FOpen_Exception( $path, $size ); 455 457 return true; 456 458 … … 472 474 if ( ( $data = @file_get_contents( $path ) ) === false ) { 473 475 474 $size = OBFW_ Exception();476 $size = OBFW_Tidy_Exception(); 475 477 return true; 476 478 … … 616 618 // Open file 617 619 if ( !( $fh = @fopen( $path, 'rb' ) ) ) { 618 $size = OBFW_ Exception();620 $size = OBFW_Tidy_Exception(); 619 621 return true; 620 622 } … … 641 643 if ( ( $data = @fread( $fh, $this->WPOnlineBackup->Get_Setting( 'max_block_size' ) ) ) === false ) { 642 644 643 $size = OBFW_ Exception();645 $size = OBFW_Tidy_Exception(); 644 646 645 647 @fclose( $fh ); -
wponlinebackup/trunk/include/stream_full.php
r640384 r650319 424 424 if ( is_null( $size ) && ( $size = @filesize( $path ) ) === false ) { 425 425 426 $size = OBFW_Exception(); 426 $size = OBFW_Tidy_Exception(); 427 $size = OBFW_FOpen_Exception( $path, $size ); 427 428 return true; 428 429 … … 434 435 if ( ( $status['mod_time'] = @filemtime( $path ) ) === false ) { 435 436 436 $size = OBFW_Exception(); 437 $size = OBFW_Tidy_Exception(); 438 $size = OBFW_FOpen_Exception( $path, $size ); 437 439 return true; 438 440 … … 452 454 if ( ( $data = @file_get_contents( $path ) ) === false ) { 453 455 454 $size = OBFW_ Exception();456 $size = OBFW_Tidy_Exception(); 455 457 return true; 456 458 … … 588 590 // Open file 589 591 if ( !( $fh = @fopen( $path, 'rb' ) ) ) { 590 $size = OBFW_ Exception();592 $size = OBFW_Tidy_Exception(); 591 593 return true; 592 594 } … … 613 615 if ( ( $data = @fread( $fh, $this->WPOnlineBackup->Get_Setting( 'max_block_size' ) ) ) === false ) { 614 616 615 $size = OBFW_ Exception();617 $size = OBFW_Tidy_Exception(); 616 618 617 619 @fclose( $fh ); -
wponlinebackup/trunk/include/transmission.php
r640449 r650319 45 45 46 46 $this->db_prefix = $db_prefix; 47 48 // Enable our error handling functions 49 $WPOnlineBackup->Enable_Error_Handling(); 47 50 } 48 51 -
wponlinebackup/trunk/js/progress.js
r619850 r650319 75 75 $('#wponlinebackup_events').css( 'opacity', 0 ).slideDown().animate( { opacity: 1 } ); 76 76 77 var href = WPOnlineBackup_Vars.Events_URL + result.activity_id.toString();77 var href = WPOnlineBackup_Vars.Events_URL + '§ion=events&activity=' + result.activity_id.toString(); 78 78 79 79 if ( $('#wponlinebackup_events_link').attr( 'href' ) != href ) -
wponlinebackup/trunk/readme.txt
r640449 r650319 71 71 72 72 == Changelog == 73 74 = 2.2.16 = 75 * Event log entry for custom excludes now correctly shows (Custom exclude) instead of () 76 * Fix broken filesystem excludes on Windows systems 77 * Cleaner error reporting when files can't be accessed 78 * Installations on PHP4 now report errors properly instead of "Unknown error" 79 * Minor tweaks 73 80 74 81 = 2.2.15 = -
wponlinebackup/trunk/wponlinebackup.php
r640449 r650319 5 5 Description: Online Backup for WordPress can automatically backup your WordPress database and filesystem on a configurable schedule and can incrementally send the backup compressed (and optionally encrypted using DES or AES) to our online vault where you can later retrieve it. Backups can also be emailed to you or produced on-demand and downloaded straight to your computer. You can view the current status and change settings at "Tools -> Online Backup", or by clicking the "View Status" link next to the plugin name in the Plugins list. 6 6 Author: Jason Woods @ Backup Technology 7 Version: 2.2.1 57 Version: 2.2.16 8 8 Author URI: http://www.backup-technology.com/ 9 9 Licence: GPLv2 - See LICENCE.txt … … 19 19 20 20 // Version 21 define( 'WPONLINEBACKUP_VERSION', '2.2.1 5' );21 define( 'WPONLINEBACKUP_VERSION', '2.2.16' ); 22 22 define( 'WPONLINEBACKUP_DBVERSION', 11 ); 23 23 … … 38 38 define( 'PHP_EOL', "\n" ); // Default to Linux style 39 39 40 // Exception helpers 41 function OBFW_Exception() 40 // Our custom error handler - Only used when we are missing error_get_last() and only activated when WPOnlineBackup::Enable_Error_Handling is called 41 global $OBFW_Error_Handler; 42 $OBFW_Error_Handler = false; 43 44 class OBFW_Error_Handler 42 45 { 43 / / PHP 4 does not have error_get_last()44 / / - We could possibly improve this by passing $php_errormsg to this function as if track_errors in On it will have the error message45 // - A better solution would probably to set our own error handler - but that may not be worth the time as people are gradually shifting to PHP 5 46 if ( !function_exists('error_get_last'))47 return 'Unknown error';48 49 $err = error_get_last();50 if ( is_null($err) ) 51 return 'No message was logged.';52 53 // If the last error was an E_STRICT notice it will most likely be due to our PHP 4 compatibility so pretend no message was logged54 if ( defined('E_STRICT') && $err['type'] == E_STRICT )55 return 'No error message was logged.';56 57 return 'An error happened at: ' . basename( $err['file'] ) . '(' . $err['line'] . ')' . PHP_EOL .58 $err['message'];59 } 60 61 function OBFW_Exception_WP( $wp_error)62 { 63 $codes = $wp_error->get_error_codes(); 64 $messages = $wp_error->get_error_messages();65 66 $errors = array(); 67 foreach ( $codes as $key => $code)68 $errors[] = '[Error Code ' . $code . '] ' . $messages[$key];69 70 return implode( PHP_EOL, $errors );46 /*private*/ var $Last = null; 47 /*private*/ var $Previous_Handler; 48 49 /*public*/ function OBFW_Error_Handler() 50 { 51 $this->Previous_Handler = set_error_handler( array( & $this, 'Handler' ) ); 52 } 53 54 /*public*/ function Handler( $type, $message, $file, $line, $context ) 55 { 56 $this->Last = array( 57 'type' => $type, 58 'message' => $message, 59 'file' => $file, 60 'line' => $line, 61 ); 62 63 // Call the original error handler 64 if ( !is_null( $this->Previous_Handler ) ) 65 return call_user_func( $this->Previous_Handler, $type, $message, $file, $line, $context ); 66 67 return false; 68 } 69 70 /*public*/ function Get_Last() 71 { 72 return $this->Last; 73 } 71 74 } 72 75 … … 131 134 $this->admin = new WPOnlineBackup_Admin( $this ); 132 135 136 } 137 } 138 139 /*public*/ function Enable_Error_Handling() 140 { 141 // If we've already enabled our error handling functions, return 142 if ( function_exists( 'OBFW_Exception' ) ) 143 return; 144 145 // PHP4 does not have error_get_last, so let's create one 146 // We could use php_errormsg but it requires track_errors On and we need to pass it as a parameter to OBFW_Exception, and it won't exist if there is a user error handler that returned true 147 if ( !function_exists( 'error_get_last' ) ) { 148 149 // Important to get a REFERENCE to the handler back, otherwise the new will create it, and $this is registered as the event handler, but when we get it we'll actually copy it! 150 // This is also why we use GLOBALS superglobal - it is the only way to set a global to a reference as something - the global keyword essentially created a new variable in the local scope that references the global scope - if we set a reference on that we'd lose the link to global scope 151 $GLOBALS['OBFW_Error_Handler'] = & new OBFW_Error_Handler(); 152 153 function error_get_last() 154 { 155 return $GLOBALS['OBFW_Error_Handler']->Get_Last(); 156 } 157 158 } 159 160 function OBFW_Exception() 161 { 162 $err = error_get_last(); 163 if ( is_null( $err ) ) 164 return 'No message was logged.'; 165 166 // If the last error was an E_STRICT notice it will most likely be due to our PHP 4 compatibility so pretend no message was logged 167 if ( defined( 'E_STRICT' ) && $err['type'] == E_STRICT ) 168 return 'No error message was logged.'; 169 170 return 'An error happened at: ' . basename( $err['file'] ) . '(' . $err['line'] . ')' . PHP_EOL . 171 $err['message']; 172 } 173 174 function OBFW_Tidy_Exception() 175 { 176 $err = error_get_last(); 177 if ( is_null( $err ) ) 178 return 'No message was logged.'; 179 180 // If the last error was an E_STRICT notice it will most likely be due to our PHP 4 compatibility so pretend no message was logged 181 if ( defined( 'E_STRICT' ) && $err['type'] == E_STRICT ) 182 return 'No error message was logged.'; 183 184 // Try to match the error - hopefully this will match all languages as it bases solely on the layout of the error message 185 // If we can't match, just return the original message untouched 186 if ( !preg_match( '/^[^:(]+(?:\\(.*?\\))?(?: \\[.*?\\])?: (?:[^:]+: )([^:]+)$/', $err['message'], $matches ) ) 187 return $err['message']; 188 189 // Message matches nicely so let's return just the bit we need 190 return $matches[1]; 191 } 192 193 function OBFW_FOpen_Exception( $path, $original ) 194 { 195 // We call this when we failed to call filesize or stat, because they simply return "stat failed" which is pretty useless 196 // Calling fopen and getting the error from that will give us a better error, such as "permission denied" 197 if ( false === ( $f = @fopen( $path, 'rb' ) ) ) 198 return OBFW_Tidy_Exception(); 199 200 // We opened successfully, which is odd, so just close and return the original exception 201 @fclose( $f ); 202 203 return $original; 204 } 205 206 function OBFW_Exception_WP( $wp_error ) 207 { 208 $codes = $wp_error->get_error_codes(); 209 $messages = $wp_error->get_error_messages(); 210 211 $errors = array(); 212 foreach ( $codes as $key => $code ) 213 $errors[] = '[Error Code ' . $code . '] ' . $messages[$key]; 214 215 return implode( PHP_EOL, $errors ); 133 216 } 134 217 } … … 760 843 $usage = memory_get_usage(); 761 844 762 // If our current free memory is less than what we're about to use, try to adjust 845 // If our current free memory is less than what we're about to use, try to adjust, but don't drop too far 763 846 if ( ( $free = $memory_limit - $usage ) < $ret * 1.2 ) 764 $ret = floor( $free / 1.2);847 $ret = max( floor( $free / 1.2 ), 65535 ); 765 848 766 849 } … … 783 866 // If our current free memory is less than what we're about to use, try to adjust 784 867 if ( ( $free = $memory_limit - $usage ) < $ret * 1.2 ) 785 $ret = floor( $free / 1.2);868 $ret = max( floor( $free / 1.2 ), 65535 ); 786 869 787 870 }
Note: See TracChangeset
for help on using the changeset viewer.