[Phpmyadmin-devel] Gzip HTTP Content-Encoding patch

jeremy brand jeremy at nirvani.net
Fri Jul 20 08:38:15 CEST 2001


Hello Tobias (and others),

I've got board and decided to check up on this probject.  I was looking at
the feature request page on the sourceforge project and decided to whip
this out as I have just done a similar upgrade on my own web site and have
seen enourmous speed increase from the site.

I wouldn't recommend using it if the site is heavily loaded (imagine 50+
gzips running on your websever) but if it is only a single machine and
only the admin is accessing this, it should be fine.

It would be nice to know how much gzip increases the load on a heavily
loaded server, but I have no such server.

cioa,
Jeremy

-- 
Jeremy Brand :: Sr. Software Engineer :: +393485323988 :: jeremy at nirvani.net
http://www.JeremyBrand.com/Jeremy/Brand/Jeremy_Brand.html for more
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    "LINUX is obsolete"  -- Andy Tanenbaum, January 29th, 1992
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  Get your own Free, Private email at http://www.smackdown.com/
-------------- next part --------------
Index: header.inc.php3
===================================================================
RCS file: /cvsroot/phpmyadmin/phpMyAdmin/header.inc.php3,v
retrieving revision 1.8
diff -u -w -U6 -r1.8 header.inc.php3
--- header.inc.php3	2001/07/10 19:41:05	1.8
+++ header.inc.php3	2001/07/20 06:32:34
@@ -1,10 +1,15 @@
 <?php
 /* $Id: header.inc.php3,v 1.8 2001/07/10 19:41:05 loic1 Exp $ */
 
 require('./lib.inc.php3');
+require('./ob_lib.inc.php3');
+
+$ob_mode = out_buffer_mode_get();
+if ($ob_mode)
+  out_buffer_pre($ob_mode);
 
 /**
  * Send http headers
  */
 // Don't use cache (required for Opera)
 $now = gmdate('D, d M Y H:i:s') . ' GMT';
-------------- next part --------------
Index: footer.inc.php3
===================================================================
RCS file: /cvsroot/phpmyadmin/phpMyAdmin/footer.inc.php3,v
retrieving revision 1.1.1.1
diff -u -w -U6 -r1.1.1.1 footer.inc.php3
--- footer.inc.php3	2001/05/03 17:25:10	1.1.1.1
+++ footer.inc.php3	2001/07/20 06:32:45
@@ -1,5 +1,9 @@
     </td>
   </tr>
 </table>
 </body>
 </html>
+<?php
+if ($ob_mode)
+  out_buffer_post($ob_mode);
+?>
-------------- next part --------------
<?php

  if(!defined("__OB_LIB_INC__"))
    define("__OB_LIB_INC__", 1);

  # Output buffer functions for phpMyAdmin

  # Copyright 2001 Jeremy Brand <jeremy at nirvani.net>
  # http://www.jeremybrand.com/Jeremy/Brand/Jeremy_Brand.html

  # Check for all the needed functions for output buffering
  # Make some wrappers for the top and bottoms of our files.

  function out_buffer_mode_get()
  # This will be used eventually to support more modes.  It is
  # needed because both header and footer functions must know
  # what each other is doing.
  {
    if (function_exists('ob_start'))
      $mode = 1;
    else
      $mode = 0;

    # Zero (0) is no mode or in other words output buffering is OFF.

    # Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
    # Usefull if we ever decide to combine modes.  Then a bitmask
    # field of the sum of all modes will be the natural choice.

    header("X-ob_mode: $mode");
  
    return $mode;
  }

  # This function will need to run at the top of all pages if 
  # output buffering is turned on.  It also needs to be passed $mode
  # from the out_buffer_mode_get() function or it will be useless.
  function out_buffer_pre($mode)
  {
    switch($mode)
    {
      case 1:
        ob_start('ob_gzhandler');
        $retval = TRUE;
        break;

      default:
      case 0:
        $retval = FALSE;
        break;
    }
    return $retval;
  }
  
  # This function will need to run at the bottom of all pages if
  # output buffering is turned on.  It also needs to be passed $mode
  # from the out_buffer_mode_get() function or it will be useless.
  function out_buffer_post($mode)
  {
    switch($mode)
    {
      case 1:
        # This output buffer doesn't need a footer.
        $retval = TRUE;
        break;

      default:
      case 0:
        $retval = FALSE;
    }
    return $retval;
  }

?>


More information about the Developers mailing list