Downloads get corrupted via HiksShop

  • Posts: 151
  • Thank you received: 9
12 years 3 weeks ago #73203

Hi,

When I download a bought file via HikaShop (ZIP file) it gets corrupted during download.
When I download the same file via my own php script, the file is ok.

After comparing the corrupted ZIP-file and the correct ZIP-file in a HEX Editor, I see that in
the corrupted file line 1 is empty. The actual code starts at line 2.

The correct file's code starts at line 1, as it should.

When I manually delete the first emtpy line in the corrupt file and save it. It's repaired and it works. I can open and unzip the file.

So somewhere the HikaShop PHP code adds this first emtpy line in the download files.

This is the correct file. See the code starts at line 1



This is the corrupted file. See the code starts at line 2


Please help.

Kind regards,
Maurice

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 3 weeks ago #73208

Hi,

HikaShop does not add that empty line.
It must be something else on your website which does.
It's highly possible that it comes from one of your system plugins so I would recommend to disable them one by one and see if that fixes the problem.

Please Log in or Create an account to join the conversation.

  • Posts: 151
  • Thank you received: 9
12 years 3 weeks ago #73362

I disabled each system plugin one by one and testing it. No change.

I even disabled ALL plugins (this breaks the site) and the download is still corrupted.

So even without any plugin enabled, the download still gets corrupted because of this extra empty line at the beginning of the file.

When I open the order in the backend, and I click on the downloadlink, the file gets downloaded correct!

Link in Mail:

http://www.trancewerk-test.nl/index.php?option=com_hikashop&ctrl=order&task=download&file_id=276&order_id=432

Link in Backend:
http://www.trancewerk-test.nl/administrator/index.php?option=com_hikashop&ctrl=order&task=download&file_id=276&order_id=432


Could it have anything to do with permissions?

Maurice

Edit: when I order with my admin account and download via the front-end, I also receive the corrupted file, so I guess it has nothing to do with permissions. Maybe the line-feed handling for front-end downloads is handled wrong somewhere?

Last edit: 12 years 3 weeks ago by Maurice.

Please Log in or Create an account to join the conversation.

  • Posts: 151
  • Thank you received: 9
12 years 3 weeks ago #73380

Hi,

I found the problem. Unfortunately it IS in the HikShop code.

In file administrator/components/com_hikashop/classes/file.php I added two lines of code to fix the problem.


Change this code (around line 326)

header('Content-Type: application/octet-stream');

into:
ob_end_clean(); //added to fix ZIP file corruption
ob_start(); //added to fix ZIP file corruption 
header('Content-Type: application/octet-stream');

Save it and now the 'extra' blank line a the top of a downloaded ZIP-file is gone.

Maurice

Last edit: 12 years 3 weeks ago by Maurice.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 3 weeks ago #73613

Hi,

What you did is not a fix of a bug in HikaShop but a hack to remove the empty line added by something else on your website before letting Hikashop display the content of the file to the browser. So of course, it fixes your problem, but it's circumventing the problem coming from something else.
But I agree that it's a good idea to add that code to avoid other plugins messing with the output of HikaShop.

The following user(s) said Thank You: Maurice

Please Log in or Create an account to join the conversation.

Time to create page: 0.066 seconds
Powered by Kunena Forum