vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Community Lounge (https://vborg.vbsupport.ru/forumdisplay.php?f=13)
-   -   How Long is your PHP_INCLUDE START template? (https://vborg.vbsupport.ru/showthread.php?t=71088)

Michael Morris 10-28-2004 08:44 AM

How Long is your PHP_INCLUDE START template?
 
The one I maintain for WotC just crossed 800 lines...

Logikos 10-28-2004 09:23 AM

Thats a pretty large amount of extra code to be ran on every single page powered by the vBulletin templates don't you think?

AN-net 10-28-2004 10:13 AM

that is a little outrageous, if you have that many lines i suggest you actually intergrate that into global.php and corresponding files for the purposes of optimizing your site;)

Michael Morris 10-28-2004 12:23 PM

Most of it is setting user options. Part of the reason for the length is I'm not allowed to mod the code (corporate site) and I don't have FTP access to the file base (which is occasionally a pain). So to get the features the users want I've gotten to be very creative.

If I ever finalize it I guess it will be included as a seperate file.

Another reason for the length is the site has 12 seperate headers that are independent of the stylesets (you can match any of the 20 stylesets with the headers)

Johnny 10-28-2004 12:49 PM

right now mine is at about 13 its probably going to grow up to 20 once im done with the site.

filburt1 10-28-2004 02:20 PM

57 in php_include_start, 80 in php_include_end. However, both of those have require() statements in which the required files are hundreds of lines long. I also haven't modified a single line of vB code.

Hialls 10-28-2004 03:03 PM

heh i thought my 42 was alot :D

AN-net 10-28-2004 04:27 PM

Quote:

Originally Posted by Michael Morris
Most of it is setting user options. Part of the reason for the length is I'm not allowed to mod the code (corporate site) and I don't have FTP access to the file base (which is occasionally a pain). So to get the features the users want I've gotten to be very creative.

If I ever finalize it I guess it will be included as a seperate file.

Another reason for the length is the site has 12 seperate headers that are independent of the stylesets (you can match any of the 20 stylesets with the headers)

if your that important to the site i would highly suggest they give u ftp access or say you cant work on the community till they do

Xenon 10-28-2004 06:30 PM

on vb.org we have 106 lines of code :)

without any includes or such, and quite a few are just to change a few settings for important persons like myself ;)

Link14716 10-28-2004 07:40 PM

Quote:

Originally Posted by AN-net
if your that important to the site i would highly suggest they give u ftp access or say you cant work on the community till they do

If you can achieve something with the php_include templates, why edit global.php?

Xenon 10-28-2004 08:13 PM

there may be people who like hacking more than editing templates ;)

also if he made some scriptspecific things in phpinclude it doesn't look that well

Michael Morris 10-29-2004 12:36 AM

Heh heh,

Well, another reason it's so long is I LOVE whitespace and making the code both nice to look at as well as functioning. Many of the lines are simply { because I leave those to themselves.

I also have a LOT of commentary text so that if anyone comes in after me they can see what it does.

As an example, here's the first section...

PHP Code:

/*==============================================*\
|| ############################################ ||
|| # Startup Proceedures for Vbulletin Boards # ||
|| #         at Wizards of the Coast          # ||
|| # ---------------------------------------- # ||
|| #   Created for Wizards of the Coast by    # ||
|| #           Michael Lloyd Morris           # ||
|| #           email mlmorr0@uky.edu          # ||
|| # ---------------------------------------- # ||
|| #    This is a PHPINCLUDE_START template   # ||
|| ############################################ ||
\*==============================================*/

// ###############################################
// ##### HANDLE $_REQUESTs #######################
// ###############################################

// Launch Did You Know Pop Up
if (($_REQUEST['do'] == 'didyouknow') AND (THIS_SCRIPT == 'index'))
    {
        
$tip rand(1,15);
        
$tip 'didyouknow_' $tip;
        eval(
'$tipoftheday = "' fetch_template($tip) . '";');    
        eval(
'print_output("' fetch_template('DIDYOUKNOW') . '");');        
    }

// Move thread to Admin Forum preset
if (($_REQUEST['do'] == 'moveadmin') AND (THIS_SCRIPT == 'postings'))
    {
        
$_REQUEST['do'] = 'domovethread';
        
$_POST['do'] = 'domovethread';
        
$_POST['forumid'] = '399';
        
$_POST['method'] = 'move';
    } 

I've found that since PHP_INCLUDE start runs before any other templates or the remainder of the various vbulletin scripts it's the perfect time to intercept special $_REQUEST and $_POST variables and reassign them. The pop-up launcher is the cleanest example of this since it terminates the execution of the rest of the index script immediately when it makes the Print Output call. You can actually create whole new pages that way if you really want to. From a processing standpoint the pop-up makes sense in the PHPINCLUDE_START template since it doesn't need the $header, $footer or any other templates - just the custom DIDYOUKNOW templates.

The second item more cleanly allows the move thread presets. It's actually the 2nd version of a hack I've released and if you make a lot of thread moves it comes highly recommended.

The rest of the script does these things (just copying the commentary text...)

PHP Code:

// ###############################################
// ##### DEFINE FUNCTIONS USED IN TEMPLATE #######
// ###############################################

// ###############################################
// ##### MAIN PAGES INITIALIZATION  ##############
// ###############################################

// #### Prepare $banner array #########################

// #### Merge custom display information into $show ##########

// #### Set Defaults ################################

// ##### PARSE GLOBAL MENU TEMPLATE  #################

// ###############################################
// ##### START ANNOUNCMENTS  #####################
// ###############################################

// ###############################################
// ##### START USER SETTINGS  ####################
// ###############################################

    // #### Set Postbit ##########################
            
    // #### Set Left Column ######################

    // #### Set New Posts in Bold ################

    // #### Set Subscribed in Italics ############

    // #### Set Thread Previews ######################

    // #### Set Display Member Info at top ###########
            
    // #### Set Variable Display Width ###############

    // #### Set Forum Icon Display ###################
            
    // #### Set Tip Launcher ###################

    // #### FORUMHOME User Info ######################
        
// ###############################################
// ##### MISC ACTIONS B4 PARSING HEADERS  ########
// ###############################################

// Turn Left Columns off if we're on an editor interface

// ###############################################
// ##### START HEADERS  ##########################
// ###############################################

// ##### Forumhome ###############################

        // Parse the Forumhome greeting

        //Set the left column to false - this page has a left colum, but unlike 
        //other pages the forumhome template creates the column without the header template doing so.
        //This page is also unaffected by the status of $show['leftcolumn']

// ##### RPGA ####################################

        //Set the Banner

        //RPGA has multiple subforums with slightly different heights
        //and not all allow the navbar to slide under them.
        
        //Living Greyhawk

        //Living Force

        //RPGA Default

        //Set Items which apply to all three banners

// ##### Dungeons & Dragons #######################

        //Set the Banner

        //Set the Left Column if required

                //The D&D styleset has multiple left menus depending on the header
                //The code below changes the left menu depending on the header called.
                
                //Forgotten Realms

                //Eberron

                //D&D Miniatures

                //D&D Main

// ##### Magic: The Gathering #####################

                //This small program determines the date of the Monday that started this week.
                //We need it to determine the file name of the MtG header used in most MtG areas.
                //I think this is going to be good but it might screw up during a change of year.


                // The file name requires leading zeros, so let's add them as necessary.    
            
                // Done. Spit out the filename and evaluate the rest of the MtG header.

        // MtG: Online has a different header that doesn't change weekly.

        // Now let's attend to the prep shared by MtG and MtG Online
        //Parse the lower Magic Menu.

// ##### Duel Masters #############################

// ##### NeoPets ##################################

// ##### MLB Showdown ##############################

// ##### Star Wars TCG ##############################

// ##### Star Wars RPG ##############################

// ##### Star Wars Minis ##############################

// ##### d20 Modern #################################

// ##### d20 System #################################

// ##### GI Joe ##############################

// ##### Other banners ################################# 

And that's just the major commentary text. As I've said before, these boards are much like having 12 different boards tied at the hip - but somehow it works. I've very proud of my PHPINCLUDE_START template even if it's the one part of the boards the users never see.

Erwin 10-29-2004 01:49 AM

Looks intriguing. :) There are some load liabilities using phpinclude when you could be using global.php but if you're wanting to maintain Jelsoft official vB.com support, you do what you can. :)

Erwin 10-29-2004 01:51 AM

Quote:

Originally Posted by filburt1
57 in php_include_start, 80 in php_include_end. However, both of those have require() statements in which the required files are hundreds of lines long. I also haven't modified a single line of vB code.

Really? How do you integrate your points system without file modification?

Michael Morris 10-29-2004 02:00 AM

The Jelsoft support concern is definitely a valid one, but we have modified the code to allow forum banners. The changes are minor and can be undone in an hour or so if need be, but they are there.

I suppose I could require it in global.php, but I'm constantly upgrading the thing and as I said I don't have FTP access to the server, which I sorta would need to put it in an include file.

Logikos 10-29-2004 02:46 PM

I never touch my include template. Everything is file modded for me. ^^

Xenon 10-29-2004 04:01 PM

i think the combination is best

phpinclude can be a strong way to make some changes, but there are things which shouldn't be in that template ;)

AlexanderT 10-29-2004 06:25 PM

perhaps we should make a list of when phpinclude is especially useful and when definitely not ;) Thinking in more practical terms; it is obvious that mysql queries should be left out from phpinclude, but is it obvious to everyone why phpinclude could be still useful?

Brad 10-29-2004 06:30 PM

Phpinclude should not be used for calling templates imho, seeing how you have to hack the files to get the new template in the cache list anyway. Query's are fine in phpinclude, it just boils down to what the query dose as with hacking.

We really need to do some testing with phpinclude to see how much of an impact it has on resources over placing code directly into the files.

Brad 10-29-2004 06:40 PM

Ok I re-applied some stock vB code for de-buging to the phpinclude_start template, try this little hacket out and see how much time/memory your phpinclude_start template is eating up.

In /forumroot/global.php find:

PHP Code:

// #############################################################################
// parse PHP include
if (!is_demo_mode())
{
    @
ob_start();
    eval(
fetch_template('phpinclude_start', -10));
    
$phpinclude_output = @ob_get_contents();
    @
ob_end_clean();


Replace with:

PHP Code:

// #############################################################################
// parse PHP include
if (!is_demo_mode())
{
    if (
DB_QUERIES)
    {
        
// Time for phpinclude_start template
        
echo('Parsing phpinclude_start\n');
        
$pageendtime microtime();
        
$starttime explode(' '$pagestarttime);
        
$endtime explode(' '$pageendtime);
        
$beforetime $endtime[0] - $starttime[0] + $endtime[1] - $starttime[1];
        echo(
'Time before: $beforetime\n');
        if (
function_exists('memory_get_usage'))
        {
            echo(
'Memory Before Phpinclude_start: ' number_format((memory_get_usage() / 1024)) . 'KB' ' \n');
        }
    }

        @
ob_start();
        eval(
fetch_template('phpinclude_start', -10));
        
$phpinclude_output = @ob_get_contents();
        @
ob_end_clean();

    if (
DB_QUERIES)
    {
        
// end phpinclude_start parse timer
        
$pageendtime microtime();
        
$starttime explode(' '$pagestarttime);
        
$endtime explode(' '$pageendtime);
        
$aftertime $endtime[0] - $starttime[0] + $endtime[1] - $starttime[1];
        echo(
'Time after:  $aftertime\n');
        echo(
'Time taken: ' . ($aftertime $beforetime) . '\n');
        if (
function_exists('memory_get_usage'))
        {
            echo(
'Memory After Phpinclude_start: ' number_format((memory_get_usage() / 1024)) . 'KB' ' \n');
        }
        echo(
'\n<hr />\n\n');
    }


Go into debug mode and get the stats per normal method.

neocorteqz 10-30-2004 04:44 AM

25

that's all i need. :)

keeps my stats in line

Code:

Page generated in 0.10032010 seconds (90.13% PHP - 9.87% MySQL) with 10 queries
DEBUG Mode OFF | GZIP ON (level 1) | 0.03 : 0.02 : 0.00 | No Uncached Templates


filburt1 10-30-2004 01:29 PM

Quote:

Originally Posted by Erwin
Really? How do you integrate your points system without file modification?

The templates have registration markings (nothing to do with user registration but more like print registration markings), and php_include_end uses regular expressions to scan the page output and modify it to add references to turtle dollars where necessary.

Xenon 10-30-2004 02:22 PM

quite interesting :)

i look forward to see your template/php include things importet inv b.org soon :)

Chris M 10-30-2004 02:28 PM

Quote:

Originally Posted by filburt1
The templates have registration markings (nothing to do with user registration but more like print registration markings), and php_include_end uses regular expressions to scan the page output and modify it to add references to turtle dollars where necessary.

Very clever filburt - A nice way of doing it :)

Satan

Oblivion Knight 10-30-2004 02:54 PM

I currently only have 17 lines of code in my phpinclude_start template.. 4 of which are opening and closing statements of what the 2 blocks of code do.

Erwin 10-30-2004 11:07 PM

Quote:

Originally Posted by filburt1
The templates have registration markings (nothing to do with user registration but more like print registration markings), and php_include_end uses regular expressions to scan the page output and modify it to add references to turtle dollars where necessary.

Ahhh... clever use of regex... :) However, there surely has to be a performance hit on a busy site. But it's clever.

filburt1 10-30-2004 11:30 PM

Quote:

Originally Posted by Erwin
Ahhh... clever use of regex... :) However, there surely has to be a performance hit on a busy site. But it's clever.

Any performance hit is worth the literally 1 minute required to upgrade my site when a new release of vBulletin is made.

Xenon 10-31-2004 11:44 AM

well you still have to upgrade the templates, and regarding my experinece, that's the part which takes the most time, during an upgrade (that's why i prefer to hack everything in files ^^)

filburt1 10-31-2004 03:07 PM

Quote:

Originally Posted by Xenon
well you still have to upgrade the templates, and regarding my experinece, that's the part which takes the most time, during an upgrade (that's why i prefer to hack everything in files ^^)

I've completely rewritten many of the major templates (forumhome, showthread, and even quick reply's templates) so it doesn't really affect me.

Xenon 10-31-2004 05:21 PM

hmm, ok ^^

Tigga 11-01-2004 02:28 AM

Never touched mine. :)


All times are GMT. The time now is 11:59 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.01288 seconds
  • Memory Usage 1,861KB
  • 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
  • (1)bbcode_code_printable
  • (4)bbcode_php_printable
  • (8)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (31)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete