4images Forum & Community

4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: geohei on February 09, 2003, 12:09:10 PM

Title: Use GZip compression
Post by: geohei 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
Title: Use GZip compression
Post by: Chris on February 09, 2003, 03:16:40 PM
As far as I can tell, it's for database backups and the zip download feature.
Title: Use GZip compression
Post by: bernd 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 (http://sourceforge.net/projects/mod-gzip/)
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
Title: Use GZip compression
Post by: Chris 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 (http://sourceforge.net/projects/mod-gzip/)
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:
Title: Use GZip compression
Post by: SLL 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.
Title: Use GZip compression
Post by: V@no 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:
Title: Use GZip compression
Post by: Chris 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:
Title: Use GZip compression
Post by: geohei 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?
Title: Use GZip compression
Post by: V@no 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;;
?>
Title: Use GZip compression
Post by: geohei 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 ?!?!
Title: Use GZip compression
Post by: SLL 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);
Title: Use GZip compression
Post by: geohei 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.
Title: Use GZip compression
Post by: Chris 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 !