Forums / Setting Up Categories, Products, Attributes / Downloads deliver an empty zip file

Downloads deliver an empty zip file

Views: 3,939

Results 1 to 20 of 20
16 Jun 2011, 12:28 PM
#1
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Downloads deliver an empty zip file

Everything is working fine with the downloads except that the zip file shows up with nothing in it.

I do have downloads by redirect turned on and what I have discovered is that there is nothing in the pub directory for those redirects. as the documentation says there should be. There is one folder named .ulcwvnoxjdtmrhrirl but it is empty.

This is a linux server, the folder permissions were set to 777 (and actually 755 should work as well). These zip files are very small.

This started happening after changing servers but don't know what to tell tech support - what server setting would create this problem?

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

16 Jun 2011, 12:57 PM
#2
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Downloads deliver an empty zip file

My tech support is telling me this is a zen cart problem - not a server related issue. Why would this stop working after moving the cart if it's not a server issue?

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

16 Jun 2011, 3:16 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Downloads deliver an empty zip file

delia:

My tech support is telling me this is a zen cart problem - not a server related issue. Why would this stop working after moving the cart if it's not a server issue?
Exactly.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Jun 2011, 3:19 PM
#4
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Downloads deliver an empty zip file

Thanks for that confirmation. Grrrr......

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

16 Jun 2011, 3:23 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Downloads deliver an empty zip file

delia:

Everything is working fine with the downloads except that the zip file shows up with nothing in it.Do you mean it's zero bytes? Or that it's got content that cannot be unzipped?
delia:

Everything
I do have downloads by redirect turned on and what I have discovered is that there is nothing in the pub directory for those redirects. as the documentation says there should be. There is one folder named .ulcwvnoxjdtmrhrirl but it is empty.

This is a linux server, the folder permissions were set to 777 (and actually 755 should work as well). These zip files are very small.

This started happening after changing servers but don't know what to tell tech support - what server setting would create this problem?

With download-by-redirect, Zen Cart does the following very simple process:
a) generates a random foldername under /pub/
b) calls the PHP function to generate a symlink from the file in the /download/ folder to that new folder under /pub/ ... thus becoming /pub/.abcwhatever/filename_to_download.zip
c) and then redirects the customer's browser to that file under the pub folder, leaving it entirely up to apache (webserver engine) to do the download/delivery of the file entirely independent of PHP

So, if the server doesn't support symlinks, step b won't work. Some older PHP versions didn't support it because of filesystem/OS limitations, especially on windoze servers. If permissions prevent the creation of the folder or the generation of the symlink stub, then of course you've got a problem. If your filesystem can't handle symlinks, then you've got a dud hosting service, and will have to use an alternate delivery method - Zen Cart has 3 modes, each with varying security implications and server resource (CPU/RAM) demands.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Jun 2011, 3:25 PM
#6
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Downloads deliver an empty zip file

zero bytes, it opens but there's nothing there.

This is a dedicated server and they are going to have to fix.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

22 Jun 2011, 2:41 PM
#7
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Downloads deliver an empty zip file

So they had disabled the php readfile function the server. More secure but unusual.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

22 Jun 2011, 5:34 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Downloads deliver an empty zip file

delia:

So they had disabled the php readfile function the server. More secure but unusual.
Yes, a little unusual.
In considering workarounds, note that: That would only be a problem if Download By Redirect was off, or if symlink creation failed (due to server's inability to create symlinks, or permission problems) and Download By Streaming is off.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Jun 2011, 5:45 PM
#9
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Downloads deliver an empty zip file

hmm, I had found error logs in the cache about the readfile error and assumed. So I assumed wrong?

I ended up using download by streaming as my files are very small but still want this working server wide in case it comes up with a client.

I would have had download by streaming off and redirect on at the time.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

22 Jun 2011, 5:58 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Downloads deliver an empty zip file

delia:

I would have had download by streaming off and redirect on at the time.So, if Redirect was set to on, but the server's configuration wasn't allowing the symlinks to be created, it would failover to attempting to deliver the file directly, thus triggering your readfile problem. By turning on Download by Streaming it bypasses the attempt to use readfile and instead stream it in smaller chunks.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Jun 2011, 6:14 PM
#11
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Downloads deliver an empty zip file

exactly, well, I'm pretty sure that was what was happening. I would have to test again to be absolutely sure.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

22 Jun 2011, 6:50 PM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Downloads deliver an empty zip file

Would you mind testing this code alteration?

  1. First test that using readfile is still broken.
  2. Make the following code change to /includes/modules/pages/download/header_php.php
  3. Test the same download as you did when readfile was broken ... this time it should work.

Code:
Around line 224 of that file you should see this:if (DOWNLOAD_IN_CHUNKS != 'true') {Change it to this:```
[B] $disabled_funcs = @ini_get("disable_functions");[/B]
if (DOWNLOAD_IN_CHUNKS != 'true'[B] && !strstr($disabled_funcs,'readfile')[/B]) {

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Jun 2011, 7:02 PM
#13
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Downloads deliver an empty zip file

and now it works!

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

22 Jun 2011, 7:14 PM
#14
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Downloads deliver an empty zip file

Okay, so with the download streaming turned off and download by redirect turned on, I had to use the additional code.

If I turn on download streaming with download by redirect on - without the additional code, it does work.

But it says that shouldn't change it.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

22 Jun 2011, 7:28 PM
#15
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Downloads deliver an empty zip file

The code fix I posted should simply provide a safe fallback in the event that readfile is disabled. Everything else should work as normal.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Jun 2011, 7:39 PM
#16
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Downloads deliver an empty zip file

So if I have downloads by redirect and downloads by streaming, it's supposed to be using the redirect? Because without the code that way it works.

If I turn off download by streaming, it only works with the additional code.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

22 Jun 2011, 7:40 PM
#17
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Downloads deliver an empty zip file

Yes, that makes sense. (Because it's clear that your server isn't successfully doing any "download by redirect" at all, regardless of it being on or off)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Jun 2011, 7:45 PM
#18
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Downloads deliver an empty zip file

Thanks for helping me clarify this!

Now I have to make a decision about whether to enable readfile or not or try to remember this discussion the next time it all crops up again!

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

22 Jun 2011, 7:52 PM
#19
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Downloads deliver an empty zip file

We'll look into building that fix into a future release since it's a minor bug, albeit one that's only triggered by an unusual, uncommon server configuration.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Jun 2011, 11:56 PM
#20
vger avatar

vger

Past Contributor

Join Date:
Nov 2004
Location:
Norfolk, United Kingdom
Posts:
3,189
Plugin Contributions:
0

Re: Downloads deliver an empty zip file

We'll look into building that fix into a future release since it's a minor bug, albeit one that's only triggered by an unusual, uncommon server configuration.

In my experience "Download by redirect" doesn't work on any server running PHP as a CGI with either SuPHP or SuExec in place.

Additionally the most recent release of Apache 2.2 has tightened up security considerably on the "on the fly" creation of symlinks by site owners - because they could be misused by hackers.

Vger