Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files Corrupted when downloaded through s2member. #70

Closed
trhickman opened this issue Mar 9, 2014 · 14 comments
Closed

Files Corrupted when downloaded through s2member. #70

trhickman opened this issue Mar 9, 2014 · 14 comments

Comments

@trhickman
Copy link

The protected download links result in corrupted download files when accessed through Chrome or Internet Explorer browsers (on PCs) as well as in Safari or Chrome on iPad.

  1. I created a new, clean wordpress install at http://adcontxt.com
  2. I installed s2member & s2member Pro. I updated the s2member install and registered the Pro. I then set up s2member as basically as possible with Welcome page and Member Option pages, configured the download restrictions to infinite and then set up two download pages: 'Open Downloads' and 'Restricted Downloads'. NO OTHER PLUG INS ARE INSTALLED OR ACTIVE ON THIS SITE.
  3. I uploaded a copy of a PDF file 'XDM Sample.pdf' both to the standard s2member file location (http://adcontxt/wp-content/plugins/s2member-files) and to an unrestricted directory location (http://adcontxt.com/Open).
  4. On the 'Open Downloads' page (http://www.adcontxt.com/open-downloads/) I created three links: one to the unrestricted file location, one that directly linked to the restricted file location and one that uses the standard s2member file download link protocol.
  5. I then tested each of the links on the page above while signed in. The first, unsecured link downloaded the file and opened it in my browser inline as expected. The second link gave the pop-up download window and then produced the expected 500 error since one is not supposed to link to the file/directory location.
  6. The third link -- which uses the standard protocol for downloading in s2member (in this case, http://www.adcontxt.com/?s2member_file_download=XDM%20Sample.pdf) also produced the expected pop-up window showing the users download restriction count and then proceeded to download the file as expected.
  7. HOWEVER, the file downloaded from this third link, when clicked on, produces a 'Failed to Load PDF document' error in the browser. When attempting open this download document directly in Adobe Acrobat, Acrobat says, 'Acrobat could not open 'XDM Sample.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).'

I have set up a user on this install with the following credentials so that you can view the behavior directly:
User: testcase / password: context911

You may also check the server scanner here:
http://adcontxt.com/s2-server-scanner.php

I have two additional installations (one a multisite the other single site) which are exhibiting this same behavior. Not only is this effecting my PDF files but appears to also be corrupting zip file downloads as well.

As my business revolves around pay-for-download ... you can understand my urgent concern.

Tracy Hickman

@jaswrks
Copy link
Contributor

jaswrks commented Mar 9, 2014

This has been reported in this past; it is normally associated with GZIP compression conflicts on your server. s2Member attempts to serve the file via PHP, and to empty the Content-Encoding header; but some hosting configurations override all of s2Member's attempts to serve the file without it. Binary files like PDFs should not be served with a Content-Encoding: gzip header.

This is coming from your server as it exists now..
2014-03-08_17-21-18

Did you implement the .htaccess rules suggested by s2Member in your Dashboard yet?
Please see: s2Member ⥱ Download Options ⥱ GZIP Conflicts

@jaswrks
Copy link
Contributor

jaswrks commented Mar 9, 2014

If problems persist, even after implementing the .htaccess rules suggested by s2Member; there is another workaround that we use on stubborn servers. s2Member can force a Content-Encoding: none value which usually will prevent a server a from sending the gzip value. This is an invalid header, but it's a commonly used hack across many software platforms to avoid GZIP compression.

To implement this hack (if necessary), download the attached file (unzip) and upload via FTP, allowing it to override your existing copy of /wp-content/plugins/s2member/includes/classes/files-in.inc.php

http://d1v41qemfjie0l.cloudfront.net/s2member/uploads/2014/03/files-in.inc_.php_.zip

@trhickman
Copy link
Author

I checked the .htaccess files for adcontxt.com and discovered that s2member had automatically installed the code.

image

This code also appears in the other installations that are giving me download issues, so apparently it is the persistent server that is causing the problem.

I'll try the hack and see if that solves the issue.

@trhickman
Copy link
Author

I do not appear to have the files-in.inc file in the location you described above. Sorry, found the location as classes/ ... testing now.

@jaswrks
Copy link
Contributor

jaswrks commented Mar 9, 2014

It is actually a .php file and it should be located here.
/wp-content/plugins/s2member/includes/classes/files-in.inc.php

@jaswrks
Copy link
Contributor

jaswrks commented Mar 9, 2014

Note to self... tracking with this issue.
TODO: add a switch to enable this in a future release of s2Member

@trhickman
Copy link
Author

The hack appears to have solved the problem. I am so very grateful ... my entire business was depending on this. Thank you all for your help!

@jaswrks
Copy link
Contributor

jaswrks commented Mar 9, 2014

Glad to hear it. Very welcome! :-)

@jaswrks
Copy link
Contributor

jaswrks commented Mar 9, 2014

This will be a configurable option in this next release of s2Member.
2014-03-08_21-13-59

@NathanWailes
Copy link

Hi,

I'm working for ClassCenter.net, which uses an older version of S2Member Pro (v170722), and the site is having this issue with the corrupted downloads, and the .htaccess file already had the recommended addition, and so I'm thinking I need to make the Content-Encoding: none change as well, but the link above to the updated files-in.inc.php file is dead.

Could you update the link or let me know what specific change I need to make in the file? I'll try to figure it out myself and report here if I get it working, but I thought it was worth posting a comment at the same time.

@hausmanconsulting
Copy link

@NathanWailes Maybe you figured this out already...so weird that you just wrote about this 6 days ago. I've been running S2Member for years now with a client site and out of the blue this issue just started happening to us. I'm going to guess a server configuration change, but I have no idea how long it's been going on. I've asked the client the last time they downloaded files using S2Member and a browser other than Firefox.

Anyway, in case you don't get a reply here with your specific file, you can look at the commit that was pushed on 3/8/2014 (this link is also shown above in the post where the issue was closed) to see the changes that were made to a few files:

e2a4f4c

Hope that helps. In my case we're on the latest version so I already have the toggle and the file layout has completely changed, otherwise I'd to try to help further, but if you back up your original files and work carefully it looks like you should be able to fix this. I'd like to think it was your 6 day old post that pushed this issue to the top of Google results and got me the answer I needed. Good luck!

@NathanWailes
Copy link

NathanWailes commented Mar 30, 2022

@hausmanconsulting

Thank you! I ended up realizing that my version of S2Member actually did have the ability for me to set the Content-Encoding: none setting, but I had initially skimmed over it in the settings menu because the dropdown box had a greenish-yellow background color instead of the white background color I was expecting to see for a user-modifiable field. So everything is working for me now.

@hausmanconsulting
Copy link

@NathanWailes Glad to hear it. Are you by any chance using GoDaddy as a host? We are, and the fact that you brought this up so recently makes me wonder if something changed on a host/server that we have in common. I know we didn't make any changes to our WP site regarding file downloads but this issue popped up for us fairly recently as well.

@NathanWailes
Copy link

I don't have access to the host site credentials but it does appear the site is hosted on GoDaddy (the site is https://classcenter.net/, I used https://hostingchecker.com/ to check where it's hosted).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants