ZIP Downloads

Open to all! Ask other shopowners for help.
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: ZIP Downloads

Post by heatherbell »

ecartz wrote: Mon Aug 29, 2022 5:42 pm You might try the following in download.php:

Code: Select all

set_error_handler(function ($severity, $message, $file, $line, $context) {
  if (error_reporting() & $severity) {
    throw new ErrorException($message, 0, $severity, $file, $line);
  }
});
ob_start();

  include 'includes/application_top.php';
  if (ob_get_contents()) {
    $message = sprintf("Unneeded output:  [%s]", ob_get_clean());
    error_log($message);
    die(ini_get('display_errors') ? $message : 'Download generation failed');
  }
  
  ob_end_clean();
With the above code in download.php gives a white screen when clicking on Download Link after checkout, showing:
Unneeded output: [ ]


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: ZIP Downloads

Post by ecartz »

I do not get this in a fresh 1.0.8.17.

Something is emitting a single space, which breaks the download. I don't know what. The files that are most likely to be modified would be includes/configure.php, includes/languages/english.php, and includes/languages/english/download.php. Maybe something in modules? E.g. includes/languages/english/modules/header_tags/

With Download by Redirect set to false in admin > Configuration > Downloads, I would try with a fresh install of 1.0.8.17.

Or you could try the previous code with the die line removed and see if it works that way, although that seems like the long way around. Better to find what is emitting the extraneous space.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: ZIP Downloads

Post by ecartz »

https://github.com/CE-PhoenixCart/Phoen ... e81cf68b0d

I think that that will fix the immediate problem (that the file is corrupted) and log the underlying issue (that content is being produced).

I tested it with redirect both on and off, and it worked for me. I think that redirect is probably not the best way, at least as implemented here. In any case, it is more likely to work without redirect than with.

It's possible that someone could implement redirect at a lower level. An authenticated proxy at the Apache level would be both efficient and secure. Of course, that would require someone capable of writing some kind of mod_authn_php to integrate the PHP code with Apache. That would be nifty (we could also use that instead of basic authentication for admin), but I'm not holding my breath.
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: ZIP Downloads

Post by heatherbell »

After many hours, eventually found the source of the issue and, of course, it was exactly as you said - a space before a <?php in a non-core file.
Convinced testing was on a clean install but discovered that an error was made during FTP. :ashamedFace:
Will test your commit.
Many thanks again for your kind help and attention.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply