UBB.Dev
Posted By: Ian Spence [6.7] [beta] UBB Compression - 07/02/2004 8:15 PM
Modification Name: UBB Compression

Author(s): Ian Spence, AllenAyres

Demo: http://www.alforadmin.com

Requirements: UBB.classic 6.x, Compress::Zlib

Download Link: https://www.ubbdev.com/ubb/upload/00020028/Compress.zip

Credits: Allen for the original code

* Copy the ZIP's contents into the Modules folder.

# If installing on 6.0 <-> 6.6, uncomment "use strict;"
# This is already uncommented in 6.7+

Find:

Code
use lib("./Modules", ".");	# if there's no $0, or it's not sane...
ADD AFTER:

Code
eval { require Modules::Compress::cgi_buffer; } &CheckDollarAt($@);
import Compress::cgi_buffer;
$cgi_buffer::generate_etag = 0;
Posted By: AllenAyres Re: [6.7] [beta] UBB Compression - 07/02/2004 10:34 PM
cool , thanks for updating it smile
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 07/02/2004 11:20 PM
Just an FYI, if this works for your forums, and you have the shoutbox installed, do the following.

In ubb_shoutbox.cgi

Find:
Code
use lib("./Modules", ".");	# if there's no $0, or it's not sane...
ADD AFTER:
Code
require Modules::Compress::cgi_buffer;
import Compress::cgi_buffer;
$cgi_buffer::generate_etag = 0;
Cut my shoutbox down from 27K to 3.4K
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 07/02/2004 11:39 PM
This also works well in the CP.

In cp.cgi

FIND:
Code
	($0 =~ m!(.*)(\|/)[^/\]+!) && unshift(@INC, $1, "$1$2Modules"); # our Modules directory
use lib("./Modules", "."); # jic $0 fails
ADD AFTER:
Code
	require Modules::Compress::cgi_buffer;
import Compress::cgi_buffer;
$cgi_buffer::generate_etag = 0;
Brought my General Settings page from 197KB to 17KB
Posted By: d-talk Re: [6.7] [beta] UBB Compression - 07/03/2004 12:59 AM
Great job Ian!!! thumbsup
Posted By: GATOR420 Re: [6.7] [beta] UBB Compression - 07/03/2004 2:07 AM
Uhh.. where do I put these folders and files? Do I make any edits besides in cp.cgi and shoutbox.cgi?
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 07/03/2004 2:08 AM
they all go into the Modules folder

ie, Modules/Compress/cgi_buffer.pm

You edit ultimatebb.cgi, the other 2 are optional
Posted By: Gizmo Re: [6.7] [beta] UBB Compression - 07/03/2004 2:42 AM
Now installed at DCTalkSolo.com

I was curious however; anything additional needed to patch ultimatebb.php?
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 07/03/2004 2:54 AM
no, it uses zlib by default
Posted By: Gizmo Re: [6.7] [beta] UBB Compression - 07/03/2004 3:26 AM
Good to know... Man, i've seen some large boards get a much needed kick from this already...
Posted By: GATOR420 Re: [6.7] [beta] UBB Compression - 07/03/2004 6:39 AM
OK, I got this error:

There was a compilation error while loading the UBB.classic libraries and data files:

Can't locate Modules/Compress/cgi_buffer.pm in @INC (@INC contains: ./Modules . c:inetpubwwwrootcgi-bin c:inetpubwwwrootcgi-binModules C:/Perl/lib C:/Perl/site/lib) at c:inetpubwwwrootcgi-binultimatebb.cgi line 60.


Please make sure that you uploaded the CGI and Variables files to the proper directory, permissions are set properly on the files, and that paths in the control panel are set correctly.

I checked the permissions and they are the same as all the other directories really. I think I gave them all everything but full control. Paths are obviously set correctly... What did I mess up?
Posted By: Gizmo Re: [6.7] [beta] UBB Compression - 07/03/2004 7:25 AM
It means you don't have zlib compression installed on the system; which is required to run this mod (I'm suprised it's not in the requirements)
Posted By: Gizmo Re: [6.7] [beta] UBB Compression - 07/03/2004 7:28 AM
Edited ian's post to add additional requirement wink
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 07/03/2004 1:22 PM
smile at least in this version I got it to tell you that instead of the old "**** you very much" ISE message tipsy
Posted By: LK Re: [6.7] [beta] UBB Compression - 07/03/2004 1:47 PM
Actually I don't think you need it, you just need to copy anything inside the ZIP file into the Modules folder.
Then you'll have Modules/Compress/cgi_buffer.pm
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 07/03/2004 1:49 PM
Quote
Originally posted by LK:

Actually I don't think you need it, you just need to copy anything inside the ZIP file into the Modules folder.
Then you'll have Modules/Compress/cgi_buffer.pm
You need it.

Zip updated
Posted By: LK Re: [6.7] [beta] UBB Compression - 07/03/2004 2:21 PM
Follow-up: you don't need to have Compress::cgi_buffer in your Perl installation, you just need to upload it to your Modules folder; though you do need Compress::Zlib smirk
Posted By: GATOR420 Re: [6.7] [beta] UBB Compression - 07/03/2004 4:20 PM
OK, so just to be clear, the paths should be something similar to below?

cgi-binmodulesCompress
cgi-binmodulesDigest
cgi-binmodulesIO

And just copy the files from the zip into the all ready existing Digest and IO directories?

Or

cgi-binmodulesCompress
cgi-binmodulesCompressDigest
cgi-binmodulesCompressIO

Which was how the orginal zip was structured.


I went to the zlib website to get this application but all I found that appeared to be useful was a single DLL file? Do I just need that? And copy it to the modules folder?
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 07/03/2004 4:41 PM
I don't know how to install a module in Windows
Posted By: LK Re: [6.7] [beta] UBB Compression - 07/03/2004 6:19 PM
Quote
quote:
cgi-binmodulesCompress
cgi-binmodulesDigest
cgi-binmodulesIO
this one.. but you need Compress::Zlib
Posted By: GATOR420 Re: [6.7] [beta] UBB Compression - 07/03/2004 10:09 PM
OK... Can someone link me to that please? I tried searching for Compress::Zlib and Zlib on Google but the results are less than helpful, or perhaps I don't know what I'm looking at (probably the later). Thanks in advance...
Posted By: LK Re: [6.7] [beta] UBB Compression - 07/03/2004 10:21 PM
You have to ask your webhosting provider to install Compress::Zlib (it's a very complicated process, unlike UBB's other modules.)
If you are your own host go to http://search.cpan.org and look it up (that is the best search engine for Perl modules.)
Posted By: Charles Capps Re: [6.7] [beta] UBB Compression - 07/03/2004 10:40 PM
I fail to see how:

Unix: perl -MCPAN -e install Compress::Zlib

Windows: ppm install Compress::Zlib

is complicated.

(Unless, of course, your host has a large long approval procedure for running such commands...)
Posted By: LK Re: [6.7] [beta] UBB Compression - 07/03/2004 10:42 PM
Oh, once I tried to install a module and it was much more complicated, so I thought it's the same here shocked
Posted By: tgreene Re: [6.7] [beta] UBB Compression - 07/03/2004 11:40 PM
Quote
Originally posted by Charles Capps:

I fail to see how:

Unix: perl -MCPAN -e install Compress::Zlib

Windows: ppm install Compress::Zlib

is complicated.

(Unless, of course, your host has a large long approval procedure for running such commands...)
Sure, that's easy for YOU to say... When people such as yourself cut your fingers, binary bits flow out instead of blood! eek
Posted By: GATOR420 Re: [6.7] [beta] UBB Compression - 07/04/2004 1:24 AM
I am my own host so no problems there. I went out to the suggested website and found this link:

http://search.cpan.org/~pmqs/Compress-Zlib-1.33/Zlib.pm

Now what do I do with it? I don't see any files? Is Zlib.pm the file? How do I install it?
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 07/04/2004 2:23 AM
http://www.cpan.org/modules/by-module/Compress/Compress-Zlib-1.33.tar.gz

is what I used.
Posted By: Gizmo Re: [6.7] [beta] UBB Compression - 07/04/2004 8:32 AM
Quote
Originally posted by Charles Capps:

I fail to see how:

Unix: perl -MCPAN -e install Compress::Zlib

Windows: ppm install Compress::Zlib

is complicated.

(Unless, of course, your host has a large long approval procedure for running such commands...)



Take it up a notch; Ensim install:
quote:
[qb]Install Compress::Zlib
======================
perl -MCPAN -e shell
install Compress::Zlib
exit

Deploy Serverwide:
==================
set_pre_maintenance
set_maintenance
set_post_maintenance
service webppliance restart[/qb]
Posted By: [email protected] Re: [6.7] [beta] UBB Compression - 07/07/2004 9:12 PM
Code
Digest::MD5 object version 2.09 does not match bootstrap parameter 2.16 at /usr/lib/perl5/5.6.0/i386-linux/DynaLoader.pm line 219.
Any idea whats causing this?, can i put back the original?

Thanks
Posted By: [email protected] Re: [6.7] [beta] UBB Compression - 07/07/2004 9:26 PM
I replaced the md5 that came with this mod with the original from 6.7.1 and the errors went away.

Is there anyway to tell if its working or have i screwed it :s

Thanks
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 07/07/2004 9:41 PM
in Firefox, go to your forum summary, make sure that the page's url ends in cgi.

Now, view page info and see how large the page is.

If you only have IE, link me to the page and I can tell you
Posted By: [email protected] Re: [6.7] [beta] UBB Compression - 07/08/2004 3:50 AM
Thanks Ian

In Firefox it reports the forum sumary as 6.71k

I think that is small but i never checked it before - i guess i could uninstall it and check.

Here is the link http://forum.xbox365.net/ubb/ultimatebb.cgi
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 07/08/2004 4:57 AM
6.71K is awesome. Most decent size boards are 80+
Posted By: AllenAyres Re: [6.7] [beta] UBB Compression - 07/08/2004 4:26 PM
I'm seeing 65kb (66009 bytes) in IE and 6.7kb in firefox on the xbox site.
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 07/08/2004 4:49 PM
Firefox shows it correctly. IE shows the size of the file it cached, not the file it downloaded
Posted By: [email protected] Re: [6.7] [beta] UBB Compression - 07/08/2004 8:20 PM
I guess we can asume its working then.

Thanks fellas.
Posted By: Brett Re: [6.7] [beta] UBB Compression - 07/20/2004 5:40 AM
I have applied this to all my applications on the Alltel intranet. It chopped a 124k page to 13.2k. I know all here who deal with large pages/apps, taxing the server at every turn, any letup is greatly appreciated. smile

Great job to all those involved! thumbsup
Posted By: GATOR420 Re: [6.7] [beta] UBB Compression - 08/15/2004 2:34 AM
Hmm... Would this precompiled .dll work? I'm still not quite sure what to do with it, but it looks like I might be getting closer?

http://www.winimage.com/zLibDll/
Posted By: GATOR420 Re: [6.7] [beta] UBB Compression - 09/09/2004 2:42 AM
OK... I finally figured this out. Compression up and running. Rock on.

Are there any other pages I need to edit besides ultimatebb.cgi, ubb_shoutbox.cgi, and cp.cgi?

'Er, I thought I had it figured out... Now I get this:

'c:inetpubwwwrootcgi-binultimatebb.cgi' script produced no output

This error now seems to be occurring on all cgi pages and the second on php pages.

Status on main page also seems to be fubar'd.

Getting these error messages in IE when going to php pages:

When going to main page I get this error:

Line: 2
Char: 32
Error: Expected hexidecimal digit
Code: 0
URL: Provided

Help pretty please?
Posted By: GATOR420 Re: [6.7] [beta] UBB Compression - 09/09/2004 3:31 AM
Hmph... Interestingly enough I changed my mapping of Perl from Perlis.dll to Perl.exe and things seem to be working again. Very strange.
Posted By: GATOR420 Re: [6.7] [beta] UBB Compression - 09/09/2004 3:46 AM
What would I need to add to ubb_status.cgi, poll_ssi.cgi, ubb_hits.cgi, ubb_checkmsg.cgi in order for them to get the same benefit?

Does this work for PHP and/or Javascript like the Newsfader?
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 09/09/2004 4:32 AM
not needed for javascript and the PHP accelerator does it already
Posted By: Burak Re: [6.7] [beta] UBB Compression - 12/23/2004 1:22 AM
Quote
Originally posted by Brett:

I have applied this to all my applications on the Alltel intranet. It chopped a 124k page to 13.2k. I know all here who deal with large pages/apps, taxing the server at every turn, any letup is greatly appreciated. smile

Great job to all those involved! thumbsup



If you write your own code I have a suggestion; use only a single print for output. This way, you do not need any 3rd party buffering module like this smile and it'll be easy to port to platforms like mod_perl.

Originally posted by AllenAyres:
[qb]
I'm seeing 65kb (66009 bytes) in IE and 6.7kb in firefox on the xbox site.
[/qb]
There are several alternatives in CPAN, which basicaly do the same thing: buffer STDOUT, split body and headers and gzip body. And they may be better than this "cgi_buffer" -- I don't like the coding. But this one ( http://search.cpan.org/dist/CGI-WebGzip/ ) gives a nice idea to display the compressed size smile If you send a cookie only for this operation, you can even display compression ratio.

For eaxample this will probably do the trick:

Code
	if ($cgi_buffer::compress_content) {
foreach $encoding ('x-gzip', 'gzip') {
$_ = lc($ENV{'HTTP_ACCEPT_ENCODING'});
if ( m/$encoding/i && lc($content_type[0]) eq 'text') {
my $size_normal = length($body);
$body = Compress::Zlib::memGzip($body);
my $size_gzip = length($body);
my $ubb_gzipr = sprintf("%.2f",100-($size_gzip * 100 / $size_normal));
push @o, "Content-Encoding: $encoding";
push @o, "Vary: Accept-Encoding";
push @o, "Set-Cookie: UBBGZIPRATIO=$ubb_gzipr; path=/";
last;
}
}
}
You can then use a javascript function to read "UBBGZIPRATIO" cookie:

Code
<script>document.write("Page compression ratio: "+read_cookie('UBBGZIPRATIO'))</script>
Posted By: Ian Spence Re: [6.7] [beta] UBB Compression - 12/23/2004 2:10 AM
If you can write a better version of this mod, please do. I only ported this from the old version, and wouldn't be suprised if I did that poorly.
Posted By: AllenAyres Re: [6.7] [beta] UBB Compression - 12/23/2004 8:41 AM
And the old one is based on a module 4+ years old smile
Posted By: Burak Re: [6.7] [beta] UBB Compression - 12/23/2004 5:23 PM
Quote
Originally posted by Ian Spence:

If you can write a better version of this mod, please do. I only ported this from the old version, and wouldn't be suprised if I did that poorly.
No, I can't write a better version smile since the concept is the same and a little further can be done. But there are better alternatives like CGI::WebGzip. It auto-checks the existence of Compress::Zlib and does not require any other module like "IO::String" or MD5 smile

Also there is this one: http://search.cpan.org/dist/CGI-Compress-Gzip but it requires IO::Zlib

There may be some other modules...
© UBB.Developers