| Author |
Message |
nuke-design

Joined: Jan 19, 2008
Posts: 51
|
Posted:
Tue Apr 21, 2009 11:42 pm |
|
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? |
| |
|
|
 |
Guardian

Joined: Dec 09, 2006
Posts: 335
|
Posted:
Fri Apr 24, 2009 2:07 pm |
|
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 921
|
Posted:
Mon May 04, 2009 3:15 pm |
|
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. |
| |
|
|
 |
nuke-design

Joined: Jan 19, 2008
Posts: 51
|
Posted:
Wed May 06, 2009 4:09 am |
|
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 |
| |
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 921
|
Posted:
Wed May 06, 2009 7:42 am |
|
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 ); |
|
| |
|
|
 |
nuke-design

Joined: Jan 19, 2008
Posts: 51
|
Posted:
Wed May 06, 2009 3:26 pm |
|
ill try it see what happens |
| |
|
|
 |
floppy

Joined: Nov 29, 2006
Posts: 85
Location: Jackson, Mississippi
|
Posted:
Fri Jun 12, 2009 2:09 pm |
|
| 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 |
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 921
|
Posted:
Fri Jun 12, 2009 3:42 pm |
|
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. |
| |
|
|
 |
Guardian

Joined: Dec 09, 2006
Posts: 335
|
Posted:
Fri Jun 12, 2009 4:01 pm |
|
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 |
|
|
 |
gotcha
Site Admin


Joined: Oct 25, 2004
Posts: 921
|
Posted:
Fri Jun 12, 2009 4:38 pm |
|
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. |
| |
|
|
 |
|
|