<?php
//error_reporting(0);
$download = 'http://s52.jakisadres/download/128265050_255103_1308449084_0_9241315151731';
$remoteFile = $download;
$ch = curl_init($remoteFile);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
$data = curl_exec($ch);
curl_close($ch);
if ($data === false) {
}
if (preg_match('/^HTTP\/1\.[01] (\d\d\d)/', $data, $matches)) { $status = (int)$matches[1];
}
if (preg_match('/Content-Length: (\d+)/', $data, $matches)) { $waga = (int)$matches[1];
}
if (preg_match('/filename="(.*)"/', $data, $wynik)){ $nazwa = trim($wynik[1
]); }
//print_r($waga);
switch( $file_extension ) {
case "exe":
$ctype="application/octet-stream";
break;
case "rar":
$ctype="application/x-rar-compressed";
break;
case "zip":
$ctype="application/zip";
break;
case "mp3":
$ctype="audio/mpeg";
break;
case "mpg":
$ctype="video/mpeg";
break;
case "avi":
$ctype="video/x-msvideo";
break;
case "php":
case "htm":
case "html":
case "txt":
die("<b>Bład plik ". $file_extension ." !</b>"); break;
default:
$ctype="application/force-download";
}
header("Cache-Control: public"); header("Content-Type: $ctype");
$header='Content-Disposition: attachment; filename='.$filespaces;
header("Accept-Ranges: bytes");
$size = $waga;
if(isset($_SERVER['HTTP_RANGE'])) {
$seek_range = substr($_SERVER['HTTP_RANGE'] , 6
); $range = explode( '-', $seek_range); if($range[0
] > 0
) { $seek_start = intval($range[0
]); } if($range[1
] > 0
) { $seek_end = intval($range[1
]); }
header("HTTP/1.1 206 Partial Content"); header("Content-Length: " . ($seek_end - $seek_start + 1
)); header("Content-Range: bytes $seek_start-$seek_end/$size"); } else {
header("Content-Range: bytes 0-$seek_end/$size"); header("Content-Length: $waga"); }
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $download);
curl_exec($ch);
curl_close($ch);
?>
niestety niewiem czemu nie wznawia mi połączenie jak zerwie się trzeba potem od nowa pobierać
Ten post edytował krysia5522 5.09.2011, 17:03:19