vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Graveyard (https://vborg.vbsupport.ru/forumdisplay.php?f=224)
-   -   Board Optimization - Plugin Based Template Cache (https://vborg.vbsupport.ru/showthread.php?t=121876)

dbirosel 03-12-2007 04:36 PM

reserved!!

orban 03-12-2007 05:03 PM

Quote:

Originally Posted by bluechris (Post 1200525)
I have a problem since i installed it.... suddenly the forum index shows a strange error



the line 151 in forums.php is this



Forums.php is the normal index.php that vb has but i had renamed it and i have index the cmps.

The thing is that the code in the file is fine.... even though i had replaced it with the latest and i still getting the error.

I had also uninstalled the addon with no luck...... I am with IIS6 .. php 4.4.6 with apc and mysql 4.1.16.

Anyone has any clue?

Are you using the experimental version?

Quote:

Originally Posted by dbirosel (Post 1201702)
reserved!!

Pardon?

Zia 03-13-2007 04:28 AM

helo orban,

here its ur experiemntal one ?
https://vborg.vbsupport.ru/showpost....&postcount=242

i got spaces for using it...but could u plese be more specific...or can u just make the function.php or whatever.php files here .. i want to go for it..if it give more output......

Looking for ur help.
Thnx.

GrendelKhan{TSU 03-16-2007 12:19 PM

woot

|Jordan| 03-18-2007 12:33 AM

Where can i get the opcode cache plugin?

Zia 03-18-2007 06:22 AM

Quote:

Originally Posted by |Jordan| (Post 1205956)
Where can i get the opcode cache plugin?

do u have any opcode cacher installed ?
like Xcache /eAcc or APC ?

Orban's mod will boost cacher....


if ur on xcache u can also try IT

orban 03-18-2007 09:20 AM

Quote:

Originally Posted by |Jordan| (Post 1205956)
Where can i get the opcode cache plugin?

Sorry, what do you mean?

You don't need any vBulletin modification to run APC/aAccelerator/xcache.

Zia 03-18-2007 12:24 PM

Quote:

Originally Posted by orban (Post 1157214)
EXPERIMENTAL (for your dev board)

This will NEVER work with plugins who modify templates on run time so don't even try :)

Place the function in a file & create forums/cache folder

Code:

function cache_templates_one_file($templates, $templateidlist)
{
        global $vbulletin, $templateassoc;

        if (empty($templateassoc))
        {
                $templateassoc = unserialize($templateidlist);
        }

        if ($vbulletin->options['legacypostbit'] AND in_array('postbit', $templates))
        {
                $templateassoc['postbit'] = $templateassoc['postbit_legacy'];
        }
       
        foreach ($templates AS $template)
        {
                $templateids[] = intval($templateassoc["$template"]);
        }

        /* THE ACTUAL PLUGIN */
        $templatefile = 'cache/'.md5(implode(',', $templateids)).'.php';
        if (file_exists($templatefile))
        {
                include($templatefile);
        }
        else
        {
                $templatecache = '';
        /* END ACTUAL PLUGIN */
                // run query
                $temps = $vbulletin->db->query_read("
                        SELECT templateid, title, template
                        FROM " . TABLE_PREFIX . "template
                        WHERE templateid IN (" . implode(',', $templateids) . ")");
                // cache templates
                while ($temp = $vbulletin->db->fetch_array($temps))
                {
                        /* START ACTUAL PLUGIN */
                        preg_match_all('/\$[a-zA-Z][a-zA-Z\_0-9]+/', $temp['template'], $out);
                        $vars = array_unique($out[0]);
                        $templatecache .= '
                                /* '.$temp['title'].' */ $template_vars['.$temp['templateid'].'] = \''.implode(', ', $vars).'\'; function template_'.$temp['templateid'].'('.implode(', ', $vars).') { return "'.$temp['template'].'"; } ';
                        /* END ACTUAL PLUGIN */
                }
                $vbulletin->db->free_result($temps);
                /* START ACTUAL PLUGIN */
                $fp = fopen($templatefile, 'w+');
                if ($fp && flock($fp, LOCK_EX))
                {
                        fwrite($fp, '<?php '.$templatecache.' ?>');
                        flock($fp, LOCK_UN);
                        fclose($fp);
                }
                include($templatefile);
                /* END ACTUAL PLUGIN */
        }

        foreach ($templates AS $template)
        {
                if (substr($template, 0, 17) == 'editor_jsoptions_' or substr($template, 0, 14) == 'editor_styles_')
                {
                        $vbulletin->templatecache[$template] = call_user_func('template_'.intval($templateassoc["$template"]));
                }
                else $vbulletin->templatecache[$template] = '".template_'.intval($templateassoc["$template"]).'('.$template_vars[intval($templateassoc["$template"])].')."';
                #$vbulletin->templatecache[$template] = '';
        }
       
        $vbulletin->bbcode_style = array(
                'code'  => &$templateassoc['bbcode_code_styleid'],
                'html'  => &$templateassoc['bbcode_html_styleid'],
                'php'  => &$templateassoc['bbcode_php_styleid'],
                'quote' => &$templateassoc['bbcode_quote_styleid']
        );
}

And call it in "cache_templates" hook (adjust the path for the file with the function in it)

Code:

include('includes/functions_hooks.php');
cache_templates_one_file($globaltemplates, $style['templatelist']);
$globaltemplates = array();

does not delete cache when modifying templates and no options in it, please

ONLY USE THIS IF YOU KNOW WHAT YOU ARE DOING and understand the code

It basically reads all templates and creates a function for every template with all the variables in it passed as arguments so you can avoid scope issues.

Please note this takes up A LOT of space in xcache/APC (about 40mb for the cache/ files alone) so make sure you have enough space allocated (I'm using 128mb atm and that works fine).

Again please don't install this if you don't know PHP well and know what you're doing. Just sharing this because I've been using it for a few days successfully and maybe somebody can use it. :) This mod doesn't modify the database or any vB files (like the version you can download).

Orban,could u please help a bit more about it...

orban 03-18-2007 12:32 PM

I just don't have the time right now to support this thing (I mean check the number of pages in this thread, and the experimental is indeed experimental and there's several issues to be worked out).

Zia 03-18-2007 12:40 PM

ah ha..Okay..
just thought it might be good than the existing one...so wanted to give a try....

Okay....but like this existing mods "boost up php cache" for any opcode cacher...
is there any way to boost up var.cacher ?


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

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01312 seconds
  • Memory Usage 1,763KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete