News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

How to improve downloading and add resume support?

Started by manis99, August 22, 2010, 02:29:08 AM

Previous topic - Next topic

manis99

Hi ,
I m using 2.0 rc3 on my forum http://myemobiles.com .
The prob. Is that smf default downloading is not resume supported. It sucks when u hv to download large file on slow connection. It doesn't even show the file size while downloading.

Is there anyway to solve it. It there anyway to show file size during downloading and make it resumable. What and where the coding is needed?

Kill Em All

There is no SMF default download manager. Which download mod are you using?


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

manis99

Yeah i know. M nt using any download mod. I mean to say the default simple downloading from smf based sites. The files we uploaded when we need to download it, then this happens.


manis99

its not the web host prob. bcz all other sites on that host support resuming. except smf.

u can test it with the official smf forum. it will also not give u resume support.

Kill Em All

What downloading are you using? You do mean by resume support? resume as in a job application type file?


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

manis99

resume mean to start the downloading file again from the break point.
in smf if u stopped the download in the middle or it got stopped due to network failure then the file will again start from the begining except from the breakpoint.
  want an eg. Then download any file from my forum or from smf itself and then stop it in the middle before completion and then see it will start from begining instead of the breakpoint. And then download anything from phpbb,mybb,vbulletin or other based forums and do the same with those files and then start again then see that will start from breakpoint.
    this is very irritating.

Kill Em All

Thats just how it is, there is really no getting around beginning a download from where you left off. I suppose it could be done, maybe if someone created a mod to allow something like utorrent to download the SMF attachment... it would be a difficult mod to code though I would imagine.


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

manis99

i need it very badly. Bcz my site is growing and members r having problems in downloading. I dont want to leave smf. But this one is pretty imp and if remain unsolved then will hv to move to other forum software.

Kill Em All

Every other forum software is gonna have this problem, the whole internet is gonna have this problem pretty much...

Have you considered changing web hosts to avoid disconnection issues?


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

SlammedDime

Adding Resume support isn't an easy task... it would require reworking SMF's download function quite a bit.... I'm thinking of adding this for the new Customize site... if I can get something in working form, I'll probably submit it as a modification... it probably would not be a default feature in SMF 2.0... perhaps the next version of SMF.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

manis99

Quote from: SlammedDime on August 26, 2010, 02:56:42 AM
Adding Resume support isn't an easy task... it would require reworking SMF's download function quite a bit.... I'm thinking of adding this for the new Customize site... if I can get something in working form, I'll probably submit it as a modification... it probably would not be a default feature in SMF 2.0... perhaps the next version of SMF.

That's why i m afraid , its still no final version of 2.0 then how can we expect for other next versions. Btw it is the only thing i don't like in smf .

hope u get succed soon.. plz post a reply here when u r done.

or any other member can help me then plz.... :)

Kill Em All

It would def be something that would probably rely heavily on cookies too, which could be a possible slowdown if it relies to much on them.


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

SlammedDime

Naw, cookies aren't needed for it... nothing extra is needed except a server that supports it (I'd imagine that apache probably does) and the code to make it work in PHP.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

Kill Em All

Really? How would it keep track then of where someone left of downloading?


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

SlammedDime

The browser or download manager itself keeps track, and if you try to 'resume' the download, it sends a 'HTTP_RANGE' header that includes the amount that has been downloaded so far, then in the PHP script, you break apart the header to determine where it left off, then you 'seek' to that place in the file and start sending the download from there.  It's not difficult to do, but because of the way SMF does downloads, it will take some reworking.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

SlammedDime

#16
Update: I have successfully added Resume support on the new customize site I'm writing... I'll work on getting it packaged into a modification for SMF... unfortunately it might take more work on SMF itself... I'm using a heavily modified version of SMF's attachment download function on the new cust site.

Update 2: I found a different way to do it using the same code on both the new cust site and my test SMF install... Just need to verify it works on SMF and I'll post some code for anyone to test out...

Update 3:  Try the following:

Update 4: Code deleted - see below.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

SlammedDime

#17
I forgot an important piece of code that could cause issues with some resume requests... use the code below:

File: Sources/Display.php

Code (Find) Select
// Since we don't do output compression for files this large...
if (filesize($filename) > 4194304 || !empty($resuming))
{
// Forcibly end any output buffering going on.
if (function_exists('ob_get_level'))
{
while (@ob_get_level() > 0)
@ob_end_clean();
}
else
{
@ob_end_clean();
@ob_end_clean();
@ob_end_clean();
}

$fp = fopen($filename, 'rb');
while (!feof($fp))
{
if (isset($callback))
echo $callback(fread($fp, 8192));
else
echo fread($fp, 8192);
flush();
}
fclose($fp);
}


Code (Replace) Select
// Resume support?
$filesize = filesize($filename);
if (!in_array('ob_gzhandler', ob_list_handlers()) && !isset($callback)  && isset($_SERVER['HTTP_RANGE']) && preg_match('~bytes=(\d+)-(\d*)~i', $_SERVER['HTTP_RANGE'], $range))
{
list(, $seek_start, $seek_end) = $range;

$seek_end = empty($seek_end) ? $filesize - 1 : min(abs(intval($seek_end)), $filesize - 1);
$seek_start = empty($seek_start) || $seek_end < abs(intval($seek_start)) ? 0 : max(abs(intval($seek_start)), 0);

if ($seek_start > 0 || $seek_end < $filesize - 1)
{
header('HTTP/1.1 206 Partial Content');
header('Content-Range: bytes ' . $seek_start . '-' . $seek_end . '/' . $filesize);
$filesize = $seek_end - $seek_start + 1;
header('Content-Length: ' . $filesize);
$resuming = TRUE;
}
}

// Since we don't do output compression for files this large...
if ($filesize > 4194304 || !empty($resuming))
{
// Forcibly end any output buffering going on.
if (function_exists('ob_get_level'))
{
while (@ob_get_level() > 0)
@ob_end_clean();
}
else
{
@ob_end_clean();
@ob_end_clean();
@ob_end_clean();
}

$fp = fopen($filename, 'rb');
if (!empty($resuming))
fseek($fp, $seek_start);
while (!feof($fp) && $filesize > 0)
{
$read_length = $filesize < 8192 ? $filesize : 8192;
if (isset($callback))
echo $callback(fread($fp, $read_length));
else
echo fread($fp, $read_length);
flush();
$filesize -= $read_length;
}
fclose($fp);
}
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

manis99

#18
This doesnt work.........
still the same thing happen . it doesn't even show the filesize.
and also no resume support.

SlammedDime

#19
How are you testing it?  What are you using to download with?  And what specifically are you downloading?

I should have probably clarified what it will and will not work with...

If the file is greater than or equal to 4MB, it will always work unless the following is true:
   If the file is 'txt', 'css', 'htm', 'html', 'php', 'xml' and $modSettings['attachmentRecodeLineEndings'] is set

If the file is less than 4MB, it will work unless the following is true:
   If the file is 'txt', 'html', 'htm', 'js', 'doc', 'pdf', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java' and $modSettings['enableCompressedOutput'] is set.

I tested using FireFox and a 35MB zip file and it worked flawlessly.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

manis99

actually i tried to download symbian .sis file and .jar file , both of almost 1mb size but the resume didn't worked. Tried with chrome as well firefox.

SlammedDime

How did you test it?  I tested by starting the download, then canceling the download in firefox's download window, then clicking the small 'resume' icon in firefox's download window to restart it.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

manis99

i did the same too. But it refused to download. It either stops or download from start.

SlammedDime

SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

manis99

you can test with http://myemobiles.com



. Try to download attachment in the below link and stop it in the middle  then start again.    http://myemobiles.com/index.php/topic,1012.0.html

SlammedDime

Do you have a test account I can use to log in with? 
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

yakyakyak

tried this late last night and pause/resume on local hosted files working perfect!

manis99

Sorry for late reply
Here is a demo a/c.
Username : demo
Pass : demo123

SlammedDime

Last thing... and hopefully I'll be able to figure it out... need a phpinfo() file.  What is a phpinfo() file?
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

manis99

#29
Got it solved almost. But prob remain with some browsers and some file type eg. .sis, .sisx

Kill Em All

We, and when I say we I mean SD is probably going to still need a phpinfo link.


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

manis99


Kill Em All

Warning: phpinfo() has been disabled for security reasons in /home/myemobil/public_html/phpinfo.php on line 1

Your host is blocking the phpinfo file from being created, you can try to ask them to please disable it.


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

SlammedDime

You may want to find a new host... anyone that blocks phpinfo must be really insecure with their hosting abilities...
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

manis99



SlammedDime

The settings on there look okay from what I can tell.  I was mainly concerned about zlib and it seems to be okay.

Are there some files this works for you with, and others it doesn't?  If so, what works and what doesn't?
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

manis99

only zip and rar files r working. They r resume supported now , while other files eg: .jar , .sis , .sisx , .thm , .nth is not showing resume support.


Advertisement: