Forums / Setting Up Categories, Products, Attributes / product downloads producing test files

product downloads producing test files

Locked

Views: 1,538

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
2 Sep 2008, 11:42 PM
#1
lentron avatar

lentron

New Zenner

Join Date:
Sep 2008
Posts:
3
Plugin Contributions:
0

product downloads producing test files

I have a customer using zen cart 1.3.7.1 to provide downloadable pdf's. Currently the downloads aren't working properly, they are producing what appears at first glance to be a corrupt file.
Further investigation shows that the content of the file has been replaced with the text "test".
This happens regardless of whether the file is one of the pdf's that the customer has uploaded or the test.zip file provided with zencart. In all cases the file downloaded has the correct file name, but is an ASCII text file with the word test in it.
To troubleshoot this one I've setup a test download product following one of the zencart tutrials. I've also verified that the files in the download folder are valid (removed the .htaccess file and downloaded them directly).
I've tried disabling download by redirect with the same result, I've also tried enabling download by streaming with redirect disabled, again with the same result.

The server is running apache 2.2 and the site is using php 5.2.5. The pub and download folders are both 755, the site itself is in a chrooted environment so php can read and write to 755 folders. I have tried changing the pub folder to 777 but that hasn't made any difference.
The configure.php has correct paths for download and pub folders and the Admin page has a green dot next to the downloadable files.

The fact that the files are being overwritten with a text file containing test suggests that this is some kind test mode in zencart. But I haven't been able to find any thing that would enable / disable that in zencart, nor in any of the setup downloadable product tutorials.
Customer was testing with the Credit Card payment module and have also tried with PayPal IPN.

5 Sep 2008, 1:08 AM
#2
lentron avatar

lentron

New Zenner

Join Date:
Sep 2008
Posts:
3
Plugin Contributions:
0

Re: product downloads producing test files

sigh. Found it, someone had a put die("test"); in includes/modules/pages/download/header_php.php. I'm guessing one of my earstwhile colleagues was trying to debug why the downloads weren't working.

I think he was trying to determine why Download by redirect wasn't working on the server. Which does bring up an interesting issue that others may encounter.
This is a Linux server, that allows FollowSymlinks but will not work with Download by redirect, at least not easily. The server software sets up sites in a chrooted environment so the site is completely contained within its' own environment. It's great for security in that php and cgi scripts only run as the site user.
It also means that the FS root for the site is not the same as the server root. For example the web folder from the server root would be:
/home/sites/DOMAIN.NAME/var/www/html

However from inside the chrooted environment the web folder from root is:
/var/www/html

This becomes a problem with download by redirect as the zencart must be configured the chrooted web folder root. So when it sets up links for downloads the link is setup as follows:
pub/.RANDOM/MY_FILE.zip ->/var/www/html/shop/downloads/MY_FILE.zip

While php and cgi are run as the user from the chrooted environment apache is not. Apache won't be able to follow the link, the only way that would work is if the symlink is setup as follows:
pub/.RANDOM/MY_FILE.zip ->/home/sites/DOMAIN.NAME/var/www/html/shop/downloads/MY_FILE.zip

5 Sep 2008, 1:18 AM
#3
lentron avatar

lentron

New Zenner

Join Date:
Sep 2008
Posts:
3
Plugin Contributions:
0

Re: product downloads producing test files

actuall on reflection it could be fixe by specifying the download folder as:
../../../home/site/DOMAIN.NAME/var/www/html/shop/download

Awful I know, but it should work in that the sym link would be generated as:
/var/www/html/../../../home/site/DOMAIN.NAME/var/www/html/shop/download/FILE

That would be a valid path from the root of the server.