Plugin Directory

Changeset 338704

Timestamp:
01/30/2011 02:01:49 AM (13 years ago)
Author:
filosofo
Message:

check to see if gzipping successful; if not, download full sized file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-db-backup/tags/2.2.4/wp-db-backup.php

    r338565 r338704  
    183183            default:
    184184                $this->deliver_backup($this->backup_file, $via);
    185                 $this->error_display( 'frame' );
    186             }
    187             die();
     185                );
     186            }
     187            ;
    188188        }
    189189        if (isset($_GET['fragment'] )) {
     
    245245            <script type="text/javascript">
    246246            //<![CDATA[
     247
     248
     249
     250
     251
     252
     253
     254
     255
    247256            window.onbeforeunload = function() {
    248257                return "' . __('Navigating away from this page will cause your backup to fail.', 'wp-db-backup') . '";
     
    286295                window.onbeforeunload = null;
    287296                fram.src = "' . $download_uri . '";
     297
     298
     299
    288300            ';
    289301            break;
     
    10171029       
    10181030        $diskfile = $this->backup_dir . $filename;
     1031
     1032
    10191033        /**
    1020          * Try to compress to gzip, if available
     1034         * Try
    10211035         */
    1022         if ( function_exists('gzencode') ) {
    1023             $gz_diskfile = "{$diskfile}.gz";
    1024             if ( function_exists('file_get_contents') ) {
    1025                 $text = file_get_contents($diskfile);
    1026             } else {
    1027                 $text = implode("", file($diskfile));
    1028             }
    1029             $gz_text = gzencode($text, 9);
    1030             $fp = fopen($gz_diskfile, "w");
    1031             fwrite($fp, $gz_text);
    1032             if ( fclose($fp) ) {
     1036        if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < 64 ) ) {
     1037            @ini_set('memory_limit', '64M' );
     1038        }
     1039
     1040        if ( file_exists( $diskfile ) && empty( $_GET['download-retry'] ) ) {
     1041            /**
     1042             * Try gzipping with an external application
     1043             */
     1044            if ( file_exists( $diskfile ) && ! file_exists( $gz_diskfile ) ) {
     1045                @exec( "gzip $diskfile" );
     1046            }
     1047
     1048            if ( file_exists( $gz_diskfile ) ) {
    10331049                unlink($diskfile);
    10341050                $diskfile = $gz_diskfile;
    10351051                $filename = "{$filename}.gz";
    1036             }
    1037         }
    1038         /*
    1039          *
    1040          */
     1052           
     1053            /**
     1054             * Try to compress to gzip, if available
     1055             */
     1056            } else {
     1057                if ( function_exists('gzencode') ) {
     1058                    if ( function_exists('file_get_contents') ) {
     1059                        $text = file_get_contents($diskfile);
     1060                    } else {
     1061                        $text = implode("", file($diskfile));
     1062                    }
     1063                    $gz_text = gzencode($text, 9);
     1064                    $fp = fopen($gz_diskfile, "w");
     1065                    fwrite($fp, $gz_text);
     1066                    if ( fclose($fp) ) {
     1067                        unlink($diskfile);
     1068                        $diskfile = $gz_diskfile;
     1069                        $filename = "{$filename}.gz";
     1070                    }
     1071                }
     1072            }
     1073            /*
     1074             *
     1075             */
     1076        }
    10411077
    10421078        if ('http' == $delivery) {
    1043             if (! file_exists($diskfile))
     1079            if (
    10441080                $this->error(array('kind' => 'fatal', 'msg' => sprintf(__('File not found:%s','wp-db-backup'), "&nbsp;<strong>$filename</strong><br />") . '<br /><a href="' . $this->page_url . '">' . __('Return to Backup','wp-db-backup') . '</a>'));
    1045             header('Content-Description: File Transfer');
    1046             header('Content-Type: application/octet-stream');
    1047             header('Content-Length: ' . filesize($diskfile));
    1048             header("Content-Disposition: attachment; filename=$filename");
    1049             $success = readfile($diskfile);
    1050             unlink($diskfile);
     1081            } elseif ( file_exists( $diskfile ) ) {
     1082                header('Content-Description: File Transfer');
     1083                header('Content-Type: application/octet-stream');
     1084                header('Content-Length: ' . filesize($diskfile));
     1085                header("Content-Disposition: attachment; filename=$filename");
     1086                $success = readfile($diskfile);
     1087                unlink($diskfile);
     1088            }
    10511089        } elseif ('smtp' == $delivery) {
    10521090            if (! file_exists($diskfile)) {
Note: See TracChangeset for help on using the changeset viewer.