Index: classes/Download.php =================================================================== --- classes/Download.php (revision 706775) +++ classes/Download.php (working copy) @@ -416,24 +416,24 @@ wp_die(__('Could not read file!', WPFB)); $begin = 0; - $end = $size; + $end = $size - 1; $http_range = isset($_SERVER['HTTP_RANGE']) ? $_SERVER['HTTP_RANGE'] : ''; if(!empty($http_range) && strpos($http_range, 'bytes=') !== false && strpos($http_range, ',') === false) // multi-range not supported (yet)! { $range = explode('-', trim(substr($http_range, 6))); $begin = 0 + trim($range[0]); - if(!empty($range[1])) + if(is_numeric($range[1])) $end = 0 + trim($range[1]); } else $http_range = ''; - if($begin > 0 || $end < $size) + if($begin > 0 || $end < ($size - 1)) header('HTTP/1.0 206 Partial Content'); else header('HTTP/1.0 200 OK'); - $length = ($end-$begin); + $length = ($end - $begin + 1); WPFB_Download::AddTraffic($length); @@ -447,7 +447,7 @@ } header("Content-Length: " . $length); if(!empty($http_range)) - header("Content-Range: bytes " . $begin . "-" . ($end-1) . "/" . $size); + header("Content-Range: bytes " . $begin . "-" . $end . "/" . $size); // clean up things that are not needed for download @session_write_close(); // disable blocking of multiple downloads at the same time @@ -483,9 +483,9 @@ $cur = $begin; - while(!@feof($fh) && $cur < $end && @connection_status() == 0) + while(!@feof($fh) && $cur <= $end && @connection_status() == 0) { - $nbytes = min($buffer_size, $end-$cur); + $nbytes = min($buffer_size, $end - $cur + 1); $ts = microtime(true); print @fread($fh, $nbytes); @@ -534,4 +534,4 @@ return array('error' => false, 'size' => $size); } -} \ No newline at end of file +}