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:
use lib("./Modules", "."); # if there's no $0, or it's not sane...
ADD AFTER:
eval { require Modules::Compress::cgi_buffer; } &CheckDollarAt($@);
import Compress::cgi_buffer;
$cgi_buffer::generate_etag = 0;
, thanks for updating it
Just an FYI, if this works for your forums, and you have the shoutbox installed, do the following.
In ubb_shoutbox.cgi
Find:
use lib("./Modules", "."); # if there's no $0, or it's not sane...
ADD AFTER:
require Modules::Compress::cgi_buffer;
import Compress::cgi_buffer;
$cgi_buffer::generate_etag = 0;
Cut my shoutbox down from 27K to 3.4K
This also works well in the CP.
In cp.cgi
FIND:
($0 =~ m!(.*)(\|/)[^/\]+!) && unshift(@INC, $1, "$1$2Modules"); # our Modules directory
use lib("./Modules", "."); # jic $0 fails
ADD AFTER:
require Modules::Compress::cgi_buffer;
import Compress::cgi_buffer;
$cgi_buffer::generate_etag = 0;
Brought my General Settings page from 197KB to 17KB
Great job Ian!!!
Uhh.. where do I put these folders and files? Do I make any edits besides in cp.cgi and shoutbox.cgi?
they all go into the Modules folder
ie, Modules/Compress/cgi_buffer.pm
You edit ultimatebb.cgi, the other 2 are optional
Now installed at DCTalkSolo.com
I was curious however; anything additional needed to patch ultimatebb.php?
no, it uses zlib by default
Good to know... Man, i've seen some large boards get a much needed kick from this already...
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?
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)
Edited ian's post to add additional requirement
at least in this version I got it to tell you that instead of the old "**** you very much" ISE message
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
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
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
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?
I don't know how to install a module in Windows
quote:
cgi-binmodulesCompress
cgi-binmodulesDigest
cgi-binmodulesIO
this one.. but you need Compress::Zlib
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...
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.)
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...)
Oh, once I tried to install a module and it was much more complicated, so I thought it's the same here
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!
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?
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]
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
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
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
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
6.71K is awesome. Most decent size boards are 80+
I'm seeing 65kb (66009 bytes) in IE and 6.7kb in firefox on the xbox site.
Firefox shows it correctly. IE shows the size of the file it cached, not the file it downloaded
I guess we can asume its working then.
Thanks fellas.
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.
Great job to all those involved!
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/
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?
Hmph... Interestingly enough I changed my mapping of Perl from Perlis.dll to Perl.exe and things seem to be working again. Very strange.
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?
not needed for javascript and the PHP accelerator does it already
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.
Great job to all those involved!
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
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
If you send a cookie only for this operation, you can even display compression ratio.
For eaxample this will probably do the trick:
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:
<script>document.write("Page compression ratio: "+read_cookie('UBBGZIPRATIO'))</script>
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.
And the old one is based on a module 4+ years old
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
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
Also there is this one:
http://search.cpan.org/dist/CGI-Compress-Gzip but it requires IO::Zlib
There may be some other modules...