4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: kerberos on September 02, 2005, 06:40:54 PM
-
[EDIT by V@no]
This mod does not work properly.
Moved to the end of the forum untill problem resolved
[/EDIT]
Hi ;)
This mod allows you to resume broken downloads.
open download.php
find
$user_access = get_permission();
add after
$rangeheader=getenv("HTTP_RANGE");
$rangeheader=str_replace("bytes=","",$rangeheader);
$range=explode("-", $rangeheader);
$offset1=$range[0];
$offset2=$range[1];
find function get_file_data($file_path) {
global $script_url;
replace
global $script_url;
with
global $script_url,$offset1,$offset2;
find and comment out
ob_start();
@ob_implicit_flush(0);
@readfile($file_path);
$file_data = ob_get_contents();
ob_end_clean();
add after commented
$fp=fopen($file_path,"rb");
fseek($fp,$offset1);
if (empty($offset2)) $offset2=filesize($file_path)-1;
$file_data=fread($fp, $offset2-$offset1);
fclose($fp);
find else {
echo $lang['download_error']."\n<!-- NO ACTION SPECIFIED //-->";
exit;
}
if (!empty($file['file_data'])) {
add after
header("HTTP/1.1 206 Partial Content");
find else {
header("Content-Disposition: attachment; filename=\"".$file['file_name']."\"\n");
header("Content-Type: application/octet-stream\n");
}
add after
header("Accept-Ranges:bytes");
header("Content-Range:bytes ${offset1}-${offset2}/".filesize($file["file_path"]));
header("Connection:close");
header("Content-Length: ".($offset2-$offset1)."\n\n");
-
Outstanding addon. I was hoping to have these functions personally someday. ;)
-
This mod addicted to users who has 56Kb dial-up connection...and useful for downloading big files.... and.... its really outstanding 8)
-
сыпет ошибки - PHP Warning: Cannot modify header information - headers already sent by (output started at ..../download.php:71) in ..../download.php on line 277
как поправить ?
-
FAQ
-
Where exactly do not prompt? That that is written http://www.4homepages.de/forum/index.php?topic=3378.0 and http://www.4homepages.de/forum/index.php?topic=7277.0 Does not approach at all about that... I know that a problem with headings. I know that there is a mistake - when try to download in some streams but how to solve a problem?
-
Где можно это увидеть?
-
можно по руски - ок !
ошибку увидеть ? её видно только по логам php. плюс из за ошибки идет сильная нагрузка на сервер.
-
А что находится на строках с 70 по 72 в download.php?
-
70 if (empty($offset2)) $offset2=filesize($file_path)-1;
71 $file_data=fread($fp, $offset2-$offset1);
72 fclose($fp);
-
можно попробовать добавить кляп в это строку:
$file_data=@fread($fp, $offset2-$offset1);
-
кляп просто не будет скандалить - но серверу от этого легче не станет :( на нем так же будет большая загрузка от обработки кривых хедеров.
вот тут нашел сие:
Как корректно заставить броузер скачать и записать файл вместо открытия
в окне с поддержкой докачки? (пример скрипта)
Предполагается, что
$cd - путь к файлу,
$fn - имя файла
<?php
$filename = $cd."/".$fn;
if (!file_exists($filename))
{
header ("HTTP/1.0 404 Not Found");
exit;
}
$fsize = filesize($filename);
$ftime = date("D, d M Y H:i:s T", filemtime($filename));
$fd = @fopen($filename, "rb");
if (!$fd){
header ("HTTP/1.0 403 Forbidden");
exit;
}
// Если запрашивающий агент поддерживает докачку
if ($HTTP_SERVER_VARS["HTTP_RANGE"]) {
$range = $HTTP_SERVER_VARS["HTTP_RANGE"];
$range = str_replace("bytes=", "", $range);
$range = str_replace("-", "", $range);
if ($range) {fseek($fd, $range);}
}
$content = fread($fd, filesize($filename));
fclose($fd);
if ($range) {
header("HTTP/1.1 206 Partial Content");
}
else {
header("HTTP/1.1 200 OK");
}
header("Content-Disposition: attachment; filename=$fn");
header("Last-Modified: $ftime");
header("Accept-Ranges: bytes");
header("Content-Length: ".($fsize-$range));
header("Content-Range: bytes $range-".($fsize -1)."/".$fsize);
header("Content-type: application/octet-stream");
print $content;
exit;
?>
можно как нибудь с помощью этого подправить мод ?
-
кляп просто не будет скандалить - но серверу от этого легче не станет :( на нем так же будет большая загрузка от обработки кривых хедеров.
вот тут нашел сие:
можно как нибудь с помощью этого подправить мод ?
Я не вижу большего отличия в этом коде, там используется абсолютно такой-же принцип как и в моде.
-
тогда стоит отказаться от возможности докачки ? неужели нет никаких вариантов ?
странно почему движек изначчально не поддерживает такую функцию. ведь даже если использовать его для фотографий то фотографии не так уж мало весят тем более когда качать избраное. ;)
-
Hello, i get this error when i try to download :
Parse error: parse error, unexpected ',' in /home/educima/public_html/download.php on line 108
on line 108 : $script_url,$offset1,$offset2;
-
its a typo in the tutorial (fixed now)
replace that line with:global $script_url,$offset1,$offset2;
-
I've "unsticky" this topic because it does not work properly. You should not install it, unless you willing to fix it ;)
It will stay this way untill its fixed.
-
Can anyone fix this one for us users please? :D
Regards.
-
just trying my luck again...I use 1.7.6...anyone?