Google

NukeCoder


View next topic
View previous topic
Post new topic   Reply to topic
Author Message
nuke-design




Joined: Jan 19, 2008
Posts: 51

PostPosted: Tue Apr 21, 2009 11:42 pm
Reply with quote

max maxupload is 64mb

i have a a 400 mb file in shop

after they purchase it downlaods files cept it only downloads bout 10 mbs then quits? will not download entire file?
 
View user's profile Send private message
Guardian




Joined: Dec 09, 2006
Posts: 335

PostPosted: Fri Apr 24, 2009 2:07 pm
Reply with quote

Is 64mb the max file size limitation for your server?

_________________
Code Authors Nuke Reviews 
View user's profile Send private message
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 921

PostPosted: Mon May 04, 2009 3:15 pm
Reply with quote

This is probably due to output buffering. Output buffering on large files can cause php to run out of memory very quickly. On small files, it isn't really a big deal but it does cause a noticeable delay from when the download is clicked to when it starts. The solution, disable output buffering on shop downloads.

nuke-design, if I remember right, you are running evo - so this example is based on evo...

Open up mainfile.php and find the following block of code....

Code:
if (ini_get('output_buffering') && !isset($agent['bot'])) {
    ob_end_clean();
    header('Content-Encoding: none');
}

$do_gzip_compress = false;
if (GZIPSUPPORT && !ini_get('zlib.output_compression') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && eregi('gzip', $_SERVER['HTTP_ACCEPT_ENCODING'])) {
    if (version_compare(PHPVERS, '4.3.0', '>=')) { # PHP 4.2.x seems to give memleak
        ob_start('ob_gzhandler');
    } else {
        $do_gzip_compress = true;
        ob_start();
        ob_implicit_flush(0);
        header('Content-Encoding: gzip');
    }
} else {
    ob_start();
    ob_implicit_flush(0);
}


Above that code we need to start an if statement like so...

Code:

// begin shop edit for output buffering...
if ($name != 'Digital_Shop' && (empty($_GET['act']) || $_GET['act'] != 'downloadItemFile' && $_GET['act'] != 'downloadFile') )
{


Below the code, end the if statement with.

Code:
// end shop edit for output buffering...
}


In the end, you should have...

Code:

// begin shop edit for output buffering...
if ($name != 'Digital_Shop' && (empty($_GET['act']) || $_GET['act'] != 'downloadItemFile' && $_GET['act'] != 'downloadFile') )
{

if (ini_get('output_buffering') && !isset($agent['bot'])) {
    ob_end_clean();
    header('Content-Encoding: none');
}

$do_gzip_compress = false;
if (GZIPSUPPORT && !ini_get('zlib.output_compression') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && eregi('gzip', $_SERVER['HTTP_ACCEPT_ENCODING'])) {
    if (version_compare(PHPVERS, '4.3.0', '>=')) { # PHP 4.2.x seems to give memleak
        ob_start('ob_gzhandler');
    } else {
        $do_gzip_compress = true;
        ob_start();
        ob_implicit_flush(0);
        header('Content-Encoding: gzip');
    }
} else {
    ob_start();
    ob_implicit_flush(0);
}

// end shop edit for output buffering...
}


That is for Evo only,but similar methods can be used for other flavors of nuke..

For example, in RavenNuke, the code to find is...

Code:
if ($phpver >= '4.0.4pl1' && isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'],'compatible')) {
    if (extension_loaded('zlib')) {
       
        if (empty($_GET['act']) && $_GET['act'] != 'captcha'){@ob_end_clean();
        ob_start('ob_gzhandler');}
    }
} elseif ($phpver > '4.0' && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && !empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
    if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
        if (extension_loaded('zlib')) {
            $do_gzip_compress = true;
            ob_start(array('ob_gzhandler',5));
            ob_implicit_flush(0);
            if (ereg('MSIE', $_SERVER['HTTP_USER_AGENT'])) {
                header('Content-Encoding: gzip');
            }
        }
    }
}


Just enclose it in the if statement just like the above example and watch your downloads start up instantly.

PS. I changed the subject to fit the answer and made this a Sticky.
 
View user's profile Send private message Visit poster's website
nuke-design




Joined: Jan 19, 2008
Posts: 51

PostPosted: Wed May 06, 2009 4:09 am
Reply with quote

i am not using evo i'v moved on to vbulletin so now im using the standalone version of the shop and this issue still occurs
 
View user's profile Send private message
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 921

PostPosted: Wed May 06, 2009 7:42 am
Reply with quote

Ok, then open up your lib/constants.php and find the following line...

Code:
define('BUFFER_SIZE_LG' , 10485760 );


That # = 10MB, lets change it to about 6MB by doing
1024 * 1024 * 6 = 6291456

Code:
define('BUFFER_SIZE_LG' , 6291456 );
 
View user's profile Send private message Visit poster's website
nuke-design




Joined: Jan 19, 2008
Posts: 51

PostPosted: Wed May 06, 2009 3:26 pm
Reply with quote

ill try it see what happens
 
View user's profile Send private message
floppy




Joined: Nov 29, 2006
Posts: 85
Location: Jackson, Mississippi

PostPosted: Fri Jun 12, 2009 2:09 pm
Reply with quote

gotcha wrote:
Ok, then open up your lib/constants.php and find the following line...

Code:
define('BUFFER_SIZE_LG' , 10485760 );


That # = 10MB, lets change it to about 6MB by doing
1024 * 1024 * 6 = 6291456

Code:
define('BUFFER_SIZE_LG' , 6291456 );


Why to a smaller buffer size?

_________________
"I am not a great coder, I am persistent"
Mack Hankins
Clan Themes Staff 
View user's profile Send private message Visit poster's website MSN Messenger
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 921

PostPosted: Fri Jun 12, 2009 3:42 pm
Reply with quote

Because if your php memory limit is set at 8MB and it tries to buffer 10MB into memory you can see how it could cause problems....

To make matters even worse, nuke turns on output buffering no matter if you want it or not. So instead of the server just starting to serve the file instantly, the user gets a delay before the download starts due to the ob waiting for the whole file before it sends it to the user.
 
View user's profile Send private message Visit poster's website
Guardian




Joined: Dec 09, 2006
Posts: 335

PostPosted: Fri Jun 12, 2009 4:01 pm
Reply with quote

I was wondering the same thing but now it makes perfect sense.
Out of curiosity and also off-topic, isnt' output buffering needed for url re-writing?
Hmm, I may turn it of in *nuke and see what happens.

_________________
Code Authors Nuke Reviews 
View user's profile Send private message
gotcha
Site Admin
Site Admin



Joined: Oct 25, 2004
Posts: 921

PostPosted: Fri Jun 12, 2009 4:38 pm
Reply with quote

Yeah, it is needed to rewrite the url's, but when outputting files like the shop and forums attachments mods do, there is nothing to rewrite anyways. If mainfile.php didn't try to do everything, it would probably be easier to allow developers turn it off selectively.
 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 5 Hours
Forums ©