• [MOD] Resume download (not working properly) 1 0 5 1
Currently:  

Author Topic: [MOD] Resume download (not working properly)  (Read 25731 times)

0 Members and 1 Guest are viewing this topic.

Offline kerberos

  • Pre-Newbie
  • Posts: 2
    • View Profile
[MOD] Resume download (not working properly)
« 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
Code: [Select]
$user_access = get_permission();
add after
Code: [Select]
$rangeheader=getenv("HTTP_RANGE");
$rangeheader=str_replace("bytes=","",$rangeheader);
$range=explode("-", $rangeheader);
$offset1=$range[0];
$offset2=$range[1];

find
Code: [Select]
function get_file_data($file_path) {
  global $script_url;

replace
Code: [Select]
global $script_url;with
Code: [Select]
global $script_url,$offset1,$offset2;
find and comment out
Code: [Select]
  ob_start();
  @ob_implicit_flush(0);
  @readfile($file_path);
  $file_data = ob_get_contents();
  ob_end_clean();

add after commented

Code: [Select]
  $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
Code: [Select]
else {
  echo $lang['download_error']."\n<!-- NO ACTION SPECIFIED //-->";
  exit;
}

if (!empty($file['file_data'])) {

add after
Code: [Select]
  header("HTTP/1.1 206 Partial Content");

find
Code: [Select]
  else {
    header("Content-Disposition: attachment; filename=\"".$file['file_name']."\"\n");
    header("Content-Type: application/octet-stream\n");
  }

add after
Code: [Select]
  header("Accept-Ranges:bytes");
  header("Content-Range:bytes ${offset1}-${offset2}/".filesize($file["file_path"]));
  header("Connection:close");
  header("Content-Length: ".($offset2-$offset1)."\n\n");
« Last Edit: March 19, 2006, 09:37:32 PM by V@no »

TheOracle

  • Guest
Re: [MOD] Resume download
« Reply #1 on: September 03, 2005, 04:09:02 PM »
Outstanding addon. I was hoping to have these functions personally someday. ;)

Offline kerberos

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [MOD] Resume download
« Reply #2 on: September 07, 2005, 01:17:02 PM »
This mod addicted to users who has 56Kb dial-up connection...and useful for downloading big files.... and.... its really outstanding  8)

Offline silencess

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [MOD] Resume download
« Reply #3 on: January 20, 2006, 10:38:03 AM »
сыпет ошибки  - PHP Warning:  Cannot modify header information - headers already sent by (output started at ..../download.php:71) in ..../download.php on line 277

как поправить ?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Resume download
« Reply #4 on: January 20, 2006, 02:05:53 PM »
FAQ
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline silencess

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [MOD] Resume download
« Reply #5 on: January 23, 2006, 05:16:23 AM »
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?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Resume download
« Reply #6 on: January 23, 2006, 05:25:47 AM »
Где можно это увидеть?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline silencess

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [MOD] Resume download
« Reply #7 on: January 23, 2006, 05:35:56 AM »
можно по руски - ок !
ошибку увидеть ? её видно только по логам php. плюс из за ошибки идет сильная нагрузка на сервер.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Resume download
« Reply #8 on: January 23, 2006, 05:55:29 AM »
А что находится на строках с 70 по 72 в download.php?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline silencess

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [MOD] Resume download
« Reply #9 on: January 23, 2006, 06:07:43 AM »
70   if (empty($offset2)) $offset2=filesize($file_path)-1;
71  $file_data=fread($fp, $offset2-$offset1);
72  fclose($fp);

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Resume download
« Reply #10 on: January 23, 2006, 06:52:03 AM »
можно попробовать добавить кляп в это строку:
Quote
$file_data=@fread($fp, $offset2-$offset1);
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline silencess

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [MOD] Resume download
« Reply #11 on: January 23, 2006, 10:24:28 AM »
кляп просто не будет скандалить - но серверу от этого легче не станет :( на нем так же будет большая загрузка от обработки кривых хедеров.

вот тут нашел сие:
Code: [Select]
Как корректно заставить броузер скачать и записать файл вместо открытия
в окне с поддержкой докачки? (пример скрипта)
Предполагается, что
$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($fdfilesize($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;

?>

можно как нибудь с помощью этого подправить мод ?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Resume download
« Reply #12 on: January 23, 2006, 02:09:36 PM »
кляп просто не будет скандалить - но серверу от этого легче не станет :( на нем так же будет большая загрузка от обработки кривых хедеров.

вот тут нашел сие:

можно как нибудь с помощью этого подправить мод ?
Я не вижу большего отличия в этом коде, там используется абсолютно такой-же принцип как и в моде.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline silencess

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [MOD] Resume download
« Reply #13 on: January 24, 2006, 04:31:18 AM »
тогда стоит отказаться от возможности докачки ? неужели нет никаких вариантов ?
странно почему движек изначчально не поддерживает такую функцию. ведь даже если использовать его для фотографий то фотографии не так уж мало весят тем более когда качать избраное. ;)

Offline kief24

  • Sr. Member
  • ****
  • Posts: 267
    • View Profile
Re: [MOD] Resume download
« Reply #14 on: February 09, 2006, 05:43:52 PM »
Hello, i get this error when i try to download :

Code: [Select]
Parse error: parse error, unexpected ',' in /home/educima/public_html/download.php on line 108
on line 108 :   
Code: [Select]
$script_url,$offset1,$offset2;