Exemplo n.º 1
0
         }
     }
     unset($item['description']);
 }
 // The publish date
 if (isset($item['pubDate'])) {
     $item['pubDate'] = parse_date($item['pubDate']);
 }
 // Filesize and content type
 $cacheid = $item['enclosure']['_params']['url'];
 if (isset($item['enclosure']['_params']['type']) && isset($item['enclosure']['_params']['length'])) {
     //
 } elseif (!isset($data['cache'][$cacheid])) {
     $headers = get_remote_headers($item['enclosure']['_params']['url']);
     $type = get_content_type($headers);
     $length = get_content_length($headers);
     if (!$headers) {
         appcastr_die('Appcastr can\'t make a connection to <code>' . $item['enclosure']['url'] . '</code>, or the file doesn\'t exist.');
     } else {
         $item['enclosure']['_params']['type'] = $type;
         $item['enclosure']['_params']['length'] = $length;
         $data['cache'][$cacheid] = array('type' => $type, 'length' => $length);
     }
 } elseif (isset($data['cache'][$cacheid])) {
     $item['enclosure']['_params']['type'] = $data['cache'][$cacheid]['type'];
     $item['enclosure']['_params']['length'] = $data['cache'][$cacheid]['length'];
 }
 // Still no content type?
 if (!isset($item['enclosure']['_params']['type'])) {
     $item['enclosure']['_params']['type'] = 'application/octet-stream';
 }
Exemplo n.º 2
0
    }
    $filesize = filesize($file);
    $from_byte = intval($start_time * $filesize / $chunk_size);
    if ($duration + $start_time >= $chunk_size) {
        $to_byte = $filesize;
        $duration -= $chunk_size - $start_time;
        $start_time = 0;
    } else {
        $to_byte = intval(($start_time + $duration) * $filesize / $chunk_size);
        $duration = 0;
    }
    $queue[] = array("filename" => $file, "from_byte" => $from_byte, "to_byte" => $to_byte, "size" => $to_byte - $from_byte);
    $start_time = 0;
    $file = get_next_file($file);
}
$size = get_content_length($queue);
_log("\nTotal size: " . $size);
if (isset($_SERVER['HTTP_RANGE'])) {
    list($size_unit, $range_orig) = explode('=', $_SERVER['HTTP_RANGE'], 2);
    if ($size_unit == 'bytes') {
        list($range, $extra_ranges) = explode(',', $range_orig, 2);
        _log("Range: " . $range_orig);
    } else {
        $range = '';
    }
} else {
    $range = '';
}
list($seek_start, $seek_end) = explode('-', $range, 2);
$seek_end = empty($seek_end) ? $size - 1 : min(abs(intval($seek_end)), $size - 1);
$seek_start = empty($seek_start) || $seek_end < abs(intval($seek_start)) ? 0 : max(abs(intval($seek_start)), 0);