Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases

Reply
 
Thread Tools
Compress Forum Templates (Speed up your Forums & Save Bandwidth) Details »»
Compress Forum Templates (Speed up your Forums & Save Bandwidth)
Version: 2.8, by Trigunflame Trigunflame is offline
Developer Last Online: Nov 2019 Show Printable Version Email this Page

Version: 3.0.7 Rating:
Released: 04-13-2005 Last Update: Never Installs: 95
 
No support by the author.

Compress Forum Templates & Phrases
Speed up your Forums & Save Bandwidth


Description:

Hi, this is a pretty simple hack that involves compressing the 'compiled' version of your templates, this way it only compresses the part thats to be shown on the forum and not the actual template data you edit.

Background:

Got the idea from Zero Tolerance in buro9's thread:
https://vborg.vbsupport.ru/showthread.php?t=69787

The above hack compresses the page at parse time, while it provides some speed enhancement, on large pages you can actually "negate" the point of using the hack in the first place, because of the overhead in compression.

Thus, the creation of this hack is to provide similiar functionality, but done in the adminCP; and without the overhead of constant compression.

Info:

No Queries. Only query is used when compressing your templates, the rest of the time its just pulling the templates straight out of the database like normal.

Updates:

Version 2.8 - Added Strip Whitespace from Start of JS Line by buro9
Version 2.7 - Option to strip HTML Comments from Compressed Output
Version 2.6 - Removed Phrase Compression altogether, Too Iffy
Version 2.5 - Removed the ASCII \n removal, emails should work now.
Version 2.4 - Had to add editor_jsoptions_size to the Bad Templates array, it also was causing a font selection error.
Version 2.3 - Added Phrase compression support, should help further increase page compression.
Version 2.2 - Slightly Recoded Template compression for faster results.
Version 2.1 - Added php_include templates to bad templates, will not compress these.
Version 2.0 - Recoded Script, added support for certain templates to not compress
Version 1.9 - Re-Added support for InLine Styles.
Version 1.8 - Removed support for InLine Styles, all Style data is left with Linebreaks.
Version 1.7 - Removed support for InLine Javascript, all JavaScript is left with Linebreaks.
Version 1.6 - Fixed Tab problem, tabs are replaced with a single space
Version 1.5 - Removed a part of the SQL.
Version 1.4 - TOTALLY Remade, Works perfect now; Ultimate Compression
Version 1.3 - Adjusted Again
Version 1.2 - Adjusted Stripping regex
Version 1.1 - Added Uncompress Support
Version 1.0 - Release

Install:

Step 1. [ Open admincp/template.php ]
Step 2. [ Go to about line: 1278, or just look for $_REQUEST['do'] == 'edit' ]
Step 3. [ Above Step 2, add the below code ]

PHP Code:
// #############################################################################
// Rebuild Templates Compressed
if ($_REQUEST['do'] == 'compressall')
{
    
/**
     * Compress Templates Mod
     *
     * Thanks for Idea From Zero Tolerance.
     * Thanks for Help & Support From buro9
     *
     * @author Trigunflame
     * @version 2.8
     * @copyright Dusty Burns, 2005-2006
     */

    // Strip Comments?
    // Use true or false
    
$stripComments true;

    
// Search & Replace
    
$search  = array('/\s+/''/\t+/'); 
    
$replace ' '
    
$jsearch  = array('/^\s+/''/\t+/');
    
$jreplace = array(''' ');
    
    
// Strip Comments
    
if ($stripComments) { $search[] = '/<!--.*?-->/'; }
    
    
// List of Templates to NOT Compress
    
$badTemplates = array(
        
'editor_jsoptions_font',
        
'editor_jsoptions_size',
        
'phpinclude_start',
        
'phpinclude_end'
    
);
            
    
// Get Modified Templates
    
$templates $DB_site->query(
        
"SELECT templateid, title, template_un " 
        
"FROM " TABLE_PREFIX "template " .
        
"WHERE template_un <> '' "
    
);
    
    
// Selectively Compress
    
while ($template $DB_site->fetch_array($templates))
    {
        
// Compile Template
        
$compiledTemplate compile_template($template['template_un']);
        
        
// Bad Template
        
if (in_array(strtolower($template['title']), $badTemplates))
        {
            
// Ignoring Template
            
echo "Bad Template [" $template['templateid'] . "] " $template['title'] . "<br />\n";
            
            
$compressedTemplate $compiledTemplate;
        }
        
        
// Reverting Template
        
else if ($_REQUEST['revert'])
        {
            
// Uncompressing
            
echo "Uncompressing [" $template['templateid'] . "] " $template['title'] . "<br />\n";
            
            
$compressedTemplate $compiledTemplate;
        }
        
        
// Good Template
        
else
        {
            
// Compressing
            
echo "Compressing [" $template['templateid'] . "] " $template['title'] . "<br />\n";
            
            
// Get All Lines
            
$compiledTemplate preg_split('(\r\n|\r|\n)'$compiledTemplate);
            
            
// Javascript Status
            
$js false;

            
// Compressed Output
            
$compressedTemplate '';
            
            
// Loop Lines
            
foreach ($compiledTemplate AS $line)
            {
                
// LowerCase Line
                
$lowerLine strtolower($line);
                
                
// Look For Start of JavaScript
                
if (strpos($lowerLine'<script') !== false) { $js true; }
                
                
// Check For Null
                
if (trim($line) == '') continue;
    
                
// Check JS Status
                
if (!$js && !$st)
                {
                    
// Full WhiteSpace Strip
                    
$line preg_replace($search$replace$line);
                }
                else
                {
                    
// Straight Output
                    
$line preg_replace($jsearch$jreplace$line) . "\r\n";
                }

                
// Look For End of JavaScript
                
if (strpos($lowerLine'</script>') !== false) { $js false; }
                
                
// Check For Null
                
if (trim($line) == '') continue;
                
                
// Append Line
                
$compressedTemplate .= $line;
            }
        }
        
        
// Update Template
        
$DB_site->query(
            
"UPDATE " TABLE_PREFIX "template " 
            
"SET template = '" addslashes($compressedTemplate) . "' " 
            
"WHERE templateid = '" $template['templateid'] . "'"
        
);
    }
    
    
// Redirect
    
print_cp_redirect('index.php?do=home'1);
    
    
/**
     * End Compress Templates Mod
     */

Step 4. [ close admincp/template.php and open admincp/index.php ]
Step 5. [ look for ]

PHP Code:
construct_nav_option($vbphrase['find_updated_templates'], 'template.php?do=findupdates''<br />'); 
Step 6. [ below this, add the code ]

PHP Code:
construct_nav_option("Compress Templates"'template.php?do=compressall''<br />');
construct_nav_option("Uncompress Templates"'template.php?do=compressall&revert=1''<br />'); 
How-To Run

1. Install
2. In the admincp left navigation, select "Compress Templates".
3. Repeat Step 2 after each modification of your Templates whenever you decide to change something.
4. If you want to uncompress all Templates, select "Uncompress Templates"
5. IF Any Templates Come Out Weird, add the template Name to the Bad Templates Array and Re-Run the Compress Templates.

Supporters / CoAuthors

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #152  
Old 05-31-2005, 10:17 AM
PIKenPIK PIKenPIK is offline
 
Join Date: Feb 2005
Location: Netherlands
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

w00t .............. forum goes like a rocket :lick: :lick: :lick: :lick: :lick: :lick:

Big HUGGGG :banana:

//edit:
one small Q:
Quote:
The bad templates array exist for a reason, add the offending templates to the array and it will skip them.
I've done the compression & everything seems to work like a a charm.

Compress Templates and Uncompress Templates seems for me the only 2 options in the ACP ..
Is there only a bad templates array when there is a bad template?
Or where can i find this array?
Reply With Quote
  #153  
Old 06-02-2005, 07:47 AM
LambHyjoo LambHyjoo is offline
 
Join Date: Apr 2005
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I forgot to post my opinion on this hack : Very good job !

I had little problems with some custom templates I did, but it was tuned in less an hour.

Thanks again !
Reply With Quote
  #154  
Old 06-02-2005, 07:58 AM
PIKenPIK PIKenPIK is offline
 
Join Date: Feb 2005
Location: Netherlands
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by LambHyjoo
I forgot to post my opinion on this hack : Very good job !

I had little problems with some custom templates I did, but it was tuned in less an hour.

Thanks again !
So, you can give me an answer to my question? :ninja:
Reply With Quote
  #155  
Old 06-02-2005, 08:12 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In admincp/template.php:
PHP Code:
    // List of Templates to NOT Compress 
    
$badTemplates = array( 
        
'editor_jsoptions_font'
        
'editor_jsoptions_size'
        
'phpinclude_start'
        
'phpinclude_end' 
    
); 
Reply With Quote
  #156  
Old 06-02-2005, 10:01 PM
smacklan's Avatar
smacklan smacklan is offline
 
Join Date: Mar 2005
Posts: 497
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What a freakin awesome hack...I'm running 2 to 3 times faster!!! Installed without any ill effects as far as I can tell ( at least none that I can't live with)! Thanks dude!
Reply With Quote
  #157  
Old 06-09-2005, 02:45 AM
LuBi LuBi is offline
 
Join Date: Oct 2001
Posts: 416
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

worked fine for me on a very modded and styled board.. no issues I can see at all..? nice release. thanks.
Reply With Quote
  #158  
Old 07-14-2005, 07:00 AM
kthlnwrnr kthlnwrnr is offline
 
Join Date: Mar 2005
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does this hack work with VB 3.3?
I tried insalling it but I guess I am doing something wrong. I get an internal server error everytime I click on the compress link.

There is a chance that I am doing one thing wrong. In step to the instruction says I should
Quote:
[ Go to about line: 1278, or just look for $_REQUEST['do'] == 'edit' ]

Now should I paste the codes right above
Quote:
$_REQUEST['do'] == 'edit')
or right above
Quote:
if ($_REQUEST['do'] == 'edit')
Or right above
Quote:
(This is line 1278 in my template.php)//################################################## ###########################
// edit form for an existing template
if ($_REQUEST['do'] == 'edit')
?

I apologize in advance for my ignorance, but I am a bit confused and would like to get this hack to work.
Reply With Quote
  #159  
Old 08-03-2005, 07:17 PM
Prodimysterio Prodimysterio is offline
 
Join Date: Feb 2005
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by LuBi
worked fine for me on a very modded and styled board.. no issues I can see at all..? nice release. thanks.
Same here. Thanks for the great modification.

Reply With Quote
  #160  
Old 08-12-2005, 07:12 PM
loftyasianz loftyasianz is offline
 
Join Date: May 2004
Location: philadelphia, pa
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks for this awesome hack. it really seems like a good idea.

i just finished installing this and i compressed my templates. but when i refreshed my page, i got this
Code:
Parse error: parse error, unexpected ',' in /home/gm0nk3y/public_html/forums/index.php(672) : eval()'d code on line 1
any suggestions? it was all fixed when i uncompressed the templates.

thanks in advance,
warren
Reply With Quote
  #161  
Old 08-29-2005, 04:05 AM
gbechtel gbechtel is offline
 
Join Date: Aug 2005
Posts: 75
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed & woking on masscops.com with no problems at all! Excelent job, thanks...
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:13 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05272 seconds
  • Memory Usage 2,365KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (4)bbcode_php
  • (7)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete