Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

WP-Filebase Range handling patch for 0.2.9.36..

By: a guest on May 2nd, 2013  |  syntax: Diff  |  size: 1.59 KB  |  views: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Index: classes/Download.php
  2. ===================================================================
  3. --- classes/Download.php        (revision 706775)
  4. +++ classes/Download.php        (working copy)
  5. @@ -416,7 +416,7 @@
  6.                 wp_die(__('Could not read file!', WPFB));
  7.                
  8.         $begin = 0;
  9. -       $end = $size;
  10. +       $end = $size - 1;
  11.  
  12.         $http_range = isset($_SERVER['HTTP_RANGE']) ? $_SERVER['HTTP_RANGE'] : '';
  13.         if(!empty($http_range) && strpos($http_range, 'bytes=') !== false && strpos($http_range, ',') === false) // multi-range not supported (yet)!
  14. @@ -428,12 +428,12 @@
  15.         } else
  16.                 $http_range = '';
  17.        
  18. -       if($begin > 0 || $end < $size)
  19. +       if($begin > 0 || $end < ($size - 1))
  20.                 header('HTTP/1.0 206 Partial Content');
  21.         else
  22.                 header('HTTP/1.0 200 OK');
  23.                
  24. -       $length = ($end-$begin);
  25. +       $length = ($end - $begin + 1);
  26.         WPFB_Download::AddTraffic($length);
  27.        
  28.        
  29. @@ -447,7 +447,7 @@
  30.         }
  31.         header("Content-Length: " . $length);
  32.         if(!empty($http_range))
  33. -               header("Content-Range: bytes " . $begin . "-" . ($end-1) . "/" . $size);
  34. +               header("Content-Range: bytes " . $begin . "-" . $end . "/" . $size);
  35.        
  36.         // clean up things that are not needed for download
  37.         @session_write_close(); // disable blocking of multiple downloads at the same time
  38. @@ -485,7 +485,7 @@
  39.                
  40.                 while(!@feof($fh) && $cur < $end && @connection_status() == 0)
  41.                 {              
  42. -                       $nbytes = min($buffer_size, $end-$cur);
  43. +                       $nbytes = min($buffer_size, $end - $cur + 1);
  44.                         $ts = microtime(true);
  45.  
  46.                         print @fread($fh, $nbytes);
  47. @@ -534,4 +534,4 @@
  48.         return array('error' => false, 'size' => $size);
  49.  }
  50.  
  51. -}
  52. \ No newline at end of file
  53. +}