Plugin Directory

Changeset 650319


Ignore:
Timestamp:
01/09/2013 04:53:57 PM (13 years ago)
Author:
Driskell
Message:

Stage 2.2.16

Location:
wponlinebackup/trunk
Files:
10 edited

Legend:

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

    r640384 r650319  
    831831                    'jquery',
    832832                ),
    833                 '2012082801'
     833                '2013010201'
    834834            );
    835835            wp_localize_script(
     
    840840                    'Plugin_URL'        => WPONLINEBACKUP_URL,
    841841                    'Plugin_File'       => WPONLINEBACKUP_FILE,
    842                     'Events_URL'        => 'tools.php?page=' . urlencode( WPONLINEBACKUP_FILE ) . '&section=events&activity=',
     842                    'Events_URL'        => 'tools.php?page=' . urlencode( WPONLINEBACKUP_FILE ),
    843843                    'String_Backup'     => _x( 'Backup', 'Plugin section', 'wponlinebackup' ),
    844844                    'Refresh_Interval'  => 2,
     
    12611261    /*private*/ function Prepare_Decrypt()
    12621262    {
     1263        // Enable our error handling functions
     1264        $this->WPOnlineBackup->Enable_Error_Handling();
     1265
    12631266        // Just try and create the upload folder - ignore error - it just means it is there when they upload via FTP if at all possible
    12641267        // 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
     
    29042907                                $errors[] = array(
    29052908                                    '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' ),
    29072910                                );
    29082911
     
    35063509            }
    35073510
    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 );
    35103513            } 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 );
    35423527            }
    35433528
     
    37563741</tr>
    37573742<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"<?php
     3743<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
    37603745// 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 ) ) ) {
    37623747?> checked="checked"<?php
    37633748        }
    3764 ?>>&nbsp;<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 ?>>&nbsp;<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?>>&nbsp;<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>
    37743750</tr>
    37753751<tr valign="top">
  • wponlinebackup/trunk/include/bootstrap.php

    r640384 r650319  
    5757// (in the same PHP process) Perform(). So we use this global to ensure we run once per process!
    5858// We also use this to detect how long we've been running and adjust max_execution_time as necessary
     59global $WPOnlineBackup_Init, $WPOnlineBackup_Perform_Once, $WPOnlineBackup_Perform_Check_Once;
    5960$WPOnlineBackup_Init = time();
    6061$WPOnlineBackup_Perform_Once = false;
     
    9394        // Need formatting functions - used during initialisation of email backup and also during files backup and transmission
    9495        require_once WPONLINEBACKUP_PATH . '/include/formatting.php';
     96
     97        // Enable our error handling functions
     98        $WPOnlineBackup->Enable_Error_Handling();
    9599    }
    96100
     
    650654        if ( $this->status['status'] == WPONLINEBACKUP_STATUS_RUNNING ) {
    651655
    652             // Clean up stream but don't wipe it - this will ensure fclose is called on all file handles
    653             // 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
    654             if ( is_object( $this->stream ) )
    655                 $this->stream->CleanUp( false );
    656 
    657656            // Copy last tick status to current status
    658657            $this->status = $this->last_tick_status;
     
    677676
    678677        }
     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 );
    679683
    680684        // Just in case the below fails, schedule next event
     
    10041008        // Ignore user aborts
    10051009        @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', '' );
    10061014
    10071015        // Test safe mode
  • wponlinebackup/trunk/include/files.php

    r640384 r650319  
    6363            WPONLINEBACKUP_FILE_EXCLUDE_PLUGINS_MU  => __( 'Multisite plugins directory', 'wponlinebackup' ),
    6464            WPONLINEBACKUP_FILE_EXCLUDE_UPLOADS => __( 'Uploads directory', 'wponlinebackup' ),
     65            WPONLINEBACKUP_FILE_EXCLUDE_CUSTOM  => __( 'Custom exclude', 'wponlinebackup' ),
    6566        );
    6667    }
     
    7879        $counter = 0;
    7980
    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
    8182        $orig_root = preg_replace( '#(?:\\\\|/)$#', '', ABSPATH );
    8283
     
    8485        if ( ( $root = @realpath( $orig_root ) ) === false ) {
    8586
    86             $ret = OBFW_Exception();
     87            $ret = OBFW_Tidy_Exception();
    8788
    8889            $bootstrap->Log_Event(
    8990                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 )
    9193            );
    9294
     
    9597
    9698        }
     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 );
    97102
    98103        // Always have the root as the folder just above WordPress - we'll just change the stack to only do the WordPress folder if needed
     
    135140
    136141        // 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 );
    138144
    139145        // Grab custom excludes and add them to the list
     
    146152
    147153            // Normalise
    148             $exclude_item = $this->Normalise_Path($exclude_item);
     154            $exclude_item = $this->Normalise_Path( $exclude_item );
    149155
    150156            // If prefixed with ../ then take relative to the parent folder if we have one - ignoring the exclude if we don't
     
    434440
    435441                    // 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();
    437443
    438444                    $upone = false;
     
    674680        $tick_progress = $prefix . ':' . $item_path;
    675681
    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 file
     682        // 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
    677683        if ( $this->progress['tick_progress'][0] === $tick_progress ) {
    678684
     
    685691                if ( is_array( $size = $this->Fetch_Stat( $item_path ) ) ) {
    686692
    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 ) );
    688694
    689695                } else {
     
    703709        }
    704710
    705 // Log where we are
     711        // Log where we are
    706712        $this->progress['tick_progress'] = array(
    707713            0   => $tick_progress,
     
    720726        // Get the next folder to process from the top of the stack
    721727        $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'] );
    723729
    724730        $current_folder = $parent_folder . $this_folder . '/';
     
    772778            if ( ( $folder = @opendir( $this->job['root'] . $current_folder ) ) === false ) {
    773779
    774                 $ret = OBFW_Exception();
     780                $ret = OBFW_Tidy_Exception();
    775781
    776782                $this->bootstrap->Log_Event(
     
    812818
    813819                // 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;
    830835
    831836            } else if ( is_dir( $item_path ) ) {
     
    838843                    return $ret;
    839844
    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'] ) ) ) {
    841846
    842847                    if ( $key > WPONLINEBACKUP_FILE_EXCLUDE_CUSTOM )
     
    846851                    $this->bootstrap->Log_Event(
    847852                        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] )
    849854                    );
    850855
     
    858863                    $this->bootstrap->Log_Event(
    859864                        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 ) )
    861866                    );
    862867
     
    889894                }
    890895
    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'] ) ) ) {
    892897
    893898                // 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;
    912916
    913917            // Add the item
     
    915919
    916920                // 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;
    933936
    934937            } else {
     
    15391542            $this->job['progress'] = 5;
    15401543
    1541             $this->bootstrap->Tick();
     1544            // Force an update so we update to the deleted files message immediately
     1545            $this->bootstrap->Tick( false, true );
    15421546
    15431547        }
     
    16221626            $this->job['progress'] = 5;
    16231627
    1624             $this->bootstrap->Tick();
     1628            // Force update to set the above message immediately
     1629            $this->bootstrap->Tick( false, true );
    16251630
    16261631        }
     
    17601765    /*private*/ function Fetch_Stat( $file )
    17611766    {
    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        }
    17641775
    17651776        return compact( 'file_size', 'mod_time' );
  • wponlinebackup/trunk/include/httprange.php

    r613977 r650319  
    9898        }
    9999
    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 );
    101118        $buffers = ob_get_level();
    102119        while ( $buffers-- )
     
    110127        else
    111128            $type = 'application/octet-stream';
    112 
    113         @set_time_limit( 0 );
    114         @ignore_user_abort( false );
    115         @ini_set( 'implicit_flush', 1 );
    116129
    117130        header( 'Content-Type: ' . $type );
  • wponlinebackup/trunk/include/stream_delta.php

    r640384 r650319  
    442442        if ( is_null( $size ) && ( $size = @filesize( $path ) ) === false ) {
    443443
    444             $size = OBFW_Exception();
     444            $size = OBFW_Tidy_Exception();
     445            $size = OBFW_FOpen_Exception( $path, $size );
    445446            return true;
    446447
     
    452453            if ( ( $status['mod_time'] = @filemtime( $path ) ) === false ) {
    453454
    454                 $size = OBFW_Exception();
     455                $size = OBFW_Tidy_Exception();
     456                $size = OBFW_FOpen_Exception( $path, $size );
    455457                return true;
    456458
     
    472474            if ( ( $data = @file_get_contents( $path ) ) === false ) {
    473475
    474                 $size = OBFW_Exception();
     476                $size = OBFW_Tidy_Exception();
    475477                return true;
    476478
     
    616618        // Open file
    617619        if ( !( $fh = @fopen( $path, 'rb' ) ) ) {
    618             $size = OBFW_Exception();
     620            $size = OBFW_Tidy_Exception();
    619621            return true;
    620622        }
     
    641643            if ( ( $data = @fread( $fh, $this->WPOnlineBackup->Get_Setting( 'max_block_size' ) ) ) === false ) {
    642644
    643                 $size = OBFW_Exception();
     645                $size = OBFW_Tidy_Exception();
    644646
    645647                @fclose( $fh );
  • wponlinebackup/trunk/include/stream_full.php

    r640384 r650319  
    424424        if ( is_null( $size ) && ( $size = @filesize( $path ) ) === false ) {
    425425
    426             $size = OBFW_Exception();
     426            $size = OBFW_Tidy_Exception();
     427            $size = OBFW_FOpen_Exception( $path, $size );
    427428            return true;
    428429
     
    434435            if ( ( $status['mod_time'] = @filemtime( $path ) ) === false ) {
    435436
    436                 $size = OBFW_Exception();
     437                $size = OBFW_Tidy_Exception();
     438                $size = OBFW_FOpen_Exception( $path, $size );
    437439                return true;
    438440
     
    452454            if ( ( $data = @file_get_contents( $path ) ) === false ) {
    453455
    454                 $size = OBFW_Exception();
     456                $size = OBFW_Tidy_Exception();
    455457                return true;
    456458
     
    588590        // Open file
    589591        if ( !( $fh = @fopen( $path, 'rb' ) ) ) {
    590             $size = OBFW_Exception();
     592            $size = OBFW_Tidy_Exception();
    591593            return true;
    592594        }
     
    613615            if ( ( $data = @fread( $fh, $this->WPOnlineBackup->Get_Setting( 'max_block_size' ) ) ) === false ) {
    614616
    615                 $size = OBFW_Exception();
     617                $size = OBFW_Tidy_Exception();
    616618
    617619                @fclose( $fh );
  • wponlinebackup/trunk/include/transmission.php

    r640449 r650319  
    4545
    4646        $this->db_prefix = $db_prefix;
     47
     48        // Enable our error handling functions
     49        $WPOnlineBackup->Enable_Error_Handling();
    4750    }
    4851
  • wponlinebackup/trunk/js/progress.js

    r619850 r650319  
    7575                    $('#wponlinebackup_events').css( 'opacity', 0 ).slideDown().animate( { opacity: 1 } );
    7676
    77                 var href = WPOnlineBackup_Vars.Events_URL + result.activity_id.toString();
     77                var href = WPOnlineBackup_Vars.Events_URL + '&section=events&activity=' + result.activity_id.toString();
    7878
    7979                if ( $('#wponlinebackup_events_link').attr( 'href' ) != href )
  • wponlinebackup/trunk/readme.txt

    r640449 r650319  
    7171
    7272== 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
    7380
    7481= 2.2.15 =
  • wponlinebackup/trunk/wponlinebackup.php

    r640449 r650319  
    55Description: 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.
    66Author: Jason Woods @ Backup Technology
    7 Version: 2.2.15
     7Version: 2.2.16
    88Author URI: http://www.backup-technology.com/
    99Licence: GPLv2 - See LICENCE.txt
     
    1919
    2020// Version
    21 define( 'WPONLINEBACKUP_VERSION', '2.2.15' );
     21define( 'WPONLINEBACKUP_VERSION', '2.2.16' );
    2222define( 'WPONLINEBACKUP_DBVERSION', 11 );
    2323
     
    3838    define( 'PHP_EOL', "\n" ); // Default to Linux style
    3939
    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
     41global $OBFW_Error_Handler;
     42$OBFW_Error_Handler = false;
     43
     44class OBFW_Error_Handler
    4245{
    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 message
    45     // - 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 logged
    54     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    }
    7174}
    7275
     
    131134            $this->admin = new WPOnlineBackup_Admin( $this );
    132135
     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 );
    133216        }
    134217    }
     
    760843                            $usage = memory_get_usage();
    761844
    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
    763846                            if ( ( $free = $memory_limit - $usage ) < $ret * 1.2 )
    764                                 $ret = floor( $free / 1.2 );
     847                                $ret = max( floor( $free / 1.2 ), 65535 );
    765848
    766849                        }
     
    783866                            // If our current free memory is less than what we're about to use, try to adjust
    784867                            if ( ( $free = $memory_limit - $usage ) < $ret * 1.2 )
    785                                 $ret = floor( $free / 1.2 );
     868                                $ret = max( floor( $free / 1.2 ), 65535 );
    786869
    787870                        }
Note: See TracChangeset for help on using the changeset viewer.