zlib compression

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AndrewD
    Member
    • Aug 2002
    • 68
    • 3.6.x

    zlib compression

    I tried this over on vbulletin.org, Dean answered, but his answer was for another question, I think.

    I ran into problems with file downloading code on a site that had set zlib.output_compression=on and was using php version 4.3.4. The user got garbage on the screen, which was presumably due to compressed material not being uncompressed or vice versa.

    The cryptic comment from his local expert was that
    In php.ini I changed the line
    zlib.output_compression = On
    to
    zlib.output_compression = Off
    I have found better performance from php websites having it on. Most sites check to see if php has it on to avoid the problem, but it seems this software doesn't.
    How does one write a script that is safe against zlib.output_compression being "on"?

    This is what I've tried, seemingly successfully, but I've no idea if this is adequate, failsafe, etc.
    PHP Code:
    // Guard against uncontrolled use of zlib library
    $zlib ini_get('zlib.output_compression');
    ini_set('zlib.output_compression''Off');
    headers...
    download..
    // Restore setting of zlib library
    ini_set('zlib.output_compression'$zlib); 
    Anyone got any thoughts on this?
    Andrew
  • TheSpaceDude
    New Member
    • Mar 2004
    • 1

    #2
    ini_set makes a temporary change. From the php manual:

    The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.

    Just add this to the top of your script:

    PHP Code:
    ini_set('zlib.output_compression''off'); 
    That should be all you need.

    Comment

    • Squee
      New Member
      • Feb 2004
      • 20
      • 3.5.x

      #3
      I'm not sure exactly what you're after here, but we encountered on our board some interesting problems with zlib.output_compression and php 4.3.4...There is a bug in the flush() command used in some php files that causes the zlib output the munched. commenting out any flush()'s in the code (or disabling zlib compression) fixes this. PHP 4.3.5 should fix this issue as well.

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...