Plugin Directory


Ignore:
Timestamp:
06/03/2013 05:52:33 PM (13 years ago)
Author:
fabifott
Message:

WP-Filebase 0.2.9.37

  • Fixed Batch Uploader
  • Further memory optimizations
  • Updated DataTables to 1.9.4
  • Fixed monthly/daily traffic limit
  • Fixed download range header handling (thanks to mrogaski)
  • Minified DataTables init JS to prevent auto <p>
  • Added wpfilebase_file_downloaded hook for download logging
  • Fixed HTML escaping for some file template vars
Location:
wp-filebase/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-filebase/trunk

    • Property svn:ignore set to
      .git
  • wp-filebase/trunk/classes/Download.php

    r702142 r722195  
    4343    $traffic = wpfb_call('Misc','GetTraffic');
    4444   
    45     $limit_month = (WPFB_Core::GetOpt('traffic_month') * 1048576);
    46     $limit_day = (WPFB_Core::GetOpt('traffic_day') * 1073741824);
     45    $limit_month = (WPFB_Core::GetOpt('traffic_month') * 1073741824); //GiB
     46    $limit_day = (WPFB_Core::GetOpt('traffic_day') * 1048576); // MiB
    4747   
    4848    return ( ($limit_month == 0 || ($traffic['month'] + $file_size) < $limit_month) && ($limit_day == 0 || ($traffic['today'] + $file_size) < $limit_day) );
     
    417417       
    418418    $begin = 0;
    419     $end = $size;
     419    $end = $size-1;
    420420
    421421    $http_range = isset($_SERVER['HTTP_RANGE']) ? $_SERVER['HTTP_RANGE'] : '';
    422422    if(!empty($http_range) && strpos($http_range, 'bytes=') !== false && strpos($http_range, ',') === false) // multi-range not supported (yet)!
    423423    {
    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        }
    428431    } else
    429432        $http_range = '';
    430433   
    431     if($begin > 0 || $end < $size)
     434    if($begin > 0 || $end < ($size-1))
    432435        header('HTTP/1.0 206 Partial Content');
    433436    else
    434437        header('HTTP/1.0 200 OK');
    435438       
    436     $length = ($end-$begin);
     439    $length = ($end-$begin+1);
    437440    WPFB_Download::AddTraffic($length);
    438441   
     
    448451    header("Content-Length: " . $length);
    449452    if(!empty($http_range))
    450         header("Content-Range: bytes " . $begin . "-" . ($end-1) . "/" . $size);
     453        header("Content-Range: bytes $begin-$end/$size");
    451454   
    452455    // clean up things that are not needed for download
     
    484487        $cur = $begin;
    485488       
    486         while(!@feof($fh) && $cur < $end && @connection_status() == 0)
     489        while(!@feof($fh) && $cur <= $end && @connection_status() == 0)
    487490        {       
    488             $nbytes = min($buffer_size, $end-$cur);
     491            $nbytes = min($buffer_size, $end-$cur+1);
    489492            $ts = microtime(true);
    490493
Note: See TracChangeset for help on using the changeset viewer.