- Posts: 151
- Thank you received: 9
Downloads get corrupted via HiksShop
13 years 10 months ago #73203
by Maurice
Downloads get corrupted via HiksShop was created by Maurice
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
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
Please Log in or Create an account to join the conversation.
13 years 10 months ago #73208
by nicolas
Replied by nicolas on topic Re: Downloads get corrupted via HiksShop
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.
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.
13 years 10 months ago - 13 years 10 months ago #73362
by Maurice
Replied by Maurice on topic Re: Downloads get corrupted via HiksShop
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:
Link in Backend:
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?
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:
Code:
http://www.trancewerk-test.nl/index.php?option=com_hikashop&ctrl=order&task=download&file_id=276&order_id=432
Link in Backend:
Code:
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: 13 years 10 months ago by Maurice.
Please Log in or Create an account to join the conversation.
13 years 10 months ago - 13 years 10 months ago #73380
by Maurice
Replied by Maurice on topic Re: Downloads get corrupted via HiksShop
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)
into:
Save it and now the 'extra' blank line a the top of a downloaded ZIP-file is gone.
Maurice
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)
Code:
header('Content-Type: application/octet-stream');
into:
Code:
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: 13 years 10 months ago by Maurice.
Please Log in or Create an account to join the conversation.
13 years 10 months ago #73613
by nicolas
Replied by nicolas on topic Re: Downloads get corrupted via HiksShop
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.
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.202 seconds