Changeset 722195 for wp-filebase/trunk/classes/Download.php
- Timestamp:
- 06/03/2013 05:52:33 PM (13 years ago)
- Location:
- wp-filebase/trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
classes/Download.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-filebase/trunk
-
Property
svn:ignore
set to
.git
-
Property
svn:ignore
set to
-
wp-filebase/trunk/classes/Download.php
r702142 r722195 43 43 $traffic = wpfb_call('Misc','GetTraffic'); 44 44 45 $limit_month = (WPFB_Core::GetOpt('traffic_month') * 10 48576);46 $limit_day = (WPFB_Core::GetOpt('traffic_day') * 10 73741824);45 $limit_month = (WPFB_Core::GetOpt('traffic_month') * 1073741824); //GiB 46 $limit_day = (WPFB_Core::GetOpt('traffic_day') * 1048576); // MiB 47 47 48 48 return ( ($limit_month == 0 || ($traffic['month'] + $file_size) < $limit_month) && ($limit_day == 0 || ($traffic['today'] + $file_size) < $limit_day) ); … … 417 417 418 418 $begin = 0; 419 $end = $size ;419 $end = $size-1; 420 420 421 421 $http_range = isset($_SERVER['HTTP_RANGE']) ? $_SERVER['HTTP_RANGE'] : ''; 422 422 if(!empty($http_range) && strpos($http_range, 'bytes=') !== false && strpos($http_range, ',') === false) // multi-range not supported (yet)! 423 423 { 424 $range = explode('-', trim(substr($http_range, 6))); 425 $begin = 0 + trim($range[0]); 426 if(!empty($range[1])) 427 $end = 0 + trim($range[1]); 424 $range = array_map('trim',explode('-', trim(substr($http_range, 6)))); 425 if(is_numeric($range[0])) { 426 $begin = 0 + $range[0]; 427 if(is_numeric($range[1])) $end = 0 + $range[1]; 428 } else { 429 $begin = $size - $range[1]; // format "-x": last x bytes 430 } 428 431 } else 429 432 $http_range = ''; 430 433 431 if($begin > 0 || $end < $size)434 if($begin > 0 || $end < ($size-1)) 432 435 header('HTTP/1.0 206 Partial Content'); 433 436 else 434 437 header('HTTP/1.0 200 OK'); 435 438 436 $length = ($end-$begin );439 $length = ($end-$begin+1); 437 440 WPFB_Download::AddTraffic($length); 438 441 … … 448 451 header("Content-Length: " . $length); 449 452 if(!empty($http_range)) 450 header("Content-Range: bytes " . $begin . "-" . ($end-1) . "/" . $size);453 header("Content-Range: bytes $begin-$end/$size"); 451 454 452 455 // clean up things that are not needed for download … … 484 487 $cur = $begin; 485 488 486 while(!@feof($fh) && $cur < $end && @connection_status() == 0)489 while(!@feof($fh) && $cur <= $end && @connection_status() == 0) 487 490 { 488 $nbytes = min($buffer_size, $end-$cur );491 $nbytes = min($buffer_size, $end-$cur+1); 489 492 $ts = microtime(true); 490 493
Note: See TracChangeset
for help on using the changeset viewer.