Download resume problem
-
hi am using this plugin for my download site…but when user download file they cannot resume download.
please help me
Viewing 5 replies - 1 through 5 (of 5 total)
-
Resumable downloads are not currently supported in Delightful Downloads I’m afraid.
Ashley
Can you enable that,,,we will waiting for update,,,
Yeah, it will be coming in a future update.
Ashley
hi,im trying to edit your plugin.and now download resume is enable.tested by me on my site.
visit free after effects templates.i just replace process-download.php using code below.and plugin is working fine
<?php /** * Delightful Downloads Process Download * * @package Delightful Downloads * @subpackage Includes/Process Downloads * @since 1.0 */ // Exit if accessed directly if ( !defined( 'ABSPATH' ) ) exit; /** * Process Download * * Validate download and send file to user * http://www.richnetapps.com/php-download-script-with-resume-option/ * * @since 1.0 */ function dedo_download_process() { global $dedo_options; // Get download id if ( isset( $_GET[$dedo_options['download_url']] ) ) { // Ensure only positive int, else could be fishy! $download_id = absint( $_GET[$dedo_options['download_url']] ); // Check valid download if ( !dedo_download_valid( $download_id ) ) { do_action( 'ddownload_download_invalid', $download_id ); wp_die( __( 'Invalid download.', 'delightful-downloads' ) ); } // Check blocked user agents if ( !dedo_download_blocked( $_SERVER['HTTP_USER_AGENT'] ) ) { do_action( 'ddownload_download_blocked', $download_id ); wp_die( __( 'You are blocked from downloading this file!', 'delightful-downloads' ) ); } // Get file meta $download_url = get_post_meta( $download_id, '_dedo_file_url', true ); $options = get_post_meta( $download_id, '_dedo_file_options', true ); // Check for members only if ( !dedo_download_permission( $options ) ) { do_action( 'ddownload_download_permission', $download_id ); // Get redirect location $location = ( isset( $options['members_only_redirect'] ) ) ? $options['members_only_redirect'] : $dedo_options['members_only_redirect']; // Try to redirect if ( $location = get_permalink( $location ) ) { wp_redirect( $location ); exit(); } else { // Invalid page provided, show error message wp_die( __( 'Please login to download this file!', 'delightful-downloads' ) ); } } // Password protected if ( post_password_required( $download_id ) ) { wp_die( get_the_password_form( $download_id ), __( 'Password Required', 'delightful-downloads' ) ); } // Empty file urls not allowed if ( '' === $download_url ) { wp_die( __( 'You must attach a file to this download.', 'delightful-downloads' ) ); } // Stop page caching. Cause conflicts with WP Super Cache define( 'DONOTCACHEPAGE', true ); // Disable php notices, can cause corrupt downloads @ini_set( 'display_errors', 0 ); // Disable compression if ( function_exists( 'apache_setenv' ) ) { @apache_setenv( 'no-gzip', 1 ); } @ini_set( 'zlib.output_compression', 'Off' ); // Close sessions, which can sometimes cause buffering errors?? @session_write_close(); /** * Output Buffering * * The majority of servers work when clearing output buffering. * If you get corrupt or blank downloads try the following: * * Disable by adding the following, to your theme's functions.php file: * * add_filter( 'dedo_clear_output_buffers', '__return_false' ); * */ if ( apply_filters( 'dedo_clear_output_buffers', true ) ) { do { @ob_end_clean(); } while ( ob_get_level() > 0 ); } // Disable max_execution_time set_time_limit( 0 ); // Hook before download starts do_action( 'ddownload_download_before', $download_id ); // Open in browser $open_browser = ( isset( $options['open_browser'] ) ) ? $options['open_browser'] : $dedo_options['open_browser']; if ( $open_browser ) { header( "Location: $download_url" ); exit(); } // Convert to path if ( $download_path = dedo_get_abs_path( $download_url ) ) { // Try to open file, else display server error if ( !$file = @fopen( $download_path, 'rb' ) ) { // Server error wp_die( __( 'Server error, file cannot be opened!', 'delightful-downloads' ) ); } //check if http_range is sent by browser (or download manager) if(isset($_SERVER['HTTP_RANGE'])) { list($size_unit, $range_orig) = explode('=', $_SERVER['HTTP_RANGE'], 2); if ($size_unit == 'bytes') { //multiple ranges could be specified at the same time, but for simplicity only serve the first range //http://tools.ietf.org/id/draft-ietf-http-range-retrieval-00.txt list($range, $extra_ranges) = explode(',', $range_orig, 2); } else { $range = ''; header('HTTP/1.1 416 Requested Range Not Satisfiable'); exit; } } else { $range = ''; } //figure out download piece from range (if set) list($seek_start, $seek_end) = explode('-', $range, 2); //set start and end based on range (if set), else set defaults //also check for invalid ranges. $seek_end = (empty($seek_end)) ? ($file_size - 1) : min(abs(intval($seek_end)),($file_size - 1)); $seek_start = (empty($seek_start) || $seek_end < abs(intval($seek_start))) ? 0 : max(abs(intval($seek_start)),0); //Only send partial content header if downloading a piece of the file (IE workaround) if ($seek_start > 0 || $seek_end < ($file_size - 1)) { header('HTTP/1.1 206 Partial Content'); header('Content-Range: bytes '.$seek_start.'-'.$seek_end.'/'.$file_size); header('Content-Length: '.($seek_end - $seek_start + 1)); } // Set headers nocache_headers(); header( "X-Robots-Tag: noindex, nofollow", true ); header( "Content-Type: " . dedo_download_mime( $download_path ) ); header( "Content-Description: File Transfer" ); header( "Content-Disposition: attachment; filename=\"" . basename( $download_path ) . "\";" ); header( "Content-Transfer-Encoding: binary" ); header('Accept-Ranges: bytes'); header( "Content-Length: " . @filesize( $download_path ) ); // filesize causes blank downloads on Windows servers // Output file in chuncks while ( !feof( $file ) ) { print fread( $file, 1024 * 1024 ); flush(); // Check conection, if lost close file and end loop if ( connection_status() != 0 ) { fclose( $file ); exit(); } } // Reached end of file, close it. Job done! fclose( $file ); // Hook when download complete do_action( 'ddownload_download_complete', $download_id ); // Done! Exit exit(); } else { // No disoverable path, redirect to file header( "Location: $download_url" ); exit(); } } } add_action( 'init', 'dedo_download_process', 0 );
Thanks for the code vmay. This will get worked into a future update.
Ashley
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Download resume problem’ is closed to new replies.