1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
<?php
@ini_set('memory_limit', '640M');
@ini_set('error_reporting', E_ALL & ~ E_NOTICE);
@ini_set('display_errors', 1);
// désactivation compression GZip
if (ini_get("zlib.output_compression")) {
ini_set("zlib.output_compression", "Off");
}
// ouverture d'une session
session_start();
if(!isset($_REQUEST['link']) || empty($_REQUEST['link']))
{
header("HTTP/1.0 400 Bad Request");
exit;
}
$header = get_headers($_REQUEST['link'], 1);
$file = $_REQUEST['link'];
$name = $_REQUEST['name'];
$ContentType = $header['Content-Type'];
$size = $header['Content-Length'];
// fermeture de la session
session_write_close();
header("Content-Type: $ContentType");
header('Content-Disposition: attachment; filename='.$name);
header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: post-check=0,pre-check=0");
header("Cache-Control: max-age=0");
header("Pragma: no-cache");
header("Expires: 0");
header('Accept-Ranges: bytes');
header('Content-Length: ' . $size);
readfile($file);
exit();
?> |
Partager