Author Topic: Use GZip compression  (Read 10686 times)

0 Members and 1 Guest are viewing this topic.

Offline geohei

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Use GZip compression
« on: February 09, 2003, 12:09:10 PM »
What is that option for?
For download (can't really be since the images or downloaded in the format stored on the server)?

TIA

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Use GZip compression
« Reply #1 on: February 09, 2003, 03:16:40 PM »
As far as I can tell, it's for database backups and the zip download feature.

Offline bernd

  • Full Member
  • ***
  • Posts: 214
    • View Profile
Use GZip compression
« Reply #2 on: February 09, 2003, 09:20:08 PM »
Quote from: Chris
As far as I can tell, it's for database backups and the zip download feature.


IIRC it is rather for transparent compression of the requested content. I.e. the html page itself (or the parsed php page to be precise) is gzipped, sent to the reader and the reader's browser decompresses it and displays it - normally without any notice by the user. By doing so you save your website bandwidth/transfer volume.

Here's a quote from the developer's website
Quote
mod_gzip is an Internet Content Acceleration module for the poular Apache Web Server. It compresses the contents delivered to the client. There is no need to install any additional software on the client!


cheers,
Bernd

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Use GZip compression
« Reply #3 on: February 09, 2003, 10:01:46 PM »
Careful.  Don't get these two confused...

Quote from: bernd

Here's a quote from the developer's website
Quote
mod_gzip is an Internet Content Acceleration module for the poular Apache Web Server. It compresses the contents delivered to the client. There is no need to install any additional software on the client!

As you pointed out with your quote, mod_gzip is an Apache module that does just what you described.  But the "Use gzip compression" found under the 4images admin control panel has nothing to do with this web server module.  It has everything to do with "downloading as zip", database backups and a few other 4images features.

A quick search of the 4images php code turns up the following uses:
Code: [Select]
4images/admin

admin_functions.php:  global $site_db, $start_time, $alluserinfo, $do_gzip_compress, $nozip, $config;
admin_functions.php:  if ($do_gzip_compress) {
admin_functions.php:    if (eregi("gzip", $HTTP_SERVER_VARS["HTTP_ACCEPT_ENCODING"])) {
admin_functions.php:      $encoding = "gzip";
admin_functions.php:    elseif (eregi("x-gzip", $HTTP_SERVER_VARS["HTTP_ACCEPT_ENCODING"])) {
admin_functions.php:      $encoding = "x-gzip";
admin_functions.php:    $gzip_contents = ob_get_contents();
admin_functions.php:      $s .= sprintf("<!-- Not compress length:  %s -->\n", strlen($gzip_contents));
admin_functions.php:      $s .= sprintf("<!-- Compressed length:    %s -->\n", strlen(gzcompress($gzip_contents, $config['gz_compress_level'])));
admin_functions.php:      $gzip_contents .= $s;
admin_functions.php:    $gzip_size = strlen($gzip_contents);
admin_functions.php:    $gzip_crc = crc32($gzip_contents);
admin_functions.php:    $gzip_contents = gzcompress($gzip_contents, $config['gz_compress_level']);
admin_functions.php:    $gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);
admin_functions.php:    echo $gzip_contents;
admin_functions.php:    echo pack("V", $gzip_crc);
admin_functions.php:    echo pack("V", $gzip_size);
backup.php:$nozip = 1;
email.php:$nozip = 1;
resizer.php:$nozip = 1;
stats.php:$nozip = 1;
thumbnailer.php:$nozip = 1;
validateimages.php:$nozip = 1;


4images/includes

functions.php:    $download_zip_button = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
functions.php:    $download_zip_button = ($target == "" && function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id'])."\"".$target."><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>" : "";
functions.php:    $download_zip_button = (function_exists("gzcompress") && function_exists("crc32")) ? "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />" : "";
functions.php:    $download_zip_button = ($target == "" && function_exists("gzcompress") && function_exists("crc32")) ? "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=zip&amp;".URL_IMAGE_ID."=".$image_row['image_id'])."\"".$target."><img src=\"".get_gallery_image("download_zip.gif")."\" align=\"absmiddle\" border=\"0\" alt=\"\" /></a>" : "";
functions.php:    "download_zip_button" => $download_zip_button,
page_footer.php:  $gzip_text = ($config['gz_compress'] == 1) ? "GZIP compression enabled" : "GZIP compression disabled";
page_footer.php:  $gzip_text .= ($config['gz_compress'] == 1 && !extension_loaded("zlib")) ? "*" : "";
page_footer.php:  printf("<p align=\"center\"><font size=\"-2\">Page generated in %f seconds with ".$site_db->query_count." queries, spending %f seconds doing MySQL queries and %f doing PHP things. $gzip_text</p>", $total_time, $sql_time, $php_time);
page_footer.php:if ($do_gzip_compress) {
page_footer.php:  if (eregi("gzip", $HTTP_SERVER_VARS["HTTP_ACCEPT_ENCODING"])) {
page_footer.php:    $encoding = "gzip";
page_footer.php:  elseif (eregi("x-gzip", $HTTP_SERVER_VARS["HTTP_ACCEPT_ENCODING"])) {
page_footer.php:    $encoding = "x-gzip";
page_footer.php:  $gzip_contents = ob_get_contents();
page_footer.php:    $s .= sprintf("\n<!-- Not compress length:  %s -->", strlen($gzip_contents));
page_footer.php:    $s .= sprintf("\n<!-- Compressed length:    %s -->", strlen(gzcompress($gzip_contents, $config['gz_compress_level'])));
page_footer.php:    $gzip_contents .= $s;
page_footer.php:  $gzip_size = strlen($gzip_contents);
page_footer.php:  $gzip_crc = crc32($gzip_contents);
page_footer.php:  $gzip_contents = gzcompress($gzip_contents, $config['gz_compress_level']);
page_footer.php:  $gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);
page_footer.php:  echo $gzip_contents;
page_footer.php:  echo pack("V", $gzip_crc);
page_footer.php:  echo pack("V", $gzip_size);
upload_definitions.php:$mime_type_match['gz'] = array("application/gzip", "application/x-gzip-compressed");
upload_definitions.php:$mime_type_match['zip'] = array("application/zip", "application/x-zip-compressed");
zip.php: *             File: zip.php                                              *
zip.php:makes zip files on the fly...
zip.php:        "\x00\x00";                 // .zip file comment length


4images/
download.php:$nozip = 1;
download.php:    include(ROOT_PATH."includes/zip.php");
download.php:    $zipfile = new zipfile();
download.php:        $zipfile->add_file($file_data, $file_name);
download.php:      $file['file_name'] = time().".zip";
download.php:      $file['file_data'] = $zipfile->file();
download.php:    if ($action == "zip" && !eregi("\.zip$", $file['file_name']) && function_exists("gzcompress") && function_exists("crc32")) {
download.php:      include(ROOT_PATH."includes/zip.php");
download.php:      $zipfile = new zipfile();
download.php:      $zipfile->add_file($file['file_data'], $file['file_name']);
download.php:      $file['file_data'] = $zipfile->file();
download.php:      $file['file_name'] = get_file_name($file['file_name']).".zip";
download.php:    $disposition = (!eregi("\.zip$", $file['file_name']) && $action != "zip" && $action != "lightbox") ? 'attachment' : 'inline';
global.php:$do_gzip_compress = 0;
global.php:if ($config['gz_compress'] == 1 && !isset($nozip)) {
global.php:    if (eregi("gzip", $HTTP_SERVER_VARS["HTTP_ACCEPT_ENCODING"]) || eregi("x-gzip", $HTTP_SERVER_VARS["HTTP_ACCEPT_ENCODING"])) {
global.php:        $do_gzip_compress = 1;
lightbox.php:    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox")."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
lightbox.php:    $download_button = "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />";
login.php:$nozip = 1;
logout.php:$nozip = 1;
quotation.php:    $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox")."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"".$lang['alt_download_zip']."\" /></a>";
quotation.php:    $download_button = "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"".$lang['alt_download_zip_no_file']."\" />";


Nowhere is 4images compressing the parsed output of php generated pages for rendering in the user's browser.  That's a function of the web server software.

Hope this clears things up a little bit.  :wink:

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
Use GZip compression
« Reply #4 on: February 09, 2003, 10:35:07 PM »
Quote from: Chris
mod_gzip is an Internet Content Acceleration module for the poular Apache Web Server. It compresses the contents delivered to the client. There is no need to install any additional software on the client!

By the way, it would be good to use this feature in the next release of 4images... If I'm not mistaken, it's just 10 lines of code responsible for on-fly compression, which I've found in the phpBB.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Use GZip compression
« Reply #5 on: February 09, 2003, 10:52:12 PM »
Quote from: SLL
Quote from: Chris
mod_gzip is an Internet Content Acceleration module for the poular Apache Web Server. It compresses the contents delivered to the client. There is no need to install any additional software on the client!

By the way, it would be good to use this feature in the next release of 4images... If I'm not mistaken, it's just 10 lines of code responsible for on-fly compression, which I've found in the phpBB.

is there any MOD comming  :wink:  :lol: :roll:
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Use GZip compression
« Reply #6 on: February 09, 2003, 11:56:00 PM »
Quote from: Chris
Nowhere is 4images compressing the parsed output of php generated pages for rendering in the user's browser.  That's a function of the web server software.

I should say "nowhere that I could tell in just a quick glance".  Now that I think about it, I suppose it's possible that 4images is already doing this.  :roll:

Offline geohei

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Use GZip compression
« Reply #7 on: February 10, 2003, 06:26:14 AM »
Quote from: Chris
It has everything to do with "downloading as zip", database backups and a few other 4images features.

I see only "Download" below the shown picture. I saw 4images galleries, where "ZIP" is shown right of "Download". However I didn't find any related button in the Settings section of the Control Panel to enable this "ZIP" download feature.

How can this be enabled?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Use GZip compression
« Reply #8 on: February 10, 2003, 06:33:29 AM »
zip download button only avalable when gzip or zlib(?) library installed on your server.
try to run this script and see if its installed:
Code: [Select]
<?php
phpinfo
&#40;&#41;;
?>
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline geohei

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Use GZip compression
« Reply #9 on: February 10, 2003, 07:59:06 AM »
This says:

HTTP_ACCEPT_ENCODING gzip, deflate, compress;q=0.9
Accept-Encoding gzip, deflate, compress;q=0.9

I guess this means that it is available at the server.

But ZIP still doesn't show up next to my "Download" button ?!?!

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
Use GZip compression
« Reply #10 on: February 10, 2003, 09:27:56 AM »
Quote from: Chris
Now that I think about it, I suppose it's possible that 4images is already doing this.  :roll:

well, well... we should have been looking into page_footer.php before  :oops:
Code: [Select]
 $gzip_size = strlen($gzip_contents);
  $gzip_crc = crc32($gzip_contents);

  $gzip_contents = gzcompress($gzip_contents, $config['gz_compress_level']);
  $gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);

  header("Content-Encoding: $encoding");
  echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
  echo $gzip_contents;
  echo pack("V", $gzip_crc);
  echo pack("V", $gzip_size);

Offline geohei

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Use GZip compression
« Reply #11 on: February 10, 2003, 10:46:05 PM »
Quote from: Chris
It has everything to do with "downloading as zip", database backups and a few other 4images features.

Nope ... just got .htaccess now configured propery on my server. This file (with the content "AddType php-cgi .php") allowed my to see the "Download as zip" feature below the image.

However switching "Use GZip compression" on or off didn't change anything. "Download as zip" was available in both cases.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Use GZip compression
« Reply #12 on: February 11, 2003, 12:23:34 AM »
Quote from: SLL
Quote from: Chris
Now that I think about it, I suppose it's possible that 4images is already doing this.  :roll:

well, well... we should have been looking into page_footer.php before  :oops: [/code]


 :oops:  Yep.  That's what I suspected. I stand corrected !