From 16b8fb476df8bc68488b2c496a88c3da84f72526 Mon Sep 17 00:00:00 2001 From: denis Date: Thu, 21 May 2026 20:50:39 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20download.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- download.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 download.php diff --git a/download.php b/download.php new file mode 100644 index 0000000..f19b6cd --- /dev/null +++ b/download.php @@ -0,0 +1,51 @@ +0) $to++; +if ($to) $to-=$from;header('HTTP/1.1 206 Partial Content'); +$cr='Content-Range: bytes ' . $from . '-' . (($to)?($to . '/' . $to+1):filesize($filename)); +} else header('HTTP/1.1 200 Ok'); +$etag=md5($filename); +$etag=substr($etag, 0, 8) . '-' . substr($etag, 8, 7) . '-' . substr($etag, 15, 8); +header('ETag: "' . $etag . '"'); +header('Accept-Ranges: bytes'); +header('Content-Length: ' . (filesize($filename)-$to+$from)); +if ($cr) header($cr); +header('Connection: close'); +header('Content-Type: ' . $mimetype); +header('Last-Modified: ' . gmdate('r', filemtime($filename))); +$f=fopen($filename, 'r'); +header('Content-Disposition: attachment; filename="' . basename($filename) . '";'); +if ($from) fseek($f, $from, SEEK_SET); +if (!isset($to) or empty($to)) {$size=filesize($filename)-$from; +} else {$size=$to; +} + +$downloaded = 0; +while( (!feof($f)) && (connection_status()==0) && ($downloaded < $size) ) { + +$block = min(1024*8, $size - $downloaded); +print(fread($f, $block)); +$downloaded += $block; +flush(); +} + +fclose($f); +exit; \ No newline at end of file