Witam. Mam taki skrypt. Co zrobic aby pliki można było pobierac z zewnętrznego serwera ???
<?php
$file = stripslashes($_GET['file']);
if (! is_file($file))
{
header('HTTP/1.1 404 File Not Found');
die();
}
$fname = basename($file);
$fsize = filesize($file);
$ftime = filemtime($file);
$range = $_SERVER['HTTP_RANGE'];
$r_start = 0;
$c_length = $fsize;
if ($range)
{
$reg = "/bytes=([0-9]+)-([0-9]*)/";
preg_match($reg, $range, $matches);
$r_start = (int) $matches[1];
$r_stop = (int) $matches[2];
if ($r_stop < $r_start) $r_stop = $fsize - 1;
$c_length = $r_stop - $r_start + 1;
header('HTTP/1.1 206 Partial Content');
header('Content-Range: bytes ' .
$r_start . '-' . $r_stop . '/' . $fsize);
}
else
{
header('HTTP/1.1 200 OK');
}
header('Last-Modified: ' .
gmdate('D, d M Y H:i:s', $ftime) . ' GMT');
header('Content-Disposition: ' .
'attachment; filename="' . $fname . '"');
header('Accept-Ranges: bytes');
header('Content-Type: application/x-unknown');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . $c_length);
if ($fp = fopen($file, 'rb'))
{
flock($fp, 1);
fseek($fp, $r_start);
echo(fread($fp, $c_length));
flock($fp, 3);
fclose($fp);
}
?>